Question 1164488
```python?code_reference&code_event_index=1
import numpy as np

# Region: 0 < x < 1, 0 < y < x
# f(x, y) = 1/x

# Verify total probability
# integral_{0}^{1} integral_{0}^{x} (1/x) dy dx
# = integral_{0}^{1} [y/x]_{0}^{x} dx
# = integral_{0}^{1} 1 dx = 1. Correct.

# iv. P(X^2 + Y^2 <= 1 | X=x)
# Conditional pdf f(y|x) = f(x,y) / f_X(x)
# f_X(x) = integral_{0}^{x} (1/x) dy = 1 for 0 < x < 1.
# So f(y|x) = (1/x) / 1 = 1/x for 0 < y < x.
# We want P(Y^2 <= 1 - x^2 | X=x) = P(Y <= sqrt(1 - x^2) | X=x)
# Since the region is 0 < y < x:
# If sqrt(1 - x^2) >= x, then the entire range 0 < y < x is included.
# sqrt(1 - x^2) >= x  => 1 - x^2 >= x^2 => 1 >= 2x^2 => x <= 1/sqrt(2)
# If x <= 1/sqrt(2), P = 1.
# If x > 1/sqrt(2), P = integral_{0}^{sqrt(1-x^2)} (1/x) dy = sqrt(1-x^2)/x.

# v. P(X^2 + Y^2 <= 1)
# Total probability.
# P = integral_{0}^{1} P(X^2+Y^2 <= 1 | X=x) * f_X(x) dx
# P = integral_{0}^{1/sqrt(2)} 1 dx + integral_{1/sqrt(2)}^{1} (sqrt(1-x^2)/x) dx

from scipy.integrate import quad

term1 = 1/np.sqrt(2)
term2, _ = quad(lambda x: np.sqrt(1 - x**2) / x, 1/np.sqrt(2), 1)

total_prob = term1 + term2
print(f"Term 1: {term1}")
print(f"Term 2: {term2}")
print(f"Total Probability: {total_prob}")


```
```text?code_stdout&code_event_index=1
Term 1: 0.7071067811865475
Term 2: 0.1742668058329955
Total Probability: 0.8813735870195429

```
To solve these problems, we first need the marginal density $f_X(x)$ and the conditional density $f(y|x)$.

**Given:**
* $f(x, y) = \frac{1}{x}$ for $0 < x < 1$ and $0 < y < x$.
* The marginal density of $X$: $f_X(x) = \int_0^x \frac{1}{x} \, dy = [\frac{y}{x}]_0^x = 1$ for $0 < x < 1$.
* The conditional density of $Y$ given $X=x$: $f(y|x) = \frac{f(x,y)}{f_X(x)} = \frac{1/x}{1} = \frac{1}{x}$ for $0 < y < x$.

---

### **iv. Find $P(X^2 + Y^2 \le 1 \mid X = x)$**

This is the probability that $Y^2 \le 1 - x^2$ given a fixed $x$. This simplifies to $Y \le \sqrt{1 - x^2}$.
Since our variable $Y$ is bounded by $0 < y < x$, we have two cases based on whether the circle boundary $\sqrt{1 - x^2}$ is inside or outside the range of $y$:

1.  **Case 1: $x \le \sqrt{1 - x^2}$**
    This occurs when $x^2 \le 1 - x^2 \implies 2x^2 \le 1 \implies x \le \frac{1}{\sqrt{2}}$.
    In this case, the entire range of $y$ ($0 < y < x$) satisfies the condition.
    $$P(X^2 + Y^2 \le 1 \mid X = x) = 1$$

2.  **Case 2: $x > \frac{1}{\sqrt{2}}$**
    The condition $Y \le \sqrt{1 - x^2}$ is more restrictive than the boundary $y < x$.
    $$P(X^2 + Y^2 \le 1 \mid X = x) = \int_0^{\sqrt{1-x^2}} \frac{1}{x} \, dy = \frac{\sqrt{1-x^2}}{x}$$

**Result:**
$$P(X^2 + Y^2 \le 1 \mid X = x) = 
\begin{cases} 
1 & 0 < x \le \frac{1}{\sqrt{2}} \\
\frac{\sqrt{1-x^2}}{x} & \frac{1}{\sqrt{2}} < x < 1
\end{cases}$$

---

### **v. Find $P(X^2 + Y^2 \le 1)$**

We calculate this by integrating the conditional probability over the marginal density of $x$:
$$P(X^2 + Y^2 \le 1) = \int_0^1 P(X^2 + Y^2 \le 1 \mid X = x) f_X(x) \, dx$$
$$P = \int_0^{1/\sqrt{2}} (1)(1) \, dx + \int_{1/\sqrt{2}}^1 \frac{\sqrt{1-x^2}}{x} (1) \, dx$$

**Solving the integrals:**
1.  **First Part:** $\int_0^{1/\sqrt{2}} 1 \, dx = \frac{1}{\sqrt{2}} \approx 0.707$
2.  **Second Part:** For $\int \frac{\sqrt{1-x^2}}{x} dx$, we use the substitution $x = \sin\theta$:
    $$\int \frac{\cos\theta}{\sin\theta} \cos\theta \, d\theta = \int (\csc\theta - \sin\theta) \, d\theta = \ln|\csc\theta - \cot\theta| + \cos\theta$$
    Evaluating this from $x = \frac{1}{\sqrt{2}}$ ($\theta = \frac{\pi}{4}$) to $x = 1$ ($\theta = \frac{\pi}{2}$):
    $$\left[ \ln\left| \frac{1 - \sqrt{1-x^2}}{x} \right| + \sqrt{1-x^2} \right]_{1/\sqrt{2}}^1 = (0 + 0) - (\ln(\sqrt{2}-1) + \frac{1}{\sqrt{2}})$$
    $$\text{Second Part} = -\ln(\sqrt{2}-1) - \frac{1}{\sqrt{2}} \approx 0.881 - 0.707 = 0.174$$

**Total Probability:**
$$P = \frac{1}{\sqrt{2}} - \ln(\sqrt{2}-1) - \frac{1}{\sqrt{2}} = -\ln(\sqrt{2}-1) = \ln\left(\frac{1}{\sqrt{2}-1}\right) = \ln(1+\sqrt{2})$$
$$P \approx 0.8814$$

**Result:**
$$P(X^2 + Y^2 \le 1) = \ln(1 + \sqrt{2}) \approx 0.8814$$