當前位置: 首頁>>代碼示例>>C#>>正文


C# Expressions.Variable類代碼示例

本文整理匯總了C#中xFunc.Maths.Expressions.Variable的典型用法代碼示例。如果您正苦於以下問題:C# Variable類的具體用法?C# Variable怎麽用?C# Variable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Variable類屬於xFunc.Maths.Expressions命名空間,在下文中一共展示了Variable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DerivativeTest3

        public void DerivativeTest3()
        {
            // x ^ 3
            Variable x = new Variable("x");
            Number num1 = new Number(3);

            IExpression exp = new Pow(x, num1);
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("1 * (3 * (x ^ (3 - 1)))", deriv.ToString());

            num1.Value = 4;
            Assert.AreEqual("x ^ 4", exp.ToString());
            Assert.AreEqual("1 * (3 * (x ^ (3 - 1)))", deriv.ToString());

            // 2 ^ (3x)
            Number num2 = new Number(2);
            num1 = new Number(3);
            Mul mul = new Mul(num1, x.Clone());

            exp = new Pow(num2, mul);
            deriv = exp.Differentiate();

            Assert.AreEqual("(ln(2) * (2 ^ (3 * x))) * (3 * 1)", deriv.ToString());

            num1.Value = 4;
            Assert.AreEqual("2 ^ (4 * x)", exp.ToString());
            Assert.AreEqual("(ln(2) * (2 ^ (3 * x))) * (3 * 1)", deriv.ToString());
        }
開發者ID:ronnycsharp,項目名稱:xFunc,代碼行數:29,代碼來源:ExponentiationTest.cs

示例2: AddDiffNum_VarSubNum_

        public void AddDiffNum_VarSubNum_()
        {
            // 2 + (x - 2)
            var add = new Add(new Number(2), new Sub(new Variable("x"), new Number(2)));
            var expected = new Variable("x");

            SimpleTest(add, expected);
        }
開發者ID:sys27,項目名稱:xFunc,代碼行數:8,代碼來源:SimplifierTest.cs

示例3: DefiniteIntegral

        public DefiniteIntegral(
			IExpression expression, 
			Variable variable, 
			IExpression left, 
			IExpression right)
            : base(new[] { expression, variable, left, right }, 4)
        {
        }
開發者ID:ronnycsharp,項目名稱:xFunc,代碼行數:8,代碼來源:DefiniteIntegral.cs

示例4: AbsDerivativeTest2

        public void AbsDerivativeTest2()
        {
            var num = new Number(2);
            var x = new Variable("x");
            var mul = new Mul(num, x);

            var exp = new Abs(mul);
            var deriv = Differentiate(exp);

            Assert.Equal("2 * 1 * ((2 * x) / abs(2 * x))", deriv.ToString());

            num.Value = 3;
            Assert.Equal("abs(3 * x)", exp.ToString());
            Assert.Equal("2 * 1 * ((2 * x) / abs(2 * x))", deriv.ToString());
        }
開發者ID:sys27,項目名稱:xFunc,代碼行數:15,代碼來源:DifferentiatorTest.cs

示例5: DerivativeTest2

        public void DerivativeTest2()
        {
            // log(x, 2)
            Number num = new Number(2);
            Variable x = new Variable("x");

            IExpression exp = new Log(x, num);
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("1 / (x * ln(2))", deriv.ToString());

            num.Value = 4;
            Assert.AreEqual("log(4, x)", exp.ToString());
            Assert.AreEqual("1 / (x * ln(2))", deriv.ToString());
        }
開發者ID:ronnycsharp,項目名稱:xFunc,代碼行數:15,代碼來源:LogTest.cs

示例6: AbsDerivativeTest2

        public void AbsDerivativeTest2()
        {
            Number num = new Number(2);
            Variable x = new Variable("x");
            Mul mul = new Mul(num, x);

            IExpression exp = new Abs(mul);
            IExpression deriv = Differentiate(exp);

            Assert.AreEqual("(2 * 1) * ((2 * x) / abs(2 * x))", deriv.ToString());

            num.Value = 3;
            Assert.AreEqual("abs(3 * x)", exp.ToString());
            Assert.AreEqual("(2 * 1) * ((2 * x) / abs(2 * x))", deriv.ToString());
        }
開發者ID:ronnycsharp,項目名稱:xFunc,代碼行數:15,代碼來源:DifferentiatorTest.cs

示例7: DerivativeTest3

        public void DerivativeTest3()
        {
            Number num = new Number(2);
            Variable x = new Variable("x");
            Mul mul = new Mul(num, x);

            IExpression exp = new Tan(mul);
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("(2 * 1) / (cos(2 * x) ^ 2)", deriv.ToString());

            num.Value = 5;
            Assert.AreEqual("tan(5 * x)", exp.ToString());
            Assert.AreEqual("(2 * 1) / (cos(2 * x) ^ 2)", deriv.ToString());
        }
開發者ID:ronnycsharp,項目名稱:xFunc,代碼行數:15,代碼來源:TangentTest.cs

示例8: DerivativeTest2

        public void DerivativeTest2()
        {
            // lg(2x)
            Number num = new Number(2);
            Variable x = new Variable("x");
            Mul mul = new Mul(num, x);

            IExpression exp = new Lg(mul);
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("(2 * 1) / ((2 * x) * ln(10))", deriv.ToString());

            num.Value = 3;
            Assert.AreEqual("lg(3 * x)", exp.ToString());
            Assert.AreEqual("(2 * 1) / ((2 * x) * ln(10))", deriv.ToString());
        }
