Solution (source code)

= Solution

For $V=\mathbb R^2$ with basis $e_1,e_2$, the step-two <Lie algebra> has basis $e_1,e_2,[e_1,e_2]$ and its last element is central. Write
$$
g(x,y,z)=\exp\bigl(xe_1+ye_2+z[e_1,e_2]\bigr).
$$
Its first level is $v=(x,y)$ and its second level is
$$
\tfrac12v\otimes v+z(e_1\otimes e_2-e_2\otimes e_1).
$$
The step-two multiplication gives
$$
\boxed{(x,y,z)(x',y',z')=
\left(x+x',y+y',z+z'+\tfrac12(xy'-yx')\right).}
$$
Consequently the map
$$
(x,y,z)\longmapsto
\begin{pmatrix}1&x&z+\tfrac12xy\\0&1&y\\0&0&1\end{pmatrix}
$$
is an isomorphism onto the real <Heisenberg group>. The shift by $xy/2$ converts exponential coordinates into the matrix coordinates used for that group. In exponential coordinates the left-invariant horizontal vector fields are
$$
X=\partial_x-\tfrac y2\partial_z,\qquad
Y=\partial_y+\tfrac x2\partial_z,\qquad [X,Y]=\partial_z.
$$
Taking $X,Y$ orthonormal gives exactly the <Carnot-Carathéodory distance> inherited from $G^2(\mathbb R^2)$.