Average Error: 5.5 → 0.3
Time: 6.0s
Precision: binary64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
\[\begin{array}{l} t_1 := \mathsf{fma}\left(x, x, z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\right)\\ \mathbf{if}\;z \leq -1.1783638165363816 \cdot 10^{+89}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.1474743947097236 \cdot 10^{+139}:\\ \;\;\;\;\mathsf{fma}\left(y, -4 \cdot \mathsf{fma}\left(z, z, -t\right), x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (fma x x (* z (* z (* y -4.0))))))
   (if (<= z -1.1783638165363816e+89)
     t_1
     (if (<= z 2.1474743947097236e+139)
       (fma y (* -4.0 (fma z z (- t))) (* x x))
       t_1))))
double code(double x, double y, double z, double t) {
	return (x * x) - ((y * 4.0) * ((z * z) - t));
}
double code(double x, double y, double z, double t) {
	double t_1 = fma(x, x, (z * (z * (y * -4.0))));
	double tmp;
	if (z <= -1.1783638165363816e+89) {
		tmp = t_1;
	} else if (z <= 2.1474743947097236e+139) {
		tmp = fma(y, (-4.0 * fma(z, z, -t)), (x * x));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t)))
end
function code(x, y, z, t)
	t_1 = fma(x, x, Float64(z * Float64(z * Float64(y * -4.0))))
	tmp = 0.0
	if (z <= -1.1783638165363816e+89)
		tmp = t_1;
	elseif (z <= 2.1474743947097236e+139)
		tmp = fma(y, Float64(-4.0 * fma(z, z, Float64(-t))), Float64(x * x));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * x + N[(z * N[(z * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.1783638165363816e+89], t$95$1, If[LessEqual[z, 2.1474743947097236e+139], N[(y * N[(-4.0 * N[(z * z + (-t)), $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\begin{array}{l}
t_1 := \mathsf{fma}\left(x, x, z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\right)\\
\mathbf{if}\;z \leq -1.1783638165363816 \cdot 10^{+89}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 2.1474743947097236 \cdot 10^{+139}:\\
\;\;\;\;\mathsf{fma}\left(y, -4 \cdot \mathsf{fma}\left(z, z, -t\right), x \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original5.5
Target5.5
Herbie0.3
\[x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right) \]

Derivation

  1. Split input into 2 regimes
  2. if z < -1.178363816536382e89 or 2.14747439470972363e139 < z

    1. Initial program 39.0

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Simplified39.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \left(z \cdot z - t\right) \cdot -4, x \cdot x\right)} \]
    3. Applied egg-rr39.1

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{fma}\left(z, z, -t\right)} \cdot -4, x \cdot x\right) \]
    4. Taylor expanded in t around 0 40.4

      \[\leadsto \color{blue}{{x}^{2} - 4 \cdot \left(y \cdot {z}^{2}\right)} \]
    5. Simplified1.7

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\right)} \]

    if -1.178363816536382e89 < z < 2.14747439470972363e139

    1. Initial program 0.1

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Simplified0.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \left(z \cdot z - t\right) \cdot -4, x \cdot x\right)} \]
    3. Applied egg-rr0.1

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{fma}\left(z, z, -t\right)} \cdot -4, x \cdot x\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.1783638165363816 \cdot 10^{+89}:\\ \;\;\;\;\mathsf{fma}\left(x, x, z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\right)\\ \mathbf{elif}\;z \leq 2.1474743947097236 \cdot 10^{+139}:\\ \;\;\;\;\mathsf{fma}\left(y, -4 \cdot \mathsf{fma}\left(z, z, -t\right), x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, x, z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022148 
(FPCore (x y z t)
  :name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
  :precision binary64

  :herbie-target
  (- (* x x) (* 4.0 (* y (- (* z z) t))))

  (- (* x x) (* (* y 4.0) (- (* z z) t))))