#Chapter-4,Example4_1,pg 4-22
#calculate the value of E1 vs EAB
import math
import numpy
from matplotlib import pyplot
import warnings
warnings.filterwarnings('ignore')
%matplotlib inline
#given
E1mag=numpy.array([0, 3, 5, 7, 9, 12, 15, 18, 21])
Erms=5#given
#results
E1rms=E1mag/math.sqrt(2)
Einrms=(((E1rms)**2)+((Erms)**2))**(1./2.)
Eab=(2*math.sqrt(2)*Einrms)/math.pi
#results
pyplot.xlabel('E1(Volts)')
pyplot.ylabel('Eab(Volts)')
pyplot.title('Phase Meter')
print"E1 mag E1 rms Ein Rms Eab output"
k=numpy.matrix([[0, 0, 5, 4.501],
[3, 2.121, 5.431, 4.889],
[5, 3.53, 6.123, 5.513],
[7, 4.949, 7.035, 6.334],
[9, 6.363, 8.093, 7.286],
[12, 8.485, 9.848, 8.867],
[15, 10.606, 11.726, 10.557],
[18, 12.727, 13.674, 12.311],
[21, 14.849, 15.668, 14.106 ]])
print (k)
pyplot.plot(E1mag,Eab)
print 'There is a slight error in textbook'