Post Reply 
Integral of 1/cos(x) in CAS
10-09-2016, 08:01 PM
Post: #1
Integral of 1/cos(x) in CAS
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)
Find all posts by this user
Quote this message in a reply
10-10-2016, 05:53 AM (This post was last modified: 10-10-2016 06:38 AM by parisse.)
Post: #2
RE: Integral of 1/cos(x) in CAS
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).
Find all posts by this user
Quote this message in a reply
10-10-2016, 07:50 PM
Post: #3
RE: Integral of 1/cos(x) in CAS
(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)
Find all posts by this user
Quote this message in a reply
10-11-2016, 05:55 AM
Post: #4
RE: Integral of 1/cos(x) in CAS
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/
Find all posts by this user
Quote this message in a reply
10-12-2016, 08:16 AM
Post: #5
RE: Integral of 1/cos(x) in CAS
(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)
Find all posts by this user
Quote this message in a reply
10-12-2016, 02:47 PM
Post: #6
RE: Integral of 1/cos(x) in CAS
(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?
Find all posts by this user
Quote this message in a reply
10-12-2016, 06:44 PM
Post: #7
RE: Integral of 1/cos(x) in CAS
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.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 3 Guest(s)