function [y,x] = MaxNorm(fn_,a,b,n)
% usage: [y,x] = MaxNorm(fcn,a,b,n) or y=MaxNorm(fcn,a,b,n)
% description: returns the max norm y of the function f(x) on the
% interval a<=x<=b based on a uniform sample of n points and
% returns the first point x where the max occurs. Observe that the
% function name fcn is a string, so must be quoted, or use a handle.

% local variables:
% h: stepsize for sampling
% xc: current sample point
% fxc: abs of function value at current sample point
% j: index variable

xc = a;
x = a;
y = 0;
h = (b-a)/(n-1);
for j=1:n
  fxc = abs(feval(fn_,xc));
  if (y < fxc)
    y = fxc;
    x = xc;
  end;
  xc = xc + h;
end;