開發者ID:ronnycsharp,項目名稱:xFunc,代碼行數:16,代碼來源:LgTest.cs

示例9: DerivativeTest3

        public void DerivativeTest3()
        {
            // cot(2x)
            Number num = new Number(2);
            Variable x = new Variable("x");
            Mul mul = new Mul(num, x);

            IExpression exp = new Cot(mul);
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("-((2 * 1) / (sin(2 * x) ^ 2))", deriv.ToString());

            num.Value = 3;
            Assert.AreEqual("cot(3 * x)", exp.ToString());
            Assert.AreEqual("-((2 * 1) / (sin(2 * x) ^ 2))", deriv.ToString());
        }
開發者ID:ronnycsharp,項目名稱:xFunc,代碼行數:16,代碼來源:CotangentTest.cs

示例10: DerivativeTest2

        public void DerivativeTest2()
        {
            // arcsec(2x)
            Number num = new Number(2);
            Variable x = new Variable("x");
            Mul mul = new Mul(num, x);

            IExpression exp = new Arcsec(mul);
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("(2 * 1) / (abs(2 * x) * sqrt(((2 * x) ^ 2) - 1))", deriv.ToString());

            num.Value = 4;
            Assert.AreEqual("arcsec(4 * x)", exp.ToString());
            Assert.AreEqual("(2 * 1) / (abs(2 * x) * sqrt(((2 * x) ^ 2) - 1))", deriv.ToString());
        }
開發者ID:ronnycsharp,項目名稱:xFunc,代碼行數:16,代碼來源:ArcsecTest.cs

示例11: DerivativeTest3

        public void DerivativeTest3()
        {
            // exp(2x)
            Number num = new Number(2);
            Variable x = new Variable("x");
            Mul mul = new Mul(num, x);

            IExpression exp = new Exp(mul);
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("(2 * 1) * exp(2 * x)", deriv.ToString());

            num.Value = 6;
            Assert.AreEqual("exp(6 * x)", exp.ToString());
            Assert.AreEqual("(2 * 1) * exp(2 * x)", deriv.ToString());
        }
開發者ID:ronnycsharp,項目名稱:xFunc,代碼行數:16,代碼來源:ExponentialTest.cs

示例12: DerivativeTest3

        public void DerivativeTest3()
        {
            // arccos(2x)
            Number num = new Number(2);
            Variable x = new Variable("x");
            Mul mul = new Mul(num, x);

            IExpression exp = new Arccos(mul);
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("-((2 * 1) / sqrt(1 - ((2 * x) ^ 2)))", deriv.ToString());

            num.Value = 6;
            Assert.AreEqual("arccos(6 * x)", exp.ToString());
            Assert.AreEqual("-((2 * 1) / sqrt(1 - ((2 * x) ^ 2)))", deriv.ToString());
        }
開發者ID:ronnycsharp,項目名稱:xFunc,代碼行數:16,代碼來源:ArccosTest.cs

示例13: DerivativeTest2

        public void DerivativeTest2()
        {
            Number num1 = new Number(2);
            Variable x = new Variable("x");
            Mul mul1 = new Mul(num1, x);

            Number num2 = new Number(3);
            Mul mul2 = new Mul(num2, x.Clone());

            IExpression exp = new Sub(mul1, mul2);
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("(2 * 1) - (3 * 1)", deriv.ToString());

            num1.Value = 5;
            num2.Value = 4;
            Assert.AreEqual("(5 * x) - (4 * x)", exp.ToString());
            Assert.AreEqual("(2 * 1) - (3 * 1)", deriv.ToString());
        }
開發者ID:ronnycsharp,項目名稱:xFunc,代碼行數:19,代碼來源:SubtractionTest.cs

示例14: DerivativeTest3

        public void DerivativeTest3()
        {
            // (2x) / (3x)
            Number num1 = new Number(2);
            Variable x = new Variable("x");
            Mul mul1 = new Mul(num1, x);

            Number num2 = new Number(3);
            Mul mul2 = new Mul(num2, x.Clone());

            IExpression exp = new Div(mul1, mul2);
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("(((2 * 1) * (3 * x)) - ((2 * x) * (3 * 1))) / ((3 * x) ^ 2)", deriv.ToString());

            num1.Value = 4;
            num2.Value = 5;
            Assert.AreEqual("(4 * x) / (5 * x)", exp.ToString());
            Assert.AreEqual("(((2 * 1) * (3 * x)) - ((2 * x) * (3 * 1))) / ((3 * x) ^ 2)", deriv.ToString());
        }
開發者ID:ronnycsharp,項目名稱:xFunc,代碼行數:20,代碼來源:DivisionTest.cs

示例15: MulSecondOne

        public void MulSecondOne()
        {
            var mul = new Mul(new Variable("x"), new Number(1));
            var expected = new Variable("x");

            SimpleTest(mul, expected);
        }
開發者ID:sys27,項目名稱:xFunc,代碼行數:7,代碼來源:SimplifierTest.cs


注:本文中的xFunc.Maths.Expressions.Variable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。