Average Error: 4.0 → 1.2
Time: 10.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 -6.22726511139875 \cdot 10^{+176}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\ \mathbf{elif}\;t \leq 5.53228479313245 \cdot 10^{-26}:\\ \;\;\;\;x + \frac{1}{\frac{z \cdot 3}{\frac{t}{y} - y}}\\ \mathbf{else}:\\ \;\;\;\;\left(x + 0.3333333333333333 \cdot \frac{t}{y \cdot z}\right) - 0.3333333333333333 \cdot \frac{y}{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 -6.22726511139875 \cdot 10^{+176}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\

\mathbf{elif}\;t \leq 5.53228479313245 \cdot 10^{-26}:\\
\;\;\;\;x + \frac{1}{\frac{z \cdot 3}{\frac{t}{y} - y}}\\

\mathbf{else}:\\
\;\;\;\;\left(x + 0.3333333333333333 \cdot \frac{t}{y \cdot z}\right) - 0.3333333333333333 \cdot \frac{y}{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 -6.22726511139875e+176)
   (+ (- x (/ y (* z 3.0))) (/ t (* y (* z 3.0))))
   (if (<= t 5.53228479313245e-26)
     (+ x (/ 1.0 (/ (* z 3.0) (- (/ t y) y))))
     (-
      (+ x (* 0.3333333333333333 (/ t (* y z))))
      (* 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 <= -6.22726511139875e+176) {
		tmp = (x - (y / (z * 3.0))) + (t / (y * (z * 3.0)));
	} else if (t <= 5.53228479313245e-26) {
		tmp = x + (1.0 / ((z * 3.0) / ((t / y) - y)));
	} else {
		tmp = (x + (0.3333333333333333 * (t / (y * z)))) - (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

Original4.0
Target1.8
Herbie1.2
\[\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 < -6.2272651113987501e176

    1. Initial program 1.3

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

    if -6.2272651113987501e176 < t < 5.53228479313245034e-26

    1. Initial program 5.4

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

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

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

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

      \[\leadsto \frac{0.3333333333333333}{\color{blue}{\frac{1}{\frac{\frac{t}{y} - y}{z}}}} + x \]
    6. Applied clear-num_binary641.4

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

      \[\leadsto \frac{1}{\color{blue}{3 \cdot \frac{z}{\frac{t}{y} - y}}} + x \]
    8. Applied associate-*r/_binary641.3

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

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

    if 5.53228479313245034e-26 < t

    1. Initial program 0.6

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-0.3333333333333333}{z}, y - \frac{t}{y}, x\right)} \]
    3. Taylor expanded in z around 0 0.6

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

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

Reproduce

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