Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive


  • To: mathgroup at
  • Subject: [mg69761] animation
  • From: dimmechan at
  • Date: Fri, 22 Sep 2006 01:04:40 -0400 (EDT)

Dear everyone,

I have the following function

f[x_] := BesselJ[0, x]/Sqrt[(x/10)^2 + 1]

Here is its integral over the range {x,0,infinity}

Timing[Integrate[f[x], {x, 0, Infinity}]]
{4.282*Second, 10*BesselI[0, 5]*BesselK[0, 5]}
a = N[%[[2]]]

Here is its numerical estimation with the option
Method->Oscillatory activated.

NIntegrate[f[x], {x, 0, Infinity}, Method -> Oscillatory]

Here I define a pure function intframe which give for
different values of the MaxRecursion option the
numerical approximation of the integral, along with the
exact value a, the needing time for the estimation and the
sampled points by NIntegrate.

intframe = Block[{Message}, ListPlot[Reap[NIntegrate[f[x], {x, 0,
Infinity}, MaxRecursion -> #1, EvaluationMonitor :> Sow[x]]][[
2,1]], Axes -> False, Frame -> True, PlotRange -> {{0, 2500}, {0,
PlotLabel -> StringJoin["exact: ", ToString[a], ", MaxRecursion: ",
ToString[#1], ", sampled points:",
ToString[Length[Reap[NIntegrate[f[x], {x, 0, Infinity}, MaxRecursion ->
#1, EvaluationMonitor :> Sow[x]]][[2,1]]]],
"\n {time, approximation}: ", ToString[Timing[NIntegrate[f[x], {x, 0,
Infinity}, MaxRecursion -> #1]]]],
ImageSize -> {600, 400}, TextStyle -> {FontFamily -> "Times", FontSize
-> 16},
FrameTicks -> {Automatic, Automatic, None, None}]] & ;

It works fine, as you can see

intframe /@ Range[4, 16,2]

What I need now is to make an animation of this graph.
I define


and I use

Block[{Message}, Animate[anframe[n], {n, 1, 10,
1}]*SelectionMove[EvaluationNotebook[], All, GeneratedCell]*
FrontEndTokenExecute["OpenCloseGroup"]; Pause[0.1];
FrontEndExecute[{FrontEnd`SelectionAnimate[200, AnimationDisplayTime ->
0.1, AnimationDirection -> ForwardBackward]}]]

(the last command is a slightly modification for my needs of a
command that appeared yesterday on a David's Park post and on
private communacation of myself with him).

Any comments/suggestions/advice/insight?

Dimitris Anagnostou

  • Prev by Date: Re: Add Quotation Marks to Data in a file
  • Next by Date: Re: does the following code shut down anyone else's kernel? - why?
  • Previous by thread: Re: Differentiation problem/bug?
  • Next by thread: trivial question