Skip to content

Instantly share code, notes, and snippets.

@notwa
Last active January 5, 2021 18:02
Show Gist options
  • Save notwa/5c5bab21e800386c9ec178808660a1d8 to your computer and use it in GitHub Desktop.
Save notwa/5c5bab21e800386c9ec178808660a1d8 to your computer and use it in GitHub Desktop.
stuff i've plotted in desmos

stuff i've plotted in desmos

in some order idk

the two nonlinearities involved in (a scalar version of) converting RGB to CIELAB.

f(x) converts RGB to linear sRGB. g(x) is used in converting linear sRGB to XYZ. the black line is the combination of the two, not quite linear.

playing around with the magnitude responses of biquads with a0=b0=1.

for the blue line, one unit on the Y axis is roughly equivalent to six decibels.

playing around with polynomials in reflected form.

see also: https://www.dsprelated.com/freebooks/filters/Computing_Reflection_Coefficients_Check.html

a smoothly rectified sine function, with a barrage of zeros in its derivatives at x=±1.

g(x) is a transformation of f'(x), and is not quite linear within -1≤x≤1. these functions are periodic.

playing around with cubic regularization for minimizing a function sampled by finite difference.

a fairly accurate approximation of the viridis colormap, implemented as a polynomial divided by a polynomial. more accurate than the one i found on shadertoy, and probably not slower. optimized to minimize peak error, not mean-square-error.

the analytic cumulative distribution function of a single-sided, translated smoothstep function. can be used to sample with a PDF in the stape of smoothstep. if you use this, you will want to flip a coin to decide whether to flip the signs, since this is single-sided.

an alternative, less direct method of sampling from a smoothstep distribution. this is based on the paper, "Can’t Invert the CDF? The Triangle-Cut Parameterization of the Region under the Curve". note that you actually can invert the CDF for this distribution; i just wanted to try out this new method and see how it compared to the old analytic method.

a half-metric for a rescaled rosenbrock "banana" function, for use with the Deterministic Optimistic Optimization (DOO) algorithm, from the paper, "Optimistic Optimization of a Deterministic Function without the Knowledge of its Smoothness"

same as above but for the ridgecircle function.

a visual demonstration of the activation function for a convnet-based game of life. TODO: what paper is this from?

drag around the black points. the linear line turns red when the function is deemed non-convex, based on the function values at the two points.

field of view equations for rectilinear projection, with the near-field visualized.

drag around the points and change m0 and m1 to control the position and slopes of the spline, respectively.

a simple plot of the various smooth-union operators suggested by IQ.

four exact, pre-defined sigma parameters for gaussian distributions, which scale certain peaks in the PDF (or one of two derivatives) to unity.

drag around the three points to see how their circumcircle is affected. sorry, i never finished simplifying the math here.

not closed form, sorry. drag the points around like it's a jumprope.

i didn't name this function; i have no idea if or how it relates to a diode. the red line (the line of interest) is actually just the 12th order smoothstep.

btw, you can find smoothstep coefficients for any order by the triangular table of this integer sequence: OEIS A091811

punching it into wolfram (try changing n)

refer to shadertoy:

approximating tanh by taking its continued fraction form and (externally) optimizing the constants. probably not useful.

a polynomial approximation of a scaled tanh function made with the excellent lolremez.

i forget where i read about this but basically you can approximate e^(-2/x) by (x-1)/(x+1) when x is large.

the black line shows the absolute error.

trying to design a cheap-to-compute gain curve for a dynamic range compressor. this thing uses just one division. iirc it didn't wind up being all that useful.

both axes are in power decibels. note that it acts as a gate under -70 dB.

trying to compute abs(x) by polynomials, or something. weird stuff.

i used this to help design turnspeed smoothing in my zdoom patch.

note to self: i think i have a more recent version of that patch lying around somewhere.

messing around with a variations of Tukey's Biweight? i think the only reason i kept this around was 'cause it's fun to watch animated.

something something windowing functions i dunno.

simple case of a SGDR curve. i just kept this around 'cause the logarithmic plot complements the linear plot in a kinda cool way.

self-explanitory.

it's SELU!

GELU activation alongside an approximation i lifted off reddit or someplace.

approximate gaussian stuff, with inversions and integrals.

possibly useful functions for squishing values. mostly based on sigmoidal functions.

approximating a quadrant of sin(x) with a polynomial and a LUT.

some fun curves relating to unit circles.

it's just Archimedes' Spiral, plus some related functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment