fabs fraction 1

Percentage Accurate: 91.7% → 99.4%
Time: 7.4s
Alternatives: 11
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 11 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.7% 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.4% accurate, 0.3× speedup?

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

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+294}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) < 3.9999999999999998e-143

    1. Initial program 84.6%

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

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

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

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

    if 3.9999999999999998e-143 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) < 2.00000000000000013e294

    1. Initial program 99.8%

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

    if 2.00000000000000013e294 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)))

    1. Initial program 78.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|\frac{x + 4}{y} - z \cdot \frac{x}{y}\right| \leq 4 \cdot 10^{-143}:\\ \;\;\;\;\left|\frac{x + 4}{y} + \frac{-1}{\frac{y}{x \cdot z}}\right|\\ \mathbf{elif}\;\left|\frac{x + 4}{y} - z \cdot \frac{x}{y}\right| \leq 2 \cdot 10^{+294}:\\ \;\;\;\;\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} \]

Alternative 2: 99.4% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \left|\frac{x + 4}{y} - z \cdot \frac{x}{y}\right|\\
\mathbf{if}\;t_0 \leq 4 \cdot 10^{-143} \lor \neg \left(t_0 \leq 2 \cdot 10^{+294}\right):\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) < 3.9999999999999998e-143 or 2.00000000000000013e294 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)))

    1. Initial program 81.0%

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

        \[\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| \]
    3. Applied egg-rr99.9%

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

    if 3.9999999999999998e-143 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) < 2.00000000000000013e294

    1. Initial program 99.8%

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

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

Alternative 3: 99.4% accurate, 0.3× speedup?

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

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+294}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) < 3.9999999999999998e-143

    1. Initial program 84.6%

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

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

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

    if 3.9999999999999998e-143 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) < 2.00000000000000013e294

    1. Initial program 99.8%

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

    if 2.00000000000000013e294 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)))

    1. Initial program 78.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|\frac{x + 4}{y} - z \cdot \frac{x}{y}\right| \leq 4 \cdot 10^{-143}:\\ \;\;\;\;\left|\frac{x \cdot z}{y} - \frac{x + 4}{y}\right|\\ \mathbf{elif}\;\left|\frac{x + 4}{y} - z \cdot \frac{x}{y}\right| \leq 2 \cdot 10^{+294}:\\ \;\;\;\;\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} \]

Alternative 4: 97.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 10^{+60}:\\ \;\;\;\;\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 1e+60)
   (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 <= 1e+60) {
		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 <= 1e+60)
		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, 1e+60], 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 10^{+60}:\\
\;\;\;\;\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 < 9.9999999999999995e59

    1. Initial program 92.5%

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

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

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

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

    if 9.9999999999999995e59 < y

    1. Initial program 96.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 10^{+60}:\\ \;\;\;\;\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} \]

Alternative 5: 69.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ t_1 := \left|x \cdot \frac{z}{y}\right|\\ \mathbf{if}\;x \leq -1.7 \cdot 10^{+104}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-14}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+87} \lor \neg \left(x \leq 2.9 \cdot 10^{+111}\right) \land x \leq 1.75 \cdot 10^{+183}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (/ x y))) (t_1 (fabs (* x (/ z y)))))
   (if (<= x -1.7e+104)
     t_0
     (if (<= x -3.1e-16)
       t_1
       (if (<= x 1.5e-14)
         (fabs (/ 4.0 y))
         (if (or (<= x 1.65e+87) (and (not (<= x 2.9e+111)) (<= x 1.75e+183)))
           t_1
           t_0))))))
double code(double x, double y, double z) {
	double t_0 = fabs((x / y));
	double t_1 = fabs((x * (z / y)));
	double tmp;
	if (x <= -1.7e+104) {
		tmp = t_0;
	} else if (x <= -3.1e-16) {
		tmp = t_1;
	} else if (x <= 1.5e-14) {
		tmp = fabs((4.0 / y));
	} else if ((x <= 1.65e+87) || (!(x <= 2.9e+111) && (x <= 1.75e+183))) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_0 = abs((x / y))
    t_1 = abs((x * (z / y)))
    if (x <= (-1.7d+104)) then
        tmp = t_0
    else if (x <= (-3.1d-16)) then
        tmp = t_1
    else if (x <= 1.5d-14) then
        tmp = abs((4.0d0 / y))
    else if ((x <= 1.65d+87) .or. (.not. (x <= 2.9d+111)) .and. (x <= 1.75d+183)) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((x / y));
	double t_1 = Math.abs((x * (z / y)));
	double tmp;
	if (x <= -1.7e+104) {
		tmp = t_0;
	} else if (x <= -3.1e-16) {
		tmp = t_1;
	} else if (x <= 1.5e-14) {
		tmp = Math.abs((4.0 / y));
	} else if ((x <= 1.65e+87) || (!(x <= 2.9e+111) && (x <= 1.75e+183))) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.fabs((x / y))
	t_1 = math.fabs((x * (z / y)))
	tmp = 0
	if x <= -1.7e+104:
		tmp = t_0
	elif x <= -3.1e-16:
		tmp = t_1
	elif x <= 1.5e-14:
		tmp = math.fabs((4.0 / y))
	elif (x <= 1.65e+87) or (not (x <= 2.9e+111) and (x <= 1.75e+183)):
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = abs(Float64(x / y))
	t_1 = abs(Float64(x * Float64(z / y)))
	tmp = 0.0
	if (x <= -1.7e+104)
		tmp = t_0;
	elseif (x <= -3.1e-16)
		tmp = t_1;
	elseif (x <= 1.5e-14)
		tmp = abs(Float64(4.0 / y));
	elseif ((x <= 1.65e+87) || (!(x <= 2.9e+111) && (x <= 1.75e+183)))
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = abs((x / y));
	t_1 = abs((x * (z / y)));
	tmp = 0.0;
	if (x <= -1.7e+104)
		tmp = t_0;
	elseif (x <= -3.1e-16)
		tmp = t_1;
	elseif (x <= 1.5e-14)
		tmp = abs((4.0 / y));
	elseif ((x <= 1.65e+87) || (~((x <= 2.9e+111)) && (x <= 1.75e+183)))
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.7e+104], t$95$0, If[LessEqual[x, -3.1e-16], t$95$1, If[LessEqual[x, 1.5e-14], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 1.65e+87], And[N[Not[LessEqual[x, 2.9e+111]], $MachinePrecision], LessEqual[x, 1.75e+183]]], t$95$1, t$95$0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -3.1 \cdot 10^{-16}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x \leq 1.65 \cdot 10^{+87} \lor \neg \left(x \leq 2.9 \cdot 10^{+111}\right) \land x \leq 1.75 \cdot 10^{+183}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.6999999999999998e104 or 1.6500000000000001e87 < x < 2.9e111 or 1.74999999999999994e183 < x

    1. Initial program 88.7%

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

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

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

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

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

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

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

    if -1.6999999999999998e104 < x < -3.1000000000000001e-16 or 1.4999999999999999e-14 < x < 1.6500000000000001e87 or 2.9e111 < x < 1.74999999999999994e183

    1. Initial program 94.8%

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

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

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

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

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

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

    if -3.1000000000000001e-16 < x < 1.4999999999999999e-14

    1. Initial program 95.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{+104}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-16}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-14}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+87} \lor \neg \left(x \leq 2.9 \cdot 10^{+111}\right) \land x \leq 1.75 \cdot 10^{+183}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 6: 69.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y}\right|\\ \mathbf{if}\;x \leq -3.35 \cdot 10^{+177}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.26 \cdot 10^{+99}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{-16} \lor \neg \left(x \leq 3.8 \cdot 10^{-14}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (* z (/ x y)))))
   (if (<= x -3.35e+177)
     t_0
     (if (<= x -1.26e+99)
       (fabs (/ x y))
       (if (or (<= x -1.75e-16) (not (<= x 3.8e-14))) t_0 (fabs (/ 4.0 y)))))))
double code(double x, double y, double z) {
	double t_0 = fabs((z * (x / y)));
	double tmp;
	if (x <= -3.35e+177) {
		tmp = t_0;
	} else if (x <= -1.26e+99) {
		tmp = fabs((x / y));
	} else if ((x <= -1.75e-16) || !(x <= 3.8e-14)) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = abs((z * (x / y)))
    if (x <= (-3.35d+177)) then
        tmp = t_0
    else if (x <= (-1.26d+99)) then
        tmp = abs((x / y))
    else if ((x <= (-1.75d-16)) .or. (.not. (x <= 3.8d-14))) then
        tmp = t_0
    else
        tmp = abs((4.0d0 / 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 <= -3.35e+177) {
		tmp = t_0;
	} else if (x <= -1.26e+99) {
		tmp = Math.abs((x / y));
	} else if ((x <= -1.75e-16) || !(x <= 3.8e-14)) {
		tmp = t_0;
	} else {
		tmp = Math.abs((4.0 / y));
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.fabs((z * (x / y)))
	tmp = 0
	if x <= -3.35e+177:
		tmp = t_0
	elif x <= -1.26e+99:
		tmp = math.fabs((x / y))
	elif (x <= -1.75e-16) or not (x <= 3.8e-14):
		tmp = t_0
	else:
		tmp = math.fabs((4.0 / y))
	return tmp
function code(x, y, z)
	t_0 = abs(Float64(z * Float64(x / y)))
	tmp = 0.0
	if (x <= -3.35e+177)
		tmp = t_0;
	elseif (x <= -1.26e+99)
		tmp = abs(Float64(x / y));
	elseif ((x <= -1.75e-16) || !(x <= 3.8e-14))
		tmp = t_0;
	else
		tmp = abs(Float64(4.0 / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = abs((z * (x / y)));
	tmp = 0.0;
	if (x <= -3.35e+177)
		tmp = t_0;
	elseif (x <= -1.26e+99)
		tmp = abs((x / y));
	elseif ((x <= -1.75e-16) || ~((x <= 3.8e-14)))
		tmp = t_0;
	else
		tmp = abs((4.0 / 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, -3.35e+177], t$95$0, If[LessEqual[x, -1.26e+99], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, -1.75e-16], N[Not[LessEqual[x, 3.8e-14]], $MachinePrecision]], t$95$0, N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;x \leq -1.75 \cdot 10^{-16} \lor \neg \left(x \leq 3.8 \cdot 10^{-14}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.3500000000000002e177 or -1.25999999999999996e99 < x < -1.75000000000000009e-16 or 3.8000000000000002e-14 < x

    1. Initial program 90.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.3500000000000002e177 < x < -1.25999999999999996e99

    1. Initial program 99.9%

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

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

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

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

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

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

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

    if -1.75000000000000009e-16 < x < 3.8000000000000002e-14

    1. Initial program 95.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.35 \cdot 10^{+177}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.26 \cdot 10^{+99}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{-16} \lor \neg \left(x \leq 3.8 \cdot 10^{-14}\right):\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array} \]

Alternative 7: 99.0% accurate, 1.0× speedup?

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

    1. Initial program 87.8%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Simplified86.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 86.2%

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

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

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

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

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

    if -1.90000000000000006e138 < x < 3.8000000000000001e135

    1. Initial program 95.4%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. 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| \]
    3. Applied egg-rr99.9%

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

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

Alternative 8: 87.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-19} \lor \neg \left(x \leq 80000\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 -2.7e-19) (not (<= x 80000.0)))
   (fabs (/ (+ z -1.0) (/ y x)))
   (fabs (/ (- -4.0 x) y))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -2.7e-19) || !(x <= 80000.0)) {
		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 <= (-2.7d-19)) .or. (.not. (x <= 80000.0d0))) 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 <= -2.7e-19) || !(x <= 80000.0)) {
		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 <= -2.7e-19) or not (x <= 80000.0):
		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 <= -2.7e-19) || !(x <= 80000.0))
		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 <= -2.7e-19) || ~((x <= 80000.0)))
		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, -2.7e-19], N[Not[LessEqual[x, 80000.0]], $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 -2.7 \cdot 10^{-19} \lor \neg \left(x \leq 80000\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 < -2.7000000000000001e-19 or 8e4 < x

    1. Initial program 91.1%

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

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

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

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

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

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

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

    if -2.7000000000000001e-19 < x < 8e4

    1. Initial program 95.6%

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

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

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

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

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

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

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

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

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

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

Alternative 9: 86.0% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 96.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999977e37 < z < 1.10000000000000004e26

    1. Initial program 96.1%

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

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

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

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

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

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

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

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

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

    if 1.10000000000000004e26 < z

    1. Initial program 81.8%

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

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

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

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

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

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

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

Alternative 10: 68.9% accurate, 1.0× speedup?

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

    1. Initial program 91.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Simplified92.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 90.9%

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

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

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

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

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

    if -1.52 < x < 4

    1. Initial program 95.7%

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

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

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

Alternative 11: 40.1% 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 93.2%

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

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

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

Reproduce

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