fabs fraction 1

Percentage Accurate: 92.5% → 97.6%
Time: 5.6s
Alternatives: 7
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 92.5% accurate, 1.0× speedup?

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

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

Alternative 1: 97.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+15}:\\
\;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\

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


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

    1. Initial program 80.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      17. remove-double-neg91.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-in91.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-in91.3%

        \[\leadsto \left|\color{blue}{\left(-\frac{-1}{y}\right) \cdot \left(-\left(\left(x + 4\right) - x \cdot z\right)\right)}\right| \]
    3. Simplified91.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 91.5%

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

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

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

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

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

    if -1.6e15 < x

    1. Initial program 93.4%

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

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

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

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

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

Alternative 2: 84.5% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 92.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      17. remove-double-neg94.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-in94.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-in94.8%

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

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

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

    if -5.49999999999999966e27 < z < 4e5

    1. Initial program 90.8%

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

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

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

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

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

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

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

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

        \[\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/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 99.4%

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

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

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

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

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

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

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

    if 4e5 < z

    1. Initial program 85.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|z \cdot \color{blue}{\frac{1 \cdot x}{-1 \cdot y}}\right| \]
      9. *-lft-identity83.1%

        \[\leadsto \left|z \cdot \frac{\color{blue}{x}}{-1 \cdot y}\right| \]
      10. neg-mul-183.1%

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

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

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

Alternative 3: 66.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -10.5:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 4 \cdot 10^{-109}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\

\mathbf{elif}\;x \leq 3050000:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -10.5 or 3.05e6 < x

    1. Initial program 84.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      17. remove-double-neg93.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-in93.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-in93.3%

        \[\leadsto \left|\color{blue}{\left(-\frac{-1}{y}\right) \cdot \left(-\left(\left(x + 4\right) - x \cdot z\right)\right)}\right| \]
    3. Simplified93.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 92.2%

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

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

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

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

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

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

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

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

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

    if -10.5 < x < 4e-109

    1. Initial program 96.6%

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

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

    if 4e-109 < x < 3.05e6

    1. Initial program 89.9%

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

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

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

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

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

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

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

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

        \[\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.9%

        \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      17. remove-double-neg99.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-in99.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-in99.9%

        \[\leadsto \left|\color{blue}{\left(-\frac{-1}{y}\right) \cdot \left(-\left(\left(x + 4\right) - x \cdot z\right)\right)}\right| \]
    3. Simplified99.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 69.7%

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

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

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

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

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

Alternative 4: 67.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -10.5:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 4 \cdot 10^{-109}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\

\mathbf{elif}\;x \leq 3200000:\\
\;\;\;\;\left|\frac{x \cdot z}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -10.5 or 3.2e6 < x

    1. Initial program 84.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      17. remove-double-neg93.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-in93.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-in93.3%

        \[\leadsto \left|\color{blue}{\left(-\frac{-1}{y}\right) \cdot \left(-\left(\left(x + 4\right) - x \cdot z\right)\right)}\right| \]
    3. Simplified93.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 92.2%

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

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

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

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

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

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

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

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

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

    if -10.5 < x < 4e-109

    1. Initial program 96.6%

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

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

    if 4e-109 < x < 3.2e6

    1. Initial program 89.9%

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

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

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

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

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

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

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

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

        \[\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.9%

        \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      17. remove-double-neg99.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-in99.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-in99.9%

        \[\leadsto \left|\color{blue}{\left(-\frac{-1}{y}\right) \cdot \left(-\left(\left(x + 4\right) - x \cdot z\right)\right)}\right| \]
    3. Simplified99.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 69.7%

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

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

Alternative 5: 84.5% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 92.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(\left(x + 4\right) - x \cdot z\right)}\right| \]
      17. remove-double-neg94.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-in94.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-in94.8%

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

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

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

    if -1.4000000000000001e25 < z < 3.5e9

    1. Initial program 90.8%

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

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

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

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

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

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

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

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

        \[\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/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 99.4%

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

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

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

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

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

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

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

    if 3.5e9 < z

    1. Initial program 85.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|z \cdot \color{blue}{\frac{1 \cdot x}{-1 \cdot y}}\right| \]
      9. *-lft-identity83.1%

        \[\leadsto \left|z \cdot \frac{\color{blue}{x}}{-1 \cdot y}\right| \]
      10. neg-mul-183.1%

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 68.1% 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 84.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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-in93.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if -10.5 < x < 4

    1. Initial program 95.5%

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

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

    \[\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: 40.0% 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 90.0%

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

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

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

Reproduce

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