Home Explore Blog CI



rustc

src/autodiff/internals.md
cca1fed16fa391cb9b19ec33a6ba65f1a7a59265ecbd7cb300000003000004b5
The `std::autodiff` module in Rust allows differentiable programming:

```rust
#![feature(autodiff)]
use std::autodiff::autodiff;

// f(x) = x * x, f'(x) = 2.0 * x
// bar therefore returns (x * x, 2.0 * x)
#[autodiff(bar, Reverse, Active, Active)]
fn foo(x: f32) -> f32 { x * x }

fn main() {
    assert_eq!(bar(3.0, 1.0), (9.0, 6.0));
    assert_eq!(bar(4.0, 1.0), (16.0, 8.0));
}
```

The detailed documentation for the `std::autodiff` module is available at [std::autodiff](https://doc.rust-lang.org/std/autodiff/index.html).

Differentiable programing is used in various fields like numerical computing, [solid mechanics][ratel], [computational chemistry][molpipx], [fluid dynamics][waterlily] or for Neural Network training via Backpropagation, [ODE solver][diffsol], [differentiable rendering][libigl], [quantum computing][catalyst], and climate simulations.


Chunks
952a495a (1st chunk of `src/autodiff/internals.md`)
Title: Introduction to Differentiable Programming in Rust with `std::autodiff`
Summary
This section introduces the `std::autodiff` module in Rust for differentiable programming. It provides an example of how to use the `autodiff` macro to automatically compute derivatives of a function. It also lists various fields where differentiable programming is applied, such as numerical computing, solid mechanics, computational chemistry, fluid dynamics, neural network training, ODE solvers, differentiable rendering, quantum computing, and climate simulations.