|
| 1 | +using IntervalArithmetic, IntervalRootFinding |
| 2 | +using ForwardDiff |
| 3 | +using Base.Test |
| 4 | + |
| 5 | +struct Slopes{T} |
| 6 | + f::Function |
| 7 | + x::Interval{T} |
| 8 | + c::T |
| 9 | + sol::Interval{T} |
| 10 | +end |
| 11 | + |
| 12 | +@testset "Automatic slope expansion" begin |
| 13 | + rts = Slopes{Float64}[] |
| 14 | + push!(rts, Slopes(x->((x + sin(x)) * exp(-x^2)), interval(0.75, 1.75), 1.25, interval(-2.8, 0.1))) |
| 15 | + push!(rts, Slopes(x->(x^4 - 10x^3 + 35x^2 - 50x + 24), interval(0.75, 1.75), 1.25, interval(-44, 38.5))) |
| 16 | + push!(rts, Slopes(x->((log(x + 1.25) - 0.84x) ^ 2), interval(0.75, 1.75), 1.25, interval(-0.16, 0.44))) |
| 17 | + push!(rts, Slopes(x->(0.02x^2 - 0.03exp(-(20(x - 0.875))^2)), interval(0.75, 1.75), 1.25, interval(0.04, 0.33))) |
| 18 | + push!(rts, Slopes(x->(exp(x^2)), interval(0.75, 1.75), 1.25, interval(6.03, 33.23))) |
| 19 | + push!(rts, Slopes(x->(x^4 - 12x^3 + 47x^2 - 60x - 20exp(-x)), interval(0.75, 1.75), 1.25, interval(-39, 65.56))) |
| 20 | + push!(rts, Slopes(x->(x^6 - 15x^4 + 27x^2 + 250), interval(0.75, 1.75), 1.25, interval(-146.9, 67.1))) |
| 21 | + |
| 22 | + for i in 1:length(rts) |
| 23 | + @test slope(rts[i].f, rts[i].x, rts[i].c) ⊆ rts[i].sol |
| 24 | + end |
| 25 | +end |
0 commit comments