Group Abstract Group Abstract

Message Boards Message Boards

Find the Maximum of a function calculated numerically?

Posted 9 years ago

Hello, I'm trying to find the maximum height reached for a projectile being launched inside a rotating cylinder. I numerically solved the differential equations of motion for two different cases and made parametric plots of height, which is defined as the radius of the cylinder (1000) minus the position vector, versus angular position. However, I'm having trouble calculating the maximum of the height from the parametric plots I've made. Any ideas on how to do this? Thank you.

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

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
Posted 9 years ago

Okay thank you very much.

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