5
$\begingroup$

Integrating the following expression, if possible, requires some hints or substitutions which I cannot find.

Integrate[(a*x + b (1 - x))^k *(1 - (a*x + b (1 - x)))^l *x^m *(1 - x)^n, {x,0,1}]

In case this matters, parameters a and b belong to [0,1], n and m are both integers greater or equal to zero, and x is in [0,1]. (EDIT 1: k and l are integers greater or equal to zero as well, I forgot to mention this originally and this "detail" actually might help Mathematica in some circumstances, see the answer by bmf.)

The expression is made of 4 exponentiated expressions ("factors") multiplied together. Though Mathematica cannot digest this integral as is, it is able to solve it if any of the 4 "factors" is removed. I am wondering if helping Mathematica by inserting a substitution could help it solve this?

I have found this answer which is able to provide a substitution, but not only was I not able to try that out (I do not know how to substitute an expression with a variable in that case) but, more importantly, it is not obvious to me what substitution would be promising in this case...

If someone does suggest a promising substitution, please also indicate how I may solve the substitution using Mathematica, unless I can easily do it by hand: so far, substituting using this method has not worked for the problem in the link discussed earlier...

*** [EDIT 2] *** This edit is to share what has been tried so far:

  • Following up on the suggestions by bmf and mikado: unfortunately I am only able to get clean answers up to l=2, which is not enough to extrapolate any potential recursive solution. For l=3, I am able to get an answer using Wolfram Alpha, but that answer breaks the logic shown with the previous values for l.
  • In parallel, I have tried using integration by parts in order to express the integral for l+1 knowing the result for l, with no success.
  • finally, I thought that the Wolfram answer for l=3 could be different because it was possible to express a hypergeometric function of certain parameters as proportional to a hypergeometric of a different set of parameters, so I tried that as well in case I could get back to a logical progression, but without success. Naming H(p)=H2F1(-k,p+m,p+m+n+1,1-a/b), the answer for l=0 involves H(1), l=1 involves H(1) andH(2), l=2 involves H(1), H(2) and H(3), but for l=3 it involves two versions of H(1) and two of H(3). As it turns out, k being a positive integer, the hypergeometricals in my integral simplify to polynomials. Nevertheless, I have not found a way to express H(p+1) as a function of H(p), so I am not able to find a solution for l=3 resemble a progression from the previous values for l.

=> So although it seems like bmf's idea is promising (and they have been chatting with me to help on the side, for which I am grateful), I fail to get it to any meaningful result so far.

$\endgroup$
2
  • $\begingroup$ Mathematica can probably do the integral for specific integer values of k,l,m,n. I would investigate the behaviour for small integer values first, to understand whether the complete answer is likely to be useful to you. $\endgroup$
    – mikado
    Commented Jan 2, 2023 at 22:22
  • $\begingroup$ @mikado I like your suggestion as it might yield insights, thanks. But as I am approximating this function and need to see how good my approximation is over the parameter space, I do need to explore that space. Also, as k, l, m and n are occurences that can in practice take values from 1 all the way into the hundreds, this is a bit of an all-or-nothing situation (my backup plan being simulation if there is no closed-form). $\endgroup$
    – tyogi
    Commented Jan 3, 2023 at 0:04

2 Answers 2

5
$\begingroup$

The binomial expansion is your friend.

Note that

(a*x + b (1 - x))^k

can be rewritten as

(b + (a - b) x)^k

and the binomial expansion is

Sum[Binomial[k, i] b^i ((a - b) x)^(k - i), {i, 0, k}]

So for each of the $k+1$ terms (after including appropriate Assumptions) then integration is

