Group Abstract Group Abstract

Message Boards Message Boards

Find the Maximum of a function calculated numerically?

Posted 9 years ago
Attachments:
POSTED BY: Owen Huff
3 Replies

If you decide to use FindMaximum, then the function you put inside it should be defined to only take numeric arguments. For example, f[t_?NumberQ] or else FindMaximum will try to differentiate it symbolically.

POSTED BY: Frank Kampas
Posted 9 years ago

Okay thank you very much.

POSTED BY: Owen Huff
Posted 9 years ago

If you look at the value that you assign to x from your NDSolve you will see that it is {{r->stuff,theta->morestuff}}.

That means there is an extra layer of {} in each of your subsequent uses of /.x and you need to either do NDSolve[stuff][[1]] or you need to do x[[1]] to eliminate that extra layer. That makes your error message go away and all that remains is a warning about not quite being able to provide you with expected precision, but I think that can be ignored in this case.

You need to do the same thing with your y and NDSolve in your second example.

With those your problems are solved.

POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard