Integral of 1/cos(x) in CAS - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Integral of 1/cos(x) in CAS (/thread-7008.html) Integral of 1/cos(x) in CAS - Nigel (UK) - 10-09-2016 08:01 PM 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) RE: Integral of 1/cos(x) in CAS - parisse - 10-10-2016 05:53 AM 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). RE: Integral of 1/cos(x) in CAS - Nigel (UK) - 10-10-2016 07:50 PM (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) RE: Integral of 1/cos(x) in CAS - parisse - 10-11-2016 05:55 AM 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/ RE: Integral of 1/cos(x) in CAS - Nigel (UK) - 10-12-2016 08:16 AM (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) RE: Integral of 1/cos(x) in CAS - John P - 10-12-2016 02:47 PM (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? RE: Integral of 1/cos(x) in CAS - parisse - 10-12-2016 06:44 PM 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.