Average Error: 3.5 → 0.4
Time: 4.5s
Precision: binary64
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
\[\begin{array}{l} t_1 := x - \frac{y}{z \cdot 3}\\ \mathbf{if}\;z \cdot 3 \leq -1.4034157054147832 \cdot 10^{-28}:\\ \;\;\;\;t_1 + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{elif}\;z \cdot 3 \leq 0.16956904717494958:\\ \;\;\;\;t_1 + \frac{\frac{1}{z}}{\frac{y}{\frac{t}{3}}}\\ \mathbf{else}:\\ \;\;\;\;t_1 + t \cdot \frac{0.3333333333333333}{z \cdot y}\\ \end{array} \]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
t_1 := x - \frac{y}{z \cdot 3}\\
\mathbf{if}\;z \cdot 3 \leq -1.4034157054147832 \cdot 10^{-28}:\\
\;\;\;\;t_1 + \frac{t}{\left(z \cdot 3\right) \cdot y}\\

\mathbf{elif}\;z \cdot 3 \leq 0.16956904717494958:\\
\;\;\;\;t_1 + \frac{\frac{1}{z}}{\frac{y}{\frac{t}{3}}}\\

\mathbf{else}:\\
\;\;\;\;t_1 + t \cdot \frac{0.3333333333333333}{z \cdot 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
 (let* ((t_1 (- x (/ y (* z 3.0)))))
   (if (<= (* z 3.0) -1.4034157054147832e-28)
     (+ t_1 (/ t (* (* z 3.0) y)))
     (if (<= (* z 3.0) 0.16956904717494958)
       (+ t_1 (/ (/ 1.0 z) (/ y (/ t 3.0))))
       (+ t_1 (* t (/ 0.3333333333333333 (* z 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 t_1 = x - (y / (z * 3.0));
	double tmp;
	if ((z * 3.0) <= -1.4034157054147832e-28) {
		tmp = t_1 + (t / ((z * 3.0) * y));
	} else if ((z * 3.0) <= 0.16956904717494958) {
		tmp = t_1 + ((1.0 / z) / (y / (t / 3.0)));
	} else {
		tmp = t_1 + (t * (0.3333333333333333 / (z * 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.5
Target1.9
Herbie0.4
\[\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 z 3) < -1.40341570541478325e-28

    1. Initial program 0.5

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

    if -1.40341570541478325e-28 < (*.f64 z 3) < 0.16956904717494958

    1. Initial program 10.5

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y} \]
    2. Applied associate-/r*_binary643.4

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{\frac{t}{z \cdot 3}}{y}} \]
    3. Applied *-un-lft-identity_binary643.4

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{\color{blue}{1 \cdot t}}{z \cdot 3}}{y} \]
    4. Applied times-frac_binary643.4

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \frac{\color{blue}{\frac{1}{z} \cdot \frac{t}{3}}}{y} \]
    5. Applied associate-/l*_binary640.3

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

    if 0.16956904717494958 < (*.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. Applied div-inv_binary640.5

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

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

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

Reproduce

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