Help to solve ODE numerically

I want to solve a ordinate differential equation, so i enter the code

NDSolve[{y[x] * y''[x] + (y'[x])^2 + (2 * x + y[x]/x) * y'[x] == 0, y[0] == 2, y[inf] == 1}, y, {x, 0, 1}]

: i get the error as the photo could you tell me how to check the error?

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! Commented May 26, 2017 at 12:38
• People here generally like users to post code as Mathematica code instead of images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find this this meta Q&A helpful Commented May 26, 2017 at 12:38
• inf is not any defined symbol in Mathematica. If you want to specify a boundary condition at infinite you may want to writeInfinity or [Esc] inf [Esc]. Commented May 26, 2017 at 13:01

NDSolve will have trouble solving this equation for a few different reasons:

1. You have not specified the variable inf. If you mean $\infty$, this should be entered as Infinity or escinfesc, as pointed out by @dpravos in the comments.

2. If you do mean that the second boundary condition should be y[∞] == 1, this is a problem for NDSolve; it cannot solve boundary-value problems where one of the boundaries is at $\infty$.

3. Even if you do want to solve the differential equation with a finite upper boundary, your equation has a singular point at $x = 0$ due to the divergence of the y[x]/x term. This means that Mathematica cannot calculate the derivatives that it needs to at $x = 0$. You may need to use asymptotic methods and/or finite element methods; see here for an example of the former technique.

You are trying to solve a boundary value problem having the far field condition at infinity. We can take inf some finite number as long as the boundary condition is satisfied. The other issue of 1/0 can be tickled by taking the start up value close to zero not exactly zero.

inf = 10;
NDSolve[{y[x]*y''[x] + (y'[x])^2 + (2*x + y[x]/x)*y'[x] == 0, y[10^-4] == 2, y[inf] == 1},
y, {x, 10^-4, 10}]
Plot[y[x] /. %, {x, 10^-4, 10}, PlotRange -> All]

• I would caution against simply setting the boundary condition slightly away from a singular point ($x = 0$ in this case), since this can be misleading for some ODEs. For example, the equation $y' + y/x = 0$ has the general solution $y = A/x$. A solution with $y(x_0) = y_0$ exists for any value of $x_0 \neq 0$ for a given $y_0 \neq 0$, so the technique you describe might lead you to conclude that solutions exist for $x_0 = 0$ and $y_0 \neq 0$ as well. But, of course, this is not the case; no such solution exists. Commented May 27, 2017 at 13:51
• if i change y[10^-4]=2 to y[10^-4]=3 or larger, i get the error "Infinite expression 1/0 encountered",could you tell me the reason
– Ding
Commented May 29, 2017 at 12:54