static void Main(string[] args) { var ass = Expr.Parse("cos(2 / 5 * pi) + cos(4 / 5 * pi) - cos(6 / 5 * pi) - cos(8 / 5 * pi)"); Console.WriteLine(ass.TrigonometricContract()); Console.WriteLine(ass.TrigonometricExpand()); Console.WriteLine(ass.TrigonometricSimplify()); Console.WriteLine(ass.Evaluate(new Dictionary <string, FloatingPoint>())); Console.WriteLine(ass.RationalReduce()); }
public static double EvaluateExpression(string input) { if (input.Any(char.IsLetter)) { //there is a letter (variable) that has not been dealt with, so the expression will fail return(0.0); } else { //try this, might need to do .Compile("")(0); return(Expr.Parse(input).RealNumberValue); } }
static void Main(string[] args) { var x = Expr.Variable("x"); var a = Expr.Variable("a"); string poly = "5x^2+3x+5"; int start; int count; int end; int posOfx; //int counting; List <int> coeff = new List <int>(); end = poly.Length; start = 0; count = 0; posOfx = 0; //counting = 0; while ((start <= end) && (posOfx > -1)) { count = end - start; posOfx = poly.IndexOf('x', start, count); if (posOfx == -1) { break; } start = posOfx + 1; coeff.Add(posOfx); } Console.WriteLine(coeff[0]); foreach (int y in coeff) { Console.WriteLine(coeff[y]); } Console.ReadLine(); // menu(); }