Simple lowpass frequency response Okay, so hopefully this isn't too hard or off-topic. Let's say I have a very simple lowpass filter (something that smooths out a signal), and the filter object has a position variable and a cutoff variable (between 0 and 1). In every step, a value is put into the following bit of pseudocode as "input": position = position*(1-c)+input*c, or more mathematically, f(n) = f(n-1)*(1-c)+x[n]*c. The output is the value of "position." Basically, it moves a percentage of the distance between the current position and then input value, stores this value internally, and returns it as output. It's intentionally simplistic, since the project I'm using this for is going to have way too many of these in sequence processing audio in real time. 
Given the filter design, how do I construct a function that takes input frequency (where 1 means a sine wave with a wavelength of 2 samples, and .5 means a sine wave with wavelength 4 samples, and 0 is a flat line), and cutoff value (between 1 and 0, as shown above) and outputs the amplitude of the resulting sine wave? Sine wave comes in, sine wave comes out, I just want to be able to figure out how much quieter it is at any input and cutoff frequency combination.
 A: I don't have enough mojo to comment on Greg's answer.


*

*Greg made a silly calculational mistake: The transfer function $A(\omega)$ should be $c/(1-(1-c)e^{-i\omega})$.

*What you want is the modulus of $A(\omega)$. Note that $\sin \omega n$ is precisely the imaginary part of $e^{i\omega n}$. Because the relation between input and output is linear, the response to $\sin\omega n$ will be the imaginary part of $A(\omega)e^{i\omega n}$. That's going to be a sinusoid with some shifting and the amplitude $|A(\omega)|$. Here is a plot for $c=1/2$.

*To read more about this sort of things, google "IIR filter" or "infinite impulse response".
A: As I understand it, you are given a sequence $(x_n)_{n\in\mathbb{N}}$ of input values from which you calculate a sequence $f_n$ that is given by the following recurrence relations:
$f_0 = 0$
$f_{n+1} = (1-c)f_n + c\cdot x_{n+1}$
Your question is: given a sine wave $x_n=\sin(\omega n)$, you assert that $f_n$ is also a sine wave and you want to know its amplitude in dependence on the frequency $\omega$.
Answer: It's easier to calculate the frequency response with exponential functions instead of sine waves.
$f_n = Ae^{i\omega n}$
$x_n = e^{i\omega n}$
Since $f_{n+1} = e^{i\omega (n+1)} = e^{i\omega} e^{i\omega n} = e^{i\omega} f_n$, the recurrence relation gives
$e^{i\omega} A e^{i\omega n} = (1-c)Ae^{i\omega n} + c e^{i\omega} e^{i\omega n}$
which implies
$A(\omega) = \frac{c}{1 - (1-c)e^{-i\omega}}$
To calculate the response for sine waves, you can represent the sine function as a linear combination of two exponential functions
$x_n = \sin(\omega n) = \frac1{2i}(e^{i\omega n}-e^{-i\omega n})$
and obtain
$f_n = \frac1{2i}(A(\omega)e^{i\omega n}-\bar A(\omega)e^{-i\omega n}) = |A(\omega)| \sin(\omega n + \phi)$ where $A(\omega) =: |A(\omega)| e^{i\phi}$.
In other words, the complex frequency response $A(\omega)$ encodes both the change in amplitude and the phase shift. I'll leave the exact calculation of $|A(\omega)|$ to you, so that you can get familiar with this method of calculation.
Without exponential functions, you'd have to use the addition and subtraction theorems for sine and cosine. Put differently, exponential functions provide a very convenient formulation of the trigonometric identities.
