Python Forum
How to integrate this function in python symbolically
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to integrate this function in python symbolically
#1
I use the following code to symbolically triple integrate a function f(t1,t2,m) , but it gives an error :



This can happen when it's not possible to detect zero in the coefficient domain. The domain of computation is RR[m]. Zero detection is guaranteed in this coefficient domain. This may indicate a bug in SymPy or the domain is user defined and doesn't implement zero detection properly.
Any help how to avoid this error?


Here is the code:


import sympy as sp


k=2;
# Define the symbols
t1, t2, m = sp.symbols('t1 t2 m')

# Define the function to integrate
f = (-(50*t1**2*(-16*(16 + 20*t1 + 6*t1**2 + 4*t1**3 + 3*t1**4) + (1 + t1)**2*(448 + 1568*t1 + 2400*t1**2 + 1920*t1**3 + 864*t1**4 + 240*t1**5 + 72*t1**6 + 42*t1**7 + 18*t1**8 + 3*t1**9)*sp.exp((4*(1 + t1))/(2 + t1))) + m*(1 + t1)*(-128 + 1536*t1**2*sp.exp((4*(1 + t1))/(2 + t1)) + 2112*t1**4*sp.exp((4*(1 + t1))/(2 + t1)) + 1008*t1**5*sp.exp((4*(1 + t1))/(2 + t1)) + 312*t1**6*sp.exp((4*(1 + t1))/(2 + t1)) + 114*t1**7*sp.exp((4*(1 + t1))/(2 + t1)) + 60*t1**8*sp.exp((4*(1 + t1))/(2 + t1)) + 21*t1**9*sp.exp((4*(1 + t1))/(2 + t1)) + 3*t1**10*sp.exp((4*(1 + t1))/(2 + t1)) + 64*t1*(-1 + 6*sp.exp((4*(1 + t1))/(2 + t1))) + 32*t1**3*(-1 + 78*sp.exp((4*(1 + t1))/(2 + t1)))))/(4.*(1 + t1)*(2 + t1)*(-48 - 96*t1 + 8*(-3 + 2*m**2)*t1**2 + 8*(3 + 2*m**2)*t1**3 + (6 + 4*m**2)*t1**4 + 6*t1**5 + 3*t1**6))) * ((50 * t1**2) +5* (-(50*t1**2*(-16*(16 + 20*t1 + 6*t1**2 + 4*t1**3 + 3*t1**4) + (1 + t1)**2*(448 + 1568*t1 + 2400*t1**2 + 1920*t1**3 + 864*t1**4 + 240*t1**5 + 72*t1**6 + 42*t1**7 + 18*t1**8 + 3*t1**9)*sp.exp((4*(1 + t1))/(2 + t1))) + (k - m)*(1 + t1)*(-128 + 1536*t1**2*sp.exp((4*(1 + t1))/(2 + t1)) + 2112*t1**4*sp.exp((4*(1 + t1))/(2 + t1)) + 1008*t1**5*sp.exp((4*(1 + t1))/(2 + t1)) + 312*t1**6*sp.exp((4*(1 + t1))/(2 + t1)) + 114*t1**7*sp.exp((4*(1 + t1))/(2 + t1)) + 60*t1**8*sp.exp((4*(1 + t1))/(2 + t1)) + 21*t1**9*sp.exp((4*(1 + t1))/(2 + t1)) + 3*t1**10*sp.exp((4*(1 + t1))/(2 + t1)) + 64*t1*(-1 + 6*sp.exp((4*(1 + t1))/(2 + t1))) + 32*t1**3*(-1 + 78*sp.exp((4*(1 + t1))/(2 + t1)))))/(4.*(1 + t1)*(2 + t1)*(-48 - 96*t1 + 8*(-3 + 2*(k - m)**2)*t1**2 + 8*(3 + 2*(k - m)**2)*t1**3 + (6 + 4*(k - m)**2)*t1**4 + 6*t1**5 + 3*t1**6)))) 


# Perform the triple integral
integral_result = sp.integrate(sp.integrate(sp.integrate(f, (t1, 0.1, 3)), (t2, 0.1, 3)), (m, 0.1, 4))
print("The result of the triple integral:", integral_result)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to integrate a discontinuous function by tplquad or nquad Safinazsalem 2 323 May-29-2024, 07:22 AM
Last Post: Safinazsalem
  Trying to integrate gcd function hhydration 3 2,258 Oct-28-2020, 02:05 PM
Last Post: perfringo
  Differentiate and Integrate A Given Function wildmommy666 2 1,719 May-11-2020, 04:30 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

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