Average Error: 4.0 → 0.8
Time: 6.7s
Precision: binary64
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
\[\begin{array}{l} t_1 := \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;x + \frac{0.3333333333333333}{\frac{z}{\frac{t}{y} - y}}\\ \mathbf{elif}\;t_1 \leq 1.2670046298233474 \cdot 10^{+291}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{\frac{z}{0.3333333333333333 \cdot \frac{t}{y} + y \cdot -0.3333333333333333}}\\ \end{array} \]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
t_1 := \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;x + \frac{0.3333333333333333}{\frac{z}{\frac{t}{y} - y}}\\

\mathbf{elif}\;t_1 \leq 1.2670046298233474 \cdot 10^{+291}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;x + \frac{1}{\frac{z}{0.3333333333333333 \cdot \frac{t}{y} + y \cdot -0.3333333333333333}}\\


\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
 (let* ((t_1 (+ (- x (/ y (* z 3.0))) (/ t (* y (* z 3.0))))))
   (if (<= t_1 (- INFINITY))
     (+ x (/ 0.3333333333333333 (/ z (- (/ t y) y))))
     (if (<= t_1 1.2670046298233474e+291)
       t_1
       (+
        x
        (/
         1.0
         (/
          z
          (+ (* 0.3333333333333333 (/ t y)) (* y -0.3333333333333333)))))))))
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 t_1 = (x - (y / (z * 3.0))) + (t / (y * (z * 3.0)));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = x + (0.3333333333333333 / (z / ((t / y) - y)));
	} else if (t_1 <= 1.2670046298233474e+291) {
		tmp = t_1;
	} else {
		tmp = x + (1.0 / (z / ((0.3333333333333333 * (t / y)) + (y * -0.3333333333333333))));
	}
	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

Original4.0
Target1.7
Herbie0.8
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y} \]

Derivation

  1. Split input into 3 regimes
  2. if (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) < -inf.0

    1. Initial program 64.0

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-0.3333333333333333}{z}, y - \frac{t}{y}, x\right)} \]
    3. Applied fma-udef_binary640.3

      \[\leadsto \color{blue}{\frac{-0.3333333333333333}{z} \cdot \left(y - \frac{t}{y}\right) + x} \]
    4. Simplified0.3

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

    if -inf.0 < (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) < 1.2670046298233474e291

    1. Initial program 0.6

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

    if 1.2670046298233474e291 < (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y)))

    1. Initial program 31.7

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-0.3333333333333333}{z}, y - \frac{t}{y}, x\right)} \]
    3. Applied fma-udef_binary644.1

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

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{\frac{z}{\frac{t}{y} - y}}} + x \]
    5. Applied clear-num_binary644.2

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{z}{\frac{t}{y} - y}}{0.3333333333333333}}} + x \]
    6. Simplified4.1

      \[\leadsto \frac{1}{\color{blue}{\frac{z}{0.3333333333333333 \cdot \left(\frac{t}{y} - y\right)}}} + x \]
    7. Applied *-un-lft-identity_binary644.1

      \[\leadsto \frac{1}{\frac{z}{0.3333333333333333 \cdot \left(\frac{t}{y} - \color{blue}{1 \cdot y}\right)}} + x \]
    8. Applied cancel-sign-sub-inv_binary644.1

      \[\leadsto \frac{1}{\frac{z}{0.3333333333333333 \cdot \color{blue}{\left(\frac{t}{y} + \left(-1\right) \cdot y\right)}}} + x \]
    9. Applied distribute-rgt-in_binary644.1

      \[\leadsto \frac{1}{\frac{z}{\color{blue}{\frac{t}{y} \cdot 0.3333333333333333 + \left(\left(-1\right) \cdot y\right) \cdot 0.3333333333333333}}} + x \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)} \leq -\infty:\\ \;\;\;\;x + \frac{0.3333333333333333}{\frac{z}{\frac{t}{y} - y}}\\ \mathbf{elif}\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)} \leq 1.2670046298233474 \cdot 10^{+291}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{\frac{z}{0.3333333333333333 \cdot \frac{t}{y} + y \cdot -0.3333333333333333}}\\ \end{array} \]

Reproduce

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