Mathematical Theory Of Opinion Dynamics With Applications