NDSolve[{u'[y] + (k + y) u''[y] - Ha^2 (k + y) u[y] - 
    u[y]/(-k + y) == -k, u[-1] == 0, u[1] == 0}, u[y], y]

gives the error

NDSolve::ndnum: Encountered non-numerical value for a derivative at y == -1..
  • $\begingroup$ You are using NDSolve but several parameters are left arbitrary $\endgroup$
    – bmf
    Jun 2 at 10:07
  • $\begingroup$ sir i cannot understand $\endgroup$ Jun 2 at 10:21
  • 2
    $\begingroup$ You have not defined specific values for k etc $\endgroup$
    – bmf
    Jun 2 at 10:50

1 Answer 1


Being new, you should be aware built-in Mathematica functions and commands begin with upper-case letters including the single-letter commands: C,D, E, I, K,N O. If you were to begin a user-defined variable with an upper-case letter, it could conflict with built-in commands. Best then to always start user-defined variables with a lower-case letter. Need also to assign values to constants in equation to numerically integrate it. It's also simpler in my opinion to use NDSolveValue which returns the function directly. Here's a test case:

Ha = 1.5;
k = 2.3;
theSol = 
 NDSolveValue[{u'[y] + (k + y) u''[y] - Ha^2 (k + y) u[y] - 
     u[y]/(-k + y) == -k, u[-1] == 0, u[1] == 0}, u, y]
Plot[theSol[y], {y, -1, 1}]

enter image description here


Not the answer you're looking for? Browse other questions tagged or ask your own question.