1. ## ODE in Maple

Hello,
sorry for my English...
I have a problem with Maple 12 in ODE:
I have 2 ODE f and g; I use the procedure

solnum := dsolve([f, g, x(0) = x0, y(0) = y0], [x(t), y(t)], numeric, range = 0 .. 10)

then, I would like to use x(t) and y(t) in an other function

h(t):=E log(x(t))- C x(t)- B y(t)+A log (y(t)) :

(A,B,C,E are parameters) but Maple say that he "don't know" x(t) and y(t): how I could say to it that x and y are the same of "solnum"?
(I used first "subs" but in this way h(t) becomes discrete and not a continous function).

Thank you very much,

Ilaria

2. Originally Posted by laureanda
Hello,
sorry for my English...
I have a problem with Maple 12 in ODE:
I have 2 ODE f and g; I use the procedure

solnum := dsolve([f, g, x(0) = x0, y(0) = y0], [x(t), y(t)], numeric, range = 0 .. 10)

then, I would like to use x(t) and y(t) in an other function

h(t):=E log(x(t))- C x(t)- B y(t)+A log (y(t)) :

(A,B,C,E are parameters) but Maple say that he "don't know" x(t) and y(t): how I could say to it that x and y are the same of "solnum"?
(I used first "subs" but in this way h(t) becomes discrete and not a continous function).

Thank you very much,

Ilaria

3. Hello,
this is the entire code:

> with(CurveFitting);
> with(plots);
> with(Optimization);

> F := diff(X(t), t) = X(t)*(A-B*Y(t));
> G := diff(Y(t), t) = Y(t)*(C*X(t)-E);
> f := diff(x(t), t) = x(t)*(a-b*y(t));
> g := diff(y(t), t) = y(t)*(c*x(t)-e);
>
>
> x0 := .4; y0 := .5; a := 1.8; b := .4; c := .2; e := .8;
0.4
0.5
1.8
0.4
0.2
0.8
> solnum := dsolve([f, g, x(0) = x0, y(0) = y0], [x(t), y(t)], numeric, range = 0 .. 10);
>
> h(t):=e log(x(t))- c x(t)- b y(t)+a log (y(t)) : ;
> plot(t, h);
Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

> H(t,A,B,C,E):=E log(x(t))- C x(t)- B y(t)+A log(y(t)) : ;
> Er(t,A,B,C,E,T):=1/(2)*(H(t,A,B,C,E) - T)^(2) ;
1 2
(t, A, B, C, E, T) -> - (H(t, A, B, C, E) - T)
2
> Er(t, a, b, c, e, 1);
1 2
- (0.8 ln(x(t)) - 0.2 x(t) - 0.4 y(t) + 1.8 ln(y(t)) - 1)
2
>
*****************************
Note: I have used 2 function (f and F, g and G) because I try to find the parameters a,b,c,e having only "solnum", like "experimental data", so f and g make the numerical solution, F and G have A,B,C,E unknown.

4. Originally Posted by laureanda
Hello,
this is the entire code:

> with(CurveFitting);
> with(plots);
> with(Optimization);

> F := diff(X(t), t) = X(t)*(A-B*Y(t));
> G := diff(Y(t), t) = Y(t)*(C*X(t)-E);
> f := diff(x(t), t) = x(t)*(a-b*y(t));
> g := diff(y(t), t) = y(t)*(c*x(t)-e);
>
>
> x0 := .4; y0 := .5; a := 1.8; b := .4; c := .2; e := .8;
0.4
0.5
1.8
0.4
0.2
0.8
> solnum := dsolve([f, g, x(0) = x0, y(0) = y0], [x(t), y(t)], numeric, range = 0 .. 10);
>
> h(t):=e log(x(t))- c x(t)- b y(t)+a log (y(t)) : ;
> plot(t, h);
Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

> H(t,A,B,C,E):=E log(x(t))- C x(t)- B y(t)+A log(y(t)) : ;
> Er(t,A,B,C,E,T):=1/(2)*(H(t,A,B,C,E) - T)^(2) ;
1 2
(t, A, B, C, E, T) -> - (H(t, A, B, C, E) - T)
2
> Er(t, a, b, c, e, 1);
1 2
- (0.8 ln(x(t)) - 0.2 x(t) - 0.4 y(t) + 1.8 ln(y(t)) - 1)
2
>
*****************************
Note: I have used 2 function (f and F, g and G) because I try to find the parameters a,b,c,e having only "solnum", like "experimental data", so f and g make the numerical solution, F and G have A,B,C,E unknown.
One potential problem I see (I haven't checked this though) is the way you define h(t)

you have

> h(t):=e log(x(t))- c x(t)- b y(t)+a log (y(t)) : ;

I think it should be

> h:=(t)->e log(x(t))- c x(t)- b y(t)+a log (y(t)) ;

Similarly for H and Er.

5. I changed the code, but the problem remain. Probably Maple don't understand that the x and y in h are the same of solnum, but I don't know how to explain it to the program!

6. Eureka!!!!

> xx(s):=subs(solnum(s),x(t)):yy(s):=subs(solnum(s), y(t)):
>
> h(s):=e log(xx(s))- c xx(s)- b yy(s)+a log(yy(s)) : ;
> plot(h);

Maple wants an other variable: I used "s" and it do its work eheheh!