# I Fourier transform

1. Jul 29, 2016

### Cristiano

Suppose that a parameter y= 123.
That parameter is somehow "perturbed" and its instantaneous value is:
y(t)= 123 +
sin(t - 50°) * 9 +
sin(t * 3 + 10°) * 3 +
sin(t * 20 + 60°) * 4

Suppose that I don't know the above formula, but I can calculate y(t) for any t. Hence I decide to use the Fourier transform to infer all the y's components.

If I use a sufficient number of samples to calculate y(t) (I currently use 216 samples) for 0 ≤ t ≤ 2π, I obtain:
y(t)= 122.999955606783 +
sin(t - 49.9942506502916°) * 8.99994072213981 +
sin(t * 3 + 10.0193463603278°) * 2.9999458244411 +
sin(t * 20 + 60.11052441823°) * 4.00000160503959

which is a very good result, while if I try to calculate y(t) for arbitrary t, I obtain a totally meaningless result.
Thank you

2. Jul 29, 2016

### BiGyElLoWhAt

I'm not sure I know what you mean. You essentially have the result, no? Isn't y(t) = 122.999 + sin(t-49.99)... y(t) for arbitrary t?
Can you elaborate on what you mean a little more?

3. Jul 29, 2016

### Cristiano

That's only an example and I know how to find the parameters only when 0 ≤ t ≤ 2π.
I need a working procedure to find the parameters in the equation:
y(t)= k0 + k1 * sin(t * a1 + b1) + k2 * sin(t * a2 + b2) + ...
knowing only y(t) and for any t (t is a time), not just for 0 ≤ t ≤ 2π.
I guess that I need to carry out some additional operations to consider that t is not in the range [0, 2π], but I don't know how to do that.

4. Jul 29, 2016

### BiGyElLoWhAt

So you know y values, the general fourier transform defines coefficients in terms of an integral, so do a numerical integral.
The general form is sum from 0 to inf of [a_n sin (2n pi t/tau) + b_n cos (2n pi t/tau)]

5. Jul 29, 2016

### BiGyElLoWhAt

You can either solve for the coefficients yourself (generally) or look up the general formula.

If you want to solve for them yoyrself (which is good to do at least once imo), try integrating cos (2n pi t/tau)sin(2m pi t/tau) from -tau/2 to tau/2.

6. Jul 29, 2016

### BiGyElLoWhAt

Notice the 'n' and 'm'. You'll have 4 cases to explore. N=0, m= 0, n=m and n!= m.

7. Jul 30, 2016

### BvU

Fourier transforms of general noisy signals require some form of windowing. Do an autocorrelation first to see what periodicity is present and what frequencies are of interest (if any: your example suggests averaging is as good as anything if all you want is the 123)

8. Jul 30, 2016

### Cristiano

I realize that my post is still unclear; here's what I'm currently doing.

I have a black box with the input t (time in seconds) and the output y(t) (a real number).
I only know that y(t) is very well fitted by an equation of the form:
y(t)= k0 + k1 * sin(t * a1 + b1) + k2 * sin(t * a2 + b2) + ...
and I'm only interested in knowing the most significant terms (k1, k2, ... must be "big"; I'll discard small k's).

In order to set up my procedure, I use a known "black box":
y(t)= 123 + sin(t - 50°) * 9 + sin(t * 3 + 10°) * 3 + sin(t * 20 + 60°) * 4
I decide to sample a reasonable number of points: N= 216
I define mul= 2 and step= mul * 2π / (N-1)
then I sample y(t):
for i= 0 to N-1
t = i * step
FFT_input_i = y(t)​
next i

now I calculate the FFT of FFT_input's and I obtain the wanted components:
for i= 0 to N/2
mag_i= magnitude(FFT_output_i)
arg_i= phase(FFT_output_i)​
next i

y(t)= k0 + k1 * sin(t * a1 + b1) + k2 * sin(t * a2 + b2) + ...
k_i= mag_i
a_i= i / mul
b_i= arg_i + 90°

That procedure perfectly works only when mul is within a small range (mul = 1 doesn't work, mul > 10 is not good).
I need to extend t to any arbitrary range (usually t is in the range [-106, 106]).