% clc
% clear all
% close all

% initialise the space variable
N  = 100;            % number of nodes
dx = 1/(N-1);        
x  = [0:dx:1]';
f  = x.*(x-1);      % source term

%A = eye(N,N);       % initialisation of the Finite Difference matrix
A = speye(N,N);     

for i=2:N-1
     A(i,i-1)=  1/dx^2 ;
     A(i,i)  = -2/dx^2 ;
     A(i,i+1)=  1/dx^2 ;
end

% measure the time of the inversion
tic
% solving the linear system
T= A\f;
% compute time needed to solve the linear problem 
time_to_solve=toc

% to display the results
figure(1)
% command to plot T as a function of x, in blue
plot(x,T,'b')
% labels of the axis
xlabel('x')
ylabel('T')

