Added calculation of thetae on flag = 3 (x-t dimensional output)