ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 31 Aug 2013 09:52:17 +0200Integrate with elliptic integral special function in resulthttps://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/I'm trying to work with the following integral:
$$\int\sqrt{1-\frac14(\cosh x)^2}\mathrm dx$$
Feeding this to sage as `integrate(sqrt(1-1/4*cosh(x)^2),x)` leaves it pretty much as it stands. [Feeding the same to Wolfram Alpha](http://www.wolframalpha.com/input/?i=integrate%28sqrt%281-1%2F4*cosh%28x%29^2%29%2Cx%29), I get a solution which at least at first glance looks better:
$$\int\sqrt{1-\frac14(\cosh x)^2}\mathrm dx=-\frac12i\sqrt3E\left(ix\Big\vert-\frac13\right)$$
So I wonder:
* **Is there a way to obtain this kind of output using sage?** (This is my main question.)
* In particular, is there a way to manually indicate that a given integral can likely be expressed in terms of elliptic integral functions, and that these would be of interest?
* Are these [elliptic integral functions](http://en.wikipedia.org/wiki/Elliptic_integral) even available at all inside sage? If they are, under what name?
* Is there any benefit in using these special elliptic integral functions, as opposed to (a `numeric_integral` version of) the original integral, in terms of performance or accuracy when dealing with actual numeric data?Wed, 15 May 2013 03:43:21 +0200https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/Answer by tmonteil for <p>I'm trying to work with the following integral:</p>
<p>$$\int\sqrt{1-\frac14(\cosh x)^2}\mathrm dx$$</p>
<p>Feeding this to sage as <code>integrate(sqrt(1-1/4*cosh(x)^2),x)</code> leaves it pretty much as it stands. <a href="http://www.wolframalpha.com/input/?i=integrate%28sqrt%281-1%2F4*cosh%28x%29^2%29%2Cx%29">Feeding the same to Wolfram Alpha</a>, I get a solution which at least at first glance looks better:</p>
<p>$$\int\sqrt{1-\frac14(\cosh x)^2}\mathrm dx=-\frac12i\sqrt3E\left(ix\Big\vert-\frac13\right)$$</p>
<p>So I wonder:</p>
<ul>
<li><strong>Is there a way to obtain this kind of output using sage?</strong> (This is my main question.)</li>
<li>In particular, is there a way to manually indicate that a given integral can likely be expressed in terms of elliptic integral functions, and that these would be of interest?</li>
<li>Are these <a href="http://en.wikipedia.org/wiki/Elliptic_integral">elliptic integral functions</a> even available at all inside sage? If they are, under what name?</li>
<li>Is there any benefit in using these special elliptic integral functions, as opposed to (a <code>numeric_integral</code> version of) the original integral, in terms of performance or accuracy when dealing with actual numeric data?</li>
</ul>
https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?answer=14927#post-id-14927What makes me fear is the following:
sage: a = integrate(sqrt(1-1/4*cosh(x)^2),x)
sage: a.full_simplify()
cosh(x)
Which is definitely a wrong answer :(
Concerning your fourth question, the second component of the result of `numerical_integral()` is the error bound:
sage: numerical_integral(sqrt(1-1/4*cosh(x)^2),0,0.1)
(0.08655430733928117, 9.609458488855213e-16)
Wed, 15 May 2013 08:51:35 +0200https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?answer=14927#post-id-14927Comment by kcrisman for <p>What makes me fear is the following:</p>
<pre><code>sage: a = integrate(sqrt(1-1/4*cosh(x)^2),x)
sage: a.full_simplify()
cosh(x)
</code></pre>
<p>Which is definitely a wrong answer :(</p>
<p>Concerning your fourth question, the second component of the result of <code>numerical_integral()</code> is the error bound:</p>
<pre><code>sage: numerical_integral(sqrt(1-1/4*cosh(x)^2),0,0.1)
(0.08655430733928117, 9.609458488855213e-16)
</code></pre>
https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?comment=17509#post-id-17509Apparently #13973 fixes this - thanks for checking to Jeroen.Thu, 13 Jun 2013 11:12:45 +0200https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?comment=17509#post-id-17509Comment by kcrisman for <p>What makes me fear is the following:</p>
<pre><code>sage: a = integrate(sqrt(1-1/4*cosh(x)^2),x)
sage: a.full_simplify()
cosh(x)
</code></pre>
<p>Which is definitely a wrong answer :(</p>
<p>Concerning your fourth question, the second component of the result of <code>numerical_integral()</code> is the error bound:</p>
<pre><code>sage: numerical_integral(sqrt(1-1/4*cosh(x)^2),0,0.1)
(0.08655430733928117, 9.609458488855213e-16)
</code></pre>
https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?comment=17095#post-id-17095Correct, http://trac.sagemath.org/ticket/13973 has not been implemented yet - there is a matrix issue we need to deal with.Sat, 31 Aug 2013 09:52:17 +0200https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?comment=17095#post-id-17095Comment by fjdu for <p>What makes me fear is the following:</p>
<pre><code>sage: a = integrate(sqrt(1-1/4*cosh(x)^2),x)
sage: a.full_simplify()
cosh(x)
</code></pre>
<p>Which is definitely a wrong answer :(</p>
<p>Concerning your fourth question, the second component of the result of <code>numerical_integral()</code> is the error bound:</p>
<pre><code>sage: numerical_integral(sqrt(1-1/4*cosh(x)^2),0,0.1)
(0.08655430733928117, 9.609458488855213e-16)
</code></pre>
https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?comment=17096#post-id-17096It seems the web version of sage (https://cloud.sagemath.com/) still has this bug.Fri, 30 Aug 2013 13:19:23 +0200https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?comment=17096#post-id-17096Answer by kcrisman for <p>I'm trying to work with the following integral:</p>
<p>$$\int\sqrt{1-\frac14(\cosh x)^2}\mathrm dx$$</p>
<p>Feeding this to sage as <code>integrate(sqrt(1-1/4*cosh(x)^2),x)</code> leaves it pretty much as it stands. <a href="http://www.wolframalpha.com/input/?i=integrate%28sqrt%281-1%2F4*cosh%28x%29^2%29%2Cx%29">Feeding the same to Wolfram Alpha</a>, I get a solution which at least at first glance looks better:</p>
<p>$$\int\sqrt{1-\frac14(\cosh x)^2}\mathrm dx=-\frac12i\sqrt3E\left(ix\Big\vert-\frac13\right)$$</p>
<p>So I wonder:</p>
<ul>
<li><strong>Is there a way to obtain this kind of output using sage?</strong> (This is my main question.)</li>
<li>In particular, is there a way to manually indicate that a given integral can likely be expressed in terms of elliptic integral functions, and that these would be of interest?</li>
<li>Are these <a href="http://en.wikipedia.org/wiki/Elliptic_integral">elliptic integral functions</a> even available at all inside sage? If they are, under what name?</li>
<li>Is there any benefit in using these special elliptic integral functions, as opposed to (a <code>numeric_integral</code> version of) the original integral, in terms of performance or accuracy when dealing with actual numeric data?</li>
</ul>
https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?answer=14928#post-id-14928Answering your third question, [yes they are](http://www.sagemath.org/doc/reference/functions/sage/functions/special.html#sage.functions.special.EllipticE)! However, they are extremely loosely integrated in with the main symbolics.
As to the simplification question Thierry points out, it turns out that nearly all of the Maxima simplification methods yield this (though just sending it to Maxima and back, `simplify`, doesn't). (I also don't see this in Maxima proper, and I'm investigating this.) These are, of course, simplifications, which might only be valid over certain domains, but I haven't seen one involving an unevaluated integral before so I'm not sure what's going on there.Wed, 15 May 2013 10:47:38 +0200https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?answer=14928#post-id-14928Comment by tmonteil for <p>Answering your third question, <a href="http://www.sagemath.org/doc/reference/functions/sage/functions/special.html#sage.functions.special.EllipticE">yes they are</a>! However, they are extremely loosely integrated in with the main symbolics. </p>
<p>As to the simplification question Thierry points out, it turns out that nearly all of the Maxima simplification methods yield this (though just sending it to Maxima and back, <code>simplify</code>, doesn't). (I also don't see this in Maxima proper, and I'm investigating this.) These are, of course, simplifications, which might only be valid over certain domains, but I haven't seen one involving an unevaluated integral before so I'm not sure what's going on there.</p>
https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?comment=17689#post-id-17689Thanks for investigating !Wed, 15 May 2013 13:00:04 +0200https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?comment=17689#post-id-17689Comment by kcrisman for <p>Answering your third question, <a href="http://www.sagemath.org/doc/reference/functions/sage/functions/special.html#sage.functions.special.EllipticE">yes they are</a>! However, they are extremely loosely integrated in with the main symbolics. </p>
<p>As to the simplification question Thierry points out, it turns out that nearly all of the Maxima simplification methods yield this (though just sending it to Maxima and back, <code>simplify</code>, doesn't). (I also don't see this in Maxima proper, and I'm investigating this.) These are, of course, simplifications, which might only be valid over certain domains, but I haven't seen one involving an unevaluated integral before so I'm not sure what's going on there.</p>
https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?comment=17683#post-id-17683Thank you, I didn't look very carefully at what this was supposed to be representing and thought it was [this guy](http://www.sagemath.org/doc/reference/functions/sage/functions/exp_integral.html#sage.functions.exp_integral.Function_exp_integral_e) with some unusual notation.Thu, 16 May 2013 15:19:04 +0200https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?comment=17683#post-id-17683Comment by MvG for <p>Answering your third question, <a href="http://www.sagemath.org/doc/reference/functions/sage/functions/special.html#sage.functions.special.EllipticE">yes they are</a>! However, they are extremely loosely integrated in with the main symbolics. </p>
<p>As to the simplification question Thierry points out, it turns out that nearly all of the Maxima simplification methods yield this (though just sending it to Maxima and back, <code>simplify</code>, doesn't). (I also don't see this in Maxima proper, and I'm investigating this.) These are, of course, simplifications, which might only be valid over certain domains, but I haven't seen one involving an unevaluated integral before so I'm not sure what's going on there.</p>
https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?comment=17688#post-id-17688Your link is for exponential integrals, which don't have that square root of sum involving square aspect of the integrand. Nevertheless, one topic down I found the special functions, and among these, [`EllipticE`](http://www.sagemath.org/doc/reference/functions/sage/functions/special.html#sage.functions.special.EllipticE) which should be the one Wolfram Alpha used.Wed, 15 May 2013 13:08:23 +0200https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?comment=17688#post-id-17688Comment by kcrisman for <p>Answering your third question, <a href="http://www.sagemath.org/doc/reference/functions/sage/functions/special.html#sage.functions.special.EllipticE">yes they are</a>! However, they are extremely loosely integrated in with the main symbolics. </p>
<p>As to the simplification question Thierry points out, it turns out that nearly all of the Maxima simplification methods yield this (though just sending it to Maxima and back, <code>simplify</code>, doesn't). (I also don't see this in Maxima proper, and I'm investigating this.) These are, of course, simplifications, which might only be valid over certain domains, but I haven't seen one involving an unevaluated integral before so I'm not sure what's going on there.</p>
https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?comment=17690#post-id-17690Got it - the Maxima `abs_integrate` package is to blame for this. Of course, there may be a branch issue involved. See [Trac 14591](http://trac.sagemath.org/sage_trac/ticket/14591).Wed, 15 May 2013 11:11:57 +0200https://ask.sagemath.org/question/10123/integrate-with-elliptic-integral-special-function-in-result/?comment=17690#post-id-17690