Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

product with non-deterministic output

0 views
Skip to first unread message

Rainer Rosenthal

unread,
Oct 26, 2009, 7:14:59 AM10/26/09
to
The following piece of code - starting with "restart"
produces either 133 or 247 or 248 using Maple 6:

restart:a := n -> (n^3-1)/(n^3+1):
funny := proc()
local s;
s := sprintf("%a",product(a(n),n=2..infinity));
length(s);
end:
funny();

Is there a random number generator involved?

Cheers,
Rainer Rosenthal
r.ros...@web.de

G. A. Edgar

unread,
Oct 26, 2009, 1:07:32 PM10/26/09
to
In article <7klelgF...@mid.individual.net>, Rainer Rosenthal
<r.ros...@web.de> wrote:

Maple 13 yields 3, presumably because sprintf is printing "2/3" which
has 3 characters. I tried it with Maple 9.5 as well, also 3.
I cannot easily run any earlier version...
What is sprintf actually printing in Maple 6?

--
G. A. Edgar http://www.math.ohio-state.edu/~edgar/

Rainer Rosenthal

unread,
Oct 26, 2009, 2:20:10 PM10/26/09
to
G. A. Edgar schrieb:

> What is sprintf actually printing in Maple 6?

Replacing procedure funny() from my first post by funny2():

restart:
a := n -> (n^3-1)/(n^3+1):

funny2 := proc()


local s;
s := sprintf("%a",product(a(n),n=2..infinity));

print(s);
length(s);
end:
funny2();

I get again the three different lengths 133, 247 and 248.
The corresponding strings are:

length 133:
"-1/6/(((1+I*3^(1/2))*(1/4-1/4*I*3^(1/2)))^(I*3^(1/2)))*((-1+I*3^(\
1/2))*(-1/4-1/4*I*3^(1/2)))^(I*3^(1/2))*(-1+I*3^(1/2))*(1+I*3^(1/\
2))"

length 247:
"-1/6*((1+I*3^(1/2))*(1/4-1/4*I*3^(1/2)))^(-1/2*I*3^(1/2))*((1-I*3\
^(1/2))*(1/4+1/4*I*3^(1/2)))^(1/2*I*3^(1/2))*((-1+I*3^(1/2))*(-1/4\
-1/4*I*3^(1/2)))^(1/2*I*3^(1/2))*((-1-I*3^(1/2))*(-1/4+1/4*I*3^(1\
/2)))^(-1/2*I*3^(1/2))*(-1+I*3^(1/2))*(1+I*3^(1/2))"

length 248:
"-1/6*((1+I*3^(1/2))*(1/4-1/4*I*3^(1/2)))^(-1/2*I*3^(1/2))*((-I*3^\
(1/2)+1)*(1/4+1/4*I*3^(1/2)))^(1/2*I*3^(1/2))*((-1+I*3^(1/2))*(-1\
/4-1/4*I*3^(1/2)))^(1/2*I*3^(1/2))*((-1-I*3^(1/2))*(-1/4+1/4*I*3^\
(1/2)))^(-1/2*I*3^(1/2))*(-1+I*3^(1/2))*(1+I*3^(1/2))"

The strings 247 and 248 differ only in one expression in their
respective first lines:
1-I*3^(1/2) in the shorter string
versus
-I*3^(1/2)+1 in the longer string

Cheers,
Rainer

G. A. Edgar

unread,
Oct 26, 2009, 3:45:16 PM10/26/09
to
In article <7km7imF...@mid.individual.net>, Rainer Rosenthal
<r.ros...@web.de> wrote:

The answers are all correct, it is just that Maple has not yet
simplified them (to 2/3) for you.

It is not, strictly speaking, a "random number generator". But choices
made in Maple algorithms can depend on which term appears first in an
expression. And the order of the terms can vary from one invocation to
another.

Rainer Rosenthal

unread,
Oct 26, 2009, 4:21:10 PM10/26/09
to
G. A. Edgar schrieb:
Thank you. I know that the result is 2/3. Using some simplify()
and expand() it has been confirmed by Maple 6:

a := n -> (n^3-1)/(n^3+1);
product(a(k),k=2..infinity); lengthy output (see above)
simplify(%); yielding -1/6*(1+I*sqrt(3))*(-1+I*sqrt(3))
expand(%); result is 2/3

During my experiments I became confused because of these different
intermediate results. So I constructed this test code above.

I don't see any terms that vary, though.

Cheers,
Rainer

0 new messages