Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

Manipulate[{
  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;
  Plot[{
     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

2 Answers 2

up vote 3 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.)

Manipulate[
 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

 
discard

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.