HP Forums

Full Version: Integral of 1/cos(x) in CAS
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have been trying to evaluate the symbolic definite integral
$\int_{l_1}^{l_2}\!{1\over\cos\theta}\,{\rm d}\theta$
using the Prime CAS. Using my default setting of no simplification I get a rather complicated but correct answer. My TI-Nspire CAS (which I only switched on to see what it would do with this same integral, honest!) gives a simpler but equivalent result.

This isn't the problem - I understand that there is no good way to define the "simplest" form of an expression, and that different software will give different results. The issue is that using the Prime to simplify the result of the definite integral causes the calculator to hang. Sometimes I can interrupt this; sometimes I can't, and a reset is needed.

Is this a bug? I am using the latest firmware.

Nigel (UK)
I will investigate, note that
a:=int(1/cos(x)); simplify(a)
returns almost immediatly ln((sin(x)^2+2*sin(x)+1)/(sin(x)^2-2*sin(x)+1))/4
If you are computing an integral with symbolic boundaries that are disjoints, then you should compute the antiderivative and rewrite it at this step then make the difference at the boundaries. This is way more efficient than rewriting the difference of the antiderivatives at the boundaries because you have one less variable and an expression that is twice smaller (there is nothing in simplify that checks for the difference of a same expression at two different points).
(10-10-2016 05:53 AM)parisse Wrote: [ -> ]I will investigate, note that
a:=int(1/cos(x)); simplify(a)
returns almost immediatly ln((sin(x)^2+2*sin(x)+1)/(sin(x)^2-2*sin(x)+1))/4
If you are computing an integral with symbolic boundaries that are disjoints, then you should compute the antiderivative and rewrite it at this step then make the difference at the boundaries. This is way more efficient than rewriting the difference of the antiderivatives at the boundaries because you have one less variable and an expression that is twice smaller (there is nothing in simplify that checks for the difference of a same expression at two different points).

Thank you; that's a helpful and practical suggestion. As I've said, it is the crash that worries me rather than the exact form of the answer.

Nigel (UK)
I did not observe a crash but it runs forever. It's a well known problem that it's sometimes difficult to interrupt a CAS computation on the Prime, because the CAS kernel was designed to run on a desktop OS. The best I can do is to commit a workaround each time a user reports a problem, for example here in geogebra SVN
https://dev.geogebra.org/trac/changeset/49639/
(10-11-2016 05:55 AM)parisse Wrote: [ -> ]I did not observe a crash but it runs forever. It's a well known problem that it's sometimes difficult to interrupt a CAS computation on the Prime, because the CAS kernel was designed to run on a desktop OS. The best I can do is to commit a workaround each time a user reports a problem, for example here in geogebra SVN
https://dev.geogebra.org/trac/changeset/49639/
Thank you once again for your help. From now on I shall approach symbolic definite integrals as you suggest!

Nigel (UK)
(10-10-2016 05:53 AM)parisse Wrote: [ -> ]I will investigate, note that
a:=int(1/cos(x)); simplify(a)
returns almost immediatly ln((sin(x)^2+2*sin(x)+1)/(sin(x)^2-2*sin(x)+1))/4
If you are computing an integral with symbolic boundaries that are disjoints, then you should compute the antiderivative and rewrite it at this step then make the difference at the boundaries. This is way more efficient than rewriting the difference of the antiderivatives at the boundaries because you have one less variable and an expression that is twice smaller (there is nothing in simplify that checks for the difference of a same expression at two different points).

Why the XCAS doesn't use the same approach as you described. Wouldn't that be more efficient and simple?
The problem is not to compute the integral, it's when the user calls simplify after that. The simplify command has no way to know that the answer is made of 2 independant parts.
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :