Average Error: 12.3 → 2.2
Time: 2.7s
Precision: binary64
\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\begin{array}{l} t_0 := \frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{if}\;t_0 \leq -5 \cdot 10^{+129}:\\ \;\;\;\;x + \frac{z}{\frac{1}{x}} \cdot \frac{-1}{y}\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{-121}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+277}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* x (- y z)) y)))
   (if (<= t_0 -5e+129)
     (+ x (* (/ z (/ 1.0 x)) (/ -1.0 y)))
     (if (<= t_0 2e-121)
       (* x (- 1.0 (/ z y)))
       (if (<= t_0 2e+277) (- x (/ (* x z) y)) (- x (/ x (/ y z))))))))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
	double t_0 = (x * (y - z)) / y;
	double tmp;
	if (t_0 <= -5e+129) {
		tmp = x + ((z / (1.0 / x)) * (-1.0 / y));
	} else if (t_0 <= 2e-121) {
		tmp = x * (1.0 - (z / y));
	} else if (t_0 <= 2e+277) {
		tmp = x - ((x * z) / y);
	} else {
		tmp = x - (x / (y / z));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * (y - z)) / y
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x * (y - z)) / y
    if (t_0 <= (-5d+129)) then
        tmp = x + ((z / (1.0d0 / x)) * ((-1.0d0) / y))
    else if (t_0 <= 2d-121) then
        tmp = x * (1.0d0 - (z / y))
    else if (t_0 <= 2d+277) then
        tmp = x - ((x * z) / y)
    else
        tmp = x - (x / (y / z))
    end if
    code = tmp
end function
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 t_0 = (x * (y - z)) / y;
	double tmp;
	if (t_0 <= -5e+129) {
		tmp = x + ((z / (1.0 / x)) * (-1.0 / y));
	} else if (t_0 <= 2e-121) {
		tmp = x * (1.0 - (z / y));
	} else if (t_0 <= 2e+277) {
		tmp = x - ((x * z) / y);
	} else {
		tmp = x - (x / (y / z));
	}
	return tmp;
}
def code(x, y, z):
	return (x * (y - z)) / y
def code(x, y, z):
	t_0 = (x * (y - z)) / y
	tmp = 0
	if t_0 <= -5e+129:
		tmp = x + ((z / (1.0 / x)) * (-1.0 / y))
	elif t_0 <= 2e-121:
		tmp = x * (1.0 - (z / y))
	elif t_0 <= 2e+277:
		tmp = x - ((x * z) / y)
	else:
		tmp = x - (x / (y / z))
	return tmp
function code(x, y, z)
	return Float64(Float64(x * Float64(y - z)) / y)
end
function code(x, y, z)
	t_0 = Float64(Float64(x * Float64(y - z)) / y)
	tmp = 0.0
	if (t_0 <= -5e+129)
		tmp = Float64(x + Float64(Float64(z / Float64(1.0 / x)) * Float64(-1.0 / y)));
	elseif (t_0 <= 2e-121)
		tmp = Float64(x * Float64(1.0 - Float64(z / y)));
	elseif (t_0 <= 2e+277)
		tmp = Float64(x - Float64(Float64(x * z) / y));
	else
		tmp = Float64(x - Float64(x / Float64(y / z)));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x * (y - z)) / y;
end
function tmp_2 = code(x, y, z)
	t_0 = (x * (y - z)) / y;
	tmp = 0.0;
	if (t_0 <= -5e+129)
		tmp = x + ((z / (1.0 / x)) * (-1.0 / y));
	elseif (t_0 <= 2e-121)
		tmp = x * (1.0 - (z / y));
	elseif (t_0 <= 2e+277)
		tmp = x - ((x * z) / y);
	else
		tmp = x - (x / (y / z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+129], N[(x + N[(N[(z / N[(1.0 / x), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e-121], N[(x * N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+277], N[(x - N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
t_0 := \frac{x \cdot \left(y - z\right)}{y}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+129}:\\
\;\;\;\;x + \frac{z}{\frac{1}{x}} \cdot \frac{-1}{y}\\

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-121}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+277}:\\
\;\;\;\;x - \frac{x \cdot z}{y}\\

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


\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.3
Target3.3
Herbie2.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 4 regimes
  2. if (/.f64 (*.f64 x (-.f64 y z)) y) < -5.0000000000000003e129

    1. Initial program 24.6

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Simplified8.0

      \[\leadsto \color{blue}{x - \frac{z}{\frac{y}{x}}} \]
    3. Applied egg-rr8.7

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

    if -5.0000000000000003e129 < (/.f64 (*.f64 x (-.f64 y z)) y) < 2e-121

    1. Initial program 6.5

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Simplified2.9

      \[\leadsto \color{blue}{x - \frac{z}{\frac{y}{x}}} \]
    3. Taylor expanded in x around 0 0.7

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

    if 2e-121 < (/.f64 (*.f64 x (-.f64 y z)) y) < 2.00000000000000001e277

    1. Initial program 0.3

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Simplified4.7

      \[\leadsto \color{blue}{x - \frac{z}{\frac{y}{x}}} \]
    3. Taylor expanded in z around 0 0.2

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

    if 2.00000000000000001e277 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 53.7

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Simplified3.7

      \[\leadsto \color{blue}{x - \frac{z}{\frac{y}{x}}} \]
    3. Applied egg-rr3.6

      \[\leadsto x - \color{blue}{\left(\frac{z}{y} \cdot {\left(\sqrt[3]{x}\right)}^{2}\right) \cdot \sqrt[3]{x}} \]
    4. Taylor expanded in z around 0 19.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -5 \cdot 10^{+129}:\\ \;\;\;\;x + \frac{z}{\frac{1}{x}} \cdot \frac{-1}{y}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq 2 \cdot 10^{-121}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq 2 \cdot 10^{+277}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \end{array} \]

Reproduce

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