Tuesday, April 8, 2014

rough notes on finding near misses to cycles in juggler sequence

this is about feeding a number back into a function over and over again, and seeing what kind of patterns we get.

see the entry for the collatz conjecture in the complexity lab manual, it is a similar game

def jug(n) = {int(sqrt(n^3))  if n is odd else  int(sqrt(n))}

int(r) is the greatest integer less than r, i.e. int(4.773)=4

so that jug(2)=2, and jug(2)=1 and jug(1)=1 and we stop there.  that's a fixed point.

jug(3)=int(sqrt(27))=5, and jug(5)=11, etc..

the sequence of numbers we get is called the orbit of the first number under the dynamical system for our function jug(x)

here are the orbits for the first 9 integers
[1]
[2, 1]
[3, 5, 11, 36, 6, 2, 1]
[4, 2, 1]
[5, 11, 36, 6, 2, 1]
[6, 2, 1]
[7, 18, 4, 2, 1]
[8, 2, 1]
[9, 27, 140, 11, 36, 6, 2, 1]
>>>

here is orbit for 37:

 [37, 225, 3375, 196069, 86818724, 9317, 899319, 852846071, 24906114455136, 4990602, 2233, 105519, 34276462, 5854, 76, 8, 2, 1]

it seems that no matter what n we start off with we reach 1 (i think this has been tested up to a million)

no one knows how to prove that this is so.  There are many systems like this and they puzzle us.
wiki on the juggler sequence

the question is: are there numbers for which the orbit reaches a fixed point?  or are there numbers for which the orbit cycles?  for instance, look at the orbit for 3:
[3, 5, 11, 36, 6, 2, 1]
if the square root of 36 had happened to be 5 this orbit would have been:
3, 5, 11, 36, 5, 11, 36, 5...

and 5,11,36 would be a cycle.  no one has found any cycles yet, but lets look for almost cycles like 3, 5, 11, 36, 6... 6 is CLOSE to 5.


so,

i generate an orbit under this dynamical system.  [(x0,0), (x1,1)....(xn,n)]
then i sort this by x, so that xi that are near each other in size are near each other in the sequence

then i create a sequence of the differences between consecutive xi's  and sort that.  here is what i get for 37:

(diff, (xi, i), (xj, j))
(1L, (1L, 17), (2L, 16))
(6L, (2L, 16), (8L, 15))
(9L, (8L, 15), (17, 18))
(20, (17, 18), (37, 0))
(39L, (37, 0), (76L, 14))
(149L, (76L, 14), (225, 1))
(1142L, (2233L, 10), (3375, 2))
(2008L, (225, 1), (2233L, 10))
(2479L, (3375, 2), (5854L, 13))
(3463L, (5854L, 13), (9317, 5))
(90550L, (105519L, 11), (196069, 3))
(96202L, (9317, 5), (105519L, 11))
(703250, (196069, 3), (899319, 6))
(4091283L, (899319, 6), (4990602L, 9))
(29285860L, (4990602L, 9), (34276462L, 12))
(52542262L, (34276462L, 12), (86818724, 4))
(766027347, (86818724, 4), (852846071, 7))
(24905261609065L, (852846071, 7), (24906114455136L, 8))


now if i want to search for orbits with near misses... what do i search for?  obviously the first few entries do not count

the 4th and 5th entries are close to what i'm looking for.  how do i write an algorithm to pick them out?  the diff must be small but the indexes must be far apart.

the 3rd entry has indices 3 apart but i'm not going to count that as a good candidate!

hmm... a programming puzzle!

this post is continued in the comments...

Sunday, April 6, 2014

If I Were Able To Focus I'd Describe This Complexity Lab Manual

The Complexity Lab Manual

What is the complexity lab manual?  It is hard to explain in a few words. It is the science and craft that we've discovered in the last 150 years that begin to bridge the gap between machines and  life, that most people never even get a glimpse of in grade school or college.  it is about discovies and techniques that are so surprisingly different than our thousand years old ways of thought and language.  but the world today is so complex, moving so fast, has become so overpopulated by people who have at their disposal immense powers to transform the earth that it is the duty of everyone to learn these new skills of how to see the world, understand it, and build with it in a sane way.

You will construct machines made of a billion parts all interacting with each other in complicated ways.   you will learn what molecules are and how a trillion of them can make fluid subtle bodies.  you will learn how light, streaming from the hot sun to the cold dark voids of outerspace, sets into motion the weather, makes our hearts beat, our muscles move, our very thoughts themselves to flow.  let's begin.

>>>MELD THESE PARAGRAPHS TOGETHER, ENDING WITH MENTIONING THE POTTER'S CLAY
most people would say that we are not machines, that love is not just a chemical reaction. throughout history most cultures have thought that our very being, our minds, our souls are separate from our bodies of flesh and bone, even that they are immortal and immune from death and decay.  that an eternal supermind and supercraftsman, God, alien to earth, death and decay, outside of the very physical universe,  created bodies out of dumb clay and breathed a little bit of himself into these clay pots to make us alive and and able to feel.


over the past few thousands of years, from the time of the cavemen, the time of the hebrew prophets and the ancient greek philosophers, human culture has built up this notion of an uncrossible divide.  On the one side we put: animated life and human thought and feeling and on the other side mud and machinery.
Most of us would think that there is an unbridgeable gap between the mechanical and the living, between  inanimate rocks chemicals and machines on the one side and  on the other side; living, fluid, subtle, creative, beautifull, beings like trees and animals and people; dancers, artists, writers, you and i who can think and feel.
>>>

complexity lab is about that clay, and what it can do without a supermind creator from the outside.  I know, these are bold thoughts, even heretical thoughts.  but the fact is that we are watching what this clay can do in our microscopes, in our laboratories, in our computers and soon in our nanotechnology factories.  We will learn that life is not made of featureless smooth gobs of stuff like the clay that the potter uses, but that life is made, not from the outside by a potter, but from the inside by a seething swarm of microscopic factories, all interacting with each other a trillion times a second.

But in this modern age most of us do have a vague notion that our bodies have something to do with chemistry, that scientists are saying that we are simply complicated machines or bags of molecules, that our human love and morality are simply chemical reactions.  But what could they mean by this?  How could chemistry or machinery do what you and i can, or even fly like a honeybee who can find flowers, build beehives..?  How can complicated machines be anything like people?  how could complex swarms of molecules, atoms, make life?  Scientists say that 99% of a tree with its finely grained wood, veined leaves, and flowers is made simply of air and water.   just how complicated are these supposed machines, and molecular interactions anyway?

It is the goal of this complexity lab manual to guide you through a series of experiments, projects, diagrams, and stories, to help you get a gut intuition of the kinds of machinery that modern science has discovered and what they are capable of.  To show you that these machines are gazillions of times more subtle, fluid, and creative than cars and robots and computers, and factories.  You will even learn to build some of these machines yourself.  We are learning to build machines that are approaching the suppleness, beauty and creativity of life.

 But our new discoveries of how lifelike machines and chemistry can be is only a hundred and fifty years old,  a mere blink of the eye in the span of human history.  And the schools are not teaching this new view of the world.

In this complexity lab, we will see that our flesh is a swarm of so many more parts than in an automobile or even in a computer.  you will see that their mechanisms of interactions are so much more  fluid and subtle than the machine parts that we are familiar with.

How do the parts of these new machines interact? Most human notions of creativity and government are that a central mind or hierarchy controlling all the parts of the body.  And in the same manner we have tried to build governments on these same models of centralized control.  Even a democracy is based on notions of hierarchical organization.  10,000 people elect one councilperson and 10 counsilpersons work with one mayor, and a million people elect an elector and 100 electors elect one president, and then in daily practice these few people deal with the lives of the many.  This is a clunky system, and not very responsive to the complex times we live in.  In fact, throughout history,  these governments have mostly been ugly and inhumane, and they rarely last more than a few centuries. They exhibit none of the stability and beauty of forests and coral reefs that last for 1000s of years  and are so refreshingly peaceful and beautiful that we flock to them for a break from our clunky ratrace cities. 

the traditional notion of craftsmanship, of building a machine or of creating a work of art, is of a single mind crafting a machine or painting from the outside, or crafting a machine by building a huge factory outside of it which can only touch the parts with a few hands or tools at a time.  We could not imagine how to craft a working kidney with its millions of densly packed, carefully interlocked tubes all in a space of a few inches.

We've yet to figure out how to build a government that can govern a million people in a humane and stable way.  and only recently are we learning how to build a real kidney, or eye.

In the complexity lab we will learn a new form of craftsmanship.  We will learn what happens when large numbers of simple parts interact with each other, instead of being controlled by a central mechanism. We will see that when  those interactions include both stabiliziing and disruptive elements, creativity results.  we will learn that when we build a machine of 10 parts, then 100 parts, then a 1000 parts... that at each stage totally new capabilities appear, they don't just become 10 times faster or smarter, but capabilities that we could never predict appear at each stage. And not just a thousand parts (maybe a car has a thousand parts if we count all the nuts and bolts) We will learn about machines with trillions of parts.

One of the main tasks and most difficult tasks of this complexity lab is to teach you how to think about very large numbers, to feel them in your gut.  you will even learn how to comprehend how big a trillion is!  You will start with understanding 2, then you will understand 3, then you will understand 10 and then 100 and thousand and so on.

In the past, in simpler times, in slower times, in times when there were only hundreds of people scattered across rural landscapes,  when there were only a few scattered cities with more than ten thousand people in them, and only a few cities interacted with each other at a time, there was no need for most of us to think about numbers. numbers weren't important.  But now, that there are six BILLION of us crowding the planet.  (most people don't even know the difference between 10,000 people in a city, 300 million people in the united states, or 6 billion people in the world) when dozens of cities with over 10million people in them span the earth in a tightly interacting global network of commerce and warfare that responds to random events in a split second, when the global economy can calapse in a day, it is our duty to learn to think about numbers.  to think about billions, to think about what happens when networks of billions of people make thousands of decisions every second of the hour, every hour of the day, every day of the year.  we've got to learn how big that number is. and we've got to learn what that number of parts can do.

yes, in the past machines were only made out of a few dozens of clunky metal parts.  but in the past two generations, we've learned to make computers out of nimble switches, switches that communicate with each other.  We've learned to connect thousands of these switches together and have them flipping on and off thousands of times each second.  not the clicking and  clacking of clunky metal parts, the movement is of microscopic bundles of static electricity.  but this was only the start.  An astounding thing happened: every year or so we learned how to weave together ten times as many switches into the same chip the size of a finger nail.  every year or so we learned to make them them make their tiny decisions ten times faster.

we can now connect together billions of switches, all changing each other a billion times a second.  these are the computers we use today.  computers that can animate movies with swarms of 1000s of lifelike people.  programs that can coordinate 100s of activities on our computer desktops.  computer chips in Aibo dogs that can get together and play a passable game of soccer.

And then there is the newest technologies: genetic engineering and nanotechnology.  we ARE learning to build with life and chemistry from the very molecules on up.  It's coming.  It's time that every highschool kid embarking on adulthood in this complicated fast moving world, learns this new worldview.

Old Intro With Links To Labs