Mathematica Finding Max/Min Y-Axis Values in Mathematica Plots

  • Thread starter Thread starter natski
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
Mathematica users are discussing how to accurately determine the maximum and minimum y-axis values on a 2D plot. The original poster is struggling with the Maximize function, which incorrectly identifies imaginary components in their function, despite it being plotted correctly. Suggestions include using the FindMaximum and FindMinimum functions, particularly with specified x_min and x_max options, as these may yield better results. There's a caution that relying on the Plot function for extracting max and min values can lead to inaccuracies due to potential errors in the plotting process. The discussion also mentions the possibility of using the Algebra`ReIm` package for additional tools that may assist in handling real-valued functions. Overall, the focus is on finding reliable methods to extract precise maximum and minimum values from complex functions in Mathematica.
natski
Messages
262
Reaction score
2
I wanted to know whether it was possible for Mathematica to give you an exact read out of the maximum and minimum y-axis values on a 2D plot?

I have tried Maximize function but it seems to think there are imaginery parts in my function (which there are not or how would it plot the function in the first place) and so refuses to work out the maximum. Even if I try and Maximise the real part of my function it doesn't work.

What I'm looking for is a way to plot the graph and then simply read off the max and min values with speed and accuracy and perhaps even form another plot of contrast (max-min) vs another variable in the formula.

Thanks
Natski
 
Physics news on Phys.org
It might help us you tell us what your function is, if for whatever reason you can't than I can only give you some general advice.

First you could try something like:
Code:
Re[your_function]

This should get read of the imaginery parts.

Secondly it might be a good idea to use the FindMaximum and FindMinimum functions (the FindMaximum is new in version 5.0 so if you have an older version perhaps FindMinimum[-your_function] would be a good alternative) with the x_min,x_max options of your Plot (something like this:
Code:
FindMinimum[f, {x,x_0 ,x_min , x_max}]
). I however don't remember if this function returns one or more minimums (maximums) so you might think about using other mathods such as deriveing the function if you only get one minimum when there are obvieusly more. As for finding the max and min from a graph I think it's hard to do an acctually not a good idea in the first place becouse the Plot function isn't meant to be used in such a way and could in some cases also produce errors (becouse of the PlotPoints option ).

If nothing helps try posting agein and explain the problem in more detail or try finding help at:

http://www.wolfram.com/
 
Last edited:
The function is several pages long and repeatedly has parts like:
(1.3+0.0i)sin(...)

So there are already no imaginery parts. However, if I take the real part of my function, the same expression is produced, as in 0.0i. So when I try and use maximize function, it tells me there are imaginery parts, even though I am using the specific Real part!

Natski
 
Have you thought about using the <<Algebra`ReIm` package? There are some things there that you might find useful (perhaps RealValued).
 

Similar threads

Back
Top