Newbie question: diff,ratsimp,factor



On 13 Feb 2007 07:00:02 -0000, Scott Ballantyne <sdb at ssr.com> wrote:
>
> Experimenting with maxima for the first time, I tried to compute the
> derivative of (%e^x-%e^(-x))/(%e^x+%e^(-x)), which I believe should
> be: 4/(e^x+e^-x)^2.
>
> Maxima gives 1 - (e^x-e^(-x))^2/(e^x+e^(-x))^2
>
> which is of course fine, but when I try to simplify this (I used
> ratsimp(%) and then factor(%)), maxima delivers
>
> 4e^(2x)/(e^(2x)+1)^2
>
> Perhaps this is correct...
>

As previous writers have mentioned, there are *many* correct forms.  Here
are a few, in increasing order of length.  Pick your favorite.

sech(x)^2
1/cosh(x)^2
1-tanh(x)^2
2/(cosh(2*x)+1)
{4/(%e^x+%e^-x)^2
1-sinh(x)^2/cosh(x)^2
-(tanh(x)-1)*(tanh(x)+1)
4*%e^(2*x)/(%e^(2*x)+1)^2
1-(%e^x-%e^-x)^2/(%e^x+%e^-x)^2
-(sinh(x)^2-cosh(x)^2)/cosh(x)^2
4*%e^(2*x)/(%e^(4*x)+2*%e^(2*x)+1)
-(sinh(x)-cosh(x))*(sinh(x)+cosh(x))/cosh(x)^2
-sech(x)^2*(-cosh(2*x)/2-(2-2*cosh(2*x))/4-1/2)
4*(sinh(2*x)+cosh(2*x))/(sinh(2*x)+cosh(2*x)+1)^2
-4*((%e^x-%e^-x)^2/4-(%e^x+%e^-x)^2/4)/(%e^x+%e^-x)^2
4*(sinh(2*x)+cosh(2*x))/(sinh(4*x)+cosh(4*x)+2*sinh(2*x)+2*cosh(2*x)+1)
4*(sinh(2*x)+cosh(2*x))/(sinh(4*x)+cosh(4*x)+2*(sinh(2*x)+cosh(2*x))+1)
(4*sinh(2*x)+4*cosh(2*x))/(sinh(4*x)+cosh(4*x)+2*sinh(2*x)+2*cosh(2*x)+1)
-4*((%e^x-%e^-x)/2-(%e^x+%e^-x)/2)*((%e^x+%e^-x)/2+(%e^x-%e^-x)/2)/(%e^x+%e^-x)^2
-1/(%e^(4*x)+2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osh(x)^2)+6*cosh(x)^2*sinh(x)^2+4*cosh(x)^3*sinh(x)+cosh(x)^4+1)+1

These were generated by:

ops:'[factor,trigify,radcan,rectform,polarform,trigsimp,trigrat,trigreduce,trigexpand,factorsum,ratsimp,exponentialize]$
moreforms(forms) :=
xreduce('union,makelist(setify(makelist((q)(r),q,ops)),r,listify(forms)))$
forms:{1-(%e^x-1/%e^x)^2/(%e^x+1/%e^x)^2};
forms: moreforms(forms);
(iterate as much as you want...)

Have fun

              -s