1 Mar 2011 15:51

### Chebyshev Integration

I was wondering how to use Maxima to integrate a Normal Distribution Function

(1.0/sqrt(2.0*PI))*exp(-0.5*x*x),

under the Clenshaw-Curtis or Chebyshev Integration Schema, WITHOUT any weight function.

I'm using the above example to get used to Maxima in order to tackle a more protracted problem..

Namely, ideally I want to integrate a Chebyshev Fit for a set of points of a histogram distribution. i.e. calculate P( x <= b ), given that I already have the Chebyshev curve (and coefficients) that interpolates the data. There seems to be 2 approaches (a) compute the moments of the fitted curve and calculate the integral (b) Follow the suggestions albeit unclear in Numerical Recipies in C pp 196 - Clenshaw-Curtis Quatrature - paragraph 1.

I'd like to use Maxima to benchmark my implementation. Any ideas on how I might solve this second problem in Maxima - namely integrating Chebyshev fitted PDFs ? Any if anybody has any pointers wrt it's implementation, I'd very much appreciate it.

Kind regards,
Alan

#avg_ls_inline_popup { position:absolute; z-index:9999; padding: 0px 0px; margin-left: 0px; margin-top: 0px; width: 240px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 13px;}
```_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
```
1 Mar 2011 16:09

### Re: Chebyshev Integration

On 3/1/2011 6:51 AM, Alzer Kong wrote:
I was wondering how to use Maxima to integrate a Normal Distribution Function

(1.0/sqrt(2.0*PI))*exp(-0.5*x*x),

under the Clenshaw-Curtis or Chebyshev Integration Schema, WITHOUT any weight function.

I'm using the above example to get used to Maxima in order to tackle a more protracted problem..

Namely, ideally I want to integrate a Chebyshev Fit for a set of points of a histogram distribution. i.e. calculate P( x <= b ), given that I already have the Chebyshev curve (and coefficients) that interpolates the data. There seems to be 2 approaches (a) compute the moments of the fitted curve and calculate the integral (b) Follow the suggestions albeit unclear in Numerical Recipies in C pp 196 - Clenshaw-Curtis Quatrature - paragraph 1.

I'd like to use Maxima to benchmark my implementation. Any ideas on how I might solve this second problem in Maxima - namely integrating Chebyshev fitted PDFs ? Any if anybody has any pointers wrt it's implementation, I'd very much appreciate it.

Kind regards,
Alan
#avg_ls_inline_popup { position:absolute; z-index:9999; padding: 0px 0px; margin-left: 0px; margin-top: 0px; width: 240px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 13px;} _______________________________________________ Maxima mailing list Maxima <at> math.utexas.edu http://www.math.utexas.edu/mailman/listinfo/maxima
1.  In maxima you'd better use  %pi  instead of PI.
2.  If you want to compute a chebyshev approximation for your data,
you presumably have some finite interval in mind.  Computing
via a discrete cosine transform is the fastest way, and can
probably be done with the FFT in some fashion. I wrote some
programs that use some pre-packaged DCT and are maybe 75 times
faster.
3. Integrating a chebyshev series is pretty easy.
4. If you are benchmarking because speed is important, you may
find Maxima slow.  If you are benchmarking because programming
time is important, not clear.

I will send you a file (not to whole list..)

RJF

```_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
```
1 Mar 2011 20:45

### Re: Chebyshev Integration

“I was wondering how to use Maxima to integrate a Normal Distribution Function

(1.0/sqrt(2.0*PI))*exp(-0.5*x*x),

under the Clenshaw-Curtis or Chebyshev Integration Schema, WITHOUT any weight function.

I'm using the above example to get used to Maxima in order to tackle a more protracted problem..

Namely, ideally I want to integrate a Chebyshev Fit for a set of points of a histogram distribution. i.e. calculate P( x <= b ), given that I already have the Chebyshev curve (and coefficients) that interpolates the data. There seems to be 2 approaches (a) compute the moments of the fitted curve and calculate the integral (b) Follow the suggestions albeit unclear in Numerical Recipies in C pp 196 - Clenshaw-Curtis Quatrature - paragraph 1.

I'd like to use Maxima to benchmark my implementation. Any ideas on how I might solve this second problem in Maxima - namely integrating Chebyshev fitted PDFs ? Any if anybody has any pointers wrt it's implementation, I'd very much appreciate it.

Kind regards,
Alan”

I am guessing that you have something like a series of functions fitting the points at different intervals.  Taking an example from interpol.mac which can do cubic splines.

You can do this.  You will need pw.mac too.

(out6)     C:/Maxima-5.23.2/share/maxima/5.23.2/share/numeric/interpol.mac
(out7)        C:/Maxima-5.23.2/share/maxima/5.23.2/share/contrib/pw.mac
(%i8) P:[[2,4],[4,8],[5,8],[6,4]];
(out8)                      [[2, 4], [4, 8], [5, 8], [6, 4]]
(%i9) cspline(P)\$
(%i10) pwint(%,x,2,6);
618
---
23

In your case you would want to use pw.mac’s between() function instead of charfun2.

for example.

f1(x)*between(x,minf,2)+f2(x)*between(x,2,3)+f3(x)*between(x,3,6)
pwint(%,x,a,b);

where f1, f2 and f3 are Chebyshev polynomials.

Rich

pw.mac is available from here.

```_______________________________________________
Maxima mailing list
Maxima <at> math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
```
1 Mar 2011 21:59

### Re: installer for maxima with ccl on windows

```This is my result for the testsuite. The tests run without an error, but
at the end I get an unexpected output.

(%i2) build_info();

Maxima version: 5.23.2
Maxima build date: 20:27 2/27/2011
Host type: i686-pc-mingw32
Lisp implementation type: Clozure Common Lisp
Lisp implementation version: Version 1.7-dev-r14645M-trunk
(WindowsX8632)

(%o2)
(%i3) run_testsuite();

[...]

No unexpected errors found out of 8,720 tests.
(LOOP WITH ERRS = 'NIL FOR TESTENTRY IN TESTS-TO-RUN DO (IF (ATOM
TESTENTRY) (PR
OGN (SETF TEST-FILE TESTENTRY) (SETF EXPECTED-FAILURES NIL)) (PROGN
(SETF TEST-F
ILE (SECOND TESTENTRY)) (SETF EXPECTED-FAILURES (CDDR TESTENTRY))))
(FORMAT T (I
NTL:GETTEXT "Running tests in ~a: ") (IF (SYMBOLP TEST-FILE) (SUBSEQ
(PRINT-INVE
RT-CASE TEST-FILE) 1) TEST-FILE)) (OR (ERRSET (PROGN
(MULTIPLE-VALUE-SETQ (TESTR
ESULT TEST-COUNT) (TEST-BATCH (\$FILE_SEARCH TEST-FILE
\$FILE_SEARCH_TESTS) EXPECT
ED-FAILURES :SHOW-EXPECTED DISPLAY_KNOWN_BUGS :SHOW-ALL
DISPLAY_ALL :SHOWTIME TI
ME)) (SETF TESTRESULT (REST TESTRESULT)) (INCF TOTAL-COUNT TEST-COUNT)
(WHEN TES
TRESULT (INCF ERROR-COUNT (LENGTH (CDR TESTRESULT))) (SETQ ERRS (APPEND
ERRS (LI
ST TESTRESULT)))))) (PROGN (SETQ ERROR-BREAK-FILE (FORMAT NIL "~a"
TEST-FILE)) (
SETQ ERRS (APPEND ERRS (LIST (LIST ERROR-BREAK-FILE "error break"))))
(FORMAT T
(INTL:GETTEXT "~%Caused an error break: ~a~%") TEST-FILE))) FINALLY
(COND ((NULL
ERRS) (FORMAT T (INTL:GETTEXT "~%~%No unexpected errors found out of
~:D tests.
~%") TOTAL-COUNT)) (T (FORMAT T (INTL:GETTEXT "~%Error summary:~%"))
(MAPCAR #'(
LAMBDA (X) (LET ((S (IF (> (LENGTH (REST X)) 1) "s" ""))) (FORMAT T
(INTL:GETTEX
T "Error~a found in ~a, problem~a:~%~a~%") S (FIRST X) S (SORT (REST X)
#'<))))
ERRS) (FORMAT T (INTL:GETTEXT "~&~:D test~P failed out of ~:D total
tests.~%") E
RROR-COUNT ERROR-COUNT TOTAL-COUNT)))) took 1,007,172 milliseconds
(1007.172 sec
onds) to run
with 2 available CPU cores.
During that period, 953,984 milliseconds (953.984 seconds) were spent in
user mo
de
8,265 milliseconds (8.265 seconds) were spent in
system mode

47,625 milliseconds (47.625 seconds) was spent in GC.
9,501,617,839 bytes of memory allocated.
(%o0)                                done
---------------------------------------------------------------------

And this is my result for the share_testsuite:

Error summary:
Error#1=s found in
d:/Programme/Maxima-5.23.2/share/maxima/5.23.2/share/contrib/
stringproc/rtestprintf.mac, problem#1#:
(27 54)
Error#1=s found in
d:/Programme/Maxima-5.23.2/share/maxima/5.23.2/share/contrib/
graphs/rtest_graphs.mac, problem#1#:
(1 3 4 5 6 7 8 9 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
29 30 31
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
56 57 58
59 60 61 62 63 64 65 67 68 70 71 72 74 75 76 78 79 80 81 82 84 85 86 87
89 90 9
1)
85 tests failed out of 3,151 total tests.
(LOOP WITH ERRS = 'NIL FOR TESTENTRY IN TESTS-TO-RUN DO (IF (ATOM
TESTENTRY) (PR
OGN (SETF TEST-FILE TESTENTRY) (SETF EXPECTED-FAILURES NIL)) (PROGN
(SETF TEST-F
ILE (SECOND TESTENTRY)) (SETF EXPECTED-FAILURES (CDDR TESTENTRY))))
(FORMAT T (I
NTL:GETTEXT "Running tests in ~a: ") (IF (SYMBOLP TEST-FILE) (SUBSEQ
(PRINT-INVE
RT-CASE TEST-FILE) 1) TEST-FILE)) (OR (ERRSET (PROGN
(MULTIPLE-VALUE-SETQ (TESTR
ESULT TEST-COUNT) (TEST-BATCH (\$FILE_SEARCH TEST-FILE
\$FILE_SEARCH_TESTS) EXPECT
ED-FAILURES :SHOW-EXPECTED DISPLAY_KNOWN_BUGS :SHOW-ALL
DISPLAY_ALL :SHOWTIME TI
ME)) (SETF TESTRESULT (REST TESTRESULT)) (INCF TOTAL-COUNT TEST-COUNT)
(WHEN TES
TRESULT (INCF ERROR-COUNT (LENGTH (CDR TESTRESULT))) (SETQ ERRS (APPEND
ERRS (LI
ST TESTRESULT)))))) (PROGN (SETQ ERROR-BREAK-FILE (FORMAT NIL "~a"
TEST-FILE)) (
SETQ ERRS (APPEND ERRS (LIST (LIST ERROR-BREAK-FILE "error break"))))
(FORMAT T
(INTL:GETTEXT "~%Caused an error break: ~a~%") TEST-FILE))) FINALLY
(COND ((NULL
ERRS) (FORMAT T (INTL:GETTEXT "~%~%No unexpected errors found out of
~:D tests.
~%") TOTAL-COUNT)) (T (FORMAT T (INTL:GETTEXT "~%Error summary:~%"))
(MAPCAR #'(
LAMBDA (X) (LET ((S (IF (> (LENGTH (REST X)) 1) "s" ""))) (FORMAT T
(INTL:GETTEX
T "Error~a found in ~a, problem~a:~%~a~%") S (FIRST X) S (SORT (REST X)
#'<))))
ERRS) (FORMAT T (INTL:GETTEXT "~&~:D test~P failed out of ~:D total
tests.~%") E
RROR-COUNT ERROR-COUNT TOTAL-COUNT)))) took 1,364,329 milliseconds
(1364.329 sec
onds) to run
with 2 available CPU cores.
During that period, 1,330,703 milliseconds (1330.703 seconds) were spent
in user
mode
6,984 milliseconds (6.984 seconds) were spent in
system mode

54,657 milliseconds (54.657 seconds) was spent in GC.
10,898,409,889 bytes of memory allocated.
(%o0)
d:/Programme/Maxima-5.23.2/share/maxima/5.23.2/share/share_testsuite.mac

Dieter Kaiser
```
1 Mar 2011 22:23

