Proving that if $A$ is diagonalizable with non-negative eigenvalues, then $A=B^2$ for some $B$

Let $A$ be a diagonalizable $n \times n$ matrix with non-negative eigenvalues. Prove that there exists a matrix $B$ such that$$A=B^2.$$

I honestly don’t have a clue what to do. Could anyone please help me out?

Solutions Collecting From Web of "Proving that if $A$ is diagonalizable with non-negative eigenvalues, then $A=B^2$ for some $B$"

At first we definie the Squareroot function for a diagonal matrix $D$ as $\sqrt{D}:=(\sqrt{d_{ij}})_{i,j}$ (as all values are greater equal $0$ this is well defined.

In special we notice that $$\sqrt{D} \cdot \sqrt{D}=D$$

As we know that $A$ is diagonalizable we have.
$$ A= T D T^{-1}=T \sqrt{D} \sqrt{D} T^{-1}$$
This looks pretty good, but to make it even nicer we can write this as
$$T \sqrt{D} T^{-1}\cdot T \sqrt{D} T^{-1}$$

Choosing now
$$B=T \sqrt{D} T^{-1}$$ we see that $B^2=A$. In fact that is the way we can define a square root function for any positive semidefinit matrices.