# Solve a differential eq with a boundray condtion and plot it

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

• Analytically or numerically?
– bmf
Commented Apr 13, 2022 at 17:47
• firstly, I prefer analytical if it is not possible then numerically. Commented Apr 13, 2022 at 17:54
• 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
– bmf
Commented Apr 13, 2022 at 18:17

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]


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


This plots for a=10 and b=3

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


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

## Version with Manipulate

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


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