Average Error: 13.0 → 1.6
Time: 3.0s
Precision: binary64
\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -3.764995542857667 \cdot 10^{-12}:\\ \;\;\;\;\left(1 - \frac{z}{y}\right) \cdot x\\ \mathbf{elif}\;y \leq 5.8766865566272 \cdot 10^{+33}:\\ \;\;\;\;x - \frac{z \cdot x}{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
 (if (<= y -3.764995542857667e-12)
   (* (- 1.0 (/ z y)) x)
   (if (<= y 5.8766865566272e+33) (- x (/ (* z x) 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 tmp;
	if (y <= -3.764995542857667e-12) {
		tmp = (1.0 - (z / y)) * x;
	} else if (y <= 5.8766865566272e+33) {
		tmp = x - ((z * x) / 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) :: tmp
    if (y <= (-3.764995542857667d-12)) then
        tmp = (1.0d0 - (z / y)) * x
    else if (y <= 5.8766865566272d+33) then
        tmp = x - ((z * x) / 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 tmp;
	if (y <= -3.764995542857667e-12) {
		tmp = (1.0 - (z / y)) * x;
	} else if (y <= 5.8766865566272e+33) {
		tmp = x - ((z * x) / y);
	} else {
		tmp = x - (x / (y / z));
	}
	return tmp;
}
def code(x, y, z):
	return (x * (y - z)) / y
def code(x, y, z):
	tmp = 0
	if y <= -3.764995542857667e-12:
		tmp = (1.0 - (z / y)) * x
	elif y <= 5.8766865566272e+33:
		tmp = x - ((z * x) / 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)
	tmp = 0.0
	if (y <= -3.764995542857667e-12)
		tmp = Float64(Float64(1.0 - Float64(z / y)) * x);
	elseif (y <= 5.8766865566272e+33)
		tmp = Float64(x - Float64(Float64(z * x) / 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)
	tmp = 0.0;
	if (y <= -3.764995542857667e-12)
		tmp = (1.0 - (z / y)) * x;
	elseif (y <= 5.8766865566272e+33)
		tmp = x - ((z * x) / 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_] := If[LessEqual[y, -3.764995542857667e-12], N[(N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, 5.8766865566272e+33], N[(x - N[(N[(z * x), $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}
\mathbf{if}\;y \leq -3.764995542857667 \cdot 10^{-12}:\\
\;\;\;\;\left(1 - \frac{z}{y}\right) \cdot x\\

\mathbf{elif}\;y \leq 5.8766865566272 \cdot 10^{+33}:\\
\;\;\;\;x - \frac{z \cdot x}{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

Original13.0
Target3.3
Herbie1.6
\[\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 < -3.7649955428576671e-12

    1. Initial program 16.7

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

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

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

    if -3.7649955428576671e-12 < y < 5.87668655662720012e33

    1. Initial program 6.7

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

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

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

    if 5.87668655662720012e33 < y

    1. Initial program 19.3

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

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

      \[\leadsto x - \color{blue}{\frac{1}{y} \cdot \frac{z}{\frac{1}{x}}} \]
    4. Taylor expanded in z around 0 6.7

      \[\leadsto x - \frac{1}{y} \cdot \color{blue}{\left(z \cdot x\right)} \]
    5. Applied egg-rr0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.764995542857667 \cdot 10^{-12}:\\ \;\;\;\;\left(1 - \frac{z}{y}\right) \cdot x\\ \mathbf{elif}\;y \leq 5.8766865566272 \cdot 10^{+33}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \end{array} \]

Reproduce

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