f = (Integrate[Binomial[k, i] b^i ((a - b) x)^(k - i)*(1 - (b + (a - b) x))^l*x^m*(1 - x)^n,
  {x, 0, 1}, Assumptions -> {0 < a < 1, 0 < b < 1, 
   k \[Element] PositiveIntegers, l \[Element] NonNegativeIntegers, 
   m \[Element] NonNegativeIntegers, n \[Element] NonNegativeIntegers, 
   i \[Element] NonNegativeIntegers, 0 <= i <= k}] // FunctionExpand) /. Gamma[u_] -> (u - 1)!

which results in

((1 - b)^l (a - b)^(-i + k) b^i k! (-i + k + m)! n!*
  Hypergeometric2F1[-l, 1 - i + k + m, 2 - i + k + m + n, (-a + b)/(-1 + b)])/
  (i! (-i + k)! (1 - i + k + m + n)!)

Then just sum over $i=0,\ldots,k$:

integrate[k_, l_, m_, n_] := Sum[((1 - b)^l (a - b)^(-i + k) b^i k! (-i + k + m)! n!*
  Hypergeometric2F1[-l, 1 - i + k + m, 2 - i + k + m + n, (-a + b)/(-1 + b)])/
  (i! (-i + k)! (1 - i + k + m + n)!), {i, 0, k}, 
  Assumptions -> {0 < a < 1, 0 < b < 1, k \[Element] PositiveIntegers,
    l \[Element] NonNegativeIntegers, m \[Element] NonNegativeIntegers, 
    n \[Element] NonNegativeIntegers}]

A specific example:

integrate[10, 3, 7, 5] // Expand // Together // Simplify

Integration result

$\endgroup$
5
  • $\begingroup$ (+1) very nice. much more straightforward than what I had in mind!!! $\endgroup$
    – bmf
    Commented Jan 6, 2023 at 1:22
  • $\begingroup$ I'm pretty sure this is the answer I was looking for, thanks a ton! It was not immediately clear to me why Mma would find this expression easier to digest, but I believe it is leveraging the earlier idea implemented by bmf (the fact that Mma can solve for given k) and combining it with a known form for how the expression evolves with k (the binomial expansion). Finally, a minor observation: I am unsure as to why k (>0) has a different assumption than the other three parameters l, m and n (>= 0), it seems to me that k=0 should be valid as well. $\endgroup$
    – tyogi
    Commented Jan 6, 2023 at 3:16
  • $\begingroup$ You are correct: $k=0$ works fine and I should have used k \[Element] NonNegativeIntegers. And actually something like parms = {k -> 10, l -> 3, m -> 7, n -> 5}; Integrate[((a*x + b (1 - x))^k*(1 - (a*x + b (1 - x)))^l*x^m*(1 - x)^n /. parms) // Expand, {x, 0, 1}] is far faster than what I wrote above even if one ignores the amount of time to construct f. $\endgroup$
    – JimB
    Commented Jan 6, 2023 at 3:59
  • 2
    $\begingroup$ @bmf I stole from your answer to update my answer: used FunctionExpand and converted gammas to factorials. $\endgroup$
    – JimB
    Commented Jan 6, 2023 at 5:58
  • $\begingroup$ @JimB I am very happy you did so :-) I honestly believe you provided a beautiful solution. It was not stealing, hence. It was collaborating online :-) $\endgroup$
    – bmf
    Commented Jan 6, 2023 at 7:04
9
$\begingroup$

Edit 1:

extra hints for the form of the solution.

The solution is roughly a power of b to the k times some factorial stuff times a linear combination of hypergeometric functions.

The easiest way to see that is the following:

define

expr = (a*x + b (1 - x))^k*(1 - (a*x + b (1 - x)))^l*x^m*(1 - x)^n // 
  FullSimplify

then consider

resl0 = Assuming[Re[b] > 0, 
   Assuming[Re[b/(a - b)] >= 0 || Re[b/(a - b)] <= -1, 
    Assuming[
     k \[Element] Integers && k >= 0 && m \[Element] Integers && 
      m >= 0 && n \[Element] Integers && n >= 0, 
     Integrate[expr /. {l -> 0}, {x, 0, 1}]]]];
resl1 = Assuming[Re[b] > 0, 
   Assuming[Re[b/(a - b)] >= 0 || Re[b/(a - b)] <= -1, 
    Assuming[
     k \[Element] Integers && k >= 0 && m \[Element] Integers && 
      m >= 0 && n \[Element] Integers && n >= 0, 
     Integrate[expr /. {l -> 1}, {x, 0, 1}]]]];
resl2 = Assuming[Re[b] > 0, 
   Assuming[Re[b/(a - b)] >= 0 || Re[b/(a - b)] <= -1, 
    Assuming[
     k \[Element] Integers && k >= 0 && m \[Element] Integers && 
      m >= 0 && n \[Element] Integers && n >= 0, 
     Integrate[expr /. {l -> 2}, {x, 0, 1}]]]];
resl3 = Assuming[Re[b] > 0, 
   Assuming[Re[b/(a - b)] >= 0 || Re[b/(a - b)] <= -1, 
    Assuming[
     k \[Element] Integers && k >= 0 && m \[Element] Integers && 
      m >= 0 && n \[Element] Integers && n >= 0, 
     Integrate[expr /. {l -> 3}, {x, 0, 1}]]]];

and now just have a look at the results breaking them up roughly.

Just call them and examine them

resl0 // FunctionExpand;
resl1 // FunctionExpand;
resl2 // FunctionExpand;
resl3 // Factor;

The first one is some Gamma stuff times Hypergeometric2F1. Great. So, simplify the the Gamma stuff

((b^k) Gamma[1 + m] Gamma[1 + n] )/Gamma[2 + m + n] /. 
 Gamma[x_] :> Factorial[x - 1]

output is:

(b^k m! n!)/(1 + m + n)!

You can do the same for the other cases namely l=1, l=2 and l=3. The outputs are respectively

For l=1

(b^k m! n!)/(1 + m + n)!

For l=2

(b^k m! n!)/(3 + m + n)!

For l=3

(b^k m! n!)/(4 + m + n)!

Hint: in order to get the last one easily, just call resl3 // FunctionExpand and then apply /. Gamma[x_] :> Factorial[x - 1] to the prefactor with the gammas.

So, roughly speaking it seems that they follow a pattern, namely

(b^k m! n!)/(m + n + l + 1)!

times a linear combination of hypergeometrics. Perhaps from this point, you can make an ansatz, fit to ansatz with these known cases and verify for a couple of higher l.

This is just an extended comment, but it seems promising.

