-
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.
-
llvm-project
The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
You can absolutely do this with: https://github.com/RJVB/sse_mathfun
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...
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...
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
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.