Last active
July 31, 2018 21:43
-
-
Save stephen-lazaro/73c30c866515261c8e73e19e49372bd6 to your computer and use it in GitHub Desktop.
Automatic differentiation in one dimension using the Dual numbers of the ring of doubles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object differentials { | |
import spire.implicits._ | |
import spire.math._ | |
import spire.algebra._ | |
implicit val duals = JetDim(1) | |
def auto_diff (f: Jet [Double] => Jet [Double]) = (x: Double) => f ( Jet (x, 0) ) | |
def df (f: Jet[Double] => Jet[Double]) = (x: Double) => auto_diff (f) (x) ._2 (0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment