Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def my_newton(n, x0):
- my_function = lambda x: x - (1 / (3 + math.sin(3.6 * x)))
- my_derivative = lambda x: 1 + (3.6 * math.cos(3.6 * x) / ((3 + math.sin(3.6 * x)) ** 2))
- newton = lambda x: x - my_function(x) / my_derivative(x)
- for i in range(1, n + 1):
- x0 = newton(x0)
- print(i, ' : ', x0)
- def my_iteration(n, x0):
- my_function = lambda x: x - (1 / (3 + math.sin(3.6 * x)))
- my_derivative = lambda x: 1 + (3.6 * math.cos(3.6 * x) / ((3 + math.sin(3.6 * x)) ** 2))
- func_g = lambda x: 1 / (3 + math.sin(3.6 * x))
- for i in range(1, n + 1):
- x0 = func_g(x0)
- print(i, ' : ', x0)
- x = 0
- my_newton(20, x)
- my_iteration(20, x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement