-
Notifications
You must be signed in to change notification settings - Fork 21
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
Problems with Romberg and Simpson integration #31
Comments
Thank you for the report. The Simpson issue you're having has been resolved for a while, but the version that has the fixes hasn't yet been upstreamed into JuliaRegistry (that's being dealt with in an adjacent issue). Running your example on the master branch yields:
The Romberg integration still has an accuracy issue, but it should reliably output warnings on the edge cases where it cannot reach the expected accuracy due to the algorithm used. This is a compromise between performance and accuracy, since historically this package was basically written to get the fastest performance possible. In the past few days Romberg.jl also got a new implementation that might be able to compete on performance as well (also described in a fellow issue here), so I might just add that as a fallback dependency to cover these edge cases as well. For the moment your options are either running the master branch ( |
Hi @dextorious ,
|
|
Dear developer, hi to everybody! I am new to Julia, I am physicist and I am trying to understand if it makes sense to use julia for my next scientific projects. I was trying to perform some numerical integration and I found your package, so I decided to make some simple tests.
k = 2^4
x = LinRange(0, π, k+1)
y = sin.(x)
println(integrate(x, y, Trapezoidal()))
println(integrate(x, y, SimpsonEven()))
println(integrate(x, y, RombergEven()))
obtaining
1.9935703437723393
2.222549924725271
2.000005549979671
In order to be sure I am doing things correctly, I decided to cross-check the results performing the same calculation in Python
k = 2**4
x = np.linspace(0, np.pi, k+1)
y = np.sin(x)
print(np.trapz(y,x))
print(integrate.simps(y,x))
print(integrate.romb(y=y, dx=x[1]-x[0], show=False))
obtaining
1.9935703437723393
2.0000165910479355
1.9999999945872902
As you can see, the trapz integrations looks fine but there are huge discrepancies in the Simpson and Romberg results. I looked into your issues and I found this Romber.jl, so I decided to use it finding
println(romberg(x, y))
(1.9999999945872906, 5.555392379896773e-6)
This result is almost the same of the scipy simpson method!
Furthermore, I found that if try
k = 2^5
x = LinRange(0, π, k+1)
y = sin.(x)
println(integrate(x, y, RombergEven()))
I obtain
1.9999999945872906
Which is exactly the result of Romberg.jl and scipy! it looks that the result of
RombergEven
with 2^(k+1)+1 points is the same ofscipy
andromberg
with 2^k+1 points.Am I using your package in the wrong way or there is something else?
Thank you for your time!
The text was updated successfully, but these errors were encountered: