Skip to content

Errors parsing and evaluating complex-valued string #104

@King-Taz

Description

@King-Taz

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); 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions