# Using the solution to an equation as an integral limit (when plotting)

I am trying to use the solution $r_0$ of the equation

$r^3 -r b^2 +2b^2=0$

as the limit of the integral

$\int^{r_0}_0 \left[b-b^3 u^3+\frac{b^3 u^2}{2}+\left(\frac{3 b^5}{8}+\frac{2 b^3}{\sqrt{\pi }}\right) u^4 \right] du$

and plot this between $b=5$ and $b=10$.

I tried to use

Plot[Integrate[ b + 1/2 b^3 u^2-b^3 u^3 + (3/8 b^5 + (2  b^3)/Sqrt[\[ Pi]])
u^4, {u, 0,  Evaluate[ NSolve[r^3 == b^2 (r - 2), r, Reals]}]],{b,5,10}]


and

Subscript[r, 0][b_] = NSolve[r^3 == b^2 (r - 2), r, Reals]

Plot[Integrate[b + 1/2  b^3 u^2 - b^3 u^3 + (3/8  b^5 +
(2b^3)/Sqrt[\[Pi]]) u^4, {u, 0, Evaluate[Subscript[r, 0][b]}]], {b, 5, 10}]


but these both give me a blank graph

• There are several mistakes. 1. if you want to evaluate the expression before plotting, you should apply Evaluate on it. 2. The integration interval of Integrate should be a number or a symbol, but what NSolve returns is clearly not. Mar 14, 2017 at 12:02
• Thanks, so what should I do to NSolve? Should I apply Evaluate to NSolve? That doesn't seem to help Mar 14, 2017 at 12:08
• Well I meant the Evaluate should be before Integrate not NSolve... Mar 14, 2017 at 12:12
• Ok, so how should I get NSolve to give a number? Mar 14, 2017 at 12:14
• Which root are you looking for? Between $3\sqrt{3}$ and $10$, all three are real. Mar 15, 2017 at 4:03

## 1 Answer

You do not have to pile up everything together. Have clarity with function definitions - what depends on what? Check that every part works separately.

bfun[b_] = First[r /. Solve[r^3 == b^2 (r - 2), r, Reals]];

abfun[a_, b_] = Integrate[b + (b^3 u^2)/2 - b^3 u^3 +
((3 b^5)/8 + (2 b^3)/Sqrt[Pi]) u^4, {u, 0, a}];

Plot[abfun[bfun[b], b], {b, 5, 10}, PlotTheme -> "Detailed"]