patrick-kidger / patrick-kidger/diffrax

What is the best way to integrate a function?

Open
#361 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
2.1k
Forks
189
Avg merge
3d 18h
Merged PRs (30d)
1

Description

Let say I have a function $h(t)$ that I can evaluate in any $t$ and I want to calculate $$\int_0^1 h(t) dt.$$

Would diffrax used like that be a good idea?

def h(t):
    return t**2


dx.diffeqsolve(
    dx.ODETerm(lambda t, _y, _args: h(t)),
    dx.Tsit5(),
    0.0,
    1.0,
    dt0=None,
    y0=0.0,
    stepsize_controller=dx.PIDController(rtol=0.0, atol=1e-3),
).ys.squeeze(0)

Contributor guide

Open the contributing guide

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 with the dx.diffeqsolve and dx.ODETerm entry points shown in the issue, then review the existing Diffrax documentation and examples for integrating scalar functions. The issue is resolved when the recommended approach, including any limitations or alternatives, is documented or answered clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.