Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
23
Task/Numerical-integration/Python/numerical-integration-2.py
Normal file
23
Task/Numerical-integration/Python/numerical-integration-2.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
for a, b, steps, func in ((0., 1., 100, cube), (1., 100., 1000, reciprocal)):
|
||||
for rule in (left_rect, mid_rect, right_rect, trapezium, simpson):
|
||||
print('%s integrated using %s\n from %r to %r (%i steps) = %r' %
|
||||
(func.__name__, rule.__name__, a, b, steps,
|
||||
integrate( func, a, b, steps, rule)))
|
||||
a, b = Fraction.from_float(a), Fraction.from_float(b)
|
||||
for rule in (left_rect, mid_rect, right_rect, trapezium, simpson):
|
||||
print('%s integrated using %s\n from %r to %r (%i steps and fractions) = %r' %
|
||||
(func.__name__, rule.__name__, a, b, steps,
|
||||
float(integrate( func, a, b, steps, rule))))
|
||||
|
||||
# Extra tests (compute intensive)
|
||||
for a, b, steps, func in ((1., 5000., 5000000, identity),
|
||||
(1., 6000., 6000000, identity)):
|
||||
for rule in (left_rect, mid_rect, right_rect, trapezium, simpson):
|
||||
print('%s integrated using %s\n from %r to %r (%i steps) = %r' %
|
||||
(func.__name__, rule.__name__, a, b, steps,
|
||||
integrate( func, a, b, steps, rule)))
|
||||
a, b = Fraction.from_float(a), Fraction.from_float(b)
|
||||
for rule in (left_rect, mid_rect, right_rect, trapezium, simpson):
|
||||
print('%s integrated using %s\n from %r to %r (%i steps and fractions) = %r' %
|
||||
(func.__name__, rule.__name__, a, b, steps,
|
||||
float(integrate( func, a, b, steps, rule))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue