# PDF of $Y - (X - 1)^2$ for $(X, Y)$ uniform on $[0, 2] \times [0, 1]$

I am trying to find the p.d.f (but will calculate the c.d.f first) of $Z = Y - {(X - 1)}^2$ knowing that $(X, Y)$ is distributed uniformly on $[0, 2] \times [0, 1]$. So, $$f_{X, Y}(x, y) = \begin{cases}\frac{1}{2} & (x, y) \in [0, 2] \times [0, 1] \\ 0 & \text{otherwise} \end{cases}$$

$$F_Z(z) = P_{X, Y}(\left\{(x, y): y - {(x - 1)}^2 \leq z\right\})$$

I understand that $z$ changes in: $z \leq - 1$, $- 1 < z \leq 0$, $0 < z \leq 1$ and $z > 1$

When $z \leq - 1$: $F_Z(z) = 0$ and when $z > 1$: $F_Z(z) = 1$. My question is regarding $- 1 < z \leq 0$ and $0 < z \leq 1$. This is what I got: $$F_Z(z) = \begin{cases}2 \cdot (\int\limits_0^{1 - \sqrt{-z}} \int\limits_0^{z + {(x - 1)}^2} \frac{1}{2}\,\mathrm{d}y\,\mathrm{d}x) & - 1 < z \leq 0 \\ \int\limits_{1 - \sqrt{1 - z}}^{1 + \sqrt{1 - z}} \int\limits_{z + {(x - 1)}^2}^1 \frac{1}{2}\,\mathrm{d}y\,\mathrm{d}x & 0 < z \leq 1 \end{cases}$$

Do you agree with the definition of the c.d.f? I am asking because finding the integrals (especially the integration limits) was a bit tricky.

Finally, assuming that the c.d.f is correct, I did the derivative and got the following p.d.f:

$$f_Z(z) = \begin{cases}1 - \sqrt{-z} & - 1 < z \leq 0 \\ \sqrt{-(z - 1)} & 0 < z \leq 1 \\ 0 & \text{otherwise} \end{cases}$$

Although your final formula is correct (kudos for that), let me advocate a more systematic approach. Be warned though that this approach avoids nearly all head-scratching, hence it is not suitable to anybody preferring this kind of experience (that is, head-scratching) to the banal application of some routine and very sure procedure.

First step: Write down the density correctly.

That is, recall that the density $f$ of the distribution of $(X,Y)$ is defined on the whole space $\mathbb R^2$ hence one should define the function $f$ everywhere and avoid cases. This is easily done, using indicator functions. Here, for every $(x,y)$ in $\mathbb R^2$, $$f(x,y)=\frac12\mathbf 1_{0\leqslant x\leqslant 2,0\leqslant y\leqslant 1}.$$

Second step: Use the functional approach.

That is, try to reach the identity $$E[u(Z)]=\int_\mathbb R u(z)g(z)\mathrm dz,$$ for every bounded measurable function $u$. If this is done, one knows that $g$ is the density of $Z$.

To do so, note that, by definition of the distribution of $(X,Y)$ as the measure with density $f$, $$E[u(\color{red}{Y-(X-1)^2})]=\iint_{\mathbb R^2} u(\color{red}{y-(x-1)^2})f(x,y)\mathrm dx\mathrm dy,$$ hence the goal is to equate the RHS of the two last displayed equations. Note that nothing we wrote until now is case-specific hence these steps will always be the same (boring, I told you).

Third step: Choose a change of variable.

Here, $(x,y)\to(z,t)$ where, obviously, $z=\color{red}{y-(x-1)^2}$ and $t$ is almost free. A plausible choice is $t=x-1$ (but others are equally handy). This is the first moment when one should be half-awake.

One must also express the old variables $(x,y)$ in terms of the new variables $(z,t)$ (second half-awake moment). Here, $(x,y)=(t+1,z+t^2)$.

Fourth step: Proceed with the change of variable by computing the associated Jacobian.

Here, $\mathrm dx=\mathrm dt$ hence $\mathrm dx\mathrm dy=\mathrm dt\mathrm dz$, hence the Jacobian (third half-awake moment) is $1$ and $$E[u(Z)]=\iint_{\mathbb R^2} u(z)f(t+1,z+t^2)\,1\,\mathrm dz\mathrm dt,$$ which indicates that $$g(z)=\int_\mathbb Rf(t+1,z+t^2)\mathrm dt,$$ that is, in the present case, $$g(z)=\int\frac12\mathbf 1_{0\leqslant t+1\leqslant 2,0\leqslant z+t^2\leqslant 1}\mathrm dt=\frac12\int_{-1}^1\mathbf 1_{-z\leqslant t^2\leqslant 1-z}\mathrm dt.$$ Now the identification of $g$, which in general is pretty fast but in your case is actually rather tedious. One has:

• If $z\gt1$, then $t^2\leqslant 1-z$ never happens.
• If $0\lt z\lt1$, then $-z\leqslant t^2\leqslant 1-z$ and $-1\lt t\lt1$ happens when $-\sqrt{1-z}\leqslant t\leqslant\sqrt{1-z}$.
• If $-1\lt z\lt0$, then $-z\leqslant t^2\leqslant 1-z$ and $-1\lt t\lt1$ happens when $-1\leqslant t\leqslant-\sqrt{-z}$ or $\sqrt{-z}\leqslant t\leqslant1$.
• If $z\lt-1$, then $-z\leqslant t^2$ and $-1\lt t\lt1$ never happens.

This shows that $$\color{green}{g(z)=\sqrt{1-z}\,\mathbf 1_{0\lt z\lt1}+(1-\sqrt{-z})\,\mathbf 1_{-1\lt z\lt0}}.$$

Final step: Check that the result is plausible in every way you can think of.

Do not omit this final step. Here, check at least that $g\geqslant0$ everywhere and that the integral of $g$ on $\mathbb R$ is $1$ (otherwise something went amiss). Et voilà!

• This is a great answer. – Emily Nov 13 '13 at 21:01
• I like your precise reply very much, but I can't understand one thing. I haven't heard about such property, that $g(x)$ is density if for every measurable function $u$ holds $\mathbb{E} (u(X))=\int_{\mathbb{R}} u(x)g(x) \mathbb{d}x$. Could you please give me a refference or most conviniently a link to a pdf about this fact? Thanks in advance. – 3dok Nov 13 '13 at 21:33
• Thanks for taking the time to write an answer, Did. I'm a CompSci student currently taking probability. Unfortunately classes are not good, and the resources I found on this subject were too advanced for me to understand. I always like to think, and trust me; I came here because I would like to validate what I did after several hours of reading and reasoning. Although your approach might be systematic, I do not understand because I lack knowledge. What resource do you recommend? – David Robert Jones Nov 13 '13 at 21:39
• @3dok and David: Probability with martingales, David Williams. – Did Nov 13 '13 at 21:56
• dartmouth.edu/~chance/teaching_aids/books_articles/… – Did Nov 13 '13 at 21:58

