Average Error: 6.0 → 3.2
Time: 6.3s
Precision: binary64
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.3323133106492984 \cdot 10^{154}:\\ \;\;\;\;\left(x \cdot x - z \cdot \left(\left(y \cdot 4\right) \cdot \left(z + \sqrt{t}\right)\right)\right) - \left(\left(y \cdot 4\right) \cdot \left(z + \sqrt{t}\right)\right) \cdot \left(-\sqrt{t}\right)\\ \mathbf{elif}\;z \le 1.12072093876105296 \cdot 10^{145}:\\ \;\;\;\;x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - \left(\left(\left(y \cdot 4\right) \cdot \left(z + \sqrt{t}\right)\right) \cdot \sqrt{z - \sqrt{t}}\right) \cdot \sqrt{z - \sqrt{t}}\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.0
Target6.0
Herbie3.2
\[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.3323133106492984e+154

    1. Initial program 64.0

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

      \[\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-squares64.0

      \[\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*31.0

      \[\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)}\]
    6. Using strategy rm
    7. Applied sub-neg31.0

      \[\leadsto x \cdot x - \left(\left(y \cdot 4\right) \cdot \left(z + \sqrt{t}\right)\right) \cdot \color{blue}{\left(z + \left(-\sqrt{t}\right)\right)}\]
    8. Applied distribute-lft-in31.0

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

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

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

    if -1.3323133106492984e+154 < z < 1.120720938761053e+145

    1. Initial program 0.1

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

    if 1.120720938761053e+145 < z

    1. Initial program 57.5

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

      \[\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-squares61.0

      \[\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*32.4

      \[\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)}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt32.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.3323133106492984 \cdot 10^{154}:\\ \;\;\;\;\left(x \cdot x - z \cdot \left(\left(y \cdot 4\right) \cdot \left(z + \sqrt{t}\right)\right)\right) - \left(\left(y \cdot 4\right) \cdot \left(z + \sqrt{t}\right)\right) \cdot \left(-\sqrt{t}\right)\\ \mathbf{elif}\;z \le 1.12072093876105296 \cdot 10^{145}:\\ \;\;\;\;x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - \left(\left(\left(y \cdot 4\right) \cdot \left(z + \sqrt{t}\right)\right) \cdot \sqrt{z - \sqrt{t}}\right) \cdot \sqrt{z - \sqrt{t}}\\ \end{array}\]

Reproduce

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