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.Fri, 09 Mar 2012 14:41:28 +0100Difficult integral?https://ask.sagemath.org/question/8781/difficult-integral/Hello all,
I'm trying to get the integral with respect to x of the following expression:
(a / x + b(y) * x ^ c) ^ d,
where a,c,d are positive constants, and b is a function of some variable y.
I'm not sure what I'm doing wrong. Can you help me?
I got a solution in Mathematica (some hypergeometric function), but Mathematica is a software that I'm trying not to use anymore.
Best,
Alejandro
Fri, 09 Mar 2012 10:01:34 +0100https://ask.sagemath.org/question/8781/difficult-integral/Answer by Alejandro for <p>Hello all,</p>
<p>I'm trying to get the integral with respect to x of the following expression:</p>
<p>(a / x + b(y) * x ^ c) ^ d,</p>
<p>where a,c,d are positive constants, and b is a function of some variable y.</p>
<p>I'm not sure what I'm doing wrong. Can you help me?</p>
<p>I got a solution in Mathematica (some hypergeometric function), but Mathematica is a software that I'm trying not to use anymore.</p>
<p>Best,</p>
<p>Alejandro</p>
https://ask.sagemath.org/question/8781/difficult-integral/?answer=13204#post-id-13204Thanks for your answers!
I tried to use the mathematica_free algorithm. There is an additional problem: the constant b is indeed a function some variable y. It is of course a constant, but it is undetermined when integrating the function.
So, Sage returns:
NotImplementedError: Mathematica online integrator can only handle
single letter variables.
AlejandroFri, 09 Mar 2012 12:08:44 +0100https://ask.sagemath.org/question/8781/difficult-integral/?answer=13204#post-id-13204Answer by achrzesz for <p>Hello all,</p>
<p>I'm trying to get the integral with respect to x of the following expression:</p>
<p>(a / x + b(y) * x ^ c) ^ d,</p>
<p>where a,c,d are positive constants, and b is a function of some variable y.</p>
<p>I'm not sure what I'm doing wrong. Can you help me?</p>
<p>I got a solution in Mathematica (some hypergeometric function), but Mathematica is a software that I'm trying not to use anymore.</p>
<p>Best,</p>
<p>Alejandro</p>
https://ask.sagemath.org/question/8781/difficult-integral/?answer=13229#post-id-13229You can make the substitution after integration:
sage: var('a b c d y')
sage: ii=integrate((a/x+b*x^c)^d,x,algorithm='mathematica_free')
sage: b=function('b',y)
sage: ii(b=b(y))
-(x^c*b(y) + a/x)^d*x*hypergeometric2f1(-(d - 1)/(c + 1), -d, -(d - 1)/(c + 1) + 1,
-x^(c + 1)*b(y)/a)/((d - 1)*(x^(c + 1)*b(y)/a + 1)^d)
but I don't think that sage understands hypergeometric2f1
Fri, 09 Mar 2012 12:41:33 +0100https://ask.sagemath.org/question/8781/difficult-integral/?answer=13229#post-id-13229Comment by Alejandro for <p>You can make the substitution after integration:</p>
<pre><code>sage: var('a b c d y')
sage: ii=integrate((a/x+b*x^c)^d,x,algorithm='mathematica_free')
sage: b=function('b',y)
sage: ii(b=b(y))
-(x^c*b(y) + a/x)^d*x*hypergeometric2f1(-(d - 1)/(c + 1), -d, -(d - 1)/(c + 1) + 1,
-x^(c + 1)*b(y)/a)/((d - 1)*(x^(c + 1)*b(y)/a + 1)^d)
</code></pre>
<p>but I don't think that sage understands hypergeometric2f1</p>
https://ask.sagemath.org/question/8781/difficult-integral/?comment=20149#post-id-20149Exactly, Sage doesn't recognize it. So, i'm completely stuck :S Fri, 09 Mar 2012 14:08:49 +0100https://ask.sagemath.org/question/8781/difficult-integral/?comment=20149#post-id-20149Comment by kcrisman for <p>You can make the substitution after integration:</p>
<pre><code>sage: var('a b c d y')
sage: ii=integrate((a/x+b*x^c)^d,x,algorithm='mathematica_free')
sage: b=function('b',y)
sage: ii(b=b(y))
-(x^c*b(y) + a/x)^d*x*hypergeometric2f1(-(d - 1)/(c + 1), -d, -(d - 1)/(c + 1) + 1,
-x^(c + 1)*b(y)/a)/((d - 1)*(x^(c + 1)*b(y)/a + 1)^d)
</code></pre>
<p>but I don't think that sage understands hypergeometric2f1</p>
https://ask.sagemath.org/question/8781/difficult-integral/?comment=20146#post-id-20146Also, http://ask.sagemath.org/question/1168/how-can-one-use-maxima-kummer-confluent-functions has several ideas which you might find helpful. In particular, you should be able to use the templates referred to from (for instance) the beta function to create a "custom" HG function for your own use; mpmath will certainly evaluate it as well as needed, though it sounds like that is not your use case.Fri, 09 Mar 2012 14:41:28 +0100https://ask.sagemath.org/question/8781/difficult-integral/?comment=20146#post-id-20146Comment by kcrisman for <p>You can make the substitution after integration:</p>
<pre><code>sage: var('a b c d y')
sage: ii=integrate((a/x+b*x^c)^d,x,algorithm='mathematica_free')
sage: b=function('b',y)
sage: ii(b=b(y))
-(x^c*b(y) + a/x)^d*x*hypergeometric2f1(-(d - 1)/(c + 1), -d, -(d - 1)/(c + 1) + 1,
-x^(c + 1)*b(y)/a)/((d - 1)*(x^(c + 1)*b(y)/a + 1)^d)
</code></pre>
<p>but I don't think that sage understands hypergeometric2f1</p>
https://ask.sagemath.org/question/8781/difficult-integral/?comment=20147#post-id-20147See http://trac.sagemath.org/sage_trac/ticket/2516. We would *really* welcome any assistance with that; as with many things in Sage, the infrastructure has been there for a long time, the hard part is "wrapping" it so that it plays well with the rest of Sage - and even here, the hard part means "the tedious part".Fri, 09 Mar 2012 14:39:39 +0100https://ask.sagemath.org/question/8781/difficult-integral/?comment=20147#post-id-20147Answer by achrzesz for <p>Hello all,</p>
<p>I'm trying to get the integral with respect to x of the following expression:</p>
<p>(a / x + b(y) * x ^ c) ^ d,</p>
<p>where a,c,d are positive constants, and b is a function of some variable y.</p>
<p>I'm not sure what I'm doing wrong. Can you help me?</p>
<p>I got a solution in Mathematica (some hypergeometric function), but Mathematica is a software that I'm trying not to use anymore.</p>
<p>Best,</p>
<p>Alejandro</p>
https://ask.sagemath.org/question/8781/difficult-integral/?answer=13345#post-id-13345This result is similar to that from W-alpha:
sage: integrate((a/x+b*x^c)^d,x,algorithm='mathematica_free')
-(x^c*b + a/x)^d*x*hypergeometric2f1(-(d - 1)/(c + 1), -d, -(d - 1)/(c + 1) + 1,
-b*x^(c + 1)/a)/((d - 1)*(b*x^(c + 1)/a + 1)^d)
Fri, 09 Mar 2012 11:38:37 +0100https://ask.sagemath.org/question/8781/difficult-integral/?answer=13345#post-id-13345Comment by Alejandro for <p>This result is similar to that from W-alpha:</p>
<pre><code>sage: integrate((a/x+b*x^c)^d,x,algorithm='mathematica_free')
-(x^c*b + a/x)^d*x*hypergeometric2f1(-(d - 1)/(c + 1), -d, -(d - 1)/(c + 1) + 1,
-b*x^(c + 1)/a)/((d - 1)*(b*x^(c + 1)/a + 1)^d)
</code></pre>
https://ask.sagemath.org/question/8781/difficult-integral/?comment=20151#post-id-20151Oh, I see, i didn't know the mathematica_free algorithm. If i understand correctly, Sage is taking the result from the online integrator, isn't it?
The next question is if i can work further with that result. For example, evaluate it, etc.Fri, 09 Mar 2012 12:02:24 +0100https://ask.sagemath.org/question/8781/difficult-integral/?comment=20151#post-id-20151Answer by kcrisman for <p>Hello all,</p>
<p>I'm trying to get the integral with respect to x of the following expression:</p>
<p>(a / x + b(y) * x ^ c) ^ d,</p>
<p>where a,c,d are positive constants, and b is a function of some variable y.</p>
<p>I'm not sure what I'm doing wrong. Can you help me?</p>
<p>I got a solution in Mathematica (some hypergeometric function), but Mathematica is a software that I'm trying not to use anymore.</p>
<p>Best,</p>
<p>Alejandro</p>
https://ask.sagemath.org/question/8781/difficult-integral/?answer=13343#post-id-13343Probably Maxima just doesn't know this integral. They do get some hypergeometric functions as a result of certain integrals, but it is not as strong in HG functions as Mma. I do get some results if I assume `c>1`, like
sage: integrate((a/x+x^c)^3,x)
3*a^2*x^(c - 1)/(c - 1) - 1/2*a^3/x^2 + 3/2*a*x^(2*c)/c + x^(3*c + 1)/(3*c + 1)
but Maxima asks redundant and other questions on this a bunch.
(%i8) display2d:false;
(%o8) false
(%i9) integrate((a/x+b*x^c)^3,x);
Is c-1 zero or nonzero?
nonzero;
Is 3*c+1 zero or nonzero?
nonzero;
Is c zero or nonzero?
nonzero;
(%o9) b^3*x^(3*c+1)/(3*c+1)+3*a*b^2*x^(2*c)/(2*c)+3*a^2*b*x^(c-1)/(c-1)-a^3
/(2
*x^2)
And once you replace the exponent with a `d` or some noninteger exponent, it doesn't seem to know what to do.Fri, 09 Mar 2012 10:24:09 +0100https://ask.sagemath.org/question/8781/difficult-integral/?answer=13343#post-id-13343Comment by Alejandro for <p>Probably Maxima just doesn't know this integral. They do get some hypergeometric functions as a result of certain integrals, but it is not as strong in HG functions as Mma. I do get some results if I assume <code>c>1</code>, like </p>
<pre><code>sage: integrate((a/x+x^c)^3,x)
3*a^2*x^(c - 1)/(c - 1) - 1/2*a^3/x^2 + 3/2*a*x^(2*c)/c + x^(3*c + 1)/(3*c + 1)
</code></pre>
<p>but Maxima asks redundant and other questions on this a bunch.</p>
<pre><code>(%i8) display2d:false;
(%o8) false
(%i9) integrate((a/x+b*x^c)^3,x);
Is c-1 zero or nonzero?
nonzero;
Is 3*c+1 zero or nonzero?
nonzero;
Is c zero or nonzero?
nonzero;
(%o9) b^3*x^(3*c+1)/(3*c+1)+3*a*b^2*x^(2*c)/(2*c)+3*a^2*b*x^(c-1)/(c-1)-a^3
/(2
*x^2)
</code></pre>
<p>And once you replace the exponent with a <code>d</code> or some noninteger exponent, it doesn't seem to know what to do.</p>
https://ask.sagemath.org/question/8781/difficult-integral/?comment=20152#post-id-20152In that case, i should stick to Mathematica, I guess...Fri, 09 Mar 2012 11:53:52 +0100https://ask.sagemath.org/question/8781/difficult-integral/?comment=20152#post-id-20152Comment by kcrisman for <p>Probably Maxima just doesn't know this integral. They do get some hypergeometric functions as a result of certain integrals, but it is not as strong in HG functions as Mma. I do get some results if I assume <code>c>1</code>, like </p>
<pre><code>sage: integrate((a/x+x^c)^3,x)
3*a^2*x^(c - 1)/(c - 1) - 1/2*a^3/x^2 + 3/2*a*x^(2*c)/c + x^(3*c + 1)/(3*c + 1)
</code></pre>
<p>but Maxima asks redundant and other questions on this a bunch.</p>
<pre><code>(%i8) display2d:false;
(%o8) false
(%i9) integrate((a/x+b*x^c)^3,x);
Is c-1 zero or nonzero?
nonzero;
Is 3*c+1 zero or nonzero?
nonzero;
Is c zero or nonzero?
nonzero;
(%o9) b^3*x^(3*c+1)/(3*c+1)+3*a*b^2*x^(2*c)/(2*c)+3*a^2*b*x^(c-1)/(c-1)-a^3
/(2
*x^2)
</code></pre>
<p>And once you replace the exponent with a <code>d</code> or some noninteger exponent, it doesn't seem to know what to do.</p>
https://ask.sagemath.org/question/8781/difficult-integral/?comment=20148#post-id-20148Perhaps. This is really one of the only areas where Sage is at a significant disadvantage vis-a-vis the competitors in terms of functionality. Since HG functions are so ubiquitous, I'm surprised Maxima can't handle this one, but there you have it. I've asked on the Maxima list, because it *can* do them for specific positive integers `d` (even largish ones), but not a general such d.Fri, 09 Mar 2012 14:33:18 +0100https://ask.sagemath.org/question/8781/difficult-integral/?comment=20148#post-id-20148