mathnet/mathnet-symbolics

Errors parsing and evaluating complex-valued string

King-Taz opened this issue · 0 comments

Greetings, beginner here, I need to learn how to parse and evaluate a complex-valued expression to its real and imaginary parts, but getting 2 errors, (Error CS1061 'SymbolicExpression' does not contain a definition for 'RealPart' and no accessible extension method 'RealPart' accepting a first argument of type 'SymbolicExpression' could be found (are you missing a using directive or an assembly reference?)). Couldn't find documentation for class references or unit tests to assist me. Can you point me to documentation with complex examples, or tell me how to fix these errors?

    using MathNet.Numerics;
    using MathNet.Numerics.LinearAlgebra;
    using MathNet.Symbolics;

    string complexString = "3 + 2i + 1/3i - 7";
    SymbolicExpression expression = SymbolicExpression.Parse(complexString);

    // Extract real and complex parts
    SymbolicExpression realPart = expression.RealPart();
    SymbolicExpression complexPart = expression.ComplexPart();

    Console.WriteLine("Real Part: " + realPart);
    Console.WriteLine("Complex Part: " + complexPart);