在Python中计算定积分

问题描述 投票:0回答:1

我正在尝试编写一个循环来计算每一步的定积分值。函数

bigF
非常复杂。简单来说,它整合了一堆关于
s
from s=tn-(n/2)
s=tn+(n/2)
的术语。积分后,
bigF
仍然有一个变量
t
。所以你可以说
bigF(t) = integral(f(s,t))
,其中
f(s,t)
integrate.integ
之后的一大堆术语。在最后一行中,我想在
bigF(t)
计算
t=tn
 的积分后在 
bigF
 处评估 
f(s,t)

运行后,出现错误

global name 's' is not defined
。但
s
本来只是积分中的虚拟变量,因为我正在计算卷积。我需要做什么?

import numpy as np  
import scipy.integrate as integ 
import math 

nt=5001#; %since (50-0)/.01 = 5000
dt = .01#; % =H
H=.01

theta_n = np.ones(nt)
theta_n[1]=0#; %theta_o
omega_n = np.ones(nt)
omega_n[1]=-0.4# %omega_o
epsilon=10^(-6)
eta = epsilon*10
t_o=0

def bigF(t, n):
    return integrate.integ((422.11/eta)*math.exp((5*(4*((eta*t-s-tn)^2)/eta^2)-1)^(-1))*omega, s,tn-(n/2),tn+(n/2))

for n in range(1,4999)
    tn=t_o+n*dt;
    theta_n[n+1] = theta_n[n] + H*bigF(tn, n);
python scipy numerical-integration integral
1个回答
0
投票

如果你正在进行卷积,听起来你想要numpy.convolve

© www.soinside.com 2019 - 2024. All rights reserved.