/// <inheritdoc/> public override ExpNode Execute(RecipricalOperNode node) { node.Child = node.Child.Execute(this); if (node.Child is NumericalValueNode nvNode) { return(QuickOpers.MakeNumericalNode(1 / nvNode.DoubleValue)); } return(QuickOpers.Pow(node.Child, -1).Execute(this)); }
/// <inheritdoc/> public override ExpNode Execute(PowOperNode node) { // TODO: Handle variable in exponent if (node.IsConstantBy(_variable)) { return(ConstantRule(node)); } // Increment exponent, divide by exponent AdditionOperNode exponent = QuickOpers.Add(1, node.RightChild); RecipricalOperNode coefficient = QuickOpers.Reciprical(exponent.Clone()); PowOperNode @base = QuickOpers.Pow(node.LeftChild, exponent); return(QuickOpers.Multiply(coefficient, @base)); }
/// <summary> /// Executes operation on a <see cref="RecipricalOperNode"/>. /// </summary> /// <param name="node">The <see cref="RecipricalOperNode"/> to execute operation on.</param> /// <returns>The result of the operation on a <see cref="RecipricalOperNode"/>.</returns> public virtual ExpNode Execute(RecipricalOperNode node) => Execute((UOperNode)node);