JuliaDiff / JuliaDiff/FiniteDifferences.jl

Improve accuracy by using Twitter

Open
#120 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue
Dominant language
Julia
Stars
318
Forks
32
PR merge metrics
No merged PRs in 30d

Description

Ever approximate a derivative in code with:

h = 0.001
df(x) = (f(x + h) - f(x)) / h

It turns out that this has some pretty serious issues with values that can't be represented in binary. But this simple fix can correct that

temp = x + h
h = temp - x

-- https://twitter.com/willkurt/status/1330183861452541953?s=20

@wesselb suggested to insert it here:
https://github.com/JuliaDiff/FiniteDifferences.jl/blob/master/src/methods.jl#L270

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/methods.jl around line 270, the insertion point suggested in the issue. Compare how the finite-difference step is computed with the linked derivative example, then use the repository's existing test suite to check that the adjusted step improves accuracy without changing other cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.