Negligible terms in polynomials
- Subject: Negligible terms in polynomials
- From: Alexey Beshenov
- Date: Sat, 10 Jan 2009 18:05:25 +0300
Maybe it is really handy to have a special version of
freeof(x_1,...,x_n, expr) which compares x_1,...,x_n only
with non-dummy variables in expr.
Here's a code which could be used in addition to nrat4.lisp
stuff:
------------------------------------------------------------
(defun lfreeof-var (x expr)
(let*
(($listdummyvars nil)
(v ($listofvars expr)))
(loop while x do
(if (member (car x) v :test 'equal)
(return-from lfreeof-var nil))
(setf x (cdr x)))
t))
(defun $lfreeof_var (x expr)
(if ($listp x)
(lfreeof-var (margs x) expr)
(merror "First argument must be a list")))
(defun $freeof_var (&rest xe)
(let ((ex (reverse xe)))
(lfreeof-var (cdr ex) (car ex))))
------------------------------------------------------------
Examples:
freeof_var (x,y,z, x^n + y^n = z^n) => false
freeof (x,y,z, x^n + y^n = z^n) => false
Dummy variables:
freeof_var (i, 'sum(i,i,0,1000)) => true
freeof (i, 'sum(i,i,0,1000)) => true
Useless for operators or constants:
freeof_var (cos, cos(x)) => true
freeof (cos, cos(x)) => false
freeof_var (23, 23*x) => true
freeof (23, 23*x) => false
But may be useful for subscripted names:
freeof_var (x,y,z, x[0]^n + y[0]^n = z[0]^n) => true
freeof (x,y,z, x[0]^n + y[0]^n = z[0]^n) => false
--
Setting Orange, Chaos 10 YOLD 3175
Alexey Beshenov http://beshenov.ru/