- When solving a problem i met an integral that:

$$int_0^infty ln(x)x^ae^{-x}dx$$

Where a is a complex number with a negative real part. Any ideas for solving it? - And other one is:

$$int_0^infty x^ae^{-x}dx$$

I tried to use gamma function to solve it, however the result is $Gamma(a)$ and a, as I mentioned is a complex number with neagative real part so any ideas to expansion it? I need some approximation for it or some series then I can try to cut that off.

# Tag: integration

## Server Bug Fix: Is it impossible in Salesforce to authorize a URL endpoint (in remote site settings) that contains an underscore?

I just discovered that we cannot access from Salesforce any URL which contains an underscore (_). When you try to enter a URL with an underscore in remote site settings, you get the error below. I assumed there would be a simple solution to this, but after searching I’ve found nothing at all. Is there something obvious I missing?

RFC 2872 allows underscores for subdomains, as written in your example, but not all services support this nomenclature. Unfortunately, at this time, you’ll need to choose a hostname and subdomain that does not include underscores. In particular, you also won’t be able to reference sandboxes that include an underscore in its name, so you should avoid naming sandboxes this way.

Thanks, the funny thing I discovered is that this is easy to work around by using a named credential, there is no problem using an underscore there. You would think if Salesforce allows it in named credentials, it would allow it in remote site settings.

## Math Genius: Finding the Volume of a Torus by rotating a circle with equation $x^2 + (y-R)^2 = r^2$ a different way

I was trying to find the Volume of a Torus and after sketching it out in Desmos, I thought I found a solution but it doesn’t work (or at least when I evaluated it it didn’t work).

$V = 2πint_{-r}^r(sqrt{r^2-x^2}+R)^2-R^2 dx$

My reasoning was that I would take the integral of the top half of the circle subtracted by the integral of the line cutting the circle in half and then multiply the whole thing by two to get the total volume. Any help would be appreciated, thanks!

## Math Genius: Evaluating the Integral of a vector field

I am trying to find a loop intergral of a vector field F on a closed curve but I have no idea how to show it since the polynomials are not specified.

Given that the polynomials P,Q,R are in one variable and $F(x,y,z) = f(|r|)(P(x),Q(y),R(z))$, whereby $|r| = sqrt{x^2 +y^2+ z^2}$ and $f: mathbb{R}_{+} rightarrow mathbb{R} $ is any smooth function

. The aim is to find a loop integral of $F$ evaluated on any simple closed curve $gamma$ on the sphere $S_{R}^{2}$ and $R >0$ be arbitrary.

Let $gamma$ be a closed curve on the sphere $S^2_{R_0}$ for some arbitrary

$R_0 > 0$ (I write $R_0$ to distinguish this radius from the polynomial named $R$).

Let $k = f(R_0).$ Note that $k$ is a simple number that can never change unless we change the value of $R_0$ (and hence have a different sphere and presumably also a different curve).

Then for any point $(x,y,z)$ on the curve $gamma,$

$$ F(x,y,z) = k(P(x), Q(y), R(z)).$$

Hence the integral of $F(x,y,z)$ over $gamma$ is the same as the integral of

$k(P(x), Q(y), R(z)).$

But

$$ k(P(x), Q(y), R(z)) = k(P(x), 0, 0) + k(0, Q(y), 0) + k(0, 0, R(z)). $$

Integrate the three functions on the right-hand side separately over $gamma,$

then add the results.

## Math Genius: Is there a simple expression for the antiderivative of $frac{cos^n(x)dx}{1+cos(x)}$

I am looking for the antiderivative $$int frac{cos^n(x)dx}{1+cos(x)}$$

at $ (0,frac{pi}{2})$.

i used the substitution $$t=tan(frac{x}{2})$$

to get

$$int Bigl(frac{1-t^2}{1+t^2}Bigr)^ndt$$

I can’t see how to continue and i think there could be a simpler way to do it.

Thanks in advance for time.

Let $ n $ be a positive integer, using geometric series formula, we have for any $ xinmathbb{R} $ :begin{aligned}sum_{k=0}^{n-1}{left(-1right)^{k}cos^{k}{x}}=frac{1-left(-1right)^{n}cos^{n}{x}}{1+cos{x}}end{aligned} Thus : begin{aligned}frac{cos^{n}{x}}{1+cos{x}}=frac{left(-1right)^{n}}{1+cos{x}}-sum_{k=0}^{n-1}{left(-1right)^{n-k}cos^{k}{x}}end{aligned}

