fabs fraction 1

Percentage Accurate: 92.3% → 99.6%
Time: 6.8s
Alternatives: 8
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 8 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: 92.3% 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} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{+44} \lor \neg \left(x \leq 3.5 \cdot 10^{+89}\right):\\ \;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4 + x \cdot \left(1 - z\right)}{y}\right|\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -1.2e+44) (not (<= x 3.5e+89)))
   (fabs (/ (+ z -1.0) (/ y x)))
   (fabs (/ (+ 4.0 (* x (- 1.0 z))) y))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.2e+44) || !(x <= 3.5e+89)) {
		tmp = fabs(((z + -1.0) / (y / x)));
	} else {
		tmp = fabs(((4.0 + (x * (1.0 - z))) / y));
	}
	return tmp;
}
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.2d+44)) .or. (.not. (x <= 3.5d+89))) then
        tmp = abs(((z + (-1.0d0)) / (y / x)))
    else
        tmp = abs(((4.0d0 + (x * (1.0d0 - z))) / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.2e+44) || !(x <= 3.5e+89)) {
		tmp = Math.abs(((z + -1.0) / (y / x)));
	} else {
		tmp = Math.abs(((4.0 + (x * (1.0 - z))) / y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -1.2e+44) or not (x <= 3.5e+89):
		tmp = math.fabs(((z + -1.0) / (y / x)))
	else:
		tmp = math.fabs(((4.0 + (x * (1.0 - z))) / y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -1.2e+44) || !(x <= 3.5e+89))
		tmp = abs(Float64(Float64(z + -1.0) / Float64(y / x)));
	else
		tmp = abs(Float64(Float64(4.0 + Float64(x * Float64(1.0 - z))) / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -1.2e+44) || ~((x <= 3.5e+89)))
		tmp = abs(((z + -1.0) / (y / x)));
	else
		tmp = abs(((4.0 + (x * (1.0 - z))) / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.2e+44], N[Not[LessEqual[x, 3.5e+89]], $MachinePrecision]], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(4.0 + N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+44} \lor \neg \left(x \leq 3.5 \cdot 10^{+89}\right):\\
\;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.20000000000000007e44 or 3.5000000000000001e89 < x

    1. Initial program 80.8%

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \cdot 1} \]
      2. fabs-sub80.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{\left(-\left(x + 4\right)\right) + x \cdot z}}{y}\right| \]
      12. remove-double-neg87.4%

        \[\leadsto \left|\frac{\left(-\left(x + 4\right)\right) + \color{blue}{\left(-\left(-x \cdot z\right)\right)}}{y}\right| \]
      13. distribute-neg-in87.4%

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

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

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

        \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      17. remove-double-neg87.3%

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

        \[\leadsto \left|\color{blue}{-\left(-\frac{-1}{y}\right) \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      19. distribute-rgt-neg-in87.3%

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

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

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

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

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

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

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

    if -1.20000000000000007e44 < x < 3.5000000000000001e89

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\
\mathbf{if}\;t_0 \leq 10^{+301}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{x \cdot \left(z + -1\right)}{y}\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))) < 1.00000000000000005e301

    1. Initial program 99.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]

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

    1. Initial program 61.8%

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \cdot 1} \]
      2. fabs-sub61.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      17. remove-double-neg100.0%

        \[\leadsto \left|\color{blue}{\left(-\left(-\frac{-1}{y}\right)\right)} \cdot \left(\left(x + 4\right) - x \cdot z\right)\right| \]
      18. distribute-lft-neg-in100.0%

        \[\leadsto \left|\color{blue}{-\left(-\frac{-1}{y}\right) \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      19. distribute-rgt-neg-in100.0%

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

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

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

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

Alternative 3: 98.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -155000000000 \lor \neg \left(x \leq 2.25 \cdot 10^{-10}\right):\\ \;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4 - x \cdot z}{y}\right|\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -155000000000.0) (not (<= x 2.25e-10)))
   (fabs (/ (+ z -1.0) (/ y x)))
   (fabs (/ (- 4.0 (* x z)) y))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -155000000000.0) || !(x <= 2.25e-10)) {
		tmp = fabs(((z + -1.0) / (y / x)));
	} else {
		tmp = fabs(((4.0 - (x * z)) / y));
	}
	return tmp;
}
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 <= (-155000000000.0d0)) .or. (.not. (x <= 2.25d-10))) then
        tmp = abs(((z + (-1.0d0)) / (y / x)))
    else
        tmp = abs(((4.0d0 - (x * z)) / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -155000000000.0) || !(x <= 2.25e-10)) {
		tmp = Math.abs(((z + -1.0) / (y / x)));
	} else {
		tmp = Math.abs(((4.0 - (x * z)) / y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -155000000000.0) or not (x <= 2.25e-10):
		tmp = math.fabs(((z + -1.0) / (y / x)))
	else:
		tmp = math.fabs(((4.0 - (x * z)) / y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -155000000000.0) || !(x <= 2.25e-10))
		tmp = abs(Float64(Float64(z + -1.0) / Float64(y / x)));
	else
		tmp = abs(Float64(Float64(4.0 - Float64(x * z)) / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -155000000000.0) || ~((x <= 2.25e-10)))
		tmp = abs(((z + -1.0) / (y / x)));
	else
		tmp = abs(((4.0 - (x * z)) / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -155000000000.0], N[Not[LessEqual[x, 2.25e-10]], $MachinePrecision]], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(4.0 - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -155000000000 \lor \neg \left(x \leq 2.25 \cdot 10^{-10}\right):\\
\;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.55e11 or 2.25e-10 < x

    1. Initial program 83.6%

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

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

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right| \cdot \left|\color{blue}{--1}\right| \]
      5. fabs-mul83.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\left(-\left(-\frac{-1}{y}\right)\right)} \cdot \left(\left(x + 4\right) - x \cdot z\right)\right| \]
      18. distribute-lft-neg-in89.6%

        \[\leadsto \left|\color{blue}{-\left(-\frac{-1}{y}\right) \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      19. distribute-rgt-neg-in89.6%

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

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

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

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

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

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

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

    if -1.55e11 < x < 2.25e-10

    1. Initial program 98.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 68.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -1.2 \cdot 10^{+209}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -2.9 \cdot 10^{-6}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


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

    1. Initial program 82.9%

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

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

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

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

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

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

    if -1.19999999999999998e209 < x < -2.9000000000000002e-6

    1. Initial program 84.9%

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

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

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right| \cdot \left|\color{blue}{--1}\right| \]
      5. fabs-mul84.9%

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

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

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{\left(-\left(x + 4\right)\right) + x \cdot z}}{y}\right| \]
      12. remove-double-neg90.5%

        \[\leadsto \left|\frac{\left(-\left(x + 4\right)\right) + \color{blue}{\left(-\left(-x \cdot z\right)\right)}}{y}\right| \]
      13. distribute-neg-in90.5%

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

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

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

        \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      17. remove-double-neg90.3%

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

        \[\leadsto \left|\color{blue}{-\left(-\frac{-1}{y}\right) \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      19. distribute-rgt-neg-in90.3%

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

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

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

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

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

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

    if -2.9000000000000002e-6 < x < 4

    1. Initial program 98.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{+209}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-6}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 5: 85.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{+95} \lor \neg \left(z \leq 8.2 \cdot 10^{+36}\right):\\ \;\;\;\;\left|\frac{x}{y} \cdot z\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -3.8e+95) (not (<= z 8.2e+36)))
   (fabs (* (/ x y) z))
   (fabs (/ (- -4.0 x) y))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -3.8e+95) || !(z <= 8.2e+36)) {
		tmp = fabs(((x / y) * z));
	} else {
		tmp = fabs(((-4.0 - x) / y));
	}
	return tmp;
}
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 <= (-3.8d+95)) .or. (.not. (z <= 8.2d+36))) then
        tmp = abs(((x / y) * z))
    else
        tmp = abs((((-4.0d0) - x) / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -3.8e+95) || !(z <= 8.2e+36)) {
		tmp = Math.abs(((x / y) * z));
	} else {
		tmp = Math.abs(((-4.0 - x) / y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -3.8e+95) or not (z <= 8.2e+36):
		tmp = math.fabs(((x / y) * z))
	else:
		tmp = math.fabs(((-4.0 - x) / y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -3.8e+95) || !(z <= 8.2e+36))
		tmp = abs(Float64(Float64(x / y) * z));
	else
		tmp = abs(Float64(Float64(-4.0 - x) / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -3.8e+95) || ~((z <= 8.2e+36)))
		tmp = abs(((x / y) * z));
	else
		tmp = abs(((-4.0 - x) / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.8e+95], N[Not[LessEqual[z, 8.2e+36]], $MachinePrecision]], N[Abs[N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.8 \cdot 10^{+95} \lor \neg \left(z \leq 8.2 \cdot 10^{+36}\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot z\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.7999999999999999e95 or 8.20000000000000026e36 < z

    1. Initial program 87.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      17. remove-double-neg85.9%

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

        \[\leadsto \left|\color{blue}{-\left(-\frac{-1}{y}\right) \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      19. distribute-rgt-neg-in85.9%

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

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

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

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

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

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

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

    if -3.7999999999999999e95 < z < 8.20000000000000026e36

    1. Initial program 93.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\left(-\left(-\frac{-1}{y}\right)\right)} \cdot \left(\left(x + 4\right) - x \cdot z\right)\right| \]
      18. distribute-lft-neg-in99.8%

        \[\leadsto \left|\color{blue}{-\left(-\frac{-1}{y}\right) \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      19. distribute-rgt-neg-in99.8%

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    6. Simplified95.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{+95} \lor \neg \left(z \leq 8.2 \cdot 10^{+36}\right):\\ \;\;\;\;\left|\frac{x}{y} \cdot z\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \end{array} \]

Alternative 6: 68.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -10.5 \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 < -10.5 or 4 < x

    1. Initial program 83.4%

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

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

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

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

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

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

    if -10.5 < x < 4

    1. Initial program 98.5%

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

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

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

Alternative 7: 68.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-6}:\\
\;\;\;\;\left|\frac{x}{y} \cdot z\right|\\

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

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


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

    1. Initial program 81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      17. remove-double-neg91.9%

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{z \cdot \frac{x}{y}}\right| \]
    6. Simplified69.2%

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

    if -2.69999999999999998e-6 < x < 4

    1. Initial program 98.4%

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

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

    if 4 < x

    1. Initial program 85.4%

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

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

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

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

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

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

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

Alternative 8: 39.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \left|\frac{4}{y}\right| \end{array} \]
(FPCore (x y z) :precision binary64 (fabs (/ 4.0 y)))
double code(double x, double y, double z) {
	return fabs((4.0 / y));
}
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
public static double code(double x, double y, double z) {
	return Math.abs((4.0 / y));
}
def code(x, y, z):
	return math.fabs((4.0 / y))
function code(x, y, z)
	return abs(Float64(4.0 / y))
end
function tmp = code(x, y, z)
	tmp = abs((4.0 / y));
end
code[x_, y_, z_] := N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

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

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

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

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

Reproduce

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