Calculating probability If $f(x,y)=2x , 0\leq x\leq 1 ,0\leq y\leq 1 $, find $ P(Y < e^{-X} \cap X > Y)$ Given X and Y have joint distribution.
Here is my approach:
$$ P(Y < e^{-X} \cap X > Y) =  1-  P(Y > e^{-X} \cap X > Y)$$
= $1- P(X > Y > e^{-X})$ = $P(e^{-X} \leq Y \leq X )$
=$ \int_0^1\int_{e^{-x}}^x2x dydx $
=  $2e^{-1} - \frac{1}{3}$
Is my solution for this problem correct?
Thanks!
 A: An event for a bivariate random variable $(X,Y)$ is any set of possible outcomes to which a probability can meaningfully be assigned.  Examples are the set of outcomes $(x,y)$ such that $y\lt e^{-x},$ the set for which $x\gt y,$ and their intersection (about which the question is concerned).
The probability of any event is the volume under the graph of $f$ subtending that event.  We can draw a picture of this probability:

The open (dark yellow) chamber is bounded at the bottom by $y=0$, on the right by $x=1$, on the upper right by $y=e^{-x}$, on the upper left by $y=x$, and above by the graph of $f$.  The rest of the graph of $f$ is shown in dark blue with a mesh.
The calculation of this volume can be carried out in two parts: first, the integral over $x=0$ to $x=x_0$ where $(x_0, x_0) = (x_0, e^{-x_0})$ is the point at which the two graphs $y=x$ and $y=e^{-x}$ intersect.  ($x_0\approx 0.567$.)  

Second, the integral from $x=x_0$ to $x=1$.

The probability is
$$\int_0^{x_0} \int_0^x 2x\ dy dx + \int_{x_0}^1\int_0^{e^{-x}} 2x\ dy dx$$
$$= 2\frac{x_0^3}{3} + 2\left(\frac{2}{e} + x_0 + x_0^2\right)$$
$$\approx 0.427687.$$
Notice this differs from $2/e - 1/3\approx 0.402426.$

With problems like this it can be helpful (and often insightful) to double-check one's answer with a simulation.  This requires us to write code to draw values of $(X,Y)$ from the specified distribution.  In this case, notice that $Y$ has a uniform distribution independent of $X$ and that the distribution function of $X$ (for $0\le x \le 1)$
$$F_X(x) = \int_{0}^x\int_{0}^{1} f(t,y)\ dy dt = x^2.$$
Therefore, since the inverse of $F_X$ is the square root (restricted to arguments between $0$ and $1$), $X$ is distributed as the square root of a uniform distribution.
The following R code generates ten million independent realizations of $(X,Y)$.  It estimates the desired probability as the fraction of realizations in which the event occurs.  It also computes its standard error:
n<- 10^7                  # Number of realizations
set.seed(17)              # Allows this calculation to be reproduced
x <- sqrt(runif(n))       # The X values
y <- runif(n)             # The Y values
i <- y < exp(-x) & x > y  # Indicator of the event
mean(i)                   # Estimated probability
sd(i) / sqrt(length(i))   # Standard error of the estimate

After $1.7$ seconds of computation, this simulation yields a probability estimate of $0.42769$ with a standard error of $0.00016$.
(This simulation could be made several times faster, but it does the job in reasonable time and has the merit of being such a direct translation of the original question that it evidently is correct code.)
Doing this simulation would have cast strong doubt on the validity of $0.4024$ as an answer, because that is $160$ standard errors too low (and more than three SEs would be suspicious).  Indeed, even $0.4291$ is suspicious because it is $9$ SEs higher than the estimate.  In contrast, the answer developed here ($0.427687$) differs from the estimate by only $0.03$ standard errors: it is bang on.
