Hei ed,
I waited since september 5, for a solution to Gordon
Bower question about
powers of 2 beginning with a fixed number and then I
decided to solve it by
myself. Here is the Mathematica solution where n is
the fixed number and b
is the exponent base.
firstnum[n_, b_] :=
Block[{fr1 = Log[10, b], fr2 =
FractionalPart[N[Log[10, n], 20]], fr3,
fr4 = FractionalPart[N[Log[10, n + 1], 20]],
fr5 = Power[10, -StringLength[ToString[n]]], i =
1},
fr3 = fr1;
While[
Abs[FractionalPart[N[fr3, 20]] - fr2] > fr5 &&
Abs[FractionalPart[N[fr3, 20]] - fr4] > fr5,
fr3 = fr3 + fr1;
i = i + 1];
Print["lower exponent is: ", i]
]
Edoardo Gueglio
Milan
Italy
----------------------------------------------------
OK - here is my method. It finds the smallest integer n such that the
real part of the base-10 logarithm of 2^n lies in any given open
interval (a,b) where 0 epsilon,
{While[Abs[runningm-target]> epsilon &&
Sign[runningm-target] == Sign[c[i]],
{runningsum=runningsum + b[i];
runningm = Mod[runningm - c[i], 1];
AppendTo[powerlist, {runningsum, 10^runningm}]
}];
i=i+1
}]
After you run this code, "cflist" will contain convergents of the cfe of
log 2 from 1/3 up to 174131244785/578451474249, and "powerlist" will
contain all the steps in the appromixation of the target, from 3, 6, 16
... on up to ...36346536204, 38269936534, 40193336864.
Using this code for another target will, of course, mean making the
obvious changes to target= and epsilon=, and doing the first step by hand
to know what to initialize powerlist, runningsum, and i with. If your
target is more than 12 digits long, cflist needs to be made longer.
Changing the base from 2 to 3 (or any other number that's not a power ten)
requires several changes in the obvious places.
Gordon Bower
-----------------------------------------------------------------------
Here's a method for finding a power of 2 with given starting digits.
The problem is to solve, for x,y integers,
7.777777777 x 10^y < 2^x < 7.777777778 x 10^y
where the 7.777... may be replaced by any desired sequence of starting
digits.
Take the base 10 log of each term:
y + log10(7.777777777) < x log10(2) < y + log10(7.777777778)
Calculate the logs to an appropriate precision. The logs of the starting
digits must be solved to the point that they differ; the log10(2) must be
solved to approximately twice this precision, because it is going to be
multiplied by the potentially large number x.
This gives an equation like:
y + 0.8908555305315 < 0.301029995663981... x < y + 0.8908555305873
Here y is an integer, so ignore it and the whole number part
of 0.3010... x, a sort of mod 1
So we need to find x such that 0.3010... x has fractional part near
0.8908...
This is not trivial, but still doable. Given the fractional part of
the product for some x, you can always find another x with a smaller
fractional part by multiplying by the smaller number that makes that
fractional part exceed 1; this new product will have a smaller
fractional part than the original. So for x = 4, the product is
1.204... and the fractional part is reduced to 0.204...
You can jump to other values of x when you see how to make smaller
fractional parts. x=10 is a good choice yielding a fractional part
of 0.010.... Then you might go to x=3 or 0.903... and add ten 10s
to get 1.003 or thereabouts for x=103. Gradually in this manner you
find the mod 1 inverse of log10(2). When the fractional part is less
than the difference between the other logs, you are guaranteed to
be able to find a solution.
---------------------------------------------------------------------
Dear Ed,
this is an email from Germany, Munich.
I really enjoy your website since more than two years and I am visiting it weekly either to see if there are new puzzles and solutions or to go around in the old entries.
I now want to contribute to the Problem of approximating 7777777777... with powers of 2:
My idea is that you can accumulate smaller and smaller factors starting with 1.0... and by this it is possible to approach each sequence of digits in a number.
f.e. 2^ 10 = 1.02400 * 10^3
2^103 = 1.01412... * 10^31
2^196 = 1.00434... * 10^59
If you are looking for the start 77....:
Start with 2^6 = 64 (as it is smaller than 77)
and multiply ongoing with 2^10, getting 65536, 67108..., 68719..., ..., 75557..., 77371....,
so 2^86 starts with 77.
And how do you get the small factors? The same way you get the other wanted digits: using the found factors and approach the number 100...
I have written a small program (pot2zahx.exe, compiled with dos-power-basic from pot2zahx.bas and sub-programs rechnenx.*) which supplies the search for powers of 2 resulting in the wanted sequence.
When trying to get the mentioned result 2^40193336864 = 7.777777777996 * 10^12099400021 I found that the accuracy of my dos-program was bad for one digit. I had to invent my own computing with many digits. This is now already included in the program. I hope you can follow it, even if you don't understand German. You can also adjust the number of digits which are used for computing of the small factors by changing the input for the part 'RechIni2' and compiling again.
And I have included the program ‘rechnenx.exe’ which computes with many digits (variable).
As your are interested in approximations, I have found a good one for pi, which only uses 3 digits, but a lot of square-roots (=S):
S(S(S(S(S(S(S(S(S(S(7))))))))))^S(9!-S(S(4!))) = 3.1415926 30829...
(It looks much nicer if you draw the square-root-signs.)
If you don't like so many square-roots, what about the following?
2+ 24th root of 24 = 3.1415 86441, where 24=4!, so you use only 3 digits: 2,4,4.
Anyway: I hope you enjoy somehow my findings ...If you want you can publish my dos-program.If you have got any questions, please don’t hesitate to ask.
Sincerely yours
Bodo ZinserEttenhoferstr. 2aD-81375 MunichBodoZinser@CosmoData.net