Dear All,
I have two odes,
dX/dt = -X(t)*Y(t) and dY(t)/dt = X(t)*Y(t)
I can solve these numerically using the following code:
eq_1:=diff(X(t), t)=-X(t)*Y(t);
eq_2:=diff(Y(t),t)=X(t)*Y(t);
IC:={eq_1, eq_2,X(0)=10,Y(0)=1};
F:=dsolve(IC, {X(t),Y(t)},type=numeric, method=rosenbrock);
h := theta->eval(X(t),F(theta));
h(1);
However, I would like to add perturbations at specific time points. For example, at t=10, set X=5, or at t=15, Y=0. How should I do this in maple?
Note: my actual situation involves a 100 odes.
Thanks,
Colin
a simplistic approach
As you have described the problem, it sounds as though you have a situation where you have a set of initial conditions that allow you to solve the system from the initial time up to the time of the first "perturbation".
When the first perturbation occurs a new system has to be solved. This system uses the solution from the previous time interval as its initial condition - with one (or some) values reset. Now, solve up to the second time when a perturbation occurs.
Repeat the above for as many perturbations as necessary.
If you want to put everything together in one "solution", I would recommend using the piecewise command. Here is how I put this together for the example you describe in your post:
restart; eq_1:=diff(X(t), t)=-X(t)*Y(t); eq_2:=diff(Y(t),t)=X(t)*Y(t); IC1:={eq_1, eq_2,X(0)=10,Y(0)=1}; F1:=dsolve(IC1, {X(t),Y(t)},type=numeric, method=rosenbrock); h1 := theta->eval([X(t),Y(t)],F1(theta)); IC2 := {eq_1,eq_2, X(10)=5, Y(10)=h1(10)[2]}; F2:=dsolve(IC2, {X(t),Y(t)},type=numeric, method=rosenbrock); h2 := theta->eval([X(t),Y(t)],F2(theta)); H := proc(theta) if type(theta,name) then 'procname'(args) else piecewise( theta<10, h1(theta), h2(theta) ) end if; end proc; plot( [H(t)[1],H(t)[2]], t=0..15 );I do not know what you want to do with the solutions. It's possible my implementation should be modified to fit your specific needs. But, I think this shows one way to approach this type of problem. All of this could be put in a proc is desired.
Doug
post fixed, but could not send private message
Colin,
> Many thanks for you comment on my forum question, it should solve my problem. Unfortunately, your post was truncated. Is there any chance that you could fix it.
Caught by the less-than-sign again. It's now fixed.
Wishing you a Merry Christmas,
Doug
P.S. I tried to send this as a private message, but could not. The problem was that everytime I select the recipient, the To field shows "Colin" but then MaplePrimes responds that this user is unknown. I've had this problem before. Is this a bug, or is there something I am not doing correctly?
private message fixed
I have fixed the problem for the private message for this user.
Scott