1
1
import math
2
- #import numpy as np
3
- #import matplotlib.pyplot as plt
4
2
5
3
6
4
def func_task (x ):
@@ -21,6 +19,8 @@ def fib(input_num, show=0):
21
19
22
20
23
21
def fibonacci (a , b , eps , N ):
22
+ print ("Поиск методом Фибоначчи" )
23
+ print ('a =' , a , '; b =' , b , '; eps =' , eps , '; N =' , N )
24
24
a0 = a
25
25
b0 = b
26
26
k = 0
@@ -41,6 +41,7 @@ def fibonacci(a, b, eps, N):
41
41
42
42
43
43
def gold (a , b , eps ):
44
+ print ("Повысим точность" )
44
45
g = (math .sqrt (5 ) - 1.0 ) / 2
45
46
k = 0
46
47
a1 = a + (1 - g ) * (b - a )
@@ -63,18 +64,19 @@ def gold(a, b, eps):
63
64
print ('e = ' , math .e )
64
65
a = 0
65
66
b = 1
66
- N = 10
67
+ N = 20
67
68
eps = 0.000001
68
69
69
70
x = fibonacci (a , b , eps , N )
70
71
fx = func_task (x )
71
- print ("Поиск методом Фибоначчи" )
72
72
fib (N , 1 )
73
- print ('x =' , round (x , 6 ))
74
- print ('f(x) =' , round (fx , 6 ))
73
+ print ('x =' , x )
74
+ print ('f(x) = ' , fx )
75
+ #print('Округлим значение')
76
+ #print('x =', round(x, 6))
77
+ #print('f(x) =', round(fx, 6))
75
78
76
79
x = gold (a , b , eps )
77
- print ("Повысим точность" )
78
80
fx = func_task (x )
79
81
print ('x =' , x )
80
82
print ('f(x) = ' , fx )
0 commit comments