0
$\begingroup$

I'm new to Mathematica, and trying to plot a function, but stuck at integrating the function for hours. What I want to do is to plotting the following function with respect to $x$. $$-\int^1_0\sum^n_{i=1}{n-1\choose i-1}^2(x-y)^2(xy)^{2i-2}(1-x^2)^{n-i}(1-y^2)^{n-i}2ydy$$ To do so, I defined a function $h$ which has 4 variable

h[x_, y_, i_, n_] = -(Binomial[n - 1, i - 1])^2*((x - y)^2)*(x y)^(2 i - 2) ((1 - x^2) (1 - y^2))^(n - i) 2 y 

But I can't figure out how to make a summation over $i$ and then how to integrate with respect to $y$.

What should I do if I want to do the integration and summation of this multivariable function?

$\endgroup$
7
  • $\begingroup$ You need a space (or *) in xy. $\endgroup$ Commented Aug 28, 2017 at 20:30
  • $\begingroup$ I tried Sum[h[,,i,n],{i,n}], but it processed nothing.. $\endgroup$ Commented Aug 28, 2017 at 20:33
  • $\begingroup$ First integrating and then doing the summation returns an answer. $\endgroup$ Commented Aug 28, 2017 at 20:36
  • $\begingroup$ Oh my god.. Thank you so much for the help. It works!!!! By the way, I can remove the $\{x,0,1\}$ term because I integrate only w.r.t. $y$, right? $\endgroup$ Commented Aug 28, 2017 at 20:37
  • $\begingroup$ Thank you so much for your help. One thing I noticed is that If I run the code for $n=2$, n = 2; Integrate[Sum[h[x, y, i, n], {i, 1, n}], {y, 0, 1}], The output has $y$ inside in it. Something like $\frac{1}{6}+\cdots+x^2xy^2$. Why isn't the $y$ term integrated out? $\endgroup$ Commented Aug 28, 2017 at 20:46

1 Answer 1

3
$\begingroup$

Consolidating comments and using assumptions and simplifications

h[x_, y_, i_, n_] = -Binomial[n - 1, i - 1]^2*(x - y)^2*(x y)^(2 i - 2) ((1 - x^2) (1 - y^2))^(n - i) 2 y; 

Integrate each term

f[x_, i_, n_] = Assuming[Element[{i, n}, Integers] && 1 <= i <= n, Integrate[h[x, y, i, n], {y, 0, 1}] // Simplify] (* -x^(2 (-1 + i)) (1 - x^2)^(-i + n) Binomial[-1 + n, -1 + i]^2 (-i + n)! (-((2 x Gamma[1/2 + i])/ Gamma[3/2 + n]) + ((i + (1 + n) x^2) Gamma[i])/Gamma[2 + n]) *) 

Sum the integrals

g[x_, n_] = Assuming[Element[n, Integers] && n >= 1, Sum[f[x, i, n], {i, n}] // FullSimplify] (* -((1 + 2 n x^2)/(n + n^2)) + 1/Gamma[3/2 + n] Sqrt[π] x (1 - x^2)^(-1 + n) Gamma[n] Hypergeometric2F1[3/2, 1 - n, 1, x^2/(-1 + x^2)] *) 
$\endgroup$
1
  • $\begingroup$ This is perfect. Thank you so much. Today is my first day studying Mathematica, and this helped me a lot! $\endgroup$ Commented Aug 28, 2017 at 23:52

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.