Skip to content
Tayakorn
← All experiments
LAB.06RunningStarted

Drawing a sea wave with equations alone

What was tried

Ran the equations Hamid Naderi Yeganeh published for his Sea Wave image and measured how close the result gets to his original. The equations are written on the artwork itself and no text version could be found, so they were read off the image symbol by symbol and turned into a numpy script that renders 2000×1200 on the original grid. The whole image is one closed-form function with no if anywhere: every condition is a step written as e^(−e^(kx)) with a very large k, the wave is 60 stacked layers with the product ∏(1−J) acting as a z-buffer, and the foam is 17 octaves of cosine noise. The playable version in this entry is a shader that runs the same equations on the GPU of whatever device opens the page: F, how many layers are drawn, the values once suspected of being misread, the step steepness k and the foam octaves can all be changed, and the image and the F(x) chart follow. The original is his work and is not reproduced here; every image in this entry is drawn from these equations.

The full equations

Transcribed from the formulas Hamid Naderi Yeganeh printed on his Sea Wave image, reordered from the pixel colour down to the smallest parts. Every function takes (x, y); the arguments are left out.

  1. pixel⁡(m,n)=rgb⁡(F(H0),F(H1),F(H2)),x=m−14001000,y=801−n1000\operatorname{pixel}(m,n)=\operatorname{rgb}\big(F(H_0),\,F(H_1),\,F(H_2)\big),\qquad x=\frac{m-1400}{1000},\quad y=\frac{801-n}{1000}

    A 2000×1200 image · column m = 1…2000, row n = 1…1200 · the three channels are one equation at v = 0, 1, 2

  2. F(x)=⌊255e−e−1000x|x|e−e1000(x−1)⌋F(x)=\left\lfloor 255\,e^{-e^{-1000x}}\,|x|^{e^{-e^{1000(x-1)}}}\right\rfloor

    Turns a value of H into a colour, 0–255 · the first transcription dropped the e^(−…) around the exponent of |x|, which is why that image came out white · the playable version in this entry opens with clamp(255x), within 1/255 of this F

  3. Hv=(Lvv2+v+1420+3v2−3v+1620(1+y10)∏s=−950(1−Js))(1−R70)+R70(1−310R−5−310E0)(y10+91100+130(x−12)2)\begin{aligned}H_v={}&\left(L_v\,\frac{v^2+v+14}{20}+\frac{3v^2-3v+16}{20}\left(1+\frac{y}{10}\right)\prod_{s=-9}^{50}\left(1-J_s\right)\right)\left(1-R_{70}\right)\\&+R_{70}\left(1-\frac{3}{10}R_{-5}-\frac{3}{10}E_0\right)\left(\frac{y}{10}+\frac{91}{100}+\frac{1}{30}\left(x-\frac{1}{2}\right)^2\right)\end{aligned}

    Water (L) and sky, separated by the mask R₇₀

  4. Lv=∑s=−950[(∏u=−10s−1(1−Ju))Js(920+13−3(v−1)22000s+110cos⁡(s2))⋅(1+25cos⁡((127+30cos⁡(s))Cs)Ts+15cos⁡((92+20cos⁡(3s))Cs)Ws)]\begin{aligned}L_v=\sum_{s=-9}^{50}\Bigg[{}&\left(\prod_{u=-10}^{s-1}\left(1-J_u\right)\right)J_s\left(\frac{9}{20}+\frac{13-3(v-1)^2}{2000}\,s+\frac{1}{10}\cos(s^2)\right)\\&\cdot\left(1+\frac{2}{5}\cos\big((127+30\cos(s))\,C_s\big)\,T_s+\frac{1}{5}\cos\big((92+20\cos(3s))\,C_s\big)\,W_s\right)\Bigg]\end{aligned}

    Paints layer by layer, s = −9…50 · the product ∏(1 − J_u) acts as a z-buffer: the first layer covering a pixel sets its colour

  5. Ts=cos⁡((12+4cos⁡(4s))Ks+2cos⁡(6s))T_s=\cos\big((12+4\cos(4s))\,K_s+2\cos(6s)\big)
  6. Ws=cos⁡((14+5cos⁡(5s))Ks+2cos⁡(16s))W_s=\cos\big((14+5\cos(5s))\,K_s+2\cos(16s)\big)
  7. Js=exp⁡(−e−5000(s+192)−e|400Cs+2cos⁡((17+4cos⁡(14s))Ks+2cos⁡(16s))+2cos⁡((25+6cos⁡(10s))Ks+2cos⁡(19s))−560+8s|−40)⋅(1−exp⁡(−e500(x+85−12(50−s75)2+Ps2−50−s50)−e500Us))\begin{aligned}J_s={}&\exp\!\left(-e^{-5000\left(s+\frac{19}{2}\right)}-e^{\left|400C_s+2\cos\big((17+4\cos(14s))\,K_s+2\cos(16s)\big)+2\cos\big((25+6\cos(10s))\,K_s+2\cos(19s)\big)-560+8s\right|-40}\right)\\&\cdot\left(1-\exp\!\left(-e^{500\left(x+\frac{8}{5}-\frac{1}{2}\left(\frac{50-s}{75}\right)^2+\frac{P_s}{2}-\frac{50-s}{50}\right)-e^{500U_s}}\right)\right)\end{aligned}

    Wave layer s · no if anywhere, every condition is a step e^(−e^(kx)) · the term e^(−5000(s + 19/2)) makes J_s = 0 for every s ≤ −10

  8. Rv=exp⁡(−exp⁡(v(|y−910+13(x−12)2|−14+5310E0+110E1)))R_v=\exp\!\left(-\exp\!\left(v\left(\left|y-\frac{9}{10}+\frac{1}{3}\left(x-\frac{1}{2}\right)^2\right|-\frac{1}{4}+\frac{53}{10}E_0+\frac{1}{10}E_1\right)\right)\right)

    The sky and foam-edge mask

  9. Cs=(3+s50)|Us|74+70+s300Vs+90+s200Vs2C_s=\left(3+\frac{s}{50}\right)|U_s|^{\frac{7}{4}+\frac{70+s}{300}V_s}+\frac{90+s}{200}\,V_s^2
  10. Vs=Qs+Ps2V_s=Q_s+\frac{P_s}{2}
  11. Us=Ps−Qs2U_s=P_s-\frac{Q_s}{2}
  12. Ks=arctan⁡(1000Ps1+1000|Qs|)K_s=\arctan\left(\frac{1000P_s}{1+1000|Q_s|}\right)
  13. Ps=y−50−s700+150cos⁡(7s)P_s=y-\frac{50-s}{700}+\frac{1}{50}\cos(7s)
  14. Qs=x+710−50−s75+150cos⁡(5s)Q_s=x+\frac{7}{10}-\frac{50-s}{75}+\frac{1}{50}\cos(5s)
  15. Ev=∑s=1173+57v200(2320−v10)−sNv,sE_v=\sum_{s=1}^{17}\frac{3+57v}{200}\left(\frac{23}{20}-\frac{v}{10}\right)^{-s}N_{v,s}

    Foam noise, summed over 17 frequencies

  16. Nv,s=cos⁡((15−3v)s10−s(1+3cos⁡(10s))(cos⁡(2s2)x+sin⁡(2s2)y)+6cos⁡((420−84v)s250−s(cos⁡(7s2)x+sin⁡(7s2)y))+2cos⁡(5s))×cos⁡((15−3v)s10−s(1+3cos⁡(10s))(cos⁡(2s2)y−sin⁡(2s2)x)+6cos⁡((420−84v)s250−s(cos⁡(8s2)x+sin⁡(8s2)y))+2cos⁡(5s))\begin{aligned}N_{v,s}={}&\cos\!\Big((15-3v)^s\,10^{-s}\,(1+3\cos(10s))\,\big(\cos(2s^2)\,x+\sin(2s^2)\,y\big)\\&\qquad+6\cos\big((420-84v)^s\,250^{-s}\,(\cos(7s^2)\,x+\sin(7s^2)\,y)\big)+2\cos(5s)\Big)\\&\times\cos\!\Big((15-3v)^s\,10^{-s}\,(1+3\cos(10s))\,\big(\cos(2s^2)\,y-\sin(2s^2)\,x\big)\\&\qquad+6\cos\big((420-84v)^s\,250^{-s}\,(\cos(8s^2)\,x+\sin(8s^2)\,y)\big)+2\cos(5s)\Big)\end{aligned}
 Starting values
F — the last step, value to colour

Real H values sit inside the shaded band · the F missing an e^(−…) pushes nearly the whole band to 255, so the image turns white

012825500.51
Point at the chart or use the arrow keys to read values · shaded band = the H range that actually occurs, 0.106–1.196
F at sample H values
HF
-0.20
0.125
0.376
0.5127
0.8204
0.95242
1.2255
Painting layer by layer

The front layer is s = −9 · ∏(1−J) lets the first layer covering a pixel decide its colour, so later layers only show where nothing is in front

50 · 60/60
Hypotheses already tested — all failed

Three places once suspected of being misread · watch the right edge, where more sky shows than in the original

400
Published: 400
40
Published: 40
The machinery without an if

Every 'if' in the equations is written as e^(−e^(kx)) · smaller k, softer edges · fewer octaves, smoother foam

×1.00
k = 500 · 1000 · 5000
17/17
LAB.06 — A shader runs the same equations as render.py on the GPU of whatever device opens this page · it opens at the starting values: the published constants with F as clamp · measured on the author's integrated GPU at 2000×1200: 99.65% of pixels match render.py exactly and the rest differ by at most 1 per colour channel · the original image is not on this page, so there is no live similarity figure
  1. An almost entirely white frame, with only a faint trace of foam in the top-left corner
    ROUND 01Dropped

    F as first transcribed, missing an e^(−…) — the whole image collapses to 4 colours, almost all white

  2. A blue-grey wave rising from lower left to upper right, its surface in dense curved ripples and its crest broken into steps, white foam over a pale lavender sky
    ROUND 02Kept

    F as clamp(255x) — sky, foam and ripples all appear, but the right edge shows more sky than the original

LAB.06 — Each frame is labelled kept or dropped · the reason sits underneath it

What was learned

The hardest knot was F(x), the last step that turns a value into a colour. The first transcription read its second factor as |x|^(e^(1000(x−1))) and gave a 4-colour image that is almost entirely white: the real H values sit between 0.106 and 1.196, and across nearly all of that range that term is about 1, which suggested a whole e^(−…) layer had been dropped, not a single minus sign. But the rendered image could only say the first reading was wrong, not which reading is right: clamp(255x) and wrapping the exponent in one more e^(−…) both give 15,552 colours and differ by at most 1/255 on just 9 pixels, invisible to the eye. The answer came from zooming into the original again (17 Sep 2026): the exponent of |x| is e^(−e^(1000(x−1))), as suspected, and the other 15 equations match the transcription exactly. Moved onto the GPU, the colours match numpy exactly on 99.65% of pixels at 2000×1200 and differ by at most 1 per channel on the rest (measured on the author's integrated GPU); the float32 GPU needed exponents clamped at ±80 instead of ±700 (e^700 overflows float32), which leaves the steps unchanged.

What fell short

Compared pixel by pixel with the original, 89.6% matches and 10.4% does not (mean colour difference 28 out of 765). Sky covers 32.3% of the original and 41.4% of the render; the left edge is nearly exact (strip x 0–250: 64.2% in the original, 64.6% rendered) but the right edge drifts (strip x 1750–2000: 2.3% vs 16.7%), because on the positive-x side |U_s| grows toward 1, C_s settles near 3, 400·C_s lands near 1200, well outside ±40 of 560 − 8s, and no wave layer attaches there. Three hypotheses that the equations were misread were tested: swapping U and V (worse), moving the 400 multiplier on C_s across 150–500, and moving the ±40 threshold across 40–120. All three failed. Zooming into the original again line by line (17 Sep 2026) found every equation matches the transcription except F, and the clamp used for rendering differs from the true F by at most 1/255, so the right-edge drift does not come from a misreading; why a render of the printed equations differs from his picture is still unknown. The constants were not bent to make the picture closer: this entry measures the published equations, it does not fit the image.

Line of experiments

  1. LAB.06 Drawing a sea wave with equations alone (this entry)
  2. LAB.08 Drawing an active volcano with equations alone