# Initialises modules 
import numpy

# g value of a free electron in a vacuum is defined
ge = 2.002319304

# defines g shift tensor matrix
GShiftTensor = numpy.matrix([[27.9973, -0.0002, -0.0022], 
                             [-0.0002, 27.8769, -0.0032], 
                             [-0.0022, -0.0032, 11.0372]])

# defines 3x3 identity matrix 
eye3 = numpy.matrix([[1, 0, 0],
                     [0, 1, 0],
                     [0, 0, 1]])

# calculates the g tensor
GTensor = 0.001*GShiftTensor + (ge*eye3)

# obtains and prints the gx, gy, gz values
g = numpy.sqrt(numpy.linalg.eigvals(GTensor*GTensor.transpose()))

for i in range(0,3):
 print(str(g[i]))
