Factor (1 - a*b) in a Large Expression



Dear everyone,

In deriving so called ``Parabolized Stability Equations" for fluid mechanic
stability, I like to factor an expression like (1 - a*b).

The problem is that, firstly I cannot name the expression differently in
advance, sometimes the product a*b must be dropped...
Secondly, I want to factor *only* this expression.
Using collectterms, facsum and factor does not do the job...

Could you give me some suggestions how this can be done?


Thank you very much!

Koen Groot

2012/10/23 <maxima-request at math.utexas.edu>

> Send Maxima mailing list submissions to
>         maxima at math.utexas.edu
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://www.math.utexas.edu/mailman/listinfo/maxima
> or, via email, send a message with subject or body 'help' to
>         maxima-request at math.utexas.edu
>
> You can reach the person managing the list at
>         maxima-owner at math.utexas.edu
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Maxima digest..."
>
>
> Today's Topics:
>
>    1. Re: heap exhausted with matrix usage (Robert Dodier)
>    2. Re: heap exhausted with matrix usage (andre maute)
>    3. Re: heap exhausted with matrix usage (Barton Willis)
>    4. Re: heap exhausted with matrix usage (andre maute)
>    5. Re: heap exhausted with matrix usage (David Billinghurst)
>    6. Re: heap exhausted with matrix usage (andre maute)
>    7. Re: heap exhausted with matrix usage (Raymond Toy)
>    8. Re: heap exhausted with matrix usage (Raymond Toy)
>    9. Re: heap exhausted with matrix usage (andre maute)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 23 Oct 2012 06:45:43 +0000 (UTC)
> From: Robert Dodier <robert.dodier at gmail.com>
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] heap exhausted with matrix usage
> Message-ID: <k65een$29m$1 at ger.gmane.org>
>
> On 2012-10-22, andre maute <andre.maute at gmx.de> wrote:
>
> > i stumbled upon the following
> > which produces without the kill
> > a heap exhausted error on my 2Gb machine
> > under fedora 17 and sbcl 1.0.57-1.fc17
> > (I can give further information if necessary)
> >
> > ------------------------------
> > display2d : false;
> > my_M(n) := ident(n);
> > my_work(n) := block(
> >          [res:0,M],
> >          M : my_M(n),
> >          M[1,1] : 2,
> >          /* kill(M), */
> >          res : n,
> >          return(res)
> > );
> > for k : 1 thru 10 do block(
> >          h : my_work(3000),
> >          print(k,h)
> > );
> > ------------------------------
> >
> > kill fixes the heap exhausted error,
> > but top shows nevertheless usage of 800 Mb resident memory
>
> Dunno exactly what's going on, but from what I can tell, the behavior
> you've observed is a consequence of the garbage collection strategy
> employed by the Lisp implementation -- from what I can tell, the Lisp
> implementation has not freed memory which is actually available to be
> reclaimed.
>
> I tried that example with CMUCL and Clisp. The behavior of CMUCL is
> similar to what you reported for SBCL. For Clisp, the memory use
> increases from about 9 Mb at start up to 90 Mb and stays there, until
> :lisp (ext:gc) is issued, after which memory decreases to 9 Mb again. I
> suppose Clisp's behavior is probably what we would like to see for any
> Lisp implementation.
>
> In CMUCL, I looked for symbols which are bound (and therefore presumably
> not available for garbage collection) to a matrix or at least a long
> list list of numbers; didn't find any.
>
> I didn't check any other Lisp implementations, but I wouldn't be
> surprised if there are a range of behaviors.
>
> Hope this helps,
>
> Robert Dodier
>
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 23 Oct 2012 12:07:04 +0200
> From: andre maute <andre.maute at gmx.de>
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] heap exhausted with matrix usage
> Message-ID: <50866C48.1080909 at gmx.de>
> Content-Type: text/plain; charset=us-ascii; format=flowed
>
> On 10/23/2012 08:45 AM, Robert Dodier wrote:
> > On 2012-10-22, andre maute <andre.maute at gmx.de> wrote:
> >
> >> i stumbled upon the following
> >> which produces without the kill
> >> a heap exhausted error on my 2Gb machine
> >> under fedora 17 and sbcl 1.0.57-1.fc17
> >> (I can give further information if necessary)
> >>
> >> ------------------------------
> >> display2d : false;
> >> my_M(n) := ident(n);
> >> my_work(n) := block(
> >>           [res:0,M],
> >>           M : my_M(n),
> >>           M[1,1] : 2,
> >>           /* kill(M), */
> >>           res : n,
> >>           return(res)
> >> );
> >> for k : 1 thru 10 do block(
> >>           h : my_work(3000),
> >>           print(k,h)
> >> );
> >> ------------------------------
> >>
> >> kill fixes the heap exhausted error,
> >> but top shows nevertheless usage of 800 Mb resident memory
> > Dunno exactly what's going on, but from what I can tell, the behavior
> > you've observed is a consequence of the garbage collection strategy
> > employed by the Lisp implementation -- from what I can tell, the Lisp
> > implementation has not freed memory which is actually available to be
> > reclaimed.
> >
> > I tried that example with CMUCL and Clisp. The behavior of CMUCL is
> > similar to what you reported for SBCL. For Clisp, the memory use
> > increases from about 9 Mb at start up to 90 Mb and stays there, until
> > :lisp (ext:gc) is issued, after which memory decreases to 9 Mb again. I
> > suppose Clisp's behavior is probably what we would like to see for any
> > Lisp implementation.
>
> But it looks like there is a maxima component of the problem.
> I checked which maxima version chokes for which k
>
> Maxima | k
> ----------
> 5.19.2 | 5
> 5.24.0 | 8
> 5.26.0 | 5
> 5.27.0 | 5
>
> Has somebody an idea how I can call
> the garbage collector _inside_ the for loop?
>
> Regards
> Andre
>
>
>
> ------------------------------
>
> Message: 3
> Date: Tue, 23 Oct 2012 13:07:34 +0000
> From: Barton Willis <willisb at unk.edu>
> To: andre maute <andre.maute at gmx.de>, "maxima at math.utexas.edu"
>         <maxima at math.utexas.edu>
> Subject: Re: [Maxima] heap exhausted with matrix usage
> Message-ID:
>         <
> 83FD4DC40F97654495E2C9AED47658362504080B at BL2PRD0710MB361.namprd07.prod.outlook.com
> >
>
> Content-Type: text/plain; charset="us-ascii"
>
> Maxima compiled with 64 bit Clozure CL is able to finish the loop:
>
> (%i4) for k : 1 thru 10 do block(
>           h : my_work(3000),
>          print(k,h));
>
> 1 3000
> 2 3000
> 3 3000
> 4 3000
> 5 3000
> 6 3000
> 7 3000
> 8 3000
> 9 3000
> 10 3000
> (%o4) done
> (%i5) build_info();
>
> (%o5) ?%build_info("branch_5_27_base_132_g50ac673_dirty",
>                    "2012-08-03 23:09:28","i686-pc-cygwin",
>                    "Clozure Common Lisp",
>                    "Version 1.8-r15286M  (WindowsX8664)")
> --Barton
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Tue, 23 Oct 2012 16:09:02 +0200
> From: andre maute <andre.maute at gmx.de>
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] heap exhausted with matrix usage
> Message-ID: <5086A4FE.1010206 at gmx.de>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 10/23/2012 03:07 PM, Barton Willis wrote:
> > Maxima compiled with 64 bit Clozure CL is able to finish the loop:
> >
> > (%i4) for k : 1 thru 10 do block(
> >            h : my_work(3000),
> >           print(k,h));
> >
> > 1 3000
> > 2 3000
> > 3 3000
> > 4 3000
> > 5 3000
> > 6 3000
> > 7 3000
> > 8 3000
> > 9 3000
> > 10 3000
> > (%o4) done
> > (%i5) build_info();
> >
> > (%o5) ?%build_info("branch_5_27_base_132_g50ac673_dirty",
> >                     "2012-08-03 23:09:28","i686-pc-cygwin",
> >                     "Clozure Common Lisp",
> >                     "Version 1.8-r15286M  (WindowsX8664)")
> > --Barton
> >
> >
> >
>
> Thank you very much Barton,
>
> yes, Clozure Common Lisp works for me, too.
>
> But can somebody perhaps adjust the usage
> of the openmcl command line parameter e.g. to use ccl instead?
>
> (And yes I have read the history of ccl on clozure.com)
>
> Regards
> Andre
>
> --------------------------------------
> $ maxima -l openmcl
> Maxima 5.27.0 http://maxima.sourceforge.net
> using Lisp Clozure Common Lisp Version 1.8  (LinuxX8664)
> 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) build_info();
> (%o1)
> Maxima version: "5.27.0"
> Maxima build date: "2012-10-23 15:53:16"
> Host type: "x86_64-unknown-linux-gnu"
> Lisp implementation type: "Clozure Common Lisp"
> Lisp implementation version: "Version 1.8  (LinuxX8664)"
> --------------------------------------
>
>
> ------------------------------
>
> Message: 5
> Date: Wed, 24 Oct 2012 01:19:09 +1100
> From: David Billinghurst <dbmaxima at gmail.com>
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] heap exhausted with matrix usage
> Message-ID: <5086A75D.1020803 at gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
>
> On 24/10/2012 1:09 AM, andre maute wrote:
> > But can somebody perhaps adjust the usage
> > of the openmcl command line parameter e.g. to use ccl instead?
> >
> "maxima -l ccl" should work.  It is a bug if it doesn't
>
> The maxima script contains the lines
>
>     # Allow ccl as an alias of openmcl.
>     if [ "$MAXIMA_LISP" = "ccl" ]; then
>          MAXIMA_LISP=openmcl
>     fi
>
>
> -------------- next part --------------
> URL: <
> http://www.math.utexas.edu/pipermail/maxima/attachments/20121024/60416bf8/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 6
> Date: Tue, 23 Oct 2012 16:20:45 +0200
> From: andre maute <andre.maute at gmx.de>
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] heap exhausted with matrix usage
> Message-ID: <5086A7BD.6050807 at gmx.de>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 10/23/2012 04:19 PM, David Billinghurst wrote:
> > On 24/10/2012 1:09 AM, andre maute wrote:
> >> But can somebody perhaps adjust the usage
> >> of the openmcl command line parameter e.g. to use ccl instead?
> >>
> > "maxima -l ccl" should work.  It is a bug if it doesn't
> >
> > The maxima script contains the lines
> >
> >    # Allow ccl as an alias of openmcl.
> >    if [ "$MAXIMA_LISP" = "ccl" ]; then
> >         MAXIMA_LISP=openmcl
> >    fi
> >
> Yes, maxima -l ccl works for me, but
>
> $ maxima --list-avail
> Available versions:
> version 5.27.0, lisp openmcl
> version 5.27.0, lisp sbcl
>
> Andre
>
>
> ------------------------------
>
> Message: 7
> Date: Tue, 23 Oct 2012 09:12:56 -0700
> From: Raymond Toy <toy.raymond at gmail.com>
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] heap exhausted with matrix usage
> Message-ID: <wvmi6261p3p3.fsf at rtoy2.mtv.corp.google.com>
> Content-Type: text/plain; charset=us-ascii
>
> >>>>> "Robert" == Robert Dodier <robert.dodier at gmail.com> writes:
>
>
>     Robert> I tried that example with CMUCL and Clisp. The behavior of
>     Robert> CMUCL is similar to what you reported for SBCL. For Clisp,
>
> Interesting.  I just ran the test with the current HEAD version of
> maxima and cmucl 2012-10.  The test finishes and memory usage goes up
> to about 380MB and stays there until GC happens, using ":lisp (ext:gc
> :full t)" to force GC.
>
> But cmucl with gencgc has a known issue where cmucl hangs on to
> garbage for way too long, but that's usually only with specialized
> arrays, which aren't being used in this test.  The last time I saw
> this issue, I could work around it by setting the number of
> generations to 2 instead of the default 6.
>
> Ray
>
>
>
> ------------------------------
>
> Message: 8
> Date: Tue, 23 Oct 2012 09:16:46 -0700
> From: Raymond Toy <toy.raymond at gmail.com>
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] heap exhausted with matrix usage
> Message-ID: <wvmi1ugpp3ip.fsf at rtoy2.mtv.corp.google.com>
> Content-Type: text/plain; charset=us-ascii
>
> >>>>> "andre" == andre maute <andre.maute at gmx.de> writes:
>
>     andre> Yes, maxima -l ccl works for me, but
>
>     andre> $ maxima --list-avail
>     andre> Available versions:
>     andre> version 5.27.0, lisp openmcl
>     andre> version 5.27.0, lisp sbcl
>
> Is really important to say ccl instead of openmcl here?
>
> Ray
>
>
>
> ------------------------------
>
> Message: 9
> Date: Tue, 23 Oct 2012 18:43:37 +0200
> From: andre maute <andre.maute at gmx.de>
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] heap exhausted with matrix usage
> Message-ID: <5086C939.9010705 at gmx.de>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 10/23/2012 06:16 PM, Raymond Toy wrote:
> >>>>>> "andre" == andre maute <andre.maute at gmx.de> writes:
> >      andre> Yes, maxima -l ccl works for me, but
> >
> >      andre> $ maxima --list-avail
> >      andre> Available versions:
> >      andre> version 5.27.0, lisp openmcl
> >      andre> version 5.27.0, lisp sbcl
> >
> > Is really important to say ccl instead of openmcl here?
>
> No, but nice.
>
> I had first installed ccl, then maxima.
> After I entered
>
> maxima --list-avail,
>
> I thought why do I have to use now
>
> maxima -l openmcl
>
>
> Andre
>
> P.S.:
> I configured maxima with "--with-ccl=ccl64",
> so ccl64 would have been even more natural.
>
>
>
> ------------------------------
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
> End of Maxima Digest, Vol 75, Issue 16
> **************************************
>