1 ;;; -*- Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;;
5 (defmfun $eliminate
(eqns vars
)
10 (declare (special $dispflag
))
11 (unless (and ($listp eqns
) ($listp vars
))
12 (merror (intl:gettext
"eliminate: arguments must both be lists.")))
13 (when (> ($length vars
) l
)
14 (merror (intl:gettext
"eliminate: more variables than equations.")))
16 (merror (intl:gettext
"eliminate: can't eliminate from only one equation.")))
17 (when (= ($length vars
) l
)
18 (setq vars
($reverse vars
))
19 (setq sv
(maref vars
1))
20 (setq vars
($reverse
(simplify ($rest vars
))))
22 (setq eqns
(simplify (map1 (getopr 'meqhk
) eqns
)))
23 (dolist (v (cdr vars
))
24 (let ((teqns '((mlist))))
26 ((or (> j l
) (not ($freeof v
(simplify ($first eqns
))))))
27 (setq teqns
($cons
(simplify ($first eqns
)) teqns
))
28 (setq eqns
(simplify ($rest eqns
))))
29 (cond ((like eqns
'((mlist)))
32 (setq teqns
($append teqns
(simplify ($rest eqns
))))
33 (setq eqns
(simplify ($first eqns
)))
35 (let ((se '((mlist))))
36 (dotimes (j l
) ;maxima starts indices with 1, therefore the 1+
37 (setq se
($cons
(simplify ($resultant eqns
(maref teqns
(1+ j
)) v
)) se
)))
40 (list '(mlist) ($rhs
(simplify (mfuncall '$ev
(simplify ($last
(simplify ($solve
(maref eqns
1) sv
)))) '$eval
))))