3
$\begingroup$

I am trying to do the following definite integral:

Integrate[(a x^2 + b x + c)^k, {x, 0, 1}]

where $a,b,c,k \in \mathbb{R}$

Now, the problem is Mathematica takes forever to produce a result which I understand is happening because of some complicated simplification procedure.

Note that the indefinite integral is done in a flash:

Integrate[(a x^2 + b x + c)^k, x]

(2^(-1 + k) (b - Sqrt[b^2 - 4 a c] + 2 a x) (( b + Sqrt[b^2 - 4 a c] + 2 a x)/Sqrt[ b^2 - 4 a c])^-k (c + x (b + a x))^k Hypergeometric2F1[-k, 1 + k, 2 + k, (-b + Sqrt[b^2 - 4 a c] - 2 a x)/( 2 Sqrt[b^2 - 4 a c])])/(a (1 + k))

After which the following:

(% /. x -> 1 - % /. x -> 0) //PowerExpand //Simplify

does give a result, but its overly complicated and I think it can be simplified further. The reason I think so is that I have not been able to exhaust the simplification situation with say FullSimplify, that is taking forever to return a result.

Can anyone suggest any workaround here?

Edit 1:

I made a simple mistake by not putting some brackets.

((% /. x -> 1) - (% /. x -> 0)) //PowerExpand //FullSimplify

does work now.

However, I am still curious why the definite integral doesn't work in the first place. Thoughts and comments will be appreciated.

Edit 2:

Given that my original problem is solved, I would like to ask another related question. What if I wanted to do the 2-variable generalization of the same:

Integrate[(a*x^2 + b*y^2 + c x y + d x + f y + g)^k, {x, 0, 1}, {y, 0,
   1}, Assumptions -> (a*x^2 + b*y^2 + c x y + d x + f y + 
      g) \[Element] Reals && Im[b] == 0 && Im[a] == 0 && Im[c] == 0 &&
    Im[d] == 0 && Im[f] == 0 && Im[g] == 0 && Im[k] == 0]

After a while, Mathematica returns the input back. Can this be done analytically, at all?

$\endgroup$
  • 2
    $\begingroup$ you should add some brackets (% /. x -> 1) - (% /. x -> 0) // PowerExpand // Simplify $\endgroup$ – Ulrich Neumann Jun 9 '18 at 14:09
  • $\begingroup$ @UlrichNeumann Yeah you are right! $\endgroup$ – Subho Jun 9 '18 at 14:10
  • $\begingroup$ Try: Integrate[(a*x^2 + b*x + c)^k, {x, 0, 1}, Assumptions -> {a > 0, b > 0, c > 0, k > 0, k \[Element] Integers}] $\endgroup$ – Mariusz Iwaniuk Jun 9 '18 at 16:19
  • 2
    $\begingroup$ Unless k is a positive integer, your integrand will have singularities at the zeros of your quadratic. Those potentially make direct evaluation from the indefinite integral unreliable. I believe that Mathematica's difficulty here lies in the difficulty of avoiding trouble with singularities. $\endgroup$ – John Doty Jun 10 '18 at 9:23
2
$\begingroup$

Help Integrate and it will be faster by powers of ten.

The decicive hint here is Assumptions -> (a*x^2 + b*x + c) \[Element] Reals . I think this helps a lot in internal dealing with powers of k.

Further, restriction to k > 0 is faster than for real k.

(dint01[a_, b_, c_, k_] = 
Integrate[(a*x^2 + b*x + c)^k, {x, 0, 1}, 
 Assumptions -> (a*x^2 + b*x + c) \[Element] Reals && Im[b] == 0 &&
    Im[a] == 0 && Im[c] == 0 && k > 0]); // Timing

(*   {13.485, Null}   *)

(dint02[a_, b_, c_, k_] = 
Integrate[(a*x^2 + b*x + c)^k, {x, 0, 1}, 
 Assumptions -> (a*x^2 + b*x + c) \[Element] Reals && Im[b] == 0 &&
    Im[a] == 0 && Im[c] == 0 && Im[k] == 0]); // Timing

(*   {33.828, Null}   *)

In both cases you get the same result, but with more restrictions for dint01[a,b,c,k] .

dint02[a, b, c, k]

(*   ConditionalExpression[(1/(a (1 + k)))
  2^(-1 + k) (1 + b/Sqrt[b^2 - 4 a c])^-k ((
  2 a + b + Sqrt[b^2 - 4 a c])/Sqrt[
  b^2 - 4 a c])^-k (c^
  k (-b + Sqrt[b^2 - 4 a c]) ((2 a + b + Sqrt[b^2 - 4 a c])/Sqrt[
  b^2 - 4 a c])^
  k Hypergeometric2F1[-k, 1 + k, 2 + k, 
  1/2 - b/(2 Sqrt[b^2 - 4 a c])] - (a + b + c)^
  k (1 + b/Sqrt[b^2 - 4 a c])^
  k (-2 a - b + Sqrt[b^2 - 4 a c]) Hypergeometric2F1[-k, 1 + k, 
  2 + k, (-2 a - b + Sqrt[b^2 - 4 a c])/(
  2 Sqrt[b^2 - 4 a c])]), 

  (Re[(b + Sqrt[b^2 - 4 a c])/a] >= 0 || 
  2 + Re[(b + Sqrt[b^2 - 4 a c])/a] <= 0 ||
 (b + Sqrt[b^2 - 4 a c])/a \[NotElement] Reals) && (Re[(-b + Sqrt[b^2 - 4 a c])/a] == 0 ||
  Re[(b - Sqrt[b^2 - 4 a c])/a] >= 0 || 
 (Re[(-b + Sqrt[b^2 - 4 a c])/a] >= 2 && 
  2 + Re[(b - Sqrt[b^2 - 4 a c])/a] <= 0) ||
 (b - Sqrt[b^2 - 4 a c])/a \[NotElement] Reals)]   *)
$\endgroup$
  • $\begingroup$ Please check the updated question. $\endgroup$ – Subho Jun 10 '18 at 13:42
  • 1
    $\begingroup$ @Subho95 . In the future avoid shifting the goalpost. People feel frustrated to contribute effort to a specific question to then receive new requests not mentioned in the original question. You make the work others have done on your behalf seem irrelevant. Mma.SE is not a private consulting service but a public Q&A forum. Please, out of respect to the people trying to help you, either ask the question you need to ask properly the first time, or ask a new question, including you coded equations properly formatted. Cheers! $\endgroup$ – Mariusz Iwaniuk Jun 10 '18 at 14:30
  • 1
    $\begingroup$ @MariuszIwaniuk I have accepted the answer and acknowledged the help. This was just a follow up question, that is very much related and I thought would find a place in this post just as well. It's not mandatory for the original answerer to answer back but would be nice as he/she is already acquainted with the question. $\endgroup$ – Subho Jun 10 '18 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.