Average Error: 6.1 → 0.1
Time: 15.1s
Precision: binary64
Cost: 7360
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
\[\mathsf{fma}\left(y \cdot 4, t, x \cdot x + z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\right) \]
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
(FPCore (x y z t)
 :precision binary64
 (fma (* y 4.0) t (+ (* x x) (* z (* z (* y -4.0))))))
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) {
	return fma((y * 4.0), t, ((x * x) + (z * (z * (y * -4.0)))));
}
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)
	return fma(Float64(y * 4.0), t, Float64(Float64(x * x) + Float64(z * Float64(z * Float64(y * -4.0)))))
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_] := N[(N[(y * 4.0), $MachinePrecision] * t + N[(N[(x * x), $MachinePrecision] + N[(z * N[(z * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\mathsf{fma}\left(y \cdot 4, t, x \cdot x + z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\right)

Error

Target

Original6.1
Target6.1
Herbie0.1
\[x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right) \]

Derivation

  1. Initial program 6.1

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot 4, t, x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\right)} \]
  5. Final simplification0.1

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

Alternatives

Alternative 1
Error1.5
Cost2632
\[\begin{array}{l} t_1 := z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ t_2 := x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{if}\;t_2 \leq -3 \cdot 10^{+239}:\\ \;\;\;\;y \cdot \left(4 \cdot t\right) + t_1\\ \mathbf{elif}\;t_2 \leq 10^{+301}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error7.8
Cost1352
\[\begin{array}{l} t_1 := y \cdot \left(4 \cdot t\right)\\ \mathbf{if}\;z \cdot z \leq 4 \cdot 10^{-71}:\\ \;\;\;\;x \cdot x + t_1\\ \mathbf{elif}\;z \cdot z \leq 10^{+186}:\\ \;\;\;\;x \cdot x + \left(z \cdot z\right) \cdot \left(y \cdot -4\right)\\ \mathbf{else}:\\ \;\;\;\;t_1 + z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \end{array} \]
Alternative 3
Error7.7
Cost1232
\[\begin{array}{l} t_1 := x \cdot x + \left(z \cdot z\right) \cdot \left(y \cdot -4\right)\\ t_2 := z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \mathbf{if}\;z \leq -1 \cdot 10^{+150}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -5.982292274178094 \cdot 10^{-62}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.5884695087961294 \cdot 10^{-36}:\\ \;\;\;\;x \cdot x + y \cdot \left(4 \cdot t\right)\\ \mathbf{elif}\;z \leq 10^{+147}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error27.4
Cost1112
\[\begin{array}{l} t_1 := \left(y \cdot 4\right) \cdot t\\ \mathbf{if}\;x \leq -1.144215616297275 \cdot 10^{+38}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq -9.819463945390145 \cdot 10^{-45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.808366598262015 \cdot 10^{-124}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 2.9050936374770467 \cdot 10^{-136}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.026011181677652 \cdot 10^{-123}:\\ \;\;\;\;-4 \cdot \left(y \cdot \left(z \cdot z\right)\right)\\ \mathbf{elif}\;x \leq 3.806009017528787 \cdot 10^{-56}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 5
Error27.9
Cost1112
\[\begin{array}{l} t_1 := z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ t_2 := \left(y \cdot 4\right) \cdot t\\ \mathbf{if}\;x \leq -1.144215616297275 \cdot 10^{+38}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq -1.1074662465827733 \cdot 10^{-53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -3.618564010328473 \cdot 10^{-218}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.9050936374770467 \cdot 10^{-136}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 3.026011181677652 \cdot 10^{-123}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.806009017528787 \cdot 10^{-56}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 6
Error15.5
Cost1104
\[\begin{array}{l} t_1 := y \cdot \left(\left(z \cdot z - t\right) \cdot -4\right)\\ \mathbf{if}\;x \leq -1.144215616297275 \cdot 10^{+38}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 3.806009017528787 \cdot 10^{-56}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.224281303079908 \cdot 10^{-30}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 6006365075690575000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 7
Error8.1
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-52}:\\ \;\;\;\;x \cdot x + y \cdot \left(4 \cdot t\right)\\ \mathbf{elif}\;z \cdot z \leq 2 \cdot 10^{+279}:\\ \;\;\;\;y \cdot \left(\left(z \cdot z - t\right) \cdot -4\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \end{array} \]
Alternative 8
Error0.1
Cost1088
\[x \cdot x + \left(y \cdot \left(4 \cdot t\right) + z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\right) \]
Alternative 9
Error27.2
Cost848
\[\begin{array}{l} t_1 := \left(y \cdot 4\right) \cdot t\\ \mathbf{if}\;x \leq -1.144215616297275 \cdot 10^{+38}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq -9.819463945390145 \cdot 10^{-45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.808366598262015 \cdot 10^{-124}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 3.806009017528787 \cdot 10^{-56}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 10
Error41.5
Cost192
\[x \cdot x \]

Error

Reproduce

herbie shell --seed 2022308 
(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))))