sin(x+t)/(0.4+0.4*abs(sin(x+t)))

Rounded Cosine: cos(x) / (0.4 + 0.4|cos(x)|)

Explaining \( f(x) = \dfrac{\cos(x)}{0.4 + 0.4\,|\cos(x)|} \)

This page explains the wave-shaping idea behind dividing cos(x) by a term that depends on its own magnitude.

Target function:

\\[ f(x) = \frac{\cos(x)}{0.4 + 0.4\,\lvert \cos(x)\rvert} \\]

Value ranges: \( \cos(x)\in[-1,1] \) and \( 0.4 + 0.4\,|\cos(x)| \in [0.4,\,0.8] \).

1) Numerator: \( \cos(x) \)

The base signal is a standard cosine: period \(2\pi\) and amplitude within \([-1,1]\).

2) Denominator: \( 0.4 + 0.4\,|\cos(x)| \)

Because \( |\cos(x)| \in [0,1] \), the denominator varies smoothly between 0.4 (when \( \cos(x)=0 \)) and 0.8 (when \( |\cos(x)|=1 \)).

3) Net Effect (Wave Rounding)

Where \( |\cos(x)| \) is large (near peaks/valleys), the denominator is larger, so the output is pushed smaller.

Where \( |\cos(x)| \) is small (near zero crossings), the denominator is smaller, so the output is slightly larger.

This redistributes amplitude and visually “rounds” the sharp crests and troughs of a cosine—handy for shader aesthetics.

4) Intuition

Think of it as a gentle, signal-dependent normalization: the wave compresses more at extremes and less around zero, yielding a smoother, more rounded profile.

5) Notes for Shaders

  • Use directly as a fragment-space curve or to modulate color/normal intensity.
  • To adjust the rounding strength, replace 0.4 by a parameter \(a\in(0,1]\): \( \cos(x)/(a+a|\cos x|) \).
  • Clamp \(a\) away from zero to avoid division blow-ups.



https://graphtoy.com/?f1(x,t)=sin(x+t)%20/%20(0.4%20+%200.4%20*%20abs(sin(x+t)))&v1=true&f2(x,t)=&v2=true&f3(x,t)=&v3=true&f4(x,t)=&v4=true&f5(x,t)=&v5=true&f6(x,t)=&v6=true&grid=1&coords=0,0,10.909090909090908




© 2025 — Math and text by request. Typeset with MathJax.

Comments

Popular posts from this blog

Japan Jazz Anthology Select: Jazz of the SP Era

In practice, the most workable approach is to measure a composite “civility score” built from multiple indicators.