Average Error: 3.4 → 0.5
Time: 8.5s
Precision: binary64
Cost: 1544
Math TeX FPCore C \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
↓
\[\begin{array}{l}
\mathbf{if}\;z \cdot 3 \leq -4.102547550221847 \cdot 10^{-89} \lor \neg \left(z \cdot 3 \leq 2.047513759840316 \cdot 10^{-08}\right):\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-0.3333333333333333}{\frac{z}{y - \frac{t}{y}}}\\
\end{array}\]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} ↓
\begin{array}{l}
\mathbf{if}\;z \cdot 3 \leq -4.102547550221847 \cdot 10^{-89} \lor \neg \left(z \cdot 3 \leq 2.047513759840316 \cdot 10^{-08}\right):\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-0.3333333333333333}{\frac{z}{y - \frac{t}{y}}}\\
\end{array} (FPCore (x y z t)
:precision binary64
(+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y)))) ↓
(FPCore (x y z t)
:precision binary64
(if (or (<= (* z 3.0) -4.102547550221847e-89)
(not (<= (* z 3.0) 2.047513759840316e-08)))
(+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y)))
(+ x (/ -0.3333333333333333 (/ z (- y (/ t y))))))) double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
↓
double code(double x, double y, double z, double t) {
double tmp;
if (((z * 3.0) <= -4.102547550221847e-89) || !((z * 3.0) <= 2.047513759840316e-08)) {
tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
} else {
tmp = x + (-0.3333333333333333 / (z / (y - (t / y))));
}
return tmp;
}
Try it out Enter valid numbers for all inputs
Target Original 3.4 Target 1.9 Herbie 0.5
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]
Alternatives Alternative 1 Error 3.6 Cost 1474
\[\begin{array}{l}
\mathbf{if}\;y \leq -5.061193822850261 \cdot 10^{-166}:\\
\;\;\;\;x + \frac{-0.3333333333333333}{\frac{z}{y - \frac{t}{y}}}\\
\mathbf{elif}\;y \leq 1.5629371845185122 \cdot 10^{-197}:\\
\;\;\;\;x + 0.3333333333333333 \cdot \frac{t}{z \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{\frac{z}{-0.3333333333333333 \cdot \left(y - \frac{t}{y}\right)}}\\
\end{array}\]
Alternative 2 Error 3.7 Cost 1346
\[\begin{array}{l}
\mathbf{if}\;y \leq -2.1328192736786707 \cdot 10^{-167}:\\
\;\;\;\;x + \frac{-0.3333333333333333}{\frac{z}{y - \frac{t}{y}}}\\
\mathbf{elif}\;y \leq 6.072844017225707 \cdot 10^{-194}:\\
\;\;\;\;x + 0.3333333333333333 \cdot \frac{t}{z \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-0.3333333333333333 \cdot \left(y - \frac{t}{y}\right)}{z}\\
\end{array}\]
Alternative 3 Error 3.6 Cost 1032
\[\begin{array}{l}
\mathbf{if}\;y \leq -2.031342023748196 \cdot 10^{-167} \lor \neg \left(y \leq 1.775910276249274 \cdot 10^{-197}\right):\\
\;\;\;\;x + \frac{-0.3333333333333333 \cdot \left(y - \frac{t}{y}\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x + 0.3333333333333333 \cdot \frac{t}{z \cdot y}\\
\end{array}\]
Alternative 4 Error 3.9 Cost 1032
\[\begin{array}{l}
\mathbf{if}\;y \leq -3.824787149237756 \cdot 10^{-163} \lor \neg \left(y \leq -2.0845605174032763 \cdot 10^{-304}\right):\\
\;\;\;\;x + -0.3333333333333333 \cdot \frac{y - \frac{t}{y}}{z}\\
\mathbf{else}:\\
\;\;\;\;x + 0.3333333333333333 \cdot \frac{t}{z \cdot y}\\
\end{array}\]
Alternative 5 Error 8.2 Cost 1218
\[\begin{array}{l}
\mathbf{if}\;y \leq -3.4425981747227545 \cdot 10^{-18}:\\
\;\;\;\;x + \frac{1}{\frac{z}{y} \cdot -3}\\
\mathbf{elif}\;y \leq 4.348498850758092 \cdot 10^{+28}:\\
\;\;\;\;x + 0.3333333333333333 \cdot \frac{t}{z \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{-0.3333333333333333}{z}\\
\end{array}\]
Alternative 6 Error 8.3 Cost 1860
\[\begin{array}{l}
\mathbf{if}\;y \leq -4.422948289970177 \cdot 10^{-20}:\\
\;\;\;\;x + y \cdot \frac{-0.3333333333333333}{z}\\
\mathbf{elif}\;y \leq 1.426168426782496 \cdot 10^{-198}:\\
\;\;\;\;x + 0.3333333333333333 \cdot \frac{t}{z \cdot y}\\
\mathbf{elif}\;y \leq 4.2352197974092834 \cdot 10^{-139}:\\
\;\;\;\;x + \frac{\frac{t}{y} \cdot 0.3333333333333333}{z}\\
\mathbf{elif}\;y \leq 3.6824183286726317 \cdot 10^{+28}:\\
\;\;\;\;x + 0.3333333333333333 \cdot \frac{t}{z \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{-0.3333333333333333}{z}\\
\end{array}\]
Alternative 7 Error 8.3 Cost 1860
\[\begin{array}{l}
\mathbf{if}\;y \leq -4.422948289970177 \cdot 10^{-20}:\\
\;\;\;\;x + y \cdot \frac{-0.3333333333333333}{z}\\
\mathbf{elif}\;y \leq 1.2527032477888993 \cdot 10^{-193}:\\
\;\;\;\;x + 0.3333333333333333 \cdot \frac{t}{z \cdot y}\\
\mathbf{elif}\;y \leq 6.420318399200128 \cdot 10^{-133}:\\
\;\;\;\;x + \frac{t}{y} \cdot \frac{0.3333333333333333}{z}\\
\mathbf{elif}\;y \leq 2.264812849983564 \cdot 10^{+28}:\\
\;\;\;\;x + 0.3333333333333333 \cdot \frac{t}{z \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{-0.3333333333333333}{z}\\
\end{array}\]
Alternative 8 Error 9.4 Cost 904
\[\begin{array}{l}
\mathbf{if}\;y \leq -1.0267353273179042 \cdot 10^{-18} \lor \neg \left(y \leq 8.822611347478466 \cdot 10^{+29}\right):\\
\;\;\;\;x + y \cdot \frac{-0.3333333333333333}{z}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{t}{y} \cdot \frac{0.3333333333333333}{z}\\
\end{array}\]
Alternative 9 Error 17.8 Cost 448
\[x + y \cdot \frac{-0.3333333333333333}{z}\]
Alternative 10 Error 61.9 Cost 64
\[-1\]
Alternative 11 Error 61.9 Cost 64
\[1\]
Error Derivation Split input into 2 regimes if (*.f64 z 3) < -4.1025475502218468e-89 or 2.04751375984031615e-8 < (*.f64 z 3) Initial program 0.5
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
Simplified0.5
\[\leadsto \color{blue}{\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}}\]
if -4.1025475502218468e-89 < (*.f64 z 3) < 2.04751375984031615e-8 Initial program 12.3
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
Simplified0.3
\[\leadsto \color{blue}{x + \frac{-0.3333333333333333}{z} \cdot \left(y - \frac{t}{y}\right)}\]
Using strategy rm Applied associate-*l/_binary64_14002 0.3
\[\leadsto x + \color{blue}{\frac{-0.3333333333333333 \cdot \left(y - \frac{t}{y}\right)}{z}}\]
Using strategy rm Applied associate-/l*_binary64_14004 0.3
\[\leadsto x + \color{blue}{\frac{-0.3333333333333333}{\frac{z}{y - \frac{t}{y}}}}\]
Simplified0.3
\[\leadsto \color{blue}{x + \frac{-0.3333333333333333}{\frac{z}{y - \frac{t}{y}}}}\]
Recombined 2 regimes into one program. Final simplification0.5
\[\leadsto \begin{array}{l}
\mathbf{if}\;z \cdot 3 \leq -4.102547550221847 \cdot 10^{-89} \lor \neg \left(z \cdot 3 \leq 2.047513759840316 \cdot 10^{-08}\right):\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-0.3333333333333333}{\frac{z}{y - \frac{t}{y}}}\\
\end{array}\]
Reproduce herbie shell --seed 2021044
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, H"
:precision binary64
:herbie-target
(+ (- x (/ y (* z 3.0))) (/ (/ t (* z 3.0)) y))
(+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))