On Fri, Oct 3, 2008 at 11:12 AM, Waldek Hebisch wrote:
>
> Bill Page wrote:
>> 1) Use of coercions and types in InputForm.
>> ...
>> One alternative would be to introduce a specific (non-overloaded)
>> operation exported by AlgebraicNumber such as 'algebraicNumber'
>> that does the same thing. That is how Float values are currently
>> handled:
>>
>>     (8) -> 3.141592::InputForm
>>
>>        (8)  (float 231808574432053350722 - 66 2)
>>                                                     Type: InputForm
>>     (9) -> unparse %
>>
>>        (9)  "float(231808574432053350722,-66,2)"
>>                                                     Type: String
>>
>> Would doing something like this:
>>
>>    (algebraicNumber (** 2 (/ 1 2)))
>>
>> be better?
>>
>
> What is type of argument to this hypotethical function?

algebraicNumber:Expression Integer -> AlgebraicNumber

> AFAICS constructing floats works well because float can be
> reconstructed from few integers.

I am concerned that the definition and use of coercion to InputForm is
not very clear in panAxiom. I believe the main purpose is to provide a
convenient means in each domain to express domain values as easily
evaluated expressions. It seems to me that there is always a general
solution to this problem that is based on the representation Rep of
the domain. For example, for any domain MyDomain

   if Rep has CoercibleTo(InputForm) then
      coerce(x:%) :InputForm ==
          convert(['myDomain,coerce(rep x)@InputForm])
      myDomain(x:Rep):% == per x

To make this work in general we also need standard coercions to
InputForm for built-in constructors like Record. For the most part
these already exist. For example we need something like this: For any
Record(a:A,b:B, ... ):

   if A has CoercibleTo(InputForm) and
     B has CoercibleTo(InputForm) ... then
       coerce(x:%):InputForm ==
          convert(['construct,convert([coerce(rep(x).a)@InputForm,
            coerce(rep(x).a)@InputForm, ... ]) ])

In the case of Float the Rep is

   Rep := Record( mantissa:Interger, exponent:Integer )

So for '3.141592::InputForm' we would get:

  (float (construct (231808574432053350722 -66)))

or unparse

  float(construct(231808574432053350722, -66))

This is essentially what is implemented for Float except that the
'construct' operator is absorbed into 'float' and the 3rd argument is
gratuitous.

> But for algebraic numbers we need much more complicated construction:
> in general we need to specify tower of algebraic extensions.

I don't think so. The same general construction can be applied as
above. The Rep of AlgebraicNumber is Expression(Integer).

>
>> 2) Notice that the InputForm value representing the same expression
>> occur with both ** and ^. Which one is currently the preferred form?
>>
>
> ^ is the preferred form.  ** will be eliminated.
>

Ok, I will change my patch to reflect this. Thanks.

Regards,
Bill Page.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to