2
$\begingroup$

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.

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

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:

Mathematica graphics

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]

Mathematica graphics

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

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:

enter image description here

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.

$\endgroup$
  • $\begingroup$ Thanks a lot! You are really helpful! $\endgroup$ – zeo Sep 22 '14 at 2:01
  • $\begingroup$ 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. $\endgroup$ – Michael E2 Sep 22 '14 at 2:47
  • $\begingroup$ @MichaelE2 Yes, you are right, I reconsider the equation that the "small part" isn't really negligible. I'll check your answer $\endgroup$ – zeo Sep 22 '14 at 2:59
  • $\begingroup$ @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. $\endgroup$ – Verbeia Sep 22 '14 at 3:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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