0
$\begingroup$

I was working on this equation to solve and plot it, but I'm little bit confuse?!

ClearAll["Global`*"]
b = 0.7; a = 1.3; k = -0.002; d = 0.25; 
sol=DSolve[{(2/3)*x*y[x]*Derivative[1][y][x] + a*y[x]^2 - 
Sqrt[3]*d*y[x]*Sqrt[y[x]^2 + k/x^2 - b] + ((a - 2/3)*k)/x^2 - a*b == 0, 
y[1] == 1}, y, x]

Plot[y[x]/.sol, {x, 1, 10}]
$\endgroup$
5
  • $\begingroup$ Probably xy[x] , ay[x] and dh[x] should be x y[x] ,a y[x] and d h[x]? h[x]isn't defined? $\endgroup$ Dec 1 '21 at 20:38
  • $\begingroup$ there isn't any h[x] actually only y[x], I did but the solution is not clear!! $\endgroup$
    – M.S MD
    Dec 1 '21 at 20:44
  • $\begingroup$ Without knowing h[x] you can't plot the solution! $\endgroup$ Dec 1 '21 at 20:47
  • $\begingroup$ There's no h[x] at all, please see again $\endgroup$
    – M.S MD
    Dec 1 '21 at 20:48
  • $\begingroup$ DSolve cannot solve your ODE, so it returns unevaluated. Consequently, y[x] cannot be plotted. Try NDSolve. $\endgroup$
    – bbgodfrey
    Dec 2 '21 at 14:19
1
$\begingroup$

Ok with the modified question ( no h[x] anymore) Mathematica isn't able to solve the ode analytically ( DSolve).

But numerical solution (NDSolveorNDSolveValue) is possible:

Y = NDSolveValue[{(2/3)*x*y[x]*Derivative[1][y][x] + a*y[x]^2 -Sqrt[3]*d*y[x]*Sqrt[y[x]^2 + k/x^2 - b] + ((a - 2/3)*k)/x^2 -a*b == 0, y[1] == 1}
, y, {x, 1, 10}]


Plot[Y[x], {x, 1, 10}, PlotRange -> {0, 1}]

enter image description here

$\endgroup$
11
  • $\begingroup$ I was thinking if I use this parametric plot how should be look like: ParametricNDSolve[{(2/3)*xy[x]*Derivative[1][y][x] + ay[x]^2 - dSqrt[3]*y[x]*Sqrt[y[x]^2 + k/x^2 - b] + (k*(a - 2/3))/ x^2 - ab == 0, y[1] == 1}, y, {x, 1, 10}, {b, k, d, a}] Plot[Evaluate[Table[y[b, k, d, a][x] /. sol, {b, -0.7, -0.69, 0.01}, {k, -0.002, -0.003, -0.001}, {d, 0.2, 0.4, 0.1}, {a, 1, 2, 0.5}]], {x, 1, 10}, PlotRange -> All] $\endgroup$
    – M.S MD
    Dec 2 '21 at 15:21
  • $\begingroup$ Again don't forget in your differential equation! Try Y = ParametricNDSolveValue[{(2/3)*x y[x]*Derivative[1][y][x] + a y[x]^2 - d Sqrt[3]*y[x]*Sqrt[y[x]^2 + k/x^2 - b] + (k*(a - 2/3))/x^2 - a b == 0, y[1] == 1}, y, {x, 1, 10}, {b, k, d, a}] $\endgroup$ Dec 2 '21 at 15:44
  • $\begingroup$ ...and try Plot[Table[ Y[b, k, d, a][x] , {b, -0.7, -0.69, 0.01}, {k, -0.002, -0.003, -0.001}, {d, 0.2, 0.4, 0.1}, {a, 1, 2, 0.5}] , {x, 1, 10}, PlotRange -> All] $\endgroup$ Dec 2 '21 at 15:47
  • $\begingroup$ I did this but it is not running!! $\endgroup$
    – M.S MD
    Dec 2 '21 at 15:56
  • $\begingroup$ IAgain I checked my code and it runs (MMA v12.2) $\endgroup$ Dec 2 '21 at 16:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.