back to list

Maple code for ?(x)

🔗Gene Ward Smith <gwsmith@svpal.org>

1/20/2004 2:35:46 PM

This shows how easy it is to compute, and may inspire anyone who wants
to code it in something other than Maple. Paul was using a log-based
system for defining harmonic entropy, and that makes more sense, so
the actual function to do Stieltjes integration with would be ?(2^x)
or ?(2^(x/1200)), but either way you want a ? function to start out with.

quest := proc(x)
# Minkowsky question mark function
local i, j, d, l, s, t;
l := convert(x, confrac);
d := nops(l);
s := l[1];
for i from 2 to d do
t := 1;
for j from 2 to i do
t := t - l[j] od;
s := s + (-1)^i * 2^t od;
s end:

🔗Paul Erlich <perlich@aya.yale.edu>

1/20/2004 2:53:08 PM

--- In tuning-math@yahoogroups.com, "Gene Ward Smith" <gwsmith@s...>
wrote:
> This shows how easy it is to compute, and may inspire anyone who
wants
> to code it in something other than Maple. Paul was using a log-based
> system for defining harmonic entropy, and that makes more sense, so
> the actual function to do Stieltjes integration with would be ?(2^x)
> or ?(2^(x/1200)), but either way you want a ? function to start out
with.
>
> quest := proc(x)
> # Minkowsky question mark function
> local i, j, d, l, s, t;
> l := convert(x, confrac);
> d := nops(l);
> s := l[1];
> for i from 2 to d do
> t := 1;
> for j from 2 to i do
> t := t - l[j] od;
> s := s + (-1)^i * 2^t od;
> s end:

what is nops?

🔗Gene Ward Smith <gwsmith@svpal.org>

1/20/2004 3:54:03 PM

--- In tuning-math@yahoogroups.com, "Paul Erlich" <perlich@a...> wrote:

> > quest := proc(x)
> > # Minkowsky question mark function
> > local i, j, d, l, s, t;
> > l := convert(x, confrac);
> > d := nops(l);
> > s := l[1];
> > for i from 2 to d do
> > t := 1;
> > for j from 2 to i do
> > t := t - l[j] od;
> > s := s + (-1)^i * 2^t od;
> > s end:
>
> what is nops?

Nops gives the number of operands for a variety of expressions.
Convert(x, confrac) returns a list of integers, and for a list, nops
gives the number of elements of the list.

🔗Paul Erlich <perlich@aya.yale.edu>

1/21/2004 5:02:37 AM

--- In tuning-math@yahoogroups.com, "Gene Ward Smith" <gwsmith@s...>
wrote:
> --- In tuning-math@yahoogroups.com, "Paul Erlich" <perlich@a...>
wrote:
>
> > > quest := proc(x)
> > > # Minkowsky question mark function
> > > local i, j, d, l, s, t;
> > > l := convert(x, confrac);
> > > d := nops(l);
> > > s := l[1];
> > > for i from 2 to d do
> > > t := 1;
> > > for j from 2 to i do
> > > t := t - l[j] od;
> > > s := s + (-1)^i * 2^t od;
> > > s end:
> >
> > what is nops?
>
> Nops gives the number of operands for a variety of expressions.
> Convert(x, confrac) returns a list of integers, and for a list, nops
> gives the number of elements of the list.

Aren't 'most' continued fractions infinite?

🔗Gene Ward Smith <gwsmith@svpal.org>

1/21/2004 10:40:44 AM

--- In tuning-math@yahoogroups.com, "Paul Erlich" <perlich@a...> wrote:

> Aren't 'most' continued fractions infinite?

Obviously, Maple is not going to compute an infinte number of
convergents. What it does depends on the setting of Digits.

🔗Paul Erlich <perlich@aya.yale.edu>

1/21/2004 10:54:56 AM

--- In tuning-math@yahoogroups.com, "Gene Ward Smith" <gwsmith@s...>
wrote:
> --- In tuning-math@yahoogroups.com, "Paul Erlich" <perlich@a...>
wrote:
>
> > Aren't 'most' continued fractions infinite?
>
> Obviously, Maple is not going to compute an infinte number of
> convergents. What it does depends on the setting of Digits.

So we're getting some *approximation* to the ? function, yes? Matlab
does continued fractions, but they're strings not vectors, they use
an error tolerance to determine when to stop, and they allow negative
entries. I've written code to get around the last limitation; the
other two shouldn't be that hard . . .

🔗Carl Lumma <ekin@lumma.org>

1/21/2004 1:43:27 PM

>> Obviously, Maple is not going to compute an infinte number of
>> convergents. What it does depends on the setting of Digits.
>
>So we're getting some *approximation* to the ? function, yes? Matlab
>does continued fractions, but they're strings not vectors, they use
>an error tolerance to determine when to stop, and they allow negative
>entries. I've written code to get around the last limitation; the
>other two shouldn't be that hard . . .

By the way, somebody once told me that maple code can be executed
in Matlab. Dunno if that's true...

-Carl

🔗Paul Erlich <perlich@aya.yale.edu>

1/21/2004 2:00:24 PM

--- In tuning-math@yahoogroups.com, Carl Lumma <ekin@l...> wrote:
> >> Obviously, Maple is not going to compute an infinte number of
> >> convergents. What it does depends on the setting of Digits.
> >
> >So we're getting some *approximation* to the ? function, yes?
Matlab
> >does continued fractions, but they're strings not vectors, they
use
> >an error tolerance to determine when to stop, and they allow
negative
> >entries. I've written code to get around the last limitation; the
> >other two shouldn't be that hard . . .
>
> By the way, somebody once told me that maple code can be executed
> in Matlab. Dunno if that's true...

They must have had an intepreter or something . . .

🔗Carl Lumma <ekin@lumma.org>

1/21/2004 2:05:18 PM

>> By the way, somebody once told me that maple code can be executed
>> in Matlab. Dunno if that's true...
>
>They must have had an intepreter or something . . .

They claimed the maple kernel is included with matlab. Though I
suspect they were wrong. :)

-Carl

🔗Carl Lumma <ekin@lumma.org>

1/21/2004 2:11:42 PM

>>> By the way, somebody once told me that maple code can be executed
>>> in Matlab. Dunno if that's true...
>>
>>They must have had an intepreter or something . . .
>
>They claimed the maple kernel is included with matlab. Though I
>suspect they were wrong. :)

From Matlab help...

>Using Maple Functions
>The maple function lets you access Maple functions directly.
>This function takes sym objects, strings, and doubles as inputs.
>It returns a symbolic object, character string, or double
>corresponding to the class of the input. You can also use the
>maple function to debug symbolic math programs that you develop.

>Precompiled Maple Procedures
>When Maple loads a source (ASCII text) procedure into its workspace,
>it compiles (translates) the procedure into an internal format. You
>can subsequently use the maple function to save the procedures in
>the internal format. The advantage is you avoid recompiling the
>procedure the next time you load it, thereby speeding up the process.

>maple
>Access Maple kernel.
>
>Syntax
>r = maple('statement')
>r = maple('function',arg1,arg2,...)
>[r, status] = maple(...)
>maple('traceon') or maple trace on
>maple('traceoff') or maple trace off

>The computational engine underlying the [symbolic math] toolboxes is
>the kernel of Maple, a system developed primarily at the University
>of Waterloo, Canada, and, more recently, at the Eidgenössiche
>Technische Hochschule, Zürich, Switzerland. Maple is marketed and
>supported by Waterloo Maple, Inc.

Once again I learn not to suspect Dan of being wrong.

-Carl

🔗Paul Erlich <perlich@aya.yale.edu>

1/21/2004 2:16:45 PM

--- In tuning-math@yahoogroups.com, Carl Lumma <ekin@l...> wrote:
> >>> By the way, somebody once told me that maple code can be
executed
> >>> in Matlab. Dunno if that's true...
> >>
> >>They must have had an intepreter or something . . .
> >
> >They claimed the maple kernel is included with matlab. Though I
> >suspect they were wrong. :)
>
> From Matlab help...
>
> >Using Maple Functions
> >The maple function lets you access Maple functions directly.
> >This function takes sym objects, strings, and doubles as inputs.
> >It returns a symbolic object, character string, or double
> >corresponding to the class of the input. You can also use the
> >maple function to debug symbolic math programs that you develop.
>
> >Precompiled Maple Procedures
> >When Maple loads a source (ASCII text) procedure into its
workspace,
> >it compiles (translates) the procedure into an internal format. You
> >can subsequently use the maple function to save the procedures in
> >the internal format. The advantage is you avoid recompiling the
> >procedure the next time you load it, thereby speeding up the
process.
>
> >maple
> >Access Maple kernel.
> >
> >Syntax
> >r = maple('statement')
> >r = maple('function',arg1,arg2,...)
> >[r, status] = maple(...)
> >maple('traceon') or maple trace on
> >maple('traceoff') or maple trace off
>
> >The computational engine underlying the [symbolic math] toolboxes
is
> >the kernel of Maple, a system developed primarily at the University
> >of Waterloo, Canada, and, more recently, at the Eidgenössiche
> >Technische Hochschule, Zürich, Switzerland. Maple is marketed and
> >supported by Waterloo Maple, Inc.
>
> Once again I learn not to suspect Dan of being wrong.
>
> -Carl

I don't have the symbolic math toolbox. I have the optimization
toolbox and the statistics toolbox, that's it. Each toolbox is like
$1000!

🔗Carl Lumma <ekin@lumma.org>

1/21/2004 5:54:09 PM

>>>The computational engine underlying the [symbolic math] toolboxes
>>>is the kernel of Maple, a system developed primarily at the
>>>University of Waterloo, Canada, and, more recently, at the
>>>Eidgenössiche Technische Hochschule, Zürich, Switzerland. Maple
>>>is marketed and supported by Waterloo Maple, Inc.
>>
>> Once again I learn not to suspect Dan of being wrong.
>
>I don't have the symbolic math toolbox. I have the optimization
>toolbox and the statistics toolbox, that's it. Each toolbox is like
>$1000!

How can one tell what toolboxes are installed? I have 27 toolboxes
in my "launch pad", whatever that means.

-Carl

🔗Graham Breed <graham@microtonal.co.uk>

1/22/2004 6:44:08 AM

Paul Erlich wrote:

> I don't have the symbolic math toolbox. I have the optimization > toolbox and the statistics toolbox, that's it. Each toolbox is like > $1000!

It looks like I have it at college. Does anybody know an easy way to test it?

Graham

🔗Paul Erlich <perlich@aya.yale.edu>

1/22/2004 11:50:21 AM

--- In tuning-math@yahoogroups.com, Carl Lumma <ekin@l...> wrote:
> >>>The computational engine underlying the [symbolic math]
toolboxes
> >>>is the kernel of Maple, a system developed primarily at the
> >>>University of Waterloo, Canada, and, more recently, at the
> >>>Eidgenössiche Technische Hochschule, Zürich, Switzerland. Maple
> >>>is marketed and supported by Waterloo Maple, Inc.
> >>
> >> Once again I learn not to suspect Dan of being wrong.
> >
> >I don't have the symbolic math toolbox. I have the optimization
> >toolbox and the statistics toolbox, that's it. Each toolbox is
like
> >$1000!
>
> How can one tell what toolboxes are installed?

Go to your "toolbox" subdirectory. Within that, you'll have "matlab"
and "local" subdirectories, plus ones for whatever toolboxes you have.

> I have 27 toolboxes
> in my "launch pad", whatever that means.
>
> -Carl

But you don't know which ones?

🔗Carl Lumma <ekin@lumma.org>

1/22/2004 12:13:35 PM

>> How can one tell what toolboxes are installed?
>
>Go to your "toolbox" subdirectory. Within that, you'll have "matlab"
>and "local" subdirectories, plus ones for whatever toolboxes you have.

Yep, looks like I have the works. No wonder the bugger was 2 full
cds.

>> I have 27 toolboxes
>> in my "launch pad", whatever that means.
>
>But you don't know which ones?

It says which ones. Symbolic math and Optimization among them. But
since I already have Maple it's kinda moot in this case.

-Carl