Skip to content

Commit 2c77108

Browse files
authored
Merge pull request #123 from JuliaReach/schillic/75
#75 - Truncated exponential sum
2 parents a82937a + 454d310 commit 2c77108

File tree

2 files changed

+53
-27
lines changed

2 files changed

+53
-27
lines changed

src/exponential.jl

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,45 @@ function quadratic_expansion(A::IntervalMatrix, α::Real, β::Real)
121121
return IntervalMatrix(B)
122122
end
123123

124+
function _truncated_exponential_series(A::IntervalMatrix{T}, t, p::Integer;
125+
n=checksquare(A)) where {T}
126+
if p == 0
127+
# index i = 0 (identity matrix)
128+
return IntervalMatrix(Interval(one(T)) * I, n)
129+
elseif p == 1
130+
# index i = 1
131+
S = A * t
132+
else
133+
# indices i = 1 and i = 2
134+
S = quadratic_expansion(A, t)
135+
end
136+
137+
# index i = 0, (identity matrix, added implicitly)
138+
for i in 1:n
139+
S[i, i] += one(T)
140+
end
141+
142+
if p < 3
143+
return S
144+
end
145+
146+
# indices i >= 3
147+
pow = IntervalMatrixPower(A)
148+
increment!(pow)
149+
fact_num = t^2
150+
fact_denom = 2
151+
for i in 3:p
152+
fact_num *= t
153+
fact_denom *= i
154+
Aⁱ = increment!(pow)
155+
S += Aⁱ * (fact_num / fact_denom)
156+
end
157+
158+
return S
159+
end
160+
124161
"""
125-
exp_overapproximation(M::IntervalMatrix{T, Interval{T}}, t, p) where {T}
162+
exp_overapproximation(A::IntervalMatrix{T, Interval{T}}, t, p) where {T}
126163
127164
Overapproximation of the exponential of an interval matrix.
128165
@@ -139,26 +176,9 @@ Parameters and Inputs* by M. Althoff, O. Stursberg, M. Buss.
139176
"""
140177
function exp_overapproximation(A::IntervalMatrix{T, Interval{T}}, t, p) where {T}
141178
n = checksquare(A)
142-
179+
S = _truncated_exponential_series(A, t, p; n=n)
143180
E = _exp_remainder(A, t, p; n=n)
144-
S = IntervalMatrix(zeros(Interval{T}, n, n))
145-
Ai = square(A)
146-
fact_num = t^2
147-
fact_denom = 2
148-
for i in 3:p
149-
fact_num *= t
150-
fact_denom *= i
151-
Ai *= A
152-
S += Ai * (fact_num / fact_denom)
153-
end
154-
W = quadratic_expansion(A, t)
155-
res = W + S + E
156-
157-
# add identity matrix implicitly
158-
for i in 1:n
159-
res[i, i] += one(T)
160-
end
161-
return res
181+
return S + E
162182
end
163183

164184
# Implementation of Prop. 1 in Althoff, Matthias, Bruce H. Krogh, and Olaf Stursberg.
@@ -263,24 +283,25 @@ See Theorem 2 in *Reachability Analysis of Linear Systems with Uncertain
263283
Parameters and Inputs* by M. Althoff, O. Stursberg, M. Buss.
264284
"""
265285
function exp_underapproximation(A::IntervalMatrix{T, Interval{T}}, t, p) where {T}
286+
@assert p > 1 "the order $p < 2 is not supported"
266287
n = checksquare(A)
267288

268289
Y = zeros(n, n)
269290
LA = inf(A)
270-
Ail = LA^2
291+
Aⁱl = LA^2
271292
Z = zeros(n, n)
272293
RA = sup(A)
273-
Air = RA^2
294+
Aⁱr = RA^2
274295
fact_num = t^2
275296
fact_denom = 2
276297
for i in 3:p
277298
fact_num *= t
278299
fact_denom *= i
279300
fact = fact_num / fact_denom
280-
Ail *= LA
281-
Y += Ail * fact
282-
Air *= RA
283-
Z += Air * fact
301+
Aⁱl *= LA
302+
Y += Aⁱl * fact
303+
Aⁱr *= RA
304+
Z += Aⁱr * fact
284305
end
285306

286307
B = IntervalMatrix{T}(undef, n , n)

test/runtests.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using IntervalMatrices, Test, LinearAlgebra
22

3-
using IntervalMatrices: scale_and_square
3+
using IntervalMatrices: _truncated_exponential_series, scale_and_square
44

55
@testset "Interval arithmetic" begin
66
a = -1.5 ± 0.5
@@ -67,6 +67,11 @@ end
6767

6868
@testset "Interval matrix exponential" begin
6969
m = IntervalMatrix([-1.1..0.9 -4.1.. -3.9; 3.9..4.1 -1.1..0.9])
70+
71+
for i in 0:4
72+
_truncated_exponential_series(m, 1.0, i)
73+
end
74+
7075
overapp1 = exp_overapproximation(m, 1.0, 4)
7176
overapp2 = scale_and_square(m, 5, 1.0, 4)
7277
underapp = exp_underapproximation(m, 1.0, 4)

0 commit comments

Comments
 (0)