stan-dev / stan-dev/math

Use finite-differences where forward-mode not implementable

Open
#2,842 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
839
Forks
220
Avg merge
2d 4h
Merged PRs (30d)
14

Description

Description

As discussed over in #2839, the ODE methods are not fvar<T> compatible, and it would be a significant amount of work to do so. This means that any downstream methods depending on fvar<> or higher-order autodiff will fail to compile, a current example of this is the new $hessian() method in cmdstanr.

In these instances it would be great to have a method that "works", even if it's slow - better to have in a limited form than to not have at all (imo).

Boost Math has existing optimised routines for finite-differencing, including the use of the complex step approximation for any complex-compatible functions (allowing for estimating the derivative with a single function evaluation)

Current Version:

v4.4.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 by reviewing the ODE compatibility discussion in #2839 and Boost Math's finite-difference and complex-step documentation. Identify which ODE methods need a fallback for higher-order autodiff, then verify that a downstream use such as cmdstanr's $hessian() works where forward mode is unavailable.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.