Hence : begin{aligned}int{frac{cos^{n}{x}}{1+cos{x}},mathrm{d}x}=left(-1right)^{n}int{frac{mathrm{d}x}{1+cos{x}}}-sum_{k=0}^{n-1}{left(-1right)^{n-k}int{cos^{k}{x},mathrm{d}x}}end{aligned}

Using the fact that $ cos^{k}{x}=frac{1}{2^{k}}sumlimits_{p=0}^{k}{binom{k}{p}cos{left(left(k-2pright)xright)}} $, and that $ 1+cos{x}=2cos^{2}{left(frac{x}{2}right)} $, we get : begin{aligned}int{frac{cos^{n}{x}}{1+cos{x}},mathrm{d}x}&=left(-1right)^{n}int{frac{mathrm{d}x}{2cos^{2}{left(frac{x}{2}right)}}}-sum_{k=0}^{n-1}{sum_{p=0}^{k}{left(-1right)^{n-k}binom{k}{p}frac{1}{2^{k}}int{cos{left(left(k-2pright)xright)},mathrm{d}x}}}\ &=left(-1right)^{n}tan{left(frac{x}{2}right)}-sum_{k=0}^{n-1}{sum_{p=0}^{k}{left(-1right)^{n-k}binom{k}{p}frac{f_{k,p}left(xright)}{2^{k}}}}+Cend{aligned}

Where $ f_{k,p}left(xright)=leftlbracebegin{aligned}frac{sin{left(left(k-2pright)xright)}}{k-2p} &textrm{If }kneq 2p\ x &textrm{If }k=2pend{aligned}right. cdot $

## Math Genius: General mean value theorem for integrals

Studying changing variables under multiple integrals i have encountered such statement:

Using mean value theorem for integral we get:

$ intlimits_{T(B_j)} f(y) dy= f(y_j)v(T(B_j) $ for some $y_j=T(x_j)in T(B_j) $

What does mean $v$ in $v(T(B_j))$?

## Math Genius: Is there a simple expression for the antiderivative of $frac{cos^n(x)dx}{1+cos(x)}$

I am looking for the antiderivative $$int frac{cos^n(x)dx}{1+cos(x)}$$

at $ (0,frac{pi}{2})$.

i used the substitution $$t=tan(frac{x}{2})$$

to get

$$int Bigl(frac{1-t^2}{1+t^2}Bigr)^ndt$$

I can’t see how to continue and i think there could be a simpler way to do it.

Thanks in advance for time.

Let $ n $ be a positive integer, using geometric series formula, we have for any $ xinmathbb{R} $ :begin{aligned}sum_{k=0}^{n-1}{left(-1right)^{k}cos^{k}{x}}=frac{1-left(-1right)^{n}cos^{n}{x}}{1+cos{x}}end{aligned} Thus : begin{aligned}frac{cos^{n}{x}}{1+cos{x}}=frac{left(-1right)^{n}}{1+cos{x}}-sum_{k=0}^{n-1}{left(-1right)^{n-k}cos^{k}{x}}end{aligned}

Hence : begin{aligned}int{frac{cos^{n}{x}}{1+cos{x}},mathrm{d}x}=left(-1right)^{n}int{frac{mathrm{d}x}{1+cos{x}}}-sum_{k=0}^{n-1}{left(-1right)^{n-k}int{cos^{k}{x},mathrm{d}x}}end{aligned}

Using the fact that $ cos^{k}{x}=frac{1}{2^{k}}sumlimits_{p=0}^{k}{binom{k}{p}cos{left(left(k-2pright)xright)}} $, and that $ 1+cos{x}=2cos^{2}{left(frac{x}{2}right)} $, we get : begin{aligned}int{frac{cos^{n}{x}}{1+cos{x}},mathrm{d}x}&=left(-1right)^{n}int{frac{mathrm{d}x}{2cos^{2}{left(frac{x}{2}right)}}}-sum_{k=0}^{n-1}{sum_{p=0}^{k}{left(-1right)^{n-k}binom{k}{p}frac{1}{2^{k}}int{cos{left(left(k-2pright)xright)},mathrm{d}x}}}\ &=left(-1right)^{n}tan{left(frac{x}{2}right)}-sum_{k=0}^{n-1}{sum_{p=0}^{k}{left(-1right)^{n-k}binom{k}{p}frac{f_{k,p}left(xright)}{2^{k}}}}+Cend{aligned}

Where $ f_{k,p}left(xright)=leftlbracebegin{aligned}frac{sin{left(left(k-2pright)xright)}}{k-2p} &textrm{If }kneq 2p\ x &textrm{If }k=2pend{aligned}right. cdot $

## Math Genius: Cauchy’s Residue Theorem multiple choice question.

Consider the real integral $I=int^{infty}_{- infty} frac{1}{1+x^2} dx$. This can be computed using Cauchy’s Residue Theorem. Which one of the following is false?

A) Let $γ(R)$ be a semicircle of radius $R > 1$ traced anticlockwise, centred at the origin and closed in the lower half of the complex plane. Then $I= lim_{R to infty} oint_{γ(R)} frac{1}{1+z^2}dz$.

