On August 25, 2008, Stavros Macrakis wrote:
>
> Depends on your definition of "success". Trigrat's purpose is to express
> expressions involving trig functions as a quotient of linear combinations
> of
> trig functions. (sin(y+x)-sin(y-x))/2 is of that form, while sin(x)*cos(y)
> is not. Which is "simpler"? Depends on your goal.
>
> Simplification is complicated.
>
> -s
>
I agree that simplification is in the eye of the beholder.
Often the goal is to compare your result with someone else's,
or compare a hand calculation with a Maxima calc. or
a Mathematica calc. etc.
-----------
On August 24, 2008, Edwin Woollett wrote
>Thanks for the suggestions.
>The following code blends these suggestions:
>(%i1) display2d:false$
>(%i2) load("opsubst.lisp");
>(%o2)
>"C:/PROGRA~1/MAXIMA~1.1/share/maxima/5.16.1/share/contrib/opsubst.lisp"
>
>(%i3) trs1(expr) : = block ( [ee, a, cosargs, sinargs, arglist],
> ee : expr, cosargs : ( gatherargs( expr, 'cos),
> listofvars(%%) ),
> sinargs : ( gatherargs( expr, 'sin), listofvars(%%) ),
> arglist : ( append( cosargs, sinargs), listofvars(%%) ),
> for a in arglist do ee : ratsubst(1, cos(a)^2+sin(a)^2, ee),
> ee )$
>
The above code is not recommended for practical use, since
it is a blunt instrument and tries to affect all cosines and sines.
A sharper tool is cosisimp(...) below, since the user can guess
which sets of trig functions ought to be cancelling out, and
insert the appropriate arguments (and, of course, also
compare the result of using trigsimp).
I have included comparisons with trigsimp for cases
(I have noticed so far) where the result is different:
--------------------------------------------
(%i1) display2d:false$
(%i2) cosisimp(expr,var) := block(
[csargs, ee, a],
csargs : var,
ee : expr,
/* make csargs a list if not already */
if not listp(csargs) then csargs : [csargs],
for a in csargs do
ee : ratsubst(1, sin(a)^2+cos(a)^2, ee ),
ee )$
(%i3) [trigsimp(cos(x)^2), cosisimp(cos(x)^2,x) ];
(%o3) [cos(x)^2, 1-sin(x)^2]
---------------------------------------------------
(%i4) [trigsimp(sin(x)^2), cosisimp(sin(x)^2,x)];
(%o4) [sin(x)^2, 1-cos(x)^2]
------------------------------
(%i5) [ trigsimp( sin(x)^2/(1-cos(x)^2) ),
cosisimp( sin(x)^2/(1-cos(x)^2), x ) ];
(%o5) [-sin(x)^2/(cos(x)^2-1), 1]
-------------------------------
(%i6) [ trigsimp( cos(x)^2/(1-sin(x)^2) ),
cosisimp( cos(x)^2/(1-sin(x)^2), x ) ];
(%o6) [-cos(x)^2/(sin(x)^2-1), 1]
-------------------------------
(%i7) [ trigsimp( cos(y)*sin(x)^3/(1-cos(x)^2) ),
cosisimp( cos(y)*sin(x)^3/(1-cos(x)^2), x ) ];
(%o7) [-sin(x)^3*cos(y)/(cos(x)^2-1), sin(x)*cos(y)]
-----------------------------------------
(%i8) [ trigsimp( cos(y)*cos(x)^3/(1-sin(x)^2) ),
cosisimp( cos(y)*cos(x)^3/(1-sin(x)^2), x ) ];
(%o8) [-cos(x)^3*cos(y)/(sin(x)^2-1), cos(x)*cos(y)]
---------------------------------------
(%i10) trigsimp(cos(z)*sin(x)^2*(cos(y)^2-1)/
(1-cos(x)^2));
(%o10) sin(x)^2*sin(y)^2*cos(z)/(cos(x)^2-1)
(%i11) cosisimp(cos(z)*sin(x)^2*(cos(y)^2-1)/
(1-cos(x)^2),[x,y]);
(%o11) -sin(y)^2*cos(z)
----------------------------
(%i12) trigsimp(cos(z)*sin(x)^2*(1-cos(y)^2)/
(cos(x)^2-1));
(%o12) sin(x)^2*sin(y)^2*cos(z)/(cos(x)^2-1)
(%i13) cosisimp(cos(z)*sin(x)^2*(1-cos(y)^2)/
(cos(x)^2-1),[x,y]);
(%o13) -sin(y)^2*cos(z)
------------------------------
(%i14) trigsimp(cos(z)*sin(x)^3*(cos(y)^2-1)/
(cos(x)^2-1) );
(%o14) -sin(x)^3*sin(y)^2*cos(z)/(cos(x)^2-1)
(%i15) cosisimp(cos(z)*sin(x)^3*(cos(y)^2-1)/
(cos(x)^2-1),[x,y]);
(%o15) sin(x)*sin(y)^2*cos(z)
----------------------------------
There appears to be enough difference that
another tool would be useful.
Another tool I am working on is for additional
simplification of hyperbolic trig functions.
Ted Woollett