function x = solveApprox(A, b, tol)
% solveApprox approximatly solves the system A*x=b
%
% This function solves the system A*x=b by svd only keeping
% singular values such that s(i)/s(1) > tol
%
% x = solveApprox(A, b, tol)
%
%
[U,S,V] = svd(full(A));

s  = diag(S);
sn = s(s./s(1)>tol);
n  = length(sn);

Sninv = diag(1./sn);
Un = U(:, 1:n);
Vn = V(:, 1:n);


x = Vn*Sninv*Un'*b;
end