# Can Mathematica solve this equation with NDSolve?

Here is my code:

k = 0.55; e = 6; d = 12; n = 1/0.617; R1 = 300; m = 0;

s = NDSolve[{k^2 (w'[y] - 2 Exp[y](1 + Log[Exp[y]/R1])(n - 1) (w[y] + m)/(R1 - (n - 1) Exp[y]))^(3/2)w'[y]^(1/2) ((R1 - (n - 1) Exp[y])/R1)^4 +
w'[y] Exp[-y] ((R1 - (n - 1) Exp[y])/R1)^3 - 1 == 0,
w[Log[5.531]] == R1^3/((R1 - 5.531 (n - 1))^2 (2 n - 2)) - R1/(2 n - 2)}, w,{y,Log[5.531],Log[ R1/(2 n)]}]

Ce1[y_] = Evaluate[w[y] /. s]

Plot[Ce1[y], {y, Log[5.531], Log[ R1/(2 n)]}]


This code ran my computer out of memory but still give no solution. Is this equation too complicated to be solved with NDSolve? If yes, is there any way that I can solve this equation? Thanks.

• Dear all, I feel like this is probably a duplicate, but couldn't find it easily. – Verbeia Sep 22 '14 at 1:22

On V10.0.1, I get the suggestion to try Method -> {"EquationSimplification" -> "Residual"}, which produces a reasonable result. (On V9.0.1, I get lots of errors, but the OP's original code still produces the same solution as below, apparently.)

s = NDSolve[{k^2 (w'[y] -
2 Exp[y] (1 + Log[Exp[y]/R1]) (n -
1) (w[y] + m)/(R1 - (n - 1) Exp[y]))^(3/2) w'[
y]^(1/2) ((R1 - (n - 1) Exp[y])/R1)^4 +
w'[y] Exp[-y] ((R1 - (n - 1) Exp[y])/R1)^3 - 1 == 0,
w[Log[5.531]] ==
R1^3/((R1 - 5.531 (n - 1))^2 (2 n - 2)) - R1/(2 n - 2)},
w, {y, Log[5.531], Log[R1/(2 n)]},
Method -> {"EquationSimplification" -> "Residual"}];


Plot:

The solution seems to satisfy the differential equation:

Plot[k^2 (w'[y] -
2 Exp[y] (1 + Log[Exp[y]/R1]) (n -
1) (w[y] + m)/(R1 - (n - 1) Exp[y]))^(3/2) w'[
y]^(1/2) ((R1 - (n - 1) Exp[y])/R1)^4 +
w'[y] Exp[-y] ((R1 - (n - 1) Exp[y])/R1)^3 - 1 /. First@s,
{y, Log[5.531], Log[R1/(2 n)]},
Evaluated -> True]


• This answer works. Thanks. V10. is much more powerful. – zeo Sep 22 '14 at 4:29

Your problem is that you are using a mix of integers and real-valued parameters, which isn't what NDSolve is really designed to do. When I make e, d and R1 real-valued by adding decimal points, the equations to be solved become:

{-1 + 3.7037*10^-8 E^-y (300. - 0.620746 E^y)^3 Derivative[1][w][y] +
3.73457*10^-11 (300. - 0.620746 E^y)^4 Sqrt[
Derivative[1][w][
y]] (-((1.24149 E^y (1 + Log[0.00333333 E^y]) w[y])/(
300. - 0.620746 E^y)) + Derivative[1][w][y])^(3/2) == 0,
w[1.71037] == 5.62742}


You can see the bit with a coefficient with an order of magnitude of $10^{-11}$ there. I'm pretty sure this is numerical round-off error. When I eliminate that small part using Chop, I get a solution in a fraction of a second.

s = NDSolve[
Chop@{k^2 (w'[y] -
2 Exp[y] (1 + Log[Exp[y]/R1]) (n -
1) (w[y] + m)/(R1 - (n - 1) Exp[y]))^(3/2) w'[
y]^(1/2) ((R1 - (n - 1) Exp[y])/R1)^4 +
w'[y] Exp[-y] ((R1 - (n - 1) Exp[y])/R1)^3 - 1 == 0,
w[Log[5.531]] ==
R1^3/((R1 - 5.531 (n - 1))^2 (2 n - 2)) - R1/(2 n - 2)},
w, {y, Log[5.531], Log[R1/(2 n)]}]

(* {{w->InterpolatingFunction[{{1.71037,4.52775}},<>]}} *)


The plot then looks like this:

It is always a good idea to evaluate your equations and have a look before you try to solve them using Solve, NSolve, DSolve or NDSolve.

• Thanks a lot! You are really helpful! – zeo Sep 22 '14 at 2:01
• It's not clear to me that the term with a factor of 10^-11 is negligible. The only other term with w'[y] has a factor of 3.7037*10^-8 E^-y. See my answer. – Michael E2 Sep 22 '14 at 2:47
• @MichaelE2 Yes, you are right, I reconsider the equation that the "small part" isn't really negligible. I'll check your answer – zeo Sep 22 '14 at 2:59
• @MichaelE2 - fair enough: I think the main value in my answer is the point about exact versus real coefficients, which is why I can't help thinking that the question is a duplicate. – Verbeia Sep 22 '14 at 3:00