Error: "fraction must have unit denominator" when converting symbolic expression into Univariate Polynomial Ring
I want to convert a symbolic expression into (fractional) polynomials over RealField
.
ploy_real = RealField()['E']
(E_real,) = ploy_real._first_ngens(1)
E = SR.var('E')
f = -1/4*(4*E + 3)/E
f.polynomial(base_ring=RealField())
However, I got this error. How to solve this error? Hasn't f
already had a denominator E
?
/usr/lib/python3/dist-packages/sage/rings/fraction_field.py in _call_(self, x, check)
1242 # However, too much existing code is expecting this to throw a
1243 # TypeError, so we decided to keep it for the time being.
-> 1244 raise TypeError("fraction must have unit denominator")
1245 return num * den.inverse_of_unit()
Your expression cannot be a polynomial. Consider :
i. e. $1+\frac{3}{4x}$, which is not a (finite) polynomial. You may try :
i. e.
$$ \frac{4 \, x + 3}{4 \, x} = \frac{3}{4} \, {\sum_{p=0}^{+\infty} {\left(-x + 1\right)}^{p}} + 1 $$
valid for $x\in\left(0\ 1\right)$.
But this "polynomial" has an infinite number of terms...
I see. I found what I want is
f.fraction(RealField())
Thank you.I see. BTW, ypu can get that more easily, along the lines of :
HTH,