Average Error: 12.5 → 3.2
Time: 2.5s
Precision: binary64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;y \leq -4.703315838445289 \cdot 10^{-269}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;y \leq 2.8551718262738205 \cdot 10^{-60}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;y \leq -4.703315838445289 \cdot 10^{-269}:\\
\;\;\;\;x \cdot \frac{y - z}{y}\\

\mathbf{elif}\;y \leq 2.8551718262738205 \cdot 10^{-60}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (if (<= y -4.703315838445289e-269)
   (* x (/ (- y z) y))
   (if (<= y 2.8551718262738205e-60) (* (- y z) (/ x y)) (/ x (/ y (- y z))))))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
	double tmp;
	if (y <= -4.703315838445289e-269) {
		tmp = x * ((y - z) / y);
	} else if (y <= 2.8551718262738205e-60) {
		tmp = (y - z) * (x / y);
	} else {
		tmp = x / (y / (y - z));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.5
Target3.2
Herbie3.2
\[\begin{array}{l} \mathbf{if}\;z < -2.060202331921739 \cdot 10^{+104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z < 1.6939766013828526 \cdot 10^{+213}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if y < -4.7033158384452891e-269

    1. Initial program 12.4

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

      \[\leadsto \frac{x \cdot \left(y - z\right)}{\color{blue}{1 \cdot y}}\]
    4. Applied times-frac_binary642.8

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

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

    if -4.7033158384452891e-269 < y < 2.85517182627382053e-60

    1. Initial program 8.6

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Using strategy rm
    5. Applied associate-/r/_binary649.7

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

    if 2.85517182627382053e-60 < y

    1. Initial program 14.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.703315838445289 \cdot 10^{-269}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;y \leq 2.8551718262738205 \cdot 10^{-60}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020219 
(FPCore (x y z)
  :name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))

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