Description
We have syntax trees that we can evaluate, reduce (to some degree) and take the derivative of. It would be useful to be bale to take the integral of such a tree as well.
Implementation
The easiest way to do this would be via a recursive algorithm similar to the derivative algorithm. Some short cuts should be built in, to take the work off of the reduce call.
Math
It should be assumed that all of these an have any constant C added to them and remain valid:
- ∫ k dx = kx
- ∫ x dx = x^2/2
- ∫ u(x)v(x) dx = u∫v dx - ∫u'(∫v dx) dx
- ∫(u+v) dx = ∫u dx + ∫v dx
Description
We have syntax trees that we can evaluate, reduce (to some degree) and take the derivative of. It would be useful to be bale to take the integral of such a tree as well.
Implementation
The easiest way to do this would be via a recursive algorithm similar to the derivative algorithm. Some short cuts should be built in, to take the work off of the reduce call.
Math
It should be assumed that all of these an have any constant C added to them and remain valid: