TITLE: What's the probability that three points determine an acute triangle?
QUESTION [12 upvotes]: Three distinct points are chosen at random from the unit square. The goal is to find the probability that they form an acute triangle. I started working on this because I want to know how to approach a problem of this sort, where the sample space seems to be something like $[0,1]^2$. However I've had no experience dealing with pdf's on $[0,1]^2$, $\mathbb{R}^2$, etc. 
So far, given any two  points, I can find the probability that the third point will work via a simple geometry/area argument (see below). But then what to do with that? I suspect integration, but of what and over what domain?

Suppose $(a,b)$ and $(c,d)$ are two points in the square. Construct a line containing $(a,b)$ and a line containing $(c,d)$ so that both are perpendicular to the segment joining the points. The probability that the third point will work is the area of the region between the two lines and inside the square, but outside the circle whose diameter is the segment joining the points. (If the third point is inside the circle then an obtuse triangle is formed, and if the  third point is on the circle a right triangle is formed.)

REPLY [5 votes]: While I wouldn't want to quibble with @joriki's excellent answer, I can't help but think that there is a simpler solution. Remembering a bit from probability, here is an indication, as yet still incomplete, of how one might proceed.
I would start by formulating the problem as that of being given six i.i.d. uniform random variates as three pairs $\{(X_i,Y_i)\}_{i=1}^3\in[0,1]^{2\times3}$ considered as vertices $V_i$ of a triangle, each with angle $\Theta_i$ (allowing indices to "wrap" or "cycle" modulo $3$), and being asked for the probability that each $\Delta_{ij}=\operatorname{sign}(\cos\Theta_i)$ is positive. However, from the inner product formula
$$\cos\Theta_i
=(x_{i+1}-x_i)(x_{i-1}-x_i)
+(y_{i+1}-y_i)(y_{i-1}-y_i)$$
we can see that the problem can be reformulated
using intermediate variables $U=(x_1-x_3)(x_2-x_3)$
and $V$ independent but identically distributed to $U$,
by noting that
$$\cos\Theta_i
=U+V\,.$$
Before computing $Pr(U+V>0)$, let us compute $Pr(U>u)$,
from which the distribution of $U+V$ will follow.
To compute this for $u\in[-1,1]$,
let us call the variates $(x,y,z)$
rather than $(x_1,x_2,x_3)$
and start, for example, with $u=0$, for which
$$
Pr(U>0)=\int_0^1 \left(z^2+(1-z)^2\right)dz=\int_0^1(2w+1)\,dz=\frac23
$$
This can be seen by noting that, for $z\in(0,1)$ fixed (and $w=z^2-z$),
the product $(x-z)(y-z)$ is positive inside the squares
going from $(0,0)$ to $(z,z)$ and from $(z,z)$ to $(1,1)$
(the grey & green regions below),
and negative on the rest of $(x,y)\in[0,1]^2$ (in white & red).
For the general integral $Pr(U > u)$ with $u\in[-1,1]$,
instead of the bounding lines $x,y=z$,
we have the bounding curve $(x-z)(y-z)=u$,
which on $[0,1]^2$ has up to two components.
Here is a graph showing what the curves
(and regions) look like when $z=\frac25$ for
$U>.08$ (in green),
$U<-.08$ (red), and for
$U\in(0,.08)$ (grey).

