SynthMaker

Taylor expansion

Archive · 2005 15 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

unkargherth ·

After PM'ing jorge, we though could be interesting to start a topic on this, so clever people here could help others to find solutions to ( by now) uninmplemented math functionality in SM and/or to find new/optimal ways of doing some things

So here is mi litle contribution: Making some investigationon Biquad filters, i've found that to make a new implementation i need some math primitives not implemented at this moment. After a litle research i've found the following

Hyperbolyc Sine/Cosine: Useful in Lowshelf/Highsghelve biquads. Taylor expansion follow

sinh(x)=x+ 0.1666666*x^3+0.0833333*x^7+0.0001984*x^7

reasonably good aproximation in the interval -1<x<1, max error in the interval 0.075

cosh(x)=1+0.5*x^2+0.0416666*x^4+0.0013888*x^6;

good aproximation in the interval -2<x<2, max error in the interval 0.006

I also repost, for the ones who missed, the taylor expansion for exp(x)

exp(x)=1+x+0.5*x^2+ 0.1666666*x^3+0.0416666*x^4+0.0083*x^5+ 0.0013888*x^6+0.0001984*x^7

Good approx. in interval -2<x<2. max error 0.008

OK boys and girls.. now is your turn!!!

lalo ·

beautiful!

what's a Taylor series ? 😀 ..and who's Taylor ? 😀

not the duran duran's bass player i guess 😀

lalo

Shifrin ·

You could check out :-

http://en.wikipedia.org/wiki/Taylor%27s_theorem

and :-

http://en.wikipedia.org/wiki/Taylor_expansion

The maths isn't as hard as it might look. I'd have a go at trying to explain myself but it's a very long time since I did such stuff. I wish I'd kept my hand in with maths (did it at uni) but I've not looked at it for several years now - still got all my lecture notes etc though!

Shif.

NothanUmber ·

