Update dft

This commit is contained in:
2026-02-03 12:37:33 +01:00
parent f66f627c2e
commit b508c5178d
3 changed files with 1112 additions and 7 deletions

View File

@@ -1,5 +1,13 @@
using Pkg
Pkg.add("Plots")
using Plots
"""
Start the program with
julia -i HahnWitjesZettel6.4.jl
"""
# https://en.wikipedia.org/wiki/Discrete_Fourier_transform#Definition
function dft(x)
N = length(x)
@@ -23,13 +31,13 @@ function evaluate_coefficients(x, coeffs)
end
function f(n)
xs = (0:n-1) ./ n
xs = (0:n-1) ./ n # Exclude the last one
[x < 1/2 ? (x, x) : (x, 1 - x) for x in xs]
end
function main()
ns = [3, 6, 10, 15, 20, 25]
plt = plot(layout = (length(ns), 2), size = (1000, 1000))
plt = plot(layout = (length(ns), 2), size = (1200, 1000))
for (row, n) in enumerate(ns)
points = f(n)
@@ -45,7 +53,7 @@ function main()
plt[row, 1],
xfine,
real.(poly),
title = "n = $n (real part)",
title = "n = $n (Realteil)",
legend = false
)
scatter!(
@@ -57,14 +65,13 @@ function main()
plt[row, 2],
xfine,
imag.(poly),
title = "n = $n (imag part)",
title = "n = $n (Imaginaerteil)",
legend = false
)
end
gui(plt)
savefig("HahnWitjesZettel6.4.svg")
end
main()
gui()

1096
src/Manifest.toml Normal file
View File

File diff suppressed because it is too large Load Diff

2
src/Project.toml Normal file
View File

@@ -0,0 +1,2 @@
[deps]
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"