From a9019e933a6d45cd98e7518af61243c84a47f610 Mon Sep 17 00:00:00 2001 From: Vedant Puri Date: Wed, 15 Nov 2023 14:11:34 -0500 Subject: [PATCH 1/2] Update how_it_works.md Adding code for forming nested duals in the docs so folks don't make the mistakes I made in https://github.com/JuliaDiff/ForwardDiff.jl/issues/671 --- docs/src/dev/how_it_works.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/src/dev/how_it_works.md b/docs/src/dev/how_it_works.md index fc923d2d..ca86b1a6 100644 --- a/docs/src/dev/how_it_works.md +++ b/docs/src/dev/how_it_works.md @@ -56,8 +56,9 @@ learn about [hyper-dual numbers](https://arc.aiaa.org/doi/abs/10.2514/6.2011-886 which extend dual numbers to higher orders by introducing extra ``\epsilon`` terms that can cross-multiply. ForwardDiff's `Dual` number implementation naturally supports hyper-dual numbers without additional code by allowing instances of the `Dual` type to nest within each -other. For example, a second-order hyper-dual number has the type `Dual{T,Dual{S,V,M},N}`, a -third-order hyper-dual number has the type `Dual{T,Dual{S,Dual{R,V,K},M},N}`, and so on. +other. For example, a second-order hyper-dual number has the type `Dual{T,Dual{S,V,M},N}`, +and can be formed as follows: `Dual(Dual(x, one(eltype(x))), one(eltype(x)))`. Athird-order +hyper-dual number has the type `Dual{T,Dual{S,Dual{R,V,K},M},N}`, and so on. ## ForwardDiff's API From ff943a81ffa2a7a39ffc3eeb24484ad041f5a9f8 Mon Sep 17 00:00:00 2001 From: Vedant Puri Date: Mon, 1 Jan 2024 17:12:05 +0530 Subject: [PATCH 2/2] Update docs/src/dev/how_it_works.md Co-authored-by: Yuto Horikawa --- docs/src/dev/how_it_works.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/dev/how_it_works.md b/docs/src/dev/how_it_works.md index ca86b1a6..93512405 100644 --- a/docs/src/dev/how_it_works.md +++ b/docs/src/dev/how_it_works.md @@ -57,7 +57,7 @@ which extend dual numbers to higher orders by introducing extra ``\epsilon`` ter cross-multiply. ForwardDiff's `Dual` number implementation naturally supports hyper-dual numbers without additional code by allowing instances of the `Dual` type to nest within each other. For example, a second-order hyper-dual number has the type `Dual{T,Dual{S,V,M},N}`, -and can be formed as follows: `Dual(Dual(x, one(eltype(x))), one(eltype(x)))`. Athird-order +and can be formed as follows: `Dual(Dual(x, one(eltype(x))), one(eltype(x)))`. A third-order hyper-dual number has the type `Dual{T,Dual{S,Dual{R,V,K},M},N}`, and so on. ## ForwardDiff's API