mathnet/mathnet-symbolics

How to use variables in algebra problems using a string?

troelschristensen opened this issue · 2 comments

Hi again.

Really love this package. Now I can solve equations and simplify algebra. This is great.

I'm coding in Visual Basic.

I would like to create an algebra problem, where a string is saying eg "2*a+a+a" and the question is, what it is if "a=2"!? Can anyone help me with this?

Str="2*a+a+a"

Kind regards.

Imports MathNet.Symbolics
Imports expr = MathNet.Symbolics.SymbolicExpression
Module Program
    Sub Main(args As String())
        Dim e1 = expr.Parse("2*a+a+a")
        Dim dict As New Dictionary(Of String, FloatingPoint)
        dict.Add("a", 2)
        Console.WriteLine(e1.Evaluate(dict)) 'Real 8
    End Sub
End Module

Thank you, @FoggyFinder. Again it worked.👌💪 Really helpfull.👌

Sent with GitHawk