"trigrat" caught in infinite loop - depending on how you call it
Subject: "trigrat" caught in infinite loop - depending on how you call it
From: Robert Dodier
Date: Fri, 9 Nov 2012 04:12:08 +0000 (UTC)
On 2012-11-07, Stavros Macrakis <macrakis at alum.mit.edu> wrote:
> Well, it looks as though it's not an issue in the assume database,
> anyway.... All we need to do is wrap $trigrat with (let ((varlist)) ...).
Looks like binding VARLIST does indeed fix the problem with trigrat, but
it turns out trigrat is a Maxima function, so the problem is not in
trigrat but in one of the functions it calls.
Here's the existing trigrat function (from share/trigonometry/trigrat.lisp):
#$trigrat(exp):=
if matrixp (exp) or listp (exp) or setp (exp) or trigrat_equationp
(exp)
then map (trigrat, exp)
else block([e,n,d,lg,f,lexp,ls,d2,l2,alg,gcd1],
alg:algebraic,gcd1:gcd,
algebraic:true,gcd:subres,
e: rat(ratsimp(expand(exponentialize(exp)))),
n:num(e),d:denom(e),
listofei(d),
l2:map(lambda([u,v],u^((hipow(d2,v)+lopow(d2,v))/2)),
lexp,lg),
f:if length(lexp)=0 then 1
else if length(lexp)=1 then part(l2,1)
else apply("*",l2),
n:rectform(ratexpand(n/f)),
d:rectform(ratexpand(d/f)),
e:ratsimp(n/d,%i),
algebraic:alg,gcd:gcd1,
e)$
Adding ?varlist:false to the list of variables in the block fixes the bug.
I guess at this point we need to figure out which of the built-in
functions is not restoring VARLIST ....
best
Robert Dodier