Re: numerical fourier transform of an error function
- From: John O'Flaherty <quiasmox@xxxxxxxxx>
- Date: Mon, 21 Jan 2008 14:22:33 -0600
On Mon, 21 Jan 2008 17:14:02 +0000 (UTC), "Jianjun "
<jianjunp@xxxxxxxxxxxxx> wrote:
I am trying to evaluate a fourier transform of an error{snipped}
function f(x)=erf(x+16)-erf(x-16);
I used subs(maple('fourier',erf(x+16)-erf(x-16),x,w),w,
[0:0.001:1]');
All I need is get the value of w at [0:0.001:1] region.
Because the fourier transfrm of error function is not
explicit,it only gives me something like
Could anyone tell me how to obtain the nemerical value of
this problem? Thank you all in advance.
The erf() can't be evaluated in closed form in terms of elementary
functions. According to the following, it can be evaluated in terms of
a Taylor series:
http://en.wikipedia.org/wiki/Error_function
That is too hideous to contemplate, so to get a numerical answer, it
would be easier to give a numeric range to f(x). This is easier if you
think about what the function looks like - it is the difference of two
erf curves, one shifted to the left by 16, and one shifted to the
right by the same amount. When the difference is taken, what is seen
is a function that rises quickly around -16 from zero to two, and then
decreases quickly from two to zero around +16. If you assign an x
range of +/- 20 to x, you will get virtually all of the change in the
curve (within 4 sigma, speaking loosely).
With the resulting vector, you can take a numeric fft and see what
pops out.
I made up this m-file to show the function and its fft:
x = -20 : .001 : 20; %x vector
L= length(x);
xrf = erf(x+16)-erf(x-16); % f(x)
plot(x,erf(x+16),x,erf(x-16),x,xrf); % picture f(x)
figure
% this copied from Matlab fft help with variable names modified...
NFFT = 2^nextpow2(L); % Next power of 2 from length of x
XRF = fft(xrf,NFFT)/L;
f = L/2*linspace(0,1,NFFT/2);
% Plot single-sided amplitude spectrum.
plot(f,2*abs(XRF(1:NFFT/2)))
title('Single-Sided Amplitude Spectrum of f(x)')
xlabel('Units?')
ylabel('|XRF(f)|')
XRF(1:NFFT/2); % print the numbers if desired
The scaling depends on what values of time are assigned to x = -20:20,
and what sample rate. I'll leave it to you to figure the scaling to
get the numeric values you need in w = 0 to 1. You'll probably need to
play with the input resolution.
.
- References:
- numerical fourier transform of an error function
- From: Jianjun
- numerical fourier transform of an error function
- Prev by Date: Piecewise functions
- Next by Date: Re: Compare accuracy issue
- Previous by thread: numerical fourier transform of an error function
- Next by thread: panel data
- Index(es):
Relevant Pages
|