1 | initial version |
Avoid the symbolic ring whenever you can, and work in the appropriate structures for the task at hand.
Manipulate polynomials and rational fractions in the corresponding structures. Define
sage: R.<z> = PolynomialRing(QQ)
sage: F = FractionField(R)
sage: S = PowerSeriesRing(QQ,'z')
and check the result:
sage: R
Univariate Polynomial Ring in z over Rational Field
sage: F
Fraction Field of Univariate Polynomial Ring in z over Rational Field
sage: S
Power Series Ring in z over Rational Field
Define your polynomials and rational fractions.
sage: a = 2 - 3*z + z^2
sage: b = z
sage: f = a / b
Check what you get.
sage: a
z^2 - 3*z + 2
sage: b
z
sage: f
(z^2 - 3*z + 2)/z
Check out where a, b, f live.
sage: a.parent()
Univariate Polynomial Ring in z over Rational Field
sage: b.parent()
Univariate Polynomial Ring in z over Rational Field
sage: f.parent()
Fraction Field of Univariate Polynomial Ring in z over Rational Field
Want the Taylor series at 1 of f, and its inverse under composition.
First shift the function to move to the point 1.
sage: g = f(1+z)
sage: g
(z^2 - z)/(z + 1)
Move to the ring of power series.
sage: gg = S(g)
Check the first few terms.
sage: gg + O(z^8)
-z + 2*z^2 - 2*z^3 + 2*z^4 - 2*z^5 + 2*z^6 - 2*z^7 + O(z^8)
The constant term is zero and the coefficient of z is nonzero: we can compute the composition inverse.
sage: hh = gg.reversion()
Examine the first few terms.
sage: hh + O(z^8)
-z + 2*z^2 - 6*z^3 + 22*z^4 - 90*z^5 + 394*z^6 - 1806*z^7 + O(z^8)
2 | No.2 Revision |
Avoid the symbolic ring whenever you can, and work in the appropriate structures for the task at hand.
Manipulate polynomials and rational fractions in the corresponding structures. Define
sage: R.<z> = PolynomialRing(QQ)
sage: F = FractionField(R)
sage: S = PowerSeriesRing(QQ,'z')
and check the result:
sage: R
Univariate Polynomial Ring in z over Rational Field
sage: F
Fraction Field of Univariate Polynomial Ring in z over Rational Field
sage: S
Power Series Ring in z over Rational Field
Define your polynomials and rational fractions.
sage: a = 2 - 3*z + z^2
sage: b = z
sage: f = a / b
Check what you get.
sage: a
z^2 - 3*z + 2
sage: b
z
sage: f
(z^2 - 3*z + 2)/z
Check out where a, b, f live.
sage: a.parent()
Univariate Polynomial Ring in z over Rational Field
sage: b.parent()
Univariate Polynomial Ring in z over Rational Field
sage: f.parent()
Fraction Field of Univariate Polynomial Ring in z over Rational Field
Want the Taylor series at 1 of f, and its inverse under composition.
First shift the function to move to the point 1.
sage: g = f(1+z)
sage: g
(z^2 - z)/(z + 1)
Move to the ring of power series.
sage: gg = S(g)
Check the first few terms.
sage: gg + O(z^8)
-z + 2*z^2 - 2*z^3 + 2*z^4 - 2*z^5 + 2*z^6 - 2*z^7 + O(z^8)
The constant term is zero and the coefficient of z is nonzero: we can compute the composition inverse.
sage: hh = gg.reversion()
Examine the first few terms.
sage: hh + O(z^8)
-z + 2*z^2 - 6*z^3 + 22*z^4 - 90*z^5 + 394*z^6 - 1806*z^7 + O(z^8)
Check that hh is the composition inverse of gg:
sage: hh(gg)
z + O(z^21)
sage: gg(hh)
z + O(z^21)
3 | No.3 Revision |
Avoid the symbolic ring whenever you can, and work in the appropriate structures for the task at hand.
Manipulate polynomials and rational fractions in the corresponding structures. Define
sage: R.<z> = PolynomialRing(QQ)
sage: F = FractionField(R)
sage: S = PowerSeriesRing(QQ,'z')
and check the result:
sage: R
Univariate Polynomial Ring in z over Rational Field
sage: F
Fraction Field of Univariate Polynomial Ring in z over Rational Field
sage: S
Power Series Ring in z over Rational Field
Define your polynomials and rational fractions.
sage: a = 2 - 3*z + z^2
sage: b = z
sage: f = a / b
Check what you get.
sage: a
z^2 - 3*z + 2
sage: b
z
sage: f
(z^2 - 3*z + 2)/z
Check out where a, b, f live.
sage: a.parent()
Univariate Polynomial Ring in z over Rational Field
sage: b.parent()
Univariate Polynomial Ring in z over Rational Field
sage: f.parent()
Fraction Field of Univariate Polynomial Ring in z over Rational Field
Want the Taylor series at 1 of f, and its inverse under composition.
First shift the function to move to the point 1.
sage: g = f(1+z)
sage: g
(z^2 - z)/(z + 1)
Move to the ring of power series.
sage: gg = S(g)
Check the first few terms.
sage: gg + O(z^8)
-z + 2*z^2 - 2*z^3 + 2*z^4 - 2*z^5 + 2*z^6 - 2*z^7 + O(z^8)
The constant term is zero and the coefficient of z is nonzero: we can compute the composition inverse.
sage: hh = gg.reversion()
Examine the first few terms.
sage: hh + O(z^8)
-z + 2*z^2 - 6*z^3 + 22*z^4 - 90*z^5 + 394*z^6 - 1806*z^7 + O(z^8)
Check that hh is the composition inverse of gg:
sage: hh(gg)
z + O(z^21)
sage: gg(hh)
z + O(z^21)
EDIT (to answer your follow-up question).
If you have a rational fraction g
, then gnum = g.numerator()
and gden = g.denominator()
will get you the polynomials for the numerator and the denominator of g
. You can check where they live by gnum.parent()
and gden.parent()
. If you need them to be in R
, F
or S
, just do R(gnum)
, F(gnum)
, S(gnum)
, etc.
4 | No.4 Revision |
Avoid the The symbolic ring whenever you can, and work in the appropriate structures for has its strengths mostly in calculus.
Sage also implements a wealth of algebraic structures,
some of which are more suited to the task at hand.hand here.
Manipulate polynomials and rational fractions in the corresponding structures. Define
sage: R.<z> = PolynomialRing(QQ)
sage: F = FractionField(R)
sage: S = PowerSeriesRing(QQ,'z')
and check the result:
sage: R
Univariate Polynomial Ring in z over Rational Field
sage: F
Fraction Field of Univariate Polynomial Ring in z over Rational Field
sage: S
Power Series Ring in z over Rational Field
Define your polynomials and rational fractions.
sage: a = 2 - 3*z + z^2
sage: b = z
sage: f = a / b
Check what you get.
sage: a
z^2 - 3*z + 2
sage: b
z
sage: f
(z^2 - 3*z + 2)/z
Check out where a, b, f live.
sage: a.parent()
Univariate Polynomial Ring in z over Rational Field
sage: b.parent()
Univariate Polynomial Ring in z over Rational Field
sage: f.parent()
Fraction Field of Univariate Polynomial Ring in z over Rational Field
Want the Taylor series at 1 of f, and its inverse under composition.
First shift the function to move to the point 1.
sage: g = f(1+z)
sage: g
(z^2 - z)/(z + 1)
Move to the ring of power series.
sage: gg = S(g)
Check the first few terms.
sage: gg + O(z^8)
-z + 2*z^2 - 2*z^3 + 2*z^4 - 2*z^5 + 2*z^6 - 2*z^7 + O(z^8)
The constant term is zero and the coefficient of z is nonzero: we can compute the composition inverse.
sage: hh = gg.reversion()
Examine the first few terms.
sage: hh + O(z^8)
-z + 2*z^2 - 6*z^3 + 22*z^4 - 90*z^5 + 394*z^6 - 1806*z^7 + O(z^8)
Check that hh is the composition inverse of gg:
sage: hh(gg)
z + O(z^21)
sage: gg(hh)
z + O(z^21)
EDIT (to answer your follow-up question).
If you have a rational fraction g
, then gnum = g.numerator()
and gden = g.denominator()
will get you the polynomials for the numerator and the denominator of g
. You can check where they live by gnum.parent()
and gden.parent()
. If you need them to be in R
, F
or S
, just do R(gnum)
, F(gnum)
, S(gnum)
, etc.