public override IBaseMathOperator Derivate() { if (IsConstant()) { return(new ConstantMathOperator(0)); } var topFirstMultiply = new MultiplyMathOperator(); topFirstMultiply.Instantiate(new [] { B, A.Derivate() }); var topSecondMultiply = new MultiplyMathOperator(); topSecondMultiply.Instantiate(new [] { A, B.Derivate() }); var topMin = new MinMathOperator(); topMin.Instantiate(new IBaseMathOperator[] { topFirstMultiply, topSecondMultiply }); var bottom = ExpotentialOperator.SetExpotentialOperator(B, 2); var divide = new DevideMathOperator(); divide.Instantiate(new IBaseMathOperator[] { topMin, bottom }); return(divide); }
public override IBaseMathOperator Derivate() { if (A is ConstantMathOperator && B is ConstantMathOperator) { return(new ConstantMathOperator(0)); } if (!(A is ConstantMathOperator || B is ConstantMathOperator)) { var left = new MultiplyMathOperator(); left.Instantiate(new [] { A.Derivate(), B }); var right = new MultiplyMathOperator(); right.Instantiate(new [] { B.Derivate(), A }); var add = new AddMathOperator(); add.Instantiate(new IBaseMathOperator[] { left, right }); return(add); } var ADir = A is ConstantMathOperator ? A : A.Derivate(); var BDir = B is ConstantMathOperator ? B : B.Derivate(); var multi = new MultiplyMathOperator(); multi.Instantiate(new [] { ADir, BDir }); return(multi); }
public override IBaseMathOperator Derivate() { var newThis = new ExpotentialOperator(); newThis.Instantiate(GetChilds()); if (IsConstant()) { return(new ConstantMathOperator(0)); } if (B is ConstantMathOperator) { var times = new MultiplyMathOperator(); var constant = new ConstantMathOperator(B.Result()); var expo = new ExpotentialOperator(); expo.Instantiate(new [] { A, new ConstantMathOperator(B.Result() - 1) }); times.Instantiate(new IBaseMathOperator[] { constant, expo }); return(times); } var log = new LogMathOperator(); log.Instantiate(new[] { A }); if (A is ConstantMathOperator) { //chain rule var leftTimes = new MultiplyMathOperator(); leftTimes.Instantiate(new[] { A, B.Derivate() }); var expo2 = new ExpotentialOperator(); expo2.Instantiate(new[] { leftTimes, B }); //end.. var multi = new MultiplyMathOperator(); multi.Instantiate(new IBaseMathOperator[] { expo2, log }); return(multi); } var rightMulti = new MultiplyMathOperator(); rightMulti.Instantiate(new [] { log, B }); var result = new MultiplyMathOperator(); result.Instantiate(new [] { newThis, rightMulti.Derivate() }); return(result); }
public static ExpotentialOperator SetExpotentialOperator(IBaseMathOperator A, float number) { var expo = new ExpotentialOperator(); if (A is ExpotentialOperator) { var times = new MultiplyMathOperator(); times.Instantiate(new IBaseMathOperator[] { A.GetChilds()[1], new ConstantMathOperator(number), }); expo.Instantiate(new IBaseMathOperator[] { A.GetChilds()[0], times }); return(expo); } expo.Instantiate(new IBaseMathOperator[] { A, new ConstantMathOperator(number) }); return(expo); }
public override IBaseMathOperator Derivate() { if (IsConstant()) { return(new ConstantMathOperator(0)); } var cos = new CosMathOperator(); cos.Instantiate(new [] { A }); var result = new MultiplyMathOperator(); result.Instantiate(new [] { A.Derivate(), cos }); return(result); }
public override IBaseMathOperator Derivate() { if (IsConstant()) { return(new ConstantMathOperator(0)); } var newThis = new ExpotentialEOperator(); newThis.Instantiate(GetChilds()); var rightMulti = new MultiplyMathOperator(); rightMulti.Instantiate(new [] { A.Derivate(), newThis }); return(rightMulti); }
public override IBaseMathOperator Derivate() { if (IsConstant()) { return(new ConstantMathOperator(0)); } var sin = new SinMathOperator(); sin.Instantiate(new [] { A }); var multiply = new MultiplyMathOperator(); multiply.Instantiate(new IBaseMathOperator[] { new ConstantMathOperator(-1), sin }); var result = new MultiplyMathOperator(); result.Instantiate(new [] { A.Derivate(), multiply }); return(result); }