Average Error: 6.1 → 0.2
Time: 9.1s
Precision: binary64
Cost: 1537
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 1.1176245341763669 \cdot 10^{+297}:\\ \;\;\;\;x \cdot x - \left(y \cdot \left(t \cdot -4\right) + \left(z \cdot z\right) \cdot \left(y \cdot 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\ \end{array}\]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 1.1176245341763669 \cdot 10^{+297}:\\
\;\;\;\;x \cdot x - \left(y \cdot \left(t \cdot -4\right) + \left(z \cdot z\right) \cdot \left(y \cdot 4\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\

\end{array}
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
(FPCore (x y z t)
 :precision binary64
 (if (<= (* z z) 1.1176245341763669e+297)
   (- (* x x) (+ (* y (* t -4.0)) (* (* z z) (* y 4.0))))
   (- (* 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) {
	double tmp;
	if ((z * z) <= 1.1176245341763669e+297) {
		tmp = (x * x) - ((y * (t * -4.0)) + ((z * z) * (y * 4.0)));
	} else {
		tmp = (x * x) - (z * (z * (y * 4.0)));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Alternatives

Alternative 1
Error0.2
Cost1088
\[x \cdot x - \left(y \cdot \left(t \cdot -4\right) + z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\right)\]
Alternative 2
Error0.1
Cost1281
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 1.1176245341763669 \cdot 10^{+297}:\\ \;\;\;\;x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\ \end{array}\]
Alternative 3
Error7.0
Cost2500
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 2.1112733160038397 \cdot 10^{-85}:\\ \;\;\;\;x \cdot x + y \cdot \left(t \cdot 4\right)\\ \mathbf{elif}\;z \cdot z \leq 3.726563230844544 \cdot 10^{-38}:\\ \;\;\;\;x \cdot x - \left(z \cdot z\right) \cdot \left(y \cdot 4\right)\\ \mathbf{elif}\;z \cdot z \leq 1.2097206389561111 \cdot 10^{+21}:\\ \;\;\;\;x \cdot x + y \cdot \left(t \cdot 4\right)\\ \mathbf{elif}\;z \cdot z \leq 4.169555110572424 \cdot 10^{+72}:\\ \;\;\;\;y \cdot \left(-4 \cdot \left(z \cdot z - t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\ \end{array}\]
Alternative 4
Error11.2
Cost904
\[\begin{array}{l} \mathbf{if}\;x \leq -0.31494806243018536 \lor \neg \left(x \leq 5.65756512641683 \cdot 10^{-47}\right):\\ \;\;\;\;x \cdot x + y \cdot \left(t \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-4 \cdot \left(z \cdot z - t\right)\right)\\ \end{array}\]
Alternative 5
Error15.7
Cost904
\[\begin{array}{l} \mathbf{if}\;x \leq -2.1443810186746414 \cdot 10^{+54} \lor \neg \left(x \leq 2.8897216281371824 \cdot 10^{+39}\right):\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-4 \cdot \left(z \cdot z - t\right)\right)\\ \end{array}\]
Alternative 6
Error27.5
Cost1604
\[\begin{array}{l} \mathbf{if}\;x \leq -0.09662812088304433:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq -3.7502015261340084 \cdot 10^{-165}:\\ \;\;\;\;y \cdot \left(t \cdot 4\right)\\ \mathbf{elif}\;x \leq -4.344082954146494 \cdot 10^{-277}:\\ \;\;\;\;-4 \cdot \left(\left(z \cdot z\right) \cdot y\right)\\ \mathbf{elif}\;x \leq 2.8897216281371824 \cdot 10^{+39}:\\ \;\;\;\;y \cdot \left(t \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array}\]
Alternative 7
Error25.7
Cost648
\[\begin{array}{l} \mathbf{if}\;x \leq -0.1085978784158788 \lor \neg \left(x \leq 2.8897216281371824 \cdot 10^{+39}\right):\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(t \cdot 4\right)\\ \end{array}\]
Alternative 8
Error41.1
Cost192
\[x \cdot x\]
Alternative 9
Error60.5
Cost64
\[0\]
Alternative 10
Error61.5
Cost64
\[1\]

Error

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 z z) < 1.11762453417636693e297

    1. Initial program 0.1

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
    2. Using strategy rm
    3. Applied sub-neg_binary64_174620.1

      \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \color{blue}{\left(z \cdot z + \left(-t\right)\right)}\]
    4. Applied distribute-rgt-in_binary64_174190.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)}\]
    5. Simplified0.1

      \[\leadsto x \cdot x - \left(\color{blue}{\left(y \cdot 4\right) \cdot \left(z \cdot z\right)} + \left(-t\right) \cdot \left(y \cdot 4\right)\right)\]
    6. Simplified0.2

      \[\leadsto x \cdot x - \left(\left(y \cdot 4\right) \cdot \left(z \cdot z\right) + \color{blue}{y \cdot \left(t \cdot -4\right)}\right)\]
    7. Simplified0.2

      \[\leadsto \color{blue}{x \cdot x - \left(y \cdot \left(t \cdot -4\right) + \left(z \cdot z\right) \cdot \left(y \cdot 4\right)\right)}\]

    if 1.11762453417636693e297 < (*.f64 z z)

    1. Initial program 59.3

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
    2. Using strategy rm
    3. Applied sub-neg_binary64_1746259.3

      \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \color{blue}{\left(z \cdot z + \left(-t\right)\right)}\]
    4. Applied distribute-rgt-in_binary64_1741959.3

      \[\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)}\]
    5. Simplified59.3

      \[\leadsto x \cdot x - \left(\color{blue}{\left(y \cdot 4\right) \cdot \left(z \cdot z\right)} + \left(-t\right) \cdot \left(y \cdot 4\right)\right)\]
    6. Simplified59.3

      \[\leadsto x \cdot x - \left(\left(y \cdot 4\right) \cdot \left(z \cdot z\right) + \color{blue}{y \cdot \left(t \cdot -4\right)}\right)\]
    7. Using strategy rm
    8. Applied associate-*r*_binary64_174090.3

      \[\leadsto x \cdot x - \left(\color{blue}{\left(\left(y \cdot 4\right) \cdot z\right) \cdot z} + y \cdot \left(t \cdot -4\right)\right)\]
    9. Taylor expanded around inf 59.4

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

      \[\leadsto x \cdot x - \color{blue}{z \cdot \left(\left(y \cdot 4\right) \cdot z\right)}\]
    11. Simplified0.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot z \leq 1.1176245341763669 \cdot 10^{+297}:\\ \;\;\;\;x \cdot x - \left(y \cdot \left(t \cdot -4\right) + \left(z \cdot z\right) \cdot \left(y \cdot 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\ \end{array}\]

Reproduce

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