static void Main() { var x = new Variable("x"); var y = new Variable("y"); Console.WriteLine("f(x,y) = (x + y) * Sin(x / 2)"); var expr = (x + y) * new Sin(x / 2); Console.WriteLine("f(5, 3) = {0:F3}", expr.Compute(new Dictionary <string, double> { ["x"] = 5, ["y"] = 3 })); Console.WriteLine("f(pi/6, 7) = {0:F3}", expr.Compute(new Dictionary <string, double> { ["x"] = PI / 6, ["y"] = 7 })); expr = new Pow(new Tan(x / 2), 2 / 3) + new Cot(x / 2) * (1 / 3) / y; Console.WriteLine("f(0,3) = {0:F3}", expr.Compute(new Dictionary <string, double> { ["x"] = 0, ["y"] = 3 })); Console.WriteLine("f(7pi/3, 6) = {0:F3}", expr.Compute(new Dictionary <string, double> { ["x"] = PI / 3, ["y"] = 6 })); Console.ReadKey(); }
public void IsConstantPow() { Constant const1 = 1; var const2 = 2.0; var res = new Pow(const1, const2); Assert.AreEqual(true, res.IsConstant); }
public void IsPolynom_Pow() { var var1 = new Variable("x"); var const1 = 4.0; var res = new Pow(var1, const1).IsPolynom; Assert.AreEqual(true, res); }
public void PowIsPolynom2nonPol() { var const1 = new Arcsin("x"); var const2 = 2.0; var res = new Pow(const1, const2).IsPolynom; Assert.AreEqual(false, res); }
public void PowIsPolynomPolPowerConst() { var const1 = new Variable("x"); var const2 = 1.0; var res = new Pow(const1, const2).IsPolynom; Assert.AreEqual(true, res); }
public void PowIsPolynom2Const() { var const1 = new Constant(1); var const2 = 1.0; var res = new Pow(const1, const2).IsPolynom; Assert.AreEqual(true, res); }
public void Power2ConstantsTest() { var const1 = new Constant(4); var const2 = 2.0; var res = new Pow(const1, const2); Assert.AreEqual(16, res.Compute(null)); }
public void PowerVariableConstantTest() { var var1 = new Variable("x"); var var2 = 2.0; var res = new Pow(var1, var2); Assert.AreEqual(16, res.Compute(new Dictionary <string, double>() { ["x"] = 4 })); }