JavaRush /Java Blog /Random EN /Dedicated to Groundhog Day... Recursion in real life

Dedicated to Groundhog Day... Recursion in real life

Published in the Random EN group
February. Well, hello, February. We are glad to see you. And today - even more so. Because February 2 is the most cyclical and recursive day in the world thanks to the movie Groundhog Day.
Dedicated to Groundhog Day... Recursion in real life - 1
In this winter cycle, you can once again watch the same “Groundhog Day” (2.02) and “Radio Day” (13.02), cheer for your favorite athletes at the Winter Olympics (9.02-25.02), eat pancakes (12.02-16.02), give “Valentine” (02/14) and another shaving lotion (02/23), congratulations on the polar bear holiday (02/27)… And then a new spring cycle will begin.
Dedicated to Groundhog Day... Recursion in real life - 2
And now about today. The main character of the movie "Groundhog Day" finds himself in a kind of recursive situation that looks like an endless loop. In fact, on each day a number of events occur in which the hero can intervene in one way or another. The hero reasonably assumed that to get out of Groundhog Day, he must do something about these situations. The difficulty is that there are many situations, there are many ways to intervene in them, and there are even more combinations of both. With nothing to do, he began to thoroughly study his only repeating day, believing that the way out of it could be anything - from stealing a groundhog to committing suicide. Gradually he came to the idea of ​​self-improvement. To discover the exit point, the hero must use the knowledge gained in previous lives of this day, and gradually he succeeded. But recursion can be found not only in programming or science fiction films. This is a very common phenomenon even in everyday life. A classic example of infinite recursion is two mirrors placed opposite each other: they form two corridors of fading reflections of the mirrors.
Dedicated to Groundhog Day... Recursion in real life - 3
Dedicated to Groundhog Day... Recursion in real life - 4
Recursion is not necessarily infinite. Here, for example, is a matryoshka doll. Quite recursive, but you will definitely get to the smallest of them.
Dedicated to Groundhog Day... Recursion in real life - 5
The easiest way to see recursion without leaving your computer is to point your webcam at the computer monitor screen. The camera will record the image of the computer screen and display it on this screen, it will be something like a closed loop. And we will observe something similar to a tunnel.
Dedicated to Groundhog Day... Recursion in real life - 6

Examples of recursion in nature

The most spectacular example of recursion is geographical objects. For example, similar to the aforementioned nesting dolls, islands in the middle of lakes, which in turn are located on islands. Among such sites, the most famous is the freshwater Taal Lake, located on Lawson Island in the province of Batangas, Philippines. On the lake is the volcanic island of Taal, in its crater there is another lake. And it, in turn, has its own small island, Vulcan Point.
Dedicated to Groundhog Day... Recursion in real life - 7
A clear example is also rivers formed from other rivers, mountains and lightning.
Dedicated to Groundhog Day... Recursion in real life - 8
Dedicated to Groundhog Day... Recursion in real life - 9
No less interesting are examples of “vegetable” recursions. Here, for example, are regular onions and white cabbage:
Dedicated to Groundhog Day... Recursion in real life - 10
Recursions look completely different in cauliflower and Romanesco cabbage. Their heads consist of inflorescences, which in turn consist of inflorescences. Interestingly, the head of Romanesco cabbage consists of light green inflorescences that have the shape of a fractal spiral. In addition, each individual bud forms its own spiral.
Dedicated to Groundhog Day... Recursion in real life - 11
Dedicated to Groundhog Day... Recursion in real life - 12
A tree consists of branches. The branch in turn consists of smaller branches. Each branch repeats the tree.
Dedicated to Groundhog Day... Recursion in real life - 13
The same structure can be observed in a complex fern leaf:
Dedicated to Groundhog Day... Recursion in real life - 14
The seeds of some flowers (for example, sunflowers) are arranged in intersecting spiral fans, determined by the Fibonacci ratio:
Dedicated to Groundhog Day... Recursion in real life - 15
A remarkable example of recursion is dendrites - complex crystalline formations of a tree-like branching structure. We are all familiar with ice dendrites - these are snowflakes and frosty drawings on glass:
Dedicated to Groundhog Day... Recursion in real life - 16
Dedicated to Groundhog Day... Recursion in real life - 17
Dendrites of metals, such as gold and copper, are also found:
Dedicated to Groundhog Day... Recursion in real life - 18
Examples of recursion from the animal world are also quite clear: the eternal pair “chicken and egg” and... evolution:
Dedicated to Groundhog Day... Recursion in real life - 19
Dedicated to Groundhog Day... Recursion in real life - 20

