fabs fraction 1

Percentage Accurate: 91.5% → 99.6%
Time: 7.7s
Alternatives: 7
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \end{array} \]
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
double code(double x, double y, double z) {
	return fabs((((x + 4.0) / y) - ((x / y) * z)));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = abs((((x + 4.0d0) / y) - ((x / y) * z)))
end function
public static double code(double x, double y, double z) {
	return Math.abs((((x + 4.0) / y) - ((x / y) * z)));
}
def code(x, y, z):
	return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
function code(x, y, z)
	return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z)))
end
function tmp = code(x, y, z)
	tmp = abs((((x + 4.0) / y) - ((x / y) * z)));
end
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 7 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 91.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \end{array} \]
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
double code(double x, double y, double z) {
	return fabs((((x + 4.0) / y) - ((x / y) * z)));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = abs((((x + 4.0d0) / y) - ((x / y) * z)))
end function
public static double code(double x, double y, double z) {
	return Math.abs((((x + 4.0) / y) - ((x / y) * z)));
}
def code(x, y, z):
	return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
function code(x, y, z)
	return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z)))
end
function tmp = code(x, y, z)
	tmp = abs((((x + 4.0) / y) - ((x / y) * z)));
end
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\end{array}

Alternative 1: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 5 \cdot 10^{+67}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{\frac{y}{z}}\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= y 5e+67)
   (fabs (/ (- (+ x 4.0) (* x z)) y))
   (fabs (- (/ (+ x 4.0) y) (/ x (/ y z))))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (y <= 5e+67) {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = fabs((((x + 4.0) / y) - (x / (y / z))));
	}
	return tmp;
}
NOTE: y should be positive before calling this 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 <= 5d+67) then
        tmp = abs((((x + 4.0d0) - (x * z)) / y))
    else
        tmp = abs((((x + 4.0d0) / y) - (x / (y / z))))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 5e+67) {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = Math.abs((((x + 4.0) / y) - (x / (y / z))));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if y <= 5e+67:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	else:
		tmp = math.fabs((((x + 4.0) / y) - (x / (y / z))))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (y <= 5e+67)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	else
		tmp = abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(x / Float64(y / z))));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 5e+67)
		tmp = abs((((x + 4.0) - (x * z)) / y));
	else
		tmp = abs((((x + 4.0) / y) - (x / (y / z))));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[y, 5e+67], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{+67}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{\frac{y}{z}}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 4.99999999999999976e67

    1. Initial program 87.4%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/89.3%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/87.2%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified87.2%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in y around 0 96.9%

      \[\leadsto \left|\color{blue}{\frac{\left(4 + x\right) - z \cdot x}{y}}\right| \]
    5. Step-by-step derivation
      1. +-commutative96.9%

        \[\leadsto \left|\frac{\color{blue}{\left(x + 4\right)} - z \cdot x}{y}\right| \]
    6. Simplified96.9%

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

    if 4.99999999999999976e67 < y

    1. Initial program 95.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/86.8%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/99.9%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Step-by-step derivation
      1. clear-num99.8%

        \[\leadsto \left|\frac{x + 4}{y} - x \cdot \color{blue}{\frac{1}{\frac{y}{z}}}\right| \]
      2. un-div-inv99.9%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x}{\frac{y}{z}}}\right| \]
    5. Applied egg-rr99.9%

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x}{\frac{y}{z}}}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 5 \cdot 10^{+67}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{\frac{y}{z}}\right|\\ \end{array} \]

Alternative 2: 99.0% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 3.4 \cdot 10^{-106}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= y 3.4e-106)
   (fabs (/ (- (+ x 4.0) (* x z)) y))
   (fabs (- (/ (+ x 4.0) y) (* x (/ z y))))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (y <= 3.4e-106) {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = fabs((((x + 4.0) / y) - (x * (z / y))));
	}
	return tmp;
}
NOTE: y should be positive before calling this 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.4d-106) then
        tmp = abs((((x + 4.0d0) - (x * z)) / y))
    else
        tmp = abs((((x + 4.0d0) / y) - (x * (z / y))))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 3.4e-106) {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = Math.abs((((x + 4.0) / y) - (x * (z / y))));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if y <= 3.4e-106:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	else:
		tmp = math.fabs((((x + 4.0) / y) - (x * (z / y))))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (y <= 3.4e-106)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	else
		tmp = abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(x * Float64(z / y))));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 3.4e-106)
		tmp = abs((((x + 4.0) - (x * z)) / y));
	else
		tmp = abs((((x + 4.0) / y) - (x * (z / y))));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[y, 3.4e-106], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.4 \cdot 10^{-106}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 3.39999999999999982e-106

    1. Initial program 84.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/86.6%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/83.8%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified83.8%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in y around 0 96.0%

      \[\leadsto \left|\color{blue}{\frac{\left(4 + x\right) - z \cdot x}{y}}\right| \]
    5. Step-by-step derivation
      1. +-commutative96.0%

        \[\leadsto \left|\frac{\color{blue}{\left(x + 4\right)} - z \cdot x}{y}\right| \]
    6. Simplified96.0%

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

    if 3.39999999999999982e-106 < y

    1. Initial program 97.6%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/93.4%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/99.9%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 3.4 \cdot 10^{-106}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \end{array} \]

Alternative 3: 97.7% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 1.15 \cdot 10^{+14}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= x 1.15e+14)
   (fabs (/ (- (+ x 4.0) (* x z)) y))
   (fabs (/ (- 1.0 z) (/ y x)))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (x <= 1.15e+14) {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = fabs(((1.0 - z) / (y / x)));
	}
	return tmp;
}
NOTE: y should be positive before calling this 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 (x <= 1.15d+14) then
        tmp = abs((((x + 4.0d0) - (x * z)) / y))
    else
        tmp = abs(((1.0d0 - z) / (y / x)))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= 1.15e+14) {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = Math.abs(((1.0 - z) / (y / x)));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if x <= 1.15e+14:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	else:
		tmp = math.fabs(((1.0 - z) / (y / x)))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (x <= 1.15e+14)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	else
		tmp = abs(Float64(Float64(1.0 - z) / Float64(y / x)));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= 1.15e+14)
		tmp = abs((((x + 4.0) - (x * z)) / y));
	else
		tmp = abs(((1.0 - z) / (y / x)));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[x, 1.15e+14], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(1.0 - z), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.15 \cdot 10^{+14}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.15e14

    1. Initial program 91.6%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/95.3%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/91.3%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified91.3%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in y around 0 97.9%

      \[\leadsto \left|\color{blue}{\frac{\left(4 + x\right) - z \cdot x}{y}}\right| \]
    5. Step-by-step derivation
      1. +-commutative97.9%

        \[\leadsto \left|\frac{\color{blue}{\left(x + 4\right)} - z \cdot x}{y}\right| \]
    6. Simplified97.9%

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

    if 1.15e14 < x

    1. Initial program 81.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/71.7%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/83.9%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified83.9%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in y around 0 87.7%

      \[\leadsto \left|\color{blue}{\frac{\left(4 + x\right) - z \cdot x}{y}}\right| \]
    5. Step-by-step derivation
      1. +-commutative87.7%

        \[\leadsto \left|\frac{\color{blue}{\left(x + 4\right)} - z \cdot x}{y}\right| \]
    6. Simplified87.7%

      \[\leadsto \left|\color{blue}{\frac{\left(x + 4\right) - z \cdot x}{y}}\right| \]
    7. Taylor expanded in x around inf 87.7%

      \[\leadsto \left|\color{blue}{\frac{\left(1 - z\right) \cdot x}{y}}\right| \]
    8. Step-by-step derivation
      1. associate-/l*99.7%

        \[\leadsto \left|\color{blue}{\frac{1 - z}{\frac{y}{x}}}\right| \]
    9. Simplified99.7%

      \[\leadsto \left|\color{blue}{\frac{1 - z}{\frac{y}{x}}}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.15 \cdot 10^{+14}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\ \end{array} \]

Alternative 4: 68.5% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -1.55:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 23.5:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= x -1.55)
   (fabs (/ x y))
   (if (<= x 23.5) (fabs (/ 4.0 y)) (fabs (/ z (/ y x))))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.55) {
		tmp = fabs((x / y));
	} else if (x <= 23.5) {
		tmp = fabs((4.0 / y));
	} else {
		tmp = fabs((z / (y / x)));
	}
	return tmp;
}
NOTE: y should be positive before calling this 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 (x <= (-1.55d0)) then
        tmp = abs((x / y))
    else if (x <= 23.5d0) then
        tmp = abs((4.0d0 / y))
    else
        tmp = abs((z / (y / x)))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.55) {
		tmp = Math.abs((x / y));
	} else if (x <= 23.5) {
		tmp = Math.abs((4.0 / y));
	} else {
		tmp = Math.abs((z / (y / x)));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if x <= -1.55:
		tmp = math.fabs((x / y))
	elif x <= 23.5:
		tmp = math.fabs((4.0 / y))
	else:
		tmp = math.fabs((z / (y / x)))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (x <= -1.55)
		tmp = abs(Float64(x / y));
	elseif (x <= 23.5)
		tmp = abs(Float64(4.0 / y));
	else
		tmp = abs(Float64(z / Float64(y / x)));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -1.55)
		tmp = abs((x / y));
	elseif (x <= 23.5)
		tmp = abs((4.0 / y));
	else
		tmp = abs((z / (y / x)));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[x, -1.55], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 23.5], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55:\\
\;\;\;\;\left|\frac{x}{y}\right|\\

\mathbf{elif}\;x \leq 23.5:\\
\;\;\;\;\left|\frac{4}{y}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.55000000000000004

    1. Initial program 87.8%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/86.7%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/92.4%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified92.4%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in y around 0 94.3%

      \[\leadsto \left|\color{blue}{\frac{\left(4 + x\right) - z \cdot x}{y}}\right| \]
    5. Step-by-step derivation
      1. +-commutative94.3%

        \[\leadsto \left|\frac{\color{blue}{\left(x + 4\right)} - z \cdot x}{y}\right| \]
    6. Simplified94.3%

      \[\leadsto \left|\color{blue}{\frac{\left(x + 4\right) - z \cdot x}{y}}\right| \]
    7. Taylor expanded in x around inf 91.8%

      \[\leadsto \left|\color{blue}{\frac{\left(1 - z\right) \cdot x}{y}}\right| \]
    8. Step-by-step derivation
      1. associate-/l*97.2%

        \[\leadsto \left|\color{blue}{\frac{1 - z}{\frac{y}{x}}}\right| \]
    9. Simplified97.2%

      \[\leadsto \left|\color{blue}{\frac{1 - z}{\frac{y}{x}}}\right| \]
    10. Taylor expanded in z around 0 71.6%

      \[\leadsto \left|\color{blue}{\frac{x}{y}}\right| \]

    if -1.55000000000000004 < x < 23.5

    1. Initial program 93.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/99.9%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/90.3%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified90.3%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in x around 0 72.4%

      \[\leadsto \left|\color{blue}{\frac{4}{y}}\right| \]

    if 23.5 < x

    1. Initial program 82.4%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/73.6%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/85.0%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified85.0%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in z around inf 47.0%

      \[\leadsto \left|\color{blue}{-1 \cdot \frac{z \cdot x}{y}}\right| \]
    5. Step-by-step derivation
      1. associate-*r/47.0%

        \[\leadsto \left|\color{blue}{\frac{-1 \cdot \left(z \cdot x\right)}{y}}\right| \]
      2. mul-1-neg47.0%

        \[\leadsto \left|\frac{\color{blue}{-z \cdot x}}{y}\right| \]
      3. distribute-lft-neg-out47.0%

        \[\leadsto \left|\frac{\color{blue}{\left(-z\right) \cdot x}}{y}\right| \]
      4. *-commutative47.0%

        \[\leadsto \left|\frac{\color{blue}{x \cdot \left(-z\right)}}{y}\right| \]
      5. associate-*r/58.3%

        \[\leadsto \left|\color{blue}{x \cdot \frac{-z}{y}}\right| \]
    6. Simplified58.3%

      \[\leadsto \left|\color{blue}{x \cdot \frac{-z}{y}}\right| \]
    7. Step-by-step derivation
      1. *-commutative58.3%

        \[\leadsto \left|\color{blue}{\frac{-z}{y} \cdot x}\right| \]
      2. distribute-frac-neg58.3%

        \[\leadsto \left|\color{blue}{\left(-\frac{z}{y}\right)} \cdot x\right| \]
      3. distribute-lft-neg-in58.3%

        \[\leadsto \left|\color{blue}{-\frac{z}{y} \cdot x}\right| \]
      4. associate-/r/66.0%

        \[\leadsto \left|-\color{blue}{\frac{z}{\frac{y}{x}}}\right| \]
      5. distribute-neg-frac66.0%

        \[\leadsto \left|\color{blue}{\frac{-z}{\frac{y}{x}}}\right| \]
      6. add-sqr-sqrt31.6%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}{\frac{y}{x}}\right| \]
      7. sqrt-unprod47.8%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}}{\frac{y}{x}}\right| \]
      8. sqr-neg47.8%

        \[\leadsto \left|\frac{\sqrt{\color{blue}{z \cdot z}}}{\frac{y}{x}}\right| \]
      9. sqrt-unprod34.3%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}{\frac{y}{x}}\right| \]
      10. add-sqr-sqrt66.0%

        \[\leadsto \left|\frac{\color{blue}{z}}{\frac{y}{x}}\right| \]
    8. Applied egg-rr66.0%

      \[\leadsto \left|\color{blue}{\frac{z}{\frac{y}{x}}}\right| \]
  3. Recombined 3 regimes into one program.
  4. Final simplification70.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.55:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 23.5:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \end{array} \]

Alternative 5: 85.4% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -8 \cdot 10^{+139}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;z \leq 9.4 \cdot 10^{+30}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= z -8e+139)
   (fabs (/ x (/ y z)))
   (if (<= z 9.4e+30) (fabs (/ (- -4.0 x) y)) (fabs (* x (/ z y))))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (z <= -8e+139) {
		tmp = fabs((x / (y / z)));
	} else if (z <= 9.4e+30) {
		tmp = fabs(((-4.0 - x) / y));
	} else {
		tmp = fabs((x * (z / y)));
	}
	return tmp;
}
NOTE: y should be positive before calling this 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 (z <= (-8d+139)) then
        tmp = abs((x / (y / z)))
    else if (z <= 9.4d+30) then
        tmp = abs((((-4.0d0) - x) / y))
    else
        tmp = abs((x * (z / y)))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -8e+139) {
		tmp = Math.abs((x / (y / z)));
	} else if (z <= 9.4e+30) {
		tmp = Math.abs(((-4.0 - x) / y));
	} else {
		tmp = Math.abs((x * (z / y)));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if z <= -8e+139:
		tmp = math.fabs((x / (y / z)))
	elif z <= 9.4e+30:
		tmp = math.fabs(((-4.0 - x) / y))
	else:
		tmp = math.fabs((x * (z / y)))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (z <= -8e+139)
		tmp = abs(Float64(x / Float64(y / z)));
	elseif (z <= 9.4e+30)
		tmp = abs(Float64(Float64(-4.0 - x) / y));
	else
		tmp = abs(Float64(x * Float64(z / y)));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -8e+139)
		tmp = abs((x / (y / z)));
	elseif (z <= 9.4e+30)
		tmp = abs(((-4.0 - x) / y));
	else
		tmp = abs((x * (z / y)));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[z, -8e+139], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 9.4e+30], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{+139}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\

\mathbf{elif}\;z \leq 9.4 \cdot 10^{+30}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -8.00000000000000026e139

    1. Initial program 88.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/84.2%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/89.3%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified89.3%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in z around inf 71.8%

      \[\leadsto \left|\color{blue}{-1 \cdot \frac{z \cdot x}{y}}\right| \]
    5. Step-by-step derivation
      1. associate-*r/71.8%

        \[\leadsto \left|\color{blue}{\frac{-1 \cdot \left(z \cdot x\right)}{y}}\right| \]
      2. mul-1-neg71.8%

        \[\leadsto \left|\frac{\color{blue}{-z \cdot x}}{y}\right| \]
      3. distribute-lft-neg-out71.8%

        \[\leadsto \left|\frac{\color{blue}{\left(-z\right) \cdot x}}{y}\right| \]
      4. *-commutative71.8%

        \[\leadsto \left|\frac{\color{blue}{x \cdot \left(-z\right)}}{y}\right| \]
      5. associate-*r/82.0%

        \[\leadsto \left|\color{blue}{x \cdot \frac{-z}{y}}\right| \]
    6. Simplified82.0%

      \[\leadsto \left|\color{blue}{x \cdot \frac{-z}{y}}\right| \]
    7. Step-by-step derivation
      1. clear-num81.9%

        \[\leadsto \left|x \cdot \color{blue}{\frac{1}{\frac{y}{-z}}}\right| \]
      2. un-div-inv82.1%

        \[\leadsto \left|\color{blue}{\frac{x}{\frac{y}{-z}}}\right| \]
      3. add-sqr-sqrt81.9%

        \[\leadsto \left|\frac{x}{\frac{y}{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}}\right| \]
      4. sqrt-unprod42.1%

        \[\leadsto \left|\frac{x}{\frac{y}{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}}}\right| \]
      5. sqr-neg42.1%

        \[\leadsto \left|\frac{x}{\frac{y}{\sqrt{\color{blue}{z \cdot z}}}}\right| \]
      6. sqrt-unprod0.0%

        \[\leadsto \left|\frac{x}{\frac{y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}}\right| \]
      7. add-sqr-sqrt82.1%

        \[\leadsto \left|\frac{x}{\frac{y}{\color{blue}{z}}}\right| \]
    8. Applied egg-rr82.1%

      \[\leadsto \left|\color{blue}{\frac{x}{\frac{y}{z}}}\right| \]

    if -8.00000000000000026e139 < z < 9.39999999999999979e30

    1. Initial program 95.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Simplified98.8%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    3. Taylor expanded in z around 0 91.9%

      \[\leadsto \left|\color{blue}{-1 \cdot \frac{4 + x}{y}}\right| \]
    4. Step-by-step derivation
      1. associate-*r/91.9%

        \[\leadsto \left|\color{blue}{\frac{-1 \cdot \left(4 + x\right)}{y}}\right| \]
      2. distribute-lft-in91.9%

        \[\leadsto \left|\frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y}\right| \]
      3. metadata-eval91.9%

        \[\leadsto \left|\frac{\color{blue}{-4} + -1 \cdot x}{y}\right| \]
      4. neg-mul-191.9%

        \[\leadsto \left|\frac{-4 + \color{blue}{\left(-x\right)}}{y}\right| \]
      5. sub-neg91.9%

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    5. Simplified91.9%

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]

    if 9.39999999999999979e30 < z

    1. Initial program 71.8%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/66.7%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/68.4%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified68.4%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in z around inf 77.0%

      \[\leadsto \left|\color{blue}{-1 \cdot \frac{z \cdot x}{y}}\right| \]
    5. Step-by-step derivation
      1. associate-*r/77.0%

        \[\leadsto \left|\color{blue}{\frac{-1 \cdot \left(z \cdot x\right)}{y}}\right| \]
      2. mul-1-neg77.0%

        \[\leadsto \left|\frac{\color{blue}{-z \cdot x}}{y}\right| \]
      3. distribute-lft-neg-out77.0%

        \[\leadsto \left|\frac{\color{blue}{\left(-z\right) \cdot x}}{y}\right| \]
      4. *-commutative77.0%

        \[\leadsto \left|\frac{\color{blue}{x \cdot \left(-z\right)}}{y}\right| \]
      5. associate-*r/82.3%

        \[\leadsto \left|\color{blue}{x \cdot \frac{-z}{y}}\right| \]
    6. Simplified82.3%

      \[\leadsto \left|\color{blue}{x \cdot \frac{-z}{y}}\right| \]
    7. Step-by-step derivation
      1. clear-num82.2%

        \[\leadsto \left|x \cdot \color{blue}{\frac{1}{\frac{y}{-z}}}\right| \]
      2. un-div-inv82.2%

        \[\leadsto \left|\color{blue}{\frac{x}{\frac{y}{-z}}}\right| \]
      3. add-sqr-sqrt0.0%

        \[\leadsto \left|\frac{x}{\frac{y}{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}}\right| \]
      4. sqrt-unprod56.3%

        \[\leadsto \left|\frac{x}{\frac{y}{\color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}}}\right| \]
      5. sqr-neg56.3%

        \[\leadsto \left|\frac{x}{\frac{y}{\sqrt{\color{blue}{z \cdot z}}}}\right| \]
      6. sqrt-unprod81.9%

        \[\leadsto \left|\frac{x}{\frac{y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}}\right| \]
      7. add-sqr-sqrt82.2%

        \[\leadsto \left|\frac{x}{\frac{y}{\color{blue}{z}}}\right| \]
    8. Applied egg-rr82.2%

      \[\leadsto \left|\color{blue}{\frac{x}{\frac{y}{z}}}\right| \]
    9. Step-by-step derivation
      1. clear-num82.2%

        \[\leadsto \left|\color{blue}{\frac{1}{\frac{\frac{y}{z}}{x}}}\right| \]
      2. associate-/r/82.2%

        \[\leadsto \left|\color{blue}{\frac{1}{\frac{y}{z}} \cdot x}\right| \]
      3. clear-num82.3%

        \[\leadsto \left|\color{blue}{\frac{z}{y}} \cdot x\right| \]
    10. Applied egg-rr82.3%

      \[\leadsto \left|\color{blue}{\frac{z}{y} \cdot x}\right| \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8 \cdot 10^{+139}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;z \leq 9.4 \cdot 10^{+30}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \end{array} \]

