Message Boards Message Boards

0
|
3459 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

How to make NDSolve to use NSolve solution?

Hi, I have an NDSolve that requires an NSolve solution at each time step:

a[t_] := A /. NSolve[x[t]*A == 1 - x[t]^2];
NDSolve[{x'[t] == 2*a[t]*x[t], x[0] == 2}, {x[t]}, {t, 0, 1}];
Plot[x[t]/.%, {t, 0, 1}]

Which should result similar to this:

NDSolve[{x'[t] == 2*(1-x[t]^2), x[0] == 2}, {x[t]}, {t, 0, 1}];

Try it with

a[t_] := First[A /. Solve[x[t]*A == 1 - x[t]^2]];

This gets you the actual solution instead of a solution in a list.

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract