public static void TestSymbolism() { // Create some constants. ComputerAlgebra.Expression A = 2; ComputerAlgebra.Constant B = ComputerAlgebra.Constant.New(3); // Create some variables. ComputerAlgebra.Expression x = "x"; Variable y = Variable.New("y"); // Create basic expression with operator overloads. ComputerAlgebra.Expression f = A * x + B * y + 4; // This expression uses the implicit conversion from string to // Expression, which parses the string. ComputerAlgebra.Expression g = "5*x + C*y + 8"; // Create a system of equations from the above expressions. var system = new List <Equal>() { Equal.New(f, 0), Equal.New(g, 0), }; // We can now solve the system of equations for x and y. Since the // equations have a variable 'C', the solutions will not be // constants. List <Arrow> solutions = system.Solve(x, y); Debug.WriteLine("The solutions are:"); foreach (Arrow i in solutions) { Debug.WriteLine(i.ToString()); } }
protected override string VisitConstant(Constant C) { return(C.Value.ToString(NumberFormat, NumberFormatProvider)); }