I am trying desperately to be able to integrate a matrix and this is my 3rd or 4th approach. Every time I try to resolve an error, I get a new one and get stuck. This time, I am getting the error:
---------------------------------------------------------------------------
PolynomialError Traceback (most recent call last)
<ipython-input-20-445ad8aa95c1> in <module>
25 var = 0.16
26 A = (1/var)*transpose@M
---> 27 A.integrate((s,0,1))
PolynomialError: 1.0*(6.25000000000002*_t0 + 0.0359195402298851)/(1.0*_t0 + 0.00574712643678161) is not an element of K[_t0, 1/_t0].
I have looked at every other post with regards to this error (including the one about cosine) and nothing resolves my error. I have tried np.exp, sym.exp, etc.
import sympy
from scipy.integrate import odeint
%matplotlib inline
import matplotlib.pyplot as plt
import scipy.integrate as integrate
from scipy.linalg import inv
from sympy.matrices import Matrix
from sympy.abc import s
from sympy import symbols, diff, exp, log, power
#M = Matrix([[x, y], [1, 0]])
#M.integrate((x, ))
K = 17.5
r = 0.7
x0 = 0.1
dxdK = (x0*x0-x0*x0*sympy.exp(-r*s))/((x0+K*sympy.exp(-r*s)-x0*sympy.exp(-r*s))**2)
dxdr = (K*K*x0*s*sympy.exp(-r*s)-K*x0*x0*s*sympy.exp(-r*s))/((x0+K*sympy.exp(-r*s)-x0*sympy.exp(-r*s))**2)
dxdx0 = (K*x0+K*K*sympy.exp(-r*s)-K*x0*sympy.exp(-r*s)-K*x0+K*x0*sympy.exp(-r*s))/((x0+K*sympy.exp(-r*s)-x0*sympy.exp(-r*s))**2)
M = Matrix([[dxdK, dxdr, dxdx0]])
transpose = M.T
var = 0.16
A = (1/var)*transpose@M
A.integrate((s,0,1))
As stated before, my only real goal is to be able to integrate the matrix (1/var)*tranpose@M with respect to s. I'm currently trying to resolve the error above, but am also open to suggestions to changing the code entirely to just be able to integrate the thing (which is why I provided so much of the code). I have another post with previous code I had to try and integrate it, but never got a good answer.