Average Error: 11.6 → 3.0
Time: 2.9s
Precision: binary64
\[x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -4.9327349569339891 \cdot 10^{-308}:\\ \;\;\;\;x - \frac{y \cdot 2}{z \cdot 2 - t \cdot \frac{y}{z}}\\ \mathbf{elif}\;t \le 7.00890351588839801 \cdot 10^{-130}:\\ \;\;\;\;x - \left(y \cdot 2\right) \cdot \frac{z}{2 \cdot {z}^{2} - t \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{1}{\frac{z \cdot 2 - \frac{t}{\frac{z}{y}}}{y \cdot 2}}\\ \end{array}\]
x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}
\begin{array}{l}
\mathbf{if}\;t \le -4.9327349569339891 \cdot 10^{-308}:\\
\;\;\;\;x - \frac{y \cdot 2}{z \cdot 2 - t \cdot \frac{y}{z}}\\

\mathbf{elif}\;t \le 7.00890351588839801 \cdot 10^{-130}:\\
\;\;\;\;x - \left(y \cdot 2\right) \cdot \frac{z}{2 \cdot {z}^{2} - t \cdot y}\\

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

\end{array}
double code(double x, double y, double z, double t) {
	return ((double) (x - ((double) (((double) (((double) (y * 2.0)) * z)) / ((double) (((double) (((double) (z * 2.0)) * z)) - ((double) (y * t))))))));
}
double code(double x, double y, double z, double t) {
	double VAR;
	if ((t <= -4.932734956933989e-308)) {
		VAR = ((double) (x - ((double) (((double) (y * 2.0)) / ((double) (((double) (z * 2.0)) - ((double) (t * ((double) (y / z))))))))));
	} else {
		double VAR_1;
		if ((t <= 7.008903515888398e-130)) {
			VAR_1 = ((double) (x - ((double) (((double) (y * 2.0)) * ((double) (z / ((double) (((double) (2.0 * ((double) pow(z, 2.0)))) - ((double) (t * y))))))))));
		} else {
			VAR_1 = ((double) (x - ((double) (1.0 / ((double) (((double) (((double) (z * 2.0)) - ((double) (t / ((double) (z / y)))))) / ((double) (y * 2.0))))))));
		}
		VAR = VAR_1;
	}
	return VAR;
}

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

Original11.6
Target0.1
Herbie3.0
\[x - \frac{1}{\frac{z}{y} - \frac{\frac{t}{2}}{z}}\]

Derivation

  1. Split input into 3 regimes
  2. if t < -4.9327349569339891e-308

    1. Initial program 11.5

      \[x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}\]
    2. Using strategy rm
    3. Applied associate-/l*6.7

      \[\leadsto x - \color{blue}{\frac{y \cdot 2}{\frac{\left(z \cdot 2\right) \cdot z - y \cdot t}{z}}}\]
    4. Using strategy rm
    5. Applied div-sub6.7

      \[\leadsto x - \frac{y \cdot 2}{\color{blue}{\frac{\left(z \cdot 2\right) \cdot z}{z} - \frac{y \cdot t}{z}}}\]
    6. Simplified2.8

      \[\leadsto x - \frac{y \cdot 2}{\color{blue}{z \cdot 2} - \frac{y \cdot t}{z}}\]
    7. Simplified2.8

      \[\leadsto x - \frac{y \cdot 2}{z \cdot 2 - \color{blue}{\frac{t \cdot y}{z}}}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity2.8

      \[\leadsto x - \frac{y \cdot 2}{z \cdot 2 - \frac{t \cdot y}{\color{blue}{1 \cdot z}}}\]
    10. Applied times-frac2.5

      \[\leadsto x - \frac{y \cdot 2}{z \cdot 2 - \color{blue}{\frac{t}{1} \cdot \frac{y}{z}}}\]
    11. Simplified2.5

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

    if -4.9327349569339891e-308 < t < 7.00890351588839801e-130

    1. Initial program 14.3

      \[x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity14.3

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

      \[\leadsto x - \color{blue}{\frac{y \cdot 2}{1} \cdot \frac{z}{\left(z \cdot 2\right) \cdot z - y \cdot t}}\]
    5. Simplified8.6

      \[\leadsto x - \color{blue}{\left(y \cdot 2\right)} \cdot \frac{z}{\left(z \cdot 2\right) \cdot z - y \cdot t}\]
    6. Simplified8.6

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

    if 7.00890351588839801e-130 < t

    1. Initial program 10.5

      \[x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}\]
    2. Using strategy rm
    3. Applied associate-/l*5.8

      \[\leadsto x - \color{blue}{\frac{y \cdot 2}{\frac{\left(z \cdot 2\right) \cdot z - y \cdot t}{z}}}\]
    4. Using strategy rm
    5. Applied div-sub5.8

      \[\leadsto x - \frac{y \cdot 2}{\color{blue}{\frac{\left(z \cdot 2\right) \cdot z}{z} - \frac{y \cdot t}{z}}}\]
    6. Simplified2.9

      \[\leadsto x - \frac{y \cdot 2}{\color{blue}{z \cdot 2} - \frac{y \cdot t}{z}}\]
    7. Simplified2.9

      \[\leadsto x - \frac{y \cdot 2}{z \cdot 2 - \color{blue}{\frac{t \cdot y}{z}}}\]
    8. Using strategy rm
    9. Applied associate-/l*1.5

      \[\leadsto x - \frac{y \cdot 2}{z \cdot 2 - \color{blue}{\frac{t}{\frac{z}{y}}}}\]
    10. Using strategy rm
    11. Applied clear-num1.5

      \[\leadsto x - \color{blue}{\frac{1}{\frac{z \cdot 2 - \frac{t}{\frac{z}{y}}}{y \cdot 2}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -4.9327349569339891 \cdot 10^{-308}:\\ \;\;\;\;x - \frac{y \cdot 2}{z \cdot 2 - t \cdot \frac{y}{z}}\\ \mathbf{elif}\;t \le 7.00890351588839801 \cdot 10^{-130}:\\ \;\;\;\;x - \left(y \cdot 2\right) \cdot \frac{z}{2 \cdot {z}^{2} - t \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{1}{\frac{z \cdot 2 - \frac{t}{\frac{z}{y}}}{y \cdot 2}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020153 
(FPCore (x y z t)
  :name "Numeric.AD.Rank1.Halley:findZero from ad-4.2.4"
  :precision binary64

  :herbie-target
  (- x (/ 1.0 (- (/ z y) (/ (/ t 2.0) z))))

  (- x (/ (* (* y 2.0) z) (- (* (* z 2.0) z) (* y t)))))