Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't construct a rational fraction from a symbolic one. #7741

Closed
hivert opened this issue Dec 19, 2009 · 11 comments
Closed

Can't construct a rational fraction from a symbolic one. #7741

hivert opened this issue Dec 19, 2009 · 11 comments

Comments

@hivert
Copy link

hivert commented Dec 19, 2009

Given a symbolic expression which is a rational fraction sage refuse to convert it to a element of the Field of rational fraction:

hivert@boxen:~$ sage
----------------------------------------------------------------------
| Sage Version 4.2.1, Release Date: 2009-11-14                       |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: fr = (1+x)/(1+x+x^2)
sage: Fld = FractionField(PolynomialRing(QQ,x))
sage: Fld(fr)
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (1181, 0))

[...]

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

[...]

/usr/local/sage/local/lib/python2.6/site-packages/sage/rings/polynomial/polynomial_ring.pyc in _element_constructor_(self, x, check, is_gen, construct, **kwds)
    304                 x = x.numerator() * x.denominator().inverse_of_unit()
    305             else:
--> 306                 raise TypeError, "denominator must be a unit"
    307
    308         elif isinstance(x, pari_gen):

TypeError: denominator must be a unit

It seems that it needs to convert is to a polynomial. Of course if one convert numerator and denominator separately everything is Ok:

sage: Fld((1+x))/(1+x+x^2)
(x + 1)/(x^2 + x + 1)

I'm not sure about which component should be selected... Is it algebra, calculus or coercion...

Florent

CC: @burcin

Component: coercion

Keywords: Fraction Field

Author: Robert Bradshaw

Reviewer: Florent Hivert, Burcin Erocal

Merged: sage-4.6.alpha2

Issue created by migration from https://trac.sagemath.org/ticket/7741

@robertwb
Copy link
Contributor

comment:2

Attachment: 7741-symbolic-frac.patch.gz

@hivert
Copy link
Author

hivert commented Jan 17, 2010

Author: Robert Bradshaw

@hivert
Copy link
Author

hivert commented Jan 17, 2010

Reviewer: Florent Hivert

@rlmill
Copy link
Mannequin

rlmill mannequin commented Jan 18, 2010

Work Issues: needs rebase

@rlmill rlmill mannequin added s: needs work and removed s: positive review labels Jan 18, 2010
@loefflerd
Copy link
Mannequin

loefflerd mannequin commented Jun 29, 2010

Attachment: trac_7741-symbolic-frac-rebase.patch.gz

rebased to 4.4.4

@loefflerd loefflerd mannequin added s: needs review and removed s: needs work labels Jun 29, 2010
@ghost
Copy link

ghost commented Jul 14, 2010

comment:6

William points out that denominator is 1 will fail unless denominator is the Python int 1, and nothing else...

Is this really preferable to denominator == 1?

PS, Passes tests in sage/rings/fraction_field_element.pyx

Repository owner added s: needs work and removed s: needs review labels Jul 14, 2010
@robertwb
Copy link
Contributor

comment:7

Attachment: 7741-symbolic-frac-fixed.patch.gz

Actually, the "is 1" was intentional, as I wasn't thinking of taking that path if the user passed in a ring element (as opposed to the default value) and didn't want to make the default value None and handle it everywhere. In retrospect, I think it's fine for it to be equal to 1.

@burcin
Copy link

burcin commented Sep 25, 2010

comment:8

apply only attachment: 7741-symbolic-frac-fixed.patch.

@burcin
Copy link

burcin commented Sep 25, 2010

Changed work issues from needs rebase to none

@burcin
Copy link

burcin commented Sep 25, 2010

Changed reviewer from Florent Hivert to Florent Hivert, Burcin Erocal

@burcin burcin added this to the sage-4.6 milestone Sep 25, 2010
@qed777
Copy link
Mannequin

qed777 mannequin commented Sep 29, 2010

Merged: sage-4.6.alpha2

@qed777 qed777 mannequin removed the s: positive review label Sep 29, 2010
@qed777 qed777 mannequin closed this as completed Sep 29, 2010
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants