fabs fraction 1

Percentage Accurate: 91.6% → 99.6%
Time: 7.5s
Alternatives: 9
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 9 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.6% 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, 0.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;y_m \leq 2 \cdot 10^{-59}:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y_m}, \frac{-4 - x}{y_m}\right)\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= y_m 2e-59)
   (fabs (/ (- (+ 4.0 x) (* x z)) y_m))
   (fabs (fma x (/ z y_m) (/ (- -4.0 x) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (y_m <= 2e-59) {
		tmp = fabs((((4.0 + x) - (x * z)) / y_m));
	} else {
		tmp = fabs(fma(x, (z / y_m), ((-4.0 - x) / y_m)));
	}
	return tmp;
}
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (y_m <= 2e-59)
		tmp = abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y_m));
	else
		tmp = abs(fma(x, Float64(z / y_m), Float64(Float64(-4.0 - x) / y_m)));
	end
	return tmp
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[y$95$m, 2e-59], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision] + N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;y_m \leq 2 \cdot 10^{-59}:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y_m}, \frac{-4 - x}{y_m}\right)\right|\\


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

    1. Initial program 90.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in y around 0 98.3%

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

    if 2.0000000000000001e-59 < y

    1. Initial program 96.2%

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

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

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

Alternative 2: 99.8% accurate, 0.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;\left|\frac{4 + x}{y_m} - z \cdot \frac{x}{y_m}\right| \leq 0.1:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y_m} \cdot \left(\frac{4}{x} + \left(1 - z\right)\right)\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= (fabs (- (/ (+ 4.0 x) y_m) (* z (/ x y_m)))) 0.1)
   (fabs (/ (- (+ 4.0 x) (* x z)) y_m))
   (fabs (* (/ x y_m) (+ (/ 4.0 x) (- 1.0 z))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (fabs((((4.0 + x) / y_m) - (z * (x / y_m)))) <= 0.1) {
		tmp = fabs((((4.0 + x) - (x * z)) / y_m));
	} else {
		tmp = fabs(((x / y_m) * ((4.0 / x) + (1.0 - z))));
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (abs((((4.0d0 + x) / y_m) - (z * (x / y_m)))) <= 0.1d0) then
        tmp = abs((((4.0d0 + x) - (x * z)) / y_m))
    else
        tmp = abs(((x / y_m) * ((4.0d0 / x) + (1.0d0 - z))))
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (Math.abs((((4.0 + x) / y_m) - (z * (x / y_m)))) <= 0.1) {
		tmp = Math.abs((((4.0 + x) - (x * z)) / y_m));
	} else {
		tmp = Math.abs(((x / y_m) * ((4.0 / x) + (1.0 - z))));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if math.fabs((((4.0 + x) / y_m) - (z * (x / y_m)))) <= 0.1:
		tmp = math.fabs((((4.0 + x) - (x * z)) / y_m))
	else:
		tmp = math.fabs(((x / y_m) * ((4.0 / x) + (1.0 - z))))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (abs(Float64(Float64(Float64(4.0 + x) / y_m) - Float64(z * Float64(x / y_m)))) <= 0.1)
		tmp = abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y_m));
	else
		tmp = abs(Float64(Float64(x / y_m) * Float64(Float64(4.0 / x) + Float64(1.0 - z))));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (abs((((4.0 + x) / y_m) - (z * (x / y_m)))) <= 0.1)
		tmp = abs((((4.0 + x) - (x * z)) / y_m));
	else
		tmp = abs(((x / y_m) * ((4.0 / x) + (1.0 - z))));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] / y$95$m), $MachinePrecision] - N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.1], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x / y$95$m), $MachinePrecision] * N[(N[(4.0 / x), $MachinePrecision] + N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;\left|\frac{4 + x}{y_m} - z \cdot \frac{x}{y_m}\right| \leq 0.1:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y_m} \cdot \left(\frac{4}{x} + \left(1 - z\right)\right)\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) < 0.10000000000000001

    1. Initial program 90.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in y around 0 99.9%

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

    if 0.10000000000000001 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)))

    1. Initial program 92.6%

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

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

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

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{z}{\frac{y}{x}}}\right| \]
    4. Step-by-step derivation
      1. div-inv92.6%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{z \cdot \frac{1}{\frac{y}{x}}}\right| \]
      2. clear-num92.6%

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

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

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

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

        \[\leadsto \left|\frac{4 + x}{y} + \color{blue}{\frac{-z}{\frac{y}{x}}}\right| \]
      7. add-sqr-sqrt46.7%

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

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

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

        \[\leadsto \left|\frac{4 + x}{y} + \frac{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}{\frac{y}{x}}\right| \]
      11. add-sqr-sqrt90.6%

        \[\leadsto \left|\frac{4 + x}{y} + \frac{\color{blue}{z}}{\frac{y}{x}}\right| \]
      12. frac-2neg90.6%

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

        \[\leadsto \left|\color{blue}{\frac{\left(4 + x\right) \cdot \left(-\frac{y}{x}\right) + y \cdot \left(-z\right)}{y \cdot \left(-\frac{y}{x}\right)}}\right| \]
    5. Applied egg-rr79.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 86.9% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1.92 \cdot 10^{-44} \lor \neg \left(x \leq 4.8 \cdot 10^{-32}\right):\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-4 - x}{y_m}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (or (<= x -1.92e-44) (not (<= x 4.8e-32)))
   (fabs (* x (/ (- 1.0 z) y_m)))
   (fabs (/ (- -4.0 x) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if ((x <= -1.92e-44) || !(x <= 4.8e-32)) {
		tmp = fabs((x * ((1.0 - z) / y_m)));
	} else {
		tmp = fabs(((-4.0 - x) / y_m));
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x <= (-1.92d-44)) .or. (.not. (x <= 4.8d-32))) then
        tmp = abs((x * ((1.0d0 - z) / y_m)))
    else
        tmp = abs((((-4.0d0) - x) / y_m))
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if ((x <= -1.92e-44) || !(x <= 4.8e-32)) {
		tmp = Math.abs((x * ((1.0 - z) / y_m)));
	} else {
		tmp = Math.abs(((-4.0 - x) / y_m));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if (x <= -1.92e-44) or not (x <= 4.8e-32):
		tmp = math.fabs((x * ((1.0 - z) / y_m)))
	else:
		tmp = math.fabs(((-4.0 - x) / y_m))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if ((x <= -1.92e-44) || !(x <= 4.8e-32))
		tmp = abs(Float64(x * Float64(Float64(1.0 - z) / y_m)));
	else
		tmp = abs(Float64(Float64(-4.0 - x) / y_m));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if ((x <= -1.92e-44) || ~((x <= 4.8e-32)))
		tmp = abs((x * ((1.0 - z) / y_m)));
	else
		tmp = abs(((-4.0 - x) / y_m));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -1.92e-44], N[Not[LessEqual[x, 4.8e-32]], $MachinePrecision]], N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.92 \cdot 10^{-44} \lor \neg \left(x \leq 4.8 \cdot 10^{-32}\right):\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y_m}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y_m}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.91999999999999992e-44 or 4.8000000000000003e-32 < x

    1. Initial program 90.4%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in y around 0 94.5%

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{1 - z}{y}} \cdot x\right| \]
    7. Applied egg-rr97.6%

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

    if -1.91999999999999992e-44 < x < 4.8000000000000003e-32

    1. Initial program 93.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.92 \cdot 10^{-44} \lor \neg \left(x \leq 4.8 \cdot 10^{-32}\right):\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \end{array} \]

Alternative 4: 86.9% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{-47}:\\ \;\;\;\;\left|\frac{x}{\frac{y_m}{1 - z}}\right|\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-31}:\\ \;\;\;\;\left|\frac{-4 - x}{y_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y_m}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -5.5e-47)
   (fabs (/ x (/ y_m (- 1.0 z))))
   (if (<= x 1.2e-31)
     (fabs (/ (- -4.0 x) y_m))
     (fabs (* x (/ (- 1.0 z) y_m))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -5.5e-47) {
		tmp = fabs((x / (y_m / (1.0 - z))));
	} else if (x <= 1.2e-31) {
		tmp = fabs(((-4.0 - x) / y_m));
	} else {
		tmp = fabs((x * ((1.0 - z) / y_m)));
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-5.5d-47)) then
        tmp = abs((x / (y_m / (1.0d0 - z))))
    else if (x <= 1.2d-31) then
        tmp = abs((((-4.0d0) - x) / y_m))
    else
        tmp = abs((x * ((1.0d0 - z) / y_m)))
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -5.5e-47) {
		tmp = Math.abs((x / (y_m / (1.0 - z))));
	} else if (x <= 1.2e-31) {
		tmp = Math.abs(((-4.0 - x) / y_m));
	} else {
		tmp = Math.abs((x * ((1.0 - z) / y_m)));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -5.5e-47:
		tmp = math.fabs((x / (y_m / (1.0 - z))))
	elif x <= 1.2e-31:
		tmp = math.fabs(((-4.0 - x) / y_m))
	else:
		tmp = math.fabs((x * ((1.0 - z) / y_m)))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -5.5e-47)
		tmp = abs(Float64(x / Float64(y_m / Float64(1.0 - z))));
	elseif (x <= 1.2e-31)
		tmp = abs(Float64(Float64(-4.0 - x) / y_m));
	else
		tmp = abs(Float64(x * Float64(Float64(1.0 - z) / y_m)));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -5.5e-47)
		tmp = abs((x / (y_m / (1.0 - z))));
	elseif (x <= 1.2e-31)
		tmp = abs(((-4.0 - x) / y_m));
	else
		tmp = abs((x * ((1.0 - z) / y_m)));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -5.5e-47], N[Abs[N[(x / N[(y$95$m / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.2e-31], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{-47}:\\
\;\;\;\;\left|\frac{x}{\frac{y_m}{1 - z}}\right|\\

\mathbf{elif}\;x \leq 1.2 \cdot 10^{-31}:\\
\;\;\;\;\left|\frac{-4 - x}{y_m}\right|\\

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


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

    1. Initial program 90.6%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in y around 0 98.7%

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

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

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

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

    if -5.5000000000000002e-47 < x < 1.2e-31

    1. Initial program 93.7%

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

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

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

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

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

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

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

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

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

    if 1.2e-31 < x

    1. Initial program 90.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in y around 0 90.8%

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{1 - z}{y}} \cdot x\right| \]
    7. Applied egg-rr97.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{-47}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-31}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \end{array} \]

Alternative 5: 97.9% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq 15500000000000:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y_m}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x 15500000000000.0)
   (fabs (/ (- (+ 4.0 x) (* x z)) y_m))
   (fabs (* x (/ (- 1.0 z) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= 15500000000000.0) {
		tmp = fabs((((4.0 + x) - (x * z)) / y_m));
	} else {
		tmp = fabs((x * ((1.0 - z) / y_m)));
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 15500000000000.0d0) then
        tmp = abs((((4.0d0 + x) - (x * z)) / y_m))
    else
        tmp = abs((x * ((1.0d0 - z) / y_m)))
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= 15500000000000.0) {
		tmp = Math.abs((((4.0 + x) - (x * z)) / y_m));
	} else {
		tmp = Math.abs((x * ((1.0 - z) / y_m)));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= 15500000000000.0:
		tmp = math.fabs((((4.0 + x) - (x * z)) / y_m))
	else:
		tmp = math.fabs((x * ((1.0 - z) / y_m)))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= 15500000000000.0)
		tmp = abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y_m));
	else
		tmp = abs(Float64(x * Float64(Float64(1.0 - z) / y_m)));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= 15500000000000.0)
		tmp = abs((((4.0 + x) - (x * z)) / y_m));
	else
		tmp = abs((x * ((1.0 - z) / y_m)));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, 15500000000000.0], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq 15500000000000:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\

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


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

    1. Initial program 92.8%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in y around 0 99.5%

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

    if 1.55e13 < x

    1. Initial program 89.4%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in y around 0 90.1%

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

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

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

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

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

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

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

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

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

