I have rewritten simpbetween() and now between() is a new way to define piecewise functions. It is actually a bit
faster than the equivalent signum() code.
(%i3) for a:1 thru 100 do for b : 1 thru 100 do (1+signum(b-a))/2*(signum(x-a)-signum(x-b))/2;
Evaluation took 1.6000 seconds (1.6000 elapsed)
(out3) done
(%i4) for a:1 thru 100 do for b : 1 thru 100 do between(x,a,b);
Evaluation took 0.8800 seconds (0.8800 elapsed)
(out4) done
(%i5) for a:1 thru 100 do for b : 1 thru 100 do between(x,a,b,rclosed);
Evaluation took 0.9900 seconds (0.9900 elapsed)
(out5) done
Between integrates about twice as fast as the same signum() does.
(%i3) for a:1 thru 100 do for b : 1 thru 100 do pwint((1+signum(b-a))/2*(signum(x-a)-signum(x-b))/2,x);
Evaluation took 19.2100 seconds (19.2100 elapsed)
(out3) done
(%i4) for a:1 thru 100 do for b : 1 thru 100 do pwint(between(x,a,b),x);
Evaluation took 8.6900 seconds (8.6900 elapsed)
(out4) done
(%i5) for a:1 thru 100 do for b : 1 thru 100 do pwint(between(x,a,b,rclosed),x);
Evaluation took 8.8700 seconds (8.8700 elapsed)
(out5) done
So hopefully people will want to use it.
pw.mac is at my site. I am working on unit tests for pw.mac (rtest_pw.mac) and as I go through pw.mac I am finding some
errors. rtest_pw.mac has 57 problems in it so far and (now) they all work but there are going to be more problems as I
go through testing each feature. Check out pw now at http://mysite.verizon.net/res11w2yb/id2.html
I am hoping that when I am done the rtest_pw.mac file and any fixes required this project will come to a close.
Rich
From: Richard Hennessy
Sent: Tuesday, April 06, 2010 11:53 AM
To: Stavros Macrakis
Cc: Maxima List ; Barton Willis
Subject: Re: [Maxima] 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
--------------------------------------------------------------------------------
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima