Average Error: 6.3 → 3.5
Time: 8.2s
Precision: binary64
Cost: 14209
Math TeX FPCore C \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
↓
\[\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 7.797257741793615 \cdot 10^{+303}:\\
\;\;\;\;x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - \left(\left(y \cdot 4\right) \cdot \left(z + \sqrt{t}\right)\right) \cdot \left(z - \sqrt{t}\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 7.797257741793615 \cdot 10^{+303}:\\
\;\;\;\;x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - \left(\left(y \cdot 4\right) \cdot \left(z + \sqrt{t}\right)\right) \cdot \left(z - \sqrt{t}\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) 7.797257741793615e+303)
(- (* x x) (* (* y 4.0) (- (* z z) t)))
(- (* x x) (* (* (* y 4.0) (+ z (sqrt t))) (- z (sqrt t)))))) 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) <= 7.797257741793615e+303) {
tmp = (x * x) - ((y * 4.0) * ((z * z) - t));
} else {
tmp = (x * x) - (((y * 4.0) * (z + sqrt(t))) * (z - sqrt(t)));
}
return tmp;
}
Try it out Enter valid numbers for all inputs
Target Original 6.3 Target 6.2 Herbie 3.5
\[x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right)\]
Alternatives Alternative 1 Error 29.2 Cost 34560
\[x \cdot x - \left(\sqrt[3]{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \cdot \sqrt[3]{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\right) \cdot \frac{\sqrt[3]{\left(y \cdot 4\right) \cdot \left({z}^{4} - t \cdot t\right)}}{\sqrt[3]{t + z \cdot z}}\]
Alternative 2 Error 6.9 Cost 27712
\[x \cdot x - \left(\sqrt[3]{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \cdot \sqrt[3]{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\right) \cdot \left(\sqrt[3]{y \cdot 4} \cdot \sqrt[3]{z \cdot z - t}\right)\]
Alternative 3 Error 30.2 Cost 27584
\[x \cdot x - \left(\sqrt[3]{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \cdot \sqrt[3]{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\right) \cdot \left(\sqrt[3]{4} \cdot \sqrt[3]{y \cdot \left(z \cdot z\right)}\right)\]
Alternative 4 Error 7.0 Cost 21312
\[x \cdot x - \sqrt[3]{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \cdot \left(\sqrt[3]{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \cdot \sqrt[3]{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\right)\]
Alternative 5 Error 19.2 Cost 21056
\[x \cdot x - \left(\sqrt[3]{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \cdot \sqrt[3]{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\right) \cdot \sqrt[3]{y \cdot \left(t \cdot -4\right)}\]
Alternative 6 Error 49.0 Cost 20992
\[\frac{{x}^{6} - {\left(y \cdot \left(t \cdot -4\right)\right)}^{3}}{{x}^{4} + y \cdot \left(\left(t \cdot -4\right) \cdot \left(x \cdot x + y \cdot \left(t \cdot -4\right)\right)\right)}\]
Alternative 7 Error 42.2 Cost 14784
\[x \cdot x - \frac{\left(y \cdot 4\right) \cdot \left({z}^{6} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + t \cdot \left(z \cdot z\right)\right)}\]
Alternative 8 Error 25.1 Cost 14528
\[\sqrt{x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \cdot \sqrt{x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\]
Alternative 9 Error 32.6 Cost 14272
\[x \cdot x - \sqrt{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \cdot \sqrt{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\]
Alternative 10 Error 26.5 Cost 14016
\[x \cdot x - \sqrt{z \cdot z - t} \cdot \left(\left(y \cdot 4\right) \cdot \sqrt{z \cdot z - t}\right)\]
Alternative 11 Error 31.9 Cost 13760
\[x \cdot x - \left(\left(y \cdot 4\right) \cdot \left(z + \sqrt{t}\right)\right) \cdot \left(z - \sqrt{t}\right)\]
Alternative 12 Error 33.7 Cost 13696
\[x \cdot x - \left(y \cdot 4\right) \cdot \sqrt[3]{{\left(z \cdot z - t\right)}^{3}}\]
Alternative 13 Error 46.0 Cost 13440
\[\sqrt[3]{{\left(y \cdot \left(4 \cdot t\right) + x \cdot x\right)}^{3}}\]
Alternative 14 Error 60.4 Cost 13376
\[\log \left(e^{y \cdot \left(4 \cdot t\right) + x \cdot x}\right)\]
Alternative 15 Error 33.0 Cost 13376
\[e^{\log \left(y \cdot \left(4 \cdot t\right) + x \cdot x\right)}\]
Alternative 16 Error 43.5 Cost 8576
\[\frac{{x}^{4} - y \cdot \left(\left(\left(z \cdot z - t\right) \cdot \left(z \cdot z - t\right)\right) \cdot \left(y \cdot 16\right)\right)}{x \cdot x + \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\]
Alternative 17 Error 29.0 Cost 7680
\[x \cdot x - \frac{\left(y \cdot 4\right) \cdot \left({z}^{4} - t \cdot t\right)}{t + z \cdot z}\]
Alternative 18 Error 25.6 Cost 7680
\[x \cdot x - \left(y \cdot 4\right) \cdot \frac{{z}^{4} - t \cdot t}{t + z \cdot z}\]
Alternative 19 Error 6.3 Cost 1088
\[x \cdot x - \left(y \cdot \left(t \cdot -4\right) + \left(y \cdot 4\right) \cdot \left(z \cdot z\right)\right)\]
Alternative 20 Error 6.3 Cost 832
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
Alternative 21 Error 30.1 Cost 704
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z\right)\]
Alternative 22 Error 17.9 Cost 576
\[y \cdot \left(4 \cdot t\right) + x \cdot x\]
Alternative 23 Error 25.2 Cost 576
\[y \cdot \left(-4 \cdot \left(z \cdot z - t\right)\right)\]
Alternative 24 Error 48.6 Cost 448
\[-4 \cdot \left(y \cdot \left(z \cdot z\right)\right)\]
Alternative 25 Error 37.3 Cost 320
\[y \cdot \left(4 \cdot t\right)\]
Alternative 26 Error 41.5 Cost 192
\[x \cdot x\]
Alternative 27 Error 61.4 Cost 64
\[1\]
Alternative 28 Error 60.6 Cost 64
\[0\]
Alternative 29 Error 62.2 Cost 64
\[-1\]
Error Derivation Split input into 2 regimes if (*.f64 z z) < 7.79725774179361499e303 Initial program 0.1
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
Simplified0.1
\[\leadsto \color{blue}{x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\]
if 7.79725774179361499e303 < (*.f64 z z) Initial program 62.6
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\]
Using strategy rm Applied add-sqr-sqrt_binary64_19740 63.4
\[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - \color{blue}{\sqrt{t} \cdot \sqrt{t}}\right)\]
Applied difference-of-squares_binary64_19687 63.4
\[\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)}\]
Applied associate-*r*_binary64_19658 34.2
\[\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)}\]
Simplified34.2
\[\leadsto \color{blue}{x \cdot x - \left(\left(y \cdot 4\right) \cdot \left(z + \sqrt{t}\right)\right) \cdot \left(z - \sqrt{t}\right)}\]
Recombined 2 regimes into one program. Final simplification3.5
\[\leadsto \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 7.797257741793615 \cdot 10^{+303}:\\
\;\;\;\;x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - \left(\left(y \cdot 4\right) \cdot \left(z + \sqrt{t}\right)\right) \cdot \left(z - \sqrt{t}\right)\\
\end{array}\]
Reproduce herbie shell --seed 2021042
(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))))