Skip to content

Commit 86eef81

Browse files
committed
+midpoint and right rectangle rule functions
1 parent 2d3e966 commit 86eef81

16 files changed

+125
-31
lines changed

Project.toml

+1-1
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.2.1"
4+
version = "0.3.0"
55

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

src/FunctionIntegrator.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module FunctionIntegrator
22

33
using FastGaussQuadrature
44

5-
export chebyshev_quadrature, hermite_quadrature, jacobi_quadrature, laguerre_quadrature, legendre_quadrature, lobatto_quadrature, radau_quadrature, rectangle_rule, simpsons_rule, trapezoidal_rule
5+
export chebyshev_quadrature, hermite_quadrature, jacobi_quadrature, laguerre_quadrature, legendre_quadrature, lobatto_quadrature, radau_quadrature, rectangle_rule_left, rectangle_rule_midpoint, rectangle_rule_right, simpsons_rule, trapezoidal_rule
66

77
include("Chebyshev.jl")
88
include("Hermite.jl")

src/Rectangle.jl

+45-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""
2-
rectangle_rule(f::Function, N::Number, a::Number, b::Number)
2+
rectangle_rule_left(f::Function, N::Number, a::Number, b::Number)
33
44
numerically approximates:
55
66
``\\displaystyle\\int_a^b f(x) dx``
77
8-
using the [rectangle rule](https://en.wikipedia.org/wiki/Riemann_sum#Left_Riemann_sum) with ``N`` gridpoint values. Whilst the type mentioned in the function definition for ``N`` is just 'Number' (as opposed to 'Integer'), this is just so that scientific notation can be used to define it (as scientific notation gives the type 'Float64'); an error message will be printed if it is not a positive integer.
8+
using the [left rectangle rule](https://en.wikipedia.org/wiki/Riemann_sum#Left_Riemann_sum) with ``N`` gridpoint values. Whilst the type mentioned in the function definition for ``N`` is just 'Number' (as opposed to 'Integer'), this is just so that scientific notation can be used to define it (as scientific notation gives the type 'Float64'); an error message will be printed if it is not a positive integer.
99
"""
10-
function rectangle_rule(f::Function, N::Number, a::Number, b::Number)
10+
function rectangle_rule_left(f::Function, N::Number, a::Number, b::Number)
1111
N = convert(Int64, N);
1212
h = (b-a)/N;
1313
y = 0;
@@ -18,3 +18,45 @@ function rectangle_rule(f::Function, N::Number, a::Number, b::Number)
1818
end
1919
return y
2020
end
21+
22+
"""
23+
rectangle_rule_midpoint(f::Function, N::Number, a::Number, b::Number)
24+
25+
numerically approximates:
26+
27+
``\\displaystyle\\int_a^b f(x) dx``
28+
29+
using the [midpoint rectangle rule](https://en.wikipedia.org/wiki/Riemann_sum#Midpoint_rule) with ``N`` gridpoint values. Whilst the type mentioned in the function definition for ``N`` is just 'Number' (as opposed to 'Integer'), this is just so that scientific notation can be used to define it (as scientific notation gives the type 'Float64'); an error message will be printed if it is not a positive integer.
30+
"""
31+
function rectangle_rule_midpoint(f::Function, N::Number, a::Number, b::Number)
32+
N = convert(Int64, N);
33+
h = (b-a)/N;
34+
y = 0;
35+
x = a+h/2;
36+
for i=1:N
37+
y += h*f(x)
38+
x = x + h;
39+
end
40+
return y
41+
end
42+
43+
"""
44+
rectangle_rule_right(f::Function, N::Number, a::Number, b::Number)
45+
46+
numerically approximates:
47+
48+
``\\displaystyle\\int_a^b f(x) dx``
49+
50+
using the [right rectangle rule](https://en.wikipedia.org/wiki/Riemann_sum#Right_Riemann_sum) with ``N`` gridpoint values. Whilst the type mentioned in the function definition for ``N`` is just 'Number' (as opposed to 'Integer'), this is just so that scientific notation can be used to define it (as scientific notation gives the type 'Float64'); an error message will be printed if it is not a positive integer.
51+
"""
52+
function rectangle_rule_right(f::Function, N::Number, a::Number, b::Number)
53+
N = convert(Int64, N);
54+
h = (b-a)/N;
55+
y = 0;
56+
x = a+h;
57+
for i=1:N
58+
y += h*f(x)
59+
x = x + h;
60+
end
61+
return y
62+
end

test/airyai.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ printstyled("Performing the Airy Ai(x) test, where Ai(x) is integrated on the se
1919
@time @test lobatto_quadrature(x -> airyai(x), 37, 0, 100) 1.0/3.0
2020
printstyled("Running: radau_quadrature\n"; color = :magenta)
2121
@time @test radau_quadrature(x -> airyai(x), 37, 0, 100) 1.0/3.0
22-
printstyled("Running: rectangle_rule. Only a rough approximation can be practically achieved using this function.\n"; color = :magenta)
23-
@time @test abs(rectangle_rule(x -> airyai(x), 1e8, 0, 100) - 1.0/3.0) < 1e-6
22+
printstyled("Running: rectangle_rule_left. Only a rough approximation can be practically achieved using this function.\n"; color = :magenta)
23+
@time @test abs(rectangle_rule_left(x -> airyai(x), 1e8, 0, 100) - 1.0/3.0) < 1.775106856505283e-7
24+
printstyled("Running: rectangle_rule_midpoint.\n"; color = :magenta)
25+
@time @test rectangle_rule_midpoint(x -> airyai(x), 147348, 0, 100) 1.0/3.0
26+
printstyled("Running: rectangle_rule_right. Only a rough approximation can be practically achieved using this function.\n"; color = :magenta)
27+
@time @test abs(rectangle_rule_right(x -> airyai(x), 1e8, 0, 100) - 1.0/3.0) < 1.775176824944687e-7
2428
printstyled("Running: simpsons_rule\n"; color = :magenta)
2529
@time @test simpsons_rule(x -> airyai(x), 2511, 0, 100) 1.0/3.0
2630
printstyled("Running: trapezoidal_rule\n"; color = :magenta)

test/besselj.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ printstyled("Performing the besselj test, where BesselJ_1(2) is approximated and
2121
@time @test lobatto_quadrature(besselj_integrand, 9, 0, pi/2) besselj(1,2)
2222
printstyled("Running: radau_quadrature\n"; color = :magenta)
2323
@time @test radau_quadrature(besselj_integrand, 8, 0, pi/2) besselj(1,2)
24-
printstyled("Running: rectangle_rule\n"; color = :magenta)
25-
@time @test rectangle_rule(besselj_integrand, 52378763, 0, pi/2) besselj(1,2)
24+
printstyled("Running: rectangle_rule_left\n"; color = :magenta)
25+
@time @test rectangle_rule_left(besselj_integrand, 52378763, 0, pi/2) besselj(1,2)
26+
printstyled("Running: rectangle_rule_midpoint\n"; color = :magenta)
27+
@time @test rectangle_rule_midpoint(besselj_integrand, 4, 0, pi/2) besselj(1,2)
28+
printstyled("Running: rectangle_rule_right\n"; color = :magenta)
29+
@time @test rectangle_rule_right(besselj_integrand, 52995612, 0, pi/2) besselj(1,2)
2630
printstyled("Running: simpsons_rule\n"; color = :magenta)
2731
@time @test simpsons_rule(besselj_integrand, 6, 0, pi/2) besselj(1,2)
2832
printstyled("Running: trapezoidal_rule\n"; color = :magenta)

test/cos_cot_integral.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ printstyled("Integrating cos^2(x)/(1+cot(x)) from 0 to pi/2 and comparing the re
2323
@time @test lobatto_quadrature(cos_cot_fn, 7, 0, pi/2) 0.25
2424
printstyled("Running: radau_quadrature\n"; color = :magenta)
2525
@time @test radau_quadrature(cos_cot_fn, 8, 0, pi/2) 0.25
26-
printstyled("Running: rectangle_rule\n"; color = :magenta)
27-
@time @test rectangle_rule(cos_cot_fn, 7430, 0, pi/2) 0.25
26+
printstyled("Running: rectangle_rule_left\n"; color = :magenta)
27+
@time @test rectangle_rule_left(cos_cot_fn, 7430, 0, pi/2) 0.25
28+
printstyled("Running: rectangle_rule_midpoint\n"; color = :magenta)
29+
@time @test rectangle_rule_midpoint(cos_cot_fn, 5254, 0, pi/2) 0.25
30+
printstyled("Running: rectangle_rule_right\n"; color = :magenta)
31+
@time @test rectangle_rule_right(cos_cot_fn, 7430, 0, pi/2) 0.25
2832
printstyled("Running: simpsons_rule\n"; color = :magenta)
2933
@time @test simpsons_rule(cos_cot_fn, 78, 0, pi/2) 0.25
3034
printstyled("Running: trapezoidal_rule\n"; color = :magenta)

test/cosine.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ printstyled("Integrating cosine from 0 to pi/2 and comparing the result to the a
1717
@time @test lobatto_quadrature(x -> cos.(x), 6, 0, pi/2) 1
1818
printstyled("Running: radau_quadrature\n"; color = :magenta)
1919
@time @test radau_quadrature(x -> cos.(x), 5, 0, pi/2) 1
20-
printstyled("Running: rectangle_rule\n"; color = :magenta)
21-
@time @test rectangle_rule(x -> cos.(x), 5.23705e7, 0, pi/2) 1
20+
printstyled("Running: rectangle_rule_left\n"; color = :magenta)
21+
@time @test rectangle_rule_left(x -> cos.(x), 5.23705e7, 0, pi/2) 1
22+
printstyled("Running: rectangle_rule_midpoint\n"; color = :magenta)
23+
@time @test rectangle_rule_midpoint(x -> cos.(x), 2627, 0, pi/2) 1
24+
printstyled("Running: rectangle_rule_right\n"; color = :magenta)
25+
@time @test rectangle_rule_right(x -> cos.(x), 5.2441522e7, 0, pi/2) 1
2226
printstyled("Running: simpsons_rule\n"; color = :magenta)
2327
@time @test simpsons_rule(x -> cos.(x), 40, 0, pi/2) 1
2428
printstyled("Running: trapezoidal_rule\n"; color = :magenta)

test/expnx2datan.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ printstyled("Integrating e^(-x^2)/(1+x^2) on the infinite domain [-inf, inf], or
2323
@time @test lobatto_quadrature(x -> exp.(-x.^2).*(x.^2+1).^(-1), 1029, -100, 100) sol_9
2424
printstyled("Running: radau_quadrature\n"; color = :magenta)
2525
@time @test radau_quadrature(x -> exp.(-x.^2).*(x.^2+1).^(-1), 669, -100, 100) sol_9
26-
printstyled("Running: rectangle_rule\n"; color = :magenta)
27-
@time @test rectangle_rule(x -> exp.(-x.^2).*(x.^2+1).^(-1), 655, -100, 100) sol_9
26+
printstyled("Running: rectangle_rule_left\n"; color = :magenta)
27+
@time @test rectangle_rule_left(x -> exp.(-x.^2).*(x.^2+1).^(-1), 655, -100, 100) sol_9
28+
printstyled("Running: rectangle_rule_midpoint\n"; color = :magenta)
29+
@time @test rectangle_rule_midpoint(x -> exp.(-x.^2).*(x.^2+1).^(-1), 655, -100, 100) sol_9
30+
printstyled("Running: rectangle_rule_right\n"; color = :magenta)
31+
@time @test rectangle_rule_right(x -> exp.(-x.^2).*(x.^2+1).^(-1), 655, -100, 100) sol_9
2832
printstyled("Running: simpsons_rule\n"; color = :magenta)
2933
@time @test simpsons_rule(x -> exp.(-x.^2).*(x.^2+1).^(-1), 1233, -100, 100) sol_9
3034
printstyled("Running: trapezoidal_rule\n"; color = :magenta)

test/gaussian.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ printstyled("Integrate exp(-x^2) from minus infinity to positive infinity and co
2323
@time @test lobatto_quadrature(x -> exp.(-x.^2), 434, -100, 100) sqrt(pi)
2424
printstyled("Running: radau_quadrature\n"; color = :magenta)
2525
@time @test radau_quadrature(x -> exp.(-x.^2), 349, -100, 100) sqrt(pi)
26-
printstyled("Running: rectangle_rule\n"; color = :magenta)
27-
@time @test rectangle_rule(x -> exp.(-x.^2), 276, -100, 100) sqrt(pi)
26+
printstyled("Running: rectangle_rule_left\n"; color = :magenta)
27+
@time @test rectangle_rule_left(x -> exp.(-x.^2), 276, -100, 100) sqrt(pi)
28+
printstyled("Running: rectangle_rule_midpoint\n"; color = :magenta)
29+
@time @test rectangle_rule_midpoint(x -> exp.(-x.^2), 276, -100, 100) sqrt(pi)
30+
printstyled("Running: rectangle_rule_right\n"; color = :magenta)
31+
@time @test rectangle_rule_right(x -> exp.(-x.^2), 276, -100, 100) sqrt(pi)
2832
printstyled("Running: simpsons_rule\n"; color = :magenta)
2933
@time @test simpsons_rule(x -> exp.(-x.^2), 533, -100, 100) sqrt(pi)
3034
printstyled("Running: trapezoidal_rule\n"; color = :magenta)

test/logarithm.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ printstyled("Integrating 1/x from 1 to e and comparing the result to the analyti
1717
@time @test lobatto_quadrature(x -> x.^(-1), 8, 1, exp(1)) 1
1818
printstyled("Running: radau_quadrature\n"; color = :magenta)
1919
@time @test radau_quadrature(x -> x.^(-1), 8, 1, exp(1)) 1
20-
printstyled("Running: rectangle_rule\n"; color = :magenta)
21-
@time @test rectangle_rule(x -> x.^(-1), 7.74699e7, 1, exp(1)) 1
20+
printstyled("Running: rectangle_rule_left\n"; color = :magenta)
21+
@time @test rectangle_rule_left(x -> x.^(-1), 7.74699e7, 1, exp(1)) 1
22+
printstyled("Running: rectangle_rule_midpoint\n"; color = :magenta)
23+
@time @test rectangle_rule_midpoint(x -> x.^(-1), 2672, 1, exp(1)) 1
24+
printstyled("Running: rectangle_rule_right\n"; color = :magenta)
25+
@time @test rectangle_rule_right(x -> x.^(-1), 3.6607201e7, 1, exp(1)) 1
2226
printstyled("Running: simpsons_rule\n"; color = :magenta)
2327
@time @test simpsons_rule(x -> x.^(-1), 70, 1, exp(1)) 1
2428
printstyled("Running: trapezoidal_rule\n"; color = :magenta)

test/logoverx.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ printstyled("Integrating log(x)/x from 1 to e and comparing the result to the an
1616
@time @test lobatto_quadrature(x -> log.(x).*x.^(-1), 9, 1, exp(1)) 0.5
1717
printstyled("Running: radau_quadrature\n"; color = :magenta)
1818
@time @test radau_quadrature(x -> log.(x).*x.^(-1), 8, 1, exp(1)) 0.5
19-
printstyled("Running: rectangle_rule\n"; color = :magenta)
20-
@time @test rectangle_rule(x -> log.(x).*x.^(-1), 4.3800001e7, 1, exp(1)) 0.5
19+
printstyled("Running: rectangle_rule_left\n"; color = :magenta)
20+
@time @test rectangle_rule_left(x -> log.(x).*x.^(-1), 4.3800001e7, 1, exp(1)) 0.5
21+
printstyled("Running: rectangle_rule_midpoint\n"; color = :magenta)
22+
@time @test rectangle_rule_midpoint(x -> log.(x).*x.^(-1), 4064, 1, exp(1)) 0.5
23+
printstyled("Running: rectangle_rule_right\n"; color = :magenta)
24+
@time @test rectangle_rule_right(x -> log.(x).*x.^(-1), 4.372011e7, 1, exp(1)) 0.5
2125
printstyled("Running: simpsons_rule\n"; color = :magenta)
2226
@time @test simpsons_rule(x -> log.(x).*x.^(-1), 100, 1, exp(1)) 0.5
2327
printstyled("Running: trapezoidal_rule\n"; color = :magenta)

test/modbessel0.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ printstyled("Approximating the modified bessel function I_1(1) and comparing it
2525
@time @test lobatto_quadrature(dmodified_bessel_1, 8, 0, pi/2) besseli(x,1)
2626
printstyled("Running: radau_quadrature\n"; color = :magenta)
2727
@time @test radau_quadrature(dmodified_bessel_1, 8, 0, pi/2) besseli(x,1)
28-
printstyled("Running: rectangle_rule\n"; color = :magenta)
29-
@time @test rectangle_rule(dmodified_bessel_1, 58999999, 0, pi/2) besseli(x,1)
28+
printstyled("Running: rectangle_rule_left\n"; color = :magenta)
29+
@time @test rectangle_rule_left(dmodified_bessel_1, 58999999, 0, pi/2) besseli(x,1)
30+
printstyled("Running: rectangle_rule_midpoint\n"; color = :magenta)
31+
@time @test rectangle_rule_midpoint(dmodified_bessel_1, 3, 0, pi/2) besseli(x,1)
32+
printstyled("Running: rectangle_rule_right\n"; color = :magenta)
33+
@time @test rectangle_rule_right(dmodified_bessel_1, 59275151, 0, pi/2) besseli(x,1)
3034
printstyled("Running: simpsons_rule\n"; color = :magenta)
3135
@time @test simpsons_rule(dmodified_bessel_1, 6, 0, pi/2) besseli(x,1)
3236
printstyled("Running: trapezoidal_rule\n"; color = :magenta)

test/simppen.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ printstyled("Integrating 1/sqrt(-19.6 sin(x)) from -pi to 0 and comparing the re
1919
@time @test abs(lobatto_quadrature(x -> (-19.6*sin.(x)).^(-0.5), 1e6, -pi+1e-6, -1e-6) - ellipk(1/2)/sqrt(2.45)) < 1e-3
2020
printstyled("Running: radau_quadrature on [-pi+1e-6, -1e-6]. Only a rough approximation can be realistically achieved with this function, partly due to the singularities.\n"; color = :magenta)
2121
@time @test abs(radau_quadrature(x -> (-19.6*sin.(x)).^(-0.5), 1e6, -pi+1e-6, -1e-6) - ellipk(1/2)/sqrt(2.45)) < 1e-3
22-
printstyled("Running: rectangle_rule on [-pi+1e-8, -1e-8]. Only a rough approximation can be realistically achieved with this function, partly due to the singularities.\n"; color = :magenta)
23-
@time @test abs(rectangle_rule(x -> (-19.6*sin.(x)).^(-0.5), 1e8, -pi+1e-8, -1e-8) - ellipk(1/2)/sqrt(2.45)) < 1e-4
22+
printstyled("Running: rectangle_rule_left on [-pi+1e-8, -1e-8]. Only a rough approximation can be realistically achieved with this function, partly due to the singularities.\n"; color = :magenta)
23+
@time @test abs(rectangle_rule_left(x -> (-19.6*sin.(x)).^(-0.5), 1e8, -pi+1e-8, -1e-8) - ellipk(1/2)/sqrt(2.45)) < 1e-4
24+
printstyled("Running: rectangle_rule_midpoint on [-pi+1e-8, -1e-8]. Only a rough approximation can be realistically achieved with this function, partly due to the singularities.\n"; color = :magenta)
25+
@time @test abs(rectangle_rule_midpoint(x -> (-19.6*sin.(x)).^(-0.5), 1e8, -pi+1e-8, -1e-8) - ellipk(1/2)/sqrt(2.45)) < 1.01e-4
26+
printstyled("Running: rectangle_rule_right on [-pi+1e-8, -1e-8]. Only a rough approximation can be realistically achieved with this function, partly due to the singularities.\n"; color = :magenta)
27+
@time @test abs(rectangle_rule_right(x -> (-19.6*sin.(x)).^(-0.5), 1e8, -pi+1e-8, -1e-8) - ellipk(1/2)/sqrt(2.45)) < 8.649e-5
2428
printstyled("Running: simpsons_rule on [-pi+1e-8, -1e-8]. Only a rough approximation can be realistically achieved with this function, partly due to the singularities.\n"; color = :magenta)
2529
@time @test abs(simpsons_rule(x -> (-19.6*sin.(x)).^(-0.5), 1e8, -pi+1e-8, -1e-8) - ellipk(1/2)/sqrt(2.45)) < 1e-4
2630
printstyled("Running: trapezoidal_rule on [-pi+1e-8, -1e-8]. Only a rough approximation can be realistically achieved with this function, partly due to the singularities.\n"; color = :magenta)

test/sinexpox.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ printstyled("Integrating sin(x^2)e^(-x)/x from 0 to infinity, with the approxima
2929
@time @test lobatto_quadrature(sinexpox, 598, 0, 100) sol_11
3030
printstyled("Running: radau_quadrature\n"; color = :magenta)
3131
@time @test radau_quadrature(sinexpox, 498, 0, 100) sol_11
32-
printstyled("Running: rectangle_rule\n"; color = :magenta)
33-
@time @test rectangle_rule(sinexpox, 394538, 0, 100) sol_11
32+
printstyled("Running: rectangle_rule_left\n"; color = :magenta)
33+
@time @test rectangle_rule_left(sinexpox, 394538, 0, 100) sol_11
34+
printstyled("Running: rectangle_rule_midpoint\n"; color = :magenta)
35+
@time @test rectangle_rule_midpoint(sinexpox, 278981, 0, 100) sol_11
36+
printstyled("Running: rectangle_rule_right\n"; color = :magenta)
37+
@time @test rectangle_rule_right(sinexpox, 394538, 0, 100) sol_11
3438
printstyled("Running: simpsons_rule\n"; color = :magenta)
3539
@time @test simpsons_rule(sinexpox, 4201, 0, 100) sol_11
3640
printstyled("Running: trapezoidal_rule\n"; color = :magenta)

test/sinxx.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ printstyled("Integrating sin(x)/x from 0 to 100 and comparing it to the exact re
2323
@time @test lobatto_quadrature(sinxx, 38, 0, 100) sol_8
2424
printstyled("Running: radau_quadrature\n"; color = :magenta)
2525
@time @test radau_quadrature(sinxx, 38, 0, 100) sol_8
26-
printstyled("Running: rectangle_rule\n"; color = :magenta)
27-
@time @test abs(rectangle_rule(sinxx, 1e8, 0, 100) - sol_8) < 1e-6
26+
printstyled("Running: rectangle_rule_left; only a rough approximation can be practically achieved using this function\n"; color = :magenta)
27+
@time @test abs(rectangle_rule_left(sinxx, 1e8, 0, 100) - sol_8) < 5.036e-7
28+
printstyled("Running: rectangle_rule_midpoint\n"; color = :magenta)
29+
@time @test rectangle_rule_midpoint(sinxx, 12461, 0, 100) sol_8
30+
printstyled("Running: rectangle_rule_right; only a rough approximation can be practically achieved using this function\n"; color = :magenta)
31+
@time @test abs(rectangle_rule_right(sinxx, 1e8, 0, 100) - sol_8) < 5.015e-7
2832
printstyled("Running: simpsons_rule\n"; color = :magenta)
2933
@time @test simpsons_rule(sinxx, 678, 0, 100) sol_8
3034
printstyled("Running: trapezoidal_rule\n"; color = :magenta)

test/test_7.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ printstyled("Integrating (x^3+1)/(x^4 (x+1)(x^2+1)) from 1 to e and comparing th
2222
@time @test lobatto_quadrature(partfrac, 11, 1, exp(1)) sol_7
2323
printstyled("Running: radau_quadrature\n"; color = :magenta)
2424
@time @test radau_quadrature(partfrac, 10, 1, exp(1)) sol_7
25-
printstyled("Running: rectangle_rule; only a rough approximation can be practically achieved using this function.\n"; color = :magenta)
26-
@time @test abs(rectangle_rule(partfrac, 1e8, 1, exp(1)) - sol_7) < 1e-8
25+
printstyled("Running: rectangle_rule_left; only a rough approximation can be practically achieved using this function.\n"; color = :magenta)
26+
@time @test abs(rectangle_rule_left(partfrac, 1e8, 1, exp(1)) - sol_7) < 1e-8
27+
printstyled("Running: rectangle_rule_midpoint\n"; color = :magenta)
28+
@time @test rectangle_rule_midpoint(partfrac, 9887, 1, exp(1)) sol_7
29+
printstyled("Running: rectangle_rule_right; only a rough approximation can be practically achieved using this function.\n"; color = :magenta)
30+
@time @test abs(rectangle_rule_right(partfrac, 1e8, 1, exp(1)) - sol_7) < 1e-8
2731
printstyled("Running: simpsons_rule\n"; color = :magenta)
2832
@time @test simpsons_rule(partfrac, 200, 1, exp(1)) sol_7
2933
printstyled("Running: trapezoidal_rule\n"; color = :magenta)

0 commit comments

Comments
 (0)