Question

I'm a calculus student, and I frequently use Sage to check work. Often, it's necessary to allow for a constant difference between two expressions. For instance, when finding an antiderivative, the two results ln(2*x) and ln(x) are equivalent, but of course bool(ln(2*x) == ln(x)) returns False. Is there a way to define a variable C so that bool(ln(2*x) == ln(x) + C) returns True?

Was it helpful?

Solution

Hmm, that is a really good question. To the best of my knowledge, the answer is no. In any case, it would be arbitrarily computationally expensive to always check whether things up are equal up to a constant...

That said, that is annoying for your case - and also for more complicated situations; this happens all the time if you choose different ways to find antiderivatives for complicated combinations of trig powers, depending on the simplifications you use.

But... I'm wondering whether it matters. Couldn't you just check the derivatives of the functions in question to see? You would have to be a little careful about domains but what you are essentially saying is "I want to check whether it's the same as the answer I got" when all you need is "do the answer I got and the one Sage gives have the same derivative". Indeed, just like checking long division is easiest using multiplication, checking antiderivatives is easiest using derivatives.

Lest you think this is a copout, here is a fun interactive thing to try which I hope works in your use case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top