The following set of comands breaks Maxima
load(eigen)$
A:matrix([1,1],[4,1]);
v:columnvector([x(t),y(t)]);
L:list_matrix_entries(A.v);
Eq1:'diff(x(t),t)=L[1];
Eq2:'diff(y(t),t)=L[2];
sol:desolve([Eq1,Eq2],[x(t),y(t)])$
define(x(t),rhs(sol[1]));
define(y(t),rhs(sol[2]));
[vals,vecs]:eigenvectors(A);
coefmatrix([x(t),y(t)],[exp(vals[1][1]*t),exp(vals[1][2]*t)]);
Message from maxima's stderr stream:
*** - Program stack overflow. RESET
SERVER: Lost socket connection ...
Trying to restart Maxima.
build_info(version="5.38.0_dirty",timestamp="2016-04-03 10:09:05",
host="i686-w64-mingw32",lisp_name="CLISP",lisp_version=
"2.49 (2010-07-07) (built on maxima [192.168.43.2])")
I forgot a very important line before the last line:
Thanks,
Daniel Volinski
The line before the last line is: [vals,vecs]:eigenvectors(A);
According to the manual, the
definecommand evaluates its second argument, which causes a problem here sincex(0)andy(0)are found insol. I suggest usingand
instead. Alternatively, the evaluation of
x(0)andy(0)could be manually suppressed by definingsolasin which case your
definecommands should work.This is a good solution too. I think it's simpler than mine, so it's to be preferred.
Hi Mike,
I'll take you suggestion.
Thanks,
Daniel
Diff:
Enclose code in four tildes for formatting; also paste in missing line.
The problem is that you have defined
x(t)andy(t)in terms ofx(0)andy(0)but the definition doesn't say what to do ift=0. Sox(t)callsx(0)andx(0)callsx(0)and there is a stack overflow. (Not a problem incoefmatrix.)There are a couple of ways to handle it. Here's one way which is to check for
t=0and return a noun expression (i.e. prevent function evaluation) in that case.Note that the
x(0)andy(0)you see here are noun expressions. You'll have to take that into account if you try to do some operations on them.Another way to handle the problem is to use simplification rules and simplify only if
t # 0. I'll leave that aside for now.Thank you Mike and Robert for the responses.
Daniel