-
Notifications
You must be signed in to change notification settings - Fork 0
/
pe686.nb
383 lines (369 loc) · 15.6 KB
/
pe686.nb
1
2
3
4
5
6
7
8
9
10
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
(* Content-type: application/vnd.wolfram.mathematica *)
(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)
(* CreatedBy='Mathematica 12.3' *)
(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[ 158, 7]
NotebookDataLength[ 15802, 375]
NotebookOptionsPosition[ 14640, 349]
NotebookOutlinePosition[ 15213, 367]
CellTagsIndexPosition[ 15170, 364]
WindowFrame->Normal*)
(* Beginning of Notebook Content *)
Notebook[{
Cell[BoxData[""], "Input",
CellChangeTimes->{{3.846011257005888*^9, 3.8460112665407543`*^9}, {
3.846011454150524*^9,
3.8460115062161465`*^9}},ExpressionUUID->"4bf7245e-220f-46b2-9c4a-\
8798187f7d95"],
Cell[CellGroupData[{
Cell[BoxData[
RowBox[{
RowBox[{"(*", "\[IndentingNewLine]",
RowBox[{
RowBox[{
"Find", " ", "the", " ", "first", " ", "few", " ", "digit", " ", "of",
" ", "large", " ", "exponent", " ", "in", " ", "the", " ", "form", " ",
"of", " ",
RowBox[{"a", "^", "b"}], "\n", "\[IndentingNewLine]",
StyleBox[
SuperscriptBox["a", "b"],
FontSize->24]}],
StyleBox["=",
FontSize->24],
RowBox[{
StyleBox[
SuperscriptBox["10",
RowBox[{"log10",
RowBox[{"(",
RowBox[{"a", "^", "b"}], ")"}]}]],
FontSize->24],
StyleBox["=",
FontSize->24],
RowBox[{
StyleBox[
SuperscriptBox["10",
RowBox[{"b", "*", "log10",
RowBox[{"(", "a", ")"}]}]],
FontSize->24],
StyleBox["\[IndentingNewLine]",
FontSize->24],
StyleBox["=",
FontSize->24],
RowBox[{
StyleBox[
RowBox[{
SuperscriptBox["10",
RowBox[{"\[LeftFloor]",
RowBox[{"b", "*", "log10",
RowBox[{"(", "a", ")"}]}], "\[RightFloor]"}]], "*",
SuperscriptBox["10",
RowBox[{
RowBox[{"b", "*", "log10",
RowBox[{"(", "a", ")"}]}], "-",
RowBox[{"\[LeftFloor]",
RowBox[{"b", "*", "log10",
RowBox[{"(", "a", ")"}]}], "\[RightFloor]"}]}]]}],
FontSize->24],
StyleBox["\[IndentingNewLine]",
FontSize->24],
StyleBox["=",
FontSize->24],
RowBox[{
StyleBox[
SuperscriptBox["10",
RowBox[{"IntegerPart", "[",
RowBox[{"b", "*", "log10",
RowBox[{"(", "a", ")"}]}], "]"}]],
FontSize->24],
StyleBox["*",
FontSize->24],
StyleBox[
SuperscriptBox["10",
RowBox[{"FractionalPart", "[",
RowBox[{"b", "*", "log10",
RowBox[{"(", "a", ")"}]}], "]"}]],
FontSize->24], "\n", "\n", "because", " ", "of", " ",
SuperscriptBox["10", "n"], " ", "does", " ", "not", " ", "change",
" ", "first", " ", "few", " ", "dighs", " ", "but", " ", "only", " ",
"add", " ", "zero", "\n", "then", " ", "the", " ", "first", " ",
"few", " ", "digits", " ", "of", " ",
SuperscriptBox["a", "b"], " ", "is", " ",
SuperscriptBox["10",
RowBox[{"FractionalPart", "[",
RowBox[{"b", "*", "log10",
RowBox[{"(", "a", ")"}]}], "]"}]]}]}]}]}]}], "\[IndentingNewLine]",
"*)"}], "\n", "\n",
RowBox[{
RowBox[{"ClearAll", "[",
RowBox[{"f", ",", "g", ",", "p", ",", "cf"}], "]"}], "\n", "\n",
RowBox[{
RowBox[{"f", "[",
RowBox[{"a_", ",", "b_"}], "]"}], ":=",
RowBox[{"10", "^",
RowBox[{"FractionalPart", "[",
RowBox[{
RowBox[{"N", "[", "b", "]"}], "*",
RowBox[{"Log10", "[", "a", "]"}]}], "]"}]}]}], "\n", "\n",
RowBox[{
RowBox[{"g", "[", "b_", "]"}], ":=",
RowBox[{"Floor", "[",
RowBox[{"100", "*",
RowBox[{"cf", "[",
RowBox[{"2", ",", "b"}], "]"}]}], "]"}]}], "\n", "\n",
RowBox[{
RowBox[{"p", "[",
RowBox[{"L_", ",", "nn_"}], "]"}], ":=", "\[IndentingNewLine]", " ",
RowBox[{"Module", "[",
RowBox[{
RowBox[{"{",
RowBox[{"n", "=", "nn"}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"Monitor", "[",
RowBox[{
RowBox[{"Do", "[",
RowBox[{
RowBox[{
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"g", "[", "j", "]"}], "==", "L"}], ",",
RowBox[{"n", "-=", "1"}]}], "]"}], ";", "\[IndentingNewLine]",
RowBox[{"If", "[",
RowBox[{
RowBox[{"n", "==", "0"}], ",",
RowBox[{"Return", "[", "j", "]"}]}], "]"}]}],
"\[IndentingNewLine]", ",",
RowBox[{"{",
RowBox[{"j", ",", "Infinity"}], "}"}]}], "]"}], ",", " ",
RowBox[{"{",
RowBox[{"j", ",", "n"}], "}"}]}], "]"}]}], "]"}]}], "\n", "\n", "\n",
RowBox[{
RowBox[{"cf", "=",
RowBox[{"Compile", "[",
RowBox[{
RowBox[{"{",
RowBox[{"a", ",", "b"}], "}"}], ",", "\n",
RowBox[{"10", "^",
RowBox[{"FractionalPart", "[",
RowBox[{
RowBox[{"N", "[", "b", "]"}], "*",
RowBox[{"Log10", "[", "a", "]"}]}], "]"}]}], ",", "\n",
RowBox[{"CompilationTarget", "\[Rule]", "\"\<C\>\""}], ",",
RowBox[{"RuntimeOptions", "\[Rule]", "\"\<Speed\>\""}]}], "]"}]}],
";"}], "\n", "\n", "\n", "\n",
RowBox[{
RowBox[{"cg", "=",
RowBox[{"With", "[",
RowBox[{
RowBox[{"{",
RowBox[{"a", "=",
RowBox[{"Log10", "[", "2", "]"}]}], "}"}], ",",
RowBox[{"Compile", "[",
RowBox[{
RowBox[{"{", "b", "}"}], ",", "\n",
RowBox[{"Floor", "[",
RowBox[{"100", "*",
RowBox[{"10", "^",
RowBox[{"FractionalPart", "[",
RowBox[{
RowBox[{"N", "[", "b", "]"}], "*", "a"}], "]"}]}]}], "]"}], ",",
"\n",
RowBox[{"CompilationTarget", "\[Rule]", "\"\<C\>\""}], ",",
RowBox[{"RuntimeOptions", "\[Rule]", "\"\<Speed\>\""}]}], "]"}]}],
"]"}]}], ";"}], "\n", "\n",
RowBox[{
RowBox[{"cp", "=",
RowBox[{"Compile", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"L", ",", "_Integer"}], "}"}], ",",
RowBox[{"{",
RowBox[{"nn", ",", "_Integer"}], "}"}]}], "}"}], ",", "\n",
RowBox[{"Module", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"n", "=", "nn"}], ",",
RowBox[{"j", "=", "1"}]}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"While", "[",
RowBox[{
RowBox[{"n", ">", "0"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"cg", "[", "j", "]"}], "==", "123"}], ",",
RowBox[{"n", "-=", "1"}]}], "]"}], ";", "\[IndentingNewLine]",
RowBox[{"j", "+=", "1"}], ";"}]}], "]"}], ";",
"\[IndentingNewLine]", "j"}]}], "]"}], "\[IndentingNewLine]", ",",
RowBox[{"CompilationTarget", "\[Rule]", "\"\<C\>\""}], ",",
RowBox[{"RuntimeOptions", "\[Rule]", "\"\<Speed\>\""}]}], "]"}]}],
";"}], "\n", "\[IndentingNewLine]",
RowBox[{
RowBox[{"cp", "[",
RowBox[{"123", ",", "678910"}], "]"}], "//", "AbsoluteTiming"}], "\n",
"\n"}]}]], "Code", "Input",
CellChangeTimes->{{3.8460150864151845`*^9, 3.8460150935512686`*^9}, {
3.8460151245329695`*^9, 3.846015160796139*^9}, {3.8460156499666824`*^9,
3.84601580842023*^9}, {3.846015966339741*^9, 3.846016052631505*^9}, {
3.846016084609188*^9, 3.8460160848345833`*^9}, 3.8460164301659517`*^9, {
3.8460165362470264`*^9, 3.8460165538451552`*^9}, {3.846016635100024*^9,
3.846016720004117*^9}, {3.8460167883536797`*^9, 3.8460169677794456`*^9}, {
3.846017038924961*^9, 3.8460174521513605`*^9}, {3.8460174840843697`*^9,
3.8460177499772663`*^9}, {3.846017865154935*^9, 3.846017992541253*^9}, {
3.8460180264515533`*^9, 3.8460180809049788`*^9}, {3.8460181486903243`*^9,
3.8460182778355722`*^9}, {3.84601831294022*^9, 3.8460183681892376`*^9},
3.846018431638369*^9, {3.8460185657847085`*^9, 3.8460185972587905`*^9}, {
3.84601882411934*^9, 3.8460188972804885`*^9}, {3.8460189277873554`*^9,
3.8460190182851934`*^9}, {3.846019096105691*^9, 3.846019195463696*^9}, {
3.84601940490108*^9, 3.8460196316985807`*^9}, {3.8460196750838213`*^9,
3.8460197173840027`*^9}, {3.8460203308547287`*^9,
3.8460203851355867`*^9}, {3.846020439456118*^9, 3.8460205616012783`*^9},
3.846020811808014*^9, {3.8460213408462057`*^9, 3.846021377787835*^9}, {
3.846021761185527*^9,
3.8460218252728815`*^9}},ExpressionUUID->"a700ce11-2ba8-4d01-81c9-\
c3ea4b2a0649"],
Cell[BoxData[
RowBox[{"{",
RowBox[{"12.4522399`", ",", "193060224"}], "}"}]], "Output",
CellChangeTimes->{{3.8460180396844883`*^9, 3.8460180722931*^9},
3.846018136362995*^9, {3.846018240042425*^9, 3.8460182619391127`*^9}, {
3.8460183134003315`*^9, 3.8460183685465527`*^9}, {3.846018570019915*^9,
3.8460185976269007`*^9}, {3.846018900633609*^9, 3.8460189198949757`*^9},
3.846018971243062*^9, 3.846019019968498*^9, {3.8460190977807684`*^9,
3.8460191616566343`*^9}, 3.8460191971633263`*^9, {3.84601941872423*^9,
3.8460195481124134`*^9}, 3.8460196335663652`*^9, {3.8460196780599008`*^9,
3.84601971908505*^9}, {3.8460203397634363`*^9, 3.8460203903386045`*^9}, {
3.84602045590983*^9, 3.846020499082133*^9}, {3.846020536698231*^9,
3.8460205786313376`*^9}, 3.8460208170186586`*^9, 3.8460208867890587`*^9, {
3.84602135871095*^9, 3.8460213725531673`*^9}, 3.846021756556919*^9},
CellLabel->
"Out[937]=",ExpressionUUID->"0bfc49dd-dcb4-4853-8854-22f21e7b33ba"]
}, Open ]],
Cell[CellGroupData[{
Cell[BoxData[{
RowBox[{"Log", "[",
RowBox[{"10", ",", "1.23"}], "]"}], "\[IndentingNewLine]",
RowBox[{"Log", "[",
RowBox[{"10", ",", "1.24"}], "]"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"f", "[", "b_", "]"}], ":=",
RowBox[{"10", "^",
RowBox[{"FractionalPart", "[",
RowBox[{
RowBox[{"N", "[", "b", "]"}], "*",
RowBox[{"Log10", "[", "2", "]"}]}], "]"}]}]}], "\[IndentingNewLine]",
RowBox[{"f", "@",
RowBox[{"Range", "[",
RowBox[{"100", ",", "200"}], "]"}]}]}], "Input",
CellChangeTimes->{{3.8460942313448896`*^9, 3.8460942392227077`*^9}, {
3.8460942710657377`*^9, 3.8460943026060286`*^9}, {3.846094374377178*^9,
3.846094381036168*^9}, {3.8460944631509433`*^9, 3.8460945006617327`*^9}, {
3.8460945490597467`*^9, 3.8460945623202276`*^9}},
CellLabel->"In[21]:=",ExpressionUUID->"43a3c4b3-9389-493e-8a11-87796ec99b33"],
Cell[BoxData["0.08990511143939792`"], "Output",
CellChangeTimes->{{3.846094244942164*^9, 3.84609427288402*^9}, {
3.8460944903437777`*^9, 3.846094500906823*^9}, {3.8460945503195524`*^9,
3.846094562691272*^9}},
CellLabel->"Out[21]=",ExpressionUUID->"419f3f5c-7f73-49ca-a548-5d4e1a2fb49f"],
Cell[BoxData["0.09342168516223506`"], "Output",
CellChangeTimes->{{3.846094244942164*^9, 3.84609427288402*^9}, {
3.8460944903437777`*^9, 3.846094500906823*^9}, {3.8460945503195524`*^9,
3.846094562699238*^9}},
CellLabel->"Out[22]=",ExpressionUUID->"038f312e-383f-4421-b453-a60e3cee7a05"],
Cell[BoxData[
RowBox[{"{",
RowBox[{
"1.2676506002282153`", ",", "2.535301200456431`", ",", "5.070602400912863`",
",", "1.0141204801825727`", ",", "2.0282409603651455`", ",",
"4.056481920730292`", ",", "8.112963841460585`", ",",
"1.6225927682921037`", ",", "3.245185536584208`", ",",
"6.490371073168417`", ",", "1.2980742146336837`", ",",
"2.5961484292673678`", ",", "5.1922968585347355`", ",",
"1.0384593717069472`", ",", "2.076918743413895`", ",",
"4.153837486827791`", ",", "8.307674973655581`", ",",
"1.6615349947311167`", ",", "3.3230699894622338`", ",",
"6.646139978924468`", ",", "1.3292279957848938`", ",",
"2.658455991569788`", ",", "5.316911983139577`", ",",
"1.0633823966279154`", ",", "2.1267647932558313`", ",",
"4.253529586511663`", ",", "8.507059173023327`", ",",
"1.7014118346046656`", ",", "3.4028236692093317`", ",",
"6.805647338418664`", ",", "1.361129467683733`", ",",
"2.7222589353674667`", ",", "5.444517870734934`", ",",
"1.0889035741469868`", ",", "2.177807148293974`", ",",
"4.355614296587949`", ",", "8.711228593175898`", ",", "1.74224571863518`",
",", "3.4844914372703606`", ",", "6.968982874540722`", ",",
"1.3937965749081445`", ",", "2.7875931498162894`", ",",
"5.57518629963258`", ",", "1.1150372599265161`", ",",
"2.2300745198530323`", ",", "4.4601490397060655`", ",",
"8.920298079412133`", ",", "1.7840596158824267`", ",",
"3.568119231764854`", ",", "7.1362384635297085`", ",",
"1.4272476927059419`", ",", "2.854495385411884`", ",",
"5.708990770823769`", ",", "1.141798154164754`", ",",
"2.2835963083295083`", ",", "4.5671926166590175`", ",",
"9.134385233318035`", ",", "1.8268770466636073`", ",",
"3.6537540933272155`", ",", "7.307508186654432`", ",",
"1.4615016373308864`", ",", "2.9230032746617254`", ",",
"5.846006549323452`", ",", "1.1692013098646905`", ",",
"2.3384026197293815`", ",", "4.676805239458764`", ",",
"9.353610478917528`", ",", "1.8707220957835058`", ",",
"3.741444191567012`", ",", "7.482888383134026`", ",",
"1.4965776766268053`", ",", "2.993155353253611`", ",",
"5.986310706507223`", ",", "1.1972621413014448`", ",",
"2.3945242826028896`", ",", "4.78904856520578`", ",", "9.578097130411562`",
",", "1.9156194260823125`", ",", "3.8312388521646255`", ",",
"7.662477704329253`", ",", "1.5324955408658507`", ",",
"3.064991081731702`", ",", "6.129982163463405`", ",", "1.225996432692681`",
",", "2.451992865385362`", ",", "4.903985730770725`", ",",
"9.807971461541452`", ",", "1.9615942923082907`", ",",
"3.923188584616582`", ",", "7.846377169233165`", ",",
"1.5692754338466333`", ",", "3.138550867693267`", ",",
"6.277101735386535`", ",", "1.255420347077307`", ",",
"2.5108406941546146`", ",", "5.021681388309229`", ",",
"1.004336277661846`", ",", "2.0086725553236926`", ",",
"4.017345110647385`", ",", "8.034690221294772`", ",",
"1.6069380442589545`"}], "}"}]], "Output",
CellChangeTimes->{{3.846094244942164*^9, 3.84609427288402*^9}, {
3.8460944903437777`*^9, 3.846094500906823*^9}, {3.8460945503195524`*^9,
3.8460945627033653`*^9}},
CellLabel->"Out[24]=",ExpressionUUID->"110017b5-bf09-44be-954f-ff8901f755b5"]
}, Open ]]
},
WindowSize->{1302, 606},
WindowMargins->{{286, Automatic}, {Automatic, 198}},
FrontEndVersion->"12.3 for Microsoft Windows (64-bit) (July 9, 2021)",
StyleDefinitions->FrontEnd`FileName[{$RootDirectory, "C:", "Users", "stary",
"AppData", "Roaming", "Mathematica", "SystemFiles", "FrontEnd",
"StyleSheets"}, "OD.nb", CharacterEncoding -> "UTF-8"],
ExpressionUUID->"c5a2c16c-7f92-46a0-8f11-56bc84fff65c"
]
(* End of Notebook Content *)
(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[558, 20, 205, 4, 38, "Input",ExpressionUUID->"4bf7245e-220f-46b2-9c4a-8798187f7d95"],
Cell[CellGroupData[{
Cell[788, 28, 8073, 208, 1421, "Code",ExpressionUUID->"a700ce11-2ba8-4d01-81c9-c3ea4b2a0649"],
Cell[8864, 238, 992, 15, 42, "Output",ExpressionUUID->"0bfc49dd-dcb4-4853-8854-22f21e7b33ba"]
}, Open ]],
Cell[CellGroupData[{
Cell[9893, 258, 870, 19, 132, "Input",ExpressionUUID->"43a3c4b3-9389-493e-8a11-87796ec99b33"],
Cell[10766, 279, 293, 4, 42, "Output",ExpressionUUID->"419f3f5c-7f73-49ca-a548-5d4e1a2fb49f"],
Cell[11062, 285, 293, 4, 67, "Output",ExpressionUUID->"038f312e-383f-4421-b453-a60e3cee7a05"],
Cell[11358, 291, 3266, 55, 477, "Output",ExpressionUUID->"110017b5-bf09-44be-954f-ff8901f755b5"]
}, Open ]]
}
]
*)