Skip to content

Commit c4c5156

Browse files
committed
Alphabetizing tests; upd comp test scr; bumping ver to 0.4.1
1 parent cdd820f commit c4c5156

15 files changed

+45
-57
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "FunctionIntegrator"
22
uuid = "7685536e-2581-4f83-bef1-2ba363c9cb91"
33
authors = ["Brenton Horne <[email protected]>"]
4-
version = "0.4.0"
4+
version = "0.4.1"
55

66
[deps]
77
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"

test/Computation_times_Travis_92.2.jl

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,22 @@
1-
# Taken from https://travis-ci.com/github/fusion809/FunctionIntegrator.jl/jobs/358878829
1+
# Taken from https://travis-ci.com/github/fusion809/FunctionIntegrator.jl/jobs/359262615
22
# 10th entry is simppen
3-
L_adaptive_simpsons = [0.153903;
4-
0.045990;
5-
0.000090;
6-
7-
L_chebyshev1=[1.493455; # AiryAi(x)
8-
0.291795; # besselj
9-
0.041686; # cos_cot
10-
0.104719; #
11-
0.116603;
12-
0.090129;
13-
0.088141;
14-
0.114219;
15-
0.162800;
16-
0.441775;
17-
0.102337;
18-
0.050055;
19-
0.048896];
20-
L_chebyshev2=[0.176496; 0.060008; 0.041355; 0.099813; 0.111966; 0.125740; 0.103428; 0.098729; 0.064575; 8.991385; 0.096214; 0.052295; 0.049748];
21-
L_chebyshev3 = [0.150834; 0.072039; 0.049798; 0.111535; 0.099392; 0.101607; 0.111045; 0.111373; 0.070177; 3.208550; 0.092763; 0.057960; 0.055562];
22-
L_chebyshev4 = [0.125087; 0.070966; 0.049619; 0.092735; 0.098091; 0.100671; 0.099425; 0.099531; 0.070195; 4.146543; 0.094798; 0.056763; 0.053876];
23-
L_jacobi = [20.655073; 0.741378; 0.079454; 0.468545; 0.220772; 2.786482; 0.531896; 0.446746; 0.479568; 22.058539; 0.242638; 1.933591; 0.694156];
24-
L_legendre=[0.122725; 0.076702; 0.030384; 0.071562; 0.078758; 0.078509; 0.088236; 0.090079; 0.043331; 4.383104; 0.059413; 0.036632; 0.033564];
25-
L_lobatto=[0.169799; 0.012460; 0.000103; 0.080504; 0.143451; 0.117507; 0.086438; 0.091315; 0.000142; 21.927058; 0.025977; 0.000409; 0.000141];
26-
L_radau = [0.151726; 0.012143; 0.000040; 0.094062; 0.129707; 0.104701; 0.086289; 0.087083; 0.000057; 22.282400; 0.025089; 0.000345; 0.000109];
27-
L_rectangle_midpoint = [0.073208; 0.000017; 0.000330; 0.019159; 0.022585; 0.030032; 0.018576; 0.021532; 0.000027; 1.863286; 0.035673; 0.000545; 0.000903];
28-
L_simpsons=[0.080275; 0.040657; 0.000012; 0.023218; 0.041971; 0.028887; 0.025965; 0.031452; 0.018607; 13.831230; 0.047495; 0.000064; 0.000078];
29-
L_simpsons38=[0.068510; ]
30-
L_trapezoidal=[0.149524; 0.034553; 0.000577; 0.017627; 0.032416; 0.022288; 0.019312; 0.023317; 0.013583; 13.361007; 0.077226; 0.001042; 0.001420];
31-
3+
L_adaptive_simpsons = [0.144420; 0.048034; 0.000163; 0.019791; 0.031644; 0.022732; 0.022157; 0.023056; 0.000081; 12.635982; 0.002164; 0.000840; 0.000220];
4+
L_chebyshev1 = [1.374153; 0.295273; 0.042028; 0.097700; 0.085278; 0.091216; 0.085430; 0.086918; 0.136373; 0.405410; 0.088461; 0.048735; 0.045503];
5+
L_chebyshev2 = [0.189887; 0.063260; 0.041871; 0.095741; 0.109335; 0.101715; 0.111041; 0.100269; 0.082595; 8.732129; 0.090618; 0.050086; 0.045789];
6+
L_chebyshev3 = [0.166648; 0.067508; 0.048010; 0.090679; 0.093410; 0.123339; 0.094715; 0.107830; 0.068438; 3.184987; 0.088439; 0.056318; 0.051559];
7+
L_chebyshev4 = [0.133982; 0.067320; 0.048107; 0.093402; 0.105892; 0.101815; 0.095580; 0.095526; 0.067627; 4.097529; 0.090069; 0.054310; 0.050882];
8+
L_jacobi = [20.730626; 0.696972; 0.074401; 0.472530; 0.214534; 2.607443; 0.521480; 0.440099; 0.493098; 21.869202; 0.162223; 1.875650; 0.579464];
9+
L_legendre = [0.104126; 0.075988; 0.029669; 0.069286; 0.074264; 0.075576; 0.072840; 0.071971; 0.043136; 4.255756; 0.058376; 0.034468; 0.030826];
10+
L_lobatto = [0.191745; 0.012332; 0.000122; 0.090188; 0.139901; 0.105984; 0.083651; 0.081196; 0.000138; 21.580829; 0.092406; 0.000301; 0.000141];
11+
L_radau = [0.140783; 0.012576; 0.000053; 0.079066; 0.108806; 0.111685; 0.096150; 0.081501; 0.000065; 21.579555; 0.023179; 0.000421; 0.000113];
12+
L_rectangle_midpoint = [0.074701; 0.000019; 0.000266; 0.018933; 0.020185; 0.018622; 0.018862; 0.018857; 0.000027; 1.564159; 0.029700; 0.000414; 0.000740];
13+
L_simpsons = [0.057260; 0.018206; 0.000013; 0.020936; 0.029926; 0.022812; 0.023652; 0.024098; 0.018203; 13.383746; 0.036649; 0.000066; 0.000052];
14+
L_simpsons38 = [0.056655; 0.040500; 0.000012; 0.023536; 0.031635; 0.026131; 0.024863; 0.025426; 0.017806; 14.101716; 0.040174; 0.000060; 0.000041];
15+
L_trapezoidal = [0.141598; 0.034595; 0.000494; 0.015096; 0.021626; 0.017495; 0.016807; 0.017933; 0.012839; 12.977622; 0.069035; 0.000937; 0.001293];
3216
N = length(L_simpsons);
3317

3418
# RMS of times
19+
rms_adaptive_simpsons_wo_simppen = sqrt((L_adaptive_simpsons[1:9]'*L_adaptive_simpsons[1:9]+L_adaptive_simpsons[11:N]'*L_adaptive_simpsons[11:N])/(N-1));
3520
rms_chebyshev1 = sqrt(L_chebyshev1'*L_chebyshev1/N);
3621
rms_chebyshev1_wo_simppen = sqrt((L_chebyshev1[1:9]'*L_chebyshev1[1:9]+L_chebyshev1[11:N]'*L_chebyshev1[11:N])/(N-1));
3722
rms_chebyshev2 = sqrt(L_chebyshev2'*L_chebyshev2/N);
@@ -49,6 +34,7 @@ rms_radau_wo_simppen = sqrt((L_radau[1:9]'*L_radau[1:9]+L_radau[11:N]'*L_radau[1
4934
rms_rectangle_midpoint = sqrt(L_rectangle_midpoint'*L_rectangle_midpoint/N);
5035
rms_rectangle_midpoint_wo_simppen = sqrt((L_rectangle_midpoint[1:9]'*L_rectangle_midpoint[1:9]+L_rectangle_midpoint[11:N]'*L_rectangle_midpoint[11:N])/(N-1));
5136
rms_simpsons_wo_simppen = sqrt((L_simpsons[1:9]'*L_simpsons[1:9]+L_simpsons[11:N]'*L_simpsons[11:N])/(N-1));
37+
rms_simpsons38_wo_simppen = sqrt((L_simpsons38[1:9]'*L_simpsons38[1:9]+L_simpsons38[11:N]'*L_simpsons38[11:N])/(N-1));
5238
rms_trapezoidal_wo_simppen = sqrt((L_trapezoidal[1:9]'*L_trapezoidal[1:9]+L_trapezoidal[11:N]'*L_trapezoidal[11:N])/(N-1));
5339

5440
rms_wo_simppen = [rms_chebyshev1_wo_simppen; rms_chebyshev2_wo_simppen; rms_chebyshev3_wo_simppen; rms_chebyshev4_wo_simppen; rms_jacobi_wo_simppen; rms_legendre_wo_simppen; rms_lobatto_wo_simppen; rms_radau_wo_simppen; rms_rectangle_midpoint_wo_simppen; rms_simpsons_wo_simppen; rms_trapezoidal_wo_simppen];
@@ -60,6 +46,7 @@ println("rms_chebyshev4 is $(rms_chebyshev4)")
6046
println("rms_jacobi is $(rms_jacobi)")
6147
println("rms_legendre is $(rms_legendre)")
6248

49+
println("rms_adaptive_simpsons_wo_simppen is $(rms_adaptive_simpsons_wo_simppen)")
6350
println("rms_chebyshev1_wo_simppen is $(rms_chebyshev1_wo_simppen)")
6451
println("rms_chebyshev2_wo_simppen is $(rms_chebyshev2_wo_simppen)")
6552
println("rms_chebyshev3_wo_simppen is $(rms_chebyshev3_wo_simppen)")
@@ -70,4 +57,5 @@ println("rms_lobatto_wo_simppen is $(rms_lobatto_wo_simppen)")
7057
println("rms_radau_wo_simppen is $(rms_radau_wo_simppen)")
7158
println("rms_rectangle_midpoint_wo_simppen is $(rms_rectangle_midpoint_wo_simppen)")
7259
println("rms_simpsons_wo_simppen is $(rms_simpsons_wo_simppen)")
60+
println("rms_simpsons38_wo_simppen is $(rms_simpsons38_wo_simppen)")
7361
println("rms_trapezoidal_wo_simppen is $(rms_trapezoidal_wo_simppen)")

test/airyai.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# AiryAi(x)
22
printstyled("Performing the Airy Ai(x) test, where Ai(x) is integrated on the semi-infinite domain, or an approximation of it, namely [0,100] and the result is compared to the analytical result 1/3.\n"; color = :red)
33
@testset "Airy Ai(x)" begin
4+
printstyled("Running: adaptive_simpsons_rule\n"; color = :magenta)
5+
@time @test adaptive_simpsons_rule(x -> airyai(x), 0, 100, 1e-8) 1.0/3.0
46
printstyled("Running: chebyshev_quadrature with k=1\n"; color = :magenta)
57
@time @test chebyshev_quadrature(x -> airyai(x), 38337, 1, 0, 100) 1.0/3.0
68
printstyled("Running: chebyshev_quadrature with k=2\n"; color = :magenta)
@@ -29,8 +31,6 @@ printstyled("Performing the Airy Ai(x) test, where Ai(x) is integrated on the se
2931
@time @test simpsons_rule(x -> airyai(x), 2512, 0, 100) 1.0/3.0
3032
printstyled("Running: simpsons38_rule\n"; color = :magenta)
3133
@time @test simpsons38_rule(x -> airyai(x), 3075, 0, 100) 1.0/3.0
32-
printstyled("Running: adaptive_simpsons_rule\n"; color = :magenta)
33-
@time @test adaptive_simpsons_rule(x -> airyai(x), 0, 100, 1e-8) 1.0/3.0
3434
printstyled("Running: trapezoidal_rule\n"; color = :magenta)
3535
@time @test trapezoidal_rule(x -> airyai(x), 208381, 0, 100) 1.0/3.0
3636
end

test/besselj.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ end
55

66
printstyled("Performing the besselj test, where BesselJ_1(2) is approximated and the result is compared to the value obtained from SpecialFunctions' besselj function.\n"; color = :red)
77
@testset "besselj" begin
8+
printstyled("Running: adaptive_simpsons_rule with ε=1e-7\n"; color = :magenta)
9+
@time @test adaptive_simpsons_rule(besselj_integrand, 0, pi/2, 1e-7) besselj(1,2)
810
printstyled("Running: chebyshev_quadrature with k=1\n"; color = :magenta)
911
@time @test chebyshev_quadrature(besselj_integrand, 4665, 1, 0, pi/2) besselj(1,2)
1012
printstyled("Running: chebyshev_quadrature with k=2\n"; color = :magenta)
@@ -31,8 +33,6 @@ printstyled("Performing the besselj test, where BesselJ_1(2) is approximated and
3133
@time @test simpsons_rule(besselj_integrand, 6, 0, pi/2) besselj(1,2)
3234
printstyled("Running: simpsons38_rule\n"; color = :magenta)
3335
@time @test simpsons38_rule(besselj_integrand, 9, 0, pi/2) besselj(1,2)
34-
printstyled("Running: adaptive_simpsons_rule with ε=1e-7\n"; color = :magenta)
35-
@time @test adaptive_simpsons_rule(besselj_integrand, 0, pi/2, 1e-7) besselj(1,2)
3636
printstyled("Running: trapezoidal_rule\n"; color = :magenta)
3737
@time @test trapezoidal_rule(besselj_integrand, 4, 0, pi/2) besselj(1,2)
3838
end

test/cos_cot_integral.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ end
77

88
printstyled("Integrating cos^2(x)/(1+cot(x)) from 0 to pi/2 and comparing the results to the analytical result 0.25.\n"; color = :red)
99
@testset "coscotint" begin
10+
printstyled("Running: adaptive_simpsons_rule with ε=1e-7\n"; color = :magenta)
11+
@time @test adaptive_simpsons_rule(cos_cot_fn, 0, pi/2, 1e-7) 0.25
1012
printstyled("Running: chebyshev_quadrature with k=1\n"; color = :magenta)
1113
@time @test chebyshev_quadrature(cos_cot_fn, 88, 1, 0, pi/2) 0.25
1214
printstyled("Running: chebyshev_quadrature with k=2\n"; color = :magenta)
@@ -33,8 +35,6 @@ printstyled("Integrating cos^2(x)/(1+cot(x)) from 0 to pi/2 and comparing the re
3335
@time @test simpsons_rule(cos_cot_fn, 78, 0, pi/2) 0.25
3436
printstyled("Running: simpsons38_rule\n"; color = :magenta)
3537
@time @test simpsons38_rule(cos_cot_fn, 96, 0, pi/2) 0.25
36-
printstyled("Running: adaptive_simpsons_rule with ε=1e-7\n"; color = :magenta)
37-
@time @test adaptive_simpsons_rule(cos_cot_fn, 0, pi/2, 1e-7) 0.25
3838
printstyled("Running: trapezoidal_rule\n"; color = :magenta)
3939
@time @test trapezoidal_rule(cos_cot_fn, 7430, 0, pi/2) 0.25
4040
end

test/cosine.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# cosine test
22
printstyled("Integrating cosine from 0 to pi/2 and comparing the result to the analytical result of 1.\n"; color = :red)
33
@testset "Cosine" begin
4+
printstyled("Running: adaptive_simpsons_rule\n"; color = :magenta)
5+
@time @test adaptive_simpsons_rule(x -> cos(x), 0, pi/2, 1e-7) 1
46
printstyled("Running: chebyshev_quadrature with k=1\n"; color = :magenta)
57
@time @test chebyshev_quadrature(x -> cos(x), 4656, 1, 0, pi/2) 1
68
printstyled("Running: chebyshev_quadrature with k=2\n"; color = :magenta)
@@ -27,8 +29,6 @@ printstyled("Integrating cosine from 0 to pi/2 and comparing the result to the a
2729
@time @test simpsons_rule(x -> cos(x), 40, 0, pi/2) 1
2830
printstyled("Running: simpsons38_rule\n"; color = :magenta)
2931
@time @test simpsons38_rule(x -> cos(x), 48, 0, pi/2) 1
30-
printstyled("Running: adaptive_simpsons_rule\n"; color = :magenta)
31-
@time @test adaptive_simpsons_rule(x -> cos(x), 0, pi/2, 1e-7) 1
3232
printstyled("Running: trapezoidal_rule\n"; color = :magenta)
3333
@time @test trapezoidal_rule(x -> cos(x), 3715, 0, pi/2) 1
3434
end

test/expnx2datan.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ sol_9 = exp(1)*pi*erfc(1);
33

44
printstyled("Integrating e^(-x^2)/(1+x^2) on the infinite domain [-inf, inf], or failing that on [-100,100], and comparing it to the analytical result exp(1)*pi*erfc(1)\n"; color = :red)
55
@testset "expnx2datan" begin
6+
printstyled("Running: adaptive_simpsons_rule with ε=1e-7\n"; color = :magenta)
7+
@time @test adaptive_simpsons_rule(x -> exp(-x^2)/(x^2+1), -100, 100, 1e-7) sol_9
68
printstyled("Running: chebyshev_quadrature with k=1\n"; color = :magenta)
79
@time @test chebyshev_quadrature(x -> exp(-x^2)/(x^2+1), 1029, 1, -100, 100) sol_9
810
printstyled("Running: chebyshev_quadrature with k=2\n"; color = :magenta)
@@ -33,8 +35,6 @@ printstyled("Integrating e^(-x^2)/(1+x^2) on the infinite domain [-inf, inf], or
3335
@time @test simpsons_rule(x -> exp(-x^2)/(x^2+1), 1240, -100, 100) sol_9
3436
printstyled("Running: simpsons38_rule\n"; color = :magenta)
3537
@time @test simpsons38_rule(x -> exp(-x^2)/(x^2+1), 1767, -100, 100) sol_9
36-
printstyled("Running: adaptive_simpsons_rule with ε=1e-7\n"; color = :magenta)
37-
@time @test adaptive_simpsons_rule(x -> exp(-x^2)/(x^2+1), -100, 100, 1e-7) sol_9
3838
printstyled("Running: trapezoidal_rule\n"; color = :magenta)
3939
@time @test trapezoidal_rule(x -> exp(-x^2)/(x^2+1), 655, -100, 100) sol_9
4040
end

test/gaussian.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Gaussian curve test
22
printstyled("Integrate exp(-x^2) from minus infinity to positive infinity and comparing the result to the analytical solution, sqrt(pi)\n"; color = :red)
33
@testset "Gaussian" begin
4+
printstyled("Running: adaptive_simpsons_rule with ε=1e-7\n"; color = :magenta)
5+
@time @test adaptive_simpsons_rule(x -> exp(-x^2), -100, 100, 1e-7) sqrt(pi)
46
printstyled("Running: chebyshev_quadrature with k=1\n"; color = :magenta)
57
@time @test chebyshev_quadrature(x -> exp(-x^2), 433, 1, -100, 100) sqrt(pi)
68
printstyled("Running: chebyshev_quadrature with k=2\n"; color = :magenta)
@@ -33,8 +35,6 @@ printstyled("Integrate exp(-x^2) from minus infinity to positive infinity and co
3335
@time @test simpsons_rule(x -> exp(-x^2), 536, -100, 100) sqrt(pi)
3436
printstyled("Running: simpsons38_rule\n"; color = :magenta)
3537
@time @test simpsons38_rule(x -> exp(-x^2), 780, -100, 100) sqrt(pi)
36-
printstyled("Running: adaptive_simpsons_rule with ε=1e-7\n"; color = :magenta)
37-
@time @test adaptive_simpsons_rule(x -> exp(-x^2), -100, 100, 1e-7) sqrt(pi)
3838
printstyled("Running: trapezoidal_rule\n"; color = :magenta)
3939
@time @test trapezoidal_rule(x -> exp(-x^2), 276, -100, 100) sqrt(pi)
4040
end

test/logarithm.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# logarithm test
22
printstyled("Integrating 1/x from 1 to e and comparing the result to the analytical solution, 1.\n"; color = :red)
33
@testset "1/x" begin
4+
printstyled("Running: adaptive_simpsons_rule with ε=1e-7\n"; color = :magenta)
5+
@time @test adaptive_simpsons_rule(x -> x^(-1), 1, exp(1), 1e-7) 1
46
printstyled("Running: chebyshev_quadrature with k=1\n"; color = :magenta)
57
@time @test chebyshev_quadrature(x -> x^(-1), 5695, 1, 1, exp(1)) 1
68
printstyled("Running: chebyshev_quadrature with k=2\n"; color = :magenta)
@@ -27,8 +29,6 @@ printstyled("Integrating 1/x from 1 to e and comparing the result to the analyti
2729
@time @test simpsons_rule(x -> x^(-1), 70, 1, exp(1)) 1
2830
printstyled("Running: simpsons38_rule\n"; color = :magenta)
2931
@time @test simpsons38_rule(x -> x^(-1), 84, 1, exp(1)) 1
30-
printstyled("Running: adaptive_simpsons_rule with ε=1e-7\n"; color = :magenta)
31-
@time @test adaptive_simpsons_rule(x -> x^(-1), 1, exp(1), 1e-7) 1
3232
printstyled("Running: trapezoidal_rule\n"; color = :magenta)
3333
@time @test trapezoidal_rule(x -> x^(-1), 3779, 1, exp(1)) 1
3434
end

test/logoverx.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
printstyled("Integrating log(x)/x from 1 to e and comparing the result to the analytical solution of 0.5.\n"; color = :red)
22
@testset "log(x)/x" begin
3+
printstyled("Running: adaptive_simpsons_rule with ε=1e-7\n"; color = :magenta)
4+
@time @test adaptive_simpsons_rule(x -> log(x)/x, 1, exp(1), 1e-8) 0.5
35
printstyled("Running: chebyshev_quadrature with k=1\n"; color = :magenta)
46
@time @test chebyshev_quadrature(x -> log(x)/x, 4177, 1, 1, exp(1)) 0.5
57
printstyled("Running: chebyshev_quadrature with k=2\n"; color = :magenta)
@@ -26,8 +28,6 @@ printstyled("Integrating log(x)/x from 1 to e and comparing the result to the an
2628
@time @test simpsons_rule(x -> log(x)/x, 100, 1, exp(1)) 0.5
2729
printstyled("Running: simpsons38_rule\n"; color = :magenta)
2830
@time @test simpsons38_rule(x -> log(x)/x, 114, 1, exp(1)) 0.5
29-
printstyled("Running: adaptive_simpsons_rule with ε=1e-7\n"; color = :magenta)
30-
@time @test adaptive_simpsons_rule(x -> log(x)/x, 1, exp(1), 1e-8) 0.5
3131
printstyled("Running: trapezoidal_rule\n"; color = :magenta)
3232
@time @test trapezoidal_rule(x -> log(x)/x, 5747, 1, exp(1)) 0.5
3333
end

0 commit comments

Comments
 (0)