function [r,h] = simple(s)
%SIMPLE	Search for simplest form of a symbolic expression.
%	SIMPLE(EXPR) tries several different algebraic simplifications of
%	EXPR, displays any which shorten the length of EXPR's representation,
%	and returns the shortest.
%
%	[R,HOW] = SIMPLE(EXPR) does not display intermediate simplifications,
%	but returns the shortest found, as well as a string describing
%	the particular simplification.
%
%	SIMPLE, with no input arguments, uses the previous expression.
%
%	Examples:
%
%	   S                          R                  How
%
%	   cos(x)^2+sin(x)^2          1                  simplify
%	   2*cos(x)^2-sin(x)^2        3*cos(x)^2-1       simplify
%	   cos(x)^2-sin(x)^2          cos(2*x)           combine(trig)
%	   cos(x)+(-sin(x)^2)^(1/2)   cos(x)+i*sin(x)    radsimp
%	   cos(x)+i*sin(x)            exp(i*x)           convert(exp)
%	   (x+1)*x*(x-1)              x^3-x              collect(x)
%	   x^3+3*x^2+3*x+1            (x+1)^3            factor
%	   cos(3*acos(x))             4*x^3-3*x          expand
%
%	See also SIMPLIFY, FACTOR, EXPAND, COLLECT.

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

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

r = s;
h = [];
p = nargout == 0;
[r,h] = simpler('simplify',s,r,h,p);
[r,h] = simpler('radsimp',s,r,h,p);
[r,h] = simpler('combine',s,r,h,p,'trig');
[r,h] = simpler('factor',s,r,h,p);
[r,h] = simpler('expand',s,r,h,p);
[r,h] = simpler('convert',s,r,h,p,'exp');
[r,h] = simpler('convert',s,r,h,p,'sincos');
[r,h] = simpler('convert',s,r,h,p,'tan');
x = symvar(s,0:1);
if ~isempty(x) & ~isnan(x)
   [r,h] = simpler('collect',s,r,h,p,x);
end
