Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to plot solution of system of equations as a function of parameter

  Quiet[sol = Solve[{Ka*P*L*L == PLL, P0 == P + PLL, r*P0 == L + 2*PLL}, {P, L, PLL}]][[3]];
  complex[x_] := PLL /. sol[[3]] /. r -> x;
     Hold[Evaluate@D[complex[r], r]],
     Hold[Evaluate@D[-complex[r], {r, 2}]]
     } // Release,
   {r, 0.1, 4},
   PlotStyle -> {Red, Blue}
 {Ka, 10000, 10000},
 {P0, 0.5, 1}

My plot has gaps! Why and how I can eliminate them?

enter image description here

share|improve this question
up vote 4 down vote accepted

Thre is a small imaginary part due to numerical errors. Just add Re inside Evaluate:

... Evaluate@Re@D[...] ...

enter image description here

share|improve this answer

One way, which I would favor, is to use Chop to remove small imaginary parts. (I would favor this in the case that large imaginary parts should not be ignored, but indicate that the actual solution is not real.)

 With[{sol = 
    Quiet[Solve[{Ka*P*L*L == PLL, P0 == P + PLL, r*P0 == L + 2*PLL}, {P, L, PLL}]][[3]]},
  With[{df = D[PLL /. sol, r], d2f = D[PLL /. sol, {r, 2}]},
   Plot[{Chop[df], Chop[-d2f]}, {r, 0.1, 4}, 
    PlotStyle -> {Red, Blue}]
 {Ka, 10000, 10000}, {P0, 0.5, 1}]

Mathematica graphics

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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