The Cantor Set a Perfect, Uncountable Set with No Segments Or a Perfect Example of All That Is Wrong with Cantor’S Infinite Set Theory

Total Page:16

File Type:pdf, Size:1020Kb

The Cantor Set a Perfect, Uncountable Set with No Segments Or a Perfect Example of All That Is Wrong with Cantor’S Infinite Set Theory The Cantor Set A Perfect, Uncountable Set with no Segments or A Perfect Example of all that is Wrong with Cantor’s Infinite Set Theory Pravin K. Johri The first course in Real Analysis or Analysis is shocking to most students. Mathematics is suddenly counterintuitive and so difficult to comprehend. The course steadily becomes more and more bizarre. Then, towards the end, the student encounters the Cantor set. So far, infinite sets existed and had nonintuitive properties. Now, one can be constructed using an infinite, never- ending procedure of subdividing the unit interval. It involves infinite sequences which previously could not reach their limits but now do, somehow. Mathematics does not specify what changed to allow such a radically different outcome. The subintervals have some characteristics the Cantor set inherits and some it doesn’t without a clear explanation why. There are other unreal properties which are often assigned as homework and one can waste entire weekends trying to make sense of it all. It is an apt culmination of the course. The Cantor set embodies everything that is wrong with Cantor’s infinite set theory starting from the initial assumptions of an actual infinity and of infinite sets. Both are simply accepted to be true in mathematics, a pure science, and cannot be disproven as there is no proof to start. The only way to show that the theory is totally unfounded is to create one inconsistency after another. And Cantor’s theory is full of contradictions. There is an entire Wikipedia page devoted to it. 1 The Cantor Set Consider subsets of the unit interval [0, 1]: A1 = [0, 1/3] U [2/3, 1] A2 = [0, 1/9] U [2/9, 3/9] U [6/9, 7/9] U [8/9, 1] And so on. ∞ Then C = ⋂푛=1 퐴푛 is the ternary Cantor set. n -n An is made up of 2 intervals each of length 3 and yet the Cantor set contains no segments. The first step removes a segment of length 1/3, the second a segment of length 2/9, and so on. The total length removed is 1/3 + 2/9 + 4/27 + … = 1. The entire length of the unit interval is excised and yet the Cantor set contains uncountable points. Excerpts from the Wikipedia page “Cantor Set” However, a closer look at the process reveals that there must be something left, since removing the "middle third" of each interval involved removing open sets (sets that do not include their endpoints). So removing the line segment (1/3, 2/3) from the original interval [0, 1] leaves behind the points 1/3 and 2/3. Subsequent steps do not remove these (or other) endpoints, since the intervals removed are always internal to the intervals remaining. So the Cantor set is not empty, and in fact contains an uncountably infinite number of points. It may appear that only the endpoints are left, but that is not the case either. The number 1/4, for example, is in the bottom third, so it is not removed at the first step, and is in the top third of the bottom third, and is in the bottom third of that, and in the top third of that, and so on ad infinitum - alternating between top and bottom thirds. Since it is never in one of the middle thirds, it is never removed, and yet it is also not one of the endpoints of any middle third. The number 3/10 is also in the Cantor set and is not an endpoint. … there are as many points in the Cantor set as there are in [0, 1], and the Cantor set is uncountable … However, the set of endpoints of the removed intervals is countable, so there must be uncountably many numbers in the Cantor set which are not interval endpoints. It can be shown that there are as many points left behind in this process as there were to begin with, and that therefore, the Cantor set is uncountable. 2 Excerpts from the Wikipedia page “Cantor Set” To see this, we show that there is a function f from the Cantor set C to the closed interval [0, 1] that is surjective (i.e. f maps from C onto [0, 1]) so that the cardinality of C is no less than that of [0, 1]. … For a number not to be excluded at step n, it must have a ternary representation whose nth digit is not 1. For a number to be in the Cantor set, it must not be excluded at any step, it must admit a numeral representation consisting entirely of 0s and 2s. … The function f from C to [0, 1] is defined by taking the numeral that does consist entirely of 0s and 2s, replacing all the 2s by 1s, and interpreting the sequence as a binary representation of a real number. The Cantor set is also a perfect set in that no point in it is an isolated point. These properties are truly unbelievable - in that they should not be believed. Ironically, the Cantor set is a perfect illustration of everything that is wrong in Cantor’s infinite set theory. Inconsistency 1: Is this a valid procedure? The first issue is whether the Cantor set can be formed in the way it is described. The sequence of natural numbers 1, 2, 3 … is endless. The process of forming the subsets An should go on forever. But it terminates and produces a set without a clear description of how the ending comes about. For segments to disappear the length of the segments, 3-n, must shrink to zero. At the same time, there is no minimum value of a real number and the number 1 cannot be reduced to 0 by repeatedly dividing it by 3. A clear, precise description is required of what happens when sequences are used within sets to diametrically change their behavior. The way numbers are defined there is an undefined gap or middle (see Appendix D). Some infinite procedures in mathematics are allowed to jump the gap, others are not. No procedure in a pure science should be based on simply the “acceptance” that completion occurs (see Appendix B), and that it can be arbitrarily applied to some situations but not to others. 3 Inconsistency 2: The undefined ultimate step (completion) The Cantor set procedure creates sequences of nested closed intervals. In = [an, bn], n N, are nested closed intervals if I1 I2 I3 … Nested Closed Interval Theorem: ∞ If |In| → 0 as n → , then T = ⋂푛=1 I푛 contains exactly one number. The sequence of nested intervals is characterized by two sequences {an} and {bn} with an bn for all n N. Hence, an a b bn and T = [a, b]. Further, T = [a, b] = a = b if |In| → 0. This theorem violates the Field axioms! A positive quantity cannot ever reduce to zero through division. There is no minimum value of a real number, a direct consequence of the field axiom mandating a unique multiplicative inverse, and 3-n cannot shrink to 0 no matter how large n becomes. For example, the first interval in each step of the Cantor set procedure has the form [0, 3-n] which becomes progressively smaller as n increases. Each and every one of these nested intervals has positive length and contains uncountable real numbers. Yet, somehow, the ∞ −푛 infinite intersection ⋂푛=1[0, 3 ] of the very same intervals no longer has this property. If the non-degenerate nested intervals [0, 3-n] shrink to a single point then there must be some, as yet, undefined ultimate step that takes uncountable points (a higher order of infinity than ℵ0) down to a single point at one fell swoop. This concept is called completion of infinite entities and mathematicians just accept that it happens (see Appendix B) for some entities (intersection of nested intervals) but not others (sequences such as {3-n}). If such an important notion is just based on faith then mathematics is no different than a religion. The onus is on mathematics to precisely define how it happens, in accordance with its core principles (see Appendix A) and remove the inconsistency in how it is applied. 4 Inconsistency 3: The use of finite logic The conclusions regarding the Cantor set rely on finite logic. Many claims are made that are clearly true when the index n is finite. It is claimed that the endpoints of all remaining intervals in any step of the Cantor set procedure are left behind in the Cantor set because they are not excised in any finite step of the procedure. But these endpoints are all rational numbers and are countable. An additional claim is made that interior points of intervals are also left behind because interior points such as 1/4 and 3/10 are not removed in a finite number of steps. Almost all members of the Cantor set must be interior points and also irrational numbers, or it cannot be uncountable. In direct contrast, every step has intervals but none remain at the end. The sequences characterizing the intervals and their limits need not have consistent properties. The sequence {3-n} has all positive terms but its limit 0 is not positive. Finite logic does not necessarily extend to the limiting values! A convergent infinite sequence like {1/n} can come arbitrarily close to its limit 0 but not quite reach it. However, the infinite intersection of the nested closed intervals defined by the same ∞ sequence and its negative equivalent, ⋂푛=1 [-1/n, 1/n] reaches the single limiting value 0, which is an interior point of all intervals in the procedure.
Recommended publications
  • Classifying Material Implications Over Minimal Logic
    Classifying Material Implications over Minimal Logic Hannes Diener and Maarten McKubre-Jordens March 28, 2018 Abstract The so-called paradoxes of material implication have motivated the development of many non- classical logics over the years [2–5, 11]. In this note, we investigate some of these paradoxes and classify them, over minimal logic. We provide proofs of equivalence and semantic models separating the paradoxes where appropriate. A number of equivalent groups arise, all of which collapse with unrestricted use of double negation elimination. Interestingly, the principle ex falso quodlibet, and several weaker principles, turn out to be distinguishable, giving perhaps supporting motivation for adopting minimal logic as the ambient logic for reasoning in the possible presence of inconsistency. Keywords: reverse mathematics; minimal logic; ex falso quodlibet; implication; paraconsistent logic; Peirce’s principle. 1 Introduction The project of constructive reverse mathematics [6] has given rise to a wide literature where various the- orems of mathematics and principles of logic have been classified over intuitionistic logic. What is less well-known is that the subtle difference that arises when the principle of explosion, ex falso quodlibet, is dropped from intuitionistic logic (thus giving (Johansson’s) minimal logic) enables the distinction of many more principles. The focus of the present paper are a range of principles known collectively (but not exhaustively) as the paradoxes of material implication; paradoxes because they illustrate that the usual interpretation of formal statements of the form “. → . .” as informal statements of the form “if. then. ” produces counter-intuitive results. Some of these principles were hinted at in [9]. Here we present a carefully worked-out chart, classifying a number of such principles over minimal logic.
    [Show full text]
  • Two Sources of Explosion
    Two sources of explosion Eric Kao Computer Science Department Stanford University Stanford, CA 94305 United States of America Abstract. In pursuit of enhancing the deductive power of Direct Logic while avoiding explosiveness, Hewitt has proposed including the law of excluded middle and proof by self-refutation. In this paper, I show that the inclusion of either one of these inference patterns causes paracon- sistent logics such as Hewitt's Direct Logic and Besnard and Hunter's quasi-classical logic to become explosive. 1 Introduction A central goal of a paraconsistent logic is to avoid explosiveness { the inference of any arbitrary sentence β from an inconsistent premise set fp; :pg (ex falso quodlibet). Hewitt [2] Direct Logic and Besnard and Hunter's quasi-classical logic (QC) [1, 5, 4] both seek to preserve the deductive power of classical logic \as much as pos- sible" while still avoiding explosiveness. Their work fits into the ongoing research program of identifying some \reasonable" and \maximal" subsets of classically valid rules and axioms that do not lead to explosiveness. To this end, it is natural to consider which classically sound deductive rules and axioms one can introduce into a paraconsistent logic without causing explo- siveness. Hewitt [3] proposed including the law of excluded middle and the proof by self-refutation rule (a very special case of proof by contradiction) but did not show whether the resulting logic would be explosive. In this paper, I show that for quasi-classical logic and its variant, the addition of either the law of excluded middle or the proof by self-refutation rule in fact leads to explosiveness.
    [Show full text]
  • 'The Denial of Bivalence Is Absurd'1
    On ‘The Denial of Bivalence is Absurd’1 Francis Jeffry Pelletier Robert J. Stainton University of Alberta Carleton University Edmonton, Alberta, Canada Ottawa, Ontario, Canada [email protected] [email protected] Abstract: Timothy Williamson, in various places, has put forward an argument that is supposed to show that denying bivalence is absurd. This paper is an examination of the logical force of this argument, which is found wanting. I. Introduction Let us being with a word about what our topic is not. There is a familiar kind of argument for an epistemic view of vagueness in which one claims that denying bivalence introduces logical puzzles and complications that are not easily overcome. One then points out that, by ‘going epistemic’, one can preserve bivalence – and thus evade the complications. James Cargile presented an early version of this kind of argument [Cargile 1969], and Tim Williamson seemingly makes a similar point in his paper ‘Vagueness and Ignorance’ [Williamson 1992] when he says that ‘classical logic and semantics are vastly superior to…alternatives in simplicity, power, past success, and integration with theories in other domains’, and contends that this provides some grounds for not treating vagueness in this way.2 Obviously an argument of this kind invites a rejoinder about the puzzles and complications that the epistemic view introduces. Here are two quick examples. First, postulating, as the epistemicist does, linguistic facts no speaker of the language could possibly know, and which have no causal link to actual or possible speech behavior, is accompanied by a litany of disadvantages – as the reader can imagine.
    [Show full text]
  • How the Law of Excluded Middle Pertains to the Second Incompleteness Theorem and Its Boundary-Case Exceptions
    How the Law of Excluded Middle Pertains to the Second Incompleteness Theorem and its Boundary-Case Exceptions Dan E. Willard State University of New York .... Summary of article in Springer’s LNCS 11972, pp. 268-286 in Proc. of Logical Foundations of Computer Science - 2020 Talk was also scheduled to appear in ASL 2020 Conference, before Covid-19 forced conference cancellation S-0 : Comments about formats for these SLIDES 1 Slides 1-15 were presented at LFCS 2020 conference, meeting during Janaury 4-7, 2020, in Deerfield Florida (under a technically different title) 2 Published as refereed 19-page paper in Springer’s LNCS 11972, pp. 268-286 in Springer’s “Proceedings of Logical Foundations of Computer Science 2020” 3 Second presentaion of this talk was intended for ASL-2020 conference, before Covid-19 cancelled conference. Willard recommends you read Item 2’s 19-page paper after skimming these slides. They nicely summarize my six JSL and APAL papers. Manuscript is also more informative than the sketch outlined here. Manuscript helps one understand all of Willard’s papers 1. Main Question left UNANSWERED by G¨odel: 2nd Incomplet. Theorem indicates strong formalisms cannot verify their own consistency. ..... But Humans Presume Their Own Consistency, at least PARTIALLY, as a prerequisite for Thinking ? A Central Question: What systems are ADEQUATELY WEAK to hold some type (?) knowledge their own consistency? ONLY PARTIAL ANSWERS to this Question are Feasible because 2nd Inc Theorem is QUITE STRONG ! Let LXM = Law of Excluded Middle OurTheme: Different USES of LXM do change Breadth and LIMITATIONS of 2nd Inc Theorem 2a.
    [Show full text]
  • On the Structures of Generating Iterated Function Systems of Cantor Sets
    ON THE STRUCTURES OF GENERATING ITERATED FUNCTION SYSTEMS OF CANTOR SETS DE-JUN FENG AND YANG WANG Abstract. A generating IFS of a Cantor set F is an IFS whose attractor is F . For a given Cantor set such as the middle-3rd Cantor set we consider the set of its generating IFSs. We examine the existence of a minimal generating IFS, i.e. every other generating IFS of F is an iterating of that IFS. We also study the structures of the semi-group of homogeneous generating IFSs of a Cantor set F in R under the open set condition (OSC). If dimH F < 1 we prove that all generating IFSs of the set must have logarithmically commensurable contraction factors. From this Logarithmic Commensurability Theorem we derive a structure theorem for the semi-group of generating IFSs of F under the OSC. We also examine the impact of geometry on the structures of the semi-groups. Several examples will be given to illustrate the difficulty of the problem we study. 1. Introduction N d In this paper, a family of contractive affine maps Φ = fφjgj=1 in R is called an iterated function system (IFS). According to Hutchinson [12], there is a unique non-empty compact d SN F = FΦ ⊂ R , which is called the attractor of Φ, such that F = j=1 φj(F ). Furthermore, FΦ is called a self-similar set if Φ consists of similitudes. It is well known that the standard middle-third Cantor set C is the attractor of the iterated function system (IFS) fφ0; φ1g where 1 1 2 (1.1) φ (x) = x; φ (x) = x + : 0 3 1 3 3 A natural question is: Is it possible to express C as the attractor of another IFS? Surprisingly, the general question whether the attractor of an IFS can be expressed as the attractor of another IFS, which seems a rather fundamental question in fractal geometry, has 1991 Mathematics Subject Classification.
    [Show full text]
  • Georg Cantor English Version
    GEORG CANTOR (March 3, 1845 – January 6, 1918) by HEINZ KLAUS STRICK, Germany There is hardly another mathematician whose reputation among his contemporary colleagues reflected such a wide disparity of opinion: for some, GEORG FERDINAND LUDWIG PHILIPP CANTOR was a corruptor of youth (KRONECKER), while for others, he was an exceptionally gifted mathematical researcher (DAVID HILBERT 1925: Let no one be allowed to drive us from the paradise that CANTOR created for us.) GEORG CANTOR’s father was a successful merchant and stockbroker in St. Petersburg, where he lived with his family, which included six children, in the large German colony until he was forced by ill health to move to the milder climate of Germany. In Russia, GEORG was instructed by private tutors. He then attended secondary schools in Wiesbaden and Darmstadt. After he had completed his schooling with excellent grades, particularly in mathematics, his father acceded to his son’s request to pursue mathematical studies in Zurich. GEORG CANTOR could equally well have chosen a career as a violinist, in which case he would have continued the tradition of his two grandmothers, both of whom were active as respected professional musicians in St. Petersburg. When in 1863 his father died, CANTOR transferred to Berlin, where he attended lectures by KARL WEIERSTRASS, ERNST EDUARD KUMMER, and LEOPOLD KRONECKER. On completing his doctorate in 1867 with a dissertation on a topic in number theory, CANTOR did not obtain a permanent academic position. He taught for a while at a girls’ school and at an institution for training teachers, all the while working on his habilitation thesis, which led to a teaching position at the university in Halle.
    [Show full text]
  • Fractal Geometry and Applications in Forest Science
    ACKNOWLEDGMENTS Egolfs V. Bakuzis, Professor Emeritus at the University of Minnesota, College of Natural Resources, collected most of the information upon which this review is based. We express our sincere appreciation for his investment of time and energy in collecting these articles and books, in organizing the diverse material collected, and in sacrificing his personal research time to have weekly meetings with one of us (N.L.) to discuss the relevance and importance of each refer- enced paper and many not included here. Besides his interdisciplinary ap- proach to the scientific literature, his extensive knowledge of forest ecosystems and his early interest in nonlinear dynamics have helped us greatly. We express appreciation to Kevin Nimerfro for generating Diagrams 1, 3, 4, 5, and the cover using the programming package Mathematica. Craig Loehle and Boris Zeide provided review comments that significantly improved the paper. Funded by cooperative agreement #23-91-21, USDA Forest Service, North Central Forest Experiment Station, St. Paul, Minnesota. Yg._. t NAVE A THREE--PART QUE_.gTION,, F_-ACHPARToF:WHICH HA# "THREEPAP,T_.<.,EACFi PART" Of:: F_.AC.HPART oF wHIct4 HA.5 __ "1t4REE MORE PARTS... t_! c_4a EL o. EP-.ACTAL G EOPAgTI_YCoh_FERENCE I G;:_.4-A.-Ti_E AT THB Reprinted courtesy of Omni magazine, June 1994. VoL 16, No. 9. CONTENTS i_ Introduction ....................................................................................................... I 2° Description of Fractals ....................................................................................
    [Show full text]
  • Fractals Lindenmayer Systems
    FRACTALS LINDENMAYER SYSTEMS November 22, 2013 Rolf Pfeifer Rudolf M. Füchslin RECAP HIDDEN MARKOV MODELS What Letter Is Written Here? What Letter Is Written Here? What Letter Is Written Here? The Idea Behind Hidden Markov Models First letter: Maybe „a“, maybe „q“ Second letter: Maybe „r“ or „v“ or „u“ Take the most probable combination as a guess! Hidden Markov Models Sometimes, you don‘t see the states, but only a mapping of the states. A main task is then to derive, from the visible mapped sequence of states, the actual underlying sequence of „hidden“ states. HMM: A Fundamental Question What you see are the observables. But what are the actual states behind the observables? What is the most probable sequence of states leading to a given sequence of observations? The Viterbi-Algorithm We are looking for indices M1,M2,...MT, such that P(qM1,...qMT) = Pmax,T is maximal. 1. Initialization ()ib 1 i i k1 1(i ) 0 2. Recursion (1 t T-1) t1(j ) max( t ( i ) a i j ) b j k i t1 t1(j ) i : t ( i ) a i j max. 3. Termination Pimax,TT max( ( )) qmax,T q i: T ( i ) max. 4. Backtracking MMt t11() t Efficiency of the Viterbi Algorithm • The brute force approach takes O(TNT) steps. This is even for N = 2 and T = 100 difficult to do. • The Viterbi – algorithm in contrast takes only O(TN2) which is easy to do with todays computational means. Applications of HMM • Analysis of handwriting. • Speech analysis. • Construction of models for prediction.
    [Show full text]
  • Logic, Ontological Neutrality, and the Law of Non-Contradiction
    Logic, Ontological Neutrality, and the Law of Non-Contradiction Achille C. Varzi Department of Philosophy, Columbia University, New York [Final version published in Elena Ficara (ed.), Contradictions. Logic, History, Actuality, Berlin: De Gruyter, 2014, pp. 53–80] Abstract. As a general theory of reasoning—and as a theory of what holds true under every possi- ble circumstance—logic is supposed to be ontologically neutral. It ought to have nothing to do with questions concerning what there is, or whether there is anything at all. It is for this reason that tra- ditional Aristotelian logic, with its tacit existential presuppositions, was eventually deemed inade- quate as a canon of pure logic. And it is for this reason that modern quantification theory, too, with its residue of existentially loaded theorems and inferential patterns, has been claimed to suffer from a defect of logical purity. The law of non-contradiction rules out certain circumstances as impossi- ble—circumstances in which a statement is both true and false, or perhaps circumstances where something both is and is not the case. Is this to be regarded as a further ontological bias? If so, what does it mean to forego such a bias in the interest of greater neutrality—and ought we to do so? Logic in the Locked Room As a general theory of reasoning, and especially as a theory of what is true no mat- ter what is the case (or in every “possible world”), logic is supposed to be ontolog- ically neutral. It should be free from any metaphysical presuppositions. It ought to have nothing substantive to say concerning what there is, or whether there is any- thing at all.
    [Show full text]
  • Generalizations and Properties of the Ternary Cantor Set and Explorations in Similar Sets
    Generalizations and Properties of the Ternary Cantor Set and Explorations in Similar Sets by Rebecca Stettin A capstone project submitted in partial fulfillment of graduating from the Academic Honors Program at Ashland University May 2017 Faculty Mentor: Dr. Darren D. Wick, Professor of Mathematics Additional Reader: Dr. Gordon Swain, Professor of Mathematics Abstract Georg Cantor was made famous by introducing the Cantor set in his works of mathemat- ics. This project focuses on different Cantor sets and their properties. The ternary Cantor set is the most well known of the Cantor sets, and can be best described by its construction. This set starts with the closed interval zero to one, and is constructed in iterations. The first iteration requires removing the middle third of this interval. The second iteration will remove the middle third of each of these two remaining intervals. These iterations continue in this fashion infinitely. Finally, the ternary Cantor set is described as the intersection of all of these intervals. This set is particularly interesting due to its unique properties being uncountable, closed, length of zero, and more. A more general Cantor set is created by tak- ing the intersection of iterations that remove any middle portion during each iteration. This project explores the ternary Cantor set, as well as variations in Cantor sets such as looking at different middle portions removed to create the sets. The project focuses on attempting to generalize the properties of these Cantor sets. i Contents Page 1 The Ternary Cantor Set 1 1 2 The n -ary Cantor Set 9 n−1 3 The n -ary Cantor Set 24 4 Conclusion 35 Bibliography 40 Biography 41 ii Chapter 1 The Ternary Cantor Set Georg Cantor, born in 1845, was best known for his discovery of the Cantor set.
    [Show full text]
  • Set Theory: Cantor
    Notes prepared by Stanley Burris March 13, 2001 Set Theory: Cantor As we have seen, the naive use of classes, in particular the connection be- tween concept and extension, led to contradiction. Frege mistakenly thought he had repaired the damage in an appendix to Vol. II. Whitehead & Russell limited the possible collection of formulas one could use by typing. Another, more popular solution would be introduced by Zermelo. But ¯rst let us say a few words about the achievements of Cantor. Georg Cantor (1845{1918) 1872 - On generalizing a theorem from the theory of trigonometric series. 1874 - On a property of the concept of all real algebraic numbers. 1879{1884 - On in¯nite linear manifolds of points. (6 papers) 1890 - On an elementary problem in the study of manifolds. 1895/1897 - Contributions to the foundation to the study of trans¯nite sets. We include Cantor in our historical overview, not because of his direct contribution to logic and the formalization of mathematics, but rather be- cause he initiated the study of in¯nite sets and numbers which have provided such fascinating material, and di±culties, for logicians. After all, a natural foundation for mathematics would need to talk about sets of real numbers, etc., and any reasonably expressive system should be able to cope with one- to-one correspondences and well-orderings. Cantor started his career by working in algebraic and analytic number theory. Indeed his PhD thesis, his Habilitation, and ¯ve papers between 1867 and 1880 were devoted to this area. At Halle, where he was employed after ¯nishing his studies, Heine persuaded him to look at the subject of trigonometric series, leading to eight papers in analysis.
    [Show full text]
  • Generators, Recursion, and Fractals
    Generators, Recursion, and Fractals 1 Generators computing a list of Fibonacci numbers defining a generator with yield putting yield in the function fib 2 Recursive Functions computing factorials recursively computing factorials iteratively 3 Recursive Images some examples recursive definition of the Cantor set recursive drawing algorithm MCS 260 Lecture 41 Introduction to Computer Science Jan Verschelde, 22 April 2016 Intro to Computer Science (MCS 260) generators and recursion L-41 22 April 2016 1 / 36 Generators, Recursion, and Fractals 1 Generators computing a list of Fibonacci numbers defining a generator with yield putting yield in the function fib 2 Recursive Functions computing factorials recursively computing factorials iteratively 3 Recursive Images some examples recursive definition of the Cantor set recursive drawing algorithm Intro to Computer Science (MCS 260) generators and recursion L-41 22 April 2016 2 / 36 the Fibonacci numbers The Fibonacci numbers are the sequence 0, 1, 1, 2, 3, 5, 8,... where the next number in the sequence is the sum of the previous two numbers in the sequence. Suppose we have a function: def fib(k): """ Computes the k-th Fibonacci number. """ and we want to use it to compute the first 10 Fibonacci numbers. Intro to Computer Science (MCS 260) generators and recursion L-41 22 April 2016 3 / 36 the function fib def fib(k): """ Computes the k-th Fibonacci number. """ ifk==0: return 0 elif k == 1: return 1 else: (prevnum, nextnum) = (0, 1) for i in range(1, k): (prevnum, nextnum) = (nextnum, \ prevnum + nextnum) return nextnum Intro to Computer Science (MCS 260) generators and recursion L-41 22 April 2016 4 / 36 themainprogram def main(): """ Prompts the user for a number n and prints the first n Fibonacci numbers.
    [Show full text]