from math import from tkinter import def II return I1 int X1 I2 I1 X2

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from math import *
from tkinter import *
def II(x):
return I1 + int((x - X1)*(I2 - I1)/(X2 - X1))
def JJ(y):
return J2 + int((y - Y1)*(J1 - J2)/(Y2 - Y1))
def F(x):
if x == 0: f = 1
else: f = exp(-x/50)
return f * cos(x)
X1 = -20; X2 = 20;
Y1 = -1.2; Y2 = 1.2
I1 = 0; J1 = 0
I2 = 500; J2 = 500
n = 25
h = (X2 - X1)/n
root = Tk()
root.title('График функции F(x) = sin(x)/x, -5*pi<=x<=5*pi')
canv = Canvas(root, width = I2 + 50, height = J2 + 50, bg = 'red')
canv.create_line(II(0), JJ(Y1), II(0), JJ(Y2), width = 2)
canv.create_line(II(X1), JJ(0), II(X2), JJ(0), width = 2)
k = 0
L = (Y2-Y1)/10
while k<Y2:
canv.create_line(II(-0.2), JJ(k), II(0.2), JJ(k), width = 2)
canv.create_text(I2+30, JJ(k), text = str(int(100*k)/100))
k += L
k = 0
while k>Y1:
canv.create_line(II(-0.2), JJ(k), II(0.2), JJ(k), width = 2)
canv.create_text(J2+30, JJ(k), text = str(int(100*k)/100))
k -= L
k = 0
L = (X2-X1)/10
while k<X2:
canv.create_line(II(k), JJ(-0.02), II(k), JJ(0.02), width = 2)
canv.create_text(II(k), J2+30, text = str(int(100*k)/100))
k += L
k = 0
while k>X1:
canv.create_line(II(k), JJ(-0.02), II(k), JJ(0.02), width = 2)
canv.create_text(II(k), I2+30, text = str(int(100*k)/100))
k -= L
points = []
x = X1+(pi/2)
for i in range(n):
y = F(x)
P = (II(x), JJ(y))
points.append(P)
x = x + h
canv.create_line(points, width = 1, fill = 'yellow', smooth = 1)
canv.create_text(40, 480, text = 'Xmin = ' + str(int(100*X1)/100))
canv.create_text(460, 480, text = 'Xmax = ' + str(int(100*X2)/100))
canv.create_text(210, 480, text = 'Ymin = ' + str(int(100*Y1)/100))
canv.create_text(210, 20, text = 'Ymax = ' + str(int(100*Y2)/100))
canv.pack()
root.mainloop()