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.Fri, 20 Oct 2023 09:06:08 +0200Pade approximant function from mpmathhttps://ask.sagemath.org/question/73930/pade-approximant-function-from-mpmath/I'd like to use the pade function from the mpmath library in Sage since in the last documentation released in 2023, Sage allows for speed up of some of mpmath's function. Nevertheless, the same code that is working in Python is not working in Sage, because it signs an error related to the types inserted in the mpmath.pade function. This pade function should receive as inputs a list of mpf or mpc type values representing truncated power series coefficients and give back two polynomials p and q representing the numerator and denominator of the Padé approximant for that series, respectively. I don't know what to do, I have typed all my variables in Sage as mpmath's mpf or mpc types and provided a list containing this types to the mpmath.pade function but is not working. There's no problem with respect to the pade
polynomials orders and the truncated series order.
The error in my code accuses the following:
TypeError Traceback (most recent call last)
/tmp/ipykernel_1480/1416428611.py in <module>
48
49 seq_inf = generate_recurrence_sequence_inf(n)
---> 50 p_inf, q_inf = mpr.mp.pade(seq_inf, n//Integer(2),n//Integer(2))
/usr/lib/python3/dist-packages/mpmath/calculus/differentiation.py in pade(ctx, a, L, M)
631 # ...
632 # a[L+M-1]*q[1] + ... + a[L]*q[M] = -a[L+M]
--> 633 A = ctx.matrix(M)
634 for j in range(M):
635 for i in range(min(M, L+j+1)):
/usr/lib/python3/dist-packages/mpmath/matrices/matrices.py in __init__(self, *args, **kwargs)
330 self.__cols = A._matrix__cols
331 else:
--> 332 raise TypeError('could not interpret given arguments')
333
334 def apply(self, f):
TypeError: could not interpret given arguments
What am I doing wrong?Thu, 19 Oct 2023 00:07:32 +0200https://ask.sagemath.org/question/73930/pade-approximant-function-from-mpmath/Comment by Emmanuel Charpentier for <p>I'd like to use the pade function from the mpmath library in Sage since in the last documentation released in 2023, Sage allows for speed up of some of mpmath's function. Nevertheless, the same code that is working in Python is not working in Sage, because it signs an error related to the types inserted in the mpmath.pade function. This pade function should receive as inputs a list of mpf or mpc type values representing truncated power series coefficients and give back two polynomials p and q representing the numerator and denominator of the Padé approximant for that series, respectively. I don't know what to do, I have typed all my variables in Sage as mpmath's mpf or mpc types and provided a list containing this types to the mpmath.pade function but is not working. There's no problem with respect to the pade
polynomials orders and the truncated series order.
The error in my code accuses the following:</p>
<pre><code>TypeError Traceback (most recent call last)
/tmp/ipykernel_1480/1416428611.py in <module>
48
49 seq_inf = generate_recurrence_sequence_inf(n)
---> 50 p_inf, q_inf = mpr.mp.pade(seq_inf, n//Integer(2),n//Integer(2))
/usr/lib/python3/dist-packages/mpmath/calculus/differentiation.py in pade(ctx, a, L, M)
631 # ...
632 # a[L+M-1]*q[1] + ... + a[L]*q[M] = -a[L+M]
--> 633 A = ctx.matrix(M)
634 for j in range(M):
635 for i in range(min(M, L+j+1)):
/usr/lib/python3/dist-packages/mpmath/matrices/matrices.py in __init__(self, *args, **kwargs)
330 self.__cols = A._matrix__cols
331 else:
--> 332 raise TypeError('could not interpret given arguments')
333
334 def apply(self, f):
TypeError: could not interpret given arguments
</code></pre>
<p>What am I doing wrong?</p>
https://ask.sagemath.org/question/73930/pade-approximant-function-from-mpmath/?comment=73961#post-id-73961> What am I doing wrong?
Since you didn't deign to tell us *what you were doing* (right or wrong), answering this question is an exercise in divination. I am not [the Cumæan Sibyl](https://en.wikipedia.org/wiki/Cumaean_Sibyl)...
In short : give us some code...Fri, 20 Oct 2023 09:06:08 +0200https://ask.sagemath.org/question/73930/pade-approximant-function-from-mpmath/?comment=73961#post-id-73961