4
$\begingroup$

I want to plot the following function:

$$\int \left(\frac{\Gamma (x+1)}{2}-\frac{\Gamma (x-1)}{2}\right) \, dx$$

$\endgroup$
4
  • $\begingroup$ what are the limits of integration $\endgroup$ – k_v Mar 28 '15 at 11:05
  • $\begingroup$ @k_v I want to plot the indefinite integral of this function. $\endgroup$ – Anixx Mar 28 '15 at 11:14
  • $\begingroup$ this integral may be calculated only numerically, and one of the limits of integration is requared to define the function $\endgroup$ – k_v Mar 28 '15 at 11:17
  • $\begingroup$ @k_v so how can I plot it? $\endgroup$ – Anixx Mar 28 '15 at 11:28
9
$\begingroup$
g[x_]=Gamma[x+1]/2-Gamma[x-1]/2 // FunctionExpand

(-(1/2) + 1/2 (-1 + x) x) Gamma[-1 + x]

f[y_] := NIntegrate[g[x], {x, 2, y}]

Plot[f[x], {x, 2, 10}]

enter image description here

$\endgroup$
4
  • $\begingroup$ Why NIntegrate does not work inside plot? $\endgroup$ – Anixx Mar 28 '15 at 17:25
  • $\begingroup$ this works Plot[NIntegrate[g[x], {x, 2, y}], {y, 2, 10}] $\endgroup$ – k_v Mar 28 '15 at 17:31
  • $\begingroup$ I have tried before asking this question, it does not. $\endgroup$ – Anixx Mar 28 '15 at 17:32
  • $\begingroup$ @Anixx I does work. What Mathematica version are you running? $\endgroup$ – m0nhawk Mar 29 '15 at 11:35
2
$\begingroup$

You could use NDSolveValue to integrate the function:

int = NDSolveValue[
    {
    f'[x] == Gamma[x+1]/2-Gamma[x-1]/2,
    f[2] == 0
    },
    f,
    {x, 2, 10}
];

Visualization:

Plot[int[x], {x, 2, 10}]

enter image description here

$\endgroup$
1
$\begingroup$

It may be interesting to plot both $f(x)$ and $g(x)$ (blue and yellow curves, respectively) on a logarithmic scale:

LogPlot[{f[x],g[x]}, {x, 2, 30}, Frame -> True, Axes -> False]

enter image description here

$\endgroup$

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.