I have an ode system, and use 2 D Math (I don't know how to copy here, so I type by hand)
' align='absmiddle'>
y'(t) = x(t) + y(t) (1 - x^2(t) - y^2(t)).
I would like to introduce x(t) = r(t) cos(Theta(t)), y(t) = r(t) sin(Theta(t)) and manipulate the equations further.
The problem is the left hand side. In one case I obtain Dx(t), in the other case (r(t) cos(Theta(t))' without calculation on it.
I ask some help. Thanks.
Sandor
Format for dsolve or DEtools
When I work with differential equations I use the following format for the DE,
diff(y(t),t) = x(t) + y(t) (1 - x(t)^2 - y(t)^2);
One can then substitute for x(t) and y(t) very easily with
eval(%,{x(t) = r(t)*cos(Theta(t)), y(t) = r(t)*sin(Theta(t)) });
Since you did not give the whole problem, I cannot go much further.
Format for dsolve
Sorry, i was not able to type in the other equation.
I tried earlier your suggestion, but the result is terrible
> eval((D(x))(t) = -y(t)+(x(t))(1-x(t)^2-y(t)^2), [x(t) = r(t)*cos(Theta(t)), y(t) = r(t)*sin(Theta(t))]);
/ 2 2
D(x)(t) = -r(t) sin(Theta(t)) + r(t)\1 - r(t) cos(Theta(t))
2 2\ / 2 2
- r(t) sin(Theta(t)) / cos(Theta(t))\1 - r(t) cos(Theta(t))
2 2\
- r(t) sin(Theta(t)) /
I didn' t type in eval by hand, I used the Expression palette, the last row, if you move the cursor on it, the eval tooltip appears.
Sandor
diff and D
Sorry again. After reading Robert's response I realized that you used diff and in Math 2D there is D. Sandor
work with diffeq
I would approach the problem this way:
eqn:=proc(x,y)
diff(y(t),t)=x(t)+y(t)*(1-x(t)^2-y(t)^2);
end proc;
eqn(x,y);
X:=t->r(t)*cos(theta(t));
Y:=t->r(t)*sin(theta(t));
eqn(X,Y);
Set up the diffeq as a proc that takes general functions x and y. Then pass specific functions X and Y.
Using D
y' in 2D math is really D(y). So instead of substituting for y(t) you have to substitute for the function y. Thus:
> eval(%,{x=(t -> r(t)*cos(Theta(t))),y=(t->r(t)*sin(Theta(t)))});D and eval
Thanks. A little bit can be improved your answer.
eval(%, {x=r*cos@Theta, y=r*sin@Theta})
also works. (You said: we have to substitute the function, so I substituted with functions. You did the same,
but it can be omitted the t variable.) Sandor
D and eval
Errhh, I'm a bit tired. I forgot brackets. x = r*(cos@Theta), y = r*(sin@Theta). Sandor
and, in 1D, with simplify also
Robert's response is good, in particular the part about how 2D math represents the derivative. The way this has to be handled is not very attractive (at least to me). I much prefer the 1D approach, shown below:
Moreover, hitting this result with simplify yields some additional benefits:
Either way, these are the basic tools to do what you want.
Doug
1D and 2D
Thanks, your answer is also good. I make an exam and I want to show the Maple's solution
to my colleagues and they not necesserally understand Maple codes, so this is why I prefer the Robert's solution.
Sandor