# Not quite a wave

Sometimes you’re just minding your own business, trying to get a little science done, and a little art pops out at you all unexpected.

What?!? You want to know where this comes from? All is revealed beneath the fold…

The dotted line is, not surprisingly, the sine function plotted from about -10 to +15. The dashed line is a crazy rational function evolved using genetic programming. The bold line shows where the test data came from that was used to evaluate the quality of the evolved solutions, and it’s clear that in that range the evolved function matches very closely.

It’s also clear that outside of that range (which was never part of the evolutionary training), the evolved function rapidly wanders off into its own happy place (including a nifty discontinuity at around x=10). This is in fact to be expected. The GP system was only allowed to use +, *, -, and /, i.e., all it could construct were rational functions. There are no rational functions that match sine across its entire range, so this is really about as good as we could do given those tools. If we’d given the GP system a periodic function (like cosine) in its toolkit, then it could potentially evolve something that would match sine everywhere. With rational functions, though, it just ain’t gonna happen.

But this graph looks a lot cooler than it would if they matched everywhere :-).

Oh?

The function that it actually evolved?

You sure you want to see that?

Well, OK…

$x\over{-a\times x \over {x \over x - b} + x + x \times (x - c)} - {x^2 \over \left( {2 \over x} + x \right) \times \left(d - {x^2 \over e} \right)}$
where

• a = 2.76609789995
• b = 10.240744822
• c = 3.9532436939
• d = 3.20011637632
• e = 12.6508398844

I never promised it would make a lot of sense, did I? Evolution often doesn’t produce pretty. So much for intelligent design…

## One thought on “Not quite a wave”

1. heuermh says:

I think evolution does produce pretty. Not optimal, but surely pretty, especially when sexual reproduction is involved. :)

Looks like you need a fitness function that measures the “pretty” of a math equation. Balance and symmetry might be good features to consider.

Comments are closed.