Taylor bugs / more precise question



On Wed, 5 Feb 2003, Richard Fateman wrote:

> You say...
> ****
> now the DISREP property doesn't correspond to the varlist variable
> anymore. Anything that uses the genvars internally and doesn't know about
> some subprocedure doing ($ratdisrep ($rat exp var)) will fail now.
> ****
> 
> Any subprogram that uses the DISREP property without making sure
> that the DISREP properties are consistent with genvar/varlist
> data is erroneous. such programs should always have at their
> top level something like
> (defun set-up-disreps-then-do-foo(foo)
>     (mapc #'(lambda(v g)(setf (get g 'disrep) v)) varlist genvars) 
> (funcall foo))

So it "remains" to look for all programs that contain a call to eg cdisrep
or rcdisrep or the like and protect all calls to unknown routines or
routines that contain $rat or the like -- foo -- with 

(let (varlist genvar) foo)

????

This seems to be a lot of work. (well, maybe it isn't: in hayat there are 
3 calls to maxima-substitute and 4 calls to meval, but I don't know which 
other calls would have to be protected)

BTW, there are comments in the routine that contain the 
maxima-substitute call which finally leads to fpolysum:


	(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))))


but meval would have to be protected too, wouldn't it? How could we find 
the places where a call has to be protected?

(so the behaviour of ($ratdisrep ($rat exp var)) is as expected?
 wouldn't it be easier to change that?)

> If you do this
> rat(x,x)$
> rat(y,y)$
> rat(z,z)$  then (when this program was first written)
> only ONE genvar would be used
> 
> If you do rat(x,x)+rat(y,y)  then 2 separate disreps are
> done and stuff is done with a varlist of (x,y)  or maybe
> (y,x)...

yes, it is even possible that one gensym is used for 2 variables in a 
single expression:
(C1) rat(x);

(D1)/R/                                x

MAXIMA>>(bl)

((|$x|) ((#:|x21773| |$x|)))

(C2) rat(y);

(D2)/R/                                y

MAXIMA>>(bl)

((|$y|) ((#:|x21773| |$y|)))

(C3) rat(x+y);

(D3)/R/                              y + x

MAXIMA>>(bl)

((|$x| |$y|) ((#:|x21773| |$x|) (#:|x21773| |$y|)))

Well, #:|x21773| and #:|x21773| do not look very different, but 
they have different DISREP props... (of course, they are different 
symbols, but it makes debugging a little funnier this way)

Martin