Commit 923884b3 authored by Gidon Lucian Bauer's avatar Gidon Lucian Bauer 🏳
Browse files

Schönere Ausgabe der Ergebniss

parent e7c52e2a
......@@ -49,7 +49,6 @@ legend('u_0', 'estimation for u_0');
max_iter = 250;
iter = zeros(n,max_iter); % store all iterates
% ...
s = svd(A); % singular values of A
......@@ -61,28 +60,19 @@ end
k_star = -1; % stopping index
eps_alpha = 1e-01;
disp(d(k_star, A, u_f_meas));
% d(alpha)
% d'(alpha)
% -> Eulermethode
% disc_para = norm(A * iter(:,i) - u_f_meas, 2);
% if (abs(disc_para - eps_alpha) <= 1e-8)
% k_star = i;
% end
xi_norm = zeros(max_iter-1, 1);
disc = zeros(max_iter-1, 1);
C_xi_norm = zeros(max_iter-1, 1);
discrepancy = zeros(max_iter-1, 1);
for i = 2:max_iter
iter(:,i) = iter(:,i-1) - beta * A' * (A * iter(:,i-1) - u_f_meas);
% c)?
xi_norm(i-1) = norm(iter(:,i), 2);
disc(i-1) = norm(A*iter(:,i) - u_f_meas, 2);
discrepancy(i-1) = norm(A*iter(:,i) - u_f_meas, 2);
% d)
C_xi_norm(i-1) = norm(C*iter(:,i), 2);
% b)
if disc(i-1) <= eps_alpha && k_star == -1
if discrepancy(i-1) <= eps_alpha && k_star == -1
k_star = i;
disp(k_star);
disp(norm(A*iter(:,i) - u_f_meas, 2));
......@@ -93,8 +83,8 @@ end
figure(2);
plot(x, u_0, 'DisplayName', 'exact');
hold on;
plot(x, iter(:, k_star), 'DisplayName', 'estimate for k*');
plot(x, iter(:, end), 'DisplayName', 'estimate max iter');
plot(x, iter(:, k_star), 'DisplayName', ['estimate for k* = ', num2str(k_star)]);
plot(x, iter(:, end), 'DisplayName', ['estimate for k = ', num2str(max_iter)]);
xlabel('x');
ylabel('temperature');
legend;
......@@ -105,28 +95,26 @@ figure(3);
plot(x, u_f, 'DisplayName', 'exact');
hold on;
plot(x, u_f_meas, 'DisplayName', 'measurment');
plot(x, A*iter(:, k_star), 'DisplayName', 'y bar');
plot(x, A*iter(:, k_star), 'DisplayName', '$\bar{y}$');
xlabel('x');
ylabel('temperature');
legend;
legend('Interpreter', 'latex');
hold off;
figure(4);
% loglog(2:max_iter, disc, '*', 'DisplayName', 'Discrepancy');
loglog(disc(1:end), xi_norm(1:end), '*', 'DisplayName', 'Discrepancy');
loglog(discrepancy(1:end), xi_norm(1:end), '.', 'DisplayName', 'Discrepancy');
hold on;
% loglog(2:max_iter, temp, 'DisplayName', '\xi');
xlabel('Discrepancy');
ylabel('\xi norm');
xlabel('$||A \tilde{\xi_k} - \tilde{y}||_2$', 'Interpreter', 'latex');
ylabel('$||\tilde{\xi_k}||_2$', 'Interpreter', 'latex');
title('L curve');
legend;
hold off;
figure(5);
loglog(disc, C_xi_norm, '*', 'DisplayName', 'Discrepancy');
loglog(discrepancy, C_xi_norm, '.', 'DisplayName', 'Discrepancy');
hold on;
xlabel('Discrepancy');
ylabel('C-\xi norm');
xlabel('$||A \tilde{\xi_k} - \tilde{y}||_2$', 'Interpreter', 'latex');
ylabel('$||C \tilde{\xi_k}||_2$', 'Interpreter', 'latex');
title('L curve');
legend;
hold off;
\ No newline at end of file
function res = d(alpha, A, y_tilde)
% to_min = @(xi) norm(A * xi - y_tilde, 2)^2 + alpha^2 * norm(xi, 2)^2;
% xi_alpha = fminsearch(to_min, zeros(length(A)));
xi_alpha = (A'*y_tilde)\(A'*A + alpha^2*eye(size(A)));
xi_alpha = xi_alpha';
res = norm(A * xi_alpha - y_tilde, 2);
end
\ No newline at end of file
function res = d_der(alpha, s, y_tilde)
end
\ No newline at end of file
function y = g_alpha(z, alpha)
y = z^2 / (z^2 * alpha^2);
end
\ No newline at end of file
Markdown is supported
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