Open dgxhubbard opened 5 years ago
Yes - but in Math.NET Symbolics, not in Numerics.
Example:
var expr = SymbolicExpression.Parse("3*x^2 + y");
// option: direct dynamic evaluation
var args = new Dictionary<string, FloatingPoint> { { "x", 1.5 }, { "y", 2.0 }};
FloatingPoint result1 = expr.Evaluate(args); // result1.RealValue == 8.75
// option: compile to .Net function
Func<double, double, double> compiled = expr.Compile("x", "y");
double result2 = compiled(1.5, 2.0); // 8.75
// collect variables in an expression:
expr.CollectVariables().Select(v => v.VariableName) // "x", "y"
@cdrnet still Math.NET doesn't have function to evaluate expression from string?
Does MathNet have a method that would take a formula
3x + y or 3 x * x + y
and create executable code for it?