Examples of recursion in linguistics and literature

A story from Stanislaw Lem's "Cyberiad" about an intelligent machine that had enough intelligence and laziness to build a similar one to solve a given problem and entrust the solution to it. (infinite recursion - each new machine built a similar one). N.V. Gogol in the story “Portrait” describes the dream of the artist Chertkov, who, having woken up, falls into a dream again, waking up from this dream he falls into the first dream, from which he will also have to wake up. "The Master and Margarita" is one of the most striking recursive novels. The theme of Yeshua and Pilate is recursively evoked from the theme of the Master and Margarita. In addition, the “book within a book” technique is also used here. The master writes a novel about Yeshua and Pilate, the text of which merges with the text of the book "The Master and Margarita". Another example of recursion is “The House That Jack Built” by Robert Burns, translated by Marshak. Or this is Isaac Asimov’s shortest story, written on a dare right in the studio while recording an interview.

“...Insert cotter pin A into slot B...”

Dave Woodbury and John Hansen, clumsy in their spacesuits, watched with excitement as the huge cage slowly separated from the transport ship and entered the airlock to another atmosphere. They spent almost a year on the A-5 space station, and they were, understandably, fed up with rattling filtration plants, leaking hydroponics tanks, air generators that hummed annoyingly, and sometimes simply failed.

“Everything is falling apart,” Woodbury sighed mournfully, “because we put it all together ourselves.”

“Following instructions,” Hansen added, “drawn up by some idiot.”

There were certainly grounds for complaint. The most scarce thing on a spaceship is the space allocated for cargo, which is why all the equipment, compactly packed, had to be delivered to the station disassembled. All instruments and installations had to be assembled at the station itself with our own hands, using obviously the wrong tools and following vague and lengthy assembly instructions.

Woodbury carefully wrote down all the complaints, Hansen provided them with the appropriate epithets, and an official request for urgent assistance in the current situation was sent to Earth. And the Earth responded. A special robot was constructed with a positronic brain, stuffed with knowledge of how to assemble any conceivable mechanism.

This robot was now in the unloading cage. Woodbury trembled nervously as the airlock doors finally closed behind her.

The most famous examples of endless recursion in literature are “endless fairy tales”: I opened my eyes: Blue skies, And a green blanket, And shaggy forests... Here is the river - everything flows, The sun has risen - it bakes again... I took a pen and a notebook And decided write everything down, I opened my eyes: Blue skies... The priest had a dog The priest had a dog, He loved her, She ate a piece of meat, He killed her And buried her in the ground, And he erected a monument, And he wrote the inscription: The priest had a dog, He loved her, she ate a piece of meat

Recursive Graphics Examples

Recursion techniques look great in painting and photography. These could be “portrait within a portrait”, “frame within a frame”, or “the artist paints a picture of him painting a picture of himself painting a picture”:
Dedicated to Groundhog Day... Recursion in real life - 21
Dedicated to Groundhog Day... Recursion in real life - 22
Dedicated to Groundhog Day... Recursion in real life - 23

Recursive humor

It's just tough. The programmers, ept, we live together, agreed like this: the first wakes up the second, the second wakes up the third, the third wakes up the first... recursion =) as a result, we slept through the lecture. For lunch we have the “Recursive” salad: tomatoes, cucumbers, lettuce. xxx: remember Antokh lost his wish? So, I wished for him: for 2 days he would put a sticker with this action on all the objects with which he performed any actions yyy: I would definitely put a sticker on the sticker with the inscription “pasted”. The little one (10 month old son) was driven into recursion... one pacifier in his mouth. gave the second one. he spat out the first one with joy. inserted the second one. I heard something fall. I was happy to see the first pacifier. dropped the second one. I put the first one in my mouth. I heard something fall... he's been changing them for 5 minutes. Today I worked with my father, he says to me like “do you want me to show you recursion?”, I’m like “come on.” He takes and sticks the plug of the drill into the extension cord, and plugs the plug of the extension cord into a free socket of the same extension cord, presses the button, the drill starts working... Damn, I must have had a very funny face, he laughed until the evening, and I stuck it in for a long time, why is this happening. It turned out the drill was battery powered. If you believe that everything in life should have practical application, then we suggest that you recall the knowledge you have acquired in programming and try to solve some of the well-known problems that are solved using recursive methods: finding Fibonacci numbers and factorials, as well as the “Towers of Hanoi” puzzle .
Dedicated to Groundhog Day... Recursion in real life - 24
February. Well hello, February. We are glad to see you. And today - even more so.
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION