Script Example: Calculate the angle between two vectors

In this example, a script will be written to calculate the angle between two vectors $\vec{A}= 3\,\hat{x} -5 \,\hat{y} +7\,\hat{z}$ and $\vec{B}= -2\,\hat{x} +6 \,\hat{y} +9\,\hat{z}$. The scalar product of these two vectors is,

$$\vec{A}\cdot\vec{B} = A_xB_x + A_yB_y + A_zB_z = |\vec{A}||\vec{B}|\cos\theta,$$

Where $\theta$ is the angle between the vectors. The script solves for the angle $\theta$.




Script Output