public void DifferentiateMexicanHatTest() { var differentiator = new Differentiator(); var dx = differentiator.Differentiate("sin(sqrt(x^2+y^2))", "x", true); var res = differentiator.Differentiate(dx, "y", true); dx = differentiator.Differentiate("sin(sqrt(x^2+y^2))", "y", true); res = differentiator.Differentiate(dx, "x", true); }
void AssertSyntacticDerivativeEqualToNumericDerivative(Expression <Func <double, double> > func) { var f = func.Compile(); double eps = 1e-7; var dfExpression = Differentiator.Differentiate(func); var df = dfExpression.Compile(); for (double x = 0.5; x < 10; x += 0.5) { Assert.AreEqual((f(x + eps) - f(x - eps)) / (2 * eps), df(x), 1e-4); } }
public void DifferentiateXYTest() { var differentiator = new Differentiator(); var d = differentiator.Differentiate("x^2+y^2", "x", true); var res = differentiator.Differentiate(d, "y", true); d = differentiator.Differentiate("x^2+y^2", "y", true); res = differentiator.Differentiate(d, "x", true); d = differentiator.Differentiate("x^y", "x", true); // toto nezvladne t.j y*x^(y-1) podla y res = differentiator.Differentiate(d, "y", true); d = differentiator.Differentiate("x^y", "y", true); res = differentiator.Differentiate(d, "x", true); }