2. Canonic fraction
-------------------

For a mutually prime  n, d : (D : IntegralDomain),
how to set fraction of  n/d  in Spad with avoiding  gcd  and also
obtaining a correct fraction?

Simplest answer is: use pretend.

Better answer is: without knowing the representation of Fraction(D) it's impossible. And nobody, except the programmer of Fraction should know the representation.

Recall that (2, -3) are mutually prime in Integer, as well as (-2, 3), or
(-2,-3).

Internally, Fraction uses a record, but it tries to keep the representation normalized. So (2,-3) would be different from (-2,3).

There is desirable a function which can be applied like this:
                                                    fraction(NoGCD, n, d).

However, there is more. If you look into Fraction

https://github.com/hemmecke/fricas-svn/blob/master/src/algebra/fraction.spad.pamphlet#L314

you see that the argument type is only required to be IntegralDomain. So one could form Fraction(X) for X being of type IntegralDomain, but not of type GcdDomain. If X has not gcd function, it will of course not be applied if you construct an element via n/d.

Anyway, you probably need it for X=Integer.

So the only way you can do what you want is "pretend" or provide a patch that adds a function constructFractionWithoutCancelling:(S,S)->%.

But I will probably argue a lot that this function is basically like pretend and should better be avoided.

[snip]

When DoCon puts a string to Axiom, fractions are in their canonical form
by "gi". And it is desirable to avoid  gcd  when parsing (by dParse)
of such a fraction to Axiom.

OK, this is a situation where your parsing framework should know about the internal structure of FriCAS domains and Fraction in particular, i.e. "pretend" should be the way to go.

You should, however, mark such "pretend" places in big bold red letters so that maintenance does not become a nightmare. Whenever a FriCAS domain changes its representation, your framework must be changed as well. So keep producing lots of test cases so that such situations are caught before a new release.

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.

Reply via email to