Alternative 6: 69.9% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1.5:\\ \;\;\;\;\left|\frac{x}{y_m}\right|\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-35}:\\ \;\;\;\;\left|\frac{4}{y_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y_m}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -1.5)
   (fabs (/ x y_m))
   (if (<= x 1.6e-35) (fabs (/ 4.0 y_m)) (fabs (* z (/ x y_m))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -1.5) {
		tmp = fabs((x / y_m));
	} else if (x <= 1.6e-35) {
		tmp = fabs((4.0 / y_m));
	} else {
		tmp = fabs((z * (x / y_m)));
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-1.5d0)) then
        tmp = abs((x / y_m))
    else if (x <= 1.6d-35) then
        tmp = abs((4.0d0 / y_m))
    else
        tmp = abs((z * (x / y_m)))
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -1.5) {
		tmp = Math.abs((x / y_m));
	} else if (x <= 1.6e-35) {
		tmp = Math.abs((4.0 / y_m));
	} else {
		tmp = Math.abs((z * (x / y_m)));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -1.5:
		tmp = math.fabs((x / y_m))
	elif x <= 1.6e-35:
		tmp = math.fabs((4.0 / y_m))
	else:
		tmp = math.fabs((z * (x / y_m)))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -1.5)
		tmp = abs(Float64(x / y_m));
	elseif (x <= 1.6e-35)
		tmp = abs(Float64(4.0 / y_m));
	else
		tmp = abs(Float64(z * Float64(x / y_m)));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -1.5)
		tmp = abs((x / y_m));
	elseif (x <= 1.6e-35)
		tmp = abs((4.0 / y_m));
	else
		tmp = abs((z * (x / y_m)));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -1.5], N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.6e-35], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5:\\
