Answer
The Ex__2_dct_formula.py
Python file contains the DCT code:
#!/usr/bin/env python """Ex__2_dct_formula.py: Answer to Ch 6 Ex 2.""" import math # Input vector x = [0.5, 0.2, 0.7, -0.6, 0.4, -0.2, 1.0, -0.3] # Compute the DCT coefficients dct_coef = [[i for i in range(len(x))] for j in range(len(x))] for n in range(len(x)): for k in range(len(x)): dct_coef[n][k] = math.cos((math.pi/len(x))* (n + 1/2)*k); # Compute the DCT x_dct = [i for i in range(len(x))] for k in range(len(x)): x_dct[k] = 0; for n in range(len(x)): x_dct[k] += x[n]*dct_coef[n][k]; # Print the results print('Index', end='') for i in range(len(x)): print("%8d" % i, end='') print('\nx ', end='') for i in range(len(x)): print("%8.4f" % x[i], end='') print('\nDCT(x) ', end='') for i in range(len(x)): print("%8.4f" % x_dct...