Average Error: 6.1 → 0.4
Time: 6.6min
Precision: binary64
Cost: 1730
Math TeX FPCore C \[x + \frac{y \cdot \left(z - t\right)}{a}\]
↓
\[\begin{array}{l}
\mathbf{if}\;y \cdot \left(z - t\right) \leq -5.514422444088807 \cdot 10^{+257}:\\
\;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a}\\
\mathbf{elif}\;y \cdot \left(z - t\right) \leq 1.3819062189176262 \cdot 10^{+287}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{z - t}{a}\\
\end{array}\]
x + \frac{y \cdot \left(z - t\right)}{a} ↓
\begin{array}{l}
\mathbf{if}\;y \cdot \left(z - t\right) \leq -5.514422444088807 \cdot 10^{+257}:\\
\;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a}\\
\mathbf{elif}\;y \cdot \left(z - t\right) \leq 1.3819062189176262 \cdot 10^{+287}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{z - t}{a}\\
\end{array} (FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) a))) ↓
(FPCore (x y z t a)
:precision binary64
(if (<= (* y (- z t)) -5.514422444088807e+257)
(+ x (* (- z t) (/ y a)))
(if (<= (* y (- z t)) 1.3819062189176262e+287)
(+ x (/ (* y (- z t)) a))
(+ x (* y (/ (- z t) a)))))) double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / a);
}
↓
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((y * (z - t)) <= -5.514422444088807e+257) {
tmp = x + ((z - t) * (y / a));
} else if ((y * (z - t)) <= 1.3819062189176262e+287) {
tmp = x + ((y * (z - t)) / a);
} else {
tmp = x + (y * ((z - t) / a));
}
return tmp;
}
Try it out Enter valid numbers for all inputs
Target Original 6.1 Target 0.7 Herbie 0.4
\[\begin{array}{l}
\mathbf{if}\;y < -1.0761266216389975 \cdot 10^{-10}:\\
\;\;\;\;x + \frac{1}{\frac{\frac{a}{z - t}}{y}}\\
\mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{a}{z - t}}\\
\end{array}\]
Alternatives Alternative 1 Error 1.0 Cost 72000
\[x + \left(\sqrt[3]{y} \cdot \frac{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\left|\frac{\sqrt[3]{a}}{\sqrt[3]{y}}\right|}}{\sqrt[3]{a}}\right) \cdot \frac{\frac{\sqrt[3]{1}}{\left|\frac{\sqrt[3]{a}}{\sqrt[3]{y}}\right|}}{\frac{1}{z - t}}\]
Alternative 2 Error 1.0 Cost 39616
\[x + \frac{\frac{1}{\frac{\sqrt[3]{a} \cdot \sqrt[3]{a}}{\sqrt[3]{y} \cdot \sqrt[3]{y}}}}{\frac{\frac{\sqrt[3]{a}}{\sqrt[3]{y}}}{z - t}}\]
Alternative 3 Error 1.0 Cost 39616
\[x + \frac{1}{\frac{\sqrt[3]{a} \cdot \sqrt[3]{a}}{\sqrt[3]{y} \cdot \sqrt[3]{y}}} \cdot \frac{z - t}{\frac{\sqrt[3]{a}}{\sqrt[3]{y}}}\]
Alternative 4 Error 0.4 Cost 1416
\[\begin{array}{l}
\mathbf{if}\;y \cdot \left(z - t\right) \leq -5.514422444088807 \cdot 10^{+257} \lor \neg \left(y \cdot \left(z - t\right) \leq 4.0307655758707046 \cdot 10^{+227}\right):\\
\;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\
\end{array}\]
Alternative 5 Error 2.3 Cost 576
\[x + \frac{z - t}{\frac{a}{y}}\]
Alternative 6 Error 2.4 Cost 576
\[x + \left(z - t\right) \cdot \frac{y}{a}\]
Alternative 7 Error 8.8 Cost 776
\[\begin{array}{l}
\mathbf{if}\;t \leq -1.5564204691164272 \cdot 10^{+17} \lor \neg \left(t \leq 3.3737087326612843 \cdot 10^{-41}\right):\\
\;\;\;\;x - t \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{z}{\frac{a}{y}}\\
\end{array}\]
Alternative 8 Error 8.8 Cost 776
\[\begin{array}{l}
\mathbf{if}\;t \leq -1.5564204691164272 \cdot 10^{+17} \lor \neg \left(t \leq 3.3845146637980385 \cdot 10^{-39}\right):\\
\;\;\;\;x - \frac{t}{\frac{a}{y}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{z}{\frac{a}{y}}\\
\end{array}\]
Alternative 9 Error 8.9 Cost 776
\[\begin{array}{l}
\mathbf{if}\;t \leq -1.4912506841300403 \cdot 10^{+17} \lor \neg \left(t \leq 1.5265949137561266 \cdot 10^{-41}\right):\\
\;\;\;\;x - \frac{t}{\frac{a}{y}}\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \frac{y}{a}\\
\end{array}\]
Alternative 10 Error 9.7 Cost 776
\[\begin{array}{l}
\mathbf{if}\;t \leq -0.002345680633920969 \lor \neg \left(t \leq 1.7644500327651093 \cdot 10^{-41}\right):\\
\;\;\;\;x - \frac{t}{\frac{a}{y}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y \cdot z}{a}\\
\end{array}\]
Alternative 11 Error 19.1 Cost 1739
\[\begin{array}{l}
\mathbf{if}\;t \leq -9.769650233455533 \cdot 10^{+89}:\\
\;\;\;\;-\frac{t}{\frac{a}{y}}\\
\mathbf{elif}\;t \leq -2.3927873258594486 \cdot 10^{+45}:\\
\;\;\;\;x + \frac{y \cdot z}{a}\\
\mathbf{elif}\;t \leq -9.875110794919842 \cdot 10^{+29}:\\
\;\;\;\;\frac{y \cdot \left(-t\right)}{a}\\
\mathbf{elif}\;t \leq 4.869973898575796 \cdot 10^{+100} \lor \neg \left(t \leq 3.881785513702398 \cdot 10^{+151}\right):\\
\;\;\;\;x + \frac{y \cdot z}{a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{t}{\frac{a}{y}}\\
\end{array}\]
Alternative 12 Error 28.0 Cost 1283
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.0619953600607391 \cdot 10^{-72}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 7.28337174311298 \cdot 10^{-269}:\\
\;\;\;\;-\frac{t}{\frac{a}{y}}\\
\mathbf{elif}\;x \leq 6.930706779240972 \cdot 10^{-62}:\\
\;\;\;\;\frac{y \cdot z}{a}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}\]
Alternative 13 Error 28.3 Cost 1604
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.2661162990789266 \cdot 10^{-75}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -3.7335213432510176 \cdot 10^{-227}:\\
\;\;\;\;z \cdot \frac{y}{a}\\
\mathbf{elif}\;x \leq 2.0403172204709538 \cdot 10^{-303}:\\
\;\;\;\;\frac{y \cdot \left(-t\right)}{a}\\
\mathbf{elif}\;x \leq 1.7737819446138153 \cdot 10^{-61}:\\
\;\;\;\;\frac{y \cdot z}{a}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}\]
Alternative 14 Error 28.3 Cost 962
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.7157302820236517 \cdot 10^{-76}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 5.874203343316973 \cdot 10^{-62}:\\
\;\;\;\;\frac{y \cdot z}{a}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}\]
Alternative 15 Error 27.9 Cost 962
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.7157302820236517 \cdot 10^{-76}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.7246350369454143 \cdot 10^{-61}:\\
\;\;\;\;\frac{z}{\frac{a}{y}}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}\]
Alternative 16 Error 27.9 Cost 962
\[\begin{array}{l}
\mathbf{if}\;x \leq -7.378909651655628 \cdot 10^{-76}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.110103578179451 \cdot 10^{-61}:\\
\;\;\;\;z \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}\]
Alternative 17 Error 30.7 Cost 64
\[x\]
Error Time Derivation Split input into 3 regimes if (*.f64 y (-.f64 z t)) < -5.51442244408880728e257 Initial program 41.9
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
Using strategy rm Applied add-cube-cbrt_binary64_12389 42.2
\[\leadsto x + \frac{y \cdot \left(z - t\right)}{\color{blue}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}}\]
Applied associate-/r*_binary64_12298 42.2
\[\leadsto x + \color{blue}{\frac{\frac{y \cdot \left(z - t\right)}{\sqrt[3]{a} \cdot \sqrt[3]{a}}}{\sqrt[3]{a}}}\]
Simplified11.2
\[\leadsto x + \frac{\color{blue}{\frac{y}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \left(z - t\right)}}{\sqrt[3]{a}}\]
Using strategy rm Applied clear-num_binary64_12353 11.2
\[\leadsto x + \color{blue}{\frac{1}{\frac{\sqrt[3]{a}}{\frac{y}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \left(z - t\right)}}}\]
Simplified0.3
\[\leadsto x + \frac{1}{\color{blue}{\frac{\frac{a}{y}}{z - t}}}\]
Using strategy rm Applied div-inv_binary64_12351 0.3
\[\leadsto x + \frac{1}{\color{blue}{\frac{a}{y} \cdot \frac{1}{z - t}}}\]
Applied add-sqr-sqrt_binary64_12376 0.3
\[\leadsto x + \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\frac{a}{y} \cdot \frac{1}{z - t}}\]
Applied times-frac_binary64_12360 0.3
\[\leadsto x + \color{blue}{\frac{\sqrt{1}}{\frac{a}{y}} \cdot \frac{\sqrt{1}}{\frac{1}{z - t}}}\]
Simplified0.2
\[\leadsto x + \color{blue}{\frac{y}{a}} \cdot \frac{\sqrt{1}}{\frac{1}{z - t}}\]
Simplified0.2
\[\leadsto x + \frac{y}{a} \cdot \color{blue}{\left(z - t\right)}\]
Simplified0.2
\[\leadsto \color{blue}{x + \frac{y}{a} \cdot \left(z - t\right)}\]
if -5.51442244408880728e257 < (*.f64 y (-.f64 z t)) < 1.3819062189176262e287 Initial program 0.4
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
Using strategy rm Applied *-commutative_binary64_12285 0.4
\[\leadsto x + \frac{\color{blue}{\left(z - t\right) \cdot y}}{a}\]
Simplified0.4
\[\leadsto \color{blue}{x + \frac{\left(z - t\right) \cdot y}{a}}\]
if 1.3819062189176262e287 < (*.f64 y (-.f64 z t)) Initial program 52.4
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
Using strategy rm Applied *-un-lft-identity_binary64_12354 52.4
\[\leadsto x + \frac{y \cdot \left(z - t\right)}{\color{blue}{1 \cdot a}}\]
Applied times-frac_binary64_12360 0.2
\[\leadsto x + \color{blue}{\frac{y}{1} \cdot \frac{z - t}{a}}\]
Simplified0.2
\[\leadsto x + \color{blue}{y} \cdot \frac{z - t}{a}\]
Simplified0.2
\[\leadsto \color{blue}{x + y \cdot \frac{z - t}{a}}\]
Recombined 3 regimes into one program. Final simplification0.4
\[\leadsto \begin{array}{l}
\mathbf{if}\;y \cdot \left(z - t\right) \leq -5.514422444088807 \cdot 10^{+257}:\\
\;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a}\\
\mathbf{elif}\;y \cdot \left(z - t\right) \leq 1.3819062189176262 \cdot 10^{+287}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{z - t}{a}\\
\end{array}\]
Reproduce herbie shell --seed 2021040
(FPCore (x y z t a)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
:precision binary64
:herbie-target
(if (< y -1.0761266216389975e-10) (+ x (/ 1.0 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (+ x (/ (* y (- z t)) a)) (+ x (/ y (/ a (- z t))))))
(+ x (/ (* y (- z t)) a)))