Pade approximant function from mpmath

asked 2023-10-19 00:07:32 +0200

updated 2023-10-19 00:45:07 +0200

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?

edit retag flag offensive close merge delete

Comments

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...

In short : give us some code...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2023-10-20 09:06:08 +0200 )edit