Search NKS | Online
211 - 220 of 681 for Novo Curso De Direito Civil - Vol. 1 - Parte Geral - 26ª EdGagliano, Pablo StolzeSaraiva Jur
An example is the algorithm of Anatolii Karatsuba from 1961 for finding products of n -digit numbers (with n = 2 s ) by operating on their digits in the nested pattern of page 608 (see also page 1093 ) according to
First[f[IntegerDigits[x, 2, n], IntegerDigits[y, 2, n], n/2]]
f[x_, y_, n_] := If[n < 1, x y, g[Partition[x, n], Partition[y, n], n]]
g[{x1_, x0_}, {y1_, y0_}, n_] := With[{z1 = f[x1, y1, n/2], z0 = f[x0, y0, n/2]}, z1 2 2n + (f[x0 + x1, y0 + y1, n/2] - z1 - z0)2 n + z0]
Other examples include the fast Fourier transform (page 1074 ) and related algorithms for ListConvolve , the quicksort algorithm for Sort , and many algorithms in fields such as computational geometry.
If one starts from the single-element set {1} then applying Union , Intersection and Complement one always gets either {} or {1} . … But if one uses instead s = {1, 2} then starts with {1} and {2} one gets any of {{}, {1}, {2}, {1, 2}} and in general with s = Range[n] one gets any of the 2 n elements in the powerset
Distribute[Map[{{}, {#}} &, s], List, List, List, Join]
But applying Complement[s, Intersection[a, b]] to these elements still always produces the same equivalences as with a ⊼ b . … And the reason for this is that with s = {1, 2} the function Union[Complement[s, a], b] corresponding to a b only ever gets to the 3 elements {{1}, {2}, {1, 2}} .
So by looking at how these heights grow across the page, one can see whether there is a correspondence with the r d - 1 form that one expects for ordinary d -dimensional space. And indeed in case (g), for example, one sees exactly r 1 linear growth, reflecting dimension 2.
Similarly, in case (d) one sees r 0 growth, reflecting dimension 1, while in case (h) one sees r 2 growth, reflecting dimension 3.
Capabilities [of sequential substitution systems]
Even with the single rule {s[1, 0] s[0, 1]} , a sequential substitution system can sort its initial conditions so that all 0's occur before all 1's.
Turing machines [emulating cellular automata]
Given the rules for an elementary cellular automaton in the form used on page 867 , the following will construct a Turing machine which emulates it:
CAToTM[rules_] := {{q[a_, b_], c : (0 | 1)} {q[b, c], {a, b, c} /. rules, 1}, {q[_, _], x} {p[0], 0, -1}, {p[a_], b : (0 | 1)} {p[b], a, -1}, {p[_], x} {q[0, 0], 0, 1}}
Given a list of initial cell colors for the cellular automaton, the initial tape for the Turing machine consists of Join[{0, 0}, list, {0, 0}] surrounded by x 's, with the head of the Turing machine on the first 0 in state q[0, 0] .
Implementation [of TM cellular automaton]
Given a non-deterministic Turing machine with rules in the form above, the rules for a cellular automaton which emulates it can be obtained from
NDTMToCA[tm_] := Flatten[{{_, h, _} h, {s, _c, _} e, {s, _, _} s, {_, s, c[i_]} s[i], {_, s, x_} x, {a[_, _], _s, _} s, {_, a[x_, y_], s[i_]} a[x, y, i], {x_, _s, _} x, {_, _, s[i_]} s[i], Map[Table[With[{b = (# 〚 Min[Length[#], z] 〛 &)[ {x, #} /. tm]}, If[Last[b] -1, {{a[_], a[x, #, z], e} h, {a[ _], a[x, #, z], s} a[x, #, z], {a[_], a[x, #, z], _} a[b 〚 2 〛 ], {a[x, #, z], a[w_], _} a[b 〚 1 〛 , w], {_, a[w_], a[x, #, z]} a[w]}, {{a[_], a[x, #, z], _} a[b 〚 2 〛 ], {a[x, #, z], a[w_], _} a[w], {_, a[w_], a[x, #, z]} a[b 〚 1 〛 , w]}]], {x, Max[Map[# 〚 1, 1 〛 &, tm]]}, {z, Max[Map[Length[# 〚 2 〛 ] &, tm]]}] &, Union[Map[# 〚 1, 2 〛 &, tm]]], {_, x_, _} x}]
Non-deterministic Turing machines
Generalizing rules from page 888 by making each right-hand side a list of possible outcomes, the list of configurations that can be reached after t steps is given by
NTMEvolve[rule_, inits_, t_Integer] := Nest[ Union[Flatten[Map[NTMStep[rule, #]&, #], 1]]&, inits, t]
NTMStep[rule_List, {s_, a_, n_}] /; 1 ≤ n ≤ Length[a] := Apply[{#1, ReplacePart[a, #2, n], n + #3}&, Replace[{s, a 〚 n 〛 }, rule], {1}]
In enumerating recursive functions it is convenient to use symbolic definitions for composition and primitive recursion
c[g_, h___] = Apply[g, Through[{h}[##]]] &
r[g_, h_] = If[#1 0, g[##2], h[#0[#1 - 1, ##2], #1 - 1, ##2]] &
where the more efficient unwound form is
r[g_,h_] = Fold[Function[{u, v}, h[u, v, ##2]], g[##2], Range[0, #1 - 1]] &
And in terms of these, for example, plus = r[p[1], s] .
… From its definition, the function can be written as
Fold[Fold[2^Ceiling[Log[2, Ceiling[(#1 + 2)/(#2 + 2)]]] (#2 + 2) - 2 - #1 &, #2, Range[#1]] &, 0, Range[#]]&
Its first zeros are at {4, 126, 813, 966, 1166, 1177, 1666, 1897} .
… Note that functions of the form Nest[r[c[s, z], #] &, c[s, s], n] are given in terms of the original Ackermann function in the note above by f[n + 1, 2, # + 1] - 1 & .
For all initial conditions this depth seems at first to increase linearly, then to decrease in a nested way according to
FoldList[Plus, 0, Flatten[Table[ {1, 1, Table[-1, {IntegerExponent[i, 2] + 1}]}, {i, m}]]]
This quantity alternates between value 1 at position 2 j and value j at position 2 j - j + 1 . … For initial conditions of size n , this occurs after at most Sum[Nest[2 # &, 0, i] - 1, {i, n}] + 1 steps.
Historically, the number of decimal digits of π that have been computed is roughly as follows: 2000 BC (Babylonians, Egyptians): 2 digits; 200 BC ( Archimedes ): 5 digits; 1430 AD: 14 digits; 1610: 35 digits; 1706: 100 digits; 1844: 200 digits; 1855: 500 digits; 1949 (ENIAC computer): 2037 digits; 1961: 100,000 digits (IBM 7090); 1973: 1 million; 1983: 16 million; 1989: 1 billion; 1997: 50 billion; 1999: 206 billion. In the first 200 billion digits, the frequencies of 0 through 9 differ from 20 billion by
{30841, -85289, 136978, 69393, -78309, -82947, -118485, -32406, 291044, -130820}
An early approximation to π was
4 Sum[(-1) k /(2k + 1), {k, 0, m}]
30 digits were obtained with
2 Apply[Times, 2/Rest[NestList[Sqrt[2 + #]&, 0, m]]]
An efficient way to compute π to n digits of precision is
(# 〚 2 〛 2 /# 〚 3 〛 )& [NestWhile[Apply[Function[{a, b, c, d}, {(a + b)/2, Sqrt[a b], c - d (a - b) 2 , 2 d}], #]&, {1, 1/Sqrt[N[2, n]], 1/4, 1/4}, # 〚 2 〛 ≠ # 〚 2 〛 &]]
This requires about Log[2, n] steps, or a total of roughly n Log[n] 2 operations (see page 1134 ).