Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def func(x):
- x_cords = range(-50, 50)
- y_cords = [-8+2*x+1*x*x for x in x_cords]
- return -8+2*x+1*x*x
- def grad(x):
- return 2+2*x
- def updt(grad, x, a):
- return x-a*grad
- num = 0
- num1 = updt(grad(num),num,0.2)
- while(abs(num1-num)>=0.0005):
- num=num1
- num1=updt(grad(num),num,0.2)
- print(num1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement