Nice introduction on the Galerkin method. As for the second example(quadratic shape functions), in Matlab code, phi should be modified into "phi=[2*(x-1/2)*(x-1); -4*x*(x-1); 2*x*(x-1/2)]" , the second phi2 has type error. Then, the final coefficients will be [u1 u2 u3]=[0 1/4 1] that is perfectly matching the true function x^2.
Yes, you are right, good catch! I did not simplify that expression in the video, otherwise we would have seen that it is indeed not x^2. The example on the website is accurate however. Thanks for pointing it out!