\;\;\;\;\left|\frac{x}{y_m}\right|\\

\mathbf{elif}\;x \leq 1.6 \cdot 10^{-35}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\

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


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

    1. Initial program 90.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in z around 0 65.9%

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

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

        \[\leadsto \left|\frac{\color{blue}{4}}{y} + \frac{x}{y}\right| \]
    4. Simplified65.9%

      \[\leadsto \left|\color{blue}{\frac{4}{y} + \frac{x}{y}}\right| \]
    5. Taylor expanded in x around inf 65.9%

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

    if -1.5 < x < 1.5999999999999999e-35

    1. Initial program 93.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in x around 0 77.3%

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

    if 1.5999999999999999e-35 < x

    1. Initial program 90.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in z around inf 50.7%

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

        \[\leadsto \left|\color{blue}{-\frac{x \cdot z}{y}}\right| \]
      2. associate-*l/68.3%

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} \cdot \color{blue}{z}\right| \]
      6. associate-*l/50.7%

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

        \[\leadsto \left|\color{blue}{\frac{-x \cdot z}{-y}}\right| \]
      8. distribute-rgt-neg-in50.7%

        \[\leadsto \left|\frac{\color{blue}{x \cdot \left(-z\right)}}{-y}\right| \]
      9. add-sqr-sqrt22.4%

        \[\leadsto \left|\frac{x \cdot \color{blue}{\left(\sqrt{-z} \cdot \sqrt{-z}\right)}}{-y}\right| \]
      10. sqrt-unprod42.7%

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

        \[\leadsto \left|\frac{x \cdot \sqrt{\color{blue}{z \cdot z}}}{-y}\right| \]
      12. sqrt-unprod28.2%

        \[\leadsto \left|\frac{x \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}}{-y}\right| \]
      13. add-sqr-sqrt50.7%

        \[\leadsto \left|\frac{x \cdot \color{blue}{z}}{-y}\right| \]
    6. Applied egg-rr50.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-35}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]

Alternative 7: 85.9% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{+17}:\\ \;\;\;\;\left|z \cdot \frac{x}{y_m}\right|\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{+40}:\\ \;\;\;\;\left|\frac{-4 - x}{y_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y_m}{z}}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= z -9e+17)
   (fabs (* z (/ x y_m)))
   (if (<= z 2.3e+40) (fabs (/ (- -4.0 x) y_m)) (fabs (/ x (/ y_m z))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (z <= -9e+17) {
		tmp = fabs((z * (x / y_m)));
	} else if (z <= 2.3e+40) {
		tmp = fabs(((-4.0 - x) / y_m));
	} else {
		tmp = fabs((x / (y_m / z)));
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-9d+17)) then
        tmp = abs((z * (x / y_m)))
    else if (z <= 2.3d+40) then
        tmp = abs((((-4.0d0) - x) / y_m))
    else
        tmp = abs((x / (y_m / z)))
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (z <= -9e+17) {
		tmp = Math.abs((z * (x / y_m)));
	} else if (z <= 2.3e+40) {
		tmp = Math.abs(((-4.0 - x) / y_m));
	} else {
		tmp = Math.abs((x / (y_m / z)));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if z <= -9e+17:
		tmp = math.fabs((z * (x / y_m)))
	elif z <= 2.3e+40:
		tmp = math.fabs(((-4.0 - x) / y_m))
	else:
		tmp = math.fabs((x / (y_m / z)))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (z <= -9e+17)
		tmp = abs(Float64(z * Float64(x / y_m)));
	elseif (z <= 2.3e+40)
		tmp = abs(Float64(Float64(-4.0 - x) / y_m));
	else
		tmp = abs(Float64(x / Float64(y_m / z)));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (z <= -9e+17)
		tmp = abs((z * (x / y_m)));
	elseif (z <= 2.3e+40)
		tmp = abs(((-4.0 - x) / y_m));
	else
		tmp = abs((x / (y_m / z)));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[z, -9e+17], N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 2.3e+40], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+17}:\\
