>my suggestion for comparing mrats in the testing is to call
>$ratdisrep on the mrat, and then proceed however you would, otherwise.
>RJF
OK, I've modified approx-alike to do this, I think. The testsuite gives about 120 failures--I think all of them are due
to comparing taylor polynomials. The use of ratdisrep allows a test such as
taylor(x,x,0,2);
''(taylor(x,x,0,12))$
to pass. One issue: In rtest9, there is a test
taylor(1+x+y+z,[x,0,3],[y,1,2],[z,2,1]);
4+(z-2)+(y-1)+x$
1/%;
1/4-(z-2)/16+(-1/16+(z-2)/32)*(y-1)+(1/64-3*(z-2)/256)*(y-1)^2
+(-1/16+(z-2)/32+(1/32-3*(z-2)/128)*(y-1)+(-3/256+3*(z-2)/256)*(y-1)^2)*x
+(1/64-3*(z-2)/256+(-3/256+3*(z-2)/256)*(y-1)+(3/512-15*(z-2)/2048)*(y-1)^2)
*x^2 +(-1/256+(z-2)/256+(1/256-5*(z-2)/1024)*(y-1)+(-5/2048+15*(z-2)/4096)*(y-1)^2) *x^3$
I guess one way to allow these tests to pass would be
-----------------------------
taylor(1+x+y+z,[x,0,3],[y,1,2],[z,2,1]); /* silly test */
''(taylor(1+x+y+z,[x,0,3],[y,1,2],[z,2,1]))$
1/%;
''(taylor(1/(1+x+y+z),[x,0,3],[y,1,2],[z,2,1]))$
Is there is a better way?
--Barton
(defun approx-alike (f g)
(cond ((floatp f) (and (floatp g) ($float_approx_equal f g)))
(($bfloatp f) (and ($bfloatp g) ($bfloat_approx_equal f g)))
((atom f) (and (atom g) (equal f g)))
;; allow a test such as sign(z); 'pnz$ to pass
((eq 'mquote (mop f))
(approx-alike (second f) g))
((atom g) (and (atom f) (equal f g)))
(($taylorp g)
(and ($taylorp f) (approx-alike (ratdisrep f) (ratdisrep g))))
(($ratp g)
(and ($ratp f) (approx-alike (ratdisrep f) (ratdisrep g))))
((eq 'lambda (mop f))
(and (eq 'lambda (mop g))
(approx-alike-list (mapcar #'(lambda (s) (simplifya s nil)) (margs f))
(mapcar #'(lambda (s) (simplifya s nil)) (margs g)))))
((arrayp f)
(and (arrayp g) (approx-alike ($listarray f) ($listarray g))))
((hash-table-p f)
(and (hash-table-p g) (approx-alike ($listarray f) ($listarray g))))
((and (eq (not (memq 'array (car f))) (not (memq 'array (car g))))
(or (approx-alike (mop f) (mop g))
(and (symbolp (mop f)) (symbolp (mop g)) (approx-alike ($nounify (mop f)) ($nounify (mop g))))))
(approx-alike-list (margs f) (margs g)))
(t nil)))