Commit dfee15ac authored by Conor McCoid's avatar Conor McCoid
Browse files

Extrap: test of v2 as underdetermined system solve

parent 6f691b6b
% Example - Extrapolation: fixed point iteration on linear function % Example - Extrapolation: fixed point iteration on linear function
% solve the equation x = Ax + b for random A and b % solve the equation x = Ax + b for random A and b
d = 100; n=2*d; d = 5; n=2*d;
A = rand(d); A = rand(d);
A = A/norm(A); A = A/norm(A);
b = rand(d,1); x_true = -(A - eye(d)) \ b; b = rand(d,1); x_true = -(A - eye(d)) \ b;
...@@ -12,8 +12,8 @@ end ...@@ -12,8 +12,8 @@ end
F = X(:,2:end) - X(:,1:n); F = X(:,2:end) - X(:,1:n);
[x_v1,r_v1] = ALGO_extrap_MPE_v1_20211022(F,X(:,1:n)); [x_v1,r_v1] = ALGO_extrap_MPE_v1_20211022(F,X(:,1:n));
% [x_v2,r_v2] = ALGO_extrap_MPE_v2_20211029(F,X(:,1:n)); [x_v2,r_v2] = ALGO_extrap_MPE_v2_20211029(F,X(:,1:n));
[x_v2,r_v2] = ALGO_extrap_MPE_v3_20211119(F,X(:,1:n)); % [x_v2,r_v2] = ALGO_extrap_MPE_v3_20211119(F,X(:,1:n));
x = x_v1(:,end); x = x_v1(:,end);
Error_abs= norm(x - x_true) Error_abs= norm(x - x_true)
Error_rel= Error_abs/norm(x_true) Error_rel= Error_abs/norm(x_true)
...@@ -25,14 +25,14 @@ Error_v2 = vecnorm(x_v2 - x_true); ...@@ -25,14 +25,14 @@ Error_v2 = vecnorm(x_v2 - x_true);
[x_GMRES,~,~,~,res_GMRES]=gmres(A-eye(d),-b,d,eps,d,eye(d),eye(d),X(:,1)); [x_GMRES,~,~,~,res_GMRES]=gmres(A-eye(d),-b,d,eps,d,eye(d),eye(d),X(:,1));
figure(1) figure(1)
semilogy(1:n,Error_v1,'b*--',1:d+1,Error_v2,'k.--') semilogy(1:n,Error_v1,'b*--',1:length(Error_v2),Error_v2,'k.--')
xlabel('Iteration') xlabel('Iteration')
ylabel('Error in solution') ylabel('Error in solution')
title('Error vs iteration') title('Error vs iteration')
legend('MPE w/ Arnoldi','MPE w/ HH,Givens') legend('MPE w/ Arnoldi','MPE w/ HH,Givens')
figure(2) figure(2)
semilogy(1:n,res_MPE_v1,'b*--',1:d+1,r_v2,'k.--',1:length(res_GMRES),res_GMRES,'ro') semilogy(1:n,res_MPE_v1,'b*--',1:length(r_v2),r_v2,'k.--',1:length(res_GMRES),res_GMRES,'ro')
xlabel('Iteration') xlabel('Iteration')
ylabel('Residual') ylabel('Residual')
title('Residual vs iteration') title('Residual vs iteration')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment