The closed-form expression for the least squares solution is derived from the goal of minimizing the sum of squared differences between the…