Prove that $(\vec{a}+\vec{b}) \cdot(\vec{a}+\vec{b})=|\vec{a}|^{2}+|\vec{b}|^{2}$, if and only if $\vec{a}, \vec{b}$ are perpendicular, given $\vec{a} \neq \overrightarrow{0}, \vec{b} \neq \overrightarrow{0}$.
$(\vec{a}+\vec{b}) \cdot(\vec{a}+\vec{b})=|\vec{a}|^{2}+|\vec{b}|^{2}$
$\Leftrightarrow \vec{a} \cdot \vec{a}+\vec{a} \cdot \vec{b}+\vec{b} \cdot \vec{a}+\vec{b} \cdot \vec{b}=|\vec{a}|^{2}+|\vec{b}|^{2}$ [Distributivity of scalar products over addition]
$\Leftrightarrow|\vec{a}|^{2}+2 \vec{a} \cdot \vec{b}+|\vec{b}|^{2}=|\vec{a}|^{2}+|\vec{b}|^{2}$ $[\vec{a} \cdot \vec{b}=\vec{b} \cdot \vec{a}$ (Scalar product is commutative) $]$
$\Leftrightarrow 2 \vec{a} \cdot \vec{b}=0$
$\Leftrightarrow \vec{a} \cdot \vec{b}=0$
$\therefore \vec{a}$ and $\vec{b}$ are perpendicular. $[\vec{a} \neq \overrightarrow{0}, \vec{b} \neq \overrightarrow{0}$ (Given) $]$