ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 26 Nov 2020 10:39:31 +0100power series method pade(m,n) off by 1?https://ask.sagemath.org/question/54385/power-series-method-pademn-off-by-1/If p = 1+ x + O(x^2) is a power series, then then the method p.pade(0,1) should give
p.pade(0,1) = 1/(1-x)
but instead it gives an error
> ValueError: the precision of the series is not large enough
The documentation says that p should be given up through O(x^(m+n+1)).
Isn't this wrong? Shouldn't it be up through O(x^(m+n)) ?
The Padé approximant P_m(x)/Q_n(x) contains m+n+1 unknown coefficients, so m+n+1 terms should be included in the power series: x^0 ... x^(m+n).
I'm working with a power series that I generate numerically, term by term. I'm using the pade method to estimate the region of analyticity in order to make a conformal transformation that will accelerate the convergence. I want to use pade(n-1,n) when I have 2n terms in the power series. But the pade(m,n) throws the above error. It does not seem possible to get a Padé approximation with the same number of coefficients as in the power series.
thanks for taking a look at this.
Daniel Friedan
Daniel Friedan
Thu, 26 Nov 2020 00:46:27 +0100https://ask.sagemath.org/question/54385/power-series-method-pademn-off-by-1/Comment by FrédéricC for <p>If p = 1+ x + O(x^2) is a power series, then then the method p.pade(0,1) should give
p.pade(0,1) = 1/(1-x)
but instead it gives an error</p>
<blockquote>
<p>ValueError: the precision of the series is not large enough</p>
</blockquote>
<p>The documentation says that p should be given up through O(x^(m+n+1)).</p>
<p>Isn't this wrong? Shouldn't it be up through O(x^(m+n)) ?</p>
<p>The Padé approximant P_m(x)/Q_n(x) contains m+n+1 unknown coefficients, so m+n+1 terms should be included in the power series: x^0 ... x^(m+n).</p>
<p>I'm working with a power series that I generate numerically, term by term. I'm using the pade method to estimate the region of analyticity in order to make a conformal transformation that will accelerate the convergence. I want to use pade(n-1,n) when I have 2n terms in the power series. But the pade(m,n) throws the above error. It does not seem possible to get a Padé approximation with the same number of coefficients as in the power series.</p>
<p>thanks for taking a look at this.
Daniel Friedan</p>
<p>Daniel Friedan</p>
https://ask.sagemath.org/question/54385/power-series-method-pademn-off-by-1/?comment=54387#post-id-54387Please look at the code and tell us where it is wrong. Open-source, we are.Thu, 26 Nov 2020 08:45:28 +0100https://ask.sagemath.org/question/54385/power-series-method-pademn-off-by-1/?comment=54387#post-id-54387Comment by FrédéricC for <p>If p = 1+ x + O(x^2) is a power series, then then the method p.pade(0,1) should give
p.pade(0,1) = 1/(1-x)
but instead it gives an error</p>
<blockquote>
<p>ValueError: the precision of the series is not large enough</p>
</blockquote>
<p>The documentation says that p should be given up through O(x^(m+n+1)).</p>
<p>Isn't this wrong? Shouldn't it be up through O(x^(m+n)) ?</p>
<p>The Padé approximant P_m(x)/Q_n(x) contains m+n+1 unknown coefficients, so m+n+1 terms should be included in the power series: x^0 ... x^(m+n).</p>
<p>I'm working with a power series that I generate numerically, term by term. I'm using the pade method to estimate the region of analyticity in order to make a conformal transformation that will accelerate the convergence. I want to use pade(n-1,n) when I have 2n terms in the power series. But the pade(m,n) throws the above error. It does not seem possible to get a Padé approximation with the same number of coefficients as in the power series.</p>
<p>thanks for taking a look at this.
Daniel Friedan</p>
<p>Daniel Friedan</p>
https://ask.sagemath.org/question/54385/power-series-method-pademn-off-by-1/?comment=54388#post-id-54388I propose a fix here : https://trac.sagemath.org/ticket/30965Thu, 26 Nov 2020 09:17:36 +0100https://ask.sagemath.org/question/54385/power-series-method-pademn-off-by-1/?comment=54388#post-id-54388Comment by Daniel Friedan for <p>If p = 1+ x + O(x^2) is a power series, then then the method p.pade(0,1) should give
p.pade(0,1) = 1/(1-x)
but instead it gives an error</p>
<blockquote>
<p>ValueError: the precision of the series is not large enough</p>
</blockquote>
<p>The documentation says that p should be given up through O(x^(m+n+1)).</p>
<p>Isn't this wrong? Shouldn't it be up through O(x^(m+n)) ?</p>
<p>The Padé approximant P_m(x)/Q_n(x) contains m+n+1 unknown coefficients, so m+n+1 terms should be included in the power series: x^0 ... x^(m+n).</p>
<p>I'm working with a power series that I generate numerically, term by term. I'm using the pade method to estimate the region of analyticity in order to make a conformal transformation that will accelerate the convergence. I want to use pade(n-1,n) when I have 2n terms in the power series. But the pade(m,n) throws the above error. It does not seem possible to get a Padé approximation with the same number of coefficients as in the power series.</p>
<p>thanks for taking a look at this.
Daniel Friedan</p>
<p>Daniel Friedan</p>
https://ask.sagemath.org/question/54385/power-series-method-pademn-off-by-1/?comment=54390#post-id-54390Thanks for the quick fix. It looks to me that the calculation of pade(m,n) was fine. It was just the error check that was off by 1. So the fix seems good to me.
I've never dared look at the code of sagemath. I came to python late in life. When I write calculations in sagemath, I spend half my time googling basic python questions.
I was a bit surprised to see that pade(m,n) is simply a wrapper around rational_reconstruct(). I had the impression that rational_reconstruct() only worked modulo a prime.
DanielThu, 26 Nov 2020 10:39:31 +0100https://ask.sagemath.org/question/54385/power-series-method-pademn-off-by-1/?comment=54390#post-id-54390Answer by Emmanuel Charpentier for <p>If p = 1+ x + O(x^2) is a power series, then then the method p.pade(0,1) should give
p.pade(0,1) = 1/(1-x)
but instead it gives an error</p>
<blockquote>
<p>ValueError: the precision of the series is not large enough</p>
</blockquote>
<p>The documentation says that p should be given up through O(x^(m+n+1)).</p>
<p>Isn't this wrong? Shouldn't it be up through O(x^(m+n)) ?</p>
<p>The Padé approximant P_m(x)/Q_n(x) contains m+n+1 unknown coefficients, so m+n+1 terms should be included in the power series: x^0 ... x^(m+n).</p>
<p>I'm working with a power series that I generate numerically, term by term. I'm using the pade method to estimate the region of analyticity in order to make a conformal transformation that will accelerate the convergence. I want to use pade(n-1,n) when I have 2n terms in the power series. But the pade(m,n) throws the above error. It does not seem possible to get a Padé approximation with the same number of coefficients as in the power series.</p>
<p>thanks for taking a look at this.
Daniel Friedan</p>
<p>Daniel Friedan</p>
https://ask.sagemath.org/question/54385/power-series-method-pademn-off-by-1/?answer=54389#post-id-54389This is a problem of convention : is the order of a development the largest explicit power or the degree of the big-Oh term ?
Sage isn't always consistent. Contrast :
sage: R1.<t>=PowerSeriesRing(QQ, default_prec=6)
sage: t.exp()
1 + t + 1/2*t^2 + 1/6*t^3 + 1/24*t^4 + 1/120*t^5 + O(t^6)
with :
sage: exp(x).maxima_methods().taylor(x,0,5)
1/120*x^5 + 1/24*x^4 + 1/6*x^3 + 1/2*x^2 + x + 1
And, by the way,
sage: t.tan().pade(2,2)
-3*t/(t^2 - 3)
whereas
sage: maxima.pade(maxima.taylor(tan(x),x,0,4),2,2).sage()
[-3*x/(x^2 - 3)]
sage: maxima.pade(maxima.taylor(tan(x),x,0,4),3,2).sage()
[-3*x/(x^2 - 3), 1/3*x^3 + x]
sage: maxima.pade(maxima.taylor(tan(x),x,0,4),2,3).sage()
[-3*x/(x^2 - 3)]
sage: maxima.pade(maxima.taylor(tan(x),x,0,5),3,2).sage()
[1/3*(x^3 - 15*x)/(2*x^2 - 5)]
sage: maxima.pade(maxima.taylor(tan(x),x,0,5),2,3).sage()
[]
A look at `maxima.pade?` shows that the conventions are different...
HTH,
Thu, 26 Nov 2020 09:30:00 +0100https://ask.sagemath.org/question/54385/power-series-method-pademn-off-by-1/?answer=54389#post-id-54389