u1 = 
        0;
n1 = 1 - (x/L);  n2 = x/L; 
ua = u1*n1 + u2*n2; 
    ub = u2*n1 + u3*n2;
  
W = 
      Integrate[AE/2 (D[ua, x])^2  -  w ua, {x, 0, L}] + 
        Integrate[
          AE/2 (D[ub, x])^2  -  w ub, {x, 0, 
            L}]
  
UU = Solve[{D[W, u2], D[W, u3]} == 0, {u2, 
            u3}][[1]]
  
ua1 = D[ua, x]; ub1 = D[ub, x]
u = 
        UnitStep[L - x] (ua /. UU) + 
          UnitStep[
              x - L] (ub /. UU /. 
                x -> (x - L));
u1 = 
        UnitStep[L - x] (ua1 /. UU) + 
          UnitStep[
              x - L] (ub1 /. UU /. 
                x -> (x - L));
  
valw = {AE -> 1, L -> 1, 
          w -> 1};
  
Plot[{u /. valw, u1 /. valw}, {x, 0, 2}, 
      PlotStyle -> {Hue[1], Hue[0.3]}]