Python Forum
code running for more than an hour now, yet didn't get any result, what should I do?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
code running for more than an hour now, yet didn't get any result, what should I do?
#1
I'm trying to implement a triple integral Riemann sum. My single and double integral codes are working. I just added the for k in range (1,l+1):, l = int(zb/dz) and za+(k-1)*dz in the code below. It's not getting any error nor results. It's just running. It's been more than an hour now. What other ways/code would you suggest as a replacement of the code below? Using math library only and has to implement the function calculate(f, xa, xb, ya, yb, za, zb). I'm still new to this just for your information. Thank you for all the help.


dx = 0.002
dy = 0.002
dz = 0.002

def calculate(f, xa, xb, ya, yb, za, zb):
  n = int(xb/dx)
  m = int(yb/dy)
  l = int(zb/dz)
  t = dx*dy*dz
  total = 0
  for i in range (1,n+1):
    for j in range (1,m+1):
      for k in range (1,l+1):
        total += f(xa+(i-1)*dx, ya+(j-1)*dy, za+(k-1)*dz)*t
  return total

def p(x, y, z):
  return math.sin(x) + math.cos(y) + math.tan(z)

s = calculate(p, 0, 3, 0, 2, 0, 1)
print("{:.3f}".format(s))
Reply


Messages In This Thread
code running for more than an hour now, yet didn't get any result, what should I do? - by aiden - Apr-06-2022, 03:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem in running a code akbarza 7 765 Feb-14-2024, 02:57 PM
Last Post: snippsat
  writing and running code in vscode without saving it akbarza 1 443 Jan-11-2024, 02:59 PM
Last Post: deanhystad
  the order of running code in a decorator function akbarza 2 580 Nov-10-2023, 08:09 AM
Last Post: akbarza
Question Sqlite3 how to know when cursor.execute didn't return anything ? SpongeB0B 2 908 Dec-18-2022, 06:13 PM
Last Post: deanhystad
  help me simple code result min and max number abrahimusmaximus 2 968 Nov-12-2022, 07:52 AM
Last Post: buran
  Code running many times nad not just one? korenron 4 1,418 Jul-24-2022, 08:12 AM
Last Post: korenron
  Error while running code on VSC maiya 4 3,900 Jul-01-2022, 02:51 PM
Last Post: maiya
  Can a program execute code in iPython shell and get result? deanhystad 3 1,803 Jun-17-2022, 03:45 AM
Last Post: Larz60+
  Needing to Check Every Quarter Hour bill_z 10 3,160 Feb-09-2022, 07:23 PM
Last Post: menator01
  Why is this Python code running twice? mcva 5 5,402 Feb-02-2022, 10:21 AM
Last Post: mcva

Forum Jump:

User Panel Messages

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