fabs fraction 1

Percentage Accurate: 91.6% → 98.0%
Time: 5.5s
Alternatives: 9
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 91.6% accurate, 1.0× speedup?

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

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

Alternative 1: 98.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 73.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{1}{\frac{y}{x}}} - x \cdot \frac{z}{y}\right| \]
      12. *-commutative77.8%

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

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

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

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

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

    if -2.0000000000000001e47 < x

    1. Initial program 95.3%

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

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

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

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

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

Alternative 2: 69.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y}\right|\\ t_1 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{+140}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -9 \cdot 10^{+39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6.8 \cdot 10^{-16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{-53}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+134}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (* z (/ x y)))) (t_1 (fabs (/ x y))))
   (if (<= x -6.5e+140)
     t_0
     (if (<= x -9e+39)
       t_1
       (if (<= x -6.8e-16)
         t_0
         (if (<= x 1.55e-53)
           (fabs (/ 4.0 y))
           (if (<= x 1.65e+134) t_0 t_1)))))))
double code(double x, double y, double z) {
	double t_0 = fabs((z * (x / y)));
	double t_1 = fabs((x / y));
	double tmp;
	if (x <= -6.5e+140) {
		tmp = t_0;
	} else if (x <= -9e+39) {
		tmp = t_1;
	} else if (x <= -6.8e-16) {
		tmp = t_0;
	} else if (x <= 1.55e-53) {
		tmp = fabs((4.0 / y));
	} else if (x <= 1.65e+134) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	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) :: t_1
    real(8) :: tmp
    t_0 = abs((z * (x / y)))
    t_1 = abs((x / y))
    if (x <= (-6.5d+140)) then
        tmp = t_0
    else if (x <= (-9d+39)) then
        tmp = t_1
    else if (x <= (-6.8d-16)) then
        tmp = t_0
    else if (x <= 1.55d-53) then
        tmp = abs((4.0d0 / y))
    else if (x <= 1.65d+134) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((z * (x / y)));
	double t_1 = Math.abs((x / y));
	double tmp;
	if (x <= -6.5e+140) {
		tmp = t_0;
	} else if (x <= -9e+39) {
		tmp = t_1;
	} else if (x <= -6.8e-16) {
		tmp = t_0;
	} else if (x <= 1.55e-53) {
		tmp = Math.abs((4.0 / y));
	} else if (x <= 1.65e+134) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.fabs((z * (x / y)))
	t_1 = math.fabs((x / y))
	tmp = 0
	if x <= -6.5e+140:
		tmp = t_0
	elif x <= -9e+39:
		tmp = t_1
	elif x <= -6.8e-16:
		tmp = t_0
	elif x <= 1.55e-53:
		tmp = math.fabs((4.0 / y))
	elif x <= 1.65e+134:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = abs(Float64(z * Float64(x / y)))
	t_1 = abs(Float64(x / y))
	tmp = 0.0
	if (x <= -6.5e+140)
		tmp = t_0;
	elseif (x <= -9e+39)
		tmp = t_1;
	elseif (x <= -6.8e-16)
		tmp = t_0;
	elseif (x <= 1.55e-53)
		tmp = abs(Float64(4.0 / y));
	elseif (x <= 1.65e+134)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = abs((z * (x / y)));
	t_1 = abs((x / y));
	tmp = 0.0;
	if (x <= -6.5e+140)
		tmp = t_0;
	elseif (x <= -9e+39)
		tmp = t_1;
	elseif (x <= -6.8e-16)
		tmp = t_0;
	elseif (x <= 1.55e-53)
		tmp = abs((4.0 / y));
	elseif (x <= 1.65e+134)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -6.5e+140], t$95$0, If[LessEqual[x, -9e+39], t$95$1, If[LessEqual[x, -6.8e-16], t$95$0, If[LessEqual[x, 1.55e-53], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.65e+134], t$95$0, t$95$1]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -9 \cdot 10^{+39}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -6.8 \cdot 10^{-16}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 1.65 \cdot 10^{+134}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6.4999999999999999e140 or -8.99999999999999991e39 < x < -6.8e-16 or 1.55000000000000008e-53 < x < 1.65e134

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.4999999999999999e140 < x < -8.99999999999999991e39 or 1.65e134 < x

    1. Initial program 85.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{x}{y} - x \cdot \frac{z}{y}}\right| \]
      10. *-lft-identity88.7%

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

        \[\leadsto \left|\color{blue}{\frac{1}{\frac{y}{x}}} - x \cdot \frac{z}{y}\right| \]
      12. *-commutative88.6%

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

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

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

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

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

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

    if -6.8e-16 < x < 1.55000000000000008e-53

    1. Initial program 97.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{+140}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -9 \cdot 10^{+39}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -6.8 \cdot 10^{-16}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{-53}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+134}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 3: 69.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|\frac{z}{\frac{y}{x}}\right|\\ t_1 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -1.65 \cdot 10^{+135}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -9 \cdot 10^{+39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-15}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-47}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{+130}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (/ z (/ y x)))) (t_1 (fabs (/ x y))))
   (if (<= x -1.65e+135)
     (fabs (* z (/ x y)))
     (if (<= x -9e+39)
       t_1
       (if (<= x -6e-15)
         t_0
         (if (<= x 6.2e-47)
           (fabs (/ 4.0 y))
           (if (<= x 1.75e+130) t_0 t_1)))))))
double code(double x, double y, double z) {
	double t_0 = fabs((z / (y / x)));
	double t_1 = fabs((x / y));
	double tmp;
	if (x <= -1.65e+135) {
		tmp = fabs((z * (x / y)));
	} else if (x <= -9e+39) {
		tmp = t_1;
	} else if (x <= -6e-15) {
		tmp = t_0;
	} else if (x <= 6.2e-47) {
		tmp = fabs((4.0 / y));
	} else if (x <= 1.75e+130) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	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) :: t_1
    real(8) :: tmp
    t_0 = abs((z / (y / x)))
    t_1 = abs((x / y))
    if (x <= (-1.65d+135)) then
        tmp = abs((z * (x / y)))
    else if (x <= (-9d+39)) then
        tmp = t_1
    else if (x <= (-6d-15)) then
        tmp = t_0
    else if (x <= 6.2d-47) then
        tmp = abs((4.0d0 / y))
    else if (x <= 1.75d+130) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((z / (y / x)));
	double t_1 = Math.abs((x / y));
	double tmp;
	if (x <= -1.65e+135) {
		tmp = Math.abs((z * (x / y)));
	} else if (x <= -9e+39) {
		tmp = t_1;
	} else if (x <= -6e-15) {
		tmp = t_0;
	} else if (x <= 6.2e-47) {
		tmp = Math.abs((4.0 / y));
	} else if (x <= 1.75e+130) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.fabs((z / (y / x)))
	t_1 = math.fabs((x / y))
	tmp = 0
	if x <= -1.65e+135:
		tmp = math.fabs((z * (x / y)))
	elif x <= -9e+39:
		tmp = t_1
	elif x <= -6e-15:
		tmp = t_0
	elif x <= 6.2e-47:
		tmp = math.fabs((4.0 / y))
	elif x <= 1.75e+130:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = abs(Float64(z / Float64(y / x)))
	t_1 = abs(Float64(x / y))
	tmp = 0.0
	if (x <= -1.65e+135)
		tmp = abs(Float64(z * Float64(x / y)));
	elseif (x <= -9e+39)
		tmp = t_1;
	elseif (x <= -6e-15)
		tmp = t_0;
	elseif (x <= 6.2e-47)
		tmp = abs(Float64(4.0 / y));
	elseif (x <= 1.75e+130)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = abs((z / (y / x)));
	t_1 = abs((x / y));
	tmp = 0.0;
	if (x <= -1.65e+135)
		tmp = abs((z * (x / y)));
	elseif (x <= -9e+39)
		tmp = t_1;
	elseif (x <= -6e-15)
		tmp = t_0;
	elseif (x <= 6.2e-47)
		tmp = abs((4.0 / y));
	elseif (x <= 1.75e+130)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.65e+135], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, -9e+39], t$95$1, If[LessEqual[x, -6e-15], t$95$0, If[LessEqual[x, 6.2e-47], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.75e+130], t$95$0, t$95$1]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -9 \cdot 10^{+39}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -6 \cdot 10^{-15}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 1.75 \cdot 10^{+130}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


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

    1. Initial program 64.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.65e135 < x < -8.99999999999999991e39 or 1.75e130 < x

    1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.99999999999999991e39 < x < -6e-15 or 6.1999999999999996e-47 < x < 1.75e130

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6e-15 < x < 6.1999999999999996e-47

    1. Initial program 97.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.65 \cdot 10^{+135}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -9 \cdot 10^{+39}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-15}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-47}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{+130}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 4: 66.9% accurate, 1.0× speedup?

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

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

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

\mathbf{elif}\;x \leq 2.5 \cdot 10^{+129}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.9999999999999999e-17 or 5.8000000000000001e-47 < x < 2.5000000000000001e129

    1. Initial program 87.3%

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

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

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

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

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

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

    if -4.9999999999999999e-17 < x < 5.8000000000000001e-47

    1. Initial program 97.0%

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

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

    if 2.5000000000000001e129 < x

    1. Initial program 81.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-17}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-47}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{+129}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 5: 86.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{-15} \lor \neg \left(x \leq 2.5 \cdot 10^{-53}\right):\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.09999999999999981e-15 or 2.5e-53 < x

    1. Initial program 86.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{x}{y} - x \cdot \frac{z}{y}}\right| \]
      10. *-lft-identity82.5%

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

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

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

        \[\leadsto \left|\frac{1}{\frac{y}{x}} - \color{blue}{\frac{z}{\frac{y}{x}}}\right| \]
      14. div-sub94.0%

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

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

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

    if -2.09999999999999981e-15 < x < 2.5e-53

    1. Initial program 97.0%

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

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

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

Alternative 6: 86.2% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.8999999999999998e-13 or 4.79999999999999985e-49 < x

    1. Initial program 86.0%

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

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

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

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

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

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

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

    if -2.8999999999999998e-13 < x < 4.79999999999999985e-49

    1. Initial program 97.0%

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

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

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

Alternative 7: 85.1% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 97.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.89999999999999987e39 < z < 3.69999999999999987e93

    1. Initial program 92.4%

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

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

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

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

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

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

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

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

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

    if 3.69999999999999987e93 < z

    1. Initial program 72.5%

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

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

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

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

Alternative 8: 68.3% 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.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{1}{\frac{y}{x}} - \color{blue}{\frac{z}{\frac{y}{x}}}\right| \]
      14. div-sub98.3%

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

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

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

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

    if -10.5 < x < 4

    1. Initial program 97.3%

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

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

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

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

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

Reproduce

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