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
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/
> 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
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.
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