rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

desolve provides ilt response #2858

Open rtoy opened 1 week ago

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-06 23:17:24 Created by danielvolinski on 2015-05-16 07:55:21 Original: https://sourceforge.net/p/maxima/bugs/2961


Using wxMaxima 5.36.1 on Windows 8.1 x64

This is a linear system I was not able to solve with desolve

dot(u):=block([r],depends([x1,x2],t),r:diff(u,t),remove([x1,x2],dependency),r)$
L2:m[1]*dot(x1)^2+m[2]*dot(x2)^2-k[1]*x1^2-k[2]*x2^2-k*(x1-x2)^2;
Eq1:dot(diff(L2,dot(x1)))-diff(L2,x1)=0$
Eq1:subst([x1=x1(t),x2=x2(t)],Eq1);
Eq2:dot(diff(L2,dot(x2)))-diff(L2,x2)=0$
Eq2:subst([x1=x1(t),x2=x2(t)],Eq2);
atvalue(x1(t),t=0,1)$
atvalue(x2(t),t=0,1)$
atvalue(diff(x1(t),t),t=0,0)$
atvalue(diff(x2(t),t),t=0,0)$
sol:desolve([Eq1,Eq2],[x1(t),x2(t)]);

The result is a function to be inverse Laplace transformed, not the actual time function I need.

Daniel Volinski

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-06 23:17:25 Created by villate on 2015-05-18 10:21:17 Original: https://sourceforge.net/p/maxima/bugs/2961/#aa19


Diff:


--- old
+++ new
@@ -2,6 +2,7 @@

 This is a linear system I was not able to solve with desolve

+~~~~
 dot(u):=block([r],depends([x1,x2],t),r:diff(u,t),remove([x1,x2],dependency),r)$
 L2:m[1]*dot(x1)^2+m[2]*dot(x2)^2-k[1]*x1^2-k[2]*x2^2-k*(x1-x2)^2;
 Eq1:dot(diff(L2,dot(x1)))-diff(L2,x1)=0$
@@ -13,6 +14,7 @@
 atvalue(diff(x1(t),t),t=0,0)$
 atvalue(diff(x2(t),t),t=0,0)$
 sol:desolve([Eq1,Eq2],[x1(t),x2(t)]);
+~~~~

 The result is a function to be inverse Laplace transformed, not the actual time function I need.
rtoy commented 1 week ago

Imported from SourceForge on 2024-07-06 23:17:28 Created by villate on 2015-05-18 10:21:17 Original: https://sourceforge.net/p/maxima/bugs/2961/#ec77


I do not think this is a bug in desolve but in ilt (and it is really a limitation of ilt, rather than a bug).

It goes down to:

ilt((s^3+(a+2)*s)/(s^4+(a+3)*s^2+2*a+1),s,t);

which ilt cannot solve, apparently because

factor(s^4+(a+3)*s^2+2*a+1);

is not sucessfull either. To make ilt work in cases like this, someone could extend it to use numerical factorization (realroots?) when factor fails. But the current implementation of ilt tries to give analytical results, rather than numerical approximations.

I'd like to give you a couple of tips for future bug reports.

First. Try to make the report simpler. For example, you could have replaced

k=1,m[1]=1,m[2]=1,k[1]=1,k[2]=a

and just show the two differential equations, without any previous steps. Namely, the bug report could have been: "desolve fails to solve the following problem:"

Eq1: 2*'diff(x1(t),t,2)+2*(x1(t)-x2(t))+2*x1(t) = 0
Eq2: 2*'diff(x2(t),t,2)+2*a*x2(t)-2*(x1(t)-x2(t)) = 0
atvalue(x1(t),t=0,1)$
atvalue(x2(t),t=0,1)$
atvalue(diff(x1(t),t),t=0,0)$
atvalue(diff(x2(t),t),t=0,0)$
sol:desolve([Eq1,Eq2],[x1(t),x2(t)]);

Second. Please click the "Preview" button and make sure the message is correct before clicking "Post". Some characters, such as *, are special and must be protected (read "Formatting help")

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-06 23:17:32 Created by sslavi on 2015-05-22 12:45:38 Original: https://sourceforge.net/p/maxima/bugs/2961/#8a13


I have noticed that the solution contains an odd parameter in the form gXXXX, where XXXX is a 4-digit number which changes with each run of the desolve([Eq1,Eq2],[x1(t),x2(t)]) command. See the attached screenshot with the highlighted parameter. Anyone knows what it is?

Attachments:

rtoy commented 1 week ago

Imported from SourceForge on 2024-07-06 23:17:35 Created by kjak on 2015-05-22 18:14:04 Original: https://sourceforge.net/p/maxima/bugs/2961/#8a13/3382


Those are what are called (Maxima) "gensyms". They're like automatically generated symbols. You can create these yourself in Maxima with the gensym function:

(%i1) gensym();
(%o1) g757

(%i2) gensym();
(%o2) g758

(%i3) gensym("k");
(%o3) k759

One reason they are used here is that ilt needs a named parameter, but we don't care what that parameter name is. If ilt succeeds, then the gensym won't appear anymore.