Powered by Starship v1.3
"When wil calc BC ever be useful to me?"
Sep 11 2024
7:57 PM

Today, I was working on some 3d matrix projection stuff for some simulation, and needed a simple sin() approximation. Because I was writing this in a non-compileime CBAS segment, I didn't have access to <math.h>, and was too lazy to add builtin trig functions. That's when I remembered: calc has a pretty simple way to approximate complicated functions with polynomials!

Even better, I didn't need an approximation that would work over all input values of theta - only between -pi/2 and pi/2, so a taylor series to three terms did the trick:

fn sin(float x) -> float:
    return x - (x*x*x/6) + (x*x*x*x*x/120);
end

:D

tags: programming math