How do you write this in lisp



Well that is amazing.

(%i5) for i : 1 thru 100 do for j : 1 thru 100 do between(x,i,j);
Evaluation took 1.4400 seconds (1.4400 elapsed)

Now it is faster than signum().

Thanks,

Rich



From: Stavros Macrakis
Sent: Tuesday, April 06, 2010 11:41 AM
To: Richard Hennessy
Cc: Barton Willis ; Maxima List
Subject: Re: [Maxima] How do you write this in lisp


Try my new code and compile simpbetween.


On Tue, Apr 6, 2010 at 11:38, Richard Hennessy <rich.hennessy at verizon.net> wrote:

  I would like between to be as fast a signum.  Probably not likely to happen I guess.


  Rich

  --------------------------------------------------
  From: "Richard Hennessy" <rich.hennessy at verizon.net>

  Sent: Tuesday, April 06, 2010 11:32 AM
  To: "Stavros Macrakis" <macrakis at alum.mit.edu>; "Barton Willis" <willisb at unk.edu>; "Maxima List" 
<maxima at math.utexas.edu>

  Subject: Re: [Maxima] How do you write this in lisp


    Here is a better way to compare speed.  These two expressions are equivalent.

    (%i3) for i : 1 thru 100 do for j : 1 thru 100 do (signum(x-i)-signum(x-j))/2;
    Evaluation took 3.3300 seconds (3.3300 elapsed)
    (out3)                                                                               done
    (%i4) for i : 1 thru 100 do for j : 1 thru 100 do between(x,i,j);
    Evaluation took 19.0600 seconds (19.0600 elapsed)
    (out4)                                                                               done

    --------------------------------------------------
    From: "Stavros Macrakis" <macrakis at alum.mit.edu>
    Sent: Monday, April 05, 2010 11:13 PM
    To: "Richard Hennessy" <rich.hennessy at verizon.net>; "Barton Willis" <willisb at unk.edu>; "Maxima List" 
<maxima at math.utexas.edu>
    Subject: Re: [Maxima] How do you write this in lisp


      Well, it will depend on how often the conditions are true or false. If
      that's the issue, you can set compbx only on demand.

      How are you measuring speed?

              -s

      On 2010-04-05, Richard Hennessy <rich.hennessy at verizon.net> wrote:

        Hi,

        Actually this was a bad idea.  I tried making between a regular function and
        it breaks a lot of code that I have
        written.  It has to be a simplifying function or I can't integrate
        expressions that contain it.

        I have posted the newest pw.mac at my site.  It can use between or signum.
        I have to update the help now.  You can get
        it here.  http://mysite.verizon.net/res11w2yb/pw.mac.txt  BTW I have tried
        using sign() in the definition of simpbetween
        but it is slower that using the relational operators.  Maybe I am going
        about it the right way.

        Rich


        --------------------------------------------------
        From: "Richard Hennessy" <rich.hennessy at verizon.net>
        Sent: Monday, April 05, 2010 10:05 PM
        To: "Barton Willis" <willisb at unk.edu>; <macrakis at alum.mit.edu>
        Cc: "Maxima List" <maxima at math.utexas.edu>
        Subject: Re: [Maxima] How do you write this in lisp


          "simplification--how much is too much".

          Maybe between should not be a simplifying function at all.  I could make
          the body of simpbetween with some possibly
          necessary changes the body of a regular user function called between.  I
          am not sure I like simplifying functions that
          much.  Maybe that would work out better.  I can't make up my mind on this
          yet.  I am going to try experimenting with
          both ways
          of doing it.

          Rich


          --------------------------------------------------
          From: "Barton Willis" <willisb at unk.edu>
          Sent: Monday, April 05, 2010 9:17 PM
          To: <macrakis at alum.mit.edu>
          Cc: "Richard Hennessy" <rich.hennessy at verizon.net>; "Maxima List"
          <maxima at math.utexas.edu>
          Subject: Re: [Maxima] How do you write this in lisp


            It would be great if there was a definitive guide to writing simplifying
            functions.
            There are plenty of examples, but no how-to manual that I know of; some
            topics
            that come to mind:

            (1) nouns and verbs,
            (2) autoloading simplifying functions,
            (3) simplification--how much is too much,
            (4) reflection rules,
            (5) binary64 & bigfloat evaluation,
            (6) extras: gradef, conjugates, limits, TeX properties, antiderivatives,
            (7) declaring function properties (complex, ...),
            (8) domain and wrong number of argument errors,

            --Barton




          _______________________________________________
          Maxima mailing list
          Maxima at math.utexas.edu
          http://www.math.utexas.edu/mailman/listinfo/maxima