On 08/21/2006 06:27 PM, Jay Belanger wrote:
Ralf Hemmecke <[EMAIL PROTECTED]> writes:
On 08/21/2006 03:38 AM, Jay Belanger wrote:
Martin Rubey <[EMAIL PROTECTED]> writes:
"Igor Khavkine" <[EMAIL PROTECTED]> writes:
Can someone explain the following behavior of Taylor series in Axiom?
(113) -> y := taylor x
(113) x
Type: UnivariateTaylorSeries(Expression Integer,x,0)
(114) -> x*y
(114) x x
Type: UnivariateTaylorSeries(Expression Integer,x,0)
(115) -> coefficient(%,1)
(115) x
Type: Expression Integer
The reason is that Axiom cannot really know whether you meant x in (114) to be
an element of the coefficient Ring EXPR INT, or to be a univariate Taylor
series. In case of doubt, it usually chooses the wrong possibility :-)
When multiplying two elements, shouldn't Axiom try to coerce them to
be in the same structure? (I realize it doesn't, particularly here,
but wouldn't that be reasonable behavior?)
But Axiom coerced the two x to the same domain!!!
Not in any meaningful way.
Well, but how can you tell this to Axiom? It should be impossible to
construct the domain UnivariateTaylorSeries(Expression Integer,x,0).
I guess the Axiom designers thought that returning that domain for
taylor x would be reasonable. I must say, I question that.
UTS(Fraction Integer, x, 0) would have been sufficient and you wouldn't
have the trouble.
What I think should have happened is something like
(1) -> y := taylor x
(1) x
Type: UnivariateTaylorSeries(Expression Integer,x,0)
(2) -> (x::UnivariateTaylorSeries(Expression Integer,x,0))*y
2
(2) x
Type: UnivariateTaylorSeries(Expression Integer,x,0)
(without the cast having to be explicit).
Oh, interesting! Then the interpreter is to blame for chosing the wrong
coerce function.
But see, x is a symbol which should be coerce into a Taylor series. The
interpreter has several choices. So assuming the ideal that the
interpreter should have no mathematical knowledge itself, it can only
take the available information from the library. But there are several
available ways to go from x to UTS(Expression Integer,x,0). So how can
the interpreter ever know that it does the wrong thing?
The first x is a coefficient, and the second x is the variable from
the Taylor series. So you cannot complain.
Oh, I can always complain. The only question is whether or not my
complaints are justified.
The only problem is that it is terribly confusing. Unfortunately, I
cannot even blame that the user did anything wrong since Axiom came up
with this strange type UnivariateTaylorSeries(Expression Integer,x,0).
But I could blame the user for trying to do "x * y". Here you instruct
the compiler to guess since there is no function
*: (Symbol, UTS(Expression Integer,x,0))->UTS(Expression Integer,x,0)
so the interpreter has to do something with the x. It coerces it to
Expression(Integer). That is perfectly legal.
But not perfectly reasonable, I think.
A program like Axiom does not "reason". Is simply follows "stupid"
instructions.
And it isn't coercing x to be in the same domain as the other x, which
> is what I think should happen.
Well, what should happen is, that Axiom users should not be confronted
with such terribly confusing stuff. First the user should learn that
Expression Integer is very very dangerous (as you can see) if used in
connection with a polynomial or powerseries domain.
One cannot ban Expression(Integer) from Axiom since it is quite powerful
in general, but Expression(Integer) is also a bit like trying to avoid
types in a strongly typed system. To my taste, working with
Expression(Integer) is like working in Mma or Maple. So one shoudn't be
surprised.
Ralf
_______________________________________________
Axiom-math mailing list
Axiom-math@nongnu.org
http://lists.nongnu.org/mailman/listinfo/axiom-math