You say that m and n are integers greater or equal to zero, but you did not feed this information into Mma.

Let's do that:

With

expr = (a*x + b (1 - x))^k*(1 - (a*x + b (1 - x)))^l*x^m*(1 - x)^n // 
  FullSimplify

we check

Assuming[m \[Element] Integers && m >= 0 && n \[Element] Integers && 
  n >= 0, Integrate[expr /. {l -> 0}, {x, 0, 1}]]

ConditionalExpression[ b^k m! n! Hypergeometric2F1Regularized[-k, 1 + m, 2 + m + n, 1 - a/b], Re[b] > 0 && ((b/(a - b) \[NotElement] Reals && Im[a] != (Im[b] Re[a])/Re[b]) || Re[b/(a - b)] >= 0 || Re[b/(a - b)] <= -1)]

So, now we can proceed as follows:

  1. Impose all the conditions
  2. Do some explicit values of l
  3. Gather the results
  4. Try to find a general formula in terms of l that fits the previous results

For l=0 we have

Assuming[Re[b] > 0, 
  Assuming[Re[b/(a - b)] >= 0 || Re[b/(a - b)] <= -1, 
   Assuming[
    m \[Element] Integers && m >= 0 && n \[Element] Integers && 
     n >= 0, Integrate[expr /. {l -> 0}, {x, 0, 1}]]]] // FullSimplify

output is:

b^k m! n! Hypergeometric2F1Regularized[-k, 1 + m, 2 + m + n, 1 - a/b]

For l=1 we write:

Assuming[Re[b] > 0, Assuming[Re[b/(a - b)] >= 0 || Re[b/(a - b)] <= -1, Assuming[ m \[Element] Integers && m >= 0 && n \[Element] Integers && n >= 0, Integrate[expr /. {l -> 1}, {x, 0, 1}]]]] // FullSimplify

output is:

b^k Gamma[1 + m] Gamma[ 1 + n] (-(-1 + b) Hypergeometric2F1Regularized[-k, 1 + m, 2 + m + n, 1 - a/b] + (-a + b) (1 + m) Hypergeometric2F1Regularized[-k, 2 + m, 3 + m + n, 1 - a/b])

For l=2 likewise:

Assuming[Re[b] > 0, Assuming[Re[b/(a - b)] >= 0 || Re[b/(a - b)] <= -1, Assuming[ m \[Element] Integers && m >= 0 && n \[Element] Integers && n >= 0, Integrate[expr /. {l -> 2}, {x, 0, 1}]]]] // FullSimplify

output is:

b^k Gamma[1 + m] Gamma[ 1 + n] ((-1 + b)^2 Hypergeometric2F1Regularized[-k, 1 + m, 2 + m + n, 1 - a/b] + (a - b) (1 + m) (2 (-1 + b) Hypergeometric2F1Regularized[-k, 2 + m, 3 + m + n, 1 - a/b] + (a - b) (2 + m) Hypergeometric2F1Regularized[-k, 3 + m, 4 + m + n, 1 - a/b]))

And then I stopped because it is getting a bit tedious, but I think you get the point.

$\endgroup$
7
  • $\begingroup$ Thanks, it is promising indeed, though the step for l=3 (which takes a full 5 minutes on my computer) yields something which appears to break the logic. I suspect that the logic is actually valid and that the result is due to the simplification, which enables Mathematica to combine some of the Hypergeometric2F1Regularized summation into a new evaluation of Hypergeometric2F1Regularized with a different set of parameters, but I am not sure. I will update and/or edit my post as soon as I have done as much as I can using this method, but I am not yet sure this is the silver bullet. $\endgroup$
    – tyogi
    Commented Jan 3, 2023 at 3:15
  • $\begingroup$ @sg1234 it's quite possible that things don't work out nicely in all generality. I only meant to offer some hints. For instance, the first is to use assumptions on variables since you know them and then evaluate for low values and see how far you can go. if there are any additional assumptions that we could feed into Mma that would be helpful I think. it's also possible that there's not a nice way of expressing the result for general values even though it works for low l $\endgroup$
    – bmf
    Commented Jan 3, 2023 at 3:27
  • 1
    $\begingroup$ absolutely, and I forgot to mention how grateful I am for you showing me how to include assumptions! The integer ones are not that helpful (on my version, removing them simply swaps factorials for Gamma functions), but the others definitely make the results way more understandable. I also forgot to mention that those properties are actually true for k and l as well, will make a small update in my question regarding that. My version of MMA actually yields a different (but equivalent) answer to yours for l=1, so it's possible that the problem I get for l=3 is not a problem on newer versions... $\endgroup$
    – tyogi
    Commented Jan 3, 2023 at 3:43
  • $\begingroup$ @sg1234 ok good, that's useful hints and added information. keep in mind that I am using version 12 right now. it's possible that version 13 is even better. $\endgroup$
    – bmf
    Commented Jan 3, 2023 at 3:57
  • $\begingroup$ I am using version 10, and I am unable to extrapolate anything for l=3, and I do not have enough from l=0, l=1 and l=2 to know what the nested terms could look like... $\endgroup$
    – tyogi
    Commented Jan 3, 2023 at 4:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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