Average Error: 5.8 → 3.5
Time: 11.8s
Precision: binary64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
\[\begin{array}{l} \mathbf{if}\;z \leq -1.6331768204397996 \cdot 10^{+153}:\\ \;\;\;\;x \cdot x - \frac{4 \cdot \left(z + \sqrt{t}\right)}{\frac{\frac{1}{z - \sqrt{t}}}{y}}\\ \mathbf{elif}\;z \leq 2.5730812676030823 \cdot 10^{+126}:\\ \;\;\;\;x \cdot x - \left(4 \cdot y\right) \cdot \left(z \cdot z - t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - \left(z - \sqrt{t}\right) \cdot \left(\left(z + \sqrt{t}\right) \cdot \left(4 \cdot y\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 \leq -1.6331768204397996 \cdot 10^{+153}:\\
\;\;\;\;x \cdot x - \frac{4 \cdot \left(z + \sqrt{t}\right)}{\frac{\frac{1}{z - \sqrt{t}}}{y}}\\

\mathbf{elif}\;z \leq 2.5730812676030823 \cdot 10^{+126}:\\
\;\;\;\;x \cdot x - \left(4 \cdot y\right) \cdot \left(z \cdot z - t\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot x - \left(z - \sqrt{t}\right) \cdot \left(\left(z + \sqrt{t}\right) \cdot \left(4 \cdot y\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 -1.6331768204397996e+153)
   (- (* x x) (/ (* 4.0 (+ z (sqrt t))) (/ (/ 1.0 (- z (sqrt t))) y)))
   (if (<= z 2.5730812676030823e+126)
     (- (* x x) (* (* 4.0 y) (- (* z z) t)))
     (- (* x x) (* (- z (sqrt t)) (* (+ z (sqrt t)) (* 4.0 y)))))))
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 <= -1.6331768204397996e+153) {
		tmp = (x * x) - ((4.0 * (z + sqrt(t))) / ((1.0 / (z - sqrt(t))) / y));
	} else if (z <= 2.5730812676030823e+126) {
		tmp = (x * x) - ((4.0 * y) * ((z * z) - t));
	} else {
		tmp = (x * x) - ((z - sqrt(t)) * ((z + sqrt(t)) * (4.0 * y)));
	}
	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

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

Derivation

  1. Split input into 3 regimes
  2. if z < -1.6331768204397996e153

    1. Initial program 62.3

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

      \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \color{blue}{\frac{\left(z \cdot z\right) \cdot \left(z \cdot z\right) - t \cdot t}{z \cdot z + t}}\]
    4. Applied associate-*r/_binary64_1741164.0

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

      \[\leadsto x \cdot x - \frac{\color{blue}{\left(y \cdot 4\right) \cdot \left({z}^{4} - t \cdot t\right)}}{z \cdot z + t}\]
    6. Using strategy rm
    7. Applied clear-num_binary64_1746864.0

      \[\leadsto x \cdot x - \color{blue}{\frac{1}{\frac{z \cdot z + t}{\left(y \cdot 4\right) \cdot \left({z}^{4} - t \cdot t\right)}}}\]
    8. Simplified62.3

      \[\leadsto x \cdot x - \frac{1}{\color{blue}{\frac{\frac{1}{z \cdot z - t}}{4 \cdot y}}}\]
    9. Using strategy rm
    10. Applied add-sqr-sqrt_binary64_1749163.2

      \[\leadsto x \cdot x - \frac{1}{\frac{\frac{1}{z \cdot z - \color{blue}{\sqrt{t} \cdot \sqrt{t}}}}{4 \cdot y}}\]
    11. Applied difference-of-squares_binary64_1743863.2

      \[\leadsto x \cdot x - \frac{1}{\frac{\frac{1}{\color{blue}{\left(z + \sqrt{t}\right) \cdot \left(z - \sqrt{t}\right)}}}{4 \cdot y}}\]
    12. Applied add-sqr-sqrt_binary64_1749163.2

      \[\leadsto x \cdot x - \frac{1}{\frac{\frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\left(z + \sqrt{t}\right) \cdot \left(z - \sqrt{t}\right)}}{4 \cdot y}}\]
    13. Applied times-frac_binary64_1747561.4

      \[\leadsto x \cdot x - \frac{1}{\frac{\color{blue}{\frac{\sqrt{1}}{z + \sqrt{t}} \cdot \frac{\sqrt{1}}{z - \sqrt{t}}}}{4 \cdot y}}\]
    14. Applied times-frac_binary64_1747529.6

      \[\leadsto x \cdot x - \frac{1}{\color{blue}{\frac{\frac{\sqrt{1}}{z + \sqrt{t}}}{4} \cdot \frac{\frac{\sqrt{1}}{z - \sqrt{t}}}{y}}}\]
    15. Applied associate-/r*_binary64_1741329.5

      \[\leadsto x \cdot x - \color{blue}{\frac{\frac{1}{\frac{\frac{\sqrt{1}}{z + \sqrt{t}}}{4}}}{\frac{\frac{\sqrt{1}}{z - \sqrt{t}}}{y}}}\]
    16. Simplified29.4

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

    if -1.6331768204397996e153 < z < 2.5730812676030823e126

    1. Initial program 0.1

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]

    if 2.5730812676030823e126 < z

    1. Initial program 44.3

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

      \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - \color{blue}{\sqrt{t} \cdot \sqrt{t}}\right)\]
    4. Applied difference-of-squares_binary64_1743854.3

      \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \color{blue}{\left(\left(z + \sqrt{t}\right) \cdot \left(z - \sqrt{t}\right)\right)}\]
    5. Applied associate-*r*_binary64_1740931.9

      \[\leadsto x \cdot x - \color{blue}{\left(\left(y \cdot 4\right) \cdot \left(z + \sqrt{t}\right)\right) \cdot \left(z - \sqrt{t}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.6331768204397996 \cdot 10^{+153}:\\ \;\;\;\;x \cdot x - \frac{4 \cdot \left(z + \sqrt{t}\right)}{\frac{\frac{1}{z - \sqrt{t}}}{y}}\\ \mathbf{elif}\;z \leq 2.5730812676030823 \cdot 10^{+126}:\\ \;\;\;\;x \cdot x - \left(4 \cdot y\right) \cdot \left(z \cdot z - t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - \left(z - \sqrt{t}\right) \cdot \left(\left(z + \sqrt{t}\right) \cdot \left(4 \cdot y\right)\right)\\ \end{array}\]

Reproduce

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