Skip to content

Commit 63d21d1

Browse files
authored
Merge pull request #286 from JuliaReach/schillic/exp_remainder
Fix `_exp_remainder`
2 parents e1be2e1 + 1022f85 commit 63d21d1

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/exponential.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ function _exp_remainder(A::IntervalMatrix{T}, t, p; n=checksquare(A)) where {T}
9292
Cⁱ *= C
9393
end
9494
M = exp(C * t)
95-
Y = M - Q
96-
Γ = IntervalMatrix(fill(interval(-one(T), one(T)), (n, n)))
97-
E = Γ * Y
98-
return E
95+
E = Matrix{Interval{T}}(undef, n, n)
96+
@inbounds for i in eachindex(M)
97+
y = M[i] - Q[i]
98+
E[i] = (y >= zero(T)) ? interval(-y, y) : interval(y, -y)
99+
end
100+
return IntervalMatrix(E)
99101
end
100102

101103
# Estimates the sum of the series in the matrix exponential. See

test/exponential.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ using IntervalMatrices: TaylorOverapproximation,
55
horner,
66
scale_and_square,
77
_truncated_exponential_series,
8+
_exp_remainder,
89
_exp_remainder_series
910

1011
@testset "Interval matrix exponential" begin
@@ -44,6 +45,14 @@ using IntervalMatrices: TaylorOverapproximation,
4445
@test underapp1 == exp(M; alg=TaylorUnderapproximation(4))
4546
end
4647

48+
@testset "Interval matrix exponential remainder" begin
49+
M = IntervalMatrix([interval(1.5, 2) interval(0); interval(0) interval(0.5, 1)])
50+
E = _exp_remainder(M, 1, 1)
51+
e1 = exp(2) - 3
52+
e2 = exp(1) - 2
53+
@test E IntervalMatrix([interval(-e1, e1) interval(0); interval(0) interval(-e2, e2)])
54+
end
55+
4756
@testset "Interval matrix correction terms" begin
4857
m = IntervalMatrix([interval(-1.1, 0.9) interval(-4.1, -3.9);
4958
interval(3.9, 4.1) interval(-1.1, 0.9)])

0 commit comments

Comments
 (0)