Dear Friends
I need to construct a function which its values come from a matrix's entries.
(From a given matrix)
Please guide me, any ideas are welcome.
The output of the function must be exactly that array.
What I have tried:
Here is a code but I am not sure whether am I doing it right or not
If there is better approach let me know please.
1 import numpy as np
2 import math
3 import matplotlib.pyplot as plt
4 from scipy import integrate
5 from scipy.integrate import quad
6 import numpy as np
7 import quadpy
8 from numpy import linalg as LA
9 from numpy.linalg import inv
10 from numpy.linalg import matrix_power
11 from scipy import linalg
12 from sympy import *
13 from numpy.linalg import eig
14 from scipy.linalg import sqrtm
15 import scipy.integrate as it
16 from numpy import vectorize
17 from scipy.integrate import quad_vec
18
19
20 from numba import vectorize, float64
21
22
23 tmax = 20
24 t = np.arange(0.0, tmax, 1)
25 t0=0
26 m=len(t)
27
28
29
30 e=np.matrix([[np.sqrt(0),np.sqrt(1),np.sqrt(2) ,np.sqrt(3),np.sqrt(4),np.sqrt(5),np.sqrt(6),np.sqrt(7),np.sqrt(8),np.sqrt(9)],
31 [np.sqrt(10),np.sqrt(11),np.sqrt(12), np.sqrt(13),np.sqrt(14),np.sqrt(15),np.sqrt(16),np.sqrt(17),np.sqrt(18),np.sqrt (19)]])
32 pow = np.power( e, 2 )
33 pow0=pow[0]
34 pow1=pow[1]
35
36 def e(xx):
37 for i in range(0,2):
38 for xx in np.arange(0.0, tmax, 1):
39 value= e[i,xx]
40 return value
41 y=e(t)
42 print(y)
As this gives the next error:
Traceback (most recent call last):
File "C:\Users\user\OneDrive\Desktop\44integral.py", line 41, in <module>
y=e(t)
File "C:\Users\user\OneDrive\Desktop\44integral.py", line 39, in e
value= e[i,xx]
TypeError: 'function' object is not subscriptable