# How to adjust PlotRange automatically depending on the value of the function?

Consider the following test function:

func[x_] = x^3 Exp[-x^2];


In general, it may be an arbitrary function without e.g. extrema.

I want to plot it:

LogLogPlot[func[x], {x, 0.01, 100}] Due to the exponential decrease, the automatic PlotRange is down to a very small values.

I want to cut it from below by say 10^-15, but also to adjust the maximal value such that it would correspond to say 1.5*Max[func[x]]. The only thing I know is to use PlotRange:

LogLogPlot[func[x], {x, 0.01, 100}, PlotRange -> {All, {10^-15, 2}}]


However, the second argument in {10^-15,2} is added by hand. Could you please tell me whether it is possible to make its evaluation automatic depending on the needs?

• Not sure how you chose $10^{-15}$ so I don't know how to do that algorithmically, but for the other end you could perhaps use NMaxValue[func[x], x] and an appropriate multiplier. Jun 2 at 13:18
• How should MMA know what your needs are? Jun 2 at 14:28

func[x_] = x^3 Exp[-x^2];