I've got a function. I want to scale the X-axis in a weird way. I want value of h = 10^-4 to appear in the middle of X-axis.

In my plot, shown below, we can't see that function is decreasing. How can I achieve my goal?

Function fn3 is deacreasing in interval 0 < h < 10^-4 and increasing in the interval 10^-4 < h <= 1.

enter image description here

  • 1
    $\begingroup$ Why can't you just adjust the plot range with PlotRange? Also, it's better if you write you code instead of pasting the image. Add the values of parameters for which you want to plot the function. $\endgroup$ – K.J. Oct 14 '18 at 12:55
  • $\begingroup$ Can you please tell me how to do it ? I just started with mathematica. $\endgroup$ – XYZCODE123 Oct 14 '18 at 13:08
  • 1
    $\begingroup$ Link to the documentation: PlotRange. As an additional option to your plot command add (for example) PlotRange->{{10^-5,10^-3}, {0, 0.1} }. You have to try with different plot ranges to get what you want. $\endgroup$ – K.J. Oct 14 '18 at 13:14

I think you can get the kind of plot you want with LogLogPlot. Like so:

fn3[h_, ϵ_] := (2 ϵ/h + h/2) Cos[1]
With[{ϵ = 10^-8/4}, LogLogPlot[fn3[h, ϵ], {h, 10^-10, 10}]]



  1. It would have been helpful if you had given the value of ϵ which minimizes your function at h = 10^-4. It would have saved me the effort of computing it.
  2. Your function fn3 can be written in the simpler way I show in this answer.
| improve this answer | |
  • $\begingroup$ The value you give for epsilon is just Solve[fun3'[10^-4] == 0, epsilon][[1]] $\endgroup$ – Bob Hanlon Oct 14 '18 at 15:38
  • $\begingroup$ @BobHanlon. That'a basically what I did. However, the OP must have had the value of ϵ at hand and should have provided it. $\endgroup$ – m_goldberg Oct 14 '18 at 21:13

Amplifying on m_goldberg's answer

Clear[fun3, h]



(* 0.540302 *)

use of Abs is unnecessary. Or just use Set rather than SetDelayed in defining fun3

fun3[h_] = (2*epsilon*Abs[Cos[1]]/h) + (h*Abs[Cos[1]]/2) // Simplify

(* ((4 epsilon + h^2) Cos[1])/(2 h) *)

When the minimum occurs, the derivative is zero. The value of epsilon for fun3 to have a minimum at 10^-4 is given by

eps = Solve[fun3'[10^-4] == 0, epsilon][[1]]

(* {epsilon -> 1/400000000} *)

The minimum is

fun3[10^-4] /. eps

(* Cos[1]/10000 *)

% // N

(* 0.0000540302 *)

The PlotRange for a symmetric LogLogPlot is

{hmin, hmax} = h /. Solve[(fun3[h] == fun3[1]) /. eps, h] // Sort

(* {1/100000000, 1} *)

Using these values

p1 = LogLogPlot[fun3[h] /. eps, {h, hmin, hmax}]

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.