Finding matrix $A$ knowing that $A^2 = B$ Let $B$ be the $3\times3$ matrix
$$
\begin{pmatrix}
1&8&5\\
0&9&5\\
0&0&4
\end{pmatrix}.
$$
How can I find a triangular matrix $A$ with positive diagonal entries such that $A^2 = B$ ?

As per my comments, we have
$$\begin{bmatrix}1&x&y\\0&3&z\\0&0&2\end{bmatrix}^2 = \begin{bmatrix}1&8&5\\0&9&5\\0&0&4\end{bmatrix}$$
and wish to find $x, y, z$. This gives
$$
\cases{4x = 8\\3y  + xz = 5\\5z = 5}
$$
where we immediately get the solutions $x = 2, z = 1$, which again gives $y = 1$. So we have
$$
A = \begin{bmatrix}1&2&1\\0&3&1\\0&0&2\end{bmatrix}
$$
