diff --git a/Project.toml b/Project.toml index fc3740d..eade314 100644 --- a/Project.toml +++ b/Project.toml @@ -16,6 +16,7 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" [compat] +ForwardDiff = "0.10.36" InvertedIndices = "1.3" QuadGK = "2.9" SpecialFunctions = "2.3" diff --git a/test/Derivative.jl b/test/Derivative.jl index 535e09a..417197c 100644 --- a/test/Derivative.jl +++ b/test/Derivative.jl @@ -6,15 +6,15 @@ half_derivative_of_x_square_minus_1_at_1 = 5/(3*sqrt(π)) half_derivative_of_exp_at_1 = ℯ*erf(1)+1/sqrt(π) @testset "Test Caputo Direct Fractional Derivative" begin - @test isapprox(fracdiff(x->x, 0.5, 0, 1, 1e-8, CaputoDirect())[1], 2/sqrt(pi); atol = 1e-5) - @test isapprox(fracdiff(x->x^5, 0.5, 0, 3.2, 1e-8, CaputoDirect())[1], 4.300306216488329e2; atol = 1e-5) - @test isapprox(fracdiff(x->x^5, 0.25, 0, 3.2, 1e-8, CaputoDirect())[1], 382.1228113951680; atol = 1e-5) - @test isapprox(fracdiff(x->(x-3)^3+(x+2)^2+5, 0.5, 0, 0.83, 1e-8, CaputoDirect())[1], 23.899930581118699; atol = 1e-5) - @test isapprox(fracdiff(x->(x-3)^3+(x+2)^2+5, 0.25, 0, 0.83, 1e-8, CaputoDirect())[1], 22.96354626572943; atol = 1e-5) - @test isapprox(fracdiff(x->cos(x), 0.5, 0, 0.34, 1e-8, CaputoDirect())[1], -0.147174774607683; atol = 1e-5) - @test isapprox(fracdiff(x->cos(x), 0.25, 0, 0.34, 1e-8, CaputoDirect())[1], -0.093074344902431; atol = 1e-5) - @test isapprox(fracdiff(x->exp(-x^2), 0.5, 0, 2.3, 1e-8, CaputoDirect())[1], -0.505891017154289; atol = 1e-5) - @test isapprox(fracdiff(x->exp(-x^2), 0.25, 0, 2.3, 1e-8, CaputoDirect())[1], -0.762927553656252; atol = 1e-5) + @test isapprox(fracdiff(x->x, 0.5, 0, 1, 1e-4, CaputoDirect())[1], 2/sqrt(pi); atol = 1e-5) + @test isapprox(fracdiff(x->x^5, 0.5, 0, 3.2, 1e-4, CaputoDirect())[1], 4.300306216488329e2; atol = 1e-5) + @test isapprox(fracdiff(x->x^5, 0.25, 0, 3.2, 1e-4, CaputoDirect())[1], 382.1228113951680; atol = 1e-5) + @test isapprox(fracdiff(x->(x-3)^3+(x+2)^2+5, 0.5, 0, 0.83, 1e-4, CaputoDirect())[1], 23.899930581118699; atol = 1e-5) + @test isapprox(fracdiff(x->(x-3)^3+(x+2)^2+5, 0.25, 0, 0.83, 1e-4, CaputoDirect())[1], 22.96354626572943; atol = 1e-5) + @test isapprox(fracdiff(x->cos(x), 0.5, 0, 0.34, 1e-4, CaputoDirect())[1], -0.147174774607683; atol = 1e-5) + @test isapprox(fracdiff(x->cos(x), 0.25, 0, 0.34, 1e-4, CaputoDirect())[1], -0.093074344902431; atol = 1e-5) + @test isapprox(fracdiff(x->exp(-x^2), 0.5, 0, 2.3, 1e-4, CaputoDirect())[1], -0.505891017154289; atol = 1e-5) + @test isapprox(fracdiff(x->exp(-x^2), 0.25, 0, 2.3, 1e-4, CaputoDirect())[1], -0.762927553656252; atol = 1e-5) @test isapprox(fracdiff(x->x, 0.5, 0, [1, 2, 3], 0.0001, CaputoDirect()), [2/sqrt(pi), 1.5957691216057408, 1.9544100476116828]; atol=1e-3) end diff --git a/test/Integral.jl b/test/Integral.jl index 374dd70..95aa6e9 100644 --- a/test/Integral.jl +++ b/test/Integral.jl @@ -2,12 +2,12 @@ using FractionalCalculus using Test @testset "Test Direct Fractional Integral" begin - @test isapprox(fracint(x->x^4, 0.5, 0, 1.23, 1e-8, RLDirect())[1], 1.163931646862977; atol = 0.00001) - @test isapprox(fracint(x->x^4, 0.25, 0, 1.23, 1e-8, RLDirect())[1], 1.64294134724409; atol = 0.00001) - @test isapprox(fracint(x->x^4, 0.15, 0, 1.23, 1e-8, RLDirect())[1], 1.878978485456182; atol = 0.00001) - @test isapprox(fracint(x->sin(x), 0.5, 0, 0.97, 1e-8, RLDirect())[1], 0.6442601778843754; atol = 0.00001) - @test isapprox(fracint(x->sin(x), 0.25, 0, 0.97, 1e-8, RLDirect())[1], 0.7448298999485293; atol = 0.00001) - @test isapprox(fracint(x->sin(x), 0.15, 0, 0.97, 1e-8, RLDirect())[1], 0.7802555196986999; atol = 0.00001) + @test isapprox(fracint(x->x^4, 0.5, 0, 1.23, 1e-4, RLDirect())[1], 1.163931646862977; atol = 0.00001) + @test isapprox(fracint(x->x^4, 0.25, 0, 1.23, 1e-4, RLDirect())[1], 1.64294134724409; atol = 0.00001) + @test isapprox(fracint(x->x^4, 0.15, 0, 1.23, 1e-4, RLDirect())[1], 1.878978485456182; atol = 0.00001) + @test isapprox(fracint(x->sin(x), 0.5, 0, 0.97, 1e-4, RLDirect())[1], 0.6442601778843754; atol = 0.00001) + @test isapprox(fracint(x->sin(x), 0.25, 0, 0.97, 1e-4, RLDirect())[1], 0.7448298999485293; atol = 0.00001) + @test isapprox(fracint(x->sin(x), 0.15, 0, 0.97, 1e-4, RLDirect())[1], 0.7802555196986999; atol = 0.00001) end @testset "Test Piecewise Fractional Integral" begin