Trying to define the Lie bracket of two vector fields

I am trying to define in the simplest possible way (only one coordinate system, no checking that variables are vectors, etc.) the Lie bracket of two vector fields in 3-space.

What is wrong with the following code ? It seems that Lie[a,b] is not understood by Mathematica as an expression of the same kind as a and b.

coo := {{x, y, z}}
Jac[v_] := D[v, coo]
Lie[v_, w_] := Jac[w[x, y, z]].v[x, y, z] - Jac[v[x, y, z]].w[x, y, z]
a[x_, y_, z_] := {1, 0, 0}; b[x_, y_, z_] := {0, 1, x^2}
Lie[a, b]
Lie[a, Lie[a, b]]
• If you try the code, you will see that Lie[a,b] gives the correct answer, but Lie[a, Lie[a, b]] doesn't work. – André Bellaïche Nov 1 '17 at 16:06

Try

coo := {{x, y, z}}
Jac[v_] := D[v, coo]
Lie[v_, w_] := Jac[w].v - Jac[v].w
a := {1, 0, 0}
b := {0, 1, x^2}

Lie[a, b]

{0, 0, 2 x}

Lie[a, Lie[a, b]]

{0, 0, 2}

One way to do it:

a = {1, 0, 0};
b = {0, 1, x^2};

Jac[v_] := D[v, {{x, y, z}}];
Lie[v_, w_] := Jac[w].v - Jac[v].w;

Lie[a, b] (* {0, 0, 2x} *)
Lie[a, Lie[a, b]] (* {0, 0, 2} *)