本文整理汇总了C#中xFunc.Maths.Expressions.Variable.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Variable.Clone方法的具体用法?C# Variable.Clone怎么用?C# Variable.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xFunc.Maths.Expressions.Variable
的用法示例。
在下文中一共展示了Variable.Clone方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例2: 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());
}
示例3: 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());
}
示例4: DivDerivativeTest3
public void DivDerivativeTest3()
{
// (2x) / (3x)
var num1 = new Number(2);
var x = new Variable("x");
var mul1 = new Mul(num1, x);
var num2 = new Number(3);
var mul2 = new Mul(num2, x.Clone());
var exp = new Div(mul1, mul2);
var deriv = Differentiate(exp);
Assert.Equal("((2 * 1 * 3 * x) - (2 * x * 3 * 1)) / ((3 * x) ^ 2)", deriv.ToString());
num1.Value = 4;
num2.Value = 5;
Assert.Equal("(4 * x) / (5 * x)", exp.ToString());
Assert.Equal("((2 * 1 * 3 * x) - (2 * x * 3 * 1)) / ((3 * x) ^ 2)", deriv.ToString());
}
示例5: SubDerivativeTest2
public void SubDerivativeTest2()
{
var num1 = new Number(2);
var x = new Variable("x");
var mul1 = new Mul(num1, x);
var num2 = new Number(3);
var mul2 = new Mul(num2, x.Clone());
var exp = new Sub(mul1, mul2);
var deriv = Differentiate(exp);
Assert.Equal("(2 * 1) - (3 * 1)", deriv.ToString());
num1.Value = 5;
num2.Value = 4;
Assert.Equal("(5 * x) - (4 * x)", exp.ToString());
Assert.Equal("(2 * 1) - (3 * 1)", deriv.ToString());
}
示例6: PowDerivativeTest3
public void PowDerivativeTest3()
{
// x ^ 3
var x = new Variable("x");
var num1 = new Number(3);
var exp = new Pow(x, num1);
var deriv = Differentiate(exp);
Assert.Equal("1 * 3 * (x ^ (3 - 1))", deriv.ToString());
num1.Value = 4;
Assert.Equal("x ^ 4", exp.ToString());
Assert.Equal("1 * 3 * (x ^ (3 - 1))", deriv.ToString());
// 2 ^ (3x)
var num2 = new Number(2);
num1 = new Number(3);
var mul = new Mul(num1, x.Clone());
exp = new Pow(num2, mul);
deriv = Differentiate(exp);
Assert.Equal("ln(2) * (2 ^ (3 * x)) * 3 * 1", deriv.ToString());
num1.Value = 4;
Assert.Equal("2 ^ (4 * x)", exp.ToString());
Assert.Equal("ln(2) * (2 ^ (3 * x)) * 3 * 1", deriv.ToString());
}
示例7: Variable
/// <summary>
/// Differentiates the specified expression.
/// </summary>
/// <param name="expression">The expression.</param>
/// <param name="variable">The variable.</param>
/// <returns>Returns the derivative.</returns>
protected virtual IExpression Variable(Variable expression, Variable variable)
{
if (expression.Equals(variable))
return new Number(1);
return expression.Clone();
}