%% Matrix Squareroot of Difference Operator
% Create a matrix representation of the fourth difference operator, A. This matrix is symmetric and positive definite.

A = [5 -4 1 0 0; -4 6 -4 1 0; 1 -4 6 -4 1; 0 1 -4 6 -4; 0 0 1 -4 6]

%
% Calculate the unique positive definite square root of A using sqrtm. X is the matrix representation of the second difference operator.

X = round(sqrtm(A))

% Copyright 2015 The MathWorks, Inc.