<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Electric Machinery Fundamentals 5th edition
Chapter 2 (Code examples)
Example 2-5
Calculate and plot the voltage regulation of a transformer as a function of load for power  factors of 0.8 lagging, 1.0, and 0.8 leading.
Import the PyLab namespace (provides set of useful commands and constants like Pi)
Step1:  Define all the parameters
Step2:  Calculate the current values for the three power factors.
The first row of I contains the lagging currents, the second row contains
the unity currents, and the third row contains the leading currents.
Step3:  Calculate VP/a
Step4:  Calculate voltage regulation
Step5:  Plot the voltage regulation
<ASSISTANT_TASK:>
Python Code:
%pylab notebook
Explanation: Electric Machinery Fundamentals 5th edition
Chapter 2 (Code examples)
Example 2-5
Calculate and plot the voltage regulation of a transformer as a function of load for power  factors of 0.8 lagging, 1.0, and 0.8 leading.
Import the PyLab namespace (provides set of useful commands and constants like Pi)
End of explanation
VS = 230.0                   # Secondary voltage (V)
amps = arange(0, 65.2, 6.52) # Current values (A)
Req = 0.0445                 # Equivalent R (ohms)
Xeq = 0.0645                 # Equivalent X (ohms)
Explanation: Define all the parameters:
End of explanation
I = amps * array ([[0.8 - 0.6j],   # Lagging
                   [1.0],          # Unity
                   [0.8 + 0.6j]])  # Leading
Explanation: Calculate the current values for the three power factors.
The first row of I contains the lagging currents, the second row contains
the unity currents, and the third row contains the leading currents.
End of explanation
VPa = VS + Req * I + 1j * Xeq * I
Explanation: Calculate VP/a:
End of explanation
VR = (abs(VPa) - VS) / VS * 100;
Explanation: Calculate voltage regulation:
End of explanation
rc('text', usetex=True)   # enable LaTeX commands for plot
plot(amps,VR[0,])
plot(amps,VR[1,])
plot(amps,VR[2,])
title(r'\textbf{Voltage Regulation Versus Load}');
xlabel(r'\textbf{Load (A)}');
ylabel(r'\textbf{Voltage Regulation (\%)}');
legend(('0.8 PF lagging','1.0 PF','0.8 PF leading'), loc=2);
grid()
Explanation: Plot the voltage regulation:
End of explanation
<END_TASK>