-1

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

enter image description here: i get the error as the photo could you tell me how to check the error?

Michael Seifert
  • 15,208
  • 31
  • 68
Ding
  • 3
  • 1
  • 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! – Michael E2 May 26 '17 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 – Michael E2 May 26 '17 at 12:38
  • 2
    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]. – dpravos May 26 '17 at 13:01

2 Answers2

2

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]

enter image description here

zhk
  • 11,939
  • 1
  • 22
  • 38
  • 2
    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. – Michael Seifert May 27 '17 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 May 29 '17 at 12:54
1

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.

Michael Seifert
  • 15,208
  • 31
  • 68