B) Let $γ(R)$ be a semicircle of radius $R > 1$ traced clockwise, centred at the origin and closed in the lower half of the complex plane. Then $I= lim_{R to infty} oint_{γ(R)} frac{1}{1+z^2}dz$.

C) $I= 2 pi i text{Res}(frac{1}{1+z^2}, z=i)$.

D) $I= -2 pi i text{Res}(frac{1}{1+z^2}, z=-i)$.

E) None of the above.

My answer is E), so I am saying that none of the above are false, is this correct? I have this answer because both C and D give me the right result, then A is correct according to my lecture notes. I guess the only one that I am doubting is B.

## Math Genius: Expectation of sample range for an exponential distribution

$X_1, ldots , X_n$, $n ge 4$ are independent random variables with exponential distribution: $fleft(xright) = mathrm{e}^{-x}, xge 0$. We define $$R= max left( X_1, ldots , X_nright) – min left( X_1, ldots , X_nright)$$

Calculate $mathbb{E}R$.

So I know that: $$mathbb{E}R =mathbb{E}left( max left( X_1, ldots , X_nright) right)- mathbb{E}left(min left( X_1, ldots , X_nright)right)$$

And I can calculate

$$mathbb{E}left(min left( X_1, ldots , X_nright)right) = intlimits_{0}^{infty}left(1-F_{min}left(xright)right) mathrm{dx}=intlimits_{0}^{infty}left(mathrm{e}^{-nx}mathrm{dx} right) = frac{1}{n}$$.

The problem is to calculate:

$$mathbb{E}left(max left( X_1, ldots , X_nright)right) = intlimits_{0}^{infty}x cdot ncdot mathrm{e}^{-x}left( 1-mathrm{e}^{-x}right)^{n-1} mathrm{dx} = ldots$$

I don’t know how to calculate the above integral.

Let $X_{(1)}<X_{(2)}<cdots<X_{(n)}$ be the order statistics corresponding to $X_1,X_2,ldots,X_n$.

Making the transformation $(X_{(1)},ldots,X_{(n)})mapsto (Y_1,ldots,Y_n)$ where $Y_1=X_{(1)}$ and $Y_i=X_{(i)}-X_{(i-1)}$ for $i=2,3,ldots,n$, we have $Y_i$ exponential with mean $1/(n-i+1)$ independently for all $i=1,ldots,n$.

Therefore, $$R=X_{(n)}-X_{(1)}=sum_{i=1}^n Y_i-Y_1=sum_{i=2}^n Y_i$$

Hence, $$mathbb E(R)=sum_{i=2}^n frac1{n-i+1}$$

A more elegant argument is provided in this answer by @Did.

Alternatively, we can proceed to find the expectation of $X_{(1)}$ and $X_{(n)}$ separately as you did. Clearly $X_{(1)}$ is exponential with mean $1/n$. And the density of $X_{(n)}$ is

$$f_{X_{(n)}}(x)=ne^{-x}(1-e^{-x})^{n-1}mathbf1_{x>0}$$

Therefore,

begin{align}

mathbb E(X_{(n)})&=int x f_{X_{(n)}}(x),dx

\&=nint_0^infty xe^{-x}(1-e^{-x})^{n-1},dx

\&=nint_0^1(-ln u)(1-u)^{n-1},du tag{1}

\&=nint_0^1 -ln(1-t)t^{n-1},dt tag{2}

\&=nint_0^1 sum_{j=1}^infty frac{t^j}{j}cdot t^{n-1},dt tag{3}

\&=nsum_{j=1}^infty frac1j int_0^1 t^{n+j-1},dt tag{4}

\&=nsum_{j=1}^infty frac1{j(n+j)}

\&=sum_{j=1}^infty left(frac1j-frac1{n+j}right)

\&=sum_{j=1}^n frac1j

end{align}

$(1)$: Substitute $e^{-r}=u$.

$(2)$: Substitute $t=1-u$.

