Is integration and differentiation code sepparate?



I've been trying to automatically develop a large number of tests for Sage. 
Hopefully millions of them.

Some of those tests actually test Maxima. I've only just started this, but the 
approach I've taken to date is:

1) Generate a "random" polynomial using a pseudo random number generator.
2) Simplify the polynomail, so the output is in a form that's reproducible.
3) Integrate the polynomial.
4) Differentiate the result from (3)
5) Simplify the result from (4)
6) Compare the results from (2) and (5).

All being well, steps (2) and (5) should be equal.

For simple polynomails, this does indeed seem to be the case. I've generated 
many thousands of them, sometimes with complex coefficients and complex powers, 
and all seems to be ok.

I'm just wondering if there's any common code, which might actually mean the 
such tests are meaningless.



I've found more complex cases (using sin, sinh, tan arctan etc) where the 
results of integrating a function, then differentiating it do NOT lead to back 
to the original function using Maxima.

But I've tried the same equations in Mathematica too, and that also has 
problems, with the result appearing to be much more complicated than what I 
started with. Perhaps I'm just expecting too much. Perhaps this approach is not 
mathematically valid - I'm not a mathematician.


Dave