<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.formulasearchengine.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=117.196.82.75</id>
	<title>formulasearchengine - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://en.formulasearchengine.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=117.196.82.75"/>
	<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/wiki/Special:Contributions/117.196.82.75"/>
	<updated>2026-08-02T23:23:02Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.47.0-wmf.7</generator>
	<entry>
		<id>https://en.formulasearchengine.com/w/index.php?title=Pull-up_resistor&amp;diff=8974</id>
		<title>Pull-up resistor</title>
		<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/w/index.php?title=Pull-up_resistor&amp;diff=8974"/>
		<updated>2013-10-24T21:37:17Z</updated>

		<summary type="html">&lt;p&gt;117.196.82.75: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Pollard&#039;s rho algorithm for logarithms&#039;&#039;&#039; is an algorithm introduced by [[John Pollard (mathematician)|John Pollard]] in 1978 for solving the [[discrete logarithm]] problem analogous to [[Pollard&#039;s rho algorithm]] for solving the [[Integer factorization]] problem.&lt;br /&gt;
&lt;br /&gt;
The goal is to compute &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;\alpha ^ \gamma = \beta&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; belongs to a [[Group (mathematics)|group]] &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; generated by &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;. The algorithm computes integers &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;b&amp;lt;/math&amp;gt;,  &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; such that &amp;lt;math&amp;gt;\alpha^a \beta^b = \alpha^A \beta^B&amp;lt;/math&amp;gt;. Assuming, for simplicity, that the underlying group is cyclic of order &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;, we can calculate &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt; as a solution of the equation &amp;lt;math&amp;gt;(B-b)\gamma = (a-A) \pmod{n}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To find the needed &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;b&amp;lt;/math&amp;gt;,  &amp;lt;math&amp;gt;A&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; the algorithm uses [[Floyd&#039;s cycle-finding algorithm]] to find a cycle in the sequence &amp;lt;math&amp;gt;x_i = \alpha^{a_i} \beta^{b_i}&amp;lt;/math&amp;gt;, where the function &amp;lt;math&amp;gt;f: x_i \mapsto x_{i+1}&amp;lt;/math&amp;gt; is assumed to be random-looking and thus is likely to enter into a loop after approximately &amp;lt;math&amp;gt;\sqrt{\frac{\pi n}{2}}&amp;lt;/math&amp;gt; steps. One way to define such a function is to use the following rules: Divide &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; into three disjoint subsets of approximately equal size: &amp;lt;math&amp;gt;S_0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;S_1&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;S_2&amp;lt;/math&amp;gt;. If &amp;lt;math&amp;gt;x_i&amp;lt;/math&amp;gt; is in &amp;lt;math&amp;gt;S_0&amp;lt;/math&amp;gt; then double both &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;b&amp;lt;/math&amp;gt;; if &amp;lt;math&amp;gt;x_i \in S_1&amp;lt;/math&amp;gt; then increment &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt;, if &amp;lt;math&amp;gt;x_i \in S_2&amp;lt;/math&amp;gt; then increment &amp;lt;math&amp;gt;b&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Algorithm==&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; be a cyclic group of order &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;, and given &amp;lt;math&amp;gt;\alpha, \beta\in G&amp;lt;/math&amp;gt;, and a partition &amp;lt;math&amp;gt;G = S_0\cup S_1\cup S_2&amp;lt;/math&amp;gt;, let &amp;lt;math&amp;gt;f:G\to G&amp;lt;/math&amp;gt; be a map&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
f(x) = \left\{\begin{matrix}&lt;br /&gt;
\beta x &amp;amp; x\in S_0\\&lt;br /&gt;
x^2 &amp;amp; x\in S_1\\&lt;br /&gt;
\alpha x &amp;amp; x\in S_2&lt;br /&gt;
\end{matrix}\right.&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and define maps &amp;lt;math&amp;gt;g:G\times\mathbb{Z}\to\mathbb{Z}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;h:G\times\mathbb{Z}\to\mathbb{Z}&amp;lt;/math&amp;gt; by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
g(x,n) = \left\{\begin{matrix}&lt;br /&gt;
n &amp;amp; x\in S_0\\&lt;br /&gt;
2n \ (\bmod \ p) &amp;amp; x\in S_1\\&lt;br /&gt;
n+1 \ (\bmod \ p) &amp;amp; x\in S_2&lt;br /&gt;
\end{matrix}\right.&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
h(x,n) = \left\{\begin{matrix}&lt;br /&gt;
n+1 \ (\bmod \ p) &amp;amp; x\in S_0\\&lt;br /&gt;
2n \ (\bmod \ p) &amp;amp; x\in S_1\\&lt;br /&gt;
n &amp;amp; x\in S_2&lt;br /&gt;
\end{matrix}\right.&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;Inputs&#039;&#039;&#039; &#039;&#039;a&#039;&#039; a generator of &#039;&#039;G&#039;&#039;, &#039;&#039;b&#039;&#039; an element of &#039;&#039;G&#039;&#039;&lt;br /&gt;
:&#039;&#039;&#039;Output&#039;&#039;&#039; An integer &#039;&#039;x&#039;&#039; such that &#039;&#039;a&amp;lt;sup&amp;gt;x&amp;lt;/sup&amp;gt; = b&#039;&#039;, or failure&lt;br /&gt;
:# Initialise &#039;&#039;a&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;&#039;&#039; &amp;amp;larr; 0&lt;br /&gt;
:#::&#039;&#039;b&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;&#039;&#039; &amp;amp;larr; 0&lt;br /&gt;
:#::&#039;&#039;x&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;&#039;&#039; &amp;amp;larr; 1 &amp;amp;isin; &#039;&#039;G&#039;&#039;&lt;br /&gt;
:#::&#039;&#039;i&#039;&#039; &amp;amp;larr; 1&lt;br /&gt;
:# &#039;&#039;x&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;&#039;&#039; &amp;amp;larr; &#039;&#039;f(x&amp;lt;sub&amp;gt;i-1&amp;lt;/sub&amp;gt;)&#039;&#039;, &#039;&#039;a&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;&#039;&#039; &amp;amp;larr; &#039;&#039;g(x&amp;lt;sub&amp;gt;i-1&amp;lt;/sub&amp;gt;,a&amp;lt;sub&amp;gt;i-1&amp;lt;/sub&amp;gt;)&#039;&#039;, &#039;&#039;b&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;&#039;&#039; &amp;amp;larr; &#039;&#039;h(x&amp;lt;sub&amp;gt;i-1&amp;lt;/sub&amp;gt;,b&amp;lt;sub&amp;gt;i-1&amp;lt;/sub&amp;gt;)&#039;&#039;&lt;br /&gt;
:#&#039;&#039;x&amp;lt;sub&amp;gt;2i&amp;lt;/sub&amp;gt;&#039;&#039; &amp;amp;larr; &#039;&#039;f(f(x&amp;lt;sub&amp;gt;2i-2&amp;lt;/sub&amp;gt;))&#039;&#039;, &#039;&#039;a&amp;lt;sub&amp;gt;2i&amp;lt;/sub&amp;gt;&#039;&#039; &amp;amp;larr; &#039;&#039;g(f(x&amp;lt;sub&amp;gt;2i-2&amp;lt;/sub&amp;gt;),g(x&amp;lt;sub&amp;gt;2i-2&amp;lt;/sub&amp;gt;,a&amp;lt;sub&amp;gt;2i-2&amp;lt;/sub&amp;gt;))&#039;&#039;, &#039;&#039;b&amp;lt;sub&amp;gt;2i&amp;lt;/sub&amp;gt;&#039;&#039; &amp;amp;larr; &#039;&#039;h(f(x&amp;lt;sub&amp;gt;2i-2&amp;lt;/sub&amp;gt;),h(x&amp;lt;sub&amp;gt;2i-2&amp;lt;/sub&amp;gt;,b&amp;lt;sub&amp;gt;2i-2&amp;lt;/sub&amp;gt;))&#039;&#039;&lt;br /&gt;
:# If &#039;&#039;x&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;&#039;&#039; = &#039;&#039;x&amp;lt;sub&amp;gt;2i&amp;lt;/sub&amp;gt;&#039;&#039; then&lt;br /&gt;
:## &#039;&#039;r&#039;&#039; &amp;amp;larr; &#039;&#039;b&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;&#039;&#039; - &#039;&#039;b&amp;lt;sub&amp;gt;2i&amp;lt;/sub&amp;gt;&#039;&#039;&lt;br /&gt;
:## If r = 0 return failure&lt;br /&gt;
:## x &amp;amp;larr; &#039;&#039;r&amp;lt;sup&amp;gt;  -1 &amp;lt;/sup&amp;gt;&#039;&#039;(&#039;&#039;a&amp;lt;sub&amp;gt;2i&amp;lt;/sub&amp;gt;&#039;&#039; - &#039;&#039;a&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;&#039;&#039;) mod &#039;&#039;p&#039;&#039;&lt;br /&gt;
:## return x&lt;br /&gt;
:# If &#039;&#039;x&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;&#039;&#039; &amp;amp;ne; &#039;&#039;x&amp;lt;sub&amp;gt;2i&amp;lt;/sub&amp;gt;&#039;&#039; then &#039;&#039;i&#039;&#039; &amp;amp;larr; &#039;&#039;i+1&#039;&#039;, and go to step 2.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
Consider, for example, the group generated by 2 modulo &amp;lt;math&amp;gt;N=1019&amp;lt;/math&amp;gt; (the order of the group is &amp;lt;math&amp;gt;n=1018&amp;lt;/math&amp;gt;, 2&lt;br /&gt;
generates the group of units modulo 1019). The algorithm is implemented by the following [[C++]] program:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 const int n = 1018, N = n + 1;  /* N = 1019 -- prime     */&lt;br /&gt;
 const int alpha = 2;            /* generator             */&lt;br /&gt;
 const int beta = 5;             /* 2^{10} = 1024 = 5 (N) */&lt;br /&gt;
 &lt;br /&gt;
 void new_xab( int&amp;amp; x, int&amp;amp; a, int&amp;amp; b ) {&lt;br /&gt;
   switch( x%3 ) {&lt;br /&gt;
   case 0: x = x*x     % N;  a =  a*2  % n;  b =  b*2  % n;  break;&lt;br /&gt;
   case 1: x = x*alpha % N;  a = (a+1) % n;                  break;&lt;br /&gt;
   case 2: x = x*beta  % N;                  b = (b+1) % n;  break;&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main(void) {&lt;br /&gt;
   int x=1, a=0, b=0;&lt;br /&gt;
   int X=x, A=a, B=b;&lt;br /&gt;
   for(int i = 1; i &amp;lt; n; ++i ) {&lt;br /&gt;
     new_xab( x, a, b );&lt;br /&gt;
     new_xab( X, A, B ); new_xab( X, A, B );&lt;br /&gt;
     printf( &amp;quot;%3d  %4d %3d %3d  %4d %3d %3d\n&amp;quot;, i, x, a, b, X, A, B );&lt;br /&gt;
     if( x == X ) break;&lt;br /&gt;
   }&lt;br /&gt;
   return 0;&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The results are as follows (edited):&lt;br /&gt;
&lt;br /&gt;
  i     x   a   b     X   A   B&lt;br /&gt;
 ------------------------------&lt;br /&gt;
  1     2   1   0    10   1   1&lt;br /&gt;
  2    10   1   1   100   2   2&lt;br /&gt;
  3    20   2   1  1000   3   3&lt;br /&gt;
  4   100   2   2   425   8   6&lt;br /&gt;
  5   200   3   2   436  16  14&lt;br /&gt;
  6  1000   3   3   284  17  15&lt;br /&gt;
  7   981   4   3   986  17  17&lt;br /&gt;
  8   425   8   6   194  17  19&lt;br /&gt;
 ..............................&lt;br /&gt;
 48   224 680 376    86 299 412&lt;br /&gt;
 49   101 680 377   860 300 413&lt;br /&gt;
 50   505 680 378   101 300 415&lt;br /&gt;
 51  1010 681 378  1010 301 416&lt;br /&gt;
&lt;br /&gt;
That is &amp;lt;math&amp;gt;2^{681} 5^{378} = 1010 = 2^{301} 5^{416} \pmod{1019}&amp;lt;/math&amp;gt; and so &amp;lt;math&amp;gt;(416-378)\gamma = 681-301 \pmod{1018}&amp;lt;/math&amp;gt;, for which &amp;lt;math&amp;gt;\gamma_1=10&amp;lt;/math&amp;gt; is a solution as expected. As &amp;lt;math&amp;gt;n=1018&amp;lt;/math&amp;gt; is not prime, there is another solution &amp;lt;math&amp;gt;\gamma_2=519&amp;lt;/math&amp;gt;, for which &amp;lt;math&amp;gt;2^{519} = 1014 = -5\pmod{1019}&amp;lt;/math&amp;gt; holds.&lt;br /&gt;
&lt;br /&gt;
==Complexity==&lt;br /&gt;
The running time is approximately O(&amp;lt;math&amp;gt;\sqrt{p}&amp;lt;/math&amp;gt;) where p is n&#039;s largest prime factor.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
*{{cite journal |first=J. M. |last=Pollard |title=Monte Carlo methods for index computation (mod &#039;&#039;p&#039;&#039;) |journal=[[Mathematics of Computation]] |volume=32 |year=1978 |issue=143 |pages=918–924 |doi= |jstor=2006496 }}&lt;br /&gt;
*{{cite book |first=Alfred J. |last=Menezes |first2=Paul C. |last2=van Oorschot |first3=Scott A. |last3=Vanstone |chapterurl=http://www.cacr.math.uwaterloo.ca/hac/about/chap3.pdf |title=Handbook of Applied Cryptography |chapter=Chapter 3 |year=2001 |location= |publisher= |isbn= }}&lt;br /&gt;
&lt;br /&gt;
{{Number-theoretic algorithms}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Logarithms]]&lt;br /&gt;
[[Category:Number theoretic algorithms]]&lt;/div&gt;</summary>
		<author><name>117.196.82.75</name></author>
	</entry>
</feed>