%
% Linear Functional Homework
%
%  The M-files below evaluate
%
%    f(x) = int_0^1 (1+t) x(t) dt
%
%  with x(t) = t.  For x(t)=t, show by hand that f(x)=5/6.  In MatLab
%  type  lfun('fsamp')  and get .8333.   Modify   intgnd.m  and  fsamp.m
%  so that lfun('fsamp') computes the new linear functional
%
%    f(x) = int_0^1 sqrt(t) x(t) dt
%
%  with x(t) = t^2.  Evaluate f(x) by hand.  How does this compare with
%  your MatLab result?
%
%  Now use MatLab to compute
%
%    f(x) = int_0^1 x(t) dt
%
%  with x(t) = sin(2 pi n t) for n=1 and n=5.
%  Discuss your results briefly.
%
% lfun.m
% ------
%
function y = lfun(f)
%lfun   Compute a linear functional.  f must be a string variable.
%       For example,  lfun('exp')  or  lfun('sin').
global LINFNAME
LINFNAME = f;
y = quad('intgnd',0,1);


%
% intgnd.m
% --------
%
function z = intgnd(t)
%intgnd  called by lfun
global LINFNAME
z = (1+t).*feval(LINFNAME,t);

%
% fsamp.m
% -------
function y=fsamp(t)
y=t;
