So,
Here is a library of functions for common Taylor polynomial expansions. Initially I wrote it to see how it would perform against native Reaper functions, and also to get a dang error function in the system. While I tried to optimize them as much as I could, they are still about 40% slower than their native counterparts.
To use in your plugins, download the attached file, rename it to have the 'jsfx-inc' extension, plop it in your 'effects' folder, include the line "import taylor.jsfx-inc" after your sliders, then put a 't' in front of the expression you wish to use. Supported functions are
sin, cos, tan, asin, acos, atan, exp, erf
become
tsin, tcos, ttan, tasin, tacos, tatan, texp, terf
Two extra functions are included -
terf5 and
texp5 use an extra term for a small measure of added accuracy, if you so desire. All polynomials are otherwise 4-term expansions, except for cosine, which is 5. Convergence on cosine is iffy, even with 5 terms - I suggest using sin() instead, adding $pi/2 to your value.
example usage
Code:
tan_x = tan(x);
taylor_tan_x = ttan(x);
...
sigmoid = erf(x); // this is included in the library
taylor_sigmoid = terf(x);
Hope you find it interesting, if not useful.