Just rediscovered MuPad for those cases (good for people who don't own one of the "bigger" math packages). Download and install

ftp://ftp.mupad.de/MuPAD/distrib/window ... ab_253.exe

and enter e.g.

taylor(5^x,x=0,10)

in order to develop the taylor series for 5^x around zero of order 10. (Disable "Pretty Print" for easier copy'n'paste and ignore the O(somevalue) at the end - that's just the order of the supressed rest that doesn't bother you). Then replace all evental ln-constants with their approximated values and wrap the result inside a "simplify"

e.g. 1 + x*ln(5) + 1/2*x^2*ln(5)^2 + 1/6*x^3*ln(5)^3 + 1/24*x^4*ln(5)^4 + 1/120\ *x^5*ln(5)^5 + 1/720*x^6*ln(5)^6 + 1/5040*x^7*ln(5)^7 + 1/40320*x^8*ln(5)^\ 8 + 1/362880*x^9*ln(5)^9 with ln(5) = 1,6094379124341003746007593332262

becomes:

simplify(1 + x*1.6094379124341003746007593332262 + 1/2*x^2*1.6094379124341003746007593332262^2 + 1/6*x^3*1.6094379124341003746007593332262^3 + 1/24*x^4*1.6094379124341003746007593332262^4 + 1/120\ *x^5*1.6094379124341003746007593332262^5 + 1/720*x^6*1.6094379124341003746007593332262^6 + 1/5040*x^7*1.6094379124341003746007593332262^7 + 1/40320*x^8*1.6094379124341003746007593332262^\ 8 + 1/362880*x^9*1.6094379124341003746007593332262^9)

which gives the result:

1.609437912*x + 1.295145197*x^2 + 0.694818594*x^3 + 0.2795668469*x^4 + 0.0\ 8998909649*x^5 + 0.02413864393*x^6 + 0.005549949814*x^7 + 0.001116537455*x\ ^8 + 0.0001996664124*x^9 + 1

which you can directly use in SynthMaker 🙂 (write x^3 as x*x*x etc.)

(Perhaps there is an even simpler way, e.g. in Maple there is an approximate-function that automatically approximates values like the constant lns with a given precision. So MuPad-gurus step forward 😉 )

NothanUmber

Sk ·

If you want to have fun with Taylor series, try the "taylortool" in Matlab 🙂

stefan ·

This was a useful page to me right now http://www3.sympatico.ca/mcomeau/webpub ... eg/reg.htm

To make a polynomial estimation of a given series of numbers. Very useful imo.

ake ·

If you want to have fun with math 🙂 maxima is a great free tool

http://maxima.sourceforge.net/

Åke

hansdump ·

In the meantime, it was so boring here, that I made a little asm optimized taylor exp version of yours here!

Feel free to use it, tell me if there´s still some possibility to optimize...

bye H.

//asm code here: streamin x;streamout y; float x2=0; float x3=0; float x4=0; float x5=0; float x6=0; float x7=0; float F1=1; float F0P5=0.5; float F0P166667=0.166667; float F0P0416667=0.0416667; float F0P00833333=0.00833333; float F0P00138889=0.00138889; float F0P000198413=0.000198413;

movaps xmm0,x; mulps xmm0,x; movaps x2,xmm0; mulps xmm0,x; movaps x3,xmm0; mulps xmm0,x; movaps x4,xmm0; mulps xmm0,x; movaps x5,xmm0; mulps xmm0,x; movaps x6,xmm0; mulps xmm0,x; movaps x7,xmm0;

movaps xmm0,F1; addps xmm0,x;

movaps xmm1,F0P5; mulps xmm1,x2; addps xmm0,xmm1;

movaps xmm1,F0P166667; mulps xmm1,x3; addps xmm0,xmm1;

movaps xmm1,F0P0416667; mulps xmm1,x4; addps xmm0,xmm1;

movaps xmm1,F0P00833333; mulps xmm1,x5; addps xmm0,xmm1;

movaps xmm1,F0P00138889; mulps xmm1,x6; addps xmm0,xmm1;

movaps xmm1,F0P000198413; mulps xmm1,x7; addps xmm0,xmm1;

movaps y,xmm0;

hansdump ·

I only wanna say that you can further improve this by the horner scheme but sry I´m too lazy now to implement this 😇

exp(x) approximatly = 1+(1+(1/2+(1/6+(1/24+(1/120+(1/720+1/5040*x)*x)*x)*x)*x)*x)*x

H.

MichaelBenjamin ·

heres the asm:

streamin x; streamout exp; float F1=1; float F0P5=0.5; float F0P16666667=0.16666667; float F0P041666668=0.041666668; float F0P0083333338=0.0083333338; float F0P0013888889=0.0013888889; float F0P0001984127=0.0001984127;

movaps xmm0,F0P0001984127; movaps xmm7,x;

mulps xmm0,xmm7; addps xmm0,F0P0013888889; mulps xmm0,xmm7; addps xmm0,F0P0083333338; mulps xmm0,xmm7; addps xmm0,F0P041666668; mulps xmm0,xmm7; addps xmm0,F0P16666667; mulps xmm0,xmm7; addps xmm0,F0P5; mulps xmm0,xmm7; addps xmm0,F1;

movaps exp,xmm0;

hansdump ·

hehe! I like this forum! 😈

H.

MegaHurtz ·

is this a more efficient way, as opposed to (e)x?

infuzion ·

MegaHurtz wrote: is this a more efficient way, as opposed to (e)x?

Is there such a function in SM? I don't think so offhand.

MB wins the award! Should go in the WiKi. 😉 😇

MegaHurtz ·

I don`t get wich power of what this is? Somebody?

hansdump ·

octave says:

exp(1)=2.7183

wikipedia says:

tanh(x)=1-2/(exp(2x)+1)

http://mathworld.wolfram.com/MaclaurinSeries.html

H.

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.