2
$\begingroup$

I plotted the following function twice using different PlotRange values:

Φ[p_, r_, ϕ_, α_] :=  
  1/Sqrt[Cosh[r]] (1/(π h m ω))^(1/4) * 
    Exp[
      -(1/(2 h m ω)) p^2 - 
      Conjugate[α]/2 (α + Conjugate[α] E^(I ϕ) Tanh[r]) + 
      1/(h m ω) E^(I ϕ) Tanh[r] p^2 - 
      I(α + Conjugate[α] E^(I ϕ) Tanh[r]) Sqrt[2 /(m ω h)] p + 
      1/2 (α + Conjugate[α] E^(I ϕ) Tanh[r] + 
            I Sqrt[2/(m ω h)] E^(I ϕ) Tanh[r] p)^2 - 
      1/2 Log[1 +E^(I ϕ)Tanh[r]] - 
      ((E^(I ϕ) Tanh[r])/(1 +E^(I ϕ) Tanh[r])) * 
      1/2 (α + Conjugate[α] E^(I ϕ) Tanh[r] + 
            I Sqrt[2/(h m ω)] E^(I ϕ)Tanh[r] p)^2]

where I set m = 1, h = 1, ω = 1.

Here's a picture of the same function

I used

Plot[Re[Φ[p, 3, 0, 1 (1 + I)]], {p, -100, 100}, 
  PlotRange -> All, PlotStyle -> {Brown, Thick}, 
  Axes -> {False, False}, Frame -> True]

and I obtained the following plot

Notice there is a straight line between 40 and 50. However, if I now plot

Plot[Re[Φ[p, 3, 0, 1 (1 + I)]], {p, 35, 55}, 
  PlotRange -> All, PlotStyle -> {Brown, Thick}, 
  Axes -> {False, False}, Frame -> True]

(I only modified PlotRange) I get the following graph:

It is the same function but now the straight line disappears. This is the behavior that I expect. I do not want that straight line. Is there a way to plot the same function using PlotRange -> {-100,100} but without that annoying straight line?

$\endgroup$
1
  • $\begingroup$ I cannot copy your definition of the function. A lot of brackets seem to be unbalanced. $\endgroup$ Commented Oct 13, 2020 at 18:46

1 Answer 1

4
$\begingroup$

This is a plotting artefact. Sometimes you need to tell Plot to use more initial points to sample the function when the automatic refinement algorithm misses parts. PlotPoints -> 100 seems to work:

Plot[Re[Φ[p, 3, 0, 1 (1 + I)]], {p, -100, 100}, 
 PlotRange -> All, PlotStyle -> {Brown, Thick}, 
 Axes -> {False, False}, Frame -> True, PlotPoints -> 100
]

enter image description here

$\endgroup$
1
  • $\begingroup$ Indeed. That was the problem! $\endgroup$
    – eemg
    Commented Oct 13, 2020 at 18:53

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