Is integration and differentiation code sepparate?



On 11/12/10 03:56 PM, Karl-Dieter Crisman wrote:
>> 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
>>
>>
>>
>
> Just to say something (fairly) obvious to mathematicians, sometimes
> there are antiderivatives that are equal up to a constant (or even
> equal) which don't look anything alike - and which presumably it's
> very hard to automatically check if they are equal up to a constant.
> This happens particularly often with things involving combinations of
> trig functions, but also with things like arcsinh/ln(stuff) and other
> integrals of radicals... I bet looking at a good table of integrals
> would show some of these things.    So that even calc textbooks point
> this out, that using different systems will give you different (but
> both correct) answers.

Would substituting some random complex numbers for x in this case not be 
worthwhile? It's not absolute proof, but if the substitute several a dozen or so 
complex numbers, and get back to the same numbers, the probability of there 
being a bug must be very small.

Or have I overlooked something?

> With regards to your project, I don't know whether the
> integration/differentiation code is separate in Maxima, but it IS
> separate in Sage, because we use Pynac/Ginac for derivatives but
> Maxima for integrals.
>
> Karl-Dieter

That's useful to know.

Dave