Formulation and numerical solution of inverse problems of electroencephalography