The reason your recursion is slow is because you used a naive approach instead of, perhaps, tail recursion.
@LaplaceAcademy Жыл бұрын
But anyways, there always exists a faster way than recursion of any type.
@holyshit922 Жыл бұрын
@@LaplaceAcademy there exists formula for Chebyshov polynomials Here is how i found it 1. From cosine of sum and cosine of difference derive recurrence relation for Chebyshov polynomials 2. Define exponential generating functiom 3. Plug it in recurrence relation 4. Solve nonhomogeneous linear differential equation of second order with constant coefficients and initial conditions (Here suitable method is Laplace transform in my opinion) 5. Calculate second derivative of solution of thiequation in step 4 6. Use Leibniz product rule to calculate nth derivative of exponential generating function of Chebyshov polynomial and evaluate it at zero After these steps we should get T_{n}(x) = sum({n \choose 2k}x^{n-2k}(x^2-1)^k,k=0..floor(n/2)) If we use binomial expansion to the (x^2-1)^k we will get T_{n}(x) = sum(binomial(n,2k)x^{n-2k}sum(binomial(k,m)x^{2m}(-1)^{k-m},m=0..k),k=0..floor(n/2)) So we will get double sum T_{n}(x) = sum(sum((-1)^{k-m}binomial(n,2k)binomial(k,m)x^{n+2m-2k},m=0..k),k=0..floor(n/2)) But how to calculate further I'm sure that it is possible to get single sum for all coefficients of Chebyshov polynomial but i dont know how to do it