Alternative 6: 69.1% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -1.55 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -1.55) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.55) || !(x <= 4.0)) {
		tmp = fabs((x / y));
	} else {
		tmp = fabs((4.0 / y));
	}
	return tmp;
}
NOTE: y should be positive before calling this 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 ((x <= (-1.55d0)) .or. (.not. (x <= 4.0d0))) then
        tmp = abs((x / y))
    else
        tmp = abs((4.0d0 / y))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.55) || !(x <= 4.0)) {
		tmp = Math.abs((x / y));
	} else {
		tmp = Math.abs((4.0 / y));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if (x <= -1.55) or not (x <= 4.0):
		tmp = math.fabs((x / y))
	else:
		tmp = math.fabs((4.0 / y))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if ((x <= -1.55) || !(x <= 4.0))
		tmp = abs(Float64(x / y));
	else
		tmp = abs(Float64(4.0 / y));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -1.55) || ~((x <= 4.0)))
		tmp = abs((x / y));
	else
		tmp = abs((4.0 / y));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[Or[LessEqual[x, -1.55], N[Not[LessEqual[x, 4.0]], $MachinePrecision]], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;\left|\frac{x}{y}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.55000000000000004 or 4 < x

    1. Initial program 85.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/80.1%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/88.6%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified88.6%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in y around 0 91.4%

      \[\leadsto \left|\color{blue}{\frac{\left(4 + x\right) - z \cdot x}{y}}\right| \]
    5. Step-by-step derivation
      1. +-commutative91.4%

        \[\leadsto \left|\frac{\color{blue}{\left(x + 4\right)} - z \cdot x}{y}\right| \]
    6. Simplified91.4%

      \[\leadsto \left|\color{blue}{\frac{\left(x + 4\right) - z \cdot x}{y}}\right| \]
    7. Taylor expanded in x around inf 88.3%

      \[\leadsto \left|\color{blue}{\frac{\left(1 - z\right) \cdot x}{y}}\right| \]
    8. Step-by-step derivation
      1. associate-/l*96.6%

        \[\leadsto \left|\color{blue}{\frac{1 - z}{\frac{y}{x}}}\right| \]
    9. Simplified96.6%

      \[\leadsto \left|\color{blue}{\frac{1 - z}{\frac{y}{x}}}\right| \]
    10. Taylor expanded in z around 0 65.4%

      \[\leadsto \left|\color{blue}{\frac{x}{y}}\right| \]

    if -1.55000000000000004 < x < 4

    1. Initial program 93.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/99.9%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/90.1%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified90.1%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in x around 0 73.4%

      \[\leadsto \left|\color{blue}{\frac{4}{y}}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification69.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.55 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array} \]

Alternative 7: 39.6% accurate, 1.1× speedup?

\[\begin{array}{l} y = |y|\\ \\ \left|\frac{4}{y}\right| \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z) :precision binary64 (fabs (/ 4.0 y)))
y = abs(y);
double code(double x, double y, double z) {
	return fabs((4.0 / y));
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = abs((4.0d0 / y))
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	return Math.abs((4.0 / y));
}
y = abs(y)
def code(x, y, z):
	return math.fabs((4.0 / y))
y = abs(y)
function code(x, y, z)
	return abs(Float64(4.0 / y))
end
y = abs(y)
function tmp = code(x, y, z)
	tmp = abs((4.0 / y));
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\left|\frac{4}{y}\right|
\end{array}
Derivation
  1. Initial program 88.7%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Step-by-step derivation
    1. associate-*l/88.9%

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
    2. associate-*r/89.3%

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
  3. Simplified89.3%

    \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
  4. Taylor expanded in x around 0 35.8%

    \[\leadsto \left|\color{blue}{\frac{4}{y}}\right| \]
  5. Final simplification35.8%

    \[\leadsto \left|\frac{4}{y}\right| \]

Reproduce

?
herbie shell --seed 2023279 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))