I have the following function:

$$f(x) = \frac{2\arctan(\sqrt{\omega^2 + 1} - \omega)}{1 + \frac{1}{2}\ln(1 + \omega^2) - \ln\omega}$$

And something strange happens when I am going to plot it with different PlotRange choice. Here is the plot according to the code

Plot[qbec[ω], {ω, 0, 3}, PlotRange -> Automatic]

enter image description here

And here is what happens when I plot it with the choice

Plot[qbec[ω], {ω, 0, 3}, PlotRange -> {0,2}]

enter image description here

P.s. Yes, in my case I called the function above as "qbec" because of some reason.

The fact is this: this function has to be plotted with three other functions together, and there is no problem in the final plot except for this "gap" or whatever it may be.

I NEED to choose a PlotRange of {0,3} because the plot needs to be clear, but when I do it, this function behaves bad. I already tried with PlotRange: Full, All and Automatic. No way to solve it.

Is there a trick or a way to fix it?

What I need is this function to start from $0$, as it shall.

Thank you!!


Here is a zoom for the second plot, in order to make you to see what I mean with "gap".

enter image description here

EDIT - qbec function

qbec[ω_] := ArcTan[1/ω]/(1 + 1/2*Log[(1 + ω^2)/ω^2])

So, as noticed the problem is that your function converges very slowly with ω approaching 0.:

LogLinearPlot[qbec[1/t], {t, 1, 10^25}
  , Frame -> True
  , PlotRangePadding -> Scaled[.05]
  , PlotRange -> {0, Automatic}
  , GridLines -> {None, {0}}
  , FrameLabel -> {"1/ω", "qbec[1/ω]"}

enter image description here

and is Indeterminate at x=0. So it may be tricky get that right automatically.

You can do this dirty trick though, just add a point at {0,0}:

    Plot[qbec[ω], {ω, 0., 3}
      , PlotRange -> {0, 2}
      , PlotStyle -> Thickness@.01
    ] /. Line[{pts__}] :> Line[{{0, 0}, pts}]
  , Plot[Sin[x] + 1, {x, 0, 3}
      , PlotStyle -> Red

Show and Plot[Sin are there to mimic your background case where you want to add more plots.

enter image description here

  • $\begingroup$ +1 More generally, qbec[0] = qbec[0.] = Limit[qbec[w], w -> 0] and Line[{pts__}] :> Line[{{0, qbec[0]}, pts}] $\endgroup$
    – Bob Hanlon
    Jun 27 '17 at 13:00
ParametricPlot[{Exp[-x], qbec[Exp[-x]]}, {x, -Log[3], 300},
 PlotRange -> {{-.5, 3}, {0, 2}}, AspectRatio -> 1/GoldenRatio, 
 PlotPoints -> 100, PlotStyle -> Red, AxesOrigin -> {-.5, 0}]

enter image description here

moved the axis just for illustration.


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.