I need to take the transpose of M, but every time I try, it just returns the same thing as M again. I am somewhat new when it comes to Python, so I can't see what the issue is.
I have tried using different codes (i.e. M.T, M.tranpose, etc.). I have made new, irrelevant matrices in a different script to make sure M.T works, and it does, so I don't see why it won't work in the main code.
def integrandtemp(s):
K = 17.5
r = 0.7
x0 = 0.1
t = 5
x = K/(1+((K/x0)-1)*np.exp(-r*s))
dxdK = (x0*x0-x0*x0*np.exp(-r*s))/((x0+K*np.exp(-r*s)-x0*np.exp(-r*s))**2)
dxdr = (K*K*x0*s*np.exp(-r*s)-K*x0*x0*s*np.exp(-r*s))/((x0+K*np.exp(-r*s)-x0*np.exp(-r*s))**2)
dxdx0 = (K*x0+K*K*np.exp(-r*s)-K*x0*np.exp(-r*s)-K*x0+K*x0*np.exp(-r*s))/((x0+K*np.exp(-r*s)-x0*np.exp(-r*s))**2)
M = [dxdK, dxdr, dxdx0]
M = np.array([M])
transpose = M.T
var = 0.16
return (1/var)*M@transpose
F = integrate.quad(integrandtemp, 0, 10)
print(F)
newF = F[0]
print(newF)
F_inv = inv(newF)
There are no errors, but M and M.T return the same thing, which they should not. I do get an error when I try to take the inverse of F a few lines later (square matrix expected).