Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import math
- # Term: x^k/k!
- # Next term: x^(k+2)/(k+2)!
- # Next term/term: x^2 / (k+1) / (k+2)
- def table(x):
- n = 1 # terms for approximation
- k = 3 # first omitted term's exponent
- e = x**3 / 6 # maximum error when n = 1, k = 3
- s = math.sin(x)
- ep = 100 * e/s
- print(n, ep, 1/ep)
- while n < 10:
- e = e * x**2 / (k+1) / (k+2)
- k += 2
- n += 1
- ep = 100 * e/s
- print(n, ep, 1/ep)
- table(0.1)
Advertisement
Add Comment
Please, Sign In to add comment