3
$\begingroup$

I want to plot the solution curves for an ODE.

This is what I do:

sol = Flatten[DSolve[y'[x] == y[x]^3/x^3 + y[x]/x + 1, y[x], x]]

Plot[Evaluate[y[x] /. sol /. {C[1] -> 1}], {x, -7, 7}, 
 PlotRange -> All]

But I get an error message after a long time of calculation saying

This system cannot be solved with the methods available to Solve.

Any ideas why?

Thanks

$\endgroup$
3
  • 1
    $\begingroup$ If you just run DSolve[] it gives the solution implicitly in terms of Solve[] (ie it gives x(y) and not y(x) as usual) and a highly non-linear and non-algebraic equation involving ArcTan[] and Log[] which cannot be solved analytically to go from x(y)->y(x), so it gets stuck there. The message simply means that the final equation cannot be solved with the tricks Solve[] knows ;-) $\endgroup$
    – Hans Olo
    Commented Sep 2, 2022 at 17:01
  • 1
    $\begingroup$ To make the plot you could either use NDSolve[] or take the equation in the Solve[] and solve that numerically. Surprisingly, one may write down the analytic solution to x(y), but inverting it to find y(x) is tough. If you're happy with x(y) and inverting it numerically, that could also be a solution. $\endgroup$
    – Hans Olo
    Commented Sep 2, 2022 at 17:03
  • $\begingroup$ A series solution at point x=1 with 5 terms : AsymptoticDSolveValue[y'[x] == y[x]^3/x^3 + y[x]/x + 1, y[x], {x, 1, 5}] /. C[1] -> 1 $\endgroup$ Commented Sep 2, 2022 at 18:47

2 Answers 2

4
$\begingroup$

You can use ContourPlot to plot an implicit solution. Generally, I'd think the plot domain needs to be determined by inspection.

ContourPlot[Evaluate[
  C[1] /. Block[{Solve}, ReplacePart[sol, 2 -> {C[1]}]] /.
   y[x] -> y],
 {x, 0, 1.1}, {y, -0.2, 10}, Contours -> {{1}}, MaxRecursion -> 3]

It's worth considering that ContourPlot can easily plot multiple solutions:

ContourPlot[Evaluate[
  C[1] /. Block[{Solve}, ReplacePart[sol, 2 -> {C[1]}]] /.
   y[x] -> y],
 {x, 0, 3}, {y, -2, 10}, MaxRecursion -> 3, 
 PlotLegends -> 
  Placed[BarLegend[Automatic, LegendLabel -> C[1]], {After, Top}]]

Alternative

ContourPlot[Evaluate[
  Block[{Solve}, 
    Replace[sol, Verbatim[Solve][eq_, __] :> eq]
    ] /. {C[1] -> 1, y[x] -> y}],
 {x, 0, 1.1}, {y, -0.2, 10}, MaxRecursion -> 2]
$\endgroup$
0
3
$\begingroup$

Just to explain more why this ode has no explicit solution.

Solve
\begin{gather*} \boxed{y^{\prime}-\frac{y^{3}}{x^{3}}-\frac{y}{x}-1=0} \end{gather*}

In canonical form, the ODE is \begin{align*} y' &= F(x,y)\\ &= \frac{x^{3}+y \,x^{2}+y^{3}}{x^{3}}\tag{1} \end{align*} This is a homogeneous ode. Since this ode is homogeneous, it is converted to separable ODE using the substitution $u=\frac{y}{x}$, or $y=ux$. Hence $$ \frac{ \mathop{\mathrm{d}y}}{\mathop{\mathrm{d}x}}= \frac{ \mathop{\mathrm{d}u}}{\mathop{\mathrm{d}x}}x + u $$

Applying the transformation $y=ux$ to the above ODE in (1) gives \begin{align*} \frac{ \mathop{\mathrm{d}u}}{\mathop{\mathrm{d}x}}x + u &= u^{3}+u +1\\ \frac{ \mathop{\mathrm{d}u}}{\mathop{\mathrm{d}x}} &= \frac{u^{3}+1}{x} \end{align*}
This is separable. It can be written as $$ \frac{ \mathop{\mathrm{d}u}}{\mathop{\mathrm{d}x}} = f( x) g(u) $$ Where $f(x)=\frac{1}{x}$ and $g(u)=u^{3}+1$. Therefore $$ \frac{ \mathop{\mathrm{d}u}}{\mathop{\mathrm{d}x}} = \left(\frac{1}{x}\right) \left(u^{3}+1\right) $$ Hence
\begin{align*} \frac{1}{u^{3}+1}\mathop{\mathrm{d}u}&= \frac{1}{x}\mathop{\mathrm{d}x}\\ \int \frac{1}{u^{3}+1}\mathop{\mathrm{d}u}&= \int \frac{1}{x}\mathop{\mathrm{d}x} \end{align*} Integrating gives \begin{align*} -\frac{\ln \left(u^{2}-u +1\right)}{6}+\frac{\sqrt{3}\, \arctan \left(\frac{\left(2 u -1\right) \sqrt{3}}{3}\right)}{3}+\frac{\ln \left(u +1\right)}{3} = \ln \left(x \right)+c_{1} \end{align*}

$u$ in the above solution is replaced back to $y$ using $u=\frac{y}{x}$ which results in the solution $$ -\frac{\ln \left(\frac{y \left(x \right)^{2}}{x^{2}}-\frac{y \left(x \right)}{x}+1\right)}{6}+\frac{\sqrt{3}\, \arctan \left(\frac{\left(\frac{2 y \left(x \right)}{x}-1\right) \sqrt{3}}{3}\right)}{3}+\frac{\ln \left(\frac{y \left(x \right)}{x}+1\right)}{3} = \ln \left(x \right)+c_{1} $$ There is no explicit solution in $y$ as not possible to analytically solve for $y$ from the above.

$\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.