Example #1
0
 /// <inheritdoc/>
 public override ExpNode Execute(VarValueNode node)
 {
     if (node.Character != _variable.Character)
     {
         return(ConstantRule(node));
     }
     return(QuickOpers.Multiply(.5, QuickOpers.Pow(node, 2)));
 }
Example #2
0
 /// <inheritdoc/>
 public override bool IsConstantBy(VarValueNode variable)
 {
     foreach (var child in Children)
     {
         if (!child.IsConstantBy(variable))
         {
             return(false);
         }
     }
     return(true);
 }
Example #3
0
 /// <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);
Example #4
0
 /// <inheritdoc/>
 public override string Print(VarValueNode node)
 {
     return($"{node.Character}");
 }
Example #5
0
 /// <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);
Example #6
0
 /// <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;
 }
Example #7
0
 /// <inheritdoc/>
 public override ExpNode Execute(VarValueNode node)
 {
     return(QuickOpers.MakeNumericalNode(node.Character == _variable.Character ? 1 : 0));
 }
Example #8
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;
 }
Example #9
0
 /// <inheritdoc/>
 public override bool IsConstantBy(VarValueNode variable) => true;
Example #10
0
 /// <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);