function uh = Galerkin(n,uD,tau,xi)

syms x

Atilde = zeros(n+1,n+1);
btilde = zeros(n+1,1);

btilde(1) = 1/2;

for i=1:n
  for j=1:n
    Atilde(i+1,j+1) = int(diff(x*(1-x)^(i-1),x)*diff(x*(1-x)^(j-1),x),x,0,1);
  end
  btilde(i+1) = int(10*sin(pi*x)*x*(1-x)^(i-1),x,0,1)
end
btilde(2) = btilde(2) + tau*1;

A = Atilde(2:end,2:end);
b = btilde(2:end) - uD*Atilde(2:end,1);

alfa = A\b;

N = length(xi);
uh = xi; uh(:) = uD*1;
for i=1:n
  uh = uh + alfa(i)*xi.*(1-xi).^(i-1);
end