?

Average Error: 5.7 → 0.1
Time: 11.1s
Precision: binary64
Cost: 7360

?

\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
\[x \cdot x - \mathsf{fma}\left(y \cdot -4, t, 4 \cdot \left(z \cdot \left(y \cdot z\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
 (- (* x x) (fma (* y -4.0) t (* 4.0 (* z (* y z))))))
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 (x * x) - fma((y * -4.0), t, (4.0 * (z * (y * z))));
}
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 Float64(Float64(x * x) - fma(Float64(y * -4.0), t, Float64(4.0 * Float64(z * Float64(y * z)))))
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[(x * x), $MachinePrecision] - N[(N[(y * -4.0), $MachinePrecision] * t + N[(4.0 * N[(z * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
x \cdot x - \mathsf{fma}\left(y \cdot -4, t, 4 \cdot \left(z \cdot \left(y \cdot z\right)\right)\right)

Error?

Target

Original5.7
Target5.7
Herbie0.1
\[x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right) \]

Derivation?

  1. Initial program 5.7

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

    \[\leadsto x \cdot x - \color{blue}{\frac{y \cdot 4}{\frac{1}{z \cdot z - t}}} \]
  3. Applied egg-rr6.4

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

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

    [Start]6.4

    \[ x \cdot x - \frac{y \cdot 4}{{\left({\left(\sqrt[3]{z \cdot z - t}\right)}^{2}\right)}^{-1} \cdot {\left(\sqrt[3]{z \cdot z - t}\right)}^{-1}} \]

    *-commutative [=>]6.4

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

    unpow-1 [=>]6.4

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

    unpow-1 [=>]6.4

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

    associate-*r/ [=>]6.4

    \[ x \cdot x - \frac{y \cdot 4}{\color{blue}{\frac{\frac{1}{\sqrt[3]{z \cdot z - t}} \cdot 1}{{\left(\sqrt[3]{z \cdot z - t}\right)}^{2}}}} \]
  5. Taylor expanded in z around 0 5.7

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

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

    [Start]5.7

    \[ x \cdot x - \left(4 \cdot \left(y \cdot {z}^{2}\right) + -4 \cdot \left(y \cdot t\right)\right) \]

    +-commutative [=>]5.7

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

    associate-*r* [=>]5.7

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

    *-commutative [<=]5.7

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

    associate-*r* [=>]5.7

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

    *-commutative [<=]5.7

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

    /-rgt-identity [<=]5.7

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

    unpow2 [=>]5.7

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

    fma-def [=>]5.7

    \[ x \cdot x - \color{blue}{\mathsf{fma}\left(y \cdot -4, t, \frac{y \cdot 4}{1} \cdot \left(z \cdot z\right)\right)} \]

    /-rgt-identity [=>]5.7

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

    *-commutative [=>]5.7

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

    unpow2 [<=]5.7

    \[ x \cdot x - \mathsf{fma}\left(y \cdot -4, t, \left(4 \cdot y\right) \cdot \color{blue}{{z}^{2}}\right) \]

    associate-*r* [<=]5.7

    \[ x \cdot x - \mathsf{fma}\left(y \cdot -4, t, \color{blue}{4 \cdot \left(y \cdot {z}^{2}\right)}\right) \]

    *-commutative [=>]5.7

    \[ x \cdot x - \mathsf{fma}\left(y \cdot -4, t, 4 \cdot \color{blue}{\left({z}^{2} \cdot y\right)}\right) \]

    unpow2 [=>]5.7

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

    associate-*l* [=>]0.1

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

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

Alternatives

Alternative 1
Error1.0
Cost8392
\[\begin{array}{l} t_1 := \left(y \cdot -4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;z \cdot \frac{y \cdot -4}{\frac{1}{z}}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+293}:\\ \;\;\;\;\mathsf{fma}\left(z \cdot z - t, y \cdot -4, x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(\left(y \cdot -4\right) \cdot z\right)\\ \end{array} \]
Alternative 2
Error1.0
Cost2120
\[\begin{array}{l} t_1 := \left(y \cdot -4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;z \cdot \frac{y \cdot -4}{\frac{1}{z}}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+293}:\\ \;\;\;\;x \cdot x + \left(y \cdot -4\right) \cdot \left(z \cdot z - t\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(\left(y \cdot -4\right) \cdot z\right)\\ \end{array} \]
Alternative 3
Error8.2
Cost1744
\[\begin{array}{l} t_1 := x \cdot x + \left(y \cdot -4\right) \cdot \left(z \cdot z\right)\\ \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{-91}:\\ \;\;\;\;x \cdot x + t \cdot \left(y \cdot 4\right)\\ \mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{-9}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot z \leq 10^{+192}:\\ \;\;\;\;\left(y \cdot -4\right) \cdot \left(z \cdot z - t\right)\\ \mathbf{elif}\;z \cdot z \leq 10^{+281}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y \cdot -4}{\frac{1}{z}}\\ \end{array} \]
Alternative 4
Error27.6
Cost1377
\[\begin{array}{l} t_1 := t \cdot \left(y \cdot 4\right)\\ t_2 := z \cdot \left(\left(y \cdot -4\right) \cdot z\right)\\ \mathbf{if}\;x \leq -1.4 \cdot 10^{+35}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq -280:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -4.6 \cdot 10^{-62}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 4.9 \cdot 10^{-201}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-98}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-63} \lor \neg \left(x \leq 4.5 \cdot 10^{-23}\right) \land x \leq 2 \cdot 10^{+39}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 5
Error27.6
Cost1376
\[\begin{array}{l} t_1 := t \cdot \left(y \cdot 4\right)\\ t_2 := z \cdot \left(\left(y \cdot -4\right) \cdot z\right)\\ \mathbf{if}\;x \leq -1.4 \cdot 10^{+35}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq -380:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -2.2 \cdot 10^{-62}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-201}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-102}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-63}:\\ \;\;\;\;\frac{y \cdot -4}{\frac{-1}{t}}\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-23}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 5 \cdot 10^{+41}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 6
Error17.2
Cost1105
\[\begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{+79}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-63} \lor \neg \left(x \leq 4.1 \cdot 10^{-22}\right) \land x \leq 2 \cdot 10^{+39}:\\ \;\;\;\;\left(y \cdot -4\right) \cdot \left(z \cdot z - t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 7
Error8.1
Cost1104
\[\begin{array}{l} t_1 := \left(y \cdot -4\right) \cdot \left(z \cdot z - t\right)\\ t_2 := z \cdot \left(\left(y \cdot -4\right) \cdot z\right)\\ \mathbf{if}\;z \leq -5 \cdot 10^{+153}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-34}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 10^{-14}:\\ \;\;\;\;x \cdot x + t \cdot \left(y \cdot 4\right)\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+153}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error8.1
Cost1104
\[\begin{array}{l} t_1 := \left(y \cdot -4\right) \cdot \left(z \cdot z - t\right)\\ \mathbf{if}\;z \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;z \cdot \left(\left(y \cdot -4\right) \cdot z\right)\\ \mathbf{elif}\;z \leq -6.5 \cdot 10^{-34}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-15}:\\ \;\;\;\;x \cdot x + t \cdot \left(y \cdot 4\right)\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+153}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y \cdot -4}{\frac{1}{z}}\\ \end{array} \]
Alternative 9
Error26.4
Cost1101
\[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 2.05 \cdot 10^{-125} \lor \neg \left(x \cdot x \leq 4.9 \cdot 10^{-72}\right) \land x \cdot x \leq 5.4 \cdot 10^{+79}:\\ \;\;\;\;t \cdot \left(y \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 10
Error40.7
Cost192
\[x \cdot x \]

Error

Reproduce?

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