原始出处:http://sbp810050504.blog.51cto.com/2799422/1608064
1
2
3
4
5
6
7
8
9
10
11
12
|
def
f_prime(x_old):
return
-
2
*
x_old
+
3
def
cal():
x_old
=
0
x_new
=
6
eps
=
0.01
presision
=
0.00001
whileabs(x_new
-
x_old)>presision:
x_old
=
x_new
x_new
=
x_old
+
eps
*
f_prime(x_old)
return
x_new
|