Student Support Forum: 'Strange behavior from Evaluate[]' topicStudent Support Forum > General > Archives > "Strange behavior from Evaluate[]"

 Next Comment > Help | Reply To Topic
 Author Comment/Response user1639133 02/28/13 11:17am So I'm using Mathematica to numerically solve a series of coupled ODEs to get some parameters along a curve. NDSolve outputs InterpolationFunctions, which plot just fine and yield the correct solution to the problem. However, I also want to integrate some of these resulting parameters along the curve, and this is where I run into problems. It seems like defining a function which contains an Evaluate[] expression breaks NIntegrate. Example: Evaluate[k1[Log[5]] /. geod] gives {2.71224*10^-11} But NIntegrate[Evaluate[k1[x1] /. geod], {x1, Log[5], Log[7]}] or NIntegrate[(Evaluate[k1[x1] /. geod])[[1]], {x1, Log[5], Log[7]}] outputs NIntegrate::inumr: The integrand InterpolatingFunction[{{1.39731,2.05268}},{4,23,1,{48},{4},0,0,0,0,Automatic},<<1>>,{DeveloperPackedArrayForm,{0,2,<<46>>,96},{3.78076*10^-11,-5.89131*10^-11,3.78072*10^-11,<<45>>,3.1389*10^-11,-4.91733*10^-11,<<46>>}},{Automatic}][<<1>>] has evaluated to non-numerical values for all sampling points in the region with boundaries {{Log[5],Log[7]}}. >> I also seem to run into trouble quickly when I wrap Evaluate[] statements inside function definitions (Func[x_] := ...). Is there a canonical procedure for dealing with this? The Evaluate[] routine itself appears buggy, as in the following example: tstarg[x1_] := 1/(Evaluate[k1[x1] /. geod]) tstarg[2][[1]] outputs 6.87121*10^10 whereas tstarg[x1_] := (Evaluate[k1[x1] /. geod]) tstarg[2][[1]] outputs InterpolatingFunction[{{1.39731, 2.05268}}, <>][ InterpolatingFunction[{{1.39731, 2.05628}}, <>]] Seems pretty fishy to me but I really hope that this can be made to work. Cheers, - user1639133 URL: ,

 Subject (listing for 'Strange behavior from Evaluate[]') Author Date Posted Strange behavior from Evaluate[] user1639133 02/28/13 11:17am Re: Strange behavior from Evaluate[] Forum Modera... 02/28/13 11:51am Re: Strange behavior from Evaluate[] Bill Simpson 02/28/13 12:11pm
 Next Comment > Help | Reply To Topic