May-06-2024, 10:12 AM
I have a function
-The integration limits of t1 and t2 are from
-The integration limits of t3 is from
The question is how to make a second loop over the variable
Here is the code that I use:
So how to adjust this code and write
Any help is appreciated!
f(t1,t2,t3, a,k)
where I make a triple integral over t1,t2,t3
and make a loop on the value of the variable "k"-The integration limits of t1 and t2 are from
0
to a
-The integration limits of t3 is from
0
to infinity
The question is how to make a second loop over the variable
a
where it tends to zero Here is the code that I use:
# %% import numpy as np import scipy.special from scipy import integrate from scipy.special import kn import matplotlib.pyplot as plt import math import time, sys H=4.10061*10**-5;ti=-100*H;end=-H;step=H;a=0; f = lambda t1, t2,t3, k: t1 + t2 +k + a +t3 X = np.arange(0,50,0.1) g=float('inf') #plot(X,f(X)) def F(x): res = np.zeros_like(x) for i,val in enumerate(x): y,err = integrate.tplquad(f, 0, a,lambda x: 0, lambda x: a,lambda x,y: 0, lambda x,y: g,args=(val,)) res[i]=y/(math.exp(H*a)**2) return res plt.plot(X,F(X)) plt.title("P(k)") plt.show()As you glance that in this code I write
f(t1,t2,t3,k)
and let a=0
. But that makes the integral vanishesSo how to adjust this code and write
f(t1,t2,t3,a,k)
then run a second loop on "a" as a variable like "k" such that "a" tends to zero.Any help is appreciated!