Group Abstract Group Abstract

Message Boards Message Boards

0
|
6.1K Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Using NDSolve in an Iteration

POSTED BY: Thomas Winkler

Hello, I know you asked for no recursion. However, this problem lends itself perfectly for a recursive step, that I have put it in anyway....

ellFunc[t_] := t Exp[-t] (*example for your l[t]*)

Define the first RHS of your ODE:

rhs[0][a_, b_, ell_] = a ell[t]^6

Compute the the base numerical solution to your ODE (I've arbitrarily integrated for 0 < t < 10 and set l[0]=0) sol[i] is the solution at the ith iteration; a and b are from your definition, ell is the choice for l[t]

sol[0][a_?NumericQ, b_?NumericQ, ell_] :=  
 sol[0][a, b, ell] = 
  enn /. NDSolve[{D[enn[t], t] == rhs[0][a, b, ell], enn[0] == 1}, 
     enn, {t, 0, 10}][[1]]

example:

sol[0][1, 2, ellFunc]
Plot[sol[0][1, 2, ellFunc][t], {t, 0, 10}]

The RHS for the ith iteration, need the solution from the previous iteration.

rhs[i_][a_?NumericQ, b_?NumericQ, ell_] := 
 rhs[i][a, b, ell] = a (ell[t] - b enn[t]) sol[i - 1][a, b, ell][t] 

The solution at the ith iteration uses the RHS for that iteration:

sol[i_][a_?NumericQ, b_?NumericQ, ell_] := 
 sol[i][a, b, ell] = 
  enn /. NDSolve[{D[enn[t], t] == rhs[i - 1][a, b, ell], enn[0] == 1},
      enn, {t, 0, 10}][[1]]

Example:

Plot[Evaluate[sol[1][1, 2, ellFunc][t]], {t, 0, 10}]

A list of solutions:

solutions = Table[sol[i][1, 2, ellFunc][t], {i, 0, 10}]

and plotting them:

Plot[solutions, {t, 0, 10}]
POSTED BY: W. Craig Carter
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard