Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am attempting to use an NDSolve solution as an initial condition for another NDSolve as suggested in this post: Using NDSolve solution as initial condition for another NDSolve ; however, Mathematica does not evaluate NDSolve, but rather returns NDSolve with "True" in place of the initial condition. How can I change my input so that the initial condition is not entered as True? Thanks for any help. Here's my code:

     d2 = Quiet@
       NDSolve[{p'[x] == 
           Sqrt[2 *4.85017 - 0.2501^2/p[x]^2 - 2 Sqrt[1 - p[x]^2] + 
             2 Log[Sqrt[1 - p[x]^2]/p[x] + 1/p[x]]], 
04820513129389631782732451812`60.] == 0.0655951920387433`}, p, {x, 15.9944121790131434664021335530341817351882269699843332105813704010026\
04820513129389631782732451812`60., 1000}, 
        WorkingPrecision -> 60]; dom1 = 
     InterpolatingFunctionDomain[First[p /. d2]]; {lim1, c1} = 
     d3 = Quiet@
       NDSolve[{p'[x] == 
           Sqrt[2*4.85017 - 0.2501^2/p[x]^2 - 2 Sqrt[1 - p[x]^2] + 
             2 Log[Sqrt[1 - p[x]^2]/p[x] + 1/p[x]]], 
         p[c1] == p[c1] /. d2}, p, {x, c1, 1000}, 
        WorkingPrecision -> 60]; dom2 = 
     InterpolatingFunctionDomain[First[p /. d3]]; {lim2, c2} = dom2[[1]];
share|improve this question

closed as off-topic by Michael E2, rasher, m_goldberg, Sjoerd C. de Vries, bobthechemist Mar 17 '14 at 14:04

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Michael E2, rasher, m_goldberg, Sjoerd C. de Vries, bobthechemist
If this question can be reworded to fit the rules in the help center, please edit the question.

I haven't read your code, but the typical cause of this is that first you write the initial condition as f[0]=0, which immediately assigns 0 to f[0]. Then you correct it to f[0] == 0, but by this time f[0] does have a value so f[0] == 0 evaluates to 0 == 0 then True. Try restarting your kernel (Evaluation -> Quit) then re-evaluating everything. Or just Clear the function. –  Szabolcs Mar 16 '14 at 16:31
@Szabolcs Thanks for the help. Unfortunately, after restarting the kernel I'm still having the same issue. –  Nicole Mar 16 '14 at 16:54
The trouble is p[c1] == p[c1] /. d2. The replacement is applied to both sides. Use p[c1] == (p[c1] /. d2). Also solved by using q as in your answer. –  Michael E2 Mar 16 '14 at 19:26
Thanks, @MichaelE2 . That's a much cleaner remedy than mine. –  Nicole Mar 16 '14 at 20:35

1 Answer 1

up vote 1 down vote accepted

Using the information that @Szabolcs provided about having assigned values to the function I was able to modify my initial condition in the second NDSolve and get the output I was looking for. In the second NDSolve I ended up changing p[x] to q[x] and this fixed the issue.

d3 = Quiet@
       NDSolve[{q'[x] == 
           Sqrt[2*4.85017 - 0.2501^2/q[x]^2 - 2 Sqrt[1 - q[x]^2] + 
             2 Log[Sqrt[1 - q[x]^2]/q[x] + 1/q[x]]], 
         q[c1] == p[c1] /. d2}, q, {x, c1, 1000}, 
        WorkingPrecision -> 60]; dom2 = 
     InterpolatingFunctionDomain[First[q /. d3]]; {lim2, c2} = dom2[[1]]
share|improve this answer
+1 Thanks for solving and answering your own question. You can accept it, too (eventually - you might have to wait). –  Michael E2 Mar 16 '14 at 19:29

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