$\newcommand{\+}{^{\dagger}}% \newcommand{\angles}[1]{\left\langle #1 \right\rangle}% \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}% \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}% \newcommand{\dd}{{\rm d}}% \newcommand{\isdiv}{\,\left.\right\vert\,}% \newcommand{\ds}[1]{\displaystyle{#1}}% \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}% \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}% \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}% \newcommand{\ic}{{\rm i}}% \newcommand{\imp}{\Longrightarrow}% \newcommand{\ket}[1]{\left\vert #1\right\rangle}% \newcommand{\pars}[1]{\left( #1 \right)}% \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\pp}{{\cal P}}% \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}% \newcommand{\sech}{\,{\rm sech}}% \newcommand{\sgn}{\,{\rm sgn}}% \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}}% \newcommand{\verts}[1]{\left\vert #1 \right\vert}% \newcommand{\yy}{\Longleftrightarrow}$

\begin{align} &{\cal P}\pars{Z} = \int_{0}^{2}\dd X\,{1 \over 2} \int_{0}^{1}\dd Y\,\delta\pars{Z - Y + \bracks{X- 1}^{2}} \\[3mm]&= {1 \over 2}\int_{0}^{2}\Theta\pars{Z + \bracks{X- 1}^{2}} \Theta\pars{1 - Z - \bracks{X- 1}^{2}}\,\dd X \\[3mm]&= \int_{0}^{1}\Theta\pars{Z + X^{2}}\Theta\pars{1 - Z - X^{2}}\,\dd X = \left.X\Theta\pars{Z + X^{2}}\Theta\pars{1 - Z - X^{2}}\right\vert_{X=0}^{X=1} \\[3mm]&- \int_{0}^{1}X\braces{% \delta\pars{Z + X^{2}}\pars{2X}\Theta\pars{1 - Z - X^{2}} + \Theta\pars{Z + X^{2}} \delta\pars{1 - Z - X^{2}}\pars{-2X} }\,\dd X \\[3mm]&= \Theta\pars{Z + 1}\Theta\pars{-Z} - 2\pars{-Z}\Theta\pars{1}\int_{0}^{1}\delta\pars{Z + X^{2}}\,\dd X + 2\pars{1 - Z}\Theta\pars{1}\int_{0}^{1}\delta\pars{1 - Z - X^{2}}\,\dd X \\[3mm]&= \Theta\pars{Z + 1}\Theta\pars{-Z} + 2Z\Theta\pars{-Z}\int_{0}^{1}{\delta\pars{X - \root{-Z}} \over 2\root{-Z}}\,\dd X \\[3mm]&+ 2\pars{1 - Z}\Theta\pars{1 - Z}\int_{0}^{1}{\delta\pars{X - \root{1 - Z}} \over 2\root{Z - 1}}\,\dd X \\[3mm]&= \Theta\pars{Z + 1}\Theta\pars{-Z} - \root{-Z}\Theta\pars{-Z}\Theta\pars{Z + 1} + \root{Z - 1}\Theta\pars{Z}\Theta\pars{1 - Z} \end{align}

$$\color{#0000ff}{\large% {\cal P}\pars{Z} = \left\lbrace% \begin{array}{lcl} 1 - \root{-Z} & \mbox{if} & -1\ <\ Z\ <\ 0 \\[2mm] \root{1 - Z} & \mbox{if} & \phantom{-}0\ <\ Z\ <\ 1 \\[2mm] 0 && \mbox{otherwise} \end{array}\right.}$$

• Thanks Felix. Unfortunately your answer is too advanced for me. – David Robert Jones Nov 13 '13 at 20:38
• May I ask what does $\Theta (Z)$ mean? $\delta$ is Dirac delta, right? – 3dok Nov 13 '13 at 21:50
• @3dok $\large\Theta$ is Step or/and Heaviside function. $\large\Theta\left(Z\right) = 1$ if $\large Z > 0$ and $\large 0$ if $\large Z < 0$. Yes, $\large\delta$ is Dirac delta. – Felix Marin Nov 14 '13 at 4:37

Given: the joint pdf of $$(X,Y)$$ is $$f(x,y)$$:

(source: tri.org.au)

Some neat solutions have been posted showing all the manual steps which involve some work. Alternatively (or just to check your work), most of this can be automated which makes solving it really quite easy. Basically, it is a one-liner:

The cdf of $$Z = Y-(X-1)^2$$ is $$P(Z:

(source: tri.org.au)

where Prob is a function from the mathStatica add-on to Mathematica (I am one of the authors of the former).

The pdf of $$Z$$ is, of course, just the derivative of the cdf:

(source: tri.org.au)

All done.