$(3)$: Use Maclaurin series expansion of $ln(1-t)$ which is valid since $tin (0,1)$.

$(4)$: Interchange integral and sum using Fubini/Tonelli’s theorem.

We can also find the density of $R$ through the change of variables $(X_{(1)},X_{(n)})mapsto (R,X_{(1)})$ and find $mathbb E(R)$ directly by essentially the same calculation as above.

You can go for calculating another integral:

$$begin{aligned}mathbb{E}maxleft(X_{1},dots,X_{n}right) & =int_{0}^{infty}Pleft(maxleft(X_{1},dots,X_{n}right)>xright)dx\

& =int_{0}^{infty}1-Pleft(maxleft(X_{1},dots,X_{n}right)leq xright)dx\

& =int_{0}^{infty}1-left(1-e^{-x}right)^{n}dx\

& =int_{0}^{infty}sum_{k=1}^{n}binom{n}{k}left(-1right)^{k-1}e^{-kx}dx\

& =sum_{k=1}^{n}binom{n}{k}left(-1right)^{k-1}int_{0}^{infty}e^{-kx}dx\

& =sum_{k=1}^{n}binom{n}{k}left(-1right)^{k-1}left[-frac{e^{-kx}}{k}right]_{0}^{infty}\

& =sum_{k=1}^{n}binom{n}{k}left(-1right)^{k-1}frac{1}{k}

end{aligned}

$$

There might be a closed form for it, but I haven’t found it yet.

**Edit**:

According to the comment of @RScrlli the outcome can be proved to equal harmonic number: $$H_n=sum_{k=1}^nfrac1{k}$$

This makes me suspect that there is a way to find it as the expectation of:$$X_{(n)}=X_{(1)}+(X_{(2)}-X_{(1)})+cdots+(X_{(n)}-X_{(n-1)})$$

a clever probabilistic approach is one that takes advantage of the homogenous parameter $lambda_i =1$ for all, and the memorylessness of the exponential distribution (and the fact that there is zero probability for any $X_i = X_j$ for $ineq j)$.

$(X_1, X_2, …,X_n)$

we want $Ebig[max_i X_ibig]$

$max_i X_i$ is equivalent to the final arrival in a poisson process with intensity $n$ where intensity drops by one after each arrival

i.e. with

first arrival in $(X_1, X_2, …,X_n)$

this is equivalent to the merger of $n$ independent Poisson processes which results in a merged Poisson process with parameter $n$.

WLOG suppose $X_n$ is first arrival, then consider

first arrival in $(X_1, X_2, …,X_{n-1})$

by memorylessness we have a fresh start with $n-1$ independent Poisson processes which is a merged process with parameter $n-1$

and continue on until WLOG

we only want first arrival in $(X_1)$

so $max_i X_i =sum_{i=1}^n T_i$ where $T_i$ are the arrival times described above

$Ebig[max_i X_ibig] =sum_{i=1}^n Ebig[T_ibig] =sum_{i=1}^n frac{1}{n-i+1}= sum_{i=1}^nfrac{1}{n}$

really you should always *try* to exploit memorylessness when dealing with exponential r.v.’s

## Math Genius: Why is $int_0^{{9pi}over{4}}{1 over |sin x|+|cos x| }dx~ = ~9int_0^{{pi}over{4}}{1 over |sin x|+|cos x| }dx$?

$$int_0^{{9pi}over{4}}{1 over |sin x|+|cos x| }dx~ = ~9int_0^{{pi}over{4}}{1 over |sin x|+|cos x| }dx$$

$ 1 over |sin x|+|cos x| $ is $pi over 2$ periodic so

$$int_0^{{9pi}over{4}}{1 over |sin x|+|cos x| }dx~ = ~4int_0^{{pi}over{2}}{1 over |sin x|+|cos x| }dx~+~int_{2pi}^{{9pi}over{4}}{1 over |sin x|+|cos x| }dx~$$

I don’t see how to transfrom this to the desired integral, I suppose this isn’t the right way to start.

Hint:

The function has a symmetry about $x=fracpi4$, i.e. $f(x)=fleft(fracpi2-xright)$:

$$left|sinleft(fracpi2-xright)right|+left|cosleft(fracpi2-xright)right|=|cos x|+|sin x|.$$

**Idea**

Observe that $|sin x+|cos x|$ is equal to one of the following (depending on the signs taken in various intervals) $pm sin x pm cos x=sqrt{2}sinleft(xpm frac{pi}{4}right) text{ or } sqrt{2}cosleft(xpm frac{pi}{4}right)$.