-1
$\begingroup$

enter image description here

Plot[-s*(-q^2/(2*s) + 
    q*(p - 1)/
      s + (-(p*s - 2*s + 1)/(2*s^2) - 
       Sqrt [s^5*(s - 1)]*(p - 2)/(2*s^4))*
     Log[(2*s^2*(-(p*s - 2*s + 1)/(2*s^2) - 
            Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s - 
         2*s)] - (-(p*s - 2*s + 1)/(2*s^2) - 
       Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4))*
     Log [q + (2*
           s^2*(-(p*s - 2*s + 1)/(2*s^2) - 
             Sqrt [s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s - 
          2*s)] + (-(p*s - 2*s + 1)/(2*s^2) + 
       Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4))*
     Log [(2*s^2*(-(p*s - 2*s + 1)/(2*s^2) + 
            Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s - 
         2*s)] - (-(p*s - 2*s + 1)/(2*s^2) + 
       Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4))*
     Log[q + (2*
           s^2*(-(p*s - 2*s + 1)/(2*s^2) + 
             Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s - 
          2*s)]), {q, 0, 1}, PlotRange -> All, Exclusions -> None]
$\endgroup$
2
1
$\begingroup$

As comment said, you should provide values for p and s so one can reproduce the result. But while waiting for coeffee, I tried few random values for p and s and reproduced the problem. The fix is to add Chop as this is result of small complex values that shows up.

ClearAll[p, s, q];
p = .1;
s = .2;
f := -s*(-q^2/(2*s) + 
     q*(p - 1)/
       s + (-(p*s - 2*s + 1)/(2*s^2) - 
        Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4))*
      Log[(2*s^2*(-(p*s - 2*s + 1)/(2*s^2) - 
             Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s - 
          2*s)] - (-(p*s - 2*s + 1)/(2*s^2) - 
        Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4))*
      Log[q + (2*
            s^2*(-(p*s - 2*s + 1)/(2*s^2) - 
              Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s - 
           2*s)] + (-(p*s - 2*s + 1)/(2*s^2) + 
        Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4))*
      Log[(2*s^2*(-(p*s - 2*s + 1)/(2*s^2) + 
             Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s - 
          2*s)] - (-(p*s - 2*s + 1)/(2*s^2) + 
        Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4))*
      Log[q + (2*
            s^2*(-(p*s - 2*s + 1)/(2*s^2) + 
              Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s - 2*s)]);
Plot[f, {q, 0, 1}, PlotRange -> All, Exclusions -> None]

Mathematica graphics

Now see what happens when adding Chop

 Plot[Chop[f], {q, 0, 1}, PlotRange -> All, Exclusions -> None]

Mathematica graphics

$\endgroup$
2
  • $\begingroup$ Chop is not needed if you use exact values for your p and s: Plot[Evaluate[(expr /. {p -> 1/10, s -> 1/5})], {q, 0, 1}] $\endgroup$ – Bob Hanlon Mar 23 '19 at 2:45
  • $\begingroup$ @BobHanlon That is true. OP must have used real values. $\endgroup$ – Nasser Mar 23 '19 at 2:48
0
$\begingroup$

Better plot the real part with Re (nulling the spurious imaginary part) instead of using Chop (nulling the spurious imaginary part if it is below a threshold; but also nulling the real part if it gets too small):

Plot[Re[f], {q, 0, 1}, PlotRange -> All, Exclusions -> None]
$\endgroup$

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