factor/simplification problem



Thanks Stavros, that is powerful and flexible and I have learned a lot
from your example.  I think I now mostly understand substpart and it
will definitely help with fine tuning.

Is there a way to do this sort of thing less interactively?  It seems
like I need to first use part to find out which terms I want to work
with and then use substpart on those terms.  (I know, you solved my
problem and I should  just be happy).  I often call Maxima from Python
and it would be awesome to write some algorithm that handles this
automatically - possibly through a recursive call to substpart with
factorsum ?   As a first step in this direction, I tried to just call
factorsum on the numerator and denominator from num and denom (my
expressions will always be fractions of transcendental expressions).
But the weird thing is that factorsum doesn't seem to work on the
numerator:


(%i56) N:num(test)
(%o56) L^3*(cos(beta)*sinh(beta)*c*s*L-cosh(beta)*sin(beta)*c*s*L+cos(beta)*sinh(beta)*k*L-
cosh(beta)*sin(beta)*k*L-2*beta*sin(beta)*sinh(beta)*EI)
(%i58) factorsum(D)
(%o58) beta^3*EI*
((cos(beta)*cosh(beta)+1)*(c*s+k)*L+beta*(cos(beta)*sinh(beta)-cosh(beta)*sin(beta))*EI)
factorsum(N);
(%i59) factorsum(N)
(%o59) L^3*(cos(beta)*sinh(beta)*c*s*L-cosh(beta)*sin(beta)*c*s*L+cos(beta)*sinh(beta)*k*L-
cosh(beta)*sin(beta)*k*L-2*beta*sin(beta)*sinh(beta)*EI)
(%i60) substpart(factorsum(piece),N,2,[1,2,3,4])
(%o60) L^3*((cos(beta)*sinh(beta)-cosh(beta)*sin(beta))*(c*s+k)*L-2*beta*sin(beta)*sinh(beta)*EI)


If I could make factorsum always work on the numerator and denominator
separately, I think I could make this work algorithmically (i.e.
non-interactively).

Thanks again,

Ryan


On 5/15/07, Stavros Macrakis <macrakis at alum.mit.edu> wrote:
> On 5/15/07, Ryan Krauss <ryanlists at gmail.com> wrote:
>
> > cos(beta)*cosh(beta)*L*c*s+cos(beta)*cosh(beta)*L*k
> >
> > I don't seem to be able to make Maxima factor/simplify this as
> > cos(beta)*cosh(beta)*L*(c*s+k)
> >
>
> factorsum will take the first expression to the second.
>
> However, factorsum only operates on the numerator.  To apply to both the
> numerator and the denominator, the simplest way is map(factorsum,test).
>
> You can also control the application of factor and factorsum in more detail
> using substpart (qv). Here's a little transcript (using very wide lines so
> the structure will be clear)...
>
> test =>
>
>      3
>    L  (cos(beta) sinh(beta) c s L - cosh(beta) sin(beta) c s L + cos(beta)
> sinh(beta) k L - cosh(beta) sin(beta) k L - 2 beta sin(beta) sinh(beta) EI)
>
> ---------------------------------------------------------------------------------------------------------------------------------------------------
>           3
>        beta  EI (cos(beta) cosh(beta) c s L + c s L + cos(beta) cosh(beta) k
> L + k L + beta cos(beta) sinh(beta) EI - beta cosh(beta) sin(beta) EI)
>
>  map(factorsum,%) =>
>
>
>      3
>    L  (cos(beta) sinh(beta) c s L - cosh(beta) sin(beta) c s L + cos(beta)
> sinh(beta) k L - cosh(beta) sin(beta) k L - 2 beta sin(beta) sinh(beta) EI)
>
> ---------------------------------------------------------------------------------------------------------------------------------------------------
>                             3
>                          beta  EI ((cos(beta) cosh(beta) + 1) (c s + k) L +
> beta (cos(beta) sinh(beta) - cosh(beta) sin(beta)) EI)
>
>  substpart(factor(piece),%,1,2,[1,2,3,4]) =>
>
>           3
>         L  ((cos(beta) sinh(beta) - cosh(beta) sin(beta)) (c s + k) L - 2
> beta sin(beta) sinh(beta) EI)
>
> ---------------------------------------------------------------------------------------------------------
>         3
>    beta  EI ((cos(beta) cosh(beta) + 1) (c s + k) L + beta (cos(beta)
> sinh(beta) - cosh(beta) sin(beta)) EI)
>
>
> Alternatively:
>
> testfs1: substpart(factorsum(piece),testfs,1,2,[1,3,5]);
>
>      3
>     L  (sinh(beta) (cos(beta) (c s + k) L - 2 beta sin(beta) EI) -
> cosh(beta) sin(beta) c s L - cosh(beta) sin(beta) k L)
>
> ---------------------------------------------------------------------------------------------------------------------
>               3
>            beta  EI ((cos(beta) cosh(beta) + 1) (c s + k) L + beta
> (cos(beta) sinh(beta) - cosh(beta) sin(beta)) EI)
>
>   substpart(factorsum(piece),testfs1,1,2,[2,3]);
>
>          3
>          L  (sinh(beta) (cos(beta) (c s + k) L - 2 beta sin(beta) EI) -
> cosh(beta) sin(beta) (c s + k) L)
>
> ---------------------------------------------------------------------------------------------------------
>         3
>     beta  EI ((cos(beta) cosh(beta) + 1) (c s + k) L + beta (cos(beta)
> sinh(beta) - cosh(beta) sin(beta)) EI)
>
> Substpart is worth getting comfortable with if you want to do fine-tuning of
> the form of an expression.
>
>            -s
>
>