fabs fraction 1

Percentage Accurate: 91.6% → 97.6%
Time: 7.6s
Alternatives: 12
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 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.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: 97.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 91.9%

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

        \[\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| \]

    if 3.89999999999999985e108 < y

    1. Initial program 89.4%

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

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

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

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

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

Alternative 2: 87.1% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 91.9%

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

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

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

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

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

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

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

    if -6.80000000000000045e-42 < x < 1.19999999999999994e-12

    1. Initial program 92.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. Taylor expanded in z around 0 78.0%

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

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

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

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

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

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

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

    if 1.19999999999999994e-12 < x

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{{\left(\frac{\frac{y}{x}}{z + -1}\right)}^{-1}}\right| \]
    8. Step-by-step derivation
      1. unpow-197.6%

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

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

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

Alternative 3: 67.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|x \cdot \frac{z}{y}\right|\\ \mathbf{if}\;x \leq -5.8 \cdot 10^{-40}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-7}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{+145}:\\ \;\;\;\;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 -5.8e-40)
     t_0
     (if (<= x 8.5e-7)
       (fabs (/ 4.0 y))
       (if (<= x 5.5e+145) t_0 (fabs (/ x y)))))))
double code(double x, double y, double z) {
	double t_0 = fabs((x * (z / y)));
	double tmp;
	if (x <= -5.8e-40) {
		tmp = t_0;
	} else if (x <= 8.5e-7) {
		tmp = fabs((4.0 / y));
	} else if (x <= 5.5e+145) {
		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 <= (-5.8d-40)) then
        tmp = t_0
    else if (x <= 8.5d-7) then
        tmp = abs((4.0d0 / y))
    else if (x <= 5.5d+145) 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 <= -5.8e-40) {
		tmp = t_0;
	} else if (x <= 8.5e-7) {
		tmp = Math.abs((4.0 / y));
	} else if (x <= 5.5e+145) {
		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 <= -5.8e-40:
		tmp = t_0
	elif x <= 8.5e-7:
		tmp = math.fabs((4.0 / y))
	elif x <= 5.5e+145:
		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 <= -5.8e-40)
		tmp = t_0;
	elseif (x <= 8.5e-7)
		tmp = abs(Float64(4.0 / y));
	elseif (x <= 5.5e+145)
		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 <= -5.8e-40)
		tmp = t_0;
	elseif (x <= 8.5e-7)
		tmp = abs((4.0 / y));
	elseif (x <= 5.5e+145)
		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, -5.8e-40], t$95$0, If[LessEqual[x, 8.5e-7], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 5.5e+145], 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.8 \cdot 10^{-40}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 5.5 \cdot 10^{+145}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -5.7999999999999998e-40 or 8.50000000000000014e-7 < x < 5.4999999999999995e145

    1. Initial program 93.6%

      \[\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 51.9%

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

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

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

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

    if -5.7999999999999998e-40 < x < 8.50000000000000014e-7

    1. Initial program 92.2%

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

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

    if 5.4999999999999995e145 < x

    1. Initial program 81.8%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 70.0% accurate, 1.0× speedup?

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

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

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

\mathbf{elif}\;x \leq 3.2 \cdot 10^{+149}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.39999999999999991e-40 or 1.01999999999999994e-11 < x < 3.2000000000000002e149

    1. Initial program 93.7%

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

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

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

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

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

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

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

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

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

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

    if -2.39999999999999991e-40 < x < 1.01999999999999994e-11

    1. Initial program 92.1%

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

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

    if 3.2000000000000002e149 < x

    1. Initial program 81.8%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{-40}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-11}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{+149}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 5: 69.7% accurate, 1.0× speedup?

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

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

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

\mathbf{elif}\;x \leq 1.1 \cdot 10^{+148}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\

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


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

    1. Initial program 91.9%

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999953e-45 < x < 7.5000000000000004e-13

    1. Initial program 92.1%

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

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

    if 7.5000000000000004e-13 < x < 1.0999999999999999e148

    1. Initial program 96.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.0999999999999999e148 < x

    1. Initial program 81.8%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-44}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-13}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{+148}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 6: 86.8% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.79999999999999976e-43 or 4e5 < x

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.79999999999999976e-43 < x < 4e5

    1. Initial program 92.2%

      \[\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. Taylor expanded in z around 0 77.6%

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

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

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

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

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

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

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

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

Alternative 7: 86.9% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.10000000000000001e-44 < x < 0.0074999999999999997

    1. Initial program 92.2%

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

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

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

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

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

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

Alternative 8: 87.2% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.06000000000000004e-39 or 4.29999999999999985e-12 < x

    1. Initial program 90.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. Taylor expanded in x around inf 90.5%

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

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

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

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

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

    if -1.06000000000000004e-39 < x < 4.29999999999999985e-12

    1. Initial program 92.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. Taylor expanded in z around 0 78.0%

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

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

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

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

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

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

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

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

Alternative 9: 97.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{+154}:\\ \;\;\;\;\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 -2.8e+154)
   (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 <= -2.8e+154) {
		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 <= (-2.8d+154)) 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 <= -2.8e+154) {
		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 <= -2.8e+154:
		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 <= -2.8e+154)
		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 <= -2.8e+154)
		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, -2.8e+154], 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.8 \cdot 10^{+154}:\\
\;\;\;\;\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.7999999999999999e154

    1. Initial program 92.4%

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

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

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

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

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

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

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

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

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

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

        \[\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.7999999999999999e154 < x

    1. Initial program 91.2%

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

        \[\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.8 \cdot 10^{+154}:\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array} \]

Alternative 10: 85.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.4 \cdot 10^{+104} \lor \neg \left(z \leq 1.45 \cdot 10^{+84}\right):\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.39999999999999969e104 or 1.44999999999999994e84 < z

    1. Initial program 83.9%

      \[\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 74.6%

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

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

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

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

    if -5.39999999999999969e104 < z < 1.44999999999999994e84

    1. Initial program 95.6%

      \[\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 89.6%

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

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

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

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

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

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

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

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

Alternative 11: 69.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -10.2 \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.2) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -10.2) || !(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.2d0)) .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.2) || !(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.2) 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.2) || !(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.2) || ~((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.2], 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.2 \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.199999999999999 or 4 < x

    1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

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

    if -10.199999999999999 < x < 4

    1. Initial program 92.5%

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

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

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

Alternative 12: 40.3% 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.4%

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

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

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

Reproduce

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