scientific-programming-exer.../ex_12.py

15 lines
300 B
Python
Raw Normal View History

2018-11-07 14:22:04 +00:00
#!/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))