### Re: installer for maxima with ccl on windows

```On 3/1/11 3:59 PM, Dieter Kaiser wrote:
> This is my result for the testsuite. The tests run without an error, but
> at the end I get an unexpected output.
>
> (%i2) build_info();
>
> Maxima version: 5.23.2
> Maxima build date: 20:27 2/27/2011
> Host type: i686-pc-mingw32
> Lisp implementation type: Clozure Common Lisp
> Lisp implementation version: Version 1.7-dev-r14645M-trunk
> (WindowsX8632)
>
> (%o2)
> (%i3) run_testsuite();
>
> [...]
>
> No unexpected errors found out of 8,720 tests.
> (LOOP WITH ERRS = 'NIL FOR TESTENTRY IN TESTS-TO-RUN DO (IF (ATOM
If you're talking about this part, this is expected.  It seems that the
TIME macro in ccl will print out the form that is being timed.   And
since the pretty printer is disabled, the form is displayed in way
that's really hard to read.

This happens on my Mac as well.

Ray
```
1 Mar 2011 22:31

### Re: foreign language patch for build-index+cl-ppcre branch

```
On Sun, 27 Feb 2011, Robert Dodier wrote:

< I;ve updated my sandbox with
<
< git pull origin
< git checkout origin/build-index+cl-ppcre
<
< nuked all maxima-index.lisp files, and ran make.
<
< maxima-index.lisp all look OK.
<
< In ISO-8859 locales, titles and content look OK.
<
< In UTF-8 locales, same behavior as before;
< titles look OK, content has garbled characters.
<
< I am launching a UTF-8 session via
<
< LC_ALL=foo.UTF-8 LANG=foo.UTF-8 konsole &
<
< and running maxima in that.
< If someone else is seeing special characters displayed
< correctly in UTF-8 locales -- how are you launching Maxima?

Perhaps I was running the wrong/incomparable test:
Non utf8: inside an xterm.
Utf8: inside an emacs shell running in an xterm.
I do not set the locale, my locale is en_GB.iso88591.

---

Following Doug Crosher's suggestion, I added a flag
to cut-out the recoding of utf8 info files, and checked
this in.

In a cloned repo, after making all the info and index files,
when I run the script tests/rtest-build-index.sh in tests/ with

LISPS="cmucl clisp sbcl" VERBOSE=1 bash ./rtest-build-index.sh

I see the special characters displayed in what appears to be a correct
fashion for all encodings and all lisps listed on the command line
in both an xterm and a gnome-terminal.

Leo

--

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
```
1 Mar 2011 22:40

### Re: foreign language patch for build-index+cl-ppcre branch

