Here are the steps to solve this using the algebraic approach with homogeneous transformations:
1) Start with the identity matrix for the initial frame:
H0 = [[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]]
2) Apply the first rotation about Z by angle θ1:
Rz1 = [[cosθ1, -sinθ1, 0, 0],
[sinθ1, cosθ1, 0, 0]
[0, 0, 1, 0]
[0, 0, 0, 1]]
H1 = Rz1 *