Thanks for contributing your trigcomb function. A couple of minor comments
on the way it's written:
* defining a function within a function defines a global function; to make
it local, you need to write local(func)
* load() shouldn't be used within a function -- the load will happen every
time the function is run. Best to use load() outside the function
definition (unfortunately, Maxima doesn't have a standard 'require'
function, and even checking whether a function is defined is ugly)
* you should probably use a gensym instead of 'i' as the temporary name for
%i to avoid variable collisions
It seems to me that we should have standard built-in functions for
converting among trigonometric, hyperbolic, and exponential forms. Right
now, we have trig,hyp -> exponential (using exponentialize) and complex
exponential -> trig (using demoivre), but the other cases aren't handled.
-s
On Mon, Nov 25, 2013 at 4:00 PM, Aleksas Domarkas <aleksasd873 at gmail.com>wrote:
> On Mon, Nov 25, 2013 at 9:58 AM, Henry Baker <hbaker1 at pipeline.com<http://www.math.utexas.edu/mailman/listinfo/maxima>>
> wrote:
>
> >What is the antidote for trigexpand with complex arguments?
> >
> >trigreduce doesn't seem to work here.
> >
> >Maxima 5.28.0-2 http://maxima.sourceforge.net
> >using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (a.k.a. GCL)
> >Distributed under the GNU Public License. See the file COPYING.
> >Dedicated to the memory of William Schelter.
> >The function bug_report() provides bug reporting information.
> >(%i1) cos(p+q*%i);
> >(%o1) cos(%i q + p)
> >(%i2) trigexpand(%);
> >(%o2) cos(p) cosh(q) - %i sin(p) sinh(q)
> >(%i3) trigreduce(%);
> >(%o3) cos(p) cosh(q) - %i sin(p) sinh(q)
> >(%i4)
>
>
>
>
> I define
>
> (%i1) trigcomb(r):=block([x,i,sinv,cosv,mi,mii,%iargs:false],
> mi(x):=%i*x,
> mii(x):=-%i*x,
> load(to_poly_solve),
> sinv:compose_functions([mii,sin,mi]),
> tanv:compose_functions([mii,tan,mi]),
> cosv:compose_functions([cos,mi]),
> cotv:compose_functions([mi,cot,mi]),
> subst([sinh=sinv,cosh=cosv,tanh=tanv,coth=cotv],r),
> subst(%i=i,%%),
> trigrat(%%),
> trigreduce(%%),
> subst(i=%i,%%)
> )$
>
> Examples:
> 1.
> (%i2) cos(p+q*%i);
> (%o2) cos(%i*q+p)
> (%i3) trigexpand(%);
> (%o3) cos(p)*cosh(q)-%i*sin(p)*sinh(q)
> (%i4) trigcomb(%);
> Loading maxima-grobner $Revision: 1.6 $ $Date: 2009-06-02 07:49:49 $
> (%o4) cos(%i*q+p)
>
> 2.
> (%i5) sin(a+b*%i);
> (%o5) sin(%i*b+a)
> (%i6) trigexpand(%);
> (%o6) %i*cos(a)*sinh(b)+sin(a)*cosh(b)
> (%i7) trigcomb(%);
> (%o7) sin(%i*b+a)
>
> 3.
> (%i8) cos(a*%i+b*%i);
> (%o8) cos(%i*b+%i*a)
> (%i9) trigexpand(%);
> (%o9) sinh(a)*sinh(b)+cosh(a)*cosh(b)
> (%i10) trigcomb(%);
> (%o10) cos(%i*b+%i*a)
>
> 4.
> (%i11) tan(a+%i*b);
> (%o11) tan(%i*b+a)
> (%i12) trigexpand(%);
> (%o12) (%i*tanh(b)+tan(a))/(1-%i*tan(a)*tanh(b))
> (%i13) trigcomb(%);
> (%o13) tan(%i*b+a)
>
> 5.
> (%i14) cot(x+%i*y);
> (%o14) cot(%i*y+x)
> (%i15) trigexpand(%);
> (%o15) (-%i*cot(x)*coth(y)-1)/(cot(x)-%i*coth(y))
> (%i16) trigcomb(%);
> (%o16) cot(%i*y+x)
>
> best
>
> Aleksas D
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>