Verify the identity by using trigonometric identities:
csc^2(x) - 2csc(x)cot(x) + cot^2 = tan^2(x/2)

Working with the right hand side (RHS):
Recall the half-angle identities,
sin²(x/2) = (1 - cos(x))/2
cos²(x/2) = (1 + cos(x))/2
so that
RHS = tan²(x/2)
RHS = sin²(x/2) / cos²(x/2)
RHS = (1 - cos(x)) / (1 + cos(x))
Multiply the numerator and denominator by 1 - cos(x).
RHS = (1 - cos(x)) / (1 + cos(x)) • (1 - cos(x)) / (1 - cos(x))
RHS = (1 - cos(x))² / (1 - cos²(x))
Recall that
sin²(x) + cos²(x) = 1
so that
RHS = (1 - cos(x))² / (1 - cos²(x))
RHS = (1 - cos(x))² / sin²(x)
Expanding the numerator yields
RHS = (1 - 2 cos(x) + cos²(x)) / sin²(x)
RHS = 1/sin²(x) - 2 cos(x)/sin²(x) + cos²(x)/sin²(x)
RHS = 1/sin²(x) - 2 cos(x)/sin(x) • 1/sin(x) + cos²(x)/sin²(x)
and by definition of csc and cot,
RHS = csc²(x) - 2 cot(x) csc(x) + cot²(x)
as required.