Average Error: 12.8 → 2.7
Time: 3.0s
Precision: binary64
\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -1.096355097136844 \cdot 10^{+49}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \leq -3.046667818042877 \cdot 10^{-274}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{z}{\sqrt[3]{y} \cdot \sqrt[3]{y}} \cdot \frac{x}{\sqrt[3]{y}}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (if (<= x -1.096355097136844e+49)
   (* x (/ (- y z) y))
   (if (<= x -3.046667818042877e-274)
     (- x (/ (* x z) y))
     (- x (* (/ z (* (cbrt y) (cbrt y))) (/ x (cbrt y)))))))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.096355097136844e+49) {
		tmp = x * ((y - z) / y);
	} else if (x <= -3.046667818042877e-274) {
		tmp = x - ((x * z) / y);
	} else {
		tmp = x - ((z / (cbrt(y) * cbrt(y))) * (x / cbrt(y)));
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.096355097136844e+49) {
		tmp = x * ((y - z) / y);
	} else if (x <= -3.046667818042877e-274) {
		tmp = x - ((x * z) / y);
	} else {
		tmp = x - ((z / (Math.cbrt(y) * Math.cbrt(y))) * (x / Math.cbrt(y)));
	}
	return tmp;
}
function code(x, y, z)
	return Float64(Float64(x * Float64(y - z)) / y)
end
function code(x, y, z)
	tmp = 0.0
	if (x <= -1.096355097136844e+49)
		tmp = Float64(x * Float64(Float64(y - z) / y));
	elseif (x <= -3.046667818042877e-274)
		tmp = Float64(x - Float64(Float64(x * z) / y));
	else
		tmp = Float64(x - Float64(Float64(z / Float64(cbrt(y) * cbrt(y))) * Float64(x / cbrt(y))));
	end
	return tmp
end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[x, -1.096355097136844e+49], N[(x * N[(N[(y - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3.046667818042877e-274], N[(x - N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(z / N[(N[Power[y, 1/3], $MachinePrecision] * N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;x \leq -1.096355097136844 \cdot 10^{+49}:\\
\;\;\;\;x \cdot \frac{y - z}{y}\\

\mathbf{elif}\;x \leq -3.046667818042877 \cdot 10^{-274}:\\
\;\;\;\;x - \frac{x \cdot z}{y}\\

\mathbf{else}:\\
\;\;\;\;x - \frac{z}{\sqrt[3]{y} \cdot \sqrt[3]{y}} \cdot \frac{x}{\sqrt[3]{y}}\\


\end{array}

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.8
Target3.2
Herbie2.7
\[\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 x < -1.096355097136844e49

    1. Initial program 28.3

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Applied *-un-lft-identity_binary6428.3

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

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y - z}{y}} \]
    4. Simplified0.1

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

    if -1.096355097136844e49 < x < -3.0466678180428768e-274

    1. Initial program 4.4

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Taylor expanded in y around 0 2.2

      \[\leadsto \color{blue}{x - \frac{z \cdot x}{y}} \]
    3. Applied sub-neg_binary642.2

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

    if -3.0466678180428768e-274 < x

    1. Initial program 12.8

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Taylor expanded in y around 0 5.2

      \[\leadsto \color{blue}{x - \frac{z \cdot x}{y}} \]
    3. Applied add-cube-cbrt_binary645.6

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

      \[\leadsto x - \color{blue}{\frac{z}{\sqrt[3]{y} \cdot \sqrt[3]{y}} \cdot \frac{x}{\sqrt[3]{y}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.096355097136844 \cdot 10^{+49}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \leq -3.046667818042877 \cdot 10^{-274}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{z}{\sqrt[3]{y} \cdot \sqrt[3]{y}} \cdot \frac{x}{\sqrt[3]{y}}\\ \end{array} \]

Reproduce

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