function r = int(f,x,a,b)
%INT	Integrate.
%	INT(S) is the indefinite integral of S with respect to its symbolic
%	variable.  See SYMVAR for definition of "symbolic variable".
%	INT(S,'v') is the indefinite integral of S with respect to v.
%	INT, with no arguments, is the indefinite integral of the previous
%	expression with repect to its symbolic variable.
%	INT(S,a,b) is the definite integral of S with respect to its
%	    symbolic variable from a to b.
%	INT(S,'v',a,b) is the definite integral of S with respect to v
%	    from a to b.
%
%	Example: int('1/(1+x^2)') is arctan(x) .
%
%	See also SYMVAR, DIFF, SYMSUM.

%	Copyright (c) 1993-95 by The MathWorks, Inc.
%	$Revision: 1.10 $  $Date: 1995/03/01 21:38:50 $

if nargin == 0
   f = maple('"');
elseif strcmp(f,'ans')
   f = maple('"');
end

if f(1) ~= '['
   % Scalar symbolic expression
   if nargin <= 2
      % Indefinite integral
      if nargin < 2, x = symvar(f); end
      r = maple('int',f,x); 
   else
      % Definite integral
      if nargin < 4, b = a; a = x; x = symvar(f); end
      r = maple('int',f,[x '=' symrat(a) '..' symrat(b)]);
   end
else
   % Symbolic matrix.
   if nargin <= 2
      % Indefinite integral
      if nargin < 2, x = symvar(f); end
      r = maple('map','int',f,x);
   else
      % Definite integral
      if nargin < 4, b = a; a = x; x = symvar(f); end
      r = maple('map','int',f,[x '=' symrat(a) '..' symrat(b)]);     
   end
end
