Post Reply 
[VA] SRC#006- Pi Day 2020 Special: A New Fast Way to Compute Pi
03-15-2020, 03:21 PM (This post was last modified: 03-15-2020 03:24 PM by J-F Garnier.)
Post: #9
RE: [VA] SRC#006- Pi Day 2020 Special: A New Fast Way to Compute Pi
(03-15-2020 02:42 PM)Albert Chan Wrote:  Below use multiple angle formula (4 times), \(\sin(5x) = 16 \sin^5 x - 20 \sin^3 x + 5 \sin x \)

Code:
10 FNM(X)=X*(5-X*X*(4+16*(1-X)*(1+X)))
20 FNT(X)=X*(1-X*X/6*(1-X*X/20))
30 FNS(X)=FNM(FNM(FNM(FNM(FNT(X/625)))))
40 FNP(X)=X+FNS(X)

>FNP(3)
3.14112000806
>FNP(RES)
3.14159265358

Nice and compact solution !

I needed to calculate 11 terms in the form u(n)=x^(2n+1)/(2n+1)!
each can be computed from the previous one by u(n) = u(n-1) * (x^2) / (2n*(2n+1)) that is 2 multiplications plus one division (I didn't optimized the factorial in my proposed solution). Total 33 mult/division operations.
Your solution needs 5 multiplications for FNM(X), called 4 times, plus the 4 multiplications and some divisions in FNT(X).

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [VA] SRC#006- Pi Day 2020 Special: A New Fast Way to Compute Pi - J-F Garnier - 03-15-2020 03:21 PM



User(s) browsing this thread: 1 Guest(s)