2
$\begingroup$

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

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

1 Answer 1

3
$\begingroup$

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"]

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.