Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numerical error too high #21

Open
AndresCenteno opened this issue Mar 22, 2024 · 4 comments
Open

Numerical error too high #21

AndresCenteno opened this issue Mar 22, 2024 · 4 comments

Comments

@AndresCenteno
Copy link

I'm doing the most simple Caputo derivative
$$^C_0 D_t^\alpha t = \frac{t^{1-\alpha}}{\Gamma(2-\alpha)}$$
and I get a relative error of $0.024$ for a time step of $10^{-9}$, is this supposed to be working properly?

using FractionalCalculus
using SpecialFunctions: gamma

T = 0.6; α = 0.9; Δt = 1e-9
numerical_caputo_der = fracdiff(t->t,α,0,T,Δt,CaputoDirect())[1]
theoretical_caputo_der = T^(1-α)/gamma(2-α)
abs(numerical_caputo_der-theoretical_caputo_der)/abs(theoretical_caputo_der) # 0.0239
@ErikQQY ErikQQY transferred this issue from SciFracX/FractionalDiffEq.jl Mar 22, 2024
@ErikQQY
Copy link
Member

ErikQQY commented Mar 22, 2024

What is the version of package you are using for the computing? I just tested on master branch:
Numerical:

julia> numerical_caputo_der = fracdiff(t->t,α,T,0.001,CaputoDiethelm())
0.9987906107845391

Analytical:

theoretical_caputo_der = T^(1-α)/gamma(2-α)
0.9987906107845398

Error:

julia> abs(numerical_caputo_der-theoretical_caputo_der)/abs(theoretical_caputo_der)
6.669404053086289e-16

@ErikQQY
Copy link
Member

ErikQQY commented Mar 22, 2024

Also, using such a small step size is bad

@AndresCenteno
Copy link
Author

FractionalCalculus v0.2.10
I tried with a bunch of stepsizes! But the CaputoDiethelm works for me, so... it's ok now
I saw in the docs that you use CaputoTrap() for example, but it throws me an error saying it is not defined

@ErikQQY
Copy link
Member

ErikQQY commented Mar 23, 2024

Just tagged a new major release, which should fix the "not defined" errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants