Real HF transmission lines, such as coaxial cable or ladder line, are not perfect conductors of HF energy,
and will therefore lead to a certain amount of RF signal loss. Depending on the type and length of transmission
line, and the operating frequency, these losses can be quite substantial.

The input impedance of a real, lossy transmission line is computed using the
Transmission Line Equation which can take
several forms. Here we use a variation using hyperbolic trigonometric functions, after
ARRL Antenna Book, 20th Edition, p. 24-12:

${Z}_{\mathrm{in}}={Z}_{0}\frac{{Z}_{L}cosh\left(\gamma l\right)+{Z}_{0}sinh\left(\gamma l\right)}{{Z}_{L}sinh\left(\gamma l\right)+{Z}_{0}cosh\left(\gamma l\right)}$

We expand this expression in order to separate out the real and imaginary parts in the sinh and cosh arguments.

${Z}_{\mathrm{in}}={Z}_{0}\frac{{Z}_{L}cosh\left(l\right(\alpha +j\beta \left)\right)+{Z}_{0}sinh\left(l\right(\alpha +j\beta \left)\right)}{{Z}_{L}sinh\left(l\right(\alpha +j\beta \left)\right)+{Z}_{0}cosh\left(l\right(\alpha +j\beta \left)\right)}$

This second expression is then expanded fully, using standard identities for hyperbolic sines and cosines of complex numbers.
This is the basis of the code used to calculate the value of Z_{in} .

${Z}_{\mathrm{in}}={Z}_{0}\frac{{Z}_{L}(cosh(l\alpha )*cos(l\beta )+jsinh(l\alpha )*sin(l\beta \left)\right)+{Z}_{0}(sinh(l\alpha )*cos(l\beta )+jcosh(l\alpha )*sin(l\beta \left)\right)}{{Z}_{L}(sinh(l\alpha )*cos(l\beta )+jcosh(l\alpha )*sin(l\beta \left)\right)+{Z}_{0}(cosh(l\alpha )*cos(l\beta )+jsinh(l\alpha )*sin(l\beta \left)\right)}$
Eq. (1)

where

${Z}_{\mathrm{in}}=$
complex impedance at input of coax line

${Z}_{L}=$
complex load impedance at end of coax line, i.e. at the antenna
$={R}_{a}\pm j{X}_{a}$

${Z}_{0}=$
characteristic impedance of coax line
$={R}_{0}+j{X}_{0}$

$l=$
physical length of coax line in meters

$\gamma =$
complex loss coefficient
$=\alpha +j\beta $

$\alpha =$
matched line loss attenuation constant, in nepers per unit length

(1 neper = 8.68589 dB; cables are rated in dB per 100 meters)

$\beta =$
phase constant of coax line in radians per unit length

$\phantom{\rule{8px}{0ex}}=\frac{2\mathrm{\pi}}{{F}_{v}{L}_{w}}$
for
${F}_{v}=$
velocity factor of coax line, and
${L}_{w}=$
wavelength
$=\frac{300}{{f}_{\mathrm{MHz}}}$

Since, for a given setup, all of these values except frequency are constant,
${Z}_{\mathrm{in}}$
will vary with frequency.

Once the value of
${Z}_{\mathrm{in}}$
has been established for a particular combination of antenna, coax feed-line and frequency, we use
the following expression
(from a letter in the Technical Correspondence section of QST magazine, November 1997, p70-71)
to calculate the loss in dB due to VSWR:

${L}_{\mathrm{VSWR}}=10{log}_{10}\left(\frac{(1-|{\rho}_{\mathrm{in}}{|}^{2})}{(1-|{\rho}_{L}{|}^{2})}\right)$
Eq. (2)

where

${L}_{\mathrm{VSWR}}=$
loss in dB due to VSWR

$\left|{\rho}_{\mathrm{in}}\right|=\text{the magnitude of\hspace{0.5em}}({Z}_{\mathrm{in}}-{Z}_{0}^{*})/({Z}_{\mathrm{in}}+{Z}_{0})$

$\left|{\rho}_{L}\right|=\text{the magnitude of\hspace{0.5em}}({Z}_{L}-{Z}_{0}^{*})/({Z}_{L}+{Z}_{0})$

${Z}_{0}^{*}=\text{complex conjugate of the feed-line characteristic impedance\hspace{0.5em}}{R}_{0}+j{X}_{0}$

This expression avoids problems associated with possibly negative values of VSWR by using complex impedances and
thus eliminating VSWR from the calculation.

In calculating losses for a particular combination of antenna and coax feed-line
over several frequencies, it is necessary to
calculate both equations 1 and 2 for each frequency. The number of frequencies covered for a VSWR curve
over a single band is on the order of 40 or 50.