Skip to content

Commit 48240bc

Browse files
authored
Merge pull request #62 from JuliaReach/schillic/46
Revise code for spectral bounds
2 parents dbd0667 + 586e76c commit 48240bc

File tree

2 files changed

+23
-34
lines changed

2 files changed

+23
-34
lines changed

src/error_bounds.jl

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
# =========================================================================================================================
1414

1515
# --- Error bounds using a priori estimate from [1] ---
16-
17-
# See Theorem 4.2 in [1]. This is a bound based on an a priori estimate
18-
# of the norm of the exact solution x(t).
1916
# These bounds use the supremum norm (p = Inf).
17+
18+
# see Theorem 4.2 in [1]; this bound is based on an a priori estimate
19+
# of the norm of the exact solution x(t)
2020
function error_bound_apriori(α, F₁, F₂; N)
2121
nF₂ = opnorm(F₂, Inf)
2222
μF₁ = logarithmic_norm(F₁, Inf)
@@ -26,7 +26,7 @@ function error_bound_apriori(α, F₁, F₂; N)
2626
return ε
2727
end
2828

29-
# See Theorem 4.2 in [1]
29+
# see Theorem 4.2 in [1]
3030
function convergence_radius_apriori(α, F₁, F₂)
3131
nF₂ = opnorm(F₂, Inf)
3232
μF₁ = logarithmic_norm(F₁, Inf)
@@ -41,7 +41,7 @@ end
4141

4242
# --- Error bounds using power series method from [1] ---
4343

44-
# See Theorem 4.3 in [1], which uses the power series method.
44+
# see Theorem 4.3 in [1], which uses the power series method
4545
function error_bound_pseries(x₀, F₁, F₂; N)
4646
nx₀ = norm(x₀, Inf)
4747
nF₁ = opnorm(F₁, Inf)
@@ -52,7 +52,7 @@ function error_bound_pseries(x₀, F₁, F₂; N)
5252
return ε
5353
end
5454

55-
# See Theorem 4.3 in [1].
55+
# see Theorem 4.3 in [1]
5656
function convergence_radius_pseries(x₀, F₁, F₂)
5757
nx₀ = norm(x₀, Inf)
5858
nF₁ = opnorm(F₁, Inf)
@@ -64,47 +64,37 @@ function convergence_radius_pseries(x₀, F₁, F₂)
6464
end
6565

6666
# --- Error bounds using spectral abscissa from [2] ---
67+
# These bounds use the spectral norm (p = 2).
6768

6869
# compute eigenvalues and sort them by increasing real part
69-
function _error_bound_specabs_Re_λ₁(F₁; check=true)
70+
function _error_bound_specabs_Re_λ₁(F₁)
7071
λ = eigvals(F₁; sortby=real)
71-
λ₁ = last(λ)
72-
Re_λ₁ = real(λ₁)
73-
if check && Re_λ₁ > 0
74-
throw(ArgumentError("expected Re(λ₁) ≤ 0, got $Re_λ₁"))
75-
end
76-
return Re_λ₁
72+
return real(last(λ))
7773
end
7874

79-
# See Definition (2.2) in [2]. These bounds use the spectral norm (p = 2)
80-
function _error_bound_specabs_R(x₀, F₂, Re_λ₁)
75+
# see Corollary 1 in [2]
76+
function error_bound_specabs(x₀, F₁, F₂; N, check=true)
77+
Re_λ₁ = _error_bound_specabs_Re_λ₁(F₁)
78+
if check && Re_λ₁ >= 0
79+
throw(ArgumentError("expected Re(λ₁) < 0, got $Re_λ₁"))
80+
end
81+
82+
# Equation (2.2)
8183
nx₀ = norm(x₀, 2)
8284
nF₂ = opnorm(F₂, 2)
83-
R = nx₀ * nF₂ / abs(Re_λ₁)
84-
return R
85-
end
86-
87-
# See Corollary 1 in [2]
88-
function error_bound_specabs(x₀, F₁, F₂; N, check=true)
89-
Re_λ₁ = _error_bound_specabs_Re_λ₁(F₁; check=check)
90-
R = _error_bound_specabs_R(x₀, F₂, Re_λ₁)
85+
R = nx₀ * nF₂ / -Re_λ₁
9186
if check && R >= 1
9287
throw(ArgumentError("expected R < 1, got R = $R; try scaling the ODE"))
9388
end
9489

95-
nx₀ = norm(x₀, 2)
96-
if iszero(Re_λ₁)
97-
nF₂ = opnorm(F₂, 2)
98-
ε = t -> nx₀ * (nx₀ * nF₂ * t)^N
99-
else
100-
ε = t -> nx₀ * R^N * (1 - exp(Re_λ₁ * t))^N
101-
end
90+
# Equation (4.29)
91+
ε = t -> nx₀ * R^N * (1 - exp(Re_λ₁ * t))^N
10292
return ε
10393
end
10494

105-
# See Corollary 1 in [2]
106-
function convergence_radius_specabs(x₀, F₁, F₂; check=true)
107-
Re_λ₁ = _error_bound_specabs_Re_λ₁(F₁; check=check)
95+
# see Corollary 1 in [2]
96+
function convergence_radius_specabs(x₀, F₁, F₂)
97+
Re_λ₁ = _error_bound_specabs_Re_λ₁(F₁)
10898

10999
if Re_λ₁ < 0
110100
T = Inf

test/runtests.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ end
156156
# Re_λ₁ > 0
157157
F1_pos = [0.0 0; 0 1]
158158
@test_throws ArgumentError convergence_radius_specabs(x0, F1_pos, F2)
159-
@test_throws ArgumentError convergence_radius_specabs(x0, F1_pos, F2; check=false)
160159

161160
F1_neg = [-2.0 -1; -1 -2]
162161
F1 = [0.0 1; -1 -2]

0 commit comments

Comments
 (0)