\;\;\;\;\left|z \cdot \frac{x}{y_m}\right|\\

\mathbf{elif}\;z \leq 2.3 \cdot 10^{+40}:\\
\;\;\;\;\left|\frac{-4 - x}{y_m}\right|\\

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


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

    1. Initial program 93.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in z around inf 74.5%

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

        \[\leadsto \left|\color{blue}{-\frac{x \cdot z}{y}}\right| \]
      2. associate-*l/76.4%

        \[\leadsto \left|-\color{blue}{\frac{x}{y} \cdot z}\right| \]
      3. distribute-rgt-neg-out76.4%

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

      \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot \left(-z\right)}\right| \]
    5. Step-by-step derivation
      1. add-sqr-sqrt76.2%

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

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

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

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

        \[\leadsto \left|\frac{x}{y} \cdot \color{blue}{z}\right| \]
      6. associate-*l/74.5%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}}\right| \]
      7. frac-2neg74.5%

        \[\leadsto \left|\color{blue}{\frac{-x \cdot z}{-y}}\right| \]
      8. distribute-rgt-neg-in74.5%

        \[\leadsto \left|\frac{\color{blue}{x \cdot \left(-z\right)}}{-y}\right| \]
      9. add-sqr-sqrt74.2%

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

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

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

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

        \[\leadsto \left|\frac{x \cdot \color{blue}{z}}{-y}\right| \]
    6. Applied egg-rr74.5%

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

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

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

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

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

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

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

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

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

    if -9e17 < z < 2.29999999999999994e40

    1. Initial program 95.0%

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

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

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

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

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

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

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

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

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

    if 2.29999999999999994e40 < z

    1. Initial program 82.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in z around inf 76.9%

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

        \[\leadsto \left|\color{blue}{-\frac{x \cdot z}{y}}\right| \]
      2. associate-*l/76.1%

        \[\leadsto \left|-\color{blue}{\frac{x}{y} \cdot z}\right| \]
      3. distribute-rgt-neg-out76.1%

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

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

        \[\leadsto \left|\color{blue}{\frac{x \cdot \left(-z\right)}{y}}\right| \]
      2. associate-/l*77.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-unprod48.8%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{+17}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{+40}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \end{array} \]

Alternative 8: 69.0% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1.55 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\left|\frac{x}{y_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y_m}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (or (<= x -1.55) (not (<= x 4.0))) (fabs (/ x y_m)) (fabs (/ 4.0 y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if ((x <= -1.55) || !(x <= 4.0)) {
		tmp = fabs((x / y_m));
	} else {
		tmp = fabs((4.0 / y_m));
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x <= (-1.55d0)) .or. (.not. (x <= 4.0d0))) then
        tmp = abs((x / y_m))
    else
        tmp = abs((4.0d0 / y_m))
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if ((x <= -1.55) || !(x <= 4.0)) {
		tmp = Math.abs((x / y_m));
	} else {
		tmp = Math.abs((4.0 / y_m));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if (x <= -1.55) or not (x <= 4.0):
		tmp = math.fabs((x / y_m))
	else:
		tmp = math.fabs((4.0 / y_m))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if ((x <= -1.55) || !(x <= 4.0))
		tmp = abs(Float64(x / y_m));
	else
		tmp = abs(Float64(4.0 / y_m));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if ((x <= -1.55) || ~((x <= 4.0)))
		tmp = abs((x / y_m));
	else
		tmp = abs((4.0 / y_m));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -1.55], N[Not[LessEqual[x, 4.0]], $MachinePrecision]], N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;\left|\frac{x}{y_m}\right|\\

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


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

    1. Initial program 89.8%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in z around 0 62.3%

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

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

        \[\leadsto \left|\frac{\color{blue}{4}}{y} + \frac{x}{y}\right| \]
    4. Simplified62.3%

      \[\leadsto \left|\color{blue}{\frac{4}{y} + \frac{x}{y}}\right| \]
    5. Taylor expanded in x around inf 62.3%

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

    if -1.55000000000000004 < x < 4

    1. Initial program 94.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in x around 0 74.3%

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

    \[\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 9: 40.2% accurate, 1.1× speedup?

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

\\
\left|\frac{4}{y_m}\right|
\end{array}
Derivation
  1. Initial program 91.9%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Taylor expanded in x around 0 39.5%

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

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

Reproduce

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