0
$\begingroup$

I'm going through question 5 here, where they ask to approximate the integral $$I=\int_0^a \cos(t^2) \mathrm{d}t $$ with $a=\sqrt{\pi/2}$. This integral can be expressed using Fresnel integrals as

Sqrt[\[Pi]/2] FresnelC[1]

and using N here gives the approximate value

0.977451

A similar value is obtained using Simpson's rule. However, the command

FindRoot[Evaluate[NIntegrate[Cos[t^2], {t, 0, x}] - 1.22505], {x, 1}]

results in the value

{x -> 1.25331}

which indeed looks like $\sqrt{\pi/2}$.

My question is then: which is the true value of $I$? Is it $I \approx 1.22505$ as they claim in the exercise (in which case I'd like to know why numerical integration suggests the other value), or is it $I \approx 0.977451$ as Mathematica first suggests (in which case I'd like to know why the FindRoot approach results in the other value)?

Thanks!

$\endgroup$
4
  • 1
    $\begingroup$ Something that might help you reason things out would be to look at the plot of your integral: Plot[Sqrt[π/2] FresnelC[Sqrt[2/π] x], {x, 0, 2}] $\endgroup$ Mar 19, 2017 at 1:24
  • $\begingroup$ @J.M. I see, so it's $I \approx 0.977451$ indeed. Thanks. Nevertheless, I'm still curious as to why `FindRoot' and the exercise itself suggest the impossible value $1.22505$. $\endgroup$
    – user1337
    Mar 19, 2017 at 1:28
  • 2
    $\begingroup$ Your FindRoot command is searching for a value for x to make the integral as close to 1.22505 as possible. What point on your plot has a y-coordinate closest to 1.22505? The number in the exercise is probably a typo (copied the wrong numeric value). $\endgroup$
    – Michael E2
    Mar 19, 2017 at 1:37
  • 1
    $\begingroup$ re: "results in the value". No it does not. It produces an error message which generally means the number it yields is garbage. You really should include such error messages in the question. $\endgroup$
    – george2079
    Mar 20, 2017 at 14:18

1 Answer 1

3
$\begingroup$

Just to illustrate the points made by MichaelE2 in the comments:

max = NIntegrate[Cos[x^2], {x, 0, Sqrt[Pi/2]}]
pt = {t, max} /. 
  Quiet@FindRoot[
    Evaluate[NIntegrate[Cos[x^2], {x, 0, t}] - max], {t, 1}]
Show[Plot[Cos[x^2], {x, 0, 2}], 
 Quiet@Plot[Evaluate[NIntegrate[Cos[x^2], {x, 0, t}]], {t, 0, 2}, 
   PlotStyle -> Red], GridLines -> {{Sqrt[Pi/2]}, {1.22505}}, 
 PlotRange -> {-1, 1.5}, Epilog -> {Black, PointSize[0.02], Point[pt]}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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