Mathematical derivation in Flash

Hi,
Does anybody know where I could find some tutorial/examples/explanation how to derivate in Flash (AS2)? I.e. how to program a function that would derivate let’s say 3x^3, and I could trace the result (9x^2). I simply have no idea how to begin. It doesn’t have to be anything advanced. Thanks for all help!

Cheers
Poco