In order to compute definite integral
$\int_{0}^{t}\exp(||e||^2)$
I have written this code
How can I adapt the number of steps with the step mathematically it seems to be true but when I want to write the code I faced to a problem
I have tried to express the upper bound (i.e. t) by using linespace I think my problem is that I could not state the interval in which "t" is located.
import numpy as np
import math
from scipy.integrate import odeint
import matplotlib.pyplot as plt
import math
from scipy import integrate
from scipy.integrate import quad
from scipy.integrate import quad
import scipy.integrate as it
import numpy as np
from scipy.integrate import quad
import matplotlib.pyplot as plt
from numpy import linalg as LA
from numpy.linalg import inv
from numpy.linalg import matrix_power
from scipy import linalg
from sympy import *
from numpy.linalg import eig
import numpy
import cvxopt
import cvxpy as cp
from cvxopt import matrix, solvers
from scipy.linalg import sqrtm
from scipy import integrate
tmax = 10
t = np.arange(0.0, tmax, 0.1)
m=len(t)
e=np.matrix([[0,1,2 ,3],
[0,1,1, 1]])
e1=e[0]
e2=e[1]
a=np.power(e1,2)
b=np.power(e2,2)
nrm2e=(a+b)
print(nrm2e)
num=10*t
x = np.linspace(0.0, t, num)
nrm2e_int=it.cumtrapz(nrm2e,x, initial=0)
print(nrm2e_int)
I got this error
Traceback (most recent call last):
File "C:/Users/user/OneDrive/Desktop/yyyyyyyyyyyyyyyyyyyyyyyyyyyyy.py", line 45, in <module>
x = np.linspace(0.0, t, num)
File "<__array_function__ internals>", line 6, in linspace
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\core\function_base.py", line 120, in linspace
num = operator.index(num)
TypeError: only integer scalar arrays can be converted to a scalar index
What I have tried:
I guess that it is because of num which is the number of steps (0.1).
Also when I print values of 10*t
I got float numbers while it must be integer.
Could you please guide me? How can I fix it?
Thank u