test-poly.ss 380 B

123456789101112131415161718
  1. (define x-1 (poly/make-from-dense 1 '(1 -1)))
  2. (define x+1 (poly/make-from-dense 1 '(1 1)))
  3. (define p1 (poly/mul (poly/mul x-1 x-1) x+1))
  4. (define p2 (poly/mul (poly/mul x+1 x+1) x-1))
  5. (poly/gcd-euclid p1 p2)
  6. ;; => (*dense* 1 1 0 -1)
  7. (pcf:->expression
  8. (poly/gcd-euclid p1 p2)
  9. '(x))
  10. ;; => (+ -1 (expt x 2))
  11. (poly->roots (poly/mul (poly/mul x-1 x-1) x+1))
  12. ;; => (-1.0 1.0 1.0)