$$
Pr(U>u)
=\int_{[0,1]^3} \chi\left((x-z)(y-z) > u\right) \,dx\,dy\,dz
=\int_0^1 A(u,z)\,dz$$
for the area function
$$
A(u,z) = \left\{\matrix{
0 &\quad& u &\ge& v &\quad&
u\ge\tfrac14~\vee~
u\in\left(0,\tfrac14\right) \wedge
z\in\left[0,\sqrt u\right]\cup\left[1-\sqrt u,1\right]
\\\\
A^+(u,z) &\quad& u &\in& \left(0,~ v\right) &\quad& 
u\in\left(0,\tfrac14\right) \wedge
z\in\left(\sqrt u,\,1-\sqrt u\right)
\\\\
2w+1 &\quad& u & = & 0 &\quad& 
u=0 \wedge
z\in\left[0,\,1\right]
\\\\
A^-(u,z) &\quad& u &\in& \left(w,~ 0\right) &\quad& 
u\in\left(-\tfrac14,\,0\right) \wedge
z\in\left(\tfrac12-\sqrt{u+\tfrac14},\,\tfrac12+\sqrt{u+\tfrac14}\right)
\\\\
0 &\quad& u &\le& w &\quad& 
u\le-\tfrac14 \vee \left|z-\frac12\right|>\sqrt{u+\frac14}
}\right.$$
where
$v=\min(z,~1-z)^2\in\left[0,~\frac14\right]$,
$w=z(z-1)\in\left[-\frac14,~0\right]$,
and $A^\pm(u,z)$ have yet to be determined
but are fairly clear from the sketch above.
Using symmetry about $y=x$ and, as reference values, the total area $1$
and $Pr(U>0)=\frac23$ as above (which has squares and no curves for all $z$),
we can write
$$
\eqalign{
A^+(u,z)
&= z^2 + (1-z)^2
 - 2 \int_{-z}^{-\min(z,\sqrt{u})}\left( \frac{u}{x}-x \right)\,dx
 - 2 \int_{\min(1-z,\sqrt{u})}^{1-z}\left( x-\frac{u}{x} \right)\,dx
\\
&= z^2 + (1-z)^2
 + \left[x^2-2u\ln|x|\right]_{-z,~1-z}^{-\min(z,\sqrt{u}),~\min(1-z,\sqrt{u})}
\\
&= \min(z^2,u)
 - u\ln\frac{\min(z^2,u)}{z^2}
 + \min\left((1-z)^2,u\right)
 - u\ln\frac{\min\left((1-z)^2,u\right)}{(1-z)^2}
\\
A^-(u,z)
&= 1
-\int_{-z}^{-\min\left(z,\,\frac{z-1}{u}\right)}\left(1-\frac{u}{x}\right)\,dx
-\int_{\min\left(1-z,~-\frac{z}{u}\right)}^{1-z}\left(1+\frac{u}{x}\right)\,dx
\\
&= 1
 - \Bigl[x\Bigr]
 _{ -z,~ \min\left(1-z,~-\frac{z}{u}\right)}
 ^{1-z,~-\min\left(z,\,\frac{z-1}{u}\right)}
 + u \Bigl[\ln|x|\Bigr]
 _{-z,~1-z}
 ^{-\min\left(z,\,\frac{z-1}{u}\right)
  ,~\min\left(1-z,~-\frac{z}{u}\right)}
\\
&= 2z
 +     \min\left(  z,\frac{ z-1}{u     }\right)
 -     \min\left(1-z,\frac{-z  }{u     }\right)
 + u\ln\min\left(1  ,\frac{ z-1}{u   z }\right)
 + u\ln\min\left(1  ,\frac{-z  }{u(1-z)}\right)
}
$$
where I have used multiple endpoints in the
bracketed antiderivative differences to save space.
This is indeed so far quite similar to Langford's 1969 solution,
the biggest differences being that he defines the CDF, $Pr(U\le u)$,
and expresses the boundaries directly in terms of $u$
rather than implicitly in terms of $z$ (and $v$ & $v$),
which I have now also done in the rightmost column above.
From this, we can see that we need only concern ourselves
with the two middle cases, $u\in\left(0,\tfrac14\right)$
and $u\in\left(-\tfrac14,0\right)$. In the former,
$$
\eqalign{
Pr(U>u)
&=\int_{\sqrt u}^{1-\sqrt u}A^+(u,z)\,dz\\
%&=\int_{\sqrt u}^{1-\sqrt u}\left[
%   \min(z^2,u)
% - u\ln\frac{\min(z^2,u)}{z^2}
% + \min\left((1-z)^2,u\right)
% - u\ln\frac{\min\left((1-z)^2,u\right)}{(1-z)^2}
%\right]dz\\
&=\int_{\sqrt u}^{1-\sqrt u}\left[
   u
 - u\ln\frac{u}{z^2}
 + u
 - u\ln\frac{u}{(1-z)^2}
\right]dz\\
&=2u\int_{\sqrt u}^{1-\sqrt u}\Bigl[ 1-\ln u + \ln z + \ln(1-z) \Bigr]dz\\
&=2u\Bigl(1-\ln u\Bigr)\Bigl[z\Bigr]_{\sqrt u}^{1-\sqrt u}
 +\int_{\sqrt u}^{1-\sqrt u}\Bigl[\ln z-\ln z\Bigr]dz\\
&=2u\Bigl(1-\ln u\Bigr)\Bigl(1-2\sqrt u\Bigr)
}
$$
since $\int_a^b\ln(1-z)dz=-\int_{1-a}^{1-b}\ln z\,dz$
using the substitution $t=1-z$.
In the latter case, setting
$a=\tfrac12-\sqrt{u+\tfrac14}$,
$b=\tfrac12+\sqrt{u+\tfrac14}$
where $\tfrac14 < u < 0 < z < 1$, note that
$(z-\tfrac12)^2 < u+\tfrac14$
$\implies$ $z(z-1)\le u$
$\implies$ $z\ge\frac{u}{z-1}$,
$\frac{z-1}{u}\ge z$ and
$1-z\ge\frac{-u}{z}$ so that
$$
\eqalign{
Pr(U>u)
&=\int_a^b A^-(u,z)\,dz\\
&=\int_a^b \left[2z+z-\frac{-z}{u}+u\ln1+u\ln\frac{-z}{u(1-z)}\right]dz\\
&=\int_a^b \left[
   \left(3+\tfrac1u\right)z
 +u\Bigl(\ln z-\ln(1-z)-\ln|u|\Bigr)\right]dz\\
&=\int_a^b \left[\left(3+\tfrac1u-u\ln|u|\right)z + 2u\ln z\right]dz\\
&= \tfrac12\left(3+\tfrac1u-u\ln|u|\right)\left[z^2\right]_a^b
 + 2u\Bigl[z\ln z-z\Bigr]_a^b\\
&= \left(3+\tfrac1u-u\ln|u|\right)\sqrt{u+\tfrac14}
 + 2u\Bigl[z\ln z \Bigr]_a^b - 4u \sqrt{u+\tfrac14}\\
}
$$
...to be continued.