1616
1717dx = L / n
1818x = range(start = -L / 2, stop = L / 2 - dx, length = n) |> Array
19- u = @. sin(5x)cos(7x);
20- du = @. 5cos(5x)cos(7x) - 7sin(5x)sin(7x);
19+ v = @. sin(5x)cos(7x);
20+ w = @. 5cos(5x)cos(7x) - 7sin(5x)sin(7x);
2121
2222k = rfftfreq(n, 2π * n / L) |> Array
2323m = length(k)
@@ -38,10 +38,10 @@ F = FunctionOperator(fwd, x, im * k;
3838ik = im * DiagonalOperator(k)
3939Dx = F \ ik * F
4040
41- Dx = cache_operator(Dx, x )
41+ Dx = cache_operator(Dx, v )
4242
43- @show ≈(Dx * u, du ; atol = 1e-8)
44- @show ≈(mul!(copy(u ), Dx, u ), du ; atol = 1e-8)
43+ @show ≈(Dx * v, w ; atol = 1e-8)
44+ @show ≈(mul!(copy(w ), Dx, v ), w ; atol = 1e-8)
4545```
4646
4747## Explanation
@@ -61,8 +61,8 @@ n = 256
6161dx = L / n
6262x = range(start = -L / 2, stop = L / 2 - dx, length = n) |> Array
6363
64- u = @. sin(5x)cos(7x);
65- du = @. 5cos(5x)cos(7x) - 7sin(5x)sin(7x);
64+ v = @. sin(5x)cos(7x);
65+ w = @. 5cos(5x)cos(7x) - 7sin(5x)sin(7x);
6666```
6767
6868Now, we define the Fourier transform. Since our input is purely Real, we use the real
@@ -87,7 +87,7 @@ fwd(v, u, p, t) = P * v
8787bwd(v, u, p, t) = P \ v
8888
8989fwd(w, v, u, p, t) = mul!(w, P, v)
90- bwd(w, v, p, t) = ldiv!(w, P, v)
90+ bwd(w, v, u, p, t) = ldiv!(w, P, v)
9191F = FunctionOperator(fwd, x, im * k;
9292 T = ComplexF64, op_adjoint = bwd,
9393 op_inverse = bwd,
@@ -106,6 +106,6 @@ Dx = F \ ik * F
106106
107107Dx = cache_operator(Dx, x)
108108
109- @show ≈(Dx * u, du ; atol = 1e-8)
110- @show ≈(mul!(copy(u ), Dx, u ), du ; atol = 1e-8)
109+ @show ≈(Dx * v, w ; atol = 1e-8)
110+ @show ≈(mul!(copy(w ), Dx, v ), w ; atol = 1e-8)
111111```
0 commit comments