function to compute wavespace over 2D domain
function wavespace(nx,ny,dx,dy)
eps = 1.0e-6
kx = Array{Float64}(undef,nx)
ky = Array{Float64}(undef,ny)
k2 = Array{Float64}(undef,nx,ny)
hx = 2.0*pi/(nx*dx)
for i = 1:Int64(nx/2)
kx[i] = hx*(i-1.0)
kx[i+Int64(nx/2)] = hx*(i-Int64(nx/2)-1)
end
kx[1] = eps
ky = kx
for i = 1:nx for j = 1:ny
k2[i,j] = kx[i]^2 + ky[j]^2
end end
return k2
end
```
**Listing 33.** Julia implementation of computing the nonlinear Jacobian term in physical space and converting it to Fourier space ✞ ☎

✝ ✆

```