Skip to content

Compute coeffs using Rationals #65

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

Merged
merged 4 commits into from
Apr 6, 2020
Merged

Compute coeffs using Rationals #65

merged 4 commits into from
Apr 6, 2020

Conversation

oxinabox
Copy link
Member

@oxinabox oxinabox commented Mar 28, 2020

Fixed #64

Turns out this can make a difference.

This not only gets result on julia 1.4 up to the standard of julia 1.2,
but actually does much more than that, significantly improving out accuracy

With this PR. in julia 1.2 or 1.4 (identical):

julia> using FiniteDifferences

julia> k3 = FiniteDifferences.fdm(FiniteDifferences.central_fdm(9, 5), y->exp(y), 1.0, adapt=4)
2.7182817496168528

julia> abs(k3-exp(1))  # Should be 0
7.884219233034173e-8

julia> f(x) = @. 4x^3 + 3x^2 + 2x + 1
f (generic function with 1 method)

julia> FiniteDifferences.fdm(FiniteDifferences.central_fdm(9, 3), f, 1.0, adapt=4) - 24
5.538680625249981e-12

Without this PR. 1.4

julia> using FiniteDifferences

julia> k3 = FiniteDifferences.fdm(FiniteDifferences.central_fdm(9, 5), y->exp(y), 1.0, adapt=4)
2.7182663156747684

julia> abs(k3-exp(1))  # Should be 0
1.5512784276694447e-5

julia> f(x) = @. 4x^3 + 3x^2 + 2x + 1
f (generic function with 1 method)

julia> FiniteDifferences.fdm(FiniteDifferences.central_fdm(9, 3), f, 1.0, adapt=4) - 24
6.48253006829691e-10

Without this PR on 1.2

julia> using FiniteDifferences

julia> k3 = FiniteDifferences.fdm(FiniteDifferences.central_fdm(9, 5), y->exp(y), 1.0, adapt=4)
2.7182815825355453

julia> abs(k3-exp(1))  # Should be 0
2.459234997864712e-7

julia> f(x) = @. 4x^3 + 3x^2 + 2x + 1
f (generic function with 1 method)

julia> FiniteDifferences.fdm(FiniteDifferences.central_fdm(9, 3), f, 1.0, adapt=4) - 24
1.071143174158351e-11

I feel like this is going to increase our cost a fair bit.
So it would be really good to get #61 done, to avoid recomputing coeffs.

@willtebbutt
Copy link
Member

This looks like a fantastic improvement in accuracy -- I'm definitely in favour of doing this. Would definitely be good to prevent reverting by tying this down with a couple of unit tests. The above snippets would probably suffice.

@oxinabox
Copy link
Member Author

I think the improvements are only really big when using higher order and a high degree of adapt

@willtebbutt
Copy link
Member

I think the improvements are only really big when using higher order and a high degree of adapt

Oh okay. Would be good to see some numbers on this then, both benchmarking and accuracy.

@oxinabox
Copy link
Member Author

oxinabox commented Apr 4, 2020

tests have been added

Copy link
Member

@willtebbutt willtebbutt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo the typo! Thanks @oxinabox

@oxinabox oxinabox force-pushed the ox/accurate_coeffs branch from e7e4750 to 7eed57f Compare April 6, 2020 12:03
@oxinabox oxinabox merged commit c9cd542 into master Apr 6, 2020
This was referenced Apr 15, 2020
@oxinabox oxinabox deleted the ox/accurate_coeffs branch August 10, 2020 21:12
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

Successfully merging this pull request may close these issues.

Less accurate results on Julia 1.3.1 vs Julia 1.1.1
2 participants