-1
$\begingroup$

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?

$\endgroup$
3
  • $\begingroup$ 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! $\endgroup$
    – Michael E2
    Commented May 26, 2017 at 12:38
  • $\begingroup$ 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 $\endgroup$
    – Michael E2
    Commented May 26, 2017 at 12:38
  • 2
    $\begingroup$ 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]. $\endgroup$
    – dpravos
    Commented May 26, 2017 at 13:01

2 Answers 2

1
$\begingroup$

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.

$\endgroup$
2
$\begingroup$

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

$\endgroup$
2
  • 2
    $\begingroup$ 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. $\endgroup$ Commented May 27, 2017 at 13:51
  • $\begingroup$ 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 $\endgroup$
    – Ding
    Commented May 29, 2017 at 12:54

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.