Take simple derivates in Haskell.
1
: Equation applied to var2
: AST3
: Derivative Rules4
: AST simplifier5
: New equation
(1) -> (2) -> (3) -> (4) -> (5)
ghc deriv.hs
./derive <equation> <var>
// see Examples
x^7*4
(canonical form: 4x^7
)
./deriv x**7*4 x
----- Output
28*x**6
x^7*4^2
(canonical form: 16x^7
)
./deriv x**7*4**2 x
----- Output
112*x**6
4-3*x
(canonical form: -3x+4
./deriv 4-3*x x
----- Output
-3
4*x-3*x^3
(canonical form: -3x^3+4x
)
./deriv 4*x-3*x**3 y
----- Output
0
4*x*y-3*x^3
(canonical form: 4xy-3x^3
./deriv 4*x*y-3*x**3 y
----- Output
4*x
Many derivatives (such as trigonometric derivatives) are not (yet) implemented. Feel free to add them.
Pull requests are welcome :)