So I have a set of differential equations (which I know are analytically integrable) but I want to integrate them numerically to get the form of the solution (the solution is not explicit and hence I want to numerically integrate it).
g=7/5
v = Function[r, 1/(n[r] r^2)]
eulerEq = v[r]*v'[r] + n'[r]*n[r]^(g - 2) + 2/r^2 == 0
initcond = n[1] == 1 (*These are my equation and initial condition *)
Now to numerically solve it.
S = NDSolve[{eulerEq, initcond}, n[r], {r, 0.5, 10}]
When I hit shift+Enter, it shows me the following error:
Power::infy: Infinite expression 1/0. encountered. >>
Infinity::indet: Indeterminate expression 0. ComplexInfinity encountered. >>
NDSolve::ndnum: Encountered non-numerical value for a derivative at r == 1.`. >>
I tried using the debugger and I realized that it is computing $n'[1]$ in the process and it is getting a 'division-by-zero'. I can integrate the equation easily and get the constant of integration using the initial condition (it is getting $n$ explicitly in terms of $r$ that is troublesome). Is there a way to do this still using NDSolve or is there an alternative? I want to do it numerically only because this equation is just a special case which is analytically integrable and I need to get the other solutions also.


n(r)it gives is in terms of a complicated non-linear function inn(r)– Nasser Dec 18 '15 at 03:51n[r] -> 1 + a (r - 1)but notn[r] -> 1 + a (r - 1)^2,n[r] -> 1 + a (r - 1)^3, etc. :) – xzczd Dec 18 '15 at 04:231+5*n(r)^(12/5)*r^4+(-2*r^4-4*r^3)*n(r)^2 = 0so it is non-linear inn(r)– Nasser Dec 18 '15 at 04:32Solve[eulerEq, Derivative[1][n][r]][[1, 1, 2]]seems to give me the errorPart::partw: "Part 1 of {} does not exist."edit: Oops, my bad! Sorry about that. Used wrong variable names – Sunil S. Dec 18 '15 at 04:40First[s1]andLast[s1]do here? I'm unable to understand their function. Thanks a lot guys – Sunil S. Dec 18 '15 at 05:06FirstandLastpick out the first and second values, respectively. – bbgodfrey Dec 18 '15 at 05:08s1seems to have a lot more than two values.s1[[3]]ands1[[4]]return some tables. Also, can you explain how it is recursively usingFirst[s1]to finds1– Sunil S. Dec 18 '15 at 05:12slhas just two values, as shown in my answer above.{a -> 1/6 (-10 - Sqrt[10])}and{a -> 1/6 (-10 + Sqrt[10])}. – bbgodfrey Dec 18 '15 at 05:17