# 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. – happy fish Mar 14 '17 at 12:02
• Thanks, so what should I do to NSolve? Should I apply Evaluate to NSolve? That doesn't seem to help – supercoolphysicist Mar 14 '17 at 12:08
• Well I meant the Evaluate should be before Integrate not NSolve... – happy fish Mar 14 '17 at 12:12
• Ok, so how should I get NSolve to give a number? – supercoolphysicist Mar 14 '17 at 12:14
• Which root are you looking for? Between $3\sqrt{3}$ and $10$, all three are real. – rcollyer Mar 15 '17 at 4:03

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