Average Error: 3.4 → 0.5
Time: 8.5s
Precision: binary64
Cost: 1544
\[\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;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.4
Target1.9
Herbie0.5
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]

Alternatives

Alternative 1
Error3.6
Cost1474
\[\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
Error3.7
Cost1346
\[\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
Error3.6
Cost1032
\[\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
Error3.9
Cost1032
\[\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
Error8.2
Cost1218
\[\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
Error8.3
Cost1860
\[\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
Error8.3
Cost1860
\[\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
Error9.4
Cost904
\[\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
Error17.8
Cost448
\[x + y \cdot \frac{-0.3333333333333333}{z}\]
Alternative 10
Error61.9
Cost64
\[-1\]
Alternative 11
Error61.9
Cost64
\[1\]

Error

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 z 3) < -4.1025475502218468e-89 or 2.04751375984031615e-8 < (*.f64 z 3)

    1. Initial program 0.5

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. 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

    1. Initial program 12.3

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Simplified0.3

      \[\leadsto \color{blue}{x + \frac{-0.3333333333333333}{z} \cdot \left(y - \frac{t}{y}\right)}\]
    3. Using strategy rm
    4. Applied associate-*l/_binary64_140020.3

      \[\leadsto x + \color{blue}{\frac{-0.3333333333333333 \cdot \left(y - \frac{t}{y}\right)}{z}}\]
    5. Using strategy rm
    6. Applied associate-/l*_binary64_140040.3

      \[\leadsto x + \color{blue}{\frac{-0.3333333333333333}{\frac{z}{y - \frac{t}{y}}}}\]
    7. Simplified0.3

      \[\leadsto \color{blue}{x + \frac{-0.3333333333333333}{\frac{z}{y - \frac{t}{y}}}}\]
  3. Recombined 2 regimes into one program.
  4. 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))))