Python Forum
How to make a double loop to evaluate this triple integral
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make a double loop to evaluate this triple integral
#1
I have a function 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 vanishes

So 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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Evaluate Calculations yrstruly 0 1,112 Jun-17-2023, 06:51 PM
Last Post: yrstruly
  Can I evaluate a Chebyshev polynomial using a function player1681 1 2,058 Nov-22-2019, 06:33 AM
Last Post: scidam
  Double 'for' loop and writing in a new columns dataframe marco_ita 0 1,811 Sep-07-2019, 12:44 PM
Last Post: marco_ita
  finding the integral of probability density function Staph 3 3,740 Aug-11-2019, 09:19 AM
Last Post: buran
  Evaluate dataset with logistic regression chisox721 6 3,698 Jun-06-2019, 03:01 PM
Last Post: chisox721
  Hydrogen ground state integral Eduard 2 2,635 Sep-26-2018, 10:19 PM
Last Post: Eduard

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020