@@ -22,17 +22,24 @@ three_halves_pi = 3*big_pi/2
22
22
f′ (x) = 2 * x* exp (x^ 2 ) + sin (x)
23
23
f1 (x) = x^ 4 - 10 x^ 3 + 35 x^ 2 - 50 x + 24
24
24
f1′ (x) = 4 x^ 3 - 30 x^ 2 + 70 x - 50
25
-
25
+ f2 (x) = 4567 x^ 2 - 9134 x + 4567
26
+ f2′ (x) = 9134 x - 9134
27
+ f3 (x) = (x^ 2 - 2 )^ 2
28
+ f3′ (x) = 4 x * (x^ 2 - 2 )
26
29
for autodiff in (false , true )
27
30
if autodiff
28
31
rts1 = newton1d (sin, - 5 .. 5 )
29
32
rts2 = newton1d (f, - ∞.. ∞)
30
33
rts3 = newton1d (f1, - 10 .. 10 )
34
+ rts4 = newton1d (f2, - 10 .. 11 )
35
+ rts5 = newton1d (f3, - 10 .. 10 )
31
36
32
37
else
33
38
rts1 = newton1d (sin, cos, - 5 .. 5 )
34
39
rts2 = newton1d (f, f′, - ∞.. ∞)
35
40
rts3 = newton1d (f1, f1′, - 10 .. 10 )
41
+ rts4 = newton1d (f2, f2′, - 10 .. 11 )
42
+ rts5 = newton1d (f3, f3′, - 10 .. 10 )
36
43
end
37
44
38
45
@test length (rts1) == 3
@@ -42,12 +49,20 @@ three_halves_pi = 3*big_pi/2
42
49
end
43
50
44
51
@test length (rts2) == 1
45
- @test (0 .. 0 ) == rts2[1 ]. interval && :unique == rts2[1 ]. status
52
+ @test (0 .. 0 ) == rts2[1 ]. interval && :unknown == rts2[1 ]. status
46
53
47
54
@test length (rts3) == 4
48
55
L = [1 , 2 , 3 , 4 ]
49
56
for i = 1 : length (rts3)
50
57
@test L[i] in rts3[i]. interval && :unique == rts3[i]. status
51
58
end
59
+
60
+ @test length (rts4) == 1
61
+ @test 1 in rts4[1 ]. interval && :unknown == rts4[1 ]. status
62
+
63
+ L1 = [- sqrt (2 ), - sqrt (2 ), sqrt (2 ), sqrt (2 )]
64
+ for i = 1 : length (rts5)
65
+ @test L1[i] in rts5[i]. interval && :unknown == rts5[i]. status
66
+ end
52
67
end
53
68
end
0 commit comments