# Fractalforums

## Fractal Software => Programming => Topic started by: Mr Rebooted on November 19, 2020, 02:54:34 PM

Title: How to implement Series Approximation in GLSL?
Post by: Mr Rebooted on November 19, 2020, 02:54:34 PM
I've seen that Perturbation Theory also comes with Series approximation. How would I implement this in OpenGL? (Using vec2 and stuff like that)
Title: Re: How to implement Series Approximation in GLSL?
Post by: claude on November 19, 2020, 04:10:05 PM
Start by implementing a function for complex multiplication.  Then look at Horner's form for polynomial evaluation.  You can pass small series in a uniform array, larger numbers of terms might be better in texture1d (not sure).  Also note that for higher order series you will want to rescale the coefficients and inputs, because they can get very big and small and can over/underflow.  Ideally you want all the values to be near 1.  gerrit explained that to me once on this forum but I didn't implement it yet, KF just uses floatexp for higher range to avoid the issue (at the cost of speed).

You can calculate the series coefficients on the CPU, it's sequential work so not worth doing on GPU.  You can use the low precision reference orbit (note: you need to compute the reference at high precision, but you can round it for the series calculation and perturbed iterations).  You need to check for "overskipping", KF does this by comparing perturbed iterations vs series approximation for "probe points" (8 points on the image boundary) and stopping before they diverge too much.

The formula for the series is at https://mathr.co.uk/blog/2016-03-06_simpler_series_approximation.html , not quite optimal (evaluating ab+ba is more costly than 2ab).
Title: Re: How to implement Series Approximation in GLSL?
Post by: sjhalayka on November 23, 2020, 10:45:25 PM
I have put up a small compute shader program example for you: