Average Error: 3.5 → 0.7
Time: 15.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}\;t \leq -2.5554260518788247 \cdot 10^{-136}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{elif}\;t \leq 4.047534560469752 \cdot 10^{-06}:\\ \;\;\;\;x + \frac{-0.3333333333333333}{z} \cdot \left(y - \frac{t}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + t \cdot \frac{0.3333333333333333}{y \cdot z}\\ \end{array}\]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;t \leq -2.5554260518788247 \cdot 10^{-136}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\

\mathbf{elif}\;t \leq 4.047534560469752 \cdot 10^{-06}:\\
\;\;\;\;x + \frac{-0.3333333333333333}{z} \cdot \left(y - \frac{t}{y}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + t \cdot \frac{0.3333333333333333}{y \cdot z}\\

\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 (<= t -2.5554260518788247e-136)
   (+ (- x (/ y (* z 3.0))) (/ t (* y (* z 3.0))))
   (if (<= t 4.047534560469752e-06)
     (+ x (* (/ -0.3333333333333333 z) (- y (/ t y))))
     (+ (- x (/ y (* z 3.0))) (* t (/ 0.3333333333333333 (* y z)))))))
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 (t <= -2.5554260518788247e-136) {
		tmp = (x - (y / (z * 3.0))) + (t / (y * (z * 3.0)));
	} else if (t <= 4.047534560469752e-06) {
		tmp = x + ((-0.3333333333333333 / z) * (y - (t / y)));
	} else {
		tmp = (x - (y / (z * 3.0))) + (t * (0.3333333333333333 / (y * z)));
	}
	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.7
Herbie0.7
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]

Derivation

  1. Split input into 3 regimes
  2. if t < -2.5554260518788247e-136

    1. Initial program 1.5

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

    if -2.5554260518788247e-136 < t < 4.04753456046975e-6

    1. Initial program 6.4

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

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

    if 4.04753456046975e-6 < t

    1. Initial program 0.6

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Using strategy rm
    3. Applied div-inv_binary64_188300.7

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

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

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

Reproduce

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