echo off;

%****************************************************************************
%                                                                           *
%     Project: Homework 3 - Exercise 3.8                                    *
%   Copyright: Copyright © 2003. All Rights Reserved                        *
%    Compiler: Matlab 6.5 for Windows                                       *
%     Company: RT Mnemonic <mnemonic@eunet.at>                              *
%      Author: Rainer Trummer                                               *
%        Date: November 16, 2003                                            *
%                                                                           *
%****************************************************************************

% Problem Description:
% Suppose that A is an m*n matrix of rank n.
% Prove that the matrix A^T*A is positive definite.

% Create random dimensions m and n
m = floor(rand*10);
n = floor(rand*10);

while n > m || n < 2
    m = floor(rand*10);
    n = floor(rand*10);
end

% Create random matrix A of rank n
A = rand(m,n) - rand(m,n);

while rank(A) < n
    A = rand(m,n) - rand(m,n);
end

% Create random vector x of size n
x = rand(n,1) - rand(n,1);

while norm(x) == 0
    x = rand(n,1) - rand(n,1);
end

% Display all values and results
echo on;
m
n
A
rank(A)
A'
A'*A
x
x'*(A'*A)*x

% End of file.