2
$\begingroup$

I need to generate a table of Chebyshev expansion coefficients of trigonometric functions (in this case Cos[2 Pi t] to very high accuracy. Code is:

ClearAll["Global`*"]

m = 4;

f[t] = Cos[2 Pi t];
Tn[t] = ChebyshevT[j, 2*t - 1];
wt[t] = 1/Sqrt[t - t^2];    

p = Table[
   NIntegrate[f[t]*Tn[t]*wt[t], {t, 0, 1}]/(Pi/2.0), {j, 0, m - 1}];
p[[1]] = p[[1]]/2;

p

Where f[t] is the trigonometric function, Tn[t], is the shifted Chebyshev polynomial, w[t] is the weight function. How can I increase the precision of this numerical integration?

I apologize if this is a duplicate, but I've read dozens of past questions dealing with $MinPrecision, $MinAccuracy, PrecisionGoal, WorkingPrecision, etc. and I've been unable to increase the precision. I'm stuck at machine precision still!

$\endgroup$
  • $\begingroup$ you do know dividing by 2.0converts the result to machine precision regardless of what NIntegrate does.. WorkingPrecision -> 20 , PrecisionGoal -> 20 should do what you want if you make that an integer 2 $\endgroup$ – george2079 Nov 6 '14 at 19:30
  • $\begingroup$ @george2079 I did not know that, but now I do. Thank you! $\endgroup$ – gKirkland Nov 6 '14 at 22:15
  • 1
    $\begingroup$ I'd like to point out that Mathematica can do the calculation symbolically (ie, infinite precision) for $0\leq m\leq 6$ (and possibly higher). So you could just calculate the symbolic results and then apply N. $\endgroup$ – DumpsterDoofus Nov 7 '14 at 1:05
1
$\begingroup$

Your results are converted to MachinePrecision because you divide by the machine precision number Pi/2.0. You can get exact solutions with Integrate and use N. This will be more accurate than NIntegrate.

Block[{m = 4},
 p = Table[
    Integrate[f[t]*Tn[t]*wt[t], {t, 0, 1}]/(Pi/2), {j, 0, m - 1}];
 ]
p[[1]] = p[[1]]/2;

p
(*
  {-BesselJ[0, π],
   0,
   2 BesselJ[2, π],
   0}
*)

N[p, 20]
(*
  {0.30424217764409386420,
   0,
   0.97086786526301821941,
   0}
*)
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.