3 ms·
It seems to me that it makes more sense to approximate sinPi(x) = sin(pi x) scaling[x_] := 8/3 (x - x^3) indices = {0, 2, 4, 6, 8, 10} inner[g_,
by grondilu 9y ago
It seems to me that it makes more sense to approximate sinPi(x) = sin(pi x)
scaling[x_] := 8/3 (x - x^3)
indices = {0, 2, 4, 6, 8, 10}
inner[g_, h_] := NIntegrate[g h/Sqrt[1 - x^2], {x, -1, 1}, WorkingPrecision-> 40, PrecisionGoal-> 20]
cheb[i_] := inner[ChebyshevT[i, x], Sin[Pi x]/scaling[x]]/inner[ChebyshevT[i,x], ChebyshevT[i, x]]
coeff = cheb /@ indices
apxi[i_] := coeff[[1 + i/2]]ChebyshevT[i, x]
sinPi[x_] := Total[apxi /@ indices]scaling[x]
Plot[sinPi[x], {x, -1, 1}]
N[Simplify[sinPi[x]/(1-x^2)], 9]
This gives the following polynomial expression for sinPi(x)/(1-x²):
3.14159264x -2.02611946x^3 +0.524036151x^5 -0.0751872634x^7 +0.00686018743x^9-0.000385937753x^11
So the function becomes:
sub sinPi($x) {
my $x2 = $x²;
$x * (1 - $x2) *
reduce * * $x2 + *,
-0.000385937753,
0.00686018743,
-0.0751872634,
0.524036151,
-2.02611946,
3.14159264
}
That being said, cool stuff, definitely.