Solving numerically the Lane-Emden equation with **theta__0(xi) **being itself the numerical approximation of the Emden equation returns this error message

__Error, (in dsolve/numeric/make_proc) ode system is singular at the initial point__

**Note** that this has nothing to do with the fact the Emden solution is solved numerically:

EmdenE := unapply( rhs(dsolve({ode1(1), theta__0(0) = 1, (D(theta__0))(0) = 0}, theta__0(xi))), xi);
ode2E := n -> diff(gamma(xi), xi, xi)-2*gamma(xi)/xi^2+alpha^2*gamma(xi) = -EmdenE(xi)^n*xi^2;
ic2 := gamma(0) = 0, D(gamma)(0) = 0;
LaneEmdenN := dsolve({ode2E(1), ic2}, numeric, parameters=[alpha])
__Error, (in dsolve/numeric/make_proc) ode system is singular at the initial point__

The reason why **dsolving/numeric** the Lane-Emden equation comes probably from the nullity at **xi=0** of the denominator of its exact solution:

LaneEmdenE := dsolve({ode2E(1), ic2})
(cos(xi alpha) xi alpha - sin(xi alpha)) _C2
gamma(xi) = --------------------------------------------
xi
/ / 2 \ 2\
\2 + \alpha - 1/ xi / sin(xi) - 2 xi cos(xi)
+ ---------------------------------------------
2 2
xi (alpha - 1) (alpha + 1)

**See at the end of this answer how to et the mw file.**

So the idea to rewrite the initial conditions this way

ic2 := gamma(epsilon) = 0, D(gamma)(epsilon) = 0;

where epsilon is aimed to be a small positive quantity (please to the first point in **Remarks** above).

The mw file will be attached as soon as this will be possible (the site experiences a technical problem presently).

Meanwhile here ifs the code (the important lines whowing how to use the numerical solution of the Emden equation are yellow highlighted)

restart
local gamma:
ode1 := n -> (diff(xi^2*(diff(theta__0(xi), xi)), xi))/xi^2 = -theta__0(xi)^n:
EmdenN := dsolve({ode1(1), theta__0(0) = 1, (D(theta__0))(0) = 0}, theta__0(xi), numeric):
plots:-odeplot(EmdenN, [xi, theta__0(xi)], xi=0..1):
**f := proc(z)
if not type(evalf(z),'numeric') then
'procname'(z);
else
eval(theta__0(xi), EmdenN(z));
end if;
end proc:**
ode2 := n -> diff(gamma(xi), xi, xi)-2*gamma(xi)/xi^2+alpha^2*gamma(xi) = **-f(xi)**^n*xi^2:
ic2 := gamma(epsilon) = 0, D(gamma)(epsilon) = 0:
LaneEmdenN := dsolve(eval({ode2(1), ic2}, epsilon=0), **known=f**, numeric, parameters=[alpha])
__Error, (in dsolve/numeric/make_proc) ode system is singular at the initial point__
# define an extra parameter epsilon
LaneEmdenN := dsolve({ode2(1), ic2}, known=f, numeric, parameters=[alpha, epsilon]):
# with epsilon=0
LaneEmdenN(parameters=[2.356, 0]):
plots:-odeplot(LaneEmdenN, [xi, gamma(xi)], xi=0..10):
Warning, cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up
# with epsilon=1e-6
LaneEmdenN(parameters=[2.356, 1e-6]):
plots:-odeplot(LaneEmdenN, [xi, gamma(xi)], xi=1e-6..10): # works well

**Remarks:**

- In your file you used 2 conditions at
**xi=0 **and another one at **xi=xi**_{I}: that's one to many.
- I used
**ode1 := n -> ...** (the same for ode2) to give you the possibility to change in a simple way the value of** n**.
- I used the '
**parameters**' option for the same flexibility reasons.

Of course you can set **n**, **alpha** and **epsilon** to numerical values BEFORE dsolving the equations:

data := {n = 1, alpha = 2.356, epsilon=1e-6}:
ode1 := (diff(xi^2*(diff(theta__0(xi), xi)), xi))/xi^2 = -theta__0(xi)^n:
ic1 := theta__0(0) = 1, (D(theta__0))(0) = 0:
EmdenN := dsolve(eval({ode1,ic1}, data), numeric);
ode2 := diff(gamma(xi), xi, xi)-2*gamma(xi)/xi^2+alpha^2*gamma(xi) = f(xi)^n*xi^2;
ic2 := gamma(epsilon) = 0, D(gamma)(epsilon) = 0;
f := proc(z)
if not type(evalf(z),'numeric') then
'procname'(z);
else
eval(theta__0(xi), EmdenN(z));
end if;
end proc;
LaneEmdenN := dsolve(eval({ode2(1), ic2}, data), known=f, numeric)

**Last but not least,**

You will see in the mw file that the exact and numerical solutions of the Lane-Emden solutions are quite different.

I haven't been able to fix this in a satisfactory way.

**To overcome the present technical difficulties Mapleprimes faces, you can download the Maple file this way:**

- edit this link DropBox,
- copy/paste it on your navigator,
- download the file (
**LaneEmdenNumeric.txt**),
- change its name into
**LaneEmdenNumeric.mw**,
- open
**LaneEmdenNumeric.mw **with Maple.