Guys, those Douglas-Peucker guys (sorry Ramer, I didn’t know about you) have worked on this
using GMT
x = LinRange(0,2π, 10_000);
y = @. 2x * sin(x)^2 + 4x * cos(2x)^4;
xy = gmtsimplify([x y], tol=0.005);
imshow(xy, marker=:point, lw=0.5, figsize=(12,12), title="Douglas-Peucker ($(size(xy,1)) points)")