3
$\begingroup$

I just wanted to know how to plot this for different value of a,b and f (Table[])?

       Clear["Global`*"]
       Clear[a, b, f, h, x]
       eqn = {h'[x] == (a*s + (9b^2 /8s -(s+1) f ) x^2 -  3b/2s * h [x]*x^2 + h[x]^2 x^2)/(h[x]* x^3)};
      sol = DSolve[{eqn, h[1] == 1}, h[x], x]
      Plot[h[x] /. sol /. {s->1/2,a -> -0.04, b -> 1, f -> 7/10}, {x, 1, 10}]
$\endgroup$
3
  • $\begingroup$ Analytically or numerically? $\endgroup$
    – bmf
    Commented Apr 13, 2022 at 17:47
  • $\begingroup$ firstly, I prefer analytical if it is not possible then numerically. $\endgroup$ Commented Apr 13, 2022 at 17:54
  • 5
    $\begingroup$ Sinc you have received already answers, let me just point out something. I see that you have asked 21 questions, yet you have not accepted any answers. I would like to politely ask you to reconsider that. See here also for more details $\endgroup$
    – bmf
    Commented Apr 13, 2022 at 18:17

2 Answers 2

5
$\begingroup$

This can't be solved analytically by Mathematica. One option is to use ParametricNDSolveValue

ClearAll[a,b,f,h,x,s]
eqn  = h'[x]==(a*s+(9b^2/8s-(s+1) f) x^2-3b/2s*h[x]*x^2+h[x]^2 x^2)/(h[x]*x^3);
bc   = h[1]==1;
vals = {s->1/2,f->7/10};
sol  = DSolve[{eqn/.vals,bc},h[x],x]

Mathematica graphics

sol = ParametricNDSolveValue[{eqn /. vals, bc}, h, {x, 1, 10}, {a, b}]

Mathematica graphics

This plots for a=10 and b=3

Plot[sol[10, 3][x], {x, 1, 10}, PlotStyle -> Red,  
      GridLines -> Automatic, GridLinesStyle -> LightGray]

Mathematica graphics

Now you can make a Manipulate and slider for a and slider for b. I'll add one soon.

Version with Manipulate

enter image description here

ClearAll[a, b, f, h, x, s]
eqn = h'[x] == (a*s + (9 b^2/8 s - (s + 1) f) x^2 - 3 b/2 s*h[x]*x^2 +
       h[x]^2 x^2)/(h[x]*x^3);
bc = h[1] == 1;
vals = {s -> 1/2, f -> 7/10};
sol = ParametricNDSolveValue[{eqn /. vals, bc}, h, {x, 1, 10}, {a, b}];
Manipulate[
 Plot[sol[a0, b0][x], {x, 1, 10}, PlotStyle -> Red, 
  GridLines -> Automatic, GridLinesStyle -> LightGray],
 {{a0, 1, "a"}, .1, 10, .1, Appearance -> "Labeled"},
 {{b0, 1, "b"}, .1, 10, .1, Appearance -> "Labeled"},
 TrackedSymbols :> {a0, b0}
 ]
$\endgroup$
4
$\begingroup$

Edit Answer to the original post with a,b,f as parameters, before user changed it.

Didn't get anylytical solution.

Clear["Global`*"]
eqn = (h'[
     x] == (a + (2 b^2 + f) x^2 - 2 b*h[x]*x^2 + h[x]^2 x^2)/(h[x]*
       x^3));
hsol[a_?NumericQ, b_?NumericQ, f_?NumericQ] := 
 h /. Flatten@
   NDSolve[{(h'[
        x] == (a + (2 b^2 + f) x^2 - 2 b*h[x]*x^2 + h[x]^2 x^2)/(h[x]*
          x^3)), h[1] == 1}, h, {x, 1, 10}]

Plot[Evaluate[
  hsol[a, b, f][x] /. {a -> -0.04, b -> 1, f -> 7/10}], {x, 1, 10}]
$\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.