Maxima Digest, Vol 81, Issue 42



Hello Rupert:

That is it! Thanks for that wonderful tip. Code readability is important
too although this is really more cosmetic than functionality.

Regards,
Berns B.


On Sun, Apr 21, 2013 at 6:13 AM, <maxima-request at math.utexas.edu> wrote:

> 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: draw / vector / key (Adam)
>    2. Re: algorithms for 'invert', was: program works with maxima
>       5.29.1 but freezes with maxima 5.30.0 (Henry Baker)
>    3. Re: algorithms for 'invert', was: program works with maxima
>       5.29.1 but freezes with maxima 5.30.0 (Barton Willis)
>    4. Re: Is there a way to symbolic constants to have them stay
>       correctly in place? (Rupert Swarbrick)
>    5. Re: Is there a way to symbolic constants to have them stay
>       correctly in place? (Richard Fateman)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 20 Apr 2013 18:29:57 +0200
> From: Adam <adammaj1 at o2.pl>
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] draw / vector / key
> Message-ID: <kkufq0$q1r$1 at ger.gmane.org>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
>
> > Short pieces of code are easier to run and check.
> Right. Sorry.
>
> >
> > The trick here is to write the legend only for the first vector and
> > leave the rest of the vectors without legends. Something like this
> > should work:
>
> Ok. Thx for the answer.
> It gives a good list ( display of list is as expected)  but draw does
> not accepts it :
>   part: argument must be a non-atomic expression; found "key = \"\""
>   -- an error. To debug this try: debugmode(true);
>
> Below are 2 batch files ( shorter) : one which not works and one which
> works.
> Probably smth ( ?part) inside draw makes this error.
>
> ?
>
> Adam
> ======= not working ======
>
>   /* riotorto.users.sourceforge.net/gnuplot/vectors/index.html */
> GiveAVector(m):=block(
>   [x,y,dx,dy],
>   x:0,
>   y:0,
>   dx:realpart(m),
>   dy:imagpart(m),
>   vector([dx,dy],[-dx,-dy])
> )$
>
>
>
> /*
>
> http://math.stackexchange.com/questions/361205/what-is-the-shape-of-parabolic-critical-orbit
> */
> /* attracting vectors
>
>
> one key for all vectpors - not works
>
> part: argument must be a non-atomic expression; found "key = \"\""
>   -- an error. To debug this try: debugmode(true);
>
> va is displayed properly
>   */
> va:solve(z^12=1/(912*%i+12*84));
> va:map(rhs,va);
> va:map(rectform,va);
> va:map('float,va);
> va:map(GiveAVector,va);
> f:first(va);
> r:rest(va,1);
> r:cons(string(key=""),r);
> va:cons(f,r);
>
>
>
>
> draw2d(
>      title = concat("All  critical orbits for discrete map f(z)=",fs ,"
>   where m=e^{2*pi*i*3/4}= -i "),
>      terminal  = screen,
>      user_preamble = "set angles degrees; set xtics 0.62996052494744;
> set mxtics 0.5; set size square", /* 360/12-30 */
>      file_name =
>
> concat("~/maxima/parabolic/critical_orbits/z4plusmz/3over4/arv/",string(iLength),"ar"),
>      pic_width  = 1000,    /* Since Maxima 5.23, pic_width and
> pic_height are deprecated. */
>      pic_height = 1000,    /* See option dimensions. To get the same
> effect, write dimensions=[800,600] */
>      yrange = [-0.75,0.75],
>      xrange = [-0.75,0.75],
>      xlabel     = "z.re ",
>      ylabel     = "z.im",
>
>
>      /* vectors */
>      head_both   = false,
>      head_length = 0.000001,
>      line_width  = 0.63,
>
>      head_angle  = 1,
>      head_type = nofilled,
>      line_type = solid,
>      key = "attracting vectors",
>      color       = yellow,
>      va
>
>   );
>
>
> =========== working =================
> draw2d(
>
>
>    /* vectors */
>      head_both   = false,
>      head_length = 0.000001,
>      line_width  = 0.63,
>
>      head_angle  = 1,
>      head_type = nofilled,
>      line_type = solid,
>      key = "attracting vectors",
>      color       = yellow,
>      first(va),
>      key="",
>      rest(va),
>      key = "repelling vectors",
>      color = gray,
>      first(vr),
>      key="",
>      rest(vr)
>
>   );
>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Sat, 20 Apr 2013 12:31:06 -0700
> From: Henry Baker <hbaker1 at pipeline.com>
> To: Barton Willis <willisb at unk.edu>
> Cc: Stavros Macrakis <macrakis at alum.mit.edu>,   Robert Dodier
>         <robert.dodier at gmail.com>,      maxima mailing list
>         <maxima at math.utexas.edu>
> Subject: Re: [Maxima] algorithms for 'invert', was: program works with
>         maxima 5.29.1 but freezes with maxima 5.30.0
> Message-ID: <E1UTdUc-0005H6-QU at elasmtp-junco.atl.sa.earthlink.net>
> Content-Type: text/plain; charset="us-ascii"
>
> Thanks, Barton.
>
> Yes, I was just learning about condition numbers.
>
>  From what Prof. Strang said on his MIT YouTube video, for a symmetric
> positive definite matrix, the condition number is the ratio of the largest
> to the smallest (both necessarily real&positive) eigenvalues.  According to
> Prof. Strang, the loss of precision is related to log(condition#).
>
> For other matrices, the condition number is
> sqrt(condition(transpose(M).M)).  (I assume that this still works even when
> M is symmetric positive definite.)
>
> What I didn't understand from Prof. Strang is what happens when
> transpose(M).M is still singular.
>
> BTW, it looks like the ill-conditioned matrices you're showing are
> precisely those generated by 'GCD-with-multipliers' applied to large
> relatively prime numbers; is this correct?
>
> At 04:46 AM 4/20/2013, Barton Willis wrote:
> >> For example, if the matrix is 'almost' singular (i.e., det(M) almost
> zero), then things can go haywire.
> >
> >A matrix can be ill conditioned with a determinant of one; famous example:
> >   (%i1)  m : matrix([63245986, 102334155],   [102334155,   165580141])$
> >
> >The determinant of m is 1, but its condition number is about 10^16
> >
> >   (%i2) [determinant(m), mat_norm(m,'inf) * mat_norm(m^^-1,'inf)];
> >
> >   (%o2) [1,71778070001175616] Let m be a coefficient matrix
> >
> >(%i4) eq : m . matrix([x],[y])- matrix([1],[1])$
> >
> >(%i5) eq  : xreduce('append,args(eq))$
> >
> >Solve using rational numbers
> >
> >(%i6) linsolve(eq,[x,y]);
> >
> >(%o6) [x=63245986,y=-39088169]
> >
> >Solve using binary64
> >
> >(%i7) linsolve(float(eq),[x,y]),keepfloat : true;
> >
> >(%o7) [x=3.1622993000000007*10^7,y=-1.95440845*10^7]
> >
> >Partial pivoting doesn't save the calculation--at least the estimated
> condition number will warn the alert user:
> >
> >(%i8) linsolve_by_lu(m,[1,1],'floatfield);
> >
> >(%o8)
> [matrix([4.1475558898394227*10^7],[-2.5633305101605773*10^7]),4.7070743271309312*10^16]
> >
> >--Barton
>
>
>
> ------------------------------
>
> Message: 3
> Date: Sat, 20 Apr 2013 21:35:31 +0000
> From: Barton Willis <willisb at unk.edu>
> To: Henry Baker <hbaker1 at pipeline.com>
> Cc: Stavros Macrakis <macrakis at alum.mit.edu>,   Robert Dodier
>         <robert.dodier at gmail.com>,      maxima mailing list
>         <maxima at math.utexas.edu>
> Subject: Re: [Maxima] algorithms for 'invert', was: program works with
>         maxima 5.29.1 but freezes with maxima 5.30.0
> Message-ID:
>         <
> 83FD4DC40F97654495E2C9AED4765836359C4667 at BLUPRD0712MB595.namprd07.prod.outlook.com
> >
>
> Content-Type: text/plain; charset="us-ascii"
>
> Matrices with a modest determinant with huge condition number aren't
> exotic; example
>
> (%i5) m : apply('diag_matrix, makelist(4*10^5*k,k,1,4)) .
> vandermonde_matrix(makelist(1+k/10000,k,0,3))$
>
> (%i6) determinant(m);
> (%o6) 4608/625
>
> (%i7) mat_norm(m,1) * mat_norm(m,1);
> (%o7) 25030016505170964600504489/1562500000000
>
> The condition number falls naturally from bounding  ||x  - xx||  where M x
> = b & MM xx = bb where
> M & MM are square matrices, ||b - bb|| < e || b|| and || M - MM || < e ||
> M ||. Generally e is the machine
> epsilon. The result is
>
>    (1 - e * K(M)) ||x - xx|| < e K(M) || x ||
>
> where K(M) = || M || * || M^-1 ||.  The norm can be any p-norm, I think.
>
> --Barton
>
> ________________________________________
> From: Henry Baker [hbaker1 at pipeline.com]
> Sent: Saturday, April 20, 2013 14:31
> To: Barton Willis
> Cc: Stavros Macrakis; maxima mailing list; Robert Dodier
> Subject: RE: [Maxima] algorithms for 'invert', was: program works with
>  maxima 5.29.1 but freezes with maxima 5.30.0
>
> Thanks, Barton.
>
> Yes, I was just learning about condition numbers.
>
>  From what Prof. Strang said on his MIT YouTube video, for a symmetric
> positive definite matrix, the condition number is the ratio of the largest
> to the smallest (both necessarily real&positive) eigenvalues.  According to
> Prof. Strang, the loss of precision is related to log(condition#).
>
> For other matrices, the condition number is
> sqrt(condition(transpose(M).M)).  (I assume that this still works even when
> M is symmetric positive definite.)
>
> What I didn't understand from Prof. Strang is what happens when
> transpose(M).M is still singular.
>
> BTW, it looks like the ill-conditioned matrices you're showing are
> precisely those generated by 'GCD-with-multipliers' applied to large
> relatively prime numbers; is this correct?
>
> At 04:46 AM 4/20/2013, Barton Willis wrote:
> >> For example, if the matrix is 'almost' singular (i.e., det(M) almost
> zero), then things can go haywire.
> >
> >A matrix can be ill conditioned with a determinant of one; famous example:
> >   (%i1)  m : matrix([63245986, 102334155],   [102334155,   165580141])$
> >
> >The determinant of m is 1, but its condition number is about 10^16
> >
> >   (%i2) [determinant(m), mat_norm(m,'inf) * mat_norm(m^^-1,'inf)];
> >
> >   (%o2) [1,71778070001175616] Let m be a coefficient matrix
> >
> >(%i4) eq : m . matrix([x],[y])- matrix([1],[1])$
> >
> >(%i5) eq  : xreduce('append,args(eq))$
> >
> >Solve using rational numbers
> >
> >(%i6) linsolve(eq,[x,y]);
> >
> >(%o6) [x=63245986,y=-39088169]
> >
> >Solve using binary64
> >
> >(%i7) linsolve(float(eq),[x,y]),keepfloat : true;
> >
> >(%o7) [x=3.1622993000000007*10^7,y=-1.95440845*10^7]
> >
> >Partial pivoting doesn't save the calculation--at least the estimated
> condition number will warn the alert user:
> >
> >(%i8) linsolve_by_lu(m,[1,1],'floatfield);
> >
> >(%o8)
> [matrix([4.1475558898394227*10^7],[-2.5633305101605773*10^7]),4.7070743271309312*10^16]
> >
> >--Barton
>
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Sat, 20 Apr 2013 13:26:07 +0100
> From: Rupert Swarbrick <rswarbrick at gmail.com>
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] Is there a way to symbolic constants to have
>         them stay       correctly in place?
> Message-ID: <04ea4axj5f.ln2 at skate.rswarbrick>
> Content-Type: text/plain; charset="us-ascii"
>
> Berns Buenaobra <berns.buenaobra at gmail.com> writes:
> > Hi all:
> >
> > Its a bit awkward and I find that students trying out Maxima can't resist
> > to check how well are constants are ordered in the derived relations
> from a
> > text book to a Maxima output.
>
> Have you looked at the ordergreat and orderless functions? For your
> first example:
>
> > Consider for example a worksheet snippet:
> >
> > ('diff(Vin(t),t,1))*C=Vout/R; solve([('diff(Vin(t),t,1))*C=Vout(t)/R],
> > [Vout(t)]);
>
> if I do the following, I think I get what you're after:
>
> (%i1) orderless(R,C);
> (%o1)                                done
> (%i2) first (solve([('diff(Vin(t),t,1))*C=Vout(t)/R], [Vout(t)]));
>                                          d
> (%o2)                     Vout(t) = R C (-- (Vin(t)))
>                                          dt
>
>
> Hopefully this is some help. There's also a package called "format"
> (look in share/contrib/format), which you might be interested in. I
> remember spending hours playing with it when I first started using
> Maxima but nowadays, I tend to just leave stuff in the form Maxima
> chooses by default and do the reordering in my head (if I can...)
>
> Rupert
>
>
> PS: Your message got held in the moderation queue. If you don't want
>     that to happen, sign up to the mailing list and make sure that you
>     send from the email address that is signed up.
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: not available
> Type: application/pgp-signature
> Size: 315 bytes
> Desc: not available
> URL: <
> http://www.math.utexas.edu/pipermail/maxima/attachments/20130420/d16ef3d8/attachment-0001.pgp
> >
>
> ------------------------------
>
> Message: 5
> Date: Sat, 20 Apr 2013 15:13:20 -0700
> From: Richard Fateman <fateman at eecs.berkeley.edu>
> To: Rupert Swarbrick <rswarbrick at gmail.com>
> Cc: maxima at math.utexas.edu, berns.buenaobra at gmail.com
> Subject: Re: [Maxima] Is there a way to symbolic constants to have
>         them stay correctly in place?
> Message-ID: <51731300.9090200 at eecs.berkeley.edu>
> Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
>
> I think it is simpler and perhaps a useful tactic to just point out that
> computers and humans
> are not the same and what is especially convenient for computers is a
> kind of uniformity.
> Based on that, sometimes the ordering of terms looks strange to humans.
> You can
> of course try to instruct the computer in detail to follow what you
> think are the right "rules"
> but in fact you are imposing something that is (most likely)
> inconsistent in the long
> run.
>
> Let the students get used to odd computer ordering, is my advice.
> Teaching them (or you)
> about ordergreat etc. is not worth the time, even if you do manage to
> get it to look right.
>
> note
> y=m*x+b
> F=m*a
>
> so in a product like m*a, do we do reverse alphabetical order? but then
> we would
> have x*m, wouldn't we?
> what about
> E=m*c^2
> E=IR
>
> There is some heuristic about "more constant"  but how do you know?
>
> RJF
>
>
>
>
>   On 4/20/2013 5:26 AM, Rupert Swarbrick wrote:
> > Berns Buenaobra <berns.buenaobra at gmail.com> writes:
> >> Hi all:
> >>
> >> Its a bit awkward and I find that students trying out Maxima can't
> resist
> >> to check how well are constants are ordered in the derived relations
> from a
> >> text book to a Maxima output.
> > Have you looked at the ordergreat and orderless functions? For your
> > first example:
> >
> >> Consider for example a worksheet snippet:
> >>
> >> ('diff(Vin(t),t,1))*C=Vout/R; solve([('diff(Vin(t),t,1))*C=Vout(t)/R],
> >> [Vout(t)]);
> > if I do the following, I think I get what you're after:
> >
> > (%i1) orderless(R,C);
> > (%o1)                                done
> > (%i2) first (solve([('diff(Vin(t),t,1))*C=Vout(t)/R], [Vout(t)]));
> >                                           d
> > (%o2)                     Vout(t) = R C (-- (Vin(t)))
> >                                           dt
> >
> >
> > Hopefully this is some help. There's also a package called "format"
> > (look in share/contrib/format), which you might be interested in. I
> > remember spending hours playing with it when I first started using
> > Maxima but nowadays, I tend to just leave stuff in the form Maxima
> > chooses by default and do the reordering in my head (if I can...)
> >
> > Rupert
> >
> >
> > PS: Your message got held in the moderation queue. If you don't want
> >      that to happen, sign up to the mailing list and make sure that you
> >      send from the email address that is signed up.
> >
> >
> > _______________________________________________
> > Maxima mailing list
> > Maxima at math.utexas.edu
> > http://www.math.utexas.edu/mailman/listinfo/maxima
>
> -------------- next part --------------
> URL: <
> http://www.math.utexas.edu/pipermail/maxima/attachments/20130420/ae6cfe75/attachment.html
> >
>
> ------------------------------
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
> End of Maxima Digest, Vol 81, Issue 42
> **************************************
>