递归

德罗斯特效应是递归的一种视觉形式。图中女性手持的物体中有一幅她本人手持同一物体的小图片,进而小图片中还有更小的一幅她手持同一物体的图片,依此类推。

递归(英語:Recursion),又译为递回,在数学计算机科学中,是指在函数的定义中使用函数自身的方法。递归一词还较常用于描述以自相似方法重复事物的过程。例如,当两面镜子相互之间近似平行时,镜中嵌套的图像是以无限递归的形式出现的。也可以理解为自我复制的过程。

正式定义

数学和计算机科学中,递归指由一种(或多种)简单的基本情况定义的一类对象或方法,并规定其他所有情况都能被还原为其基本情况。

例如,下列为某人祖先的递归定义:

  • 某人的双亲是他的祖先(基本情况)。
  • 某人祖先的双亲同样是某人的祖先(递归步骤)。

斐波那契数列是典型的递归案例:

  • (初始值)
  • (初始值)
  • 对所有大於1的整数n:(递归定义)

尽管有许多数学函数均可以递归表示,但在实际应用中,递归定义的高开销往往会让人望而却步。例如:

  • (初始值)
  • 对所有大於0的整数n:(递归定义)

一种便于理解的心理模型,是认为递归定义对对象的定义是按照“先前定义的”同类对象来定义的。例如:你怎样才能移动100个箱子?答案:你首先移动一个箱子,并记下它移动到的位置,然后再去解决较小的问题:你怎样才能移动99个箱子?最终,你的问题将变为怎样移动一个箱子,而这时你已经知道该怎么做的。

如此的定义在数学中十分常见。例如,集合论对自然数的正式定义是:1是一个自然数,每个自然数都有一个后继,这一个后继也是自然数。

以下是另一个可能更有利于理解递归过程的解释:

  1. 我们已经完成了吗?如果完成了,返回结果。如果没有这样的终止条件,递归将会永远地继续下去。
  2. 如果没有,则简化问题,解决较容易的问题,并将结果组装成原始问题的解决办法。然后返回该解决办法。

这样就有一种更有趣的描述:“为了理解递归,则必须首先理解递归。”或者更准确地,按照安德鲁·普洛特金英语Andrew Plotkin的解释:“如果你已经知道了什么是递归,只需记住答案。否则,找一个比你更接近侯世达的人;然后让他/她来告诉你什么是递归。”[1]

数学中常见的以递归形式定义的案例参见函数、集合以及分形等。

举例:编写一个程序使用递归求n的阶乘

Haskell:

fac 0 = 1
fac n = n * fac (n-1)

main = print( fac 10 )

语言中的例子

  1. 从前有座山,山里有座庙,庙里有个老和尚,正在给小和尚讲故事呢!故事是什么呢?「从前有座山,山里有座庙,庙里有个老和尚,正在给小和尚讲故事呢!故事是什么呢?『从前有座山,山里有座庙,庙里有个老和尚,正在给小和尚讲故事呢!故事是什么呢?……』」
  2. 一只狗来到厨房,偷走一小块面包。厨子举起杓子,把那只狗打死了。于是所有的狗都跑来了,给那只狗掘了一个坟墓,还在墓碑上刻了墓誌銘,让未来的狗可以看到:「一只狗来到厨房,偷走一小块面包。厨子举起杓子,把那只狗打死了。于是所有的狗都跑来了,给那只狗掘了一个坟墓,还在墓碑上刻了墓誌銘,让未来的狗可以看到:『一只狗来到厨房,偷走一小块面包。厨子举起杓子,把那只狗打死了。于是所有的狗都跑来了,给那只狗掘了一个坟墓,还在墓碑上刻了墓誌銘,让未来的狗可以看到……』」
  3. 大雄在房裏,用時光電視看着从前的情況。電視畫面中的那個時候,他正在房裏,用時光電視,看着从前的情況。電視畫面中的電視畫面的那個時候,他正在房裏,用時光電視,看着从前的情況……

數學之應用

謝爾賓斯基三角形-由封閉遞歸的三角形所形成之碎形

遞歸定義集

實例:自然數

關於遞歸定義集的經典範例,可透過自然數來說明:

, 則
滿足上述兩個條件之最小集合,即為自然數集合

實例:可導出的命題集合

另一個有趣範例為,公理系統中,所有可導出命題之集合

  • 若一個命題公理,則其為可導出之命題
  • 透過推理規則方式,若一個命題可以從可導出之命題所推論,則其為可導出之命題
  • 滿足上述條件之最小集合,為可導出之命題之集合

此集合稱為,可導出之命題之集合,因為在數學基礎方法中,依非建立性法構建的命題之集合,可能大於由公理系統推理規則所遞歸構建出之集合,詳細請參見 哥德爾不完備定理

有限次分割法

有限次分割法為幾何形式之遞歸,可用以創建類碎形之圖案。次分割原則的運作如後所述,從多個已被有限個標籤標註的多邊形開始,接著每個多邊形僅根據其標籤,繼續細切到更小的多邊形,此一細切的過程可不斷重複。

参见

参考文献

脚注

  1. ^ 原文:“If you already know what recursion is, just remember the answer. Otherwise, find someone who is standing closer to Douglas Hofstadter than you are; then ask him or her what recursion is.”

书目

  • Johnsonbaugh, Richard. Discrete Mathematics. Prentice Hall. 2004. ISBN 0-13-117686-2. 
  • Hofstadter, Douglas. Gödel, Escher, Bach: an Eternal Golden Braid. Basic Books. 1999. ISBN 0-465-02656-7. 
  • Shoenfield, Joseph R. Recursion Theory. A K Peters Ltd. 2000. ISBN 1-56881-149-7. 
  • Causey, Robert L. Logic, Sets, and Recursion. Jones & Bartlett. 2001. ISBN 0-7637-1695-2. 
  • Cori, Rene; Lascar, Daniel; Pelletier, Donald H. Recursion Theory, Godel's Theorems, Set Theory, Model Theory. Oxford University Press. 2001. ISBN 0-19-850050-5. 
  • Barwise, Jon; Moss, Lawrence S. Vicious Circles. Stanford Univ Center for the Study of Language and Information. 1996. ISBN 0-19-850050-5.  - offers a treatment of corecursion.
  • Rosen, Kenneth H. Discrete Mathematics and Its Applications. McGraw-Hill College. 2002. ISBN 0-07-293033-0. 
  • Cormen, Thomas H., Charles E. Leiserson, Ronald L. Rivest, Clifford Stein. Introduction to Algorithms. Mit Pr. 2001. ISBN 0-262-03293-7. 
  • Kernighan, B.; Ritchie, D. The C programming Language. Prentice Hall. 1988. ISBN 0-13-110362-8. 
  • Stokey, Nancy,; Robert Lucas; Edward Prescott. Recursive Methods in Economic Dynamics. Harvard University Press. 1989. ISBN 0674750969. 

外部链接

