In clmacs.lisp, you'll find a macro definition for "if"
(eval-when (compile load eval)
(defmacro if (test &rest args)
(cond ((> (length args) 2)
;(format t
;"~%Warning: Too many args for if:~% ~a"
;(cons 'if (cons test args)))
`(lisp::if ,test ,(car args) (progn ,@ (cdr args))))
(t `(lisp:if ,test ,@ args))))
Possibly, the apparent 4 argument "if" in hayat is non-bogus.
Barton
By the way, what is the origin of the (funny) name hayat?
Richard Fateman <fateman@cs.berkeley.edu>
Sent by: maxima-admin@www.ma.utexas.edu
01/13/2003 11:47 AM
To: Martin RUBEY <rubey@labri.fr>, maxima <maxima@www.ma.utexas.edu>
cc:
Subject: Re: [Maxima] HELP needed: Taylor bugs
Martin RUBEY wrote:
> Hi!
>
>
>>You can try this, which is, I think, computationally pretty harmless
>>except it will use up some symbol space until the next garbage
>>collection:
>
>
>>(let ((varlist nil)(genvar nil)(a (fpoly1 ....)) ... ??....)
>
>
> Ok, I replaced
>
> (defun fpolysum (e)
> (let ((a (fpoly1 (setq e ($expand ($ratdisrep ($rat e *var*))))))
>
> with
>
> (defun fpolysum (e)
> (let ((varlist nil) (genvar nil))
> (let ((a (fpoly1 (setq e ($expand ($ratdisrep ($rat e *var*))))))
>
>
> (which is probably what you meant)
Correct
>
> and I get the right result for
>
> taylor(sum(M^K*sum(L^K,L,1,D),K,1,INF),M,0,2),simpsum;
>
> (I didn't run any tests...)
>
> Is this a bug fix?
It enforces a correct correspondence between varlist and genvars.
Somewhere else there is a bug which gets them out of synchrony.
> I have the feeling that there is a bug hiding
> somewhere. In particular, I do not understand why it MAY happen that
> genvar contain rubbish. I may be overexact, but I would believe that
> genvar should be cleaned up after use...
In the interests of keeping the total number of symbols down,
the genvars are re-used, so that (at least in theory) if you have at most
n variables in any single expression, you need n genvar symbols. If you
have n different expressions, each with a single distinct variable, then
genvars could be of length 1, and the same genvar would be over-used.
Combining
such expressions requires some translation. In the new world of cheap
memory, maybe genvars should be set to nil rather more frequently. But
doing it All the time would mean that
rat(x+1) + rat(x+2) would never see identical varlist/genvars and would
have
to disrep both things before adding them.
I haven't thought all of this through, but that's my guess.
>
>
>>... what is returned from fpolysum is nil??
>
>
> I do not understand this sentence. Please explain.
>
It looked like the program always returned nil.
>
>>PS. it would be nice to know what is supposed to be done here. There
>>are various other programs like $ratexpand that expand polynomials. Or
>>is it not really a polynomial? RJF
>
>
> I do not understand this question either. Please explain. (sorry, I'm
> afraid I'm being annoying)
ratexpand produces an expanded version of a polynomial really fast.
However,
on things like quotients or non-poly forms, it doesn't do the same
thing as expand. if what is needed here can be done by ratexpand, it
would be faster.
>
> Another question: In hayat.lisp I find
>
> (defun tsprsum (f l type)
> (if (mfree f tvars) (newsym f)
> (let ((li (ncons (car l))) (hi (caddr l)) (lv (ncons (cadr l))) a
aa
> ($maxtayorder () )) ;; needed to determine when
terms
> are 0
> (if (and (numberp (car lv)) (numberp hi) (greaterp (car lv)
hi))
> (if (eq type '%SUM) (taylor2 0) (taylor2 1))
> (if (eq type '%SUM) (setq type () ))
> (do ((m (f* ([max-trunc]) (^ 2 $taylordepth))) (k 0 (f1+ k))
> (ans ;(mlet li lv (taylor2 (meval f)))
> (taylor2 (MAXIMA-SUBSTITUTE (car lv) (car li)
f))))
> ((equal hi (car lv)) ans)
> (rplaca lv (m1+ (car lv)))
> ;; A cheap heuristic to catch infinite recursion when
> ;; possible, should be improved in the future
> (if (> k m) (exp-pt-err)
> (setq a ;(mlet li lv (taylor2 (setq aa (meval f))))
> (taylor2 (MAXIMA-SUBSTITUTE (car lv) (car li)
> f))))
> (if type
> (if (and (1p (car a)) (1p (cdr a)) (not (1p aa)))
> (return ans)
> (setq ans (pstimes a ans)))
> (if (and (rczerop a) (not (signp e aa)))
> (return ans)
> (setq ans (psplus ans a)))))))))
>
> I do not understand the very first "if" statement, it seems to have 4
> arguments:
I think you are missing a ) because an if can't have 4 clauses.
I haven't checked it though.
That's the second if..
>
> (and (numberp ... ... hi))
>
> (if (eq type '%SUM) (taylor2 0) (taylor2 1))
>
> (if (eq type '%SUM) (setq type () ))
>
> (do ... )
>
> ???
>
> Did I miss something?
>
>
>
>