function [X] = my_exp_C1_L2(x_e,pt,wt)   % SHO Schrodinger element
%------------------------------------------------------------------- 
%  Purpose: 
%     USER defined expected value matrix X for val(x)
%     <Y|val|Y> = assembly Y_e' * X * Y_e,
%     X = Integral over length N'(x) * val(x) * N(x) dx
%     matrices for Hermitian line element 
%     nodal dof {v_1 theta_1 v_2 theta_2} , theta = v,x
% 
%  Variable Description: 
%     X - element expected x matrix (size of 4x4) 
%     x_e  - coordinate array
%     leng - element length 
%     pt,wt - Gaussian quadrature data, on -1 to +1
%     x - x at quadrature point    
%------------------------------------------------------------------- 
 
 leng = x_e(2) - x_e(1);     % physical length

  X   = zeros (4, 4); % initialize X
  Jac = leng / 2;     % Jacobian for quadrature rule
  nqp = size(pt,2);   % rule number (here 5 will be exact)

  for j = 1:nqp       % loop over quadrature points
    r = pt(j);        % non-dimensional position
    x = ((1-r)*x_e(1) + (1+r)*x_e(2))/2; % physical x

% form C1 cubic interpolation functions, Y = N_C1*Y_nodes
    N_C1(1) = (2 - 3*r + r^3)/4;          
    N_C1(2) = (1 - r - r^2 + r^3)*leng/8;
    N_C1(3) = (2 + 3*r - r^3)/4;    
    N_C1(4) = (-1 - r + r^2 + r^3)*leng/8;

% expected x matrix: X = Integral, over leng, val(x) * Y' * Y dx
% for use as <Y|val|Y> = Y_nodes' * X * Y_nodes

    val = x;                                 % user defined
    X   = X + val * N_C1' * N_C1 * Jac * wt(j) ;

  end % for j numerical integration loop

% end function my_exp_C1_L2.m
