simplify using trigonometric identities



Re:

Are there any 'best practices' for applying basically all simplification
routines to make sure you simplify rationals, exponentials, logarithms,
trigonometric stuff, well basically everything you would expect in the
solution of d.e.'s?


The basic problem is that there is no such thing as the "simplest form" of
an expression.  Many of the routines you mention are designed to
prefer a *particular
form* of an expression.  In particular:

trigexpand and trigreduce are roughly inverses; trigexpand prefers
sin(x)^2, while trigreduce prefers (1-cos(2*x))/2.  Also,
trigexpand(trigexpane(expr)) is not necessarily the same as
trigexpand(expr) -- try for example sin(2*x+a).

Any time you have a 'rat' function, it will prefer a fully-expanded nested
polynomial, e.g. y^2+(2*x+2)*y + x^2 + ... rather than (x+y+1)^2; in that
case, it can easily be reversed with 'factor', but how about (x+1)^3-x^2 =>
x^3+2*x^2+3*x+1

ratsimp with algebraic:true will try to eliminate radicals in the
denominator: do you prefer (sqrt(x)+1)/(sqrt(x)-1) or
-(x+2*sqrt(x)+1)/(x-1)?

exponentialize prefers exponential form; demoivre prefers trig form

etc. etc.

This has been discussed many times on this list.  It is easy enough to
write a system that tries many simplifications until it finds the shortest
form, and though that is fairly feasible for small expressions, it leaves
the question of what "simplest" means.  See below for an extract from an
email I wrote a while ago about this.

            -s

----------------------

...Another important thing is of course defining what you mean by "simple".
 A simple metric is number of characters in string form, but that isn't
necessarily the "nicest" form.  Depending on your goal, any one of the
following may be the "simplest" form:

     (y+x+1)^2-1 (11 chars)
     (y+x)*(y+x+2) (13 chars)
     y^2+(2*x+2)*y+x^2+2*x (21 chars)
     x^2+(2*y+2)*x+y^2+2*y (21 chars)
     y^2+2*x*y+2*y+x^2+2*x (21 chars)]

Also, simply applying trigsimp/ratsimp/etc. multiple times is not the only
way to shorten an expression.  Sometimes you might want to look at all
subexpressions or do other clever things -- how are you going to get
(y+x+1)^2-1
from y^2+2*x*y+2*y+x^2+2*x?

On Fri, Feb 1, 2013 at 4:25 PM, Nijso Beishuizen <nijso at hotmail.com> wrote:

> Ah, thanks, I didn't try that one!
>
> I now have something like this to simplify an expression (usually
> solutions of
> differential equations):
>
> exponentialize:false;
> demoivre:true;
> trigreduce(trigsimp(radcan(ratsimp(trigexpand(radexpand(expr))))));
>
> But I have no idea if part of this sequence of simplifications is doing
> nothing, or if it matters much in which order I perform simplification.
>
> Are there any 'best practices' for applying basically all simplification
> routines to make sure you simplify rationals, exponentials, logarithms,
> trigonometric stuff, well basically everything you would expect in the
> solution of d.e.'s?
>
>
>
> On Friday, February 01, 2013 12:30:09 AM laurent couraud wrote:
> > Hi,
> >
> > It seems to work with trigreduce.
> >
> > Best.
> >
> > > -----Message d'origine-----
> > > De : maxima-bounces at math.utexas.edu
> > > [mailto:maxima-bounces at math.utexas.edu] De la part de Nijso Beishuizen
> > > Envoy? : jeudi 31 janvier 2013 23:57
> > > ? : maxima at math.utexas.edu
> > > Objet : [Maxima] simplify using trigonometric identities
> > >
> > > I have a horrible expression:
> > >
> > > phi:
> > > ((c-1)*cos(x)*sin((c+1)*x)+(1-c)*sin(x)*cos((c+1)*x)
> > > + (-c-1)*cos(x)*sin((c-1)*x)
> > > +(-c-1)*sin(x)*cos((c-1)*x)) /(2*c^2-2);
> > >
> > > which can be simplified to -sin(c*x)/(c^2-1)
> > >
> > > I simplified it by hand using a number of
> > > sin(a+b)=sin(a)cos(b)+sin(b)cos(a) and cos(a+b) rules using subst().
> But
> > > can it be simplified in an automatic way without visual inspection?
> > >
> > > Best,
> > > Nijso
> > >
> > > _______________________________________________
> > > Maxima mailing list
> > > Maxima at math.utexas.edu
> > > http://www.math.utexas.edu/mailman/listinfo/maxima
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>