Solution (source code)

= Solution

The triangle $ADB$ is right-angled at $A$, with $AB=\sqrt2$ and $AD=1/\sqrt2$. Another application of the <Pythagorean theorem> gives $DB=\sqrt{2+1/2}=\sqrt{5/2}$. At the <angle> with vertex $D$, the adjacent side is $AD$ and the hypotenuse is $DB$. Hence
$$
\boxed{\cos\angle ADB=\frac{AD}{DB}=\frac1{\sqrt5}.}
$$