15 lines
300 B
Python
15 lines
300 B
Python
#!/usr/bin/python3
|
|
|
|
def numerical_shitty_integration(func, n, a, b):
|
|
epsilon = (b - a) / n
|
|
result = 0
|
|
|
|
for i in range(n):
|
|
result += epsilon * func( a + epsilon * i)
|
|
return result
|
|
|
|
if( __name__ == "__main__"):
|
|
f = lambda x: (1 - x**2)**0.5
|
|
|
|
print(numerical_shitty_integration(f, 5000, -1, 1))
|