%% Ejercicio 1

clear all
close all
clc

A = create_trid(10,4,1,1);
rank(A)

d = rand(10,1);

x1 = A\d;

[L,U,P] = lu(A);

x2 = U\(L\(P*d));
norm(x1-x2)

%% Ejercicio 2
clear all
close all
clc

prom1 = 0;
prom2 = 0;
for i = 1:20
    [t1,t2,norma] = variossistemas;
    prom1 = prom1 + t1;
    prom2 = prom2 + t2;
end
prom1 = prom1/20
prom2 = prom2/20

%% Ejercicio 3
clear all
close all
clc

W = 200;
S = 50;
xin = 0.075;
yin = 0;
n = 6;
m = 7;
[A,b] = reactor_quimico(W,S,n,m,xin,yin);
x = A\b;
disp('fraccion final de masa del quimico en agua')
x(n)
disp('fraccion final en solvente')
m*x(n)



%% Ejercicio 4
clear all
close all
clc

h = 0.1;
[A b] = calcularAb_lab3(h);
R = chol(A);
u = R\(R'\b);
u = [1; u; 1];
plot([0 h:h:1-h 1],u)
hold on
x = linspace(0,1,100);
plot(x,2*x.^2-2*x+1,'r');







