On August 23, 2008, Richard Fateman wrote:
>
> It is possible to collect in a list L,
> all the arguments of sin or cos by scanning the expression.
> Then ... for x in L do ratsubst.....
>
and David Billinghurst wrote:
> The gatherargs() function defined in share/contrib/opsubst.lisp may be
> useful here.
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 )$
(%i4) map( 'trs1, [1-cos(x)^2, cos(x)^2, 1-sin(x)^2, sin(x)^2,
sin(x)^2/(1-cos(x)^2), cos(x)^2/(1-sin(x)^2),
cos(y)*sin(x)^3/(1-cos(x)^2), cos(y)*cos(x)^3/(1-sin(x)^2)]);
(%o4) [sin(x)^2, 1-sin(x)^2, cos(x)^2, 1-cos(x)^2,
1, 1, sin(x)*cos(y), cos(x)*cos(y)]
Ted Woollett