
Self-Replicating Functions - tylerneylon
http://tylerneylon.com/a/self_repl/
======
tbabb
That is a beautifully typeset article.

~~~
tylerneylon
Thanks! I'm considering writing a follow-up note on the process that went into
the typesetting. The original source is a markdown-with-latex format that a
tool called pandoc can work with. The style is primarily from tufte.css. The
image work is mostly custom, but there are some re-usable approaches. If
you're curious:

[https://github.com/tylerneylon/math/blob/master/self_repl_fn...](https://github.com/tylerneylon/math/blob/master/self_repl_fns/self_repl_fns.md)

~~~
dkersten
fyi: the numbered lists only take up half the width of the normal paragraphs,
making it look a bit janky and odd, on my chrome on OSX.

------
SonOfLilit
My favorite self-replicating function is the sine, and I spent some time
finding it using just its very strong self-replication properties here:

[https://myownfortune.wordpress.com/2017/09/21/why-sine-
wave/](https://myownfortune.wordpress.com/2017/09/21/why-sine-wave/)

~~~
JadeNB
By the way, this is a nice article, but you unfortunately mix up "frequency"
and "period" in your quantitative discussion. (A function that repeats every
50 units, for example, has a period of 50 units, as opposed to a frequency of
1/50 1/units.)

------
dahart
This is a fun exploration! It's interesting that the summed functions have a
feature topology that mirrors each sub-function, but some of the local
features retain their original scaling, while features in the overlap region
adopt a new scaling. This reminds me a little of using absolute scaling in SVG
or CSS on something that is parented or embedded (not at the root of the
hierarchy). Sometimes you use that kind of thing for character rigs in movies
& games - break out of the local coordinate system and use world space.

Since the scaling isn't uniform, this is what causes t1 & t2 to have to be
piece-wise linear. I'd love to see what happens if the transform functions,
i.e. t1 & t2, were restricted to affine transforms. Like, how much harder is
it if you further require the summed function to be a uniformly scaled &
translated version of the sub-function? What if you added to the formal
definition something like: f_S = a * f_L ( b * x + c ), where a,b,c are
constants

This also reminds me of a mutation I added to my artificial evolution digital
art project where I was trying to generalize on the idea of a fractal. I
called it the 'harmonic mutation', and it takes any function f(x) and produces
a new function with two or more scaled copies, like c0 * f(c1 * x + c2) + c3 *
f(c4 * x + c5). Repeat several times with the same constants, and you can make
a fractal out of any function at all. Very similar concept to Perlin
turbulence too, where you have summed & scaled octaves of noise.

~~~
tylerneylon
Cool connections. Do you happen to have a link for the digital art project?

~~~
dahart
Of course. ;) I elaborated on harmonic mutations in a paper here:
[http://dahart.com/paper/hart_evomusart_2007_paper.pdf](http://dahart.com/paper/hart_evomusart_2007_paper.pdf)
and there's a gallery of images on Flickr:
[https://www.flickr.com/photos/biv4b/albums/576553](https://www.flickr.com/photos/biv4b/albums/576553)

~~~
FraKtus
Congratulations, really cool and innovative! Have you looked into ArtMatic and
how you can create a tree of functions ? It allows to create mutations that
give results very similar to yours.

~~~
dahart
I hadn't before, thanks for the tip! It's been a while since I played with
this stuff, but I might have to get a copy and explore. I have heard of
MetaSynth in audio circles. I'm not sure, but the images and videos on the
ArtMatic site look (to me) very inspired and influenced by the work of Karl
Sims, which is the main source of inspiration behind my project...
[http://www.karlsims.com/papers/siggraph91.html](http://www.karlsims.com/papers/siggraph91.html)

You can find a bunch of his videos on YouTube too.

[https://youtu.be/AgeuRukfZLE](https://youtu.be/AgeuRukfZLE)
[https://youtu.be/vIVjEkWTEXI](https://youtu.be/vIVjEkWTEXI)
[https://youtu.be/SLAa-CnUEW4](https://youtu.be/SLAa-CnUEW4)
[https://youtu.be/JBgG_VSP7f8](https://youtu.be/JBgG_VSP7f8)

~~~
FraKtus
Thank you for the link to the article! I know Eric Wenger the author of
MetaSynth / ArtMatic / Voyager since many years and his motivation to create
ArtMatic was to create textures to feed MetaSynth to create music from
visuals..

------
dansunciel
Refinable functions, used for constructing wavelets and subdivision schemes,
seem similar:
[https://en.wikipedia.org/wiki/Refinable_function](https://en.wikipedia.org/wiki/Refinable_function)
and [https://arxiv.org/abs/1012.2453](https://arxiv.org/abs/1012.2453)

------
contravariant
The definition of an exactly self replicating function seems to be any
function 'f' such that there are continuous bijections a,b,c such that f∘a +
f∘b = c∘f, and a does not equal b.

Edit: I think this includes all strictly quasi-concave functions, but I'm not
entirely sure.

~~~
tylerneylon
I think you're right. Your version of the definition is more elegantly stated,
and I may want to use it going forward, as long as a, b, and c still make
intuitive sense (thinking about that part).

~~~
contravariant
Feel free to use it. Using your notation you have a=t1, b=t1∘s, c=t2^-1.
Inversely you have s=a^-1∘b, t1=a, t2=c^-1.

------
szemet
Just if anyone interested: There are also sequences that are labelled
'fractal', those are fun too:

[https://oeis.org/A000120](https://oeis.org/A000120)

 _' An example of a fractal sequence. That is, if you omit every other number
in the sequence, you get the original sequence. And of course this can be
repeated. So if you form the sequence a(0 _ 2^n), a(1 * 2^n), a(2 * 2^n), a(3
* 2^n), ... (for any integer n > 0), you get the original sequence.' _

------
thadw
When I saw Figure 3 I was reminded of the New Zealand kidney fern, where the
veining is a very close approximation to that type of L-system, at least for
the first seven or so divisions. [http://www.terrain.net.nz/friends-of-te-
henui-group/nz-ferns...](http://www.terrain.net.nz/friends-of-te-henui-
group/nz-ferns/kidney-fern.html)

~~~
partycoder
You might also be interested in the monkey puzzle tree.

~~~
KGIII
[https://en.wikipedia.org/wiki/Araucaria_araucana](https://en.wikipedia.org/wiki/Araucaria_araucana)

It is indeed interesting.

------
falcor84
Based on the title, I imagined this would be about AWS Lambda functions.

I wonder if anyone tried simulating evolution using these. I suppose you could
even make the fitness be about earning money, e.g. solving captchas? Such that
if a function can't pay for its own upkeep it'd die off, while if it does well
it could spawn offspring.

------
ttd
What software did you use to create your figures? They look great.

~~~
tylerneylon
Thanks! The original source is custom js rendering to svg. The html version of
the article contains png files based on that output; the pdf version contains
vectorized versions. I got some solid design input from Mike Sall on the
images for this article.

Edit: example:
[https://github.com/tylerneylon/math/blob/master/self_repl_fn...](https://github.com/tylerneylon/math/blob/master/self_repl_fns/images/scratch/nonlinear_ramps.html)

------
tw1010
This reminds me of the concept of a "ring of functions" (albeit slightly more
constrained). Since you seem to be familiar with measure theory already, that
idea is probably already well known to you (the author), but I figured I'd
mention it anyway.

~~~
tylerneylon
I didn't know about that before. Looks very interesting (looking at wikipedia)
— thanks for mentioning it!

~~~
tw1010
I highly recommend learning abstract algebra thoroughly if you haven't
already, by the way. It's a lot more well connected and well researched than
you might think after just reading about this or that definition (groups,
rings, quotient rings, lattice of ideals) in a vacuum. The magic comes when
you mix all the definitions together. If you learn it correctly and master
both the rigour and intuition behind it all, you'll come to consider your pre-
abstract-algebra-self in the same Platonic cave as you might see your pre-
linear-algebra-self right now.

------
jon_richards
A while ago I thought about the fact that if you repeatedly apply f(x)=2+x/2
to a number, you approach 4. What happens if you repeatedly apply, with a
50/50 chance, either x/2 or x+2 to a distribution? What distribution do you
get?

I could find a lot of analysis using matrices in discrete math, but I couldn't
find much for continuous distributions. I haven't gotten all the way through
reading this, but it seems like it could be helpful.

~~~
JadeNB
This sounds quite a bit like a probabilistic version of the Collatz problem
([https://en.wikipedia.org/wiki/Collatz_conjecture](https://en.wikipedia.org/wiki/Collatz_conjecture)).
I thought I'd seen results on this before, but a quick Google result doesn't
turn anything up. (Instead, Google results want to discuss probabilistic
heuristics for why the deterministic Collatz conjecture holds.)

~~~
jon_richards
Hmm. Thanks for the thought. I'm not sure how related it is, but I might find
something in the attempted solutions.

The original idea behind this was to figure out how to study the stability of
certain probabilistic transformations. The hope was to be able to make
transformations that are good at detecting non-random inputs, particularly in
time-series data. Could potentially be used in a similar way to neural-nets.

------
pizza
Nice post!

If you're interested in future directions, or working off of research that
others might have generated while looking into similar questions, for the sake
of taking this idea (self-replicat'n functions) to that next level.. it would
be p interesting if you could use just a hint of the much-fabled _ｃａｔｅｇｏｒｙ
ｔｈｅｏｒｙ_ for the sake of generalization!

------
jepler
hm, now I wonder what happens if you take 'any old function', add it to a
reversed and shifted version of itself, and normalize. do you eventually get
one of these self-replicating functions, or are there functions that 'diverge'
under this treatment?

Taking a random array and giving it this treatment, I seem to get a gaussian
distribution after just a few (say, 100) iterations on a 100-element sequence,
shifted by 1/3 and then downsampled to be a 100-element sequence again). but
of course this is a global and downsampled view, the function might be very
craggy locally.

------
agumonkey
lovely class of functions, is it part of a math domain of research ?

~~~
tylerneylon
This is independent work. Probably fits in with fractals and L-systems.

~~~
agumonkey
So that was all you had in mind as a starting point ?

again, lovely article, got inspired by ti

~~~
tylerneylon
That's all the solid work I have so far. Tons of ideas for what could be next.
For example, consider convolutions on sets generated by L-systems (eg the
Cantor set). I suspect those might offer continuous, finitely-supported,
linearly-shifted self-replicating fns (the current article is mainly about
non-linear shifts; t_1 is only piecewise linear). Maybe L-systems even
completely characterize that category of self-replicating fns.

Other ideas: * Higher dimensions (eg f1 + f2 + f3 = g with domain R^2) *
Shifted fns f1, f2 whose sum has surprisingly small diff from their sum: ie
small |C(f1+f2)-shift(f1)|; the normal fn appears to fall into this category

~~~
agumonkey
as in elf similarity across projection, a R^n composition that ends up a as a
function on R^N-1 ?

------
wmnwmn
His first examples g1, g2 are not shifts of f. What am I missing.

~~~
tylerneylon
You're right that the g1 and g2 in section 2 are also scaled in addition to
being shifts of f. I plan to clarify this in the text.

This work is inspired by the self-similarity of fractals, which is in some
cases primarily an intuitive or informal idea: for example, the Mandelbrot set
is considered self-similar, but I'm not aware (despite searching) of any
simple automorphisms of the Mandelbrot.

~~~
gergoerdi
There's this local example in Wikipedia:
[https://en.wikipedia.org/wiki/Mandelbrot_set#/media/File:Man...](https://en.wikipedia.org/wiki/Mandelbrot_set#/media/File:Mandelbrot_zoom.gif)

------
tenaciousDaniel
Articles like this make me so sad, because it seems absolutely fascinating,
but I know nothing about math. I became a programmer later in life and never
got a solid education in it.

Beautiful visuals though, lol.

