\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\]
↓
\[\begin{array}{l}
t_1 := t - z \cdot z\\
t_2 := x \cdot x + \left(y \cdot 4\right) \cdot t_1\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;x \cdot x - {\left(z \cdot \left(\sqrt{y} \cdot 2\right)\right)}^{2}\\
\mathbf{elif}\;t_2 \leq 10^{+306}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot 4, t_1, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;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
(let* ((t_1 (- t (* z z))) (t_2 (+ (* x x) (* (* y 4.0) t_1))))
(if (<= t_2 (- INFINITY))
(- (* x x) (pow (* z (* (sqrt y) 2.0)) 2.0))
(if (<= t_2 1e+306) (fma (* y 4.0) t_1 (* x x)) (* z (* z (* y -4.0)))))))
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
↓
\begin{array}{l}
t_1 := t - z \cdot z\\
t_2 := x \cdot x + \left(y \cdot 4\right) \cdot t_1\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;x \cdot x - {\left(z \cdot \left(\sqrt{y} \cdot 2\right)\right)}^{2}\\
\mathbf{elif}\;t_2 \leq 10^{+306}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot 4, t_1, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\
\end{array}
Error
Target
Original
5.8
Target
5.8
Herbie
0.7
\[x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right)
\]
Derivation
Split input into 3 regimes
if (-.f64 (*.f64 x x) (*.f64 (*.f64 y 4) (-.f64 (*.f64 z z) t))) < -inf.0
Initial program 64.0
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\]
Taylor expanded in z around inf 64.0
\[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \color{blue}{{z}^{2}}
\]
Simplified64.0
\[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \color{blue}{\left(z \cdot z\right)}
\]
Proof
(*.f64 z z): 0 points increase in error, 0 points decrease in error
(Rewrite<= unpow2_binary64 (pow.f64 z 2)): 0 points increase in error, 0 points decrease in error
Applied egg-rr1.1
\[\leadsto x \cdot x - \color{blue}{{\left(z \cdot \left(\sqrt{y} \cdot 2\right)\right)}^{2}}
\]
if -inf.0 < (-.f64 (*.f64 x x) (*.f64 (*.f64 y 4) (-.f64 (*.f64 z z) t))) < 1.00000000000000002e306
Initial program 0.1
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\]
Simplified0.1
\[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot 4, t - z \cdot z, x \cdot x\right)}
\]
Proof
(fma.f64 (*.f64 y 4) (-.f64 t (*.f64 z z)) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(fma.f64 (*.f64 y 4) (Rewrite=> sub-neg_binary64 (+.f64 t (neg.f64 (*.f64 z z)))) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(fma.f64 (*.f64 y 4) (Rewrite<= +-commutative_binary64 (+.f64 (neg.f64 (*.f64 z z)) t)) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(fma.f64 (*.f64 y 4) (+.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 (*.f64 z z))) t) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(fma.f64 (*.f64 y 4) (Rewrite<= associate--r-_binary64 (-.f64 0 (-.f64 (*.f64 z z) t))) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(fma.f64 (*.f64 y 4) (Rewrite<= neg-sub0_binary64 (neg.f64 (-.f64 (*.f64 z z) t))) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(Rewrite<= fma-def_binary64 (+.f64 (*.f64 (*.f64 y 4) (neg.f64 (-.f64 (*.f64 z z) t))) (*.f64 x x))): 2 points increase in error, 0 points decrease in error
(+.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 (*.f64 y 4) (-.f64 (*.f64 z z) t)))) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(+.f64 (Rewrite<= distribute-lft-neg-out_binary64 (*.f64 (neg.f64 (*.f64 y 4)) (-.f64 (*.f64 z z) t))) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(Rewrite<= +-commutative_binary64 (+.f64 (*.f64 x x) (*.f64 (neg.f64 (*.f64 y 4)) (-.f64 (*.f64 z z) t)))): 0 points increase in error, 0 points decrease in error
(Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 (*.f64 x x) (*.f64 (*.f64 y 4) (-.f64 (*.f64 z z) t)))): 0 points increase in error, 0 points decrease in error
if 1.00000000000000002e306 < (-.f64 (*.f64 x x) (*.f64 (*.f64 y 4) (-.f64 (*.f64 z z) t)))
Initial program 58.9
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\]
Simplified58.9
\[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot 4, t - z \cdot z, x \cdot x\right)}
\]
Proof
(fma.f64 (*.f64 y 4) (-.f64 t (*.f64 z z)) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(fma.f64 (*.f64 y 4) (Rewrite=> sub-neg_binary64 (+.f64 t (neg.f64 (*.f64 z z)))) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(fma.f64 (*.f64 y 4) (Rewrite<= +-commutative_binary64 (+.f64 (neg.f64 (*.f64 z z)) t)) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(fma.f64 (*.f64 y 4) (+.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 (*.f64 z z))) t) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(fma.f64 (*.f64 y 4) (Rewrite<= associate--r-_binary64 (-.f64 0 (-.f64 (*.f64 z z) t))) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(fma.f64 (*.f64 y 4) (Rewrite<= neg-sub0_binary64 (neg.f64 (-.f64 (*.f64 z z) t))) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(Rewrite<= fma-def_binary64 (+.f64 (*.f64 (*.f64 y 4) (neg.f64 (-.f64 (*.f64 z z) t))) (*.f64 x x))): 2 points increase in error, 0 points decrease in error
(+.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 (*.f64 y 4) (-.f64 (*.f64 z z) t)))) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(+.f64 (Rewrite<= distribute-lft-neg-out_binary64 (*.f64 (neg.f64 (*.f64 y 4)) (-.f64 (*.f64 z z) t))) (*.f64 x x)): 0 points increase in error, 0 points decrease in error
(Rewrite<= +-commutative_binary64 (+.f64 (*.f64 x x) (*.f64 (neg.f64 (*.f64 y 4)) (-.f64 (*.f64 z z) t)))): 0 points increase in error, 0 points decrease in error
(Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 (*.f64 x x) (*.f64 (*.f64 y 4) (-.f64 (*.f64 z z) t)))): 0 points increase in error, 0 points decrease in error
herbie shell --seed 2022300
(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))))