I have seen the ad
package and i understand how it does automatic differentiation by providing a different instance of the class Floating
and then implementing the rules of derivatives.
But in the example
Prelude Debug.SimpleReflect Numeric.AD> diff atanh x
recip (1 - x * x) * 1
We see that it can represent functions as AST
s and show them as a string with variable names.
I wonder how they did that, because when i write:
f :: Floating a => a -> a
f x = x^2
No matter what instance I provide, i will get a function f :: Something -> Something
and not a representation like f :: AST
, or f :: String
The instance cannot "know" what the parameters are.
How they are able to do it ?
Aucun commentaire:
Enregistrer un commentaire