In fact, the formula you use is something like

wave1(x,z) := ( sin( f

_{s}* ( dir

_{x}* x + dir

_{z}* z ) + f

_{t}* t + p ) )

^{2}

where f

_{s}denoting a spatial frequency, f

_{t}denoting a temporal frequency, and p denoting a phase.

For the purpose of spatial derivative the term f

_{t}* t + p =: c

_{t}is a constant, and f

_{x}:= f

_{s}* dir

_{x}, f

_{z}:= f

_{s}* dir

_{z}can be used for simplicity. Then IIRC the derivatives are

tan1 := d wave(x,z) / d x = ( sin( f

_{x}* x + f

_{z}* z + c

_{t}) )

^{2 }/ d x = 2 sin( f

_{x}* x + f

_{z}* z + c

_{t}) * cos( f

_{x}* x + f

_{z}* z + c

_{t}) * f

_{x}

and

bitan1 := d wave(x,z) / d z = ( sin( f

_{x}* x + f

_{z}* z + c

_{t}) )

^{2}/ d z = 2 sin( f

_{x}* x + f

_{z}* z + c

_{t}) * cos( f

_{x}* x + f

_{z}* z + c

_{t}) * f

_{z}

due to the chain rule. Please check this twice.