ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 23 Jul 2014 13:38:52 -0500Series Reversionhttp://ask.sagemath.org/question/23500/series-reversion/I have a rational polynomial f(z) = P(z)/Q(z) which I want to revert (I'm trying to find the inverse of f).
I'll pick a simple example, the function f(z) = (1/z-1)^4
sage: z = var('z')
sage: z = FractionField(PolynomialRing(QQ, 'z')).objgen()
sage: f(z) = (1/z-1)^4
sage: g = f(z).taylor(x,2,4); #I expand f in a Taylor series just to make sure it's a series
sage: f.expand().reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
sage: g1 = g.power_series(QQ)
TypeError: denominator must be a unit
sage: g.reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
A power series P(z) is not a rational function P(z)/Q(z). That's why the `TypeError: denominator must be a unit` appears.
Is it possible that Sage cannot invert rational polynomials? In the [Sage help text](http://www.sagemath.org/doc/reference/power_series/sage/rings/power_series_poly.html) the computation is passed to pari first, before using Lagrangian inversion.
I thought Sage uses FLINT. Why is it not used for computing the inverse of rational polynomials?
----------
EDIT (after answer by slelievre):
My problem now is how to avoid using the Symbolic Ring. I'm trying to do the following:
I want to invert an approximation formula for the Gamma-function. I am using [Spouge's approximation](https://en.wikipedia.org/wiki/Spouge's_approximation). It has terms in the numerator and the denominator. Ithink I can compute them separetely per se, but what if I wanted to do a Pade approximation of the function
sage: f = (z+13)^(z+1/2)*exp(z)
sage: g = f.pade(5,5)
(it's the term ahead of the sum term in Spouge's approximation)
How do I get separate polynomials for the numerator and the denominator that are defined in the right algebraic structure?
Sun, 20 Jul 2014 05:43:52 -0500http://ask.sagemath.org/question/23500/series-reversion/Comment by rws for <p>I have a rational polynomial f(z) = P(z)/Q(z) which I want to revert (I'm trying to find the inverse of f).</p>
<p>I'll pick a simple example, the function f(z) = (1/z-1)^4</p>
<pre><code>sage: z = var('z')
sage: z = FractionField(PolynomialRing(QQ, 'z')).objgen()
sage: f(z) = (1/z-1)^4
sage: g = f(z).taylor(x,2,4); #I expand f in a Taylor series just to make sure it's a series
sage: f.expand().reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
sage: g1 = g.power_series(QQ)
TypeError: denominator must be a unit
sage: g.reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
</code></pre>
<p>A power series P(z) is not a rational function P(z)/Q(z). That's why the <code>TypeError: denominator must be a unit</code> appears. </p>
<p>Is it possible that Sage cannot invert rational polynomials? In the <a href="http://www.sagemath.org/doc/reference/power_series/sage/rings/power_series_poly.html">Sage help text</a> the computation is passed to pari first, before using Lagrangian inversion.</p>
<p>I thought Sage uses FLINT. Why is it not used for computing the inverse of rational polynomials?</p>
<hr/>
<p>EDIT (after answer by slelievre):</p>
<p>My problem now is how to avoid using the Symbolic Ring. I'm trying to do the following:</p>
<p>I want to invert an approximation formula for the Gamma-function. I am using <a href="https://en.wikipedia.org/wiki/Spouge's_approximation">Spouge's approximation</a>. It has terms in the numerator and the denominator. Ithink I can compute them separetely per se, but what if I wanted to do a Pade approximation of the function</p>
<pre><code>sage: f = (z+13)^(z+1/2)*exp(z)
sage: g = f.pade(5,5)
</code></pre>
<p>(it's the term ahead of the sum term in Spouge's approximation)</p>
<p>How do I get separate polynomials for the numerator and the denominator that are defined in the right algebraic structure? </p>
http://ask.sagemath.org/question/23500/series-reversion/?comment=23507#post-id-23507This is not sufficient for me to get the error. Please give all instructions necessary to reproduce the error from a fresh Sage session.Mon, 21 Jul 2014 00:50:26 -0500http://ask.sagemath.org/question/23500/series-reversion/?comment=23507#post-id-23507Comment by slelievre for <p>I have a rational polynomial f(z) = P(z)/Q(z) which I want to revert (I'm trying to find the inverse of f).</p>
<p>I'll pick a simple example, the function f(z) = (1/z-1)^4</p>
<pre><code>sage: z = var('z')
sage: z = FractionField(PolynomialRing(QQ, 'z')).objgen()
sage: f(z) = (1/z-1)^4
sage: g = f(z).taylor(x,2,4); #I expand f in a Taylor series just to make sure it's a series
sage: f.expand().reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
sage: g1 = g.power_series(QQ)
TypeError: denominator must be a unit
sage: g.reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
</code></pre>
<p>A power series P(z) is not a rational function P(z)/Q(z). That's why the <code>TypeError: denominator must be a unit</code> appears. </p>
<p>Is it possible that Sage cannot invert rational polynomials? In the <a href="http://www.sagemath.org/doc/reference/power_series/sage/rings/power_series_poly.html">Sage help text</a> the computation is passed to pari first, before using Lagrangian inversion.</p>
<p>I thought Sage uses FLINT. Why is it not used for computing the inverse of rational polynomials?</p>
<hr/>
<p>EDIT (after answer by slelievre):</p>
<p>My problem now is how to avoid using the Symbolic Ring. I'm trying to do the following:</p>
<p>I want to invert an approximation formula for the Gamma-function. I am using <a href="https://en.wikipedia.org/wiki/Spouge's_approximation">Spouge's approximation</a>. It has terms in the numerator and the denominator. Ithink I can compute them separetely per se, but what if I wanted to do a Pade approximation of the function</p>
<pre><code>sage: f = (z+13)^(z+1/2)*exp(z)
sage: g = f.pade(5,5)
</code></pre>
<p>(it's the term ahead of the sum term in Spouge's approximation)</p>
<p>How do I get separate polynomials for the numerator and the denominator that are defined in the right algebraic structure? </p>
http://ask.sagemath.org/question/23500/series-reversion/?comment=23533#post-id-23533Note: (a) using Sage in a terminal will allow you to post your code by an easy copy-paste (where the input will have the `sage: ` prompt and the output will be mixed in with the input). (b) I edited the code in your original question to make it display better. (c) I added your follow-up question as an edit to your main question rather than an answer to your original question.Tue, 22 Jul 2014 08:27:49 -0500http://ask.sagemath.org/question/23500/series-reversion/?comment=23533#post-id-23533Comment by jjack for <p>I have a rational polynomial f(z) = P(z)/Q(z) which I want to revert (I'm trying to find the inverse of f).</p>
<p>I'll pick a simple example, the function f(z) = (1/z-1)^4</p>
<pre><code>sage: z = var('z')
sage: z = FractionField(PolynomialRing(QQ, 'z')).objgen()
sage: f(z) = (1/z-1)^4
sage: g = f(z).taylor(x,2,4); #I expand f in a Taylor series just to make sure it's a series
sage: f.expand().reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
sage: g1 = g.power_series(QQ)
TypeError: denominator must be a unit
sage: g.reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
</code></pre>
<p>A power series P(z) is not a rational function P(z)/Q(z). That's why the <code>TypeError: denominator must be a unit</code> appears. </p>
<p>Is it possible that Sage cannot invert rational polynomials? In the <a href="http://www.sagemath.org/doc/reference/power_series/sage/rings/power_series_poly.html">Sage help text</a> the computation is passed to pari first, before using Lagrangian inversion.</p>
<p>I thought Sage uses FLINT. Why is it not used for computing the inverse of rational polynomials?</p>
<hr/>
<p>EDIT (after answer by slelievre):</p>
<p>My problem now is how to avoid using the Symbolic Ring. I'm trying to do the following:</p>
<p>I want to invert an approximation formula for the Gamma-function. I am using <a href="https://en.wikipedia.org/wiki/Spouge's_approximation">Spouge's approximation</a>. It has terms in the numerator and the denominator. Ithink I can compute them separetely per se, but what if I wanted to do a Pade approximation of the function</p>
<pre><code>sage: f = (z+13)^(z+1/2)*exp(z)
sage: g = f.pade(5,5)
</code></pre>
<p>(it's the term ahead of the sum term in Spouge's approximation)</p>
<p>How do I get separate polynomials for the numerator and the denominator that are defined in the right algebraic structure? </p>
http://ask.sagemath.org/question/23500/series-reversion/?comment=23522#post-id-23522see above for the instructionsMon, 21 Jul 2014 14:50:23 -0500http://ask.sagemath.org/question/23500/series-reversion/?comment=23522#post-id-23522Comment by jjack for <p>I have a rational polynomial f(z) = P(z)/Q(z) which I want to revert (I'm trying to find the inverse of f).</p>
<p>I'll pick a simple example, the function f(z) = (1/z-1)^4</p>
<pre><code>sage: z = var('z')
sage: z = FractionField(PolynomialRing(QQ, 'z')).objgen()
sage: f(z) = (1/z-1)^4
sage: g = f(z).taylor(x,2,4); #I expand f in a Taylor series just to make sure it's a series
sage: f.expand().reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
sage: g1 = g.power_series(QQ)
TypeError: denominator must be a unit
sage: g.reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
</code></pre>
<p>A power series P(z) is not a rational function P(z)/Q(z). That's why the <code>TypeError: denominator must be a unit</code> appears. </p>
<p>Is it possible that Sage cannot invert rational polynomials? In the <a href="http://www.sagemath.org/doc/reference/power_series/sage/rings/power_series_poly.html">Sage help text</a> the computation is passed to pari first, before using Lagrangian inversion.</p>
<p>I thought Sage uses FLINT. Why is it not used for computing the inverse of rational polynomials?</p>
<hr/>
<p>EDIT (after answer by slelievre):</p>
<p>My problem now is how to avoid using the Symbolic Ring. I'm trying to do the following:</p>
<p>I want to invert an approximation formula for the Gamma-function. I am using <a href="https://en.wikipedia.org/wiki/Spouge's_approximation">Spouge's approximation</a>. It has terms in the numerator and the denominator. Ithink I can compute them separetely per se, but what if I wanted to do a Pade approximation of the function</p>
<pre><code>sage: f = (z+13)^(z+1/2)*exp(z)
sage: g = f.pade(5,5)
</code></pre>
<p>(it's the term ahead of the sum term in Spouge's approximation)</p>
<p>How do I get separate polynomials for the numerator and the denominator that are defined in the right algebraic structure? </p>
http://ask.sagemath.org/question/23500/series-reversion/?comment=23504#post-id-23504I added a line with what y(x) looks like.Sun, 20 Jul 2014 09:43:13 -0500http://ask.sagemath.org/question/23500/series-reversion/?comment=23504#post-id-23504Answer by slelievre for <p>I have a rational polynomial f(z) = P(z)/Q(z) which I want to revert (I'm trying to find the inverse of f).</p>
<p>I'll pick a simple example, the function f(z) = (1/z-1)^4</p>
<pre><code>sage: z = var('z')
sage: z = FractionField(PolynomialRing(QQ, 'z')).objgen()
sage: f(z) = (1/z-1)^4
sage: g = f(z).taylor(x,2,4); #I expand f in a Taylor series just to make sure it's a series
sage: f.expand().reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
sage: g1 = g.power_series(QQ)
TypeError: denominator must be a unit
sage: g.reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
</code></pre>
<p>A power series P(z) is not a rational function P(z)/Q(z). That's why the <code>TypeError: denominator must be a unit</code> appears. </p>
<p>Is it possible that Sage cannot invert rational polynomials? In the <a href="http://www.sagemath.org/doc/reference/power_series/sage/rings/power_series_poly.html">Sage help text</a> the computation is passed to pari first, before using Lagrangian inversion.</p>
<p>I thought Sage uses FLINT. Why is it not used for computing the inverse of rational polynomials?</p>
<hr/>
<p>EDIT (after answer by slelievre):</p>
<p>My problem now is how to avoid using the Symbolic Ring. I'm trying to do the following:</p>
<p>I want to invert an approximation formula for the Gamma-function. I am using <a href="https://en.wikipedia.org/wiki/Spouge's_approximation">Spouge's approximation</a>. It has terms in the numerator and the denominator. Ithink I can compute them separetely per se, but what if I wanted to do a Pade approximation of the function</p>
<pre><code>sage: f = (z+13)^(z+1/2)*exp(z)
sage: g = f.pade(5,5)
</code></pre>
<p>(it's the term ahead of the sum term in Spouge's approximation)</p>
<p>How do I get separate polynomials for the numerator and the denominator that are defined in the right algebraic structure? </p>
http://ask.sagemath.org/question/23500/series-reversion/?answer=23524#post-id-23524<h1>Composition inverse of a power series</h1>
Avoid the symbolic ring whenever you can, and work in the appropriate structures for the task at hand.
<h2>A worked out example</h2>
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.
Mon, 21 Jul 2014 22:48:40 -0500http://ask.sagemath.org/question/23500/series-reversion/?answer=23524#post-id-23524Comment by jjack for <h1>Composition inverse of a power series</h1>
<p>Avoid the symbolic ring whenever you can, and work in the appropriate structures for the task at hand.</p>
<h2>A worked out example</h2>
<p>Manipulate polynomials and rational fractions in the corresponding structures. Define</p>
<pre><code>sage: R.<z> = PolynomialRing(QQ)
sage: F = FractionField(R)
sage: S = PowerSeriesRing(QQ,'z')
</code></pre>
<p>and check the result:</p>
<pre><code>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
</code></pre>
<p>Define your polynomials and rational fractions.</p>
<pre><code>sage: a = 2 - 3*z + z^2
sage: b = z
sage: f = a / b
</code></pre>
<p>Check what you get.</p>
<pre><code>sage: a
z^2 - 3*z + 2
sage: b
z
sage: f
(z^2 - 3*z + 2)/z
</code></pre>
<p>Check out where a, b, f live.</p>
<pre><code>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
</code></pre>
<p>Want the Taylor series at 1 of f, and its inverse under composition.</p>
<p>First shift the function to move to the point 1.</p>
<pre><code>sage: g = f(1+z)
sage: g
(z^2 - z)/(z + 1)
</code></pre>
<p>Move to the ring of power series.</p>
<pre><code>sage: gg = S(g)
</code></pre>
<p>Check the first few terms.</p>
<pre><code>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)
</code></pre>
<p>The constant term is zero and the coefficient of z is nonzero: we can compute the composition inverse.</p>
<pre><code>sage: hh = gg.reversion()
</code></pre>
<p>Examine the first few terms.</p>
<pre><code>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)
</code></pre>
<p>Check that hh is the composition inverse of gg:</p>
<pre><code>sage: hh(gg)
z + O(z^21)
sage: gg(hh)
z + O(z^21)
</code></pre>
<hr/>
<p>EDIT (to answer your follow-up question).</p>
<p>If you have a rational fraction <code>g</code>, then <code>gnum = g.numerator()</code> and <code>gden = g.denominator()</code> will get you the polynomials for the numerator and the denominator of <code>g</code>. You can check where they live by <code>gnum.parent()</code> and <code>gden.parent()</code>. If you need them to be in <code>R</code>, <code>F</code> or <code>S</code>, just do <code>R(gnum)</code>, <code>F(gnum)</code>, <code>S(gnum)</code>, etc.</p>
http://ask.sagemath.org/question/23500/series-reversion/?comment=23555#post-id-23555Thanks a lot for your help. I think I got the hang of it.Wed, 23 Jul 2014 13:38:52 -0500http://ask.sagemath.org/question/23500/series-reversion/?comment=23555#post-id-23555Answer by slelievre for <p>I have a rational polynomial f(z) = P(z)/Q(z) which I want to revert (I'm trying to find the inverse of f).</p>
<p>I'll pick a simple example, the function f(z) = (1/z-1)^4</p>
<pre><code>sage: z = var('z')
sage: z = FractionField(PolynomialRing(QQ, 'z')).objgen()
sage: f(z) = (1/z-1)^4
sage: g = f(z).taylor(x,2,4); #I expand f in a Taylor series just to make sure it's a series
sage: f.expand().reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
sage: g1 = g.power_series(QQ)
TypeError: denominator must be a unit
sage: g.reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
</code></pre>
<p>A power series P(z) is not a rational function P(z)/Q(z). That's why the <code>TypeError: denominator must be a unit</code> appears. </p>
<p>Is it possible that Sage cannot invert rational polynomials? In the <a href="http://www.sagemath.org/doc/reference/power_series/sage/rings/power_series_poly.html">Sage help text</a> the computation is passed to pari first, before using Lagrangian inversion.</p>
<p>I thought Sage uses FLINT. Why is it not used for computing the inverse of rational polynomials?</p>
<hr/>
<p>EDIT (after answer by slelievre):</p>
<p>My problem now is how to avoid using the Symbolic Ring. I'm trying to do the following:</p>
<p>I want to invert an approximation formula for the Gamma-function. I am using <a href="https://en.wikipedia.org/wiki/Spouge's_approximation">Spouge's approximation</a>. It has terms in the numerator and the denominator. Ithink I can compute them separetely per se, but what if I wanted to do a Pade approximation of the function</p>
<pre><code>sage: f = (z+13)^(z+1/2)*exp(z)
sage: g = f.pade(5,5)
</code></pre>
<p>(it's the term ahead of the sum term in Spouge's approximation)</p>
<p>How do I get separate polynomials for the numerator and the denominator that are defined in the right algebraic structure? </p>
http://ask.sagemath.org/question/23500/series-reversion/?answer=23501#post-id-23501Have you tried this?
y(x).power_series(SR)
Sun, 20 Jul 2014 08:06:33 -0500http://ask.sagemath.org/question/23500/series-reversion/?answer=23501#post-id-23501Comment by jjack for <p>Have you tried this?</p>
<pre><code> y(x).power_series(SR)
</code></pre>
http://ask.sagemath.org/question/23500/series-reversion/?comment=23503#post-id-23503`y(x).power_series(SR)`
gives
`TypeError: denominator must be a unit'Sun, 20 Jul 2014 08:46:18 -0500http://ask.sagemath.org/question/23500/series-reversion/?comment=23503#post-id-23503Answer by jjack for <p>I have a rational polynomial f(z) = P(z)/Q(z) which I want to revert (I'm trying to find the inverse of f).</p>
<p>I'll pick a simple example, the function f(z) = (1/z-1)^4</p>
<pre><code>sage: z = var('z')
sage: z = FractionField(PolynomialRing(QQ, 'z')).objgen()
sage: f(z) = (1/z-1)^4
sage: g = f(z).taylor(x,2,4); #I expand f in a Taylor series just to make sure it's a series
sage: f.expand().reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
sage: g1 = g.power_series(QQ)
TypeError: denominator must be a unit
sage: g.reversion()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'reversion'
</code></pre>
<p>A power series P(z) is not a rational function P(z)/Q(z). That's why the <code>TypeError: denominator must be a unit</code> appears. </p>
<p>Is it possible that Sage cannot invert rational polynomials? In the <a href="http://www.sagemath.org/doc/reference/power_series/sage/rings/power_series_poly.html">Sage help text</a> the computation is passed to pari first, before using Lagrangian inversion.</p>
<p>I thought Sage uses FLINT. Why is it not used for computing the inverse of rational polynomials?</p>
<hr/>
<p>EDIT (after answer by slelievre):</p>
<p>My problem now is how to avoid using the Symbolic Ring. I'm trying to do the following:</p>
<p>I want to invert an approximation formula for the Gamma-function. I am using <a href="https://en.wikipedia.org/wiki/Spouge's_approximation">Spouge's approximation</a>. It has terms in the numerator and the denominator. Ithink I can compute them separetely per se, but what if I wanted to do a Pade approximation of the function</p>
<pre><code>sage: f = (z+13)^(z+1/2)*exp(z)
sage: g = f.pade(5,5)
</code></pre>
<p>(it's the term ahead of the sum term in Spouge's approximation)</p>
<p>How do I get separate polynomials for the numerator and the denominator that are defined in the right algebraic structure? </p>
http://ask.sagemath.org/question/23500/series-reversion/?answer=23535#post-id-23535My problem now is how to avoid using the Symbolic Ring. I'm trying to do the following:
I want to invert an approximation formula for the Gamma-function. I am using [Spouge's approximation](https://en.wikipedia.org/wiki/Spouge's_approximation). It has terms in the numerator and the denominator. Ithink I can compute them separetely per se, but what if I wanted to do a Pade approximation of the function
sage: f = (z+13)^(z+1/2)*exp(z)
sage: g = f.pade(5,5)
(it's the term ahead of the sum term in Spouge's approimation)
How do I get separate polynomials for the numerator and the denominator that are defined in the right algebraic structure?
Tue, 22 Jul 2014 14:48:39 -0500http://ask.sagemath.org/question/23500/series-reversion/?answer=23535#post-id-23535Comment by slelievre for <p>My problem now is how to avoid using the Symbolic Ring. I'm trying to do the following:</p>
<p>I want to invert an approximation formula for the Gamma-function. I am using <a href="https://en.wikipedia.org/wiki/Spouge's_approximation">Spouge's approximation</a>. It has terms in the numerator and the denominator. Ithink I can compute them separetely per se, but what if I wanted to do a Pade approximation of the function</p>
<pre><code>sage: f = (z+13)^(z+1/2)*exp(z)
sage: g = f.pade(5,5)
</code></pre>
<p>(it's the term ahead of the sum term in Spouge's approimation)</p>
<p>How do I get separate polynomials for the numerator and the denominator that are defined in the right algebraic structure? </p>
http://ask.sagemath.org/question/23500/series-reversion/?comment=23536#post-id-23536If 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.Tue, 22 Jul 2014 16:40:46 -0500http://ask.sagemath.org/question/23500/series-reversion/?comment=23536#post-id-23536