1
$\begingroup$

I wish to plot the real roots of the following equation as a graph of L versus r.

L^3 - L*b (P - r) == 0

with b=2.6666, P=10, for r in (1,100) with step size 0.1. I have tried the following which does not seem to work.

sol = Solve[L^3 - L*b (P - r) == 0, L];
With[{b = 2.6666, P = 10}, Plot[{f[L]}, {r, 1, 100, 0.1}]]

How can I plot L (y-axis) versus r (x-axis) for the given range of r?

$\endgroup$
1
  • 3
    $\begingroup$ Try ContourPlot $\endgroup$
    – cvgmt
    Commented May 24, 2023 at 10:18

2 Answers 2

5
$\begingroup$

Look at your function:

L^3 - L*b (P - r) == 0

One root will certainly be zero. That leaves a quadratic:

b = 2.6666;
P = 10;
sol = Solve[L^2 - b (P - r) == 0, L, Reals]

enter image description here

Therefore, there are only real roots for r<10:

Plot[L /. sol, {r, -5, 11}]

enter image description here

$\endgroup$
0
$\begingroup$

As @cvgmt alluded to in a comment, ContourPlot is great for such problems (especially when analytical solutions aren't available). In your case:

b = 2.6666; P = 10;
ContourPlot[L^3 - L*b (P - r) == 0, {r, -10, 20}, {L, -7, 7}, MaxRecursion -> 3]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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