animation
- To: mathgroup at smc.vnet.net
- Subject: [mg69761] animation
- From: dimmechan at yahoo.com
- 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]]] 1.005450455076402 Here is its numerical estimation with the option Method->Oscillatory activated. NIntegrate[f[x], {x, 0, Infinity}, Method -> Oscillatory] 1.005450455076402 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, 15000}}, 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 anframe[n_]:=intframe[n] 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