jeudi 14 mars 2019

Using expressions to get derivative from lambda function

Imagine you have a lambda function on input like this

Function<double, double> f = x => x*x +2

And you want to calc a derivate in point x0. Signature of resulting method is gonna be:

Function<double, double> GetDerivative(Function<double, double> f)

So you get a new lambda using this method, and placing there x0 you get the result. The formula is

df(x0) = (f(x0 + eps) - f(x0)) /eps

How would you build an expression from input function?





Aucun commentaire:

Enregistrer un commentaire