existed), whereas Ralph's
I prefer my name to be spelled correctly. ;-)
was to nudge FriCAS into creating an
equation between polynomials over the extension field and then let
FriCAS automatically lift the given polynomial over the extension
field.
No. Look closer to how I've defined p.
p:P := x^2 + 1
That is a little different from what Bill showed. In fact, there is also
a coercion going on behind the scences, but I explicitly declare that I
want p to be of type P. That gives FriCAS the hint that that the input
string must be coerced in such a way that the result is of type P.
It's a little like saying
(x^2 + 1)@P
(Yes @ not ::.)
Let's see what you have done.p := x**2 + 1 :: POLY gf2p := x**2 + 1 ::
POLY gf2
p := x^2 + 1 :: POLY gf2
Let's abbreviate Q:=POLY gf2.
I'm not not completely sure, how strong :: binds so I don't know exactly
whether the lhs is to be read as
x^2 + (1::Q)
or as
(x^2 + 1)::Q
Let's assume the second. The part inside the parentheses is something
that when typed in on its own gives you something like
Polynomial(Integer). The ::Q then instructs FriCAS to search for a
function coerce:Polynomial(Integer)->P and apply it. (Actually in the
interpreter FriCAS tries harder and also looks for "convert" functions
of that type.)
So your p will be of type Q.
Now, Bill then uses p::P (with P:=Polynomial(gf16) which effectively
looks for a function
coerce: Q -> P
I didn't have to do this coercions, since my p had already been created
to be of the right type.
Why I had to do this x::P=a was simply to help FriCAS getting the types
right that the 2-argument eval function wants to have.
If you use the 3-argument eval, the types are already fine, so nothing
has to be done.
The FriCAS type system sure is a subtle and complex beast!
When you first work with FriCAS, you will surely hate that Fricas
doesn't let you do things that appear trivial in other CAS. Maybe this
hurdles is one of the reason why Axiom failed on the commercial market.
However, if you take your time to analyse why something doesn't work
then you will have to agree that FriCAS (apart from bugs) did exactly
what you instructed it to do. If you arrive at writing programs in SPAD,
you will appreciate that one always knows what FriCAS is doing.
The user interface (usually called "the interpreter") is what adds a bit
of guessing to let users enter such seemingly senseless input like
x^2+1
Maybe you enter this and wanted it to live in a polynomial ring over
rational numbers (i.e. Polynomial(Fraction Integer)). But how would
*you* guess the result type should be?
You can always be wrong. Maybe I wanted it to live in P or Q.
Untyped expressions are perhaps easy to work with, but with typed
expressions, you have more information at hand when you need it and thus
it's less risky to do something wrong by accident.
Good luck with learning FriCAS.
Ralf
--
You received this message because you are subscribed to the Google Groups "FriCAS -
computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.