Implementing Cosine in C from Scratch

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • sse_mathfun

    an extended version of Julien Pommier's sse_mathfun

  • You can absolutely do this with: https://github.com/RJVB/sse_mathfun

  • scheme

    An R7RS Scheme implemented in WebAssembly

  • I went through the same exercise implementing trig functions for scheme in webassembly...

    It was a rabbit hole for sure

    https://github.com/PollRobots/scheme/blob/main/scheme.wasm/s...

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • sectorc

    A C Compiler that fits in the 512 byte boot sector of an x86 machine

  • How good do you need it? Lol.

    This is the approximation that I used in for the animated sinwave example for SectorC:

    y ~= 100 + (x*(157 - x)) >> 7

    https://github.com/xorvoid/sectorc/blob/main/examples/sinwav...

  • Seems worth noting that although the usual algorithm for finding the minimax polynomial is the very old Remez algorithm, I'm playing with a minimax finder that relies on what I think is a novel algorithm. My algorithm seems better than Remez, and certainly beats it in many cases, even though I don't have an analysis of the algorithm.

    The main idea is to use linear programming with some chosen points from the interval to look for the polynomial that approximates the chosen function over that interval. Unlike Remez, this enables control over which individual point from the interval are chosen as representatives, which enables avoiding ill-behaved points. An example of where this leads to improvements over Remez is when optimizing relative error: Remez would trip over zeros of the function, because they cause singularities in the relative error, however my algorithm works (by avoiding ill-behaved points) as long as the discontinuities are removable.

    My algorithm is also a lot more flexible than Remez', for example it allows optimizing over multiple intervals instead of a single one.

    The Git repo of the (still in-progress) project is here: https://gitlab.com/nsajko/FindMinimaxPolynomial.jl

    The Julia package is already registered (installable from the official Julia registry): https://juliahub.com/ui/Packages/FindMinimaxPolynomial/kNIo8...

  • llvm-project

    The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.

  • We do employ this range reduction strategy in a more accurate way for trig functions in LLVM libc:

      - with FMA instructions: https://github.com/llvm/llvm-project/blob/main/libc/src/math/generic/range_reduction_fma.h

  • AvxMath

  • I once did that as well: https://github.com/Const-me/AvxMath/blob/master/AvxMath/AvxM...

    The method is different, and the OP hasn’t mentioned it — high-degree minimax polynomial approximation.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts