[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-mail] A newby question about eval and Expression
From: |
Martin Rubey |
Subject: |
[Axiom-mail] A newby question about eval and Expression |
Date: |
13 Nov 2005 12:39:40 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 |
Dear Doug,
there are two issues in your code:
Doug Stewart writes:
> )clear all
> digits 20
> -- n:=x^3+a1*x^2+a2*x+a3 ::Polynomial Fraction Integer
>
> Q:=(3*a2-a1^2)/9
> R:=(9*a1*a2-27*a3-2*a1^3)/54
> S:=(R+(Q^3+R^2)^(1/2))^(1/3)
> T:=(R-(Q^3+R^2)^(1/2))^(1/3)
> x1:=S+T-a1/3
note that x1 is *not* a polynomial. Not even a rational function.
> x2:=-(S+T)/2-a1/3 + %i*sqrt(3)*(S-T)/2
> x3:=-(S+T)/2-a1/3 - %i*sqrt(3)*(S-T)/2
>
> a5:=x^3+a1*x^2+a2*x+a3 ::Polynomial Fraction Integer;
> a6:=('x-x11) ::Polynomial Fraction Integer;
>
> a7:=monicDivide(a5,a6,x) ;
>
> a77:=a7.quotient ::Polynomial Fraction Integer;
> a78:=a7.remainder ::Polynomial Fraction Integer;
>
>
> qu1 :=eval(a77,x11,x1)
> rem1::POLY(FRAC(INT)):=eval(a78,x11,x1)
>
> this gives an error message:
>
> The form on the left hand side of an assignment must be a single
> variable ... supporting the setelt operation.
The notation "::" is a shorthand for "coerce". But then, this is bad
syntax. You can either say
rem1:POLY(FRAC(INT)):=eval(a78,x11,x1)
or
rem1:=eval(a78,x11,x1)::POLY(FRAC(INT))
However, since x1 is not a polynomial, both will fail.
The domain "Expression Integer" is the domain of all expressions you can form
with coefficients being integers. For example:
sin(x)^2+cos(x)^2-1
or
5^(n/2)
or
%pi*sum(1/i, i=1..n)
...
However, if you *can* avoid this domain (often you can't), try to do so, since
it has a major drawback:
A computer cannot test reliably whether some element of Expression Integer is
zero or not. Axiom tries, but often fails. For example, the first example above
is not zero for Axiom...
(MuPAD, Mathematica and Maple try harder, but they often fail, too)
Note that this problem does not arise for many other domains: you can test for
zero in
Integer,
Polynomial Integer,
AlgebraicNumber,
PrimeField 5
Matrix Integer,
Fraction Polynomial PrimeField 1783
and so on.
Martin