LAB 9: HUMAN HEARING AND LEAST-SQUARE TRIGONOMETRIC APPROXIMATION

Mathematics:

A human's ear recognizes sound waves, which are variations in time of the air pressure. Sound waves enter the ear with different frequencies and the ear activates signals along neural pathways to the brain with the same frequencies. The signals are interpreted as sound. However, the human's ear recognizes the sound waves having frequencies within a certain range, which is roughly from 20 to 20,000 cycles per second. Therefore, the ear only approximates the incoming sound waves by truncating signals having frequencies outside this range. This project exploits the trigonometric approximation for the model of human hearing.

Let a sound wave p(t) have a saw-tooth pattern with a basic frequency of 2000 cycles per second. Such wave is periodic in time with period T = 1/2000 = 0.0005 second. The function p(t) can be expressed analytically:

p(t) =

and graphically:

The ear recognizes only sinusoidal variations of the air pressure that are trigonometric functions of time:

q(t) = a0  +  aj cos+ bj  sin + am cos

where (aj,bj) are amplitudes of the sinusoidal components of a complex sound wave, while frequencies of the sinusoidal components j/T are truncated at the integer m such that m/T 20,000. The function q(t) is also periodic with period T.

The sound wave p(t) with period T is not a finite sum of sinusoidal components, while q(t) is. Therefore, the sound wave p(t) produces the ear's response q(t) which is only the approximation of the sound wave, obtained by truncating the frequencies higher than m./T. The same response is produced if the sound wave would be q(t).

Amplitudes (aj,bj) of the function q(t) can be found from the least-square trigonometric approximation:

aj = p(t) cosdt,    j = 0,1,2,…,m;        bj = p(t) sindt,    j = 1,2,…,m-1

The least-square trigonometric approximation minimizes the mean square error:

E = [p(t) – q(t)]2 dt

In the example of p(t) given, one can find analytically that aj = 0;    bj = .

Objectives:

·         Understand a computational algorithm for the least-square trigonometric approximation

·         Exploit the trigonometric approximation for different values of m

·         Understand the Gibbs phenomenon occurring at jump discontinuities of the trigonometric sums

#### MATLAB script for least-square trigonometric approximation

Let the interval t  [0,T] be equally spaced partitioned into (n+1) grid points:

ti = ,      i=1,2,…,n,n+1

Let n = 2m. The trigonometric approximant q(t) has 2m coefficients [aj,bj], which are to be found from equations: p(ti) = q(ti). When the function p(t) is continuous at the ends of the interval [0,T], coefficients [aj,bj] can be computed from direct summation formulas:

aj =  p(ti) cos,    j = 0,1,2,…,m;        bj = p(ti)  sin,    j = 1,2,…,m-1

When the function p(t) has a jump at the ends of the interval [0,T], coefficients [aj,bj] can be computed from:

aj = p(ti) cos + [p(0) + p(L)],    j = 0,1,…,m;  bj = p(ti)  sin,    j = 1,…,m-1

##### Steps in writing the MATLAB script:
1. Define T = 0.0005, m = 20000 T, and n = 2m.
2. Assign an equally spaced partition of [0,T] to a row-vector t with (n+1) grid points.
3. Compute a row-vector p from the function p(t) at (n+1) grid points.
4. Compute coefficients (aj,bj) of the trigonometric approximant q(t).
5. Plot the trigonometric approximant q(t) for a tense partition tint of the interval between 0 < t < T.
6. Plot the sound wave function p(t) at the same graph.

Exploiting the MATLAB script:

1.       Check a local error of the trigonometric approximation e(t) = |p(t) – q(t)| for values of t close to the end-points t = 0 and t = T.

2.       Check a local error e(t) = |p(t) – q(t)| for values of t close to the mid-point t = T/2?

#### MATLAB script for errors of least squares trigonometric approximations

The least squares trigonometric approximation becomes better as the number of terms in the approximating trigonometric polynomial q(t) becomes larger. The mean square error E can be computed from a trapezoidal rule for numerical integration:

E = ,

where h is a step size for a tense grid between [0,T]. Theoretically, the mean square error E tends to zero as the number m approaches infinity. However, because E is found approximately from the trapezoidal rule, the mean square error E approaches to a small constant which is the error of the numerical integration:

However, the trigonometric approximant q(t) with infinitely many terms (the Fourier series) may not converge to the original function p(t) at any value of t in [0,T]. If the function p(t) has a jump discontinuity at a value t = t0, then the trigonometric approximant q(t) converges to an average value of p(t) at the jump point. For example, the sound wave p(t) in our example has a jump discontinuity at t = 0 and the trigonometric approximant q(t) converges to 0.5( p(0+) + p(0-) ) = 0.5 (1 – 1) = 0 at the point t = 0. At other points of t in [0,T], the trigonometric approximant q(t) converges to the values of p(t), but the local error of the trigonometric approximation e(t) is not uniformly small for all values of t, if the function p(t) has a jump discontinuity. The local error e(t) for sufficiently large value m = 100 is shown here:

Steps in writing the MATLAB script:

1. Define T as previously. Define a loop for values of m from 1 to 100.
2. Let n = 2 m and assign an equally spaced partition of [0,T] to a row-vector t. with (n+1) grid points.
3. Compute a row-vector p from the function p(t) at (n+1) grid points.
4. Compute coefficients (aj,bj) of the trigonometric approximant q(t).
5. Compute the mean square error E for each value of m. Save E as a vector.
6. After the loop in m is terminated, plot the vector E versus m in semilogy scale.
7. For m = 100, plot the local error of the trigonometric approximation e(t) = |p(t) – q(t)| for a tense partition tint of the interval between 0 < t < T.

Exploiting the MATLAB script:

1. Plot the local error e(t) = |p(t) – q(t)| for m = 10, 50, 150, 200.

#### QUIZ:

1. Compute the trigonometric approximant q(t) of the function p(t) on t  [0,2] for m = 10:

p(t) =

1. Compute the trigonometric approximant q(t) of the function p(t) on t  [0,2] for m = 10:

p(t) = ecos t [ cos(sin t) + sin(sin t)]