Happy Coding

A simple and beautiful equation

These days Whatsapp “goes crazy” for Easter greetings. A greeting of all kinds, but this afternoon a friend sent me a very original photo with the Cartesian axes and an egg-shaped curve.
At the top was written “BUONA PASQUA!” and under the equation to draw the curve “x ^ 2 = -y ^ 2 / (1.25 + y / 5) ^ 2 + 1” (a deformed ellipse I think)
So I thought about using the equation to send you wishes for a day which represents a message of peace and hope for both believers of all religions and non-believers (for all people of good will), and I quickly wrote a very short and simple program in p5js.

Ciao!

This is the link to see the program in action:https://editor.p5js.org/mare/present/BYVelp6_z
and this is to see the code editor as well:https://editor.p5js.org/mare/sketches/BYVelp6_z

2 Likes

Oooh this is cool. The use of rotateY() to make it 3D is really clever, I’m going to have to steal that trick from you!

This reminds me of the happy cat equation. Apparently it’s designed to trick certain algorithms into arriving at the wrong (or at least sub-optimal) answer, and it happens to look like, well, a happy cat:

happy cat

You can google the title of the paper “HappyCat - A Simple Function Class Where Well-Known Direct Search Algorithms Do Fail” if you want to read all the details!

Thanks Kevin, your suggestion on the “spiteful” “HappyCat” class functions
opened a world to me!
In fact I had noticed a difficulty in “closing” the two
symmetrical halves of the egg graph, and at the end I chose a “step of y” parameter
that produced a decent chart.
But to determine this step I had to proceed trial and error because I could not understand the “law of improvement”.
I am NOT a mathematician, but to me mathematics is like a charming and perfect woman
painted in a picture.
I admire all the beauty of her, but she stays in the picture!
A greeting to the whole community