Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit 71a7cd4

Browse files
committed
added error benchmark
1 parent bd857c3 commit 71a7cd4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/error_benchmarking.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using DiffEqOperators, Plots
2+
3+
n = 10000
4+
@show n
5+
x = range(0.0; length = n, stop = 2π)
6+
dx = x[2]-x[1]
7+
y = exp.(π*x)
8+
y_ = y[2:(end-1)]
9+
10+
for dor in 1:4, aor in 2:6
11+
12+
D1 = CenteredDifference(dor,aor,dx,length(x))
13+
14+
#test result
15+
@show dor
16+
@show aor
17+
#take derivatives
18+
err_abs = abs.(D1*y .-^dor)*y_)
19+
err_percent = 100*err_abs./abs.(((π^dor)*y_))
20+
max_error = maximum(err_percent) # test operator with known derivative of exp(kx)
21+
avg_error = sum(err_percent)/length(err_percent)
22+
23+
@show max_error
24+
@show avg_error
25+
plot(x[2:(end-1)], err_percent, title="Percentage Error, n=$n aor = $aor, dor = $dor")
26+
27+
#test result
28+
end

0 commit comments

Comments
 (0)