```On 2/28/11 1:21 AM, Robert Dodier wrote:
> I am launching a UTF-8 session via
>
> LC_ALL=foo.UTF-8 LANG=foo.UTF-8 konsole &
>
> and running maxima in that.
> If someone else is seeing special characters displayed
> correctly in UTF-8 locales -- how are you launching Maxima?
It seems to be working for me.  In OSX Terminal, I do

export LANG=de.UTF-8
maxima-local
:lisp (stream:set-system-external-format :utf8) ; cmucl fix

It looks like the correct German characters.  At least it's not just a ?
as before.  The cmucl fix is to tell cmucl that we want to output the
strings using utf8.  Otherwise it will default to iso8859-1 and the
output would be messed up.

Ray
```
2 Mar 2011 02:29

### Progressive slowdown

```Dear maxima developers,

This was observed with Maxima 5.23.2 on ECL 11.1.1 on 64bit linux:

The following code shows a progressive slowdown:

assume(y>1);
while true do block([t,I,j],
t: absolute_real_time(),
for j: 1 step 1 thru 100 do I: integrate(log(x^2+y^2),x,0,1),
print(absolute_real_time()-t));

Typical output is something like:

13
17
24
30

But this doesn't occur for all integrals, for instance for:

while true do block([t,I,j],
t: absolute_real_time(),
for j: 1 step 1 thru 1000 do I: integrate(cos(x^2)*sin(x),x),
print(absolute_real_time()-t));

we get the flat behaviour one would hope for:

24
25
26
25
25

Is there a good reason for this behaviour? Is this only for ECL? Does it
point to a leak somewhere?

Kind regards,

Nils Bruin
```
2 Mar 2011 03:35

### Re: Chebyshev Integration

```On 03/01/2011 06:51 AM, Alzer Kong wrote:
> I was wondering how to use Maxima to integrate a Normal Distribution
> Function
>
> (1.0/sqrt(2.0*PI))*exp(-0.5*x*x),
>
>   under the Clenshaw-Curtis or Chebyshev Integration Schema, WITHOUT any
> weight function.
>
> I'm using the above example to get used to Maxima in order to tackle a
> more protracted problem..
>
> Namely, ideally I want to integrate a Chebyshev Fit for a set of points
> of a histogram distribution. i.e. calculate P( x <= b ), given that I
> already have the Chebyshev curve (and coefficients) that interpolates
> the data.

There is nothing that prevents your chebyshev approximation from having
negative values which is meaningless for a PDF. You may prefer to model
the logarithm of the density as a chebyshev, and then use e^x to get the
pdf.
```
2 Mar 2011 11:13

### Re: Progressive slowdown

```Hi,

I also observed such slowdown over time, with completely
different computations (I'm also using Ecl; don't know whether
it has to do with that).

Oliver

P.S. The slowdown can become very drastic, a factor of 10 or so.

On Tue, Mar 01, 2011 at 05:29:37PM -0800, Nils Bruin wrote:
> Dear maxima developers,
>
> This was observed with Maxima 5.23.2 on ECL 11.1.1 on 64bit linux:
>
> The following code shows a progressive slowdown:
>
> assume(y>1);
> while true do block([t,I,j],
>   t: absolute_real_time(),
>   for j: 1 step 1 thru 100 do I: integrate(log(x^2+y^2),x,0,1),
>   print(absolute_real_time()-t));
>
> Typical output is something like:
>
> 13
> 17
> 24
> 30
>
> But this doesn't occur for all integrals, for instance for:
>
> while true do block([t,I,j],
>   t: absolute_real_time(),
>   for j: 1 step 1 thru 1000 do I: integrate(cos(x^2)*sin(x),x),
>   print(absolute_real_time()-t));
>
> we get the flat behaviour one would hope for:
>
> 24
> 25
> 26
> 25
> 25
>
> Is there a good reason for this behaviour? Is this only for ECL? Does it
> point to a leak somewhere?
>
> Kind regards,
>
> Nils Bruin
> _______________________________________________
> Maxima mailing list
> Maxima <at> math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
```

Gmane