close all
clear all

ra = 6;
rb = 2;

c = -1;

n = 9;

tau = 0.1*ones(1,n+1)%rand(1,n+1);
%tau = tau/sum(tau);

x(1) = 0;

for i = 2:n+1
	x(i) = sum(tau(1:i-1));
end
x(n+2) = 1;

f = 2;

A = zeros(n);
b = zeros(n,1);

for i = 1:n
	%Diagonalelemente
	A(i,i) = -1/tau(i) - 1/tau(i+1) + c*(1/3*tau(i) + 1/tau(i)*x(i+1)*x(i+1) - x(i+1) + 1/3*tau(i+1) + 1/tau(i+1)*x(i+2)*x(i+2) - x(i+2));
	%Ladevektor
	b(i) = tau(i) + tau(i+1) - c*(1/3*(rb-ra)*(tau(i)^2 - tau(i+1)^2) + 1/2*(rb-ra)*tau(i)*(tau(i) - tau(i+1)) + ra*tau(i));
end

for i = 1:n-1
	%Oben
	A(i,i+1) = 1/tau(i) + c*(1/3*tau(i) + 1/2*x(i+2)*tau(i) + 1/2*x(i+2) - tau(i)*x(i+2)*x(i+2));
	%Unten
	A(i+1,i) = 1/tau(i) + c*(1/3*tau(i) + 1/2*x(i+2)*tau(i) + 1/2*x(i+2) - tau(i)*x(i+2)*x(i+2));
end

A

b


A\b

	




