(Hyper) Dual Numbers for automatic differentiation (CAS)
|
02-13-2024, 07:18 AM
(This post was last modified: 02-13-2024 07:39 AM by Thomas Klemm.)
Post: #3
|
|||
|
|||
RE: (Hyper) Dual Numbers for automatic differentiation (CAS)
This is an implementation for the HP-42S: Automatic differentiation using dual numbers.
I used complex number as representation, so we get addition, subtraction and scalar multiplication for free. But you could use the following matrix representation instead: \( \begin{bmatrix} u & {u}' \\ 0 & u \\ \end{bmatrix} \) With this you get also multiplication and division for free: \( \begin{bmatrix} u & {u}' \\ 0 & u \\ \end{bmatrix} \cdot \begin{bmatrix} v & {v}' \\ 0 & v \\ \end{bmatrix} = \begin{bmatrix} uv & u{v}'+{u}'v \\ 0 & uv \\ \end{bmatrix} \) \( \begin{bmatrix} u & {u}' \\ 0 & u \\ \end{bmatrix} \cdot \begin{bmatrix} v & {v}' \\ 0 & v \\ \end{bmatrix}^{-1} = \begin{bmatrix} \frac{u}{v} & \frac{{u}'v - u{v}'}{v^2} \\ 0 & \frac{u}{v} \\ \end{bmatrix} \) In case of function application it really depends on how it is implemented. The result should implement the chain-rule: \( f \left( \begin{bmatrix} u & {u}' \\ 0 & u \\ \end{bmatrix} \right) = \begin{bmatrix} f(u) & {f}'(u){u}' \\ 0 & f(u) \\ \end{bmatrix} \) Example Code: from sympy import Matrix \( \begin{bmatrix} 1679 & 2030 \\ 0 & 1679 \end{bmatrix} \) But here we use the same \(\varepsilon = \varepsilon_{1} = \varepsilon_{2}\). So it might not be exactly what you want. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(Hyper) Dual Numbers for automatic differentiation (CAS) - mcasl - 02-13-2024, 12:05 AM
RE: (Hyper) Dual Numbers for automatic differentiation (CAS) - Albert Chan - 02-13-2024, 03:51 AM
RE: (Hyper) Dual Numbers for automatic differentiation (CAS) - Thomas Klemm - 02-13-2024 07:18 AM
RE: (Hyper) Dual Numbers for automatic differentiation (CAS) - mcasl - 02-13-2024, 08:57 AM
RE: (Hyper) Dual Numbers for automatic differentiation (CAS) - KeithB - 02-13-2024, 02:22 PM
RE: (Hyper) Dual Numbers for automatic differentiation (CAS) - Thomas Klemm - 02-21-2024, 06:27 AM
|
User(s) browsing this thread: 1 Guest(s)