Post Reply 
[VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier"
03-24-2019, 09:08 PM
Post: #9
RE: [VA] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier"
(03-22-2019 08:04 AM)J-F Garnier Wrote:  Tier 5: Guru
In summary : Write a program or function cin(x) which has the defining property that cin(cin(cin(x))) = sin(x).
Once written, use it to tabulate cin(x) for x = 0.0, 0.2, 0.4, ..., 1.0

...
Still searching for a better one...

(03-23-2019 04:03 PM)Albert Chan Wrote:  cin(x) should be an odd function, shape like sin(x), with value between sin(x) and x

For domain [-pi/2, pi/2], cin(x) ≈ (1 + x²/9) sin(x)

Example:

sin(½) = 0.4794255386
cin(cin(cin(½))) = 0.4791650974, relative error ~ -0.05%

sin(cin(½)) ≈ 0.473044
cin(sin(½)) ≈ 0.473050

Since cin(x) is an odd function, its Taylor expansion can be written as cin(x)=x+a*x^3+b*x^5+...
So my approach was to build the Taylor expansion of cin(cin(cin(x))) and identify it to the well known sinus expansion sin(x)=x-x^3/3!+x^5/5!...
The x^3 term is easy to calculate and is just -(1/3!)/3=-1/18, in agreement with Albert's approximation (-1/3!+1/9).
The best I could calculate (by hand) was the x^5 term. Then I search for the x^7 term by try-and-error to minimize the error.
Here is my best approximation and results showing cin(cin(cin(x))) and sin(x):

10 ! SSMC24
30 A=-1/18 @ B=-7/1080 @ C=-.0015
40 DEF FNC(X)=X+A*X^3+B*X^5+C*X^7
50 FOR X=.1 TO 1 STEP .1
60 PRINT X;FNC(FNC(FNC(X)));SIN(X)
70 NEXT X

> RUN
.1 9.98334166706E-2 9.98334166468E-2
.2 .198669334313 .198669330795
.3 .295520279883 .295520206661
.4 .38941902196 .389418342309
.5 .479429531682 .479425538604
.6 .564659801456 .564642473395
.7 .644278060315 .644217687238
.8 .717533814261 .7173560909
.9 .783784102052 .783326909627
1 .842523170608 .841470984808

Another approach?

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] Short & Sweet Math Challenge #24: "2019 Spring Special 5-tier" - J-F Garnier - 03-24-2019 09:08 PM



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