mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 09:21:13 +08:00
Re-design psnr.py code and change image names (#592)
* Change some Image File names & re-code the psnr algorithm (conserving both methods). Also Added new example. * Selected psnr method and reformat some code from arithmetic_analysis
This commit is contained in:

committed by
Harshil

parent
39912aed57
commit
beafe3656f
@ -1,15 +1,18 @@
|
||||
# Newton's Method - https://en.wikipedia.org/wiki/Newton%27s_method
|
||||
|
||||
def newton(function,function1,startingInt): #function is the f(x) and function1 is the f'(x)
|
||||
x_n=startingInt
|
||||
while True:
|
||||
x_n1=x_n-function(x_n)/function1(x_n)
|
||||
if abs(x_n-x_n1)<0.00001:
|
||||
if abs(x_n-x_n1) < 10**-5:
|
||||
return x_n1
|
||||
x_n=x_n1
|
||||
|
||||
def f(x):
|
||||
return (x**3)-2*x-5
|
||||
return (x**3) - (2 * x) -5
|
||||
|
||||
def f1(x):
|
||||
return 3*(x**2)-2
|
||||
return 3 * (x**2) -2
|
||||
|
||||
print(newton(f,f1,3))
|
||||
if __name__ == "__main__":
|
||||
print(newton(f,f1,3))
|
||||
|
Reference in New Issue
Block a user