Read other articles:

Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada Desember 2022. Margaret Wood BancroftLahirJuly 10, 1893Glasgow, KentuckyMeninggal30 Agustus 1986(1986-08-30) (umur 93)San Diego, CaliforniaKebangsaanAmerikaKarier ilmiahBidangNatural HistoryInstitusiSan Diego Natural History Museum Margaret R. Wood Bancroft (10...

 

Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada November 2022. Athanasia Amanda Septevani (lahir 2 September 1984) atau lebih dikenal sebagai Amanda Septevani adalah peneliti senior di Pusat Penelitian Kimia Lembaga Ilmu Pengetahuan Indonesia (LIPI) [1] bidang polimer, dan nanoteknologi khususnya yang ber...

 

Queen consort of Denmark Judith of SaxonyQueen consort of DenmarkTenure1239–1250Bornc. 1223DiedBefore 2 February 1267SpouseEric IV of DenmarkBurgrave Burchard VIII of MagdeburgIssueSophia of DenmarkIngeborg of Denmark, Queen of NorwayJutta of DenmarkAgnes of DenmarkHouseAscaniaFatherAlbert I, Duke of SaxonyMotherAgnes of AustriaReligionRoman Catholicism Jutta of Saxony (c. 1223 – before 2 February 1267) was Queen of Denmark as the wife of King Eric IV of Denmark. She was the daughter of A...

Giuseppe Canepa Deputato dell'Assemblea CostituenteGruppoparlamentarePartito Socialista Italiano, Partito Socialista Lavoratori Italiani CollegioGenova Sito istituzionale Senatore della Repubblica ItalianaLegislaturaI GruppoparlamentareUnità Socialista Sito istituzionale Deputato del Regno d'ItaliaLegislaturaXXIII, XXIV, XXVI, XXVII Sito istituzionale Dati generaliPartito politicoPartito Socialista Italiano di Unità Proletaria Titolo di studiolaurea in giurisprudenza Professi...

 

Йоахім Кіршнернім. Joachim KirschnerНародився 7 червня 1920(1920-06-07)Лесніц, Рудні Гори, СаксоніяПомер 17 грудня 1943(1943-12-17) (23 роки)Меткович, Дубровницько-Неретванська жупанія, ХорватіяКраїна  Німецька імперіяДіяльність солдат, льотчикУчасник Друга світова війнаВійськове звання ...

 

Auf dieser Seite sind die Baudenkmäler in der schwäbischen Gemeinde Deisenhausen zusammengestellt. Diese Tabelle ist eine Teilliste der Liste der Baudenkmäler in Bayern. Grundlage ist die Bayerische Denkmalliste, die auf Basis des Bayerischen Denkmalschutzgesetzes vom 1. Oktober 1973 erstmals erstellt wurde und seither durch das Bayerische Landesamt für Denkmalpflege geführt wird. Die folgenden Angaben ersetzen nicht die rechtsverbindliche Auskunft der Denkmalschutzbehörde. [An...

У Вікіпедії є статті про інші значення цього терміна: Водяне. село Водяне Країна  Україна Область Дніпропетровська область Район Нікопольський район Рада Павлопільська сільська рада Облікова картка Водяне  Основні дані Населення 107 Поштовий індекс 53250 Телефонний ко

 

Book by P. C. Cast This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages) The topic of this article may not meet Wikipedia's notability guideline for books. Please help to demonstrate the notability of the topic by citing reliable secondary sources that are independent of the topic and provide significant coverage of it beyond a mere trivial mention. If notability cannot be shown, the article is...

 

?Морський крайт Морський крайт звичайний Біологічна класифікація Домен: Ядерні (Eukaryota) Царство: Тварини (Animalia) Тип: Хордові (Chordata) Підтип: Черепні (Craniata) Інфратип: Хребетні (Vertebrata) Клас: Плазуни (Reptilia) Ряд: Лускаті (Squamata) Підряд: Змії (Serpentes) Родина: Аспідові (Elapidae) Підродина: Мор...

Emperor of Ethiopia from 1682 to 1706 Iyasu IIyasu I with his courtEmperor of EthiopiaReign19 July 1682 –13 October 1706Coronation19 July 1682[1]PredecessorYohannes ISuccessorTekle Haymanot IBorn1654Died13 October 1706(1706-10-13) (aged 51–52)Regnal nameAdyam SagadDynastyHouse of SolomonFatherYohannes IMotherSabla WangelReligionOrthodox TewahedoIyasu I (Ge'ez: ኢያሱ ፩; 1654 – 13 October 1706), throne name Adyam Sagad (Ge'ez: አድያም ሰገድ), also known as Iyas...

 

2006 studio album by Micah P. HinsonMicah P. Hinson and the Opera CircuitStudio album by Micah P. HinsonReleased10 October 2006Recorded2006GenreIndie rockLength42:20LabelJade Tree Records (USA), Sketchbook Records (UK)ProducerMicah P. HinsonMicah P. Hinson chronology The Baby & the Satellite(2006) Micah P. Hinson and the Opera Circuit(2006) Micah P. Hinson and the Red Empire Orchestra(2008) Professional ratingsReview scoresSourceRatingAllmusic linkAlmost Cool(6.75/10) linkAustin C...

 

For the Telegu film, see Maharathi (2007 film). 2008 Indian filmMaharathiDirected byShivam NairWritten byUttam GadaProduced byDhillin MehtaStarringParesh RawalNaseeruddin ShahNeha DhupiaOm PuriBoman IraniTara SharmaCinematographyVenuEdited byAarti BajajMusic byShibani KashyapRelease date 5 December 2008 (2008-12-05) CountryIndiaLanguageHindi Maharathi is a Hindi thriller film produced by Dhilin Mehta. The film was directed by Shivam Nair and stars Paresh Rawal, Neha Dhupia, Nas...

2015 filmRomeo vs JulietDirected by Ashok Pati Abdul Aziz Written by Sudipto Sarkar Pele Bhattacharya Produced by Ashok Dhanuka Abdul Aziz Starring Joey Debroy Ankush Hazra Mahiya Mahi CinematographyYuvrajEdited by Sudipto Sarkar M. Susmit Music by Savvy Gupta Akassh Sen Productioncompany Overseas Films Limited Distributed by Jaaz Multimedia Eskay Movies Release date 16 January 2015 (2015-01-16)[1] Countries Bangladesh India LanguageBengaliBudget₹3 crore (equivalent t...

 

2021 Indonesian film The Heartbreak ClubIndonesianSobat Ambyar Directed byCharles GozaliBagus BramantiWritten byBagus BramantiGea RexyProduced byLinda GozaliDidi Kempot (executive)Starring Dede Satria Denira Wiraguna Emil Kusumo Sisca JKT48 Asri Welas Erick Estrada CinematographyHani PradigyaEdited byRyan PurwokoProductioncompanies Magma Entertainment Ideosource Entertainment Paragon Pictures Rapi Films Distributed byNetflixRelease date January 14, 2021 (2021-01-14) Running tim...

 

Cerkiew Świętych Apostołów Piotra i Pawła cerkiew parafialna Zdjęcie cerkwi sprzed 1914 Państwo  Polska Miejscowość Augustów Wyznanie prawosławne Kościół Rosyjski Kościół Prawosławny Wezwanie Świętych Apostołów Piotra i Pawła Historia Data zakończenia budowy 1884 Data poświęcenia 7 października 1884 Data zamknięcia 1924 Data zniszczenia 1926 Dane świątyni Świątynia• materiał bud.• liczba wiernych • cegła800 osób Wieża kościelna• liczba wież 1...

2009 studio album by MalajubeLabyrinthesStudio album by MalajubeReleasedFebruary 10, 2009GenreIndie rockLength38:37LabelDare to Care RecordsMalajube chronology Trompe-l'œil(2006) Labyrinthes(2009) La caverne(2011) Professional ratingsReview scoresSourceRatingPopMatters(7/10)[1]Pitchfork(6.4/10)[2] Labyrinthes is the third studio album by Malajube, a Quebec indie rock band.[3] The album was released on February 10, 2009, and is their first studio album since th...

 

IljimaePoster promosi untuk IljimaeGenrePeriod drama, Action, RomanceBerdasarkanIljimaeoleh Ko Woo-youngDitulis olehChoi RanSutradaraLee Yong-sukPemeranLee Joon-giHan Hyo-jooLee Young-ahPark Si-hooNegara asalKorea SelatanBahasa asliBahasa KoreaJmlh. episode20ProduksiProduserLee Yong-sukLokasi produksiKoreaDurasiRabu dan Kamis pada pukul 21:55 (WSK)Rumah produksiChorokbaem MediaRilis asliJaringanSeoul Broadcasting SystemFormat gambar1080i (HDTV)Rilis21 Mei (2008-05-21) –24 Juli 200...

 

Outdoor concert venue in Maryland, U.S. For the album by Animal Collective, see Merriweather Post Pavilion (album). Merriweather Post PavilionMerriweather Post Pavilion in 2017 prior to renovationAddress10475 Little Patuxent Parkway[1]LocationColumbia, Maryland, U.S.Coordinates39°12′33.29″N 76°51′45.61″W / 39.2092472°N 76.8626694°W / 39.2092472; -76.8626694Public transitRTA 406 (Central Library stop)RTA 501 , RTA 503, MTA 315 (Broken Land/Hickory Ri...

Italian-Canadian actor Giacomo GianniottiGianniotti in 2016BornGiacomo Keaton Gianniotti (1989-06-19) 19 June 1989 (age 34)Rome, ItalyAlma materHumber CollegeOccupationActorYears active2010–presentSpouse Nichole Gustafson ​(m. 2019)​ Giacomo Keaton Gianniotti (born 19 June 1989) is an Italian-Canadian film and television actor. He studied theater at Humber College and made his acting debut in the Italian television series Medicina Generale in 2010...

 

1504 engraving and 1507 paintings by Dürer Adam and Eve is the title of two famous works in different media by Albrecht Dürer, a German artist of the Northern Renaissance: an engraving made in 1504, and a pair of oil-on-panel paintings completed in 1507. The engraving of 1504 depicts Adam and Eve in the Garden of Eden, with several symbolic animals around them.[1] This famous engraving transformed how Adam and Eve were popularly depicted in art.[2] The 1507 painting in the M...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!