Average Error: 3.8 → 1.6
Time: 20.2s
Precision: binary64
\[\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 -7.504380362777868 \cdot 10^{+228}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{3}}{z \cdot y}\\ \mathbf{elif}\;z \cdot 3 \leq 1.6069296357631238 \cdot 10^{-82}:\\ \;\;\;\;x + \frac{\frac{t}{y} - y}{z \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot 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 -7.504380362777868 \cdot 10^{+228}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{3}}{z \cdot y}\\

\mathbf{elif}\;z \cdot 3 \leq 1.6069296357631238 \cdot 10^{-82}:\\
\;\;\;\;x + \frac{\frac{t}{y} - y}{z \cdot 3}\\

\mathbf{else}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \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
 (if (<= (* z 3.0) -7.504380362777868e+228)
   (+ (- x (/ y (* z 3.0))) (/ (/ t 3.0) (* z y)))
   (if (<= (* z 3.0) 1.6069296357631238e-82)
     (+ x (/ (- (/ t y) y) (* z 3.0)))
     (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) 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) <= -7.504380362777868e+228) {
		tmp = (x - (y / (z * 3.0))) + ((t / 3.0) / (z * y));
	} else if ((z * 3.0) <= 1.6069296357631238e-82) {
		tmp = x + (((t / y) - y) / (z * 3.0));
	} else {
		tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * 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.8
Target1.8
Herbie1.6
\[\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) < -7.5043803627778679e228

    1. Initial program 0.9

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

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

    if -7.5043803627778679e228 < (*.f64 z 3) < 1.6069296357631238e-82

    1. Initial program 6.9

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

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

    if 1.6069296357631238e-82 < (*.f64 z 3)

    1. Initial program 0.7

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot 3 \leq -7.504380362777868 \cdot 10^{+228}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{3}}{z \cdot y}\\ \mathbf{elif}\;z \cdot 3 \leq 1.6069296357631238 \cdot 10^{-82}:\\ \;\;\;\;x + \frac{\frac{t}{y} - y}{z \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \end{array}\]

Reproduce

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