# Relations between DSTVIII and DSTVII

## Definitions

Transform matrix is defined for operating on column-vectors y=T*x, where y, x are column-vectors, T is transform matrix

## DSTVIII matrix definition

N1=9; N=N1;
k=0:N1-1;  l=0:N1-1;
DST8=sin(pi/(N-1/2)*(k+1/2)'*(l+1/2))       % display DCTV matrix

DST8 =
Columns 1 through 7
0.0923    0.2737    0.4457    0.6026    0.7390    0.8502    0.9325
0.2737    0.7390    0.9830    0.9325    0.6026    0.0923   -0.4457
0.4457    0.9830    0.7390   -0.0923   -0.8502   -0.9325   -0.2737
0.6026    0.9325   -0.0923   -0.9830   -0.4457    0.7390    0.8502
0.7390    0.6026   -0.8502   -0.4457    0.9325    0.2737   -0.9830
0.8502    0.0923   -0.9325    0.7390    0.2737   -0.9830    0.6026
0.9325   -0.4457   -0.2737    0.8502   -0.9830    0.6026    0.0923
0.9830   -0.8502    0.6026   -0.2737   -0.0923    0.4457   -0.7390
1.0000   -1.0000    1.0000   -1.0000    1.0000   -1.0000    1.0000
Columns 8 through 9
0.9830    1.0000
-0.8502   -1.0000
0.6026    1.0000
-0.2737   -1.0000
-0.0923    1.0000
0.4457   -1.0000
-0.7390    1.0000
0.9325   -1.0000
-1.0000    1.0000


## DSTVIII in terms of Tschebyshev polynomials

The DSTVIII matrix can be expressed in terms of Tschebyshev polynomials [1]

where

are roots of polynomial

alpha=sort([roots(TschebyshevV(N-1)); -1],'descend');
DST8t=zeros(N1);
for l=0:N1-1,
DST8t(:,l+1)=polyval(TschebyshevW(l),alpha)';
end
Da8=diag(sin(1/2*pi/(N-1/2)*(k+1/2)));
DST8t=Da8*DST8t                    % display DCTV matrix

% compare DST8 and DST8t matrices (show that both definitions above are equivalent)
max(max(abs(DST8-DST8t)))

DST8t =
Columns 1 through 7
0.0923    0.2737    0.4457    0.6026    0.7390    0.8502    0.9325
0.2737    0.7390    0.9830    0.9325    0.6026    0.0923   -0.4457
0.4457    0.9830    0.7390   -0.0923   -0.8502   -0.9325   -0.2737
0.6026    0.9325   -0.0923   -0.9830   -0.4457    0.7390    0.8502
0.7390    0.6026   -0.8502   -0.4457    0.9325    0.2737   -0.9830
0.8502    0.0923   -0.9325    0.7390    0.2737   -0.9830    0.6026
0.9325   -0.4457   -0.2737    0.8502   -0.9830    0.6026    0.0923
0.9830   -0.8502    0.6026   -0.2737   -0.0923    0.4457   -0.7390
1.0000   -1.0000    1.0000   -1.0000    1.0000   -1.0000    1.0000
Columns 8 through 9
0.9830    1.0000
-0.8502   -1.0000
0.6026    1.0000
-0.2737   -1.0000
-0.0923    1.0000
0.4457   -1.0000
-0.7390    1.0000
0.9325   -1.0000
-1.0000    1.0000
ans =
1.6198e-13


## DSTVII matrix definition

N2=8; N=N2;
k=0:N2-1;  l=0:N2-1;
DST7=sin(pi/(N+1/2)*(k+1/2)'*(l+1))       % display DCTV matrix

DST7 =
Columns 1 through 7
0.1837    0.3612    0.5264    0.6737    0.7980    0.8952    0.9618
0.5264    0.8952    0.9957    0.7980    0.3612   -0.1837   -0.6737
0.7980    0.9618    0.3612   -0.5264   -0.9957   -0.6737    0.1837
0.9618    0.5264   -0.6737   -0.8952    0.1837    0.9957    0.3612
0.9957   -0.1837   -0.9618    0.3612    0.8952   -0.5264   -0.7980
0.8952   -0.7980   -0.1837    0.9618   -0.6737   -0.3612    0.9957
0.6737   -0.9957    0.7980   -0.1837   -0.5264    0.9618   -0.8952
0.3612   -0.6737    0.8952   -0.9957    0.9618   -0.7980    0.5264
Column 8
0.9957
-0.9618
0.8952
-0.7980
0.6737
-0.5264
0.3612
-0.1837


## DSTVII in terms of Tschebyshev polynomials

The DSTVII matrix can be expressed in terms of Tschebyshev polynomials [1]

where

are roots of polynomial

beta=sort([roots(TschebyshevV(N))],'descend');
DST7t=zeros(N);
for l=0:N2-1,
DST7t(:,l+1)=polyval(TschebyshevU(l),beta)';
end
Db7=diag(sin(pi/(N+1/2)*(k+1/2)));
DST7t=Db7*DST7t                    % display DCTV matrix

% compare DST7 and DST7t matrices (show that both definitions above are equivalent)
max(max(abs(DST7-DST7t)))

DST7t =
Columns 1 through 7
0.1837    0.3612    0.5264    0.6737    0.7980    0.8952    0.9618
0.5264    0.8952    0.9957    0.7980    0.3612   -0.1837   -0.6737
0.7980    0.9618    0.3612   -0.5264   -0.9957   -0.6737    0.1837
0.9618    0.5264   -0.6737   -0.8952    0.1837    0.9957    0.3612
0.9957   -0.1837   -0.9618    0.3612    0.8952   -0.5264   -0.7980
0.8952   -0.7980   -0.1837    0.9618   -0.6737   -0.3612    0.9957
0.6737   -0.9957    0.7980   -0.1837   -0.5264    0.9618   -0.8952
0.3612   -0.6737    0.8952   -0.9957    0.9618   -0.7980    0.5264
Column 8
0.9957
-0.9618
0.8952
-0.7980
0.6737
-0.5264
0.3612
-0.1837
ans =
1.4100e-13


## Finding relations

Because there exist relation

and

we can express DSTVIII through DSTVII

where

B=toeplitz([1 zeros(1,N-1)]',[1  1 zeros(1,N-length([1  1]))]);
B=[B [0; B(1:end-1,end)]];
B(8,9)=2;
B=[B; (-1).^(0:size(B,2)-1)];


## Check expression of DSTVIII through DSTVII

DST8a=Da8*blkdiag(inv(Db7)*DST7,1)*B
% compare DST8 and DST8a matrices (show correctness of representation of DSTVIII through DSTVII)
max(max(abs(DST8-DST8a)))

DST8a =
Columns 1 through 7
0.0923    0.2737    0.4457    0.6026    0.7390    0.8502    0.9325
0.2737    0.7390    0.9830    0.9325    0.6026    0.0923   -0.4457
0.4457    0.9830    0.7390   -0.0923   -0.8502   -0.9325   -0.2737
0.6026    0.9325   -0.0923   -0.9830   -0.4457    0.7390    0.8502
0.7390    0.6026   -0.8502   -0.4457    0.9325    0.2737   -0.9830
0.8502    0.0923   -0.9325    0.7390    0.2737   -0.9830    0.6026
0.9325   -0.4457   -0.2737    0.8502   -0.9830    0.6026    0.0923
0.9830   -0.8502    0.6026   -0.2737   -0.0923    0.4457   -0.7390
1.0000   -1.0000    1.0000   -1.0000    1.0000   -1.0000    1.0000
Columns 8 through 9
0.9830    1.0000
-0.8502   -1.0000
0.6026    1.0000
-0.2737   -1.0000
-0.0923    1.0000
0.4457   -1.0000
-0.7390    1.0000
0.9325   -1.0000
-1.0000    1.0000
ans =
4.8850e-15


## Check expression of DSTVII through DSTVIII

DST7a=blkdiag(Db7,1)*inv(Da8)*DST8*inv(B);
DST7a=DST7a(1:end-1,1:end-1)
% compare DST7 and DST7a matrices (show correctness of representation of DSTVII through DSTVIII)
max(max(abs(DST7-DST7a)))

DST7a =
Columns 1 through 7
0.1837    0.3612    0.5264    0.6737    0.7980    0.8952    0.9618
0.5264    0.8952    0.9957    0.7980    0.3612   -0.1837   -0.6737
0.7980    0.9618    0.3612   -0.5264   -0.9957   -0.6737    0.1837
0.9618    0.5264   -0.6737   -0.8952    0.1837    0.9957    0.3612
0.9957   -0.1837   -0.9618    0.3612    0.8952   -0.5264   -0.7980
0.8952   -0.7980   -0.1837    0.9618   -0.6737   -0.3612    0.9957
0.6737   -0.9957    0.7980   -0.1837   -0.5264    0.9618   -0.8952
0.3612   -0.6737    0.8952   -0.9957    0.9618   -0.7980    0.5264
Column 8
0.9957
-0.9618
0.8952
-0.7980
0.6737
-0.5264
0.3612
-0.1837
ans =
1.7208e-15


## Check computation of DSTVIII transform

x=randn(N1,1);
disp('x''=');disp(x');
y=DST8*x;                      % true result
disp('y''=');disp(y');
y1=Da8*blkdiag(inv(Db7)*DST7,1)*B*x;            % compute DSTVIII using DSTVII transform
disp('y1''=');disp(y1');

x'=
Columns 1 through 7
0.9642    0.5201   -0.0200   -0.0348   -0.7982    1.0187   -0.1332
Columns 8 through 9
-0.7145    1.3514
y'=
Columns 1 through 7
1.0025   -0.4754    1.6154    0.9415    2.1413   -2.1092    3.9088
Columns 8 through 9
-0.8884    0.5748
y1'=
Columns 1 through 7
1.0025   -0.4754    1.6154    0.9415    2.1413   -2.1092    3.9088
Columns 8 through 9
-0.8884    0.5748


## Check computation of DSTVII transform

x=randn(N2,1);
disp('x''=');disp(x');
y=DST7*x;                      % true result
disp('y''=');disp(y');
y1=blkdiag(Db7,1)*inv(Da8)*DST8*inv(B)*[x;0];            % compute DSTVII using DSTVIII transform
disp('y1''=');disp(y1');
% Reference

x'=
Columns 1 through 7
-0.2248   -0.5890   -0.2938   -0.8479   -1.1201    2.5260    1.6555
Column 8
0.3075
y'=
Columns 1 through 7
2.2859   -3.8946   -0.4126    3.0927   -3.5857    0.8359    2.0049
Column 8
-1.3812
y1'=
Columns 1 through 7
2.2859   -3.8946   -0.4126    3.0927   -3.5857    0.8359    2.0049
Columns 8 through 9
-1.3812   -0.0000