// Derivative rule public override Function Derivative() { if (RightFunc is Constant) { return(RightFunc * (LeftFunc ^ (RightFunc - new Constant(1))) * LeftFunc.Derivative()); } return((RightFunc.Derivative() * Funcs.Ln(LeftFunc) + LeftFunc.Derivative() * RightFunc / LeftFunc) * this); }
public override Function GetDerivativeAnalytically() { Multiply multiply = new Multiply(); multiply.LeftFunc = LeftFunc.GetDerivativeAnalytically(); multiply.RightFunc = this; return(multiply); }
public override Function GetDerivativeAnalytically() { Multiply der = new Multiply(); der.LeftFunc = LeftFunc.GetDerivativeAnalytically(); der.RightFunc = new Substract(); der.RightFunc.RightFunc = new S(); der.RightFunc.RightFunc.LeftFunc = this.LeftFunc; return(der); }
public override Function SimplifyFunction() { if (this.LeftFunc is Digit && (this.LeftFunc as Digit).Data == 0) { return(this.LeftFunc.SimplifyFunction()); } else if (this.RightFunc is Digit && (this.RightFunc as Digit).Data == 0) { return(this.RightFunc.SimplifyFunction()); } else if (this.LeftFunc is Digit && (this.LeftFunc as Digit).Data == 1) { return(this.RightFunc.SimplifyFunction()); } else if (this.RightFunc is Digit && (this.RightFunc as Digit).Data == 1) { return(this.LeftFunc.SimplifyFunction()); } else { this.LeftFunc = this.LeftFunc.SimplifyFunction(); this.RightFunc = this.RightFunc.SimplifyFunction(); //return this function if there is no x if ((this.LeftFunc is Digit || this.LeftFunc is n || this.LeftFunc is r) && (this.RightFunc is Digit || this.LeftFunc is n || this.LeftFunc is r)) { r func = new r(); (func as r).Data = this.Calculate(0); return(func); } else { if (this.LeftFunc is Digit && (this.LeftFunc as Digit).Data == 0) { return(LeftFunc.SimplifyFunction()); } else if (this.RightFunc is Digit && (this.RightFunc as Digit).Data == 0) { return(RightFunc.SimplifyFunction()); } else if (this.LeftFunc is Digit && (this.LeftFunc as Digit).Data == 1) { return(RightFunc.SimplifyFunction()); } else if (this.RightFunc is Digit && (this.RightFunc as Digit).Data == 1) { return(LeftFunc.SimplifyFunction()); } else { return(this); } } } }
public override double Calculate(double X) { if (LeftFunc != null) { return(LeftFunc.Calculate(X) - RightFunc.Calculate(X)); } else { return(-RightFunc.Calculate(X)); } }
public override decimal Calculate(decimal X) { if (LeftFunc != null) { return(LeftFunc.Calculate(X) - RightFunc.Calculate(X)); } else { return(-RightFunc.Calculate(X)); } }
// Calculate function public override double Calc(double val) { var a = LeftFunc.Calc(val); if (Math.Abs(a) <= 10e-6) { return(a); } var b = RightFunc.Calc(val); if (Math.Abs(b) <= 10e-6) { return(b); } return(a * b); }
public override decimal Calculate(decimal X) { return(LeftFunc.Calculate(X) + RightFunc.Calculate(X)); }
//Method public override string ToString() { return($"{notation}({LeftFunc.ToString()})"); }
public override double Calculate(double X) { return(Math.Cos(LeftFunc.Calculate(X))); }
// Latex view public override string Print() { return(LeftFunc.Print() + "+" + RightFunc.Print()); }
public override decimal Calculate(decimal X) { ThrowExceptionWithWrongInput(); return((decimal)Math.Pow(Convert.ToDouble(LeftFunc.Calculate(X)), Convert.ToDouble(RightFunc.Calculate(X)))); }
// Latex view public override string Print() { return(@"\frac{" + LeftFunc.Print() + "}{" + RightFunc.Print() + "}"); }
// Calculate function public override double Calc(double val) { return(LeftFunc.Calc(val) + RightFunc.Calc(val)); }
public override double Calculate(double X) { ThrowExceptionWithWrongInput(); return(GetFactorial(LeftFunc.Calculate(X))); }
// Derivative rule public override Function Derivative() { return((LeftFunc.Derivative() * RightFunc - RightFunc.Derivative() * LeftFunc) / (RightFunc * RightFunc)); }
// Protected Functions /// <summary> /// Checks for user button presses and calls respective function /// </summary> /// <param name="left">Defined Left function</param> /// <param name="right">Defined Right function</param> /// <param name="up">Defined Up function</param> /// <param name="down">Defined Down function</param> protected void directionalMenuLogic(LeftFunc left, RightFunc right, UpFunc up, DownFunc down) { horiz = InputPlayers.player0.GetAxis(HorizontalButton); vert = InputPlayers.player0.GetAxis(VerticalButton); if (horiz < LIMIT && vert < LIMIT) { changeBumpers("off"); } // Audio for each option if user holds down key for long enough // if (!hasSounded) // To be used if the welcome instructions should be skippable if the user presses a button if (horiz >= LIMIT) // Right { if (!source.isPlaying) playDirectionalSound(rightSound); changeBumpers("Right"); } else if (horiz <= -(LIMIT) ) // Left { if (!source.isPlaying) playDirectionalSound(leftSound); changeBumpers("Left"); } if (vert >= LIMIT) // Up { if (!source.isPlaying) playDirectionalSound(upSound); changeBumpers("Up"); } else if (vert <= -(LIMIT) ) // Down { if (!source.isPlaying) playDirectionalSound(downSound); changeBumpers("Down"); } if (InputPlayers.player0.GetButtonDown(SubmitButton)) { if (horiz > LIMIT) // Right { right(); } else if (horiz < -1*LIMIT) // Left { left(); } if (vert > LIMIT) // Up { up(); } else if (vert < -1*LIMIT) // Down { down(); } } }
public override double Calculate(double X) { return(LeftFunc.Calculate(X) + RightFunc.Calculate(X)); }
public override double Calculate(double X) { ThrowExceptionWithWrongInput(); return(Math.Pow(LeftFunc.Calculate(X), RightFunc.Calculate(X))); }
public override decimal Calculate(decimal X) { return((decimal)Math.Sin(Convert.ToDouble(LeftFunc.Calculate(X)))); }
public override decimal Calculate(decimal X) { ThrowExceptionWithDenominator0(); return(LeftFunc.Calculate(X) / RightFunc.Calculate(X)); }
public override double Calculate(double X) { return(Math.Exp(Convert.ToDouble(LeftFunc.Calculate(X)))); }
// Calculate function public override double Calc(double val) { return(Math.Pow(LeftFunc.Calc(val), RightFunc.Calc(val))); }
public override decimal Calculate(decimal X) { ThrowExceptionWithWrongInput(); return(getFactorial(LeftFunc.Calculate(X))); }
// Derivative rule public override Function Derivative() { return(LeftFunc.Derivative() * RightFunc + LeftFunc * RightFunc.Derivative()); }