Power in general is defined as the rate of energy change with time.
Energy is referred to as the capacity for doing work.
Work
is done when an object is moved by a force. Numerically work done by any force

when an object moves from a point A to a point B is specified as linear (or path) integral of the
force component in the direction of motion times distance moved:

(1)
Note that in general

is a scalar
product of two vectors

and

, which is equal to

, where φ is an
angle between these vectors.
If a point electric charge Q is placed in electric field it will experience a force, which is proportional to the amount of Q.
The force per unit charge is called
electric field:

(2)
We presume here that Q has a negligible size and does not distort the
field.

Combining (1) and (2) yields the expression for
work in electric field
to move a charge Q from a point A to a point B:

(3)
From (3) the power required to move charge Q in electric field from a
point A to a point B is:

,
(4)
where

is the rate of charge flow
past a given area called
electric current.
The linear integral in (4) is called
voltage (V) or
potential difference between points A and B:

(5)
Substituting (5) into (4) yields familiar expression for the
instantaneous electric power:
P=V×i,
(6)
where V and i are instantaneous values of voltage and current.
Note that generally any linear integral is a function of the path from A to
B. In electrostatic fields however, the integral (5) does not depend on
the path and is the function only of the electric field and coordinates
of points A and B. Likewise, work in electrostatic field does not
depend on the path. Particularly, the work to move a charge around any
closed loop (i.e. when A=B) is zero. Fields in which work does not
depend on path are called
conservative
(or potential) fields.
Electrostatic fields are generated by electric charges that remain in
rest or are
moving with a constant speed. Therefore, such fields present mainly
academic interest since no electronic circuit would work without
accelerating the charges. In changing fields integral (5) along a
closed loop is no longer zero due to the presence of variable
magnetic field:

,
(7)
where Ψ- magnetic flux through the closed loop,

- magnetic flux density through the loop, Ac – area of the closed loop.
As the result, the linear integral in (5) generally depends on the pass
from a point A to a point B. Therefore the voltage between any two
points A and B is no longer defined. Strictly speaking, in variable
electric fields we may only talk about voltage between points A and B
along a given path. For different paths between the same points A and B
the voltage (5) may be different. If magnetic flux is the same through
entire surface Ac formed by the loop, then (7) can be simplified:

(8)
where Ac is the area of the loop.
We see from (8) that in order to minimize the effects of changing
magnetic field we need to reduce the rate of change of magnetic field
dB/dt and/or the area Ac of the loop. If their product is small enough
we may neglect it and consider the electric field quasi-potential with
the familiar definition of voltage.
In AC circuits all quantities in (4), (5) and (6) are continuously varying and are functions of time
t.
The average value of the power over certain period of time
T is given by

(9)
Average power (9) is called
active or
real
power, or simply
watts.
The AC values are often stated as root-mean-square (RMS). The RMS value
of any variable X(t) is generally defined by

(10)
The product of RMS voltage and current
Vrms×Irms is called
apparent power (or
volt-amps).
The ratio between watts and apparent power is called
power factor.
It shows how well the electricity generator is utilized and for example
how much real power you can get from your home's wall outlet:

(11)
Note that any periodic non-sinusoidal current can be presented by Fourier transform:

(12)
Then for a pure sinusoidal voltage V(t), substituting (12) into (9)
gives active power as:

(13)
It can be shown that for n≥2:

, that is with a sinusoidal voltage active power is supplied only by the first (fundamental) harmonic of the current:

(14)
Similarly, it can be shown that in a general case of a non-sinusoidal voltage, net energy is transmitted to the load
only by the harmonics of voltage and current that have the same frequency.
For a sinusoidal voltage we derive from (14):

,
(15)
where Vpk and I
1pk-
peak (maximum) values of thevoltage and fundamental harmonic of the
current respectively, ω - angular frequency (in radian/sec), φ - is the
phase angle (in radians) between the
fundamental harmonic of the current and the voltage.
It can be derived from (10) that for any pure sine wave signal X(t):

.
Then expression for active power (15) can be rewritten as:

,
(16)
where Vrms- RMS value of the voltage, I
1rms –
RMS value of fundamental harmonic of the current.
By comparing (11) and (16) we derive the power
factor equation for a sinusoidal voltage:

,
(17)
where φ - is the phase angle between the 1st harmonic of the current
and the voltage.
In practice, the phase shift between voltage and current is caused by
capacitors and inductances, while higher current harmonics are cause by
non-linear components like rectifiers. The ratio between apparent power
associated with higher order harmonics and apparent power associated
with fundamental harmonic is called
Total Harmonic Distortion (THD).
For sinusoidal input voltage:

,
(18)
where Inrms- RMS value of the n-th harmonic of the
current.
For a periodic current from (12):

,
(19)
where Io – DC component of the current.
If Io=0, which is usually the case in AC lines unless you use an input
single-ended rectifier, then from (18) and (19) THD can be expressed as:

(20)
Finally, from expressions (17) and (20) we can also derive the relationship between PF and
THD (note that both, PF and THD can be improved by using an SMPS with power factor correction):

(21)