-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsecant.plt
184 lines (174 loc) · 6.66 KB
/
secant.plt
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
reset
set terminal png medium
set title "Root Approximation: Secant Method"
set xrange [-1.5:2.5]
set yrange [-3:3]
set xzeroaxis
set yzeroaxis
set output "images/secant1.png"
p1(x) = x**3 - x**2 - x - 1
plot p1(x) title 'x^3-x^2-x-1'
clear
unset object
unset label
unset arrow
set output "images/secant2.png"
set label 1 at -0.1,0.2
set label 1 "a" tc lt 1
set label 2 at -0.2,p1(0)-0.2
set label 2 "f(a)" tc lt 1
set arrow 1 from 0,0 to 0,p1(0) nohead lt 1
set object circle at first 0,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 0,p1(0) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
plot p1(x) title 'x^3-x^2-x-1'
clear
unset object
unset label
unset arrow
set output "images/secant3.png"
set label 1 at -0.1,0.2
set label 1 "a" tc lt 1
set label 2 at -0.2,p1(0)-0.2
set label 2 "f(a)" tc lt 1
set arrow 1 from 0,0 to 0,p1(0) nohead lt 1
set object circle at first 0,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 0,p1(0) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set label 3 at 2.1,-0.1
set label 3 "b" tc lt 1
set label 4 at 2.1,p1(2)-0.1
set label 4 "f(b)" tc lt 1
set arrow 2 from 2,0 to 2,p1(2) nohead lt 1
set object circle at first 2,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 2,p1(2) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
plot p1(x) title 'x^3-x^2-x-1'
clear
unset object
unset label
unset arrow
set output "images/secant4.png"
set label 1 at -0.1,0.2
set label 1 "a" tc lt 1
set label 2 at -0.2,p1(0)-0.2
set label 2 "f(a)" tc lt 1
set arrow 1 from 0,0 to 0,p1(0) nohead lt 1
set object circle at first 0,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 0,p1(0) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set label 3 at 2.1,-0.1
set label 3 "b" tc lt 1
set label 4 at 2.1,p1(2)-0.1
set label 4 "f(b)" tc lt 1
set arrow 2 from 2,0 to 2,p1(2) nohead lt 1
set object circle at first 2,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 2,p1(2) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set label 5 at 1.1,-0.1
set label 5 "s" tc lt 1
set label 6 at 1.1,p1(1)-0.1
set label 6 "f(s)" tc lt 1
set arrow 3 from 1,0 to 1,p1(1) nohead lt 1
set object circle at first 1,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 1,p1(1) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set arrow 4 from 0,p1(0) to 2,p1(2) nohead lt 1
plot p1(x) title 'x^3-x^2-x-1'
clear
unset object
unset label
unset arrow
set output "images/secant5.png"
set label 1 at 1.1,-0.1
set label 1 "a" tc lt 1
set label 2 at 1.1,p1(1)-0.1
set label 2 "f(a)" tc lt 1
set arrow 1 from 1,0 to 1,p1(1) nohead lt 1
set object circle at first 1,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 1,p1(1) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set label 3 at 2.1,-0.1
set label 3 "b" tc lt 1
set label 4 at 2.1,p1(2)-0.1
set label 4 "f(b)" tc lt 1
set arrow 2 from 2,0 to 2,p1(2) nohead lt 1
set object circle at first 2,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 2,p1(2) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
plot p1(x) title 'x^3-x^2-x-1'
clear
unset object
unset label
unset arrow
set output "images/secant6.png"
set label 1 at 1.1,-0.1
set label 1 "a" tc lt 1
set label 2 at 1.1,p1(1)-0.1
set label 2 "f(a)" tc lt 1
set arrow 1 from 1,0 to 1,p1(1) nohead lt 1
set object circle at first 1,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 1,p1(1) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set label 3 at 2.1,-0.1
set label 3 "b" tc lt 1
set label 4 at 2.1,p1(2)-0.1
set label 4 "f(b)" tc lt 1
set arrow 2 from 2,0 to 2,p1(2) nohead lt 1
set object circle at first 2,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 2,p1(2) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set label 5 at 1.77,-0.1
set label 5 "s" tc lt 1
set label 6 at 1.77,p1(1.67)-0.1
set label 6 "f(s)" tc lt 1
set arrow 3 from 1.67,0 to 1.67,p1(1.67) nohead lt 1
set object circle at first 1.67,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 1.67,p1(1.67) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set arrow 4 from 1,p1(1) to 2,p1(2) nohead lt 1
plot p1(x) title 'x^3-x^2-x-1'
clear
unset object
unset label
unset arrow
set output "images/secant8.png"
set label 1 at 1.57,-0.1
set label 1 "a" tc lt 1
set label 2 at 1.45,p1(1.67)-0.1
set label 2 "f(a)" tc lt 1
set arrow 1 from 1.67,0 to 1.67,p1(1.67) nohead lt 1
set object circle at first 1.67,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 1.67,p1(1.67) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set label 3 at 2.1,-0.1
set label 3 "b" tc lt 1
set label 4 at 2.1,p1(2)-0.1
set label 4 "f(b)" tc lt 1
set arrow 2 from 2,0 to 2,p1(2) nohead lt 1
set object circle at first 2,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 2,p1(2) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
plot p1(x) title 'x^3-x^2-x-1'
clear
unset object
unset label
unset arrow
set output "images/secant9.png"
set label 1 at 1.57,-0.1
set label 1 "a" tc lt 1
set label 2 at 1.45,p1(1.67)-0.1
set label 2 "f(a)" tc lt 1
set arrow 1 from 1.67,0 to 1.67,p1(1.67) nohead lt 1
set object circle at first 1.67,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 1.67,p1(1.67) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set label 3 at 2.1,-0.1
set label 3 "b" tc lt 1
set label 4 at 2.1,p1(2)-0.1
set label 4 "f(b)" tc lt 1
set arrow 2 from 2,0 to 2,p1(2) nohead lt 1
set object circle at first 2,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 2,p1(2) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set label 5 at 1.85,-0.1
set label 5 "m" tc lt 1
set label 6 at 1.85,p1(1.75)-0.1
set label 6 "f(m)" tc lt 1
set arrow 3 from 1.75,0 to 1.75,p1(1.75) nohead lt 1
set object circle at first 1.75,0 radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set object circle at first 1.75,p1(1.75) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
set arrow 4 from 1.67,p1(1.657) to 2,p1(2) nohead lt 1
plot p1(x) title 'x^3-x^2-x-1'
clear
unset object
unset label
unset arrow
set output "images/secant10.png"
set object circle at first 1.84,p1(1.84) radius char 0.5 fillstyle empty border lc rgb '#aa1100' lw 2
plot p1(x) title 'x^3-x^2-x-1'