Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- T0(x) = 1
- T1(x) = x
- Tn+1(x) = 2*x*Tn(x) - Tn-1(x)
- T0(x) = 1
- T1(x) = x
- T2(x) = 2x^2 - 1
- T3(x) = 4x^3 - 3 x
- T4(x) = 8x^4 - 8x^2 + 1
- T5(x) = 16x^5 - 20x^3 + 5x
- T10(x) = 512x^10 - 1280x^8 + 1120x^6 - 400x^4 + 50x^2 - 1
- #~ChebyshevT~x&
- ChebyshevT
- polchebyshev
- f(n)=if(n<2,x^n,2*x*f(n-1)-f(n-2))
- 1a2,qi{0X$+2f*@.-}*;`
- {1a2,@{0X$+2f*@.-}*;}
- lFTi:"0yhEbFFh-]x
- l % Push 1
- FT % Push [0 1]. These are the first two polynomials
- i:" % Input n. Do the following n times
- 0 % Push 0
- y % Duplicate most recent polynomial
- h % Concatenate: prepends 0 to that polynomial
- E % Multiply coefficients by 2
- b % Bubble up. This moves second-most recent polynomial to top
- FF % Push [0 0]
- h % Concatenate: appends [0 0] to that polynomial
- - % Subtract coefficients
- ] % End
- x % Delete. Implicitly display
- Cr1µ’ßḤ0;_’’$ß$µỊ?
- RḤ’÷Ḥ-*ḞÆṛæ«’µ1Ṡ?
- Cr1µ’ßḤ0;_’’$ß$µỊ? Input: integer n
- Ị Insignificant - abs(n) <= 1
- If true, n = 0 or n = 1
- µ Monadic chain
- C Complement, 1-x
- r1 Range to 1
- Else
- µ Monadic chain
- ’ Decrement
- ß Call itself recursively
- Ḥ Double
- 0; Prepend 0
- _ Subtract with
- $ Monadic chain
- ’’ Decrement twice
- $ Monadic chain
- ß Call itself recursively
- f=->n{x=Polynomial.new 0,1;n<2?[1,x][n]:2*x*f[n-1]-f[n-2]}
- (0>.<:)2&*1:p.@;9:o._1^+:%~1+2*i.
- (0&,1:)`(-&2((-,&0 0)~2*0&,)&$:<:)@.(>&1)
- f(n,x)==(n<2=>x^n;2*x*f(n-1,x)-f(n-2,x))
- (9) -> for i in [0,1,2,3,4,5,10] repeat output ["f(y)",i,"=", f(i,y)]
- ["f(y)",0,"=",1]
- ["f(y)",1,"=",y]
- 2
- ["f(y)",2,"=",2y - 1]
- 3
- ["f(y)",3,"=",4y - 3y]
- 4 2
- ["f(y)",4,"=",8y - 8y + 1]
- 5 3
- ["f(y)",5,"=",16y - 20y + 5y]
- 10 8 6 4 2
- ["f(y)",10,"=",512y - 1280y + 1120y - 400y + 50y - 1]
- Type: Void
- (9) -> o:=rule cos(n*%y)==f(n,cos(%y))
- (9) cos(%y n) == 'f(n,cos(%y))
- Type: RewriteRule(Integer,Integer,Expression Integer)
- Time: 0 sec
- (10) -> b:=o cos(20*x)
- (10)
- 20 18 16 14
- 524288cos(x) - 2621440cos(x) + 5570560cos(x) - 6553600cos(x)
- +
- 12 10 8 6
- 4659200cos(x) - 2050048cos(x) + 549120cos(x) - 84480cos(x)
- +
- 4 2
- 6600cos(x) - 200cos(x) + 1
- Type: Expression Integer
- Time: 0.48 (EV) + 0.02 (OT) + 0.10 (GC) = 0.60 sec
- f=n=>n?n>1?[0,...f(n-1)].map((e,i)=>e+e-(f(n-2)[i]||0)):[0,1]:[1]
- n=>[...Array(n+1)].map(g=(m=n,i)=>i<0|i>m?0:m<2?i^m^1:g(m-1,i-1)*2-g(m-2,i))
- f=(n,a=[1],b=[0,1])=>n?f(n-1,b,[0,...b].map((e,i)=>e+e-(a[i]||0))):a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement