function lipSync_sol = ashlee( f_x, a, b, N)
%  Compute the integral of the function f(x)
%  between the limits a and b using Simpson's Method
%  with N subintervals. N must be an even integer and
%  b > a.
%  oj is a function that computes the coefficients
%  1, 2, 4, 2, 4, 2, ..., 1
%  jessica is a function that computes f(xn)'s.
h = (b-a) / N;
HomerSimpson_sum = 0;
for n_count=1:N+1
    n = n_count - 1;
    HomerSimpson_sum = HomerSimpson_sum + oj(n,N) * jessica(f_x,n,a,b,N);
end
lipSync_sol = (b-a)/(3*N) * HomerSimpson_sum;


function coefficient = oj(n_input,N_input)
%  Compute the Simpson's Method coefficients 1,2,4,2,4,2,...1
if n_input == 0 | n_input == N_input
    coefficient = 1;
    return
end
if rem(n_input,2) == 0   % If n is even then coefficient = 2
    coefficient = 2;
    return
end
    coefficient = 4;    % If n is odd then coefficient = 4


function f_value = jessica(f_x, n, a, b, N)
%  jessica is a function that computes f(x) at the x value
%  specified by the index n, and the subinterval specified by
%  a, b and N.
f = fcnchk(f_x);
x = a + n * (b-a)/N;
f_value = f(x);