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.Mon, 06 Jul 2020 19:37:06 +0200How to define an integral to not be evaluatedhttps://ask.sagemath.org/question/52359/how-to-define-an-integral-to-not-be-evaluated/I'm trying to write the following script:
var('alpha beta x')
num = x**(alpha-1) * (1-x)**(beta-1)
denom = integral(x**(alpha-1) * (1-x)**(beta-1), x)
gammadist = num / denom
diff(gammadist, x)
So it is mich easier if the integral on `denom` does not get evaluated. However, I cannot find a way to do that on Sage and Sage always tries to evaluate it (without success). Is there a way to tell Sage to keep it as an integral?
ThanksMon, 06 Jul 2020 19:22:40 +0200https://ask.sagemath.org/question/52359/how-to-define-an-integral-to-not-be-evaluated/Answer by rburing for <p>I'm trying to write the following script:</p>
<pre><code>var('alpha beta x')
num = x**(alpha-1) * (1-x)**(beta-1)
denom = integral(x**(alpha-1) * (1-x)**(beta-1), x)
gammadist = num / denom
diff(gammadist, x)
</code></pre>
<p>So it is mich easier if the integral on <code>denom</code> does not get evaluated. However, I cannot find a way to do that on Sage and Sage always tries to evaluate it (without success). Is there a way to tell Sage to keep it as an integral?</p>
<p>Thanks</p>
https://ask.sagemath.org/question/52359/how-to-define-an-integral-to-not-be-evaluated/?answer=52360#post-id-52360See the [documentation of `integral`](https://doc.sagemath.org/html/en/reference/calculus/sage/symbolic/integration/integral.html#sage.symbolic.integration.integral.integral):
> To prevent automatic evaluation use the `hold` argument.
Indeed,
sage: var('alpha beta x')
sage: denom = integral(x**(alpha-1) * (1-x)**(beta-1), x, hold=True); denom
integrate(x^(alpha - 1)*(-x + 1)^(beta - 1), x)
sage: diff(denom,x)
x^(alpha - 1)*(-x + 1)^(beta - 1)Mon, 06 Jul 2020 19:37:06 +0200https://ask.sagemath.org/question/52359/how-to-define-an-integral-to-not-be-evaluated/?answer=52360#post-id-52360