% Exercícios 18.17 - 18.25
clear all
clc

fprintf('Ex 18.17\n')
A = [4 1 0 -1; 2 5 -2 -1; 0 1 4 -1; -2 1 2 3];
[Q,Ah]=jordan(A)

clc
fprintf('Ex 18.18\n')
A = [5 1 0 -1; 0 4 0 0; 0 0 4 0; 1 1 0 3];
[Q,Ah]=jordan(A)

clc
fprintf('Ex 18.19\n')
A = [5 1 2 -1; 0 4 -2 0; 0 0 4 0; 1 1 0 3];
[Q,Ah]=jordan(A)

clc
fprintf('Ex 18.20\n')
A = [0 1 0 0; 0 0 1 0; 0 0 0 1; -16 32 -24 8];
[Q,Ah]=jordan(A)

clc
fprintf('Ex 18.21\n')
A = [0 1 0 0; 0 0 1 0; 0 0 0 1; -8 20 -18 7];
[Q,Ah]=jordan(A)

%%

clc
fprintf('Ex 18.22\n')
A = [4 1 0 -1; 2 5 -2 -1; 0 1 4 -1; -2 1 2 3];
Q = [4 0 0 4; 4 2 0 0; 4 0 -1 4; 4 -2 0 0];
Ah = inv(Q)*A*Q

clc
fprintf('Ex 18.23\n')
A = [0 1 0 0; 0 0 1 0; 0 0 0 1; -16 32 -24 8];
Q = [1 0 0 0; 2 1 0 0; 4 4 1 0; 8 12 6 1];
Ah = inv(Q)*A*Q

clc
fprintf('Ex 18.24\n')
A = [5 1 0 -1; 0 4 0 0; 0 0 4 0; 1 1 0 3];
Q = [1 1 1 0; 1 0 0 0; 0 1 0 0; 2 1 1 -1];
Ah = inv(Q)*A*Q

clc
fprintf('Ex 18.25\n')
A = [5 1 2 -1; 0 4 -2 0; 0 0 4 0; 1 1 0 3];
Q = [1 0 0 0; 0 0 1 0; 0 0 0 -1/2; 1 -1 1 -1];
Ah = inv(Q)*A*Q
