TITLE: Knife inside the square
QUESTION [7 upvotes]: A square of side $n$ is drawn in the sand. A knife of length $k$ is thrown into the square. The tip of the knife lands inside the square, and then the knife falls down to the ground in a random direction. 
The location of the tip of the knife is uniformly distributed within the square, and the direction in which the knife falls to the ground is uniformly distributed in $(0,2\pi]$.
What is the probability that the entire length of the knife now lies inside the square? What happens when we replace the square with a circle of diameter $n$?

REPLY [3 votes]: We will only cover the first question of throwing a knife to a square in detail.  
Choose a coordinate system so that the square is $[0,n]^2$. Let 

$p, q$ be the landing positions for knife's tip and end.
$\theta$ be the angle between $x$-axis and knife's body. i.e.
$q - p = k_\theta \stackrel{def}{=} ( k \cos\theta, k \sin\theta )$
For any expression, let $(\cdots)_{+} = \max(\cdots,0)$ be a short hand of its positive part.
Let $\mathcal{E}$ be the event for the whole knife to lie within the square.

Since the square is convex, $\mathcal{E}$ is true if and only if $p , q \in [0,n]^2$.
This is equivalent to $p$ lies within a $(n - k|\cos\theta|)_{+} \times (n - k|\sin\theta|)_{+}$ rectangle. For example, when $\theta \in [0,\frac{\pi}{2}]$,
$$\begin{align}
p, q \in [0,n]^2 
& \iff  p \in [0,n]^2 \cap [ -k \cos\theta, n - k\cos\theta] \times [ -k \sin\theta, n - k\sin\theta]\\
& \iff p \in [0,n-k\cos\theta]\times[0,n-k\sin\theta]\end{align}$$
For general $\theta$, the conditional probability for event $\mathcal{E}$ is
$${\bf P}[\mathcal{E} | \theta ] = \left(1 - \frac{k}{n}|\cos\theta|\right)_{+}\left(1 - \frac{k}{n}|\sin\theta|\right)_{+}$$
Let $\alpha = \begin{cases}
0, & k \le n\\
\cos^{-1}\frac{n}{k}, & n < k < \sqrt{2} n\\
\frac{\pi}{4}, &  \sqrt{2} n \le k
\end{cases}$, the desired probability equals to
$$\begin{align} 
{\bf P}[\mathcal{E}] = & 
\frac{1}{2\pi} \int_0^{2\pi} {\bf P}[\mathcal{E} | \theta ] d\theta\\
= & \frac{1}{2\pi}\int_0^{2\pi}\left(1 - \frac{k}{n}|\cos\theta|\right)_{+}\left(1 - \frac{k}{n}|\sin\theta|\right)_{+} d\theta\\
= & \frac{2}{\pi}\int_0^{\frac{\pi}{2}} \left(1 - \frac{k}{n}\cos\theta\right)_{+}\left(1 - \frac{k}{n}\sin\theta\right)_{+} d\theta\\
= & \frac{2}{\pi}\int_\alpha^{\frac{\pi}{2}-\alpha}
\left(1 - \frac{k}{n}\cos\theta\right)\left(1 - \frac{k}{n}\sin\theta\right) d\theta\\
= & \frac{2}{\pi}\left[
\theta - \frac{k}{n}(\sin\theta - \cos\theta) + \frac{k^2}{2n^2}\sin^2\theta
\right]_{\alpha}^{\frac{\pi}{2}-\alpha}\\
= & \frac{2}{\pi}\left(\frac{\pi}{2} - 2\alpha - \frac{2k}{n}(\cos\alpha - \sin\alpha) + \frac{k^2}{2n^2}\cos(2\alpha)\right)
\end{align}$$
When $k \ge \sqrt{2}n$, this evaluates to $0$ as expected. For the more
interesting case $k \le n$, this simplifies to
$${\bf P}[\mathcal{E}] = 1 - \frac{4k}{\pi n} + \frac{k^2}{\pi n^2}$$
For the remaining case $n < k < \sqrt{2}n$, we have the horrible mess
$${\bf P}[\mathcal{E}] = 1 - \frac{4}{\pi}\cos^{-1}\frac{n}{k}
 - \frac{4}{\pi n}\left(n - \sqrt{k^2-n^2}\right) 
+ \frac{2n^2 - k^2}{\pi n^2}
$$
Update
For the second question, choose a coordinate system so that the "circle" is $B(0,\frac{n}{2})$, the disk centered at origin with diameter $n$.
In order for $p, q \in B(0,\frac{n}{2})$, we need $p \in B(0,\frac{n}{2}) \cap B(-k_\theta,\frac{n}{2})$. 
For any fixed $\theta$, the conditional probability becomes
$${\bf P}[\mathcal{E}|\theta] =
\frac{\verb/area/(B(0,\frac{n}{2}) \cap B(-k_\theta,\frac{n}{2}))}{\verb/area/(B(0,\frac{n}{2}))}
= \frac{\verb/area/(B(0,\frac{n}{2}) \cap B(-k_0,\frac{n}{2}))}{
\verb/area/(B(0,\frac{n}{2}))}
$$
Since the rightmost expression is independent of $\theta$, this is also 
the probability we seek. The end result is
$${\bf P}[\mathcal{E}] =
\begin{cases}
\frac{2}{\pi}\left(\cos^{-1}\frac{k}{n} - \frac{k}{n}\sqrt{1 - \frac{k^2}{n^2}}\right), & k < n\\
0, & k \ge n
\end{cases}$$