Cheat Sheet of SSE/AVX Intrinsics, for Doing Arithmetic Ll F(Int Ind, Int K) { Return Dp[Ind][K]; } on Several Numbers at Once

Total Page:16

File Type:pdf, Size:1020Kb

Cheat Sheet of SSE/AVX Intrinsics, for Doing Arithmetic Ll F(Int Ind, Int K) { Return Dp[Ind][K]; } on Several Numbers at Once University of Bergen Garbage Collectors Davide Pallotti, Jan Soukup, Olav Røthe Bakken NWERC 2017 Nov 8, 2017 UiB template .bashrc .vimrc troubleshoot 1 tan v + tan w Contest (1) Any possible infinite recursion? tan(v + w) = Invalidated pointers or iterators? 1 − tan v tan w template.cpp Are you using too much memory? v + w v − w 15 lines Debug with resubmits (e.g. remapped signals, see Various). sin v + sin w = 2 sin cos #include <bits/stdc++.h> 2 2 using namespace std; Time limit exceeded: v + w v − w Do you have any possible infinite loops? cos v + cos w = 2 cos cos #define rep(i, a, b) for(int i = a; i < (b); ++i) What is the complexity of your algorithm? 2 2 #define trav(a, x) for(auto& a : x) Are you copying a lot of unnecessary data? (References) #define all(x) x.begin(), x.end() How big is the input and output? (consider scanf) (V + W ) tan(v − w)=2 = (V − W ) tan(v + w)=2 #define sz(x) (int)(x).size() Avoid vector, map. (use arrays/unordered_map) typedef long long ll; What do your team mates think about your algorithm? where V; W are lengths of sides opposite angles v; w. typedef pair<int, int> pii; typedef vector<int> vi; Memory limit exceeded: a cos x + b sin x = r cos(x − φ) What is the max amount of memory your algorithm should need? int main() { Are you clearing all datastructures between test cases? a sin x + b cos x = r sin(x + φ) cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); p 2 2 } Mathematics (2) where r = a + b ; φ = atan2(b; a). .bashrc 3 lines 2.1 Equations 2.4 Geometry alias c=’g++ -Wall -Wconversion -Wfatal-errors -g -std=c++14 \ p -fsanitize=undefined,address’ 2 2.4.1 Triangles 2 −b ± b − 4ac xmodmap -e ’clear lock’ -e ’keycode 66=less greater’ #caps = <> ax + bx + c = 0 ) x = 2a Side lengths: a; b; c .vimrc a + b + c 2 lines The extremum is given by x = −b=2a. Semiperimeter: p = set cin aw ai is ts=4 sw=4 tm=50 nu noeb bg=dark ru cul 2 sy on | im jk <esc> | im kj <esc> | no ; : Area: A = pp(p − a)(p − b)(p − c) ed − bf abc troubleshoot.txt x = Circumradius: R = 52 lines ax + by = e ad − bc ) 4A Pre-submit: cx + dy = f af − ec A Write a few simple test cases, if sample is not enough. y = Inradius: r = Are time limits close? If so, generate max cases. ad − bc p Is the memory usage fine? Length of median (dividesp triangle into two equal-area Could anything overflow? In general, given an equation Ax = b, the solution to a 1 2 2 2 Make sure to submit the right file. triangles): ma = 2 2b + 2c − a variable xi is given by Length of bisector (divides angles in two): Wrong answer: v Print your solution! Print debug output, as well. 0 u " 2# det Ai a Are you clearing all datastructures between test cases? x = u i sa = tbc 1 − Can your algorithm handle the whole range of input? det A b + c Read the full problem statement again. 0 Do you handle all corner cases correctly? where Ai is A with the i'th column replaced by b. sin α sin β sin γ 1 Have you understood the problem correctly? Law of sines: = = = Any uninitialized variables? a b c 2R 2.2 Recurrences 2 2 2 Any overflows? Law of cosines: a = b + c − 2bc cos α Confusing N and M, i and j, etc.? α + β Are you sure your algorithm works? If an = c1an−1 + ··· + ckan−k, and r1; : : : ; rk are distinct a + b tan What special cases have you not thought of? roots of xk + c xk−1 + ··· + c , there are d ; : : : ; d s.t. Law of tangents: = 2 Are you sure the STL functions you use work as you think? 1 k 1 k a − b α − β Add some assertions, maybe resubmit. n n tan Create some testcases to run your algorithm on. an = d1r1 + ··· + dkrk : 2 Go through the algorithm for a simple case. Go through this list again. Non-distinct roots r become polynomial factors, e.g. 2.4.2 Quadrilaterals Explain your algorithm to a team mate. n Ask the team mate to look at your code. an = (d1n + d2)r . Go for a small walk, e.g. to the toilet. With side lengths a; b; c; d, diagonals e; f, diagonals angle θ, Is your output format correct? (including whitespace) area A and magic flux F = b2 + d2 − a2 − c2: Rewrite your solution from the start or let a team mate do it. 2.3 Trigonometry Runtime error: p 2 2 2 Have you tested all corner cases locally? sin(v + w) = sin v cos w + cos v sin w 4A = 2ef · sin θ = F tan θ = 4e f − F Any uninitialized variables? cos(v + w) = cos v cos w − sin v sin w Are you reading or writing outside the range of any vector? For cyclic quadrilaterals the sum of opposite angles is 180◦, Any assertions that might fail? p Any possible division by 0? (mod 0 for example) ef = ac + bd, and A = (p − a)(p − b)(p − c)(p − d). UiB 2 2.4.3 Spherical coordinates 2.7 Series First success distribution z x2 x3 ex = 1 + x + + + :::; (−∞ < x < 1) The number of trials needed to get the first success in r 2! 3! y independent yes/no experiments, each wich yields success x2 x3 x4 with probability p is Fs(p); 0 ≤ p ≤ 1. ln(1 + x) = x − + − + :::; (−1 < x ≤ 1) 2 3 4 x p(k) = p(1 − p)k−1; k = 1; 2;::: p x x2 2x3 5x4 1 + x = 1 + − + − + :::; (−1 ≤ x ≤ 1) 2 8 32 128 1 1 − p p µ = ; σ2 = x = r sin θ cos φ r = x2 + y2 + z2 2 x3 x5 x7 p p y = r sin θ sin φ θ = acos(z=px2 + y2 + z2) sin x = x − + − + :::; (−∞ < x < 1) 3! 5! 7! z = r cos θ φ = atan2(y; x) Poisson distribution x2 x4 x6 cos x = 1 − + − + :::; (−∞ < x < 1) 2.5 Derivatives/Integrals 2! 4! 6! The number of events occurring in a fixed period of time t if these events occur with a known average rate κ and 2.8 Probability theory independently of the time since the last event is d 1 d 1 arcsin x = p arccos x = −p Let X be a discrete random variable with probability p (x) Po(λ); λ = tκ. dx 1 − x2 dx 1 − x2 X of assuming the value x. It will then have an expected value k d 2 d 1 P −λ λ tan x = 1 + tan x arctan x = (mean) µ = E(X) = x xpX (x) and variance p(k) = e ; k = 0; 1; 2;::: dx dx 1 + x2 2 2 2 P 2 k! σ = V (X) = E(X ) − (E(X)) = (x − E(X)) pX (x) Z ln j cos axj Z sin ax − ax cos ax x tan ax = − x sin ax = where σ is the standard deviation. If X is instead 2 2 µ = λ, σ = λ a a continuous it will have a probability density function fX (x) p ax Z 2 π Z e and the sums above will instead be integrals with p (x) e−x = erf(x) xeaxdx = (ax − 1) X 2 a2 replaced by fX (x). 2.8.2 Continuous distributions Expectation is linear: Uniform distribution Integration by parts: E(aX + bY ) = aE(X) + bE(Y ) If the probability density function is constant between a and Z b Z b b 0 b and 0 elsewhere it is U(a; b); a < b. f(x)g(x)dx = [F (x)g(x)]a − F (x)g (x)dx For independent X and Y , a a 1 a < x < b V (aX + bY ) = a2V (X) + b2V (Y ): f(x) = b−a 2.6 Sums 0 otherwise b+1 a 2 a a+1 b c − c 2.8.1 Discrete distributions a + b (b − a) c + c + ··· + c = ; c 6= 1 µ = ; σ2 = c − 1 Binomial distribution 2 12 n(n + 1) The number of successes in n independent yes/no Exponential distribution 1 + 2 + 3 + ··· + n = 2 experiments, each which yields success with probability p is n(2n + 1)(n + 1) Bin(n; p); n = 1; 2;:::; 0 ≤ p ≤ 1. The time between events in a Poisson process is 12 + 22 + 32 + ··· + n2 = Exp(λ); λ > 0. 6 n n2(n + 1)2 p(k) = pk(1 − p)n−k 13 + 23 + 33 + ··· + n3 = λe−λx x ≥ 0 k f(x) = 4 0 x < 0 n(n + 1)(2n + 1)(3n2 + 3n − 1) 14 + 24 + 34 + ··· + n4 = µ = np; σ2 = np(1 − p) 30 1 1 µ = ; σ2 = Bin(n; p) is approximately Po(np) for small p. λ λ2 UiB OrderStatisticTree SegmentTree LazySegmentTree UnionFind SubMatrix 3 Normal distribution OrderStatisticTree.h struct Node { Description: A set (not multiset!) with support for finding the n'th ele- Node *l = 0, *r = 0; ment, and finding the index of an element. int lo, hi, mset = inf, madd = 0, val = -inf; 2 Time: O (log N) Node(int lo,int hi):lo(lo),hi(hi){} // Large interval of −inf Most real random values with mean µ and variance σ are 16 lines 2 Node(vi& v, int lo, int hi) : lo(lo), hi(hi) { well described by N (µ, σ ); σ > 0.
Recommended publications
  • On Terms of Generalized Fibonacci Sequences Which Are Powers of Their Indexes
    mathematics Article On Terms of Generalized Fibonacci Sequences which are Powers of their Indexes Pavel Trojovský Department of Mathematics, Faculty of Science, University of Hradec Králové, 500 03 Hradec Králové, Czech Republic, [email protected]; Tel.: +42-049-333-2860 Received: 29 June 2019; Accepted: 31 July 2019; Published: 3 August 2019 (k) Abstract: The k-generalized Fibonacci sequence (Fn )n (sometimes also called k-bonacci or k-step Fibonacci sequence), with k ≥ 2, is defined by the values 0, 0, ... , 0, 1 of starting k its terms and such way that each term afterwards is the sum of the k preceding terms. This paper is devoted to the proof of the fact that the (k) t (2) 2 (3) 2 Diophantine equation Fm = m , with t > 1 and m > k + 1, has only solutions F12 = 12 and F9 = 9 . Keywords: k-generalized Fibonacci sequence; Diophantine equation; linear form in logarithms; continued fraction MSC: Primary 11J86; Secondary 11B39. 1. Introduction The well-known Fibonacci sequence (Fn)n≥0 is given by the following recurrence of the second order Fn+2 = Fn+1 + Fn, for n ≥ 0, with the initial terms F0 = 0 and F1 = 1. Fibonacci numbers have a lot of very interesting properties (see e.g., book of Koshy [1]). One of the famous classical problems, which has attracted a attention of many mathematicians during the last thirty years of the twenty century, was the problem of finding perfect powers in the sequence of Fibonacci numbers. Finally in 2006 Bugeaud et al. [2] (Theorem 1), confirmed these expectations, as they showed that 0, 1, 8 and 144 are the only perfect powers in the sequence of Fibonacci numbers.
    [Show full text]
  • Number Systems and Radix Conversion
    Number Systems and Radix Conversion Sanjay Rajopadhye, Colorado State University 1 Introduction These notes for CS 270 describe polynomial number systems. The material is not in the textbook, but will be required for PA1. We humans are comfortable with numbers in the decimal system where each po- sition has a weight which is a power of 10: units have a weight of 1 (100), ten’s have 10 (101), etc. Even the fractional apart after the decimal point have a weight that is a (negative) power of ten. So the number 143.25 has a value that is 1 ∗ 102 + 4 ∗ 101 + 3 ∗ 0 −1 −2 2 5 10 + 2 ∗ 10 + 5 ∗ 10 , i.e., 100 + 40 + 3 + 10 + 100 . You can think of this as a polyno- mial with coefficients 1, 4, 3, 2, and 5 (i.e., the polynomial 1x2 + 4x + 3 + 2x−1 + 5x−2+ evaluated at x = 10. There is nothing special about 10 (just that humans evolved with ten fingers). We can use any radix, r, and write a number system with digits that range from 0 to r − 1. If our radix is larger than 10, we will need to invent “new digits”. We will use the letters of the alphabet: the digit A represents 10, B is 11, K is 20, etc. 2 What is the value of a radix-r number? Mathematically, a sequence of digits (the dot to the right of d0 is called the radix point rather than the decimal point), : : : d2d1d0:d−1d−2 ::: represents a number x defined as follows X i x = dir i 2 1 0 −1 −2 = ::: + d2r + d1r + d0r + d−1r + d−2r + ::: 1 Example What is 3 in radix 3? Answer: 0.1.
    [Show full text]
  • Composite Numbers That Give Valid RSA Key Pairs for Any Coprime P
    information Article Composite Numbers That Give Valid RSA Key Pairs for Any Coprime p Barry Fagin ID Department of Computer Science, US Air Force Academy, Colorado Springs, CO 80840, USA; [email protected]; Tel.: +1-719-339-4514 Received: 13 August 2018; Accepted: 25 August 2018; Published: 28 August 2018 Abstract: RSA key pairs are normally generated from two large primes p and q. We consider what happens if they are generated from two integers s and r, where r is prime, but unbeknownst to the user, s is not. Under most circumstances, the correctness of encryption and decryption depends on the choice of the public and private exponents e and d. In some cases, specific (s, r) pairs can be found for which encryption and decryption will be correct for any (e, d) exponent pair. Certain s exist, however, for which encryption and decryption are correct for any odd prime r - s. We give necessary and sufficient conditions for s with this property. Keywords: cryptography; abstract algebra; RSA; computer science education; cryptography education MSC: [2010] 11Axx 11T71 1. Notation and Background Consider the RSA public-key cryptosystem and its operations of encryption and decryption [1]. Let (p, q) be primes, n = p ∗ q, f(n) = (p − 1)(q − 1) denote Euler’s totient function and (e, d) the ∗ Z encryption/decryption exponent pair chosen such that ed ≡ 1. Let n = Un be the group of units f(n) Z mod n, and let a 2 Un. Encryption and decryption operations are given by: (ae)d ≡ (aed) ≡ (a1) ≡ a mod n We consider the case of RSA encryption and decryption where at least one of (p, q) is a composite number s.
    [Show full text]
  • Arxiv:1608.06086V1 [Math.NT]
    POWER OF TWO AS SUMS OF THREE PELL NUMBERS JHON J. BRAVO, BERNADETTE FAYE AND FLORIAN LUCA Abstract. In this paper, we find all the solutions of the Diophantine equation a Pℓ +Pm +Pn =2 , in nonnegative integer variables (n,m,ℓ,a) where Pk is the k-th term of the Pell sequence Pn n≥0 given by P0 = 0, P1 = 1 and Pn+1 =2Pn+Pn−1 for all n 1. { } ≥ MSC: 11D45, 11B39; 11A25 Keywords: Diophantine equations, Pell numbers, Linear forms in logarithm, reduction method. 1. Introduction The Pell sequence P is the binary reccurent sequence given by P = 0, P =1 { n}n≥0 0 1 and Pn+1 = 2Pn + Pn−1 for all n 0. There are many papers in the literature dealing with Diophantine equations≥ obtained by asking that members of some fixed binary recurrence sequence be squares, factorials, triangular, or belonging to some other interesting sequence of positive integers. For example, in 2008, A. Peth˝o[18] found all the perfect powers (of exponent larger than 1) in the Pell sequence. His result is the following. Theorem 1 (A. Peth˝o, [18]). The only positive integer solutions (n, q, x) with q 2 of the Diophantine equation ≥ q Pn = x are (n, q, x) = (1, q, 1) and (7, 2, 13). That is, the only perfect powers of exponent larger than 1 in the Pell numbers are 2 P1 =1 and P7 = 13 . The case q = 2 had been treated earlier by Ljunggren [13]. Peth˝o’s result was rediscovered by J. H.
    [Show full text]
  • Rapid Multiplication Modulo the Sum and Difference of Highly Composite Numbers
    MATHEMATICS OF COMPUTATION Volume 72, Number 241, Pages 387{395 S 0025-5718(02)01419-9 Article electronically published on March 5, 2002 RAPID MULTIPLICATION MODULO THE SUM AND DIFFERENCE OF HIGHLY COMPOSITE NUMBERS COLIN PERCIVAL Abstract. We extend the work of Richard Crandall et al. to demonstrate how the Discrete Weighted Transform (DWT) can be applied to speed up multiplication modulo any number of the form a b where p is small. In ± p ab particular this allows rapid computation modulo numbers of thej form k 2n 1. Q · ± In addition, we prove tight bounds on the rounding errors which naturally occur in floating-point implementations of FFT and DWT multiplications. This makes it possible for FFT multiplications to be used in situations where correctness is essential, for example in computer algebra packages. 1. Introduction In their seminal paper of 1994, Richard Crandall and Barry Fagin introduced the Discrete Weighted Transform (DWT) as a means of eliminating zero-padding when performing integer multiplication modulo Mersenne numbers [2]. While this does not give any improvement in the order of the multiplication, it nevertheless cuts the transform length (and thus time and memory) in half. For these reasons the DWT has become a fixture of the search for Mersenne primes [10]. By using the same form of irrational-base representation as is used for Mersenne numbers, we can in fact eliminate the zero-padding when working modulo a b ± provided that p ab p is sufficiently small that we have enough precision. Essen- tially, as with Mersennej numbers, we choose the base so that the reduction modulo xn 1 implicitQ in the FFT multiplication turns into a reduction modulo a b.
    [Show full text]
  • A Diophantine Equation in K–Generalized Fibonacci Numbers and Repdigits
    A Diophantine equation in k{generalized Fibonacci numbers and repdigits Jhon J. Bravo Departamento de Matem´aticas Universidad del Cauca Calle 5 No 4{70, Popay´an,Colombia E-mail: [email protected] Carlos Alexis G´omezRuiz Departamento de Matem´aticas Universidad del Valle 25360 Calle 13 No 100-00, Cali, Colombia E-mail: [email protected] Florian Luca School of Mathematics University of the Witwatersrand Private Bag X3 Wits 2050 Johannesburg, South Africa Max Planck Institute for Mathematics Vivatsgasse 7 53111 Bonn, Germany Department of Mathematics Faculty of Sciences University of Ostrava 30 Dubna 22 701 03 Ostrava 1, Czech Republic E-mail: [email protected] Abstract 2010 Mathematics Subject Classification: 11B39; 11J86. Key words and phrases: Generalized Fibonacci numbers, lower bounds for nonzero linear forms in logarithms of algebraic numbers, repdigits. 1 2 J. J. Bravo, C. A. G´omezand F. Luca (k) The k−generalized Fibonacci sequence fFn gn starts with the value 0;:::; 0; 1 (a total of k terms) and each term afterwards is the sum of the k preceding terms. In the present paper, we study on members of k{generalized Fibonacci sequence which are sum of two repdigts, extending a result of D´ıazand Luca [5] regarding Fibonacci numbers with the above property. 1 Introduction Given an integer k ≥ 2, we consider the k{generalized Fibonacci sequence (k) (k) or, for simplicity, the k{Fibonacci sequence F := fFn gn≥2−k given by the recurrence (k) (k) (k) (k) (1.1) Fn = Fn−1 + Fn−2 + ··· + Fn−k for all n ≥ 2; (k) (k) (k) (k) with the initial conditions F−(k−2) = F−(k−3) = ··· = F0 = 0 and F1 = 1.
    [Show full text]
  • Arxiv:2008.10398V1 [Math.NT] 24 Aug 2020 Children He Has
    JOURNAL OF THE AMERICAN MATHEMATICAL SOCIETY Volume 00, Number 0, Pages 000{000 S 0894-0347(XX)0000-0 RECURSIVELY ABUNDANT AND RECURSIVELY PERFECT NUMBERS THOMAS FINK London Institute for Mathematical Sciences, 35a South St, London W1K 2XF, UK Centre National de la Recherche Scientifique, Paris, France The divisor function σ(n) sums the divisors of n. We call n abundant when σ(n) − n > n and perfect when σ(n) − n = n. I recently introduced the recursive divisor function a(n), the recursive analog of the divisor function. It measures the extent to which a number is highly divisible into parts, such that the parts are highly divisible into subparts, so on. Just as the divisor function motivates the abundant and perfect numbers, the recursive divisor function motivates their recursive analogs, which I introduce here. A number is recursively abundant, or ample, if a(n) > n and recursively perfect, or pristine, if a(n) = n. There are striking parallels between abundant and perfect numbers and their recursive counterparts. The product of two ample numbers is ample, and ample numbers are either abundant or odd perfect numbers. Odd ample numbers exist but are rare, and I conjecture that there are such numbers not divisible by the first k primes|which is known to be true for the abundant numbers. There are infinitely many pristine numbers, but that they cannot be odd, apart from 1. Pristine numbers are the product of a power of two and odd prime solutions to certain Diophantine equations, reminiscent of how perfect numbers are the product of a power of two and a Mersenne prime.
    [Show full text]
  • Integer Sequences
    UHX6PF65ITVK Book > Integer sequences Integer sequences Filesize: 5.04 MB Reviews A very wonderful book with lucid and perfect answers. It is probably the most incredible book i have study. Its been designed in an exceptionally simple way and is particularly just after i finished reading through this publication by which in fact transformed me, alter the way in my opinion. (Macey Schneider) DISCLAIMER | DMCA 4VUBA9SJ1UP6 PDF > Integer sequences INTEGER SEQUENCES Reference Series Books LLC Dez 2011, 2011. Taschenbuch. Book Condition: Neu. 247x192x7 mm. This item is printed on demand - Print on Demand Neuware - Source: Wikipedia. Pages: 141. Chapters: Prime number, Factorial, Binomial coeicient, Perfect number, Carmichael number, Integer sequence, Mersenne prime, Bernoulli number, Euler numbers, Fermat number, Square-free integer, Amicable number, Stirling number, Partition, Lah number, Super-Poulet number, Arithmetic progression, Derangement, Composite number, On-Line Encyclopedia of Integer Sequences, Catalan number, Pell number, Power of two, Sylvester's sequence, Regular number, Polite number, Ménage problem, Greedy algorithm for Egyptian fractions, Practical number, Bell number, Dedekind number, Hofstadter sequence, Beatty sequence, Hyperperfect number, Elliptic divisibility sequence, Powerful number, Znám's problem, Eulerian number, Singly and doubly even, Highly composite number, Strict weak ordering, Calkin Wilf tree, Lucas sequence, Padovan sequence, Triangular number, Squared triangular number, Figurate number, Cube, Square triangular
    [Show full text]
  • Fermat Pseudoprimes
    1 TWO HUNDRED CONJECTURES AND ONE HUNDRED AND FIFTY OPEN PROBLEMS ON FERMAT PSEUDOPRIMES (COLLECTED PAPERS) Education Publishing 2013 Copyright 2013 by Marius Coman Education Publishing 1313 Chesapeake Avenue Columbus, Ohio 43212 USA Tel. (614) 485-0721 Peer-Reviewers: Dr. A. A. Salama, Faculty of Science, Port Said University, Egypt. Said Broumi, Univ. of Hassan II Mohammedia, Casablanca, Morocco. Pabitra Kumar Maji, Math Department, K. N. University, WB, India. S. A. Albolwi, King Abdulaziz Univ., Jeddah, Saudi Arabia. Mohamed Eisa, Dept. of Computer Science, Port Said Univ., Egypt. EAN: 9781599732572 ISBN: 978-1-59973-257-2 1 INTRODUCTION Prime numbers have always fascinated mankind. For mathematicians, they are a kind of “black sheep” of the family of integers by their constant refusal to let themselves to be disciplined, ordered and understood. However, we have at hand a powerful tool, insufficiently investigated yet, which can help us in understanding them: Fermat pseudoprimes. It was a night of Easter, many years ago, when I rediscovered Fermat’s "little" theorem. Excited, I found the first few Fermat absolute pseudoprimes (561, 1105, 1729, 2465, 2821, 6601, 8911…) before I found out that these numbers are already known. Since then, the passion for study these numbers constantly accompanied me. Exceptions to the above mentioned theorem, Fermat pseudoprimes seem to be more malleable than prime numbers, more willing to let themselves to be ordered than them, and their depth study will shed light on many properties of the primes, because it seems natural to look for the rule studying it’s exceptions, as a virologist search for a cure for a virus studying the organisms that have immunity to the virus.
    [Show full text]
  • Algorithms for Computing Fibonacci Numbers Quickly Redacted for Privacy Abstract Approved: Paul Cull
    AN ABSTRACT OF THE THESIS OF James L. Holloway for the degree of Master of Science in Computer Science presented on May 10, 1988. Title: Algorithms for Computing Fibonacci Numbers Quickly Redacted for Privacy Abstract approved:_ Paul Cull. A study of the running time of several known algorithms and several new algorithms to compute the nth element of the Fibonacci sequence is presented. Since the size of the nth Fibonacci number grows exponentially with n, the number of bit operations, instead of the number of integer operations, was used as the unit of time. The number of bit operations used to compute fn is reduced to less than a of the number of bit operations used to multiply two n bit numbers. The algorithms were programmed in Ibuki Common Lisp and timing runs were made on a Sequent Balance 21000. Multiplication was implemented using the standard n2 algorithm. Times for the various algorithms are reported as various constants times n2. An algorithm based on generating factors of Fibonacci numbers had the smallest constant. The Fibonacci sequence, arranged in various ways, is searched for redundant information that could be eliminated to reduce the number of operations. Cycles in the M' bit of fn were discovered but are not yet completely understood. Algorithms for Computing Fibonacci Numbers Quickly By J. L. Holloway A Thesis submitted to Oregon State University in partial fulfillment of the requirements for the degree of Master of Science Completed June 2, 1988 Commencement June 1989. Approved: Redacted for Privacy Professor of Computer Science in charge of major Redacted for Privacy Head of Department of Computer Science Redacted for Privacy Dean of Gradu chool 4 Date thesis presented May 10, 1988 ACKNOWLEDGEMENTS I wish to thank: Dr.
    [Show full text]
  • Number Theory
    Number Theory Naoki Sato <[email protected]> 0 Preface This set of notes on number theory was originally written in 1995 for students at the IMO level. It covers the basic background material that an IMO student should be familiar with. This text is meant to be a reference, and not a replacement but rather a supplement to a number theory textbook; several are given at the back. Proofs are given when appropriate, or when they illustrate some insight or important idea. The problems are culled from various sources, many from actual contests and olympiads, and in general are very difficult. The author welcomes any corrections or suggestions. 1 Divisibility For integers a and b, we say that a divides b, or that a is a divisor (or factor) of b, or that b is a multiple of a, if there exists an integer c such that b = ca, and we denote this by a | b. Otherwise, a does not divide b, and we denote this by a - b. A positive integer p is a prime if the only divisors of p are 1 and p. If pk | a and pk+1 - a where p is a prime, i.e. pk is the highest power of p dividing a, then we denote this by pkka. Useful Facts • If a, b > 0, and a | b, then a ≤ b. • If a | b1, a | b2,..., a | bn, then for any integers c1, c2,..., cn, n X a | bici. i=1 Theorem 1.1. The Division Algorithm. For any positive integer a and integer b, there exist unique integers q and r such that b = qa + r and 0 ≤ r < a, with r = 0 iff a | b.
    [Show full text]
  • And Polignac's Conjecture
    ON POWERS ASSOCIATED WITH SIERPINSKI´ NUMBERS,RIESEL NUMBERS AND POLIGNAC’S CONJECTURE Michael Filaseta Carrie Finch Mathematics Department Mathematics Department University of South Carolina University of South Carolina Columbia, SC 29208 Columbia, SC 29208 Mark Kozek Mathematics Department University of South Carolina Columbia, SC 29208 Abstract We address conjectures of P. Erdos˝ and conjectures of Y.-G. Chen concerning the numbers in the title. We obtain a variety of related results, including a new smallest positive integer that is simultaneously a Sierpinski´ number and a Riesel number and a proof that for every positive integer r, there is an integer k such that the numbers k, k2, k3, . , kr are simultaneously Sierpinski´ numbers. 1 Introduction and Preliminaries A Sierpinski´ number is a positive odd integer k with the property that k · 2n + 1 is composite for all positive integers n. A Riesel number is a positive odd integer k with the property that k · 2n − 1 is composite for all positive integers n. In 1849, A. de Polignac [6] conjectured that every positive odd integer k can be written as a sum of a prime and a power of two. It is well known that Polignac’s conjecture is not true. What has become of interest here are positive odd integers k for which |k − 2n| is composite for all positive integers n. In this paper, we extend previous investigations involving k with one of these properties that are also an rth power for some r > 1. We also address situations where such conditions on k can simultaneously hold. We begin with some background.
    [Show full text]