Howdy! I’m new to the forums, but I’m having some trouble with a script I’m writing, so I thought I’d see if the community can help. I’m solving a set of second order differential equations using NDSolve and I’m trying to extract the maximum values of a specific one of the interpolating functions produced, but I keep getting an error message saying something along the lines of “the function value {0.132074} is not a real number at {t} = {2.}”. I know that the function exists at that point because it is continuous and I can put t=2 in to get that value out.
Any ideas on how to get the value to resolve? Any help is appreciated!
Thanks for the help! What is the reason for this though? Is it because NDSolve spits out {InterpolatingFunction} rather than InterpolatingFunction without brackets that you have to specify First?
Edit: On further examination, I have determined that this is the case. Thanks again for the help!
Well, I simply saw the error message itself saying
FindMaximum::nrnum: "The function value {0.188062918964778} is not a real number at {t} = {2.`}."
And saw the extra {} around the number above. Since the number itself was clearly a real number, then it was the {} that was confusing it. It saw something with List Header when it was expecting a number.
The only place this {} could come from is from the solution itself, which has the extra {} around it.
{{x1 -> InterpolationFunction)}}
Using First@NDSolve removed this extra {}.
One might say that may be FindMaximum should have sorted this extra {} out itself internally and Falttened it or did FIrst@ itself and such, but I am sure there are good reason why it did not do that, as that can break other things.