fabs fraction 1

Percentage Accurate: 91.8% → 99.3%
Time: 7.6s
Alternatives: 12
Speedup: 0.9×

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 12 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.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.3% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;x \leq 6.5 \cdot 10^{+130}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

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


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

    1. Initial program 82.3%

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\left(-\left(z - 1\right)\right) \cdot \frac{x}{y}}\right| \]
      5. neg-sub099.9%

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

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

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

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

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

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

    if -3.00000000000000018e34 < x < 6.5e130

    1. Initial program 94.3%

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

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

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

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

    if 6.5e130 < x

    1. Initial program 96.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{+34}:\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{+130}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 97.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x + 4}{y} - z \cdot \frac{x}{y}\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-175}:\\ \;\;\;\;\left|t\_0\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-1}{y} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (/ (+ x 4.0) y) (* z (/ x y)))))
   (if (<= t_0 -1e-175)
     (fabs t_0)
     (fabs (* (/ -1.0 y) (fma x z (- -4.0 x)))))))
double code(double x, double y, double z) {
	double t_0 = ((x + 4.0) / y) - (z * (x / y));
	double tmp;
	if (t_0 <= -1e-175) {
		tmp = fabs(t_0);
	} else {
		tmp = fabs(((-1.0 / y) * fma(x, z, (-4.0 - x))));
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(Float64(x + 4.0) / y) - Float64(z * Float64(x / y)))
	tmp = 0.0
	if (t_0 <= -1e-175)
		tmp = abs(t_0);
	else
		tmp = abs(Float64(Float64(-1.0 / y) * fma(x, z, Float64(-4.0 - x))));
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-175], N[Abs[t$95$0], $MachinePrecision], N[Abs[N[(N[(-1.0 / y), $MachinePrecision] * N[(x * z + N[(-4.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < -1e-175

    1. Initial program 99.9%

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

    if -1e-175 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))

    1. Initial program 86.6%

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

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

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

Alternative 3: 97.2% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 91.8%

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

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

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

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

    if 5.0000000000000003e129 < y

    1. Initial program 94.2%

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

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg99.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval99.9%

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

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

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

Alternative 4: 97.5% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x + 4}{y} - z \cdot \frac{x}{y}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-67}:\\
\;\;\;\;\left|t\_0\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 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < -1.99999999999999989e-67

    1. Initial program 99.9%

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

    if -1.99999999999999989e-67 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))

    1. Initial program 87.9%

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

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

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

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

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

Alternative 5: 97.4% accurate, 0.9× speedup?

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

    1. Initial program 99.9%

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

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

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

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

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

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

    if -5.00000000000000021e35 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))

    1. Initial program 88.9%

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

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

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

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

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

Alternative 6: 69.0% accurate, 0.9× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.4500000000000001e-34 or 3.9999999999999998e163 < x

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.4500000000000001e-34 < x < 4

    1. Initial program 97.0%

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

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

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

    if 4 < x < 3.9999999999999998e163

    1. Initial program 82.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.45 \cdot 10^{-34}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 4 \cdot 10^{+163}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 68.8% accurate, 0.9× speedup?

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

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

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

\mathbf{elif}\;x \leq 1.95 \cdot 10^{+172}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -2.39999999999999991e-34

    1. Initial program 85.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.39999999999999991e-34 < x < 4

    1. Initial program 97.0%

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

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

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

    if 4 < x < 1.94999999999999984e172

    1. Initial program 82.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.94999999999999984e172 < x

    1. Initial program 95.7%

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{x \cdot \left(-z\right)}{y}}\right| \]
    7. Step-by-step derivation
      1. distribute-rgt-neg-out44.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{-34}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{+172}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 85.2% accurate, 0.9× speedup?

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

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

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

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


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

    1. Initial program 92.4%

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{x \cdot \left(-z\right)}{y}}\right| \]
    7. Step-by-step derivation
      1. distribute-rgt-neg-out86.7%

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

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

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

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

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

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

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

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

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

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

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

    if -2.09999999999999992e127 < z < 2200

    1. Initial program 93.4%

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

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

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

        \[\leadsto \left|\frac{\color{blue}{x + 4}}{y}\right| \]
      2. rem-square-sqrt41.7%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}}\right| \]
      3. fabs-sqr41.7%

        \[\leadsto \left|\color{blue}{\left|\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}\right|}\right| \]
      4. rem-square-sqrt94.4%

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

        \[\leadsto \left|\color{blue}{\left|-\frac{x + 4}{y}\right|}\right| \]
      6. distribute-neg-frac94.4%

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

        \[\leadsto \left|\left|\frac{\color{blue}{\left(-x\right) + \left(-4\right)}}{y}\right|\right| \]
      8. metadata-eval94.4%

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

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

        \[\leadsto \left|\left|\frac{\color{blue}{-4 - x}}{y}\right|\right| \]
      11. rem-square-sqrt52.1%

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

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

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

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

    if 2200 < z

    1. Initial program 88.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.1 \cdot 10^{+127}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;z \leq 2200:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 85.2% accurate, 0.9× speedup?

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

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

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

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


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

    1. Initial program 92.4%

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{x \cdot \left(-z\right)}{y}}\right| \]
    7. Step-by-step derivation
      1. distribute-rgt-neg-out86.7%

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

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

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

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

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

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

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

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

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

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

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

    if -1.3e126 < z < 15.5

    1. Initial program 93.4%

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

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

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

        \[\leadsto \left|\frac{\color{blue}{x + 4}}{y}\right| \]
      2. rem-square-sqrt41.7%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}}\right| \]
      3. fabs-sqr41.7%

        \[\leadsto \left|\color{blue}{\left|\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}\right|}\right| \]
      4. rem-square-sqrt94.4%

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

        \[\leadsto \left|\color{blue}{\left|-\frac{x + 4}{y}\right|}\right| \]
      6. distribute-neg-frac94.4%

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

        \[\leadsto \left|\left|\frac{\color{blue}{\left(-x\right) + \left(-4\right)}}{y}\right|\right| \]
      8. metadata-eval94.4%

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

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

        \[\leadsto \left|\left|\frac{\color{blue}{-4 - x}}{y}\right|\right| \]
      11. rem-square-sqrt52.1%

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

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

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

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    7. Step-by-step derivation
      1. div-sub94.5%

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

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

    if 15.5 < z

    1. Initial program 88.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.3 \cdot 10^{+126}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;z \leq 15.5:\\ \;\;\;\;\left|\frac{-4}{y} - \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 85.1% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 92.4%

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{x \cdot \left(-z\right)}{y}}\right| \]
    7. Step-by-step derivation
      1. distribute-rgt-neg-out86.7%

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

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

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

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

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

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

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

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

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

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

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

    if -1.24999999999999994e126 < z < 3.19999999999999999e99

    1. Initial program 93.4%

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

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

      \[\leadsto \left|\color{blue}{\frac{4 + x}{y}}\right| \]
    5. Step-by-step derivation
      1. +-commutative90.2%

        \[\leadsto \left|\frac{\color{blue}{x + 4}}{y}\right| \]
      2. rem-square-sqrt39.8%

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

        \[\leadsto \left|\color{blue}{\left|\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}\right|}\right| \]
      4. rem-square-sqrt90.2%

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

        \[\leadsto \left|\color{blue}{\left|-\frac{x + 4}{y}\right|}\right| \]
      6. distribute-neg-frac90.2%

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

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

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

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

        \[\leadsto \left|\left|\frac{\color{blue}{-4 - x}}{y}\right|\right| \]
      11. rem-square-sqrt49.8%

        \[\leadsto \left|\left|\color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}}\right|\right| \]
      12. fabs-sqr49.8%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}}\right| \]
      13. rem-square-sqrt90.2%

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

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

    if 3.19999999999999999e99 < z

    1. Initial program 87.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.25 \cdot 10^{+126}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{+99}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 69.0% 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 85.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -10.5 < x < 4

    1. Initial program 97.1%

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

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

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

    \[\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} \]
  5. Add Preprocessing

Alternative 12: 39.8% accurate, 1.1× speedup?

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

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

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

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

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

    \[\leadsto \left|\frac{4}{y}\right| \]
  6. Add Preprocessing

Reproduce

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