I'm trying to make a function that outputs a plot given a particular parameter, whilst using the Mathematica functions Module, Fourier, and Table. This is what I've come up with thus far.
plotit[function_, min_, max_, step_, fourier_] := Module[{data, fdata},
data = Table[{i, function[i]}, {i, min, max, step}];
fdata = Fourier[Part[data, All, If[fourier == 0, 1, 2]]];
If [fourier == 0 , ListPlot[data],
ListPlot[Transpose[{Part[data, All, 1], fdata}]]]
];
The reason for this is I want to easily be able to plot functions such as Sin, RiemannSiegelZ, ect and easily plot a Fourier of them. This sounds quite specific, I found this question in an online free workbook to help learn Mathematica.
For example I want to input
plotit[Function[x, RiemannSiegelZ[x]^2], 0, 50, .1, 0]
which outputs
%CorrectPlot%
I couldn't figure out how to upload my output into this question, sorry. Anyways I do get a plot of what I want, if I set fourier=0, butt not when fourier=1.
My last working plotit function is
plotit[function_, min_, max_, step_, fourier_] := Module[{data, fdata},
data = Table[{i, function[i]}, {i, min, max, step}];
ListPlot[data]
];
I get the desired output, of a plot, but there's nothing in there to easily change the outputted plot to be a Fourier transform of the plot.
I've tried
plotit[Function[x, Fourier[RiemannSiegelZ[x]^2]], 0, 50, .1, 1]
But it seems like the Mathematica function 'Fourier' only works on lists, so it cannot be used this way.
My goal is essentially to create a function that plots the Fourier Transform of any input function over a specific range, but also be general enough to just plot the input function over the specific range without creating another function.
If
notIF
and don't make a whitespace. $\endgroup$Fourier
then you need to start with a list so you also need to define a resolution or a number of points to discretize the function. More details on how Fourer works may be found here. $\endgroup$