I want to solve:
([y]'[x])^2 + y''[x]* y[x] + y[x] = 0 و y (0) = 1; y' (0) = 0 Is it possible to get exact or approximate or numerical solution on x in [0,1]
Approximate solution:
$Version (*"13.0.0 for Microsoft Windows (64-bit) (December 3, 2021)"*) Method 1:
solA = AsymptoticDSolveValue[{y'[x]^2 + y''[x]*y[x] + y[x] == 0, y[0] == 1, y' [0] == 0}, y[x], {x, 0, 20}] (*1 - x^2/2 - x^4/12 - (7 x^6)/180 - x^8/45 - (457 x^10)/32400 - (40859 x^12)/4276800 - (452 x^14)/66825 - (1269019 x^16)/256608000 - ( 145468123 x^18)/39261024000 - (8679629 x^20)/3067267500*) Plot[{solA, Evaluate@D[solA, x]}, {x, 0, 1}, PlotLegends -> {"y[x]", "y'[x]"}] Method 2:
I borrowed the code from here.
ClearAll["`*"]; Remove["`*"] y[x_] = Sum[a[s] x^s, {s, 0, 20}] + O[x]^21; le = LogicalExpand[y'[x]^2 + y''[x]*y[x] + y[x] == 0]; sol1 = Solve[le, Table[a[s], {s, 2, 20}]]; yy[x_] = Normal[y[x] /. First@sol1]; sol2 = Solve[{yy[0] == 1, yy'[0] == 0}, {a[0], a[1]}]; wle[x_] = yy[x] /. First@sol2 (*1 - x^2/2 - x^4/12 - (7 x^6)/180 - x^8/45 - (457 x^10)/32400 - (40859 x^12)/4276800 - (452 x^14)/66825 - (1269019 x^16)/256608000 - ( 145468123 x^18)/39261024000 - (8679629 x^20)/3067267500*) Numerical solution:
solB = NDSolveValue[{y'[x]^2 + y''[x]*y[x] + y[x] == 0, y[0] == 1, y' [0] == 0}, y, {x, 0, 1}] Plot[{solB[x], solB'[x]}, {x, 0, 1}, PlotLegends -> {"y[x]", "y'[x]"}] Table[{x, solB[x]}, {x, 0, 1, 0.05}] (*{{0., 1.}, {0.05, 0.998749}, {0.1, 0.994991}, {0.15, 0.988707}, {0.2, 0.979864}, {0.25, 0.968414}, {0.3, 0.954295}, {0.35, 0.937422}, {0.4, 0.917691}, {0.45, 0.894967}, {0.5, 0.86908}, {0.55,0.839817}, {0.6, 0.806899}, {0.65, 0.769965}, {0.7, 0.728532}, {0.75, 0.681932}, {0.8, 0.629204}, {0.85, 0.568876}, {0.9, 0.498499}, {0.95, 0.413397}, {1., 0.302054}}*) Exact solution:
DSolveValue[{y'[x]^2 + y''[x]*y[x] + y[x] == 0, y[0] == 1, y'[0] == 0}, y[x], x] (*Can't find any*) Using Maple 2021, can find 2 solutions expressed by RootOf function.
Solving integrals and converting to Mathematica implicit 2 solutions and plot:
ContourPlot[{Sqrt[6] Gamma[2/3] Gamma[5/6]/(2 Sqrt[Pi]) - Sqrt[6]/4 y^2 Hypergeometric2F1[1/2, 2/3, 5/3, y^3] == x, -Sqrt[6] Gamma[2/3] Gamma[5/6]/(2 Sqrt[Pi]) + Sqrt[6]/4 y^2 Hypergeometric2F1[1/2, 2/3, 5/3, y^3] == x}, {x, -2, 2}, {y, -2.5, 1.2}] Here's a way to coax DSolve from the general solution to the IVP:
ode = (y'[x])^2 + y''[x]*y[x] + y[x] == 0; ics = {y[0] == 1, y'[0] == 0}; gensol = DSolve[ode, y[x], x]; implgensol = gensol /. {HoldPattern[z_ -> InverseFunction[f_][u_]] :> f[z] == u} // FullSimplify[#, C[1] > 0] &; (* Set up equations to solve for C[1],C[2] from ICs *) dimplsol = FullSimplify[NestList[D[#, x] &, First@#, 1] /. x -> 0, C[1] > 0] & /@ implgensol; rationalized = And @@@ MapAt[ Solve[#, C[1]] /. {{{C[1] -> c1_}} :> C[1] == c1, {} -> False} &, dimplsol, {All, 2}]; parameq = rationalized /. First@Solve[ics]; paramsol = First@Solve[Flatten@{#}, {C[1], C[2]}] & /@ parameq; (* implicit solution *) implsol0 = MapThread[ReplaceAll, {implgensol, paramsol}] (* {{2 Sqrt[2/3] (x - (Sqrt[(3 \[Pi])/2] Gamma[5/3])/(2 Gamma[7/6])) + Hypergeometric2F1[1/2, 2/3, 5/3, y[x]^3] y[x]^2 == 0}, {2 Sqrt[2/3] (x + (Sqrt[(3 \[Pi])/2] Gamma[5/3])/(2 Gamma[7/6])) == Hypergeometric2F1[1/2, 2/3, 5/3, y[x]^3] y[x]^2}} *) ContourPlot[% /. y[x] -> y // Flatten // Evaluate, {x, -2, 2}, {y, -2.5, 1.2}]
InverseFunction really isn't that robust, hence an explicit solution leaves something to be desired (which should perhaps be expected from the plot above):
(* "explicit" solution *) sol0 = MapThread[ReplaceAll, {gensol, paramsol}]; Plot[y[x] /. sol0 // Evaluate, {x, -1.01, 1.01}, AspectRatio -> 1, Frame ->True]
Plot: InverseFunction can be slow. $\endgroup$ InverseFunction plot to include this value it'll look a little better (though the curve will still end when it hits the $x$-axis, so it doesn't capture the full behavior captured in your implicit plot.) $\endgroup$ Note that $y^2 y'^2 + \frac23 y^3$ is a first integral of this ODE, since its derivative is proportional to the ODE itself:
Simplify[D[y[x]^2 y'[x]^2 + 2/3 y[x]^3, x]] (* 2 y[x] y'[x] (y'[x]^2 + y[x] (1 + (y''[x])) *) (I found this by first noting that ${y'}^2 + y y'' = \frac{d}{dx}(y y') = \frac{1}{2} \frac{d^2 (y^2)}{dx^2}$ and then making further obvious substitutions from there.) Given the initial values $y(0) = 1$ and $y'(0) = 0$, we must have $y^2 y'^2 + \frac23 y^3 = \frac23$. Mathematica can solve this first-order ODE, though it outputs an InverseFunction involving a HyperGeometric2F1 function. As with @MichaelE2's answer, the resulting plot leaves something to be desired. Presumably the "real" solution you want for $x \in [0,1]$ would be the blue branch (which will be first function in the DSolve output.)
DSolve[{y[x]^2 y'[x]^2 + 2/3 y[x]^3 == 2/3, y[0] == 1}, y, x] Plot[Evaluate[y[x] /. %], {x, -2, 2}]