subresgcd



IMHO, the most interesting aspect of the rational functions module is
how the $ALGEBRAIC flag controls its behaviour (this is also the most
interesting source of bugs).  I hope the following description gives a
roughly correct mathematical model of what happens.

If $ALGEBRAIC is NIL all calculations are performed in a polynomial
ring R (with indeterminates corresponding to the elements of GENVAR).
Otherwise, the various algebraic relations (established either
internally or explicitly by the user) generate some ideal I, and the
calculations are performed in R/I.  Suppose that we are lucky and I is
a prime ideal (which means that R/I has no zero-divisors).

Suppose we are given two expressions with the same main variable.  In
this case, it makes sense to apply SUBRESGCD.  The idea is to consider
them as polynomials in their main variable.  The problem is that there
might be algebraic relations involving this variable.

Please ponder the consequences of this while waiting for

(C1) tellrat(t^2=x^2+1)$
(C2) gcd:subres$ /* This is the default anyway */
(C3) algebraic:true$
(C4) :lisp(trace prem)

WARNING:
TRACE: redefining function PREM in top-level, was defined in /home/wolfgang/maxima/src/binary-clisp/rat3c.fas
;; Tracing function PREM.
(PREM)
(C4) gcd(t+x,x^2+1);


to finish ;-)

Meanwhile, here is a bug fix proposal, which also fixes the Taylor
bugs

http://sourceforge.net/tracker/index.php?func=detail&aid=629539&group_id=4933&atid=104933

reported by B. Willis.  By the way, there are more brutal ways of
`fixing' theses bugs: 1) bind $ALGEBRAIC to NIL (at the beginning of
SUBRESGCD) or 2) comment out SUBRESGCD (and set $GCD to $SPMOD or
something)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cut ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(in-package "MAXIMA")

(defun subresgcd (p q)
  (if (not $algebraic)
      (psimp (p-var p) (subresgcd1 (p-terms p) (p-terms q)))
      ;; SUBRESGCD1 may introduce variables whose values are >= that of v
      ;; (because of TELLRAT properties of other variables).
      (let* ((v (p-var p))
	     (algord (get v 'algord)))
	(putprop v t 'algord)
	(prog1
	    (psimp v (subresgcd1 (p-terms p) (p-terms q)))
	  (putprop v algord 'algord))))) 


(defun subresgcd1 (p q)					
  (sloop for g = 1 then (pt-lc p)
	 for h = 1 then (pquotient (pexpt g d) h^d-1)
	 for d = (f- (pt-le p) (pt-le q))
	 for h^d-1 = (if (equal h 1) 1 (pexpt h (f1- d)))
	 do (psetq p q
		   q (pcquotient1 (pgcd1 p q) (ptimes g (ptimes h h^d-1))))
	 if (zerop (pt-le q))
	 return (if (pzerop (pt-lc q)) p 1)))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cut ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Wolfgang