What is the derivation of mirror formula of concave and convex mirror?

what is the derivation of mirror formula of concave and convex mirror?

Derivation of formula for convex mirror:
Let AB be an object placed on the principal axis of a convex mirror of focal length f. u is the distance between the object and the mirror and v is the distance between the image and the mirror.

In ABC and A1B1C
<ABC = <A1B1C (right angles)
<ACB = <A1CB1
<CAB = <CA1B (common angle)
ABC is similar to A1B1C
AB/A1B1 = BC/B1C…(1)
similarly DEF issimilar to A1B1F
DE/A1B1 = EF/B1F…(2)
But DE = AB and when the aperture is very small EF = PF
Equation (2) becomes
AB/A1B1 = PF/B1F…(3)
Frm equations (1) and (3) get
PF/B1F = BC/B1C
PF/PF-PB1 = PB + PC/PC - PB1
f/f - v = -u + 2f/2f - v
[PF = f, PB1 = v, PB = u, PC = 2f]
2(2f - v)= (f-v)(2f-u)
i could not write the following 2 steps sorry
-vf + uf + 2 fv -vu=0
fv+uf-vu=0…(4)
Dividing both sides of equation(4) by uvf we get
fv/uvf + uf/uvf - uv/uvf=0
1/u +1/v - 1/f=0
1/u + 1/v = 1/f