UNPKG

28.9 kBtext/coffeescriptView Raw
1test_roots = ->
2 run_test [
3
4 "roots(x)",
5 "0",
6
7 "roots(2^x-y,y)",
8 "2^x",
9
10 "roots(x^2)",
11 "0",
12
13 "roots(x^3)",
14 "0",
15
16 "roots(2 x)",
17 "0",
18
19 "roots(2 x^2)",
20 "0",
21
22 "roots(i*x^2-13*i*x+36*i)",
23 "[4,9]",
24
25 "roots(2 x^3)",
26 "0",
27
28 "roots(6+11*x+6*x^2+x^3)",
29 "[-3,-2,-1]",
30
31 "roots(a*x^2+b*x+c)",
32 #"[-b/(2*a)-(-4*a*c+b^2)^(1/2)/(2*a),-b/(2*a)+(-4*a*c+b^2)^(1/2)/(2*a)]",
33 "[-1/2*(b^2/(a^2)-4*c/a)^(1/2)-b/(2*a),1/2*(b^2/(a^2)-4*c/a)^(1/2)-b/(2*a)]",
34
35 "roots(3+7*x+5*x^2+x^3)",
36 "[-3,-1]",
37
38 "roots(x^3+x^2+x+1)",
39 "[-1,-i,i]",
40
41 "roots(x^2==1)",
42 "[-1,1]",
43
44 "roots(3 x + 12 == 24)",
45 "4",
46
47 "y=roots(x^2+b*x+c/k)[1]",
48 "",
49
50 "y^2+b*y+c/k",
51 "0",
52
53 "y=roots(x^2+b*x+c/k)[2]",
54 "",
55
56 "y^2+b*y+c/k",
57 "0",
58
59 "y=roots(a*x^2+b*x+c/4)[1]",
60 "",
61
62 "a*y^2+b*y+c/4",
63 "0",
64
65 "y=roots(a*x^2+b*x+c/4)[2]",
66 "",
67
68 "a*y^2+b*y+c/4",
69 "0",
70
71 "y=quote(y)",
72 "",
73
74 # --------------------------------------------
75 # some more tests with 3rd degree polynomials
76 # including use of cubic formula.
77 # Only the ones marked "DOES use cubic formula"
78 # actually do so, all other examples manage to
79 # be reduced via factoring.
80 # --------------------------------------------
81
82 "roots(x^3 + x^2 + x + 1)",
83 "[-1,-i,i]",
84
85 "roots(2*x^3 + 3*x^2 - 11*x - 6)",
86 "[-3,-1/2,2]",
87
88 "roots(x^3 - 7*x^2 + 4*x + 12)",
89 "[-1,2,6]",
90
91 "roots(x^3 + 1)",
92 "[-1,1/2-1/2*i*3^(1/2),1/2+1/2*i*3^(1/2)]",
93 # also: "[-1,-(-1)^(2/3),(-1)^(1/3))",
94
95 "roots(x^3 - 1)",
96 "[1,-1/2-1/2*i*3^(1/2),-1/2+1/2*i*3^(1/2)]",
97 # also: "[1,-(-1)^(1/3),(-1)^(2/3))",
98
99 "clearall",
100 "",
101
102 # DOES use cubic formula
103 "thePoly = x^3 + d",
104 "",
105
106 "roots(thePoly)",
107 # also OK:
108 # "[-d^(1/3),1/2*d^(1/3)*(1-i*3^(1/2)),1/2*d^(1/3)*(1+i*3^(1/2)))",
109 # or "[-(-1)^(2/3)*d^(1/3),-d^(1/3),(-1)^(1/3)*d^(1/3))",
110 "[1/2*d^(1/3)-1/2*i*3^(1/2)*d^(1/3),1/2*d^(1/3)+1/2*i*3^(1/2)*d^(1/3),-d^(1/3)]",
111
112 "and((simplify(subst(last[1],x,thePoly)) == 0),(simplify(subst(last[2],x,thePoly)) == 0),(simplify(subst(last[3],x,thePoly)) == 0))",
113 "1",
114
115 # DOES use cubic formula
116 # the actual format of this solution might change, the important thing
117 # is that the next few tests work, where we plug in the
118 # symbolic solutions in the polynomial again and we check that we
119 # get the zeroes.
120
121 "clearall",
122 "",
123
124 "thePoly = a*x^3 + b*x^2 + c*x + d",
125 "",
126
127 "roots(thePoly)",
128 "[-1/3*(1/2*(-27*b^2*c^2/(a^4)+108*b^3*d/(a^4)-486*b*c*d/(a^3)+108*c^3/(a^3)+729*d^2/(a^2))^(1/2)+b^3/(a^3)-9*b*c/(2*a^2)+27*d/(2*a))^(1/3)-b^2/(3*a^2*(1/2*(-27*b^2*c^2/(a^4)+108*b^3*d/(a^4)-486*b*c*d/(a^3)+108*c^3/(a^3)+729*d^2/(a^2))^(1/2)+b^3/(a^3)-9*b*c/(2*a^2)+27*d/(2*a))^(1/3))-b/(3*a)+c/(a*(1/2*(-27*b^2*c^2/(a^4)+108*b^3*d/(a^4)-486*b*c*d/(a^3)+108*c^3/(a^3)+729*d^2/(a^2))^(1/2)+b^3/(a^3)-9*b*c/(2*a^2)+27*d/(2*a))^(1/3)),(-1/3*a*b*(1/2*(-27*b^2*c^2/(a^4)+108*b^3*d/(a^4)-486*b*c*d/(a^3)+108*c^3/(a^3)+729*d^2/(a^2))^(1/2)+b^3/(a^3)-9*b*c/(2*a^2)+27*d/(2*a))^(1/3)-1/2*a*c+1/6*b^2-1/2*i*3^(1/2)*a*c-1/6*i*3^(1/2)*a^2*(1/2*(-27*b^2*c^2/(a^4)+108*b^3*d/(a^4)-486*b*c*d/(a^3)+108*c^3/(a^3)+729*d^2/(a^2))^(1/2)+b^3/(a^3)-9*b*c/(2*a^2)+27*d/(2*a))^(2/3)+1/6*i*3^(1/2)*b^2+1/6*a^2*(1/2*(-27*b^2*c^2/(a^4)+108*b^3*d/(a^4)-486*b*c*d/(a^3)+108*c^3/(a^3)+729*d^2/(a^2))^(1/2)+b^3/(a^3)-9*b*c/(2*a^2)+27*d/(2*a))^(2/3))/(a^2*(1/2*(-27*b^2*c^2/(a^4)+108*b^3*d/(a^4)-486*b*c*d/(a^3)+108*c^3/(a^3)+729*d^2/(a^2))^(1/2)+b^3/(a^3)-9*b*c/(2*a^2)+27*d/(2*a))^(1/3)),(-1/3*a*b*(1/2*(-27*b^2*c^2/(a^4)+108*b^3*d/(a^4)-486*b*c*d/(a^3)+108*c^3/(a^3)+729*d^2/(a^2))^(1/2)+b^3/(a^3)-9*b*c/(2*a^2)+27*d/(2*a))^(1/3)-1/2*a*c+1/6*b^2+1/2*i*3^(1/2)*a*c+1/6*i*3^(1/2)*a^2*(1/2*(-27*b^2*c^2/(a^4)+108*b^3*d/(a^4)-486*b*c*d/(a^3)+108*c^3/(a^3)+729*d^2/(a^2))^(1/2)+b^3/(a^3)-9*b*c/(2*a^2)+27*d/(2*a))^(2/3)-1/6*i*3^(1/2)*b^2+1/6*a^2*(1/2*(-27*b^2*c^2/(a^4)+108*b^3*d/(a^4)-486*b*c*d/(a^3)+108*c^3/(a^3)+729*d^2/(a^2))^(1/2)+b^3/(a^3)-9*b*c/(2*a^2)+27*d/(2*a))^(2/3))/(a^2*(1/2*(-27*b^2*c^2/(a^4)+108*b^3*d/(a^4)-486*b*c*d/(a^3)+108*c^3/(a^3)+729*d^2/(a^2))^(1/2)+b^3/(a^3)-9*b*c/(2*a^2)+27*d/(2*a))^(1/3))]",
129
130 "and((simplify(subst(last[1],x,thePoly)) == 0),(simplify(subst(last[2],x,thePoly)) == 0),(simplify(subst(last[3],x,thePoly)) == 0))",
131 "1",
132
133 "roots(x^3 + 6x - 20)",
134 "[2,-1-3*i,-1+3*i]",
135
136 "roots(x^3 - 6x - 40)",
137 "[4,-2-i*2^(1/2)*3^(1/2),-2+i*2^(1/2)*3^(1/2)]",
138
139 "roots(x^3 + x^2 - 5x - 5)",
140 "[-1,-5^(1/2),5^(1/2)]",
141
142 "roots(x^3 - 8x + 3)",
143 "[-3,3/2-1/2*5^(1/2),3/2+1/2*5^(1/2)]",
144
145 "roots(x^3 - 8x - 3)",
146 "[3,-3/2-1/2*5^(1/2),-3/2+1/2*5^(1/2)]",
147
148 "roots(x^3 - 18x + 35)",
149 "[-5,5/2-1/2*i*3^(1/2),5/2+1/2*i*3^(1/2)]",
150
151 "clearall",
152 "",
153
154 # DOES use cubic formula
155 "thePoly = x^3 - 3x + 1",
156 "",
157
158 "roots(thePoly)",
159 "[-(-1)^(1/9)+(-1)^(8/9),1/2*cos(1/9*pi)-1/2*cos(8/9*pi)+1/2*i*sin(1/9*pi)-1/2*i*sin(8/9*pi)-3^(1/2)*cos(11/18*pi),1/2*cos(1/9*pi)-1/2*cos(8/9*pi)+1/2*i*sin(1/9*pi)-1/2*i*sin(8/9*pi)+3^(1/2)*cos(11/18*pi)]",
160 # also: "[(3+1/3*(27/2+27/2*i*3^(1/2))^(2/3)-3*i*3^(1/2)+1/3*i*3^(1/2)*(27/2+27/2*i*3^(1/2))^(2/3))/(2*(27/2+27/2*i*3^(1/2))^(1/3)),(3+1/3*(27/2+27/2*i*3^(1/2))^(2/3)+3*i*3^(1/2)-1/3*i*3^(1/2)*(27/2+27/2*i*3^(1/2))^(2/3))/(2*(27/2+27/2*i*3^(1/2))^(1/3)),(-3-1/3*(27/2+27/2*i*3^(1/2))^(2/3))/((27/2+27/2*i*3^(1/2))^(1/3)))",
161
162 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-15))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-15))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-15))))",
163 "1",
164
165 "clearall",
166 "",
167
168 # DOES use cubic formula
169 "thePoly = x^3 - 3x - 1",
170 "",
171
172 "roots(thePoly)",
173 "[-(-1)^(2/9)+(-1)^(7/9),1/2*cos(2/9*pi)-1/2*cos(7/9*pi)+1/2*i*sin(2/9*pi)-1/2*i*sin(7/9*pi)-3^(1/2)*cos(13/18*pi),1/2*cos(2/9*pi)-1/2*cos(7/9*pi)+1/2*i*sin(2/9*pi)-1/2*i*sin(7/9*pi)+3^(1/2)*cos(13/18*pi)]",
174 # also: "[(3+1/3*(-27/2+27/2*i*3^(1/2))^(2/3)-3*i*3^(1/2)+1/3*i*3^(1/2)*(-27/2+27/2*i*3^(1/2))^(2/3))/(2*(-27/2+27/2*i*3^(1/2))^(1/3)),(3+1/3*(-27/2+27/2*i*3^(1/2))^(2/3)+3*i*3^(1/2)-1/3*i*3^(1/2)*(-27/2+27/2*i*3^(1/2))^(2/3))/(2*(-27/2+27/2*i*3^(1/2))^(1/3)),(-3-1/3*(-27/2+27/2*i*3^(1/2))^(2/3))/((-27/2+27/2*i*3^(1/2))^(1/3)))",
175
176 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-15))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-15))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-15))))",
177 "1",
178
179 "roots(x^3 - 15x - 4)",
180 "[4,-2-3^(1/2),-2+3^(1/2)]",
181
182 "roots(2*x^3 - 4x^2 - 22*x + 24)",
183 "[-3,1,4]",
184
185 "clearall",
186 "",
187
188 # DOES use cubic formula
189 "thePoly = 3*x^3 - 10*x^2 - 14*x + 27",
190 "",
191
192 "roots(thePoly)",
193 "[1/3*(10/3-226/(9*(781/54+i*97^(1/2)*1933^(1/2)/(2*3^(1/2)))^(1/3))-(781/54+i*97^(1/2)*1933^(1/2)/(2*3^(1/2)))^(1/3)),1/3*(10/3+113/(9*(781/54+i*97^(1/2)*1933^(1/2)/(2*3^(1/2)))^(1/3))+1/2*(781/54+i*97^(1/2)*1933^(1/2)/(2*3^(1/2)))^(1/3)-113*i*3^(1/2)/(9*(781/54+i*97^(1/2)*1933^(1/2)/(2*3^(1/2)))^(1/3))+1/2*i*3^(1/2)*(781/54+i*97^(1/2)*1933^(1/2)/(2*3^(1/2)))^(1/3)),1/3*(10/3+113/(9*(781/54+i*97^(1/2)*1933^(1/2)/(2*3^(1/2)))^(1/3))+1/2*(781/54+i*97^(1/2)*1933^(1/2)/(2*3^(1/2)))^(1/3)+113*i*3^(1/2)/(9*(781/54+i*97^(1/2)*1933^(1/2)/(2*3^(1/2)))^(1/3))-1/2*i*3^(1/2)*(781/54+i*97^(1/2)*1933^(1/2)/(2*3^(1/2)))^(1/3))]",
194
195 "and((subst(float(last[1]),x,thePoly) == 0),(subst(float(last[2]),x,thePoly) == 0),(subst(float(last[3]),x,thePoly)) == 0)",
196 "1",
197
198
199 "clearall",
200 "",
201
202 # DOES use cubic formula
203 "thePoly = 1*x^3 + 6*x^2 - 12*x + 8",
204 "",
205
206 "roots(thePoly)",
207 "[-2+2^(1/3)+2^(2/3)-i*2^(1/3)*3^(1/2)+i*2^(2/3)*3^(1/2),-2+2^(1/3)+2^(2/3)+i*2^(1/3)*3^(1/2)-i*2^(2/3)*3^(1/2),-2*(1+2^(1/3)+2^(2/3))]",
208
209 "and((subst(float(last[1]),x,thePoly) == 0),(subst(float(last[2]),x,thePoly) == 0),(subst(float(last[3]),x,thePoly) == 0))",
210 "1",
211
212
213 "roots(1*x^3 + 6*x^2 + 12*x + 8)",
214 "-2",
215
216 "clearall",
217 "",
218
219 # DOES use cubic formula
220 "thePoly = 1*x^3 + 0*x^2 + 12*x - 10",
221 "",
222
223 "roots(thePoly)",
224 "[(-6+1/6*(-135+27*89^(1/2))^(2/3)-6*i*3^(1/2)-1/6*i*3^(1/2)*(-135+27*89^(1/2))^(2/3))/((-135+27*89^(1/2))^(1/3)),(-6+1/6*(-135+27*89^(1/2))^(2/3)+6*i*3^(1/2)+1/6*i*3^(1/2)*(-135+27*89^(1/2))^(2/3))/((-135+27*89^(1/2))^(1/3)),(12-1/3*(-135+27*89^(1/2))^(2/3))/((-135+27*89^(1/2))^(1/3))]",
225
226 "and((subst(float(last[1]),x,thePoly) < float(10^(-13))),(subst(float(last[2]),x,thePoly) < float(10^(-13))),(subst(float(last[3]),x,thePoly) < float(10^(-14))))",
227 "1",
228
229 "roots(1*x^3 + 0*x^2 - 18*x + 35)",
230 "[-5,5/2-1/2*i*3^(1/2),5/2+1/2*i*3^(1/2)]",
231
232 "clearall",
233 "",
234
235 # DOES use cubic formula
236 "thePoly = 1*x^3 + 0*x^2 - 3*x - 6",
237 "",
238
239 "roots(thePoly)",
240 "[(3+1/3*(-81+54*2^(1/2))^(2/3)-3*i*3^(1/2)+1/3*i*3^(1/2)*(-81+54*2^(1/2))^(2/3))/(2*(-81+54*2^(1/2))^(1/3)),(3+1/3*(-81+54*2^(1/2))^(2/3)+3*i*3^(1/2)-1/3*i*3^(1/2)*(-81+54*2^(1/2))^(2/3))/(2*(-81+54*2^(1/2))^(1/3)),(-3-1/3*(-81+54*2^(1/2))^(2/3))/((-81+54*2^(1/2))^(1/3))]",
241
242 "and((subst(float(last[1]),x,thePoly) < float(10^(-14))),(subst(float(last[2]),x,thePoly) < float(10^(-14))),(subst(float(last[3]),x,thePoly) < float(10^(-14))))",
243 "1",
244
245 "roots(2*x^3 - 30*x^2 + 162*x - 350)",
246 "[7,4-3*i,4+3*i]",
247
248 "roots(1*x^3 - 4*x^2 - 6*x + 5)",
249 "[5,-1/2-1/2*5^(1/2),-1/2+1/2*5^(1/2)]",
250
251 "clearall",
252 "",
253
254 # DOES use cubic formula
255 "thePoly = 3*x^3 + 6*x^2 + 4*x + 9",
256 "",
257
258 "roots(thePoly)",
259 "[1/3*(-2-73^(1/3)),1/3*(-2+1/2*73^(1/3)-1/2*i*3^(1/2)*73^(1/3)),1/3*(-2+1/2*73^(1/3)+1/2*i*3^(1/2)*73^(1/3))]",
260
261 "and((subst(float(last[1]),x,thePoly) < float(10^(-14))),(subst(float(last[2]),x,thePoly) < float(10^(-14))),(subst(float(last[3]),x,thePoly) < float(10^(-14))))",
262 "1",
263
264 "clearall",
265 "",
266
267 # DOES use cubic formula
268 "thePoly = 3*x^3 + 21*x^2 + 2*x + 3",
269 "",
270
271 "roots(thePoly)",
272 "[1/3*(-7-47/((671/2+1/2*34949^(1/2))^(1/3))-(671/2+1/2*34949^(1/2))^(1/3)),1/3*(-7+47/(2*(671/2+1/2*34949^(1/2))^(1/3))+1/2*(671/2+1/2*34949^(1/2))^(1/3)-47*i*3^(1/2)/(2*(671/2+1/2*34949^(1/2))^(1/3))+1/2*i*3^(1/2)*(671/2+1/2*34949^(1/2))^(1/3)),1/3*(-7+47/(2*(671/2+1/2*34949^(1/2))^(1/3))+1/2*(671/2+1/2*34949^(1/2))^(1/3)+47*i*3^(1/2)/(2*(671/2+1/2*34949^(1/2))^(1/3))-1/2*i*3^(1/2)*(671/2+1/2*34949^(1/2))^(1/3))]",
273
274 "and((subst(float(last[1]),x,thePoly) < float(10^(-12))),(subst(float(last[2]),x,thePoly) < float(10^(-13))),(subst(float(last[3]),x,thePoly) < float(10^(-13))))",
275 "1",
276
277 "clearall",
278 "",
279
280 # DOES use cubic formula
281 "thePoly = 3*x^3 - 6*x^2 + 4*x - 5",
282 "",
283
284 "roots(thePoly)",
285 # also these ones could be sort of OK:
286 # "[2/3-1/3*(-1)^(1/3)*37^(1/3),2/3+1/6*(-1)^(1/3)*37^(1/3)-(-1)^(5/6)*37^(1/3)/(2*3^(1/2)),2/3+1/6*(-1)^(1/3)*37^(1/3)+(-1)^(5/6)*37^(1/3)/(2*3^(1/2)))",
287 # "[2/3-1/3*(-1)^(1/3)*37^(1/3),2/3-1/6*37^(1/3)+i*37^(1/3)/(2*3^(1/2)),2/3+1/3*37^(1/3))",
288 # "[1/3*(2-(-1)^(1/3)*37^(1/3)),1/3*(2-1/2*37^(1/3)+1/2*i*3^(1/2)*37^(1/3)),1/3*(2+37^(1/3)))",
289 "[2/3-1/3*(-1)^(1/3)*37^(1/3),1/3*(2-1/2*37^(1/3)+1/2*i*3^(1/2)*37^(1/3)),1/3*(2+37^(1/3))]",
290
291 "and((subst(float(last[1]),x,thePoly) < float(10^(-14))),(subst(float(last[2]),x,thePoly) < float(10^(-14))),(subst(float(last[3]),x,thePoly) < float(10^(-14))))",
292 "1",
293
294 "roots(8*x^3 - 36*x^2 + 54*x - 27)",
295 "3/2",
296
297 "roots(3*x^3 - 5*x^2 - 1*x - 2)",
298 "[2,-1/6-1/6*i*11^(1/2),-1/6+1/6*i*11^(1/2)]",
299
300
301 "clearall",
302 "",
303
304 # DOES use cubic formula
305 "thePoly = 3*x^3 - 6*x^2 + 4*x - i",
306 "",
307
308 "roots(thePoly)",
309 "[1/3*(2-(8-9*i)^(1/3)),1/3*(2+1/2*(8-9*i)^(1/3)-1/2*i*3^(1/2)*(8-9*i)^(1/3)),1/3*(2+1/2*(8-9*i)^(1/3)+1/2*i*3^(1/2)*(8-9*i)^(1/3))]",
310
311 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-15))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-15))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-15))))",
312 "1",
313
314
315 "clearall",
316 "",
317
318 # DOES use cubic formula
319 "thePoly = x^3+i",
320 "",
321
322 "roots(thePoly)",
323 # also these could be OK:
324 # "[1/2*(-1)^(1/6)-1/2*(-1)^(2/3)*3^(1/2),-(-1)^(1/6),1/2*(-1)^(1/6)*(1+i*3^(1/2)))",
325 # "[-1/2*i+1/2*3^(1/2),-(-1)^(1/6),i)",
326 # "[-(-1)^(1/6),-(-1)^(5/6),i)",
327 "[-1/2*i-1/2*3^(1/2),-1/2*i+1/2*3^(1/2),i]",
328
329 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-15))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-15))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-15))))",
330 "1",
331
332
333 "clearall",
334 "",
335
336 # DOES use cubic formula
337 "thePoly = x^3-i",
338 "",
339
340 "roots(thePoly)",
341 # "[-i,1/2*(i-3^(1/2)),1/2*(i+3^(1/2)))",
342 # "[-i,(-1)^(1/6),(-1)^(5/6))",
343 "[-3/4*i-1/2*(-1)^(5/6)-1/4*3^(1/2),3/4*i-1/2*(-1)^(5/6)+1/4*3^(1/2),(-1)^(5/6)]",
344
345 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-15))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-15))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-15))))",
346 "1",
347
348 # some quartics
349
350 "clearall",
351 "",
352
353 "thePoly = x^4 + 1",
354 "",
355
356 "theRoots = roots(thePoly)",
357 "",
358
359 "theRoots",
360 # "[-(-1)^(1/4),-(-1)^(3/4),(-1)^(1/4),(-1)^(3/4))",
361 "[-1/2*2^(1/2)-1/2*i*2^(1/2),-1/2*2^(1/2)+1/2*i*2^(1/2),1/2*2^(1/2)-1/2*i*2^(1/2),1/2*2^(1/2)+1/2*i*2^(1/2)]",
362
363 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-15))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-15))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-15))), (abs(float(subst(float(last[4]),x,thePoly))) < float(2*10^(-15))))",
364 "1",
365
366 "clearall",
367 "",
368
369 "thePoly = 4*x^4 - 1*x^3 + 4*x^2 + 3*x + 5",
370 "",
371
372 "theRoots = roots(thePoly)",
373 "",
374
375 "theRoots",
376 "[1/16-1/2*(-125/96-447/(256*(-125/192+265/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))+1/3*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3)+265*i*3^(1/2)/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))-1/3*i*3^(1/2)*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))^(1/2))-265/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))-1/3*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3)-265*i*3^(1/2)/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))+1/3*i*3^(1/2)*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))^(1/2)+1/2*(-125/192+265/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))+1/3*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3)+265*i*3^(1/2)/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))-1/3*i*3^(1/2)*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))^(1/2),1/16-1/2*(-125/96+447/(256*(-125/192+265/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))+1/3*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3)+265*i*3^(1/2)/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))-1/3*i*3^(1/2)*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))^(1/2))-265/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))-1/3*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3)-265*i*3^(1/2)/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))+1/3*i*3^(1/2)*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))^(1/2)-1/2*(-125/192+265/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))+1/3*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3)+265*i*3^(1/2)/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))-1/3*i*3^(1/2)*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))^(1/2),1/16+1/2*(-125/96-447/(256*(-125/192+265/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))+1/3*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3)+265*i*3^(1/2)/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))-1/3*i*3^(1/2)*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))^(1/2))-265/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))-1/3*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3)-265*i*3^(1/2)/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))+1/3*i*3^(1/2)*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))^(1/2)+1/2*(-125/192+265/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))+1/3*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3)+265*i*3^(1/2)/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))-1/3*i*3^(1/2)*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))^(1/2),1/16+1/2*(-125/96+447/(256*(-125/192+265/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))+1/3*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3)+265*i*3^(1/2)/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))-1/3*i*3^(1/2)*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))^(1/2))-265/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))-1/3*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3)-265*i*3^(1/2)/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))+1/3*i*3^(1/2)*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))^(1/2)-1/2*(-125/192+265/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))+1/3*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3)+265*i*3^(1/2)/(192*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))-1/3*i*3^(1/2)*(4417/1024+9/1024*i*461^(1/2)*1471^(1/2))^(1/3))^(1/2)]",
377
378 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[4]),x,thePoly))) < float(2*10^(-12))))",
379 "1",
380
381 "clearall",
382 "",
383
384 "thePoly = x^5 + 1",
385 "",
386
387 "theRoots = roots(thePoly)",
388 "",
389
390 "theRoots",
391 # "[-1,-(-1)^(2/5),-(-1)^(4/5),(-1)^(1/5),(-1)^(3/5))",
392 "[-1,cos(1/5*pi)+i*sin(1/5*pi),cos(3/5*pi)+i*sin(3/5*pi),-cos(2/5*pi)-i*sin(2/5*pi),-cos(4/5*pi)-i*sin(4/5*pi)]",
393
394 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[4]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[5]),x,thePoly))) < float(2*10^(-12))))",
395 "1",
396
397 "clearall",
398 "",
399
400 "thePoly = a*x^5 + k",
401 "",
402
403 "theRoots = roots(thePoly)",
404 "",
405
406 "theRoots[1] = simplify(theRoots[1])",
407 "",
408
409 "theRoots[1]",
410 "-(-1)^(2/5)*((k/a)^(2/5))^(1/2)",
411
412 "theRoots[2] = simplify(theRoots[2])",
413 "",
414
415 "theRoots[2]",
416 "-(-1)^(4/5)*((k/a)^(2/5))^(1/2)",
417
418 "theRoots[3] = circexp(theRoots[3])",
419 "",
420
421 "theRoots[3]",
422 "exp(1/5*i*pi)*(k/a)^(1/5)",
423
424 "theRoots[4] = circexp(theRoots[4])",
425 "",
426
427 "theRoots[4]",
428 "exp(3/5*i*pi)*(k/a)^(1/5)",
429
430 "theRoots[5] = simplify(theRoots[5])",
431 "",
432
433 "theRoots[5]",
434 "-(k/a)^(1/5)",
435
436 # unfortunately the comparison here doesn't work,
437 # due to rounding errors float() produces expressions that still hve
438 # a and k, albeit with really small
439 # coefficients, and hence the "<" comparison finds variables with
440 # undefined values and
441 # fails.
442
443 #"and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[4]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[5]),x,thePoly))) < float(2*10^(-12))))",
444 #"1",
445
446 "clearall",
447 "",
448
449 "thePoly = x^3 - 7*x^2 + 41*x - 87",
450 "",
451
452 "theRoots = roots(thePoly)",
453 "",
454
455 "theRoots",
456 "[3,2-5*i,2+5*i]",
457
458 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))))",
459 "1",
460
461 "clearall",
462 "",
463
464 "thePoly = 398683376+1720835*x+2320*x^2+x^3",
465 "",
466
467 "theRoots = roots(thePoly)",
468 "",
469
470 # root 1 ~= -961.79, root 2 ~= -895.12, root 3 ~= -463.09
471 # all three of them have a very small "error" imaginary part ~= 10^-13
472 "theRoots",
473 "[-2320/3-219895/(3*(-96123824+9*i*7^(1/2)*79^(1/2)*2297^(1/2)*13538519^(1/2))^(1/3))-1/3*(-96123824+9*i*7^(1/2)*79^(1/2)*2297^(1/2)*13538519^(1/2))^(1/3),-2320/3+219895/(6*(-96123824+9*i*7^(1/2)*79^(1/2)*2297^(1/2)*13538519^(1/2))^(1/3))+1/6*(-96123824+9*i*7^(1/2)*79^(1/2)*2297^(1/2)*13538519^(1/2))^(1/3)-219895*i*3^(1/2)/(6*(-96123824+9*i*7^(1/2)*79^(1/2)*2297^(1/2)*13538519^(1/2))^(1/3))+1/6*i*3^(1/2)*(-96123824+9*i*7^(1/2)*79^(1/2)*2297^(1/2)*13538519^(1/2))^(1/3),-2320/3+219895/(6*(-96123824+9*i*7^(1/2)*79^(1/2)*2297^(1/2)*13538519^(1/2))^(1/3))+1/6*(-96123824+9*i*7^(1/2)*79^(1/2)*2297^(1/2)*13538519^(1/2))^(1/3)+219895*i*3^(1/2)/(6*(-96123824+9*i*7^(1/2)*79^(1/2)*2297^(1/2)*13538519^(1/2))^(1/3))-1/6*i*3^(1/2)*(-96123824+9*i*7^(1/2)*79^(1/2)*2297^(1/2)*13538519^(1/2))^(1/3)]",
474
475 # the error here is particularly high because of the big coefficients
476 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-7))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-7))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-7))))",
477 "1",
478
479 "clearall",
480 "",
481
482 "thePoly = x^4 - 1*x^3 + 4*x^2 + 3*x + 5",
483 "",
484
485 "theRoots = roots(thePoly)",
486 "",
487
488 "theRoots",
489 "[-1/2-1/2*i*3^(1/2),-1/2+1/2*i*3^(1/2),1-2*i,1+2*i]",
490
491 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[4]),x,thePoly))) < float(2*10^(-12))))",
492 "1",
493
494 "clearall",
495 "",
496
497 "thePoly = x^4 - 2*x^3 - 7*x^2 + 8*x + 12",
498 "",
499
500 "theRoots = roots(thePoly)",
501 "",
502
503 "theRoots",
504 "[-2,-1,2,3]",
505
506 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[4]),x,thePoly))) < float(2*10^(-12))))",
507 "1",
508
509 "clearall",
510 "",
511
512 "thePoly = x^4+8*x^2+3",
513 "",
514
515 "theRoots = roots(thePoly)",
516 "",
517
518 "theRoots",
519 "[-(-4-13^(1/2))^(1/2),-(-4+13^(1/2))^(1/2),(-4-13^(1/2))^(1/2),(-4+13^(1/2))^(1/2)]",
520
521 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[4]),x,thePoly))) < float(2*10^(-12))))",
522 "1",
523
524 "clearall",
525 "",
526
527 "thePoly = -1*x^3-1*x^2+10*x - 8",
528 "",
529
530 "theRoots = roots(thePoly)",
531 "",
532
533 "theRoots",
534 "[-4,1,2]",
535
536 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))))",
537 "1",
538
539 "clearall",
540 "",
541
542 "thePoly = -3-9*x+3*x^2+x^3",
543 "",
544
545 "theRoots = roots(thePoly)",
546 "",
547
548 # these solutions are slightly verbose but they are essentially good,
549 # take into account that ((108+108*i*3^(1/2))^(1/3)) is
550 # really just a compact version (in terms of number of nodes)
551 # for 3*2^(2/3)*(1+i*sqrt(3))^(1/3)
552 # (just take out 108 from the radical, and 108 is 2x2x3x3x3)
553 # so essentially these are written a little redundantly but
554 # they actually are in pretty good form.
555 "theRoots",
556 # "[-1-12/((108+108*i*3^(1/2))^(1/3))-1/3*(108+108*i*3^(1/2))^(1/3),-1+6/((108+108*i*3^(1/2))^(1/3))+1/6*(108+108*i*3^(1/2))^(1/3)-6*i*3^(1/2)/((108+108*i*3^(1/2))^(1/3))+1/6*i*3^(1/2)*(108+108*i*3^(1/2))^(1/3),-1+6/((108+108*i*3^(1/2))^(1/3))+1/6*(108+108*i*3^(1/2))^(1/3)+6*i*3^(1/2)/((108+108*i*3^(1/2))^(1/3))-1/6*i*3^(1/2)*(108+108*i*3^(1/2))^(1/3))",
557 "[-1+cos(1/9*pi)-cos(8/9*pi)+i*sin(1/9*pi)-i*sin(8/9*pi)-2*3^(1/2)*cos(11/18*pi),-1+cos(1/9*pi)-cos(8/9*pi)+i*sin(1/9*pi)-i*sin(8/9*pi)+2*3^(1/2)*cos(11/18*pi),-1-2*cos(1/9*pi)+2*cos(8/9*pi)-2*i*sin(1/9*pi)+2*i*sin(8/9*pi)]",
558
559 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))))",
560 "1",
561
562 "clearall",
563 "",
564
565 "thePoly = x^4 + 8*x^3 + 12*x^2 + (2*30^(1/2) -16)*x + 4*30^(1/2)-28",
566 "",
567
568 "theRoots = roots(thePoly)",
569 "",
570
571 "theRoots",
572 "[-2-1/2*(18-4*5^(1/2))^(1/2)+3^(1/2)/(2^(1/2)),-2-1/2*(18+4*5^(1/2))^(1/2)-1/2*2^(1/2)*3^(1/2),-2+1/2*(18-4*5^(1/2))^(1/2)+3^(1/2)/(2^(1/2)),-2+1/2*(18+4*5^(1/2))^(1/2)-1/2*2^(1/2)*3^(1/2)]",
573
574 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[4]),x,thePoly))) < float(2*10^(-12))))",
575 "1",
576
577 "clearall",
578 "",
579
580 "thePoly = x^3 + x - 2",
581 "",
582
583 "theRoots = roots(thePoly)",
584 "",
585
586 "theRoots",
587 "[1,-1/2-1/2*i*7^(1/2),-1/2+1/2*i*7^(1/2)]",
588
589 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))))",
590 "1",
591
592
593 "clearall",
594 "",
595
596 "thePoly = x^3 + x^2 - 7",
597 "",
598
599 "theRoots = roots(thePoly)",
600 "",
601
602 # note how we can't use "last" here because the assignment returns nothing
603 "and(abs(float(subst(theRoots[1],x,thePoly))) < float(2*10^(-12)),abs(float(subst(theRoots[2],x,thePoly))) < float(2*10^(-12)),abs(float(subst(theRoots[3],x,thePoly))) < float(2*10^(-12)))",
604 "1",
605
606 # some quartics
607
608 "clearall",
609 "",
610
611 "thePoly = x^4 + 8*x^2 + 3",
612 "",
613
614 "theRoots = roots(thePoly)",
615 "",
616
617 "theRoots",
618 "[-(-4-13^(1/2))^(1/2),-(-4+13^(1/2))^(1/2),(-4-13^(1/2))^(1/2),(-4+13^(1/2))^(1/2)]",
619
620 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(8*10^(-15))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-15))), (abs(float(subst(float(last[3]),x,thePoly))) < float(8*10^(-15))), (abs(float(subst(float(last[4]),x,thePoly))) < float(2*10^(-15))))",
621 "1",
622
623 "clearall",
624 "",
625
626 "thePoly = x^4 - 10*x^3 + 21*x^2 + 40*x - 100",
627 "",
628
629 "theRoots = roots(thePoly)",
630 "",
631
632 "theRoots",
633 "[-2,2,5]",
634
635 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))))",
636 "1",
637
638 "clearall",
639 "",
640
641 "thePoly = 2*x^4 - 8*x^3 + 2*x^2 + 24*x - 14",
642 "",
643
644 "theRoots = roots(thePoly)",
645 "",
646
647 "clearall",
648 "",
649
650 "thePoly = x^4 - 4*x^3 + x^2 + 12*x - 7",
651 "",
652
653 "theRoots = roots(thePoly)",
654 "",
655
656 "theRoots",
657 "[-1/2-1/2*5^(1/2),-1/2+1/2*5^(1/2),5/2-1/2*i*3^(1/2),5/2+1/2*i*3^(1/2)]",
658
659 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[4]),x,thePoly))) < float(2*10^(-12))))",
660 "1",
661
662 "clearall",
663 "",
664
665 "thePoly = 2*x^4 - 8*x^3 + 2*x^2 + 24*x - 14",
666 "",
667
668 "theRoots = roots(thePoly)",
669 "",
670
671 "theRoots",
672 "[-1/2-1/2*5^(1/2),-1/2+1/2*5^(1/2),5/2-1/2*i*3^(1/2),5/2+1/2*i*3^(1/2)]",
673
674 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[4]),x,thePoly))) < float(2*10^(-12))))",
675 "1",
676
677 "clearall",
678 "",
679
680 "thePoly = x^4 - 9*x^3 + 22*x^2 + 28*x - 120",
681 "",
682
683 "theRoots = roots(thePoly)",
684 "",
685
686 "theRoots",
687 "[-2,3,4-2*i,4+2*i]",
688
689 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[4]),x,thePoly))) < float(2*10^(-12))))",
690 "1",
691
692
693 #"thePoly = 4* x^4 - 9*x^3 + 22*x^2 + 28*x - 120",
694 #"",
695 #
696 # these are really ugly - sympy or wolfram alpha don't give clean symbolic solutions either
697 #"theRoots = roots(thePoly)",
698 #"",
699 #
700 #"and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[4]),x,thePoly))) < float(2*10^(-12))))",
701 #"1",
702 #
703 #"thePoly = -20*x^4 + 5*x^3 + 17*x^2 - 29*x + 87",
704 #"",
705 #
706 # these are really ugly - sympy or wolfram alpha don't give clean symbolic solutions either
707 #"theRoots = roots(thePoly)",
708 #"",
709 #
710 #"and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-12))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-12))), (abs(float(subst(float(last[4]),x,thePoly))) < float(2*10^(-12))))",
711 #"1",
712 #
713
714 "clearall",
715 "",
716
717 "thePoly = x^4 + 2*x^3 - 41*x^2 - 42*x + 360",
718 "",
719
720 "theRoots = roots(thePoly)",
721 "",
722
723 "theRoots",
724 "[-6,-4,3,5]",
725
726 "and((abs(float(subst(float(last[1]),x,thePoly))) < float(2*10^(-15))),(abs(float(subst(float(last[2]),x,thePoly))) < float(2*10^(-15))), (abs(float(subst(float(last[3]),x,thePoly))) < float(2*10^(-15))), (abs(float(subst(float(last[4]),x,thePoly))) < float(2*10^(-15))))",
727 "1",
728
729
730
731 # clean up
732 "thePoly = quote(thePoly)",
733 "",
734
735 "theRoots = quote(theRoots)",
736 "",
737
738 ]