/// <inheritdoc/> public override ExpNode Execute(VarValueNode node) { if (node.Character != _variable.Character) { return(ConstantRule(node)); } return(QuickOpers.Multiply(.5, QuickOpers.Pow(node, 2))); }
/// <inheritdoc/> public override bool IsConstantBy(VarValueNode variable) { foreach (var child in Children) { if (!child.IsConstantBy(variable)) { return(false); } } return(true); }
/// <summary> /// Executes operation on a <see cref="VarValueNode"/>. /// </summary> /// <param name="node">The <see cref="VarValueNode"/> to execute operation on.</param> /// <returns>The result of the operation on a <see cref="VarValueNode"/>.</returns> public virtual ExpNode Execute(VarValueNode node) => Execute((ValueNode)node);
/// <inheritdoc/> public override string Print(VarValueNode node) { return($"{node.Character}"); }
/// <summary> /// Gets if this <see cref="ExpNode"/> or and its children are constant with all <see cref="VarValueNode"/> constant except <paramref name="variable"/>. /// </summary> /// <remarks> /// An <see cref="ExpNode"/> is constant by <paramref name="variable"/> if neither it or any of its children are <paramref name="variable"/>. /// </remarks> /// <param name="variable">The <see cref="VarValueNode"/> that is not constant.</param> /// <returns>a value indicating whether or not the <see cref="ExpNode"/> is constant.</returns> public abstract bool IsConstantBy(VarValueNode variable);
/// <summary> /// Initializes a new instance of the <see cref="Differentiator"/> class. /// </summary> /// <param name="variable">The variable to take the derivative over.</param> public Differentiator(VarValueNode variable) { _variable = variable; }
/// <inheritdoc/> public override ExpNode Execute(VarValueNode node) { return(QuickOpers.MakeNumericalNode(node.Character == _variable.Character ? 1 : 0)); }
/// <summary> /// Initializes a new instance of the <see cref="Integrator"/> class. /// </summary> /// <param name="variable">The variable to find the integral for.</param> public Integrator(VarValueNode variable) { _variable = variable; }
/// <inheritdoc/> public override bool IsConstantBy(VarValueNode variable) => true;
/// <summary> /// Prints a <see cref="VarValueNode"/>. /// </summary> /// <param name="node">The <see cref="VarValueNode"/> to print.</param> /// <returns>The <see cref="VarValueNode"/> printed to a string.</returns> public virtual string Print(VarValueNode node) => Print((ValueNode)node);