Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3

Percentage Accurate: 87.6% → 99.7%
Time: 9.8s
Alternatives: 18
Speedup: 0.6×

Specification

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

\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\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 18 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: 87.6% accurate, 1.0× speedup?

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

\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}

Alternative 1: 99.7% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \leq 2.1 \cdot 10^{-71}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.1000000000000001e-16

    1. Initial program 75.9%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.8%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{z}{\left(y - z\right) + 1}}} \]
      2. un-div-inv99.8%

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

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

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

    if -2.1000000000000001e-16 < z < 2.1000000000000001e-71

    1. Initial program 99.9%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. distribute-lft-in99.9%

        \[\leadsto \frac{\color{blue}{x \cdot \left(y - z\right) + x \cdot 1}}{z} \]
      2. fma-define99.9%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y - z, x \cdot 1\right)}}{z} \]
      3. *-rgt-identity99.9%

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

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

      \[\leadsto \color{blue}{\frac{x + x \cdot y}{z}} \]

    if 2.1000000000000001e-71 < z

    1. Initial program 84.8%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 93.7% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.6 \cdot 10^{-98}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y - z, x\right)}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 5.5999999999999998e-98

    1. Initial program 93.1%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. distribute-lft-in93.1%

        \[\leadsto \frac{\color{blue}{x \cdot \left(y - z\right) + x \cdot 1}}{z} \]
      2. fma-define93.1%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y - z, x \cdot 1\right)}}{z} \]
      3. *-rgt-identity93.1%

        \[\leadsto \frac{\mathsf{fma}\left(x, y - z, \color{blue}{x}\right)}{z} \]
    3. Simplified93.1%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, y - z, x\right)}{z}} \]
    4. Add Preprocessing

    if 5.5999999999999998e-98 < x

    1. Initial program 79.8%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.9%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{z}{\left(y - z\right) + 1}}} \]
      2. un-div-inv99.9%

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

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

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

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

Alternative 3: 84.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.9 \cdot 10^{+15} \lor \neg \left(y \leq 3 \cdot 10^{+20}\right) \land \left(y \leq 6.5 \cdot 10^{+66} \lor \neg \left(y \leq 3.1 \cdot 10^{+156}\right)\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} - x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -3.9e+15)
         (and (not (<= y 3e+20)) (or (<= y 6.5e+66) (not (<= y 3.1e+156)))))
   (* y (/ x z))
   (- (/ x z) x)))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -3.9e+15) || (!(y <= 3e+20) && ((y <= 6.5e+66) || !(y <= 3.1e+156)))) {
		tmp = y * (x / z);
	} else {
		tmp = (x / z) - x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-3.9d+15)) .or. (.not. (y <= 3d+20)) .and. (y <= 6.5d+66) .or. (.not. (y <= 3.1d+156))) then
        tmp = y * (x / z)
    else
        tmp = (x / z) - x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -3.9e+15) || (!(y <= 3e+20) && ((y <= 6.5e+66) || !(y <= 3.1e+156)))) {
		tmp = y * (x / z);
	} else {
		tmp = (x / z) - x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -3.9e+15) or (not (y <= 3e+20) and ((y <= 6.5e+66) or not (y <= 3.1e+156))):
		tmp = y * (x / z)
	else:
		tmp = (x / z) - x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -3.9e+15) || (!(y <= 3e+20) && ((y <= 6.5e+66) || !(y <= 3.1e+156))))
		tmp = Float64(y * Float64(x / z));
	else
		tmp = Float64(Float64(x / z) - x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -3.9e+15) || (~((y <= 3e+20)) && ((y <= 6.5e+66) || ~((y <= 3.1e+156)))))
		tmp = y * (x / z);
	else
		tmp = (x / z) - x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.9e+15], And[N[Not[LessEqual[y, 3e+20]], $MachinePrecision], Or[LessEqual[y, 6.5e+66], N[Not[LessEqual[y, 3.1e+156]], $MachinePrecision]]]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.9 \cdot 10^{+15} \lor \neg \left(y \leq 3 \cdot 10^{+20}\right) \land \left(y \leq 6.5 \cdot 10^{+66} \lor \neg \left(y \leq 3.1 \cdot 10^{+156}\right)\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.9e15 or 3e20 < y < 6.5000000000000001e66 or 3.1000000000000002e156 < y

    1. Initial program 90.7%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num85.8%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{z}{\left(y - z\right) + 1}}} \]
      2. un-div-inv89.4%

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + \left(y - z\right)}}} \]
    7. Taylor expanded in y around inf 78.3%

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    8. Step-by-step derivation
      1. *-commutative78.3%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{z} \]
      2. associate-*r/73.5%

        \[\leadsto \color{blue}{y \cdot \frac{x}{z}} \]
    9. Simplified73.5%

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

    if -3.9e15 < y < 3e20 or 6.5000000000000001e66 < y < 3.1000000000000002e156

    1. Initial program 87.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 94.5%

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{z} - 1\right)} \]
    6. Step-by-step derivation
      1. sub-neg94.5%

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{z} + \left(-1\right)\right)} \]
      2. metadata-eval94.5%

        \[\leadsto x \cdot \left(\frac{1}{z} + \color{blue}{-1}\right) \]
      3. distribute-rgt-in94.5%

        \[\leadsto \color{blue}{\frac{1}{z} \cdot x + -1 \cdot x} \]
      4. associate-*l/94.6%

        \[\leadsto \color{blue}{\frac{1 \cdot x}{z}} + -1 \cdot x \]
      5. *-lft-identity94.6%

        \[\leadsto \frac{\color{blue}{x}}{z} + -1 \cdot x \]
      6. neg-mul-194.6%

        \[\leadsto \frac{x}{z} + \color{blue}{\left(-x\right)} \]
      7. unsub-neg94.6%

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    7. Simplified94.6%

      \[\leadsto \color{blue}{\frac{x}{z} - x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.9 \cdot 10^{+15} \lor \neg \left(y \leq 3 \cdot 10^{+20}\right) \land \left(y \leq 6.5 \cdot 10^{+66} \lor \neg \left(y \leq 3.1 \cdot 10^{+156}\right)\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} - x\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 83.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.45 \cdot 10^{+16}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{+21} \lor \neg \left(y \leq 1.45 \cdot 10^{+65}\right) \land y \leq 2.5 \cdot 10^{+145}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.45e+16)
   (/ x (/ z y))
   (if (or (<= y 4.5e+21) (and (not (<= y 1.45e+65)) (<= y 2.5e+145)))
     (- (/ x z) x)
     (/ y (/ z x)))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.45e+16) {
		tmp = x / (z / y);
	} else if ((y <= 4.5e+21) || (!(y <= 1.45e+65) && (y <= 2.5e+145))) {
		tmp = (x / z) - x;
	} else {
		tmp = y / (z / x);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-1.45d+16)) then
        tmp = x / (z / y)
    else if ((y <= 4.5d+21) .or. (.not. (y <= 1.45d+65)) .and. (y <= 2.5d+145)) then
        tmp = (x / z) - x
    else
        tmp = y / (z / x)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.45e+16) {
		tmp = x / (z / y);
	} else if ((y <= 4.5e+21) || (!(y <= 1.45e+65) && (y <= 2.5e+145))) {
		tmp = (x / z) - x;
	} else {
		tmp = y / (z / x);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -1.45e+16:
		tmp = x / (z / y)
	elif (y <= 4.5e+21) or (not (y <= 1.45e+65) and (y <= 2.5e+145)):
		tmp = (x / z) - x
	else:
		tmp = y / (z / x)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.45e+16)
		tmp = Float64(x / Float64(z / y));
	elseif ((y <= 4.5e+21) || (!(y <= 1.45e+65) && (y <= 2.5e+145)))
		tmp = Float64(Float64(x / z) - x);
	else
		tmp = Float64(y / Float64(z / x));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.45e+16)
		tmp = x / (z / y);
	elseif ((y <= 4.5e+21) || (~((y <= 1.45e+65)) && (y <= 2.5e+145)))
		tmp = (x / z) - x;
	else
		tmp = y / (z / x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -1.45e+16], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 4.5e+21], And[N[Not[LessEqual[y, 1.45e+65]], $MachinePrecision], LessEqual[y, 2.5e+145]]], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{+16}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

\mathbf{elif}\;y \leq 4.5 \cdot 10^{+21} \lor \neg \left(y \leq 1.45 \cdot 10^{+65}\right) \land y \leq 2.5 \cdot 10^{+145}:\\
\;\;\;\;\frac{x}{z} - x\\

\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.45e16

    1. Initial program 87.9%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num88.1%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{z}{\left(y - z\right) + 1}}} \]
      2. un-div-inv90.5%

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + \left(y - z\right)}}} \]
    7. Taylor expanded in y around inf 66.6%

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

    if -1.45e16 < y < 4.5e21 or 1.45e65 < y < 2.49999999999999983e145

    1. Initial program 87.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 94.5%

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{z} - 1\right)} \]
    6. Step-by-step derivation
      1. sub-neg94.5%

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{z} + \left(-1\right)\right)} \]
      2. metadata-eval94.5%

        \[\leadsto x \cdot \left(\frac{1}{z} + \color{blue}{-1}\right) \]
      3. distribute-rgt-in94.5%

        \[\leadsto \color{blue}{\frac{1}{z} \cdot x + -1 \cdot x} \]
      4. associate-*l/94.6%

        \[\leadsto \color{blue}{\frac{1 \cdot x}{z}} + -1 \cdot x \]
      5. *-lft-identity94.6%

        \[\leadsto \frac{\color{blue}{x}}{z} + -1 \cdot x \]
      6. neg-mul-194.6%

        \[\leadsto \frac{x}{z} + \color{blue}{\left(-x\right)} \]
      7. unsub-neg94.6%

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    7. Simplified94.6%

      \[\leadsto \color{blue}{\frac{x}{z} - x} \]

    if 4.5e21 < y < 1.45e65 or 2.49999999999999983e145 < y

    1. Initial program 93.6%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num83.3%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{z}{\left(y - z\right) + 1}}} \]
      2. un-div-inv88.1%

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + \left(y - z\right)}}} \]
    7. Taylor expanded in y around inf 74.1%

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{y}}} \]
    8. Step-by-step derivation
      1. associate-/r/81.1%

        \[\leadsto \color{blue}{\frac{x}{z} \cdot y} \]
    9. Applied egg-rr81.1%

      \[\leadsto \color{blue}{\frac{x}{z} \cdot y} \]
    10. Step-by-step derivation
      1. *-commutative81.1%

        \[\leadsto \color{blue}{y \cdot \frac{x}{z}} \]
      2. clear-num81.0%

        \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{z}{x}}} \]
      3. un-div-inv81.3%

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
    11. Applied egg-rr81.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.45 \cdot 10^{+16}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{+21} \lor \neg \left(y \leq 1.45 \cdot 10^{+65}\right) \land y \leq 2.5 \cdot 10^{+145}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 83.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.06 \cdot 10^{+15}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{+21} \lor \neg \left(y \leq 3.2 \cdot 10^{+65}\right) \land y \leq 2.5 \cdot 10^{+145}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.06e+15)
   (/ x (/ z y))
   (if (or (<= y 2.3e+21) (and (not (<= y 3.2e+65)) (<= y 2.5e+145)))
     (- (/ x z) x)
     (* y (/ x z)))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.06e+15) {
		tmp = x / (z / y);
	} else if ((y <= 2.3e+21) || (!(y <= 3.2e+65) && (y <= 2.5e+145))) {
		tmp = (x / z) - x;
	} else {
		tmp = y * (x / 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 <= (-1.06d+15)) then
        tmp = x / (z / y)
    else if ((y <= 2.3d+21) .or. (.not. (y <= 3.2d+65)) .and. (y <= 2.5d+145)) then
        tmp = (x / z) - x
    else
        tmp = y * (x / z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.06e+15) {
		tmp = x / (z / y);
	} else if ((y <= 2.3e+21) || (!(y <= 3.2e+65) && (y <= 2.5e+145))) {
		tmp = (x / z) - x;
	} else {
		tmp = y * (x / z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -1.06e+15:
		tmp = x / (z / y)
	elif (y <= 2.3e+21) or (not (y <= 3.2e+65) and (y <= 2.5e+145)):
		tmp = (x / z) - x
	else:
		tmp = y * (x / z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.06e+15)
		tmp = Float64(x / Float64(z / y));
	elseif ((y <= 2.3e+21) || (!(y <= 3.2e+65) && (y <= 2.5e+145)))
		tmp = Float64(Float64(x / z) - x);
	else
		tmp = Float64(y * Float64(x / z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.06e+15)
		tmp = x / (z / y);
	elseif ((y <= 2.3e+21) || (~((y <= 3.2e+65)) && (y <= 2.5e+145)))
		tmp = (x / z) - x;
	else
		tmp = y * (x / z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -1.06e+15], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 2.3e+21], And[N[Not[LessEqual[y, 3.2e+65]], $MachinePrecision], LessEqual[y, 2.5e+145]]], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.06 \cdot 10^{+15}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

\mathbf{elif}\;y \leq 2.3 \cdot 10^{+21} \lor \neg \left(y \leq 3.2 \cdot 10^{+65}\right) \land y \leq 2.5 \cdot 10^{+145}:\\
\;\;\;\;\frac{x}{z} - x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.06e15

    1. Initial program 87.9%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num88.1%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{z}{\left(y - z\right) + 1}}} \]
      2. un-div-inv90.5%

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + \left(y - z\right)}}} \]
    7. Taylor expanded in y around inf 66.6%

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

    if -1.06e15 < y < 2.3e21 or 3.20000000000000007e65 < y < 2.49999999999999983e145

    1. Initial program 87.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 94.5%

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{z} - 1\right)} \]
    6. Step-by-step derivation
      1. sub-neg94.5%

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{z} + \left(-1\right)\right)} \]
      2. metadata-eval94.5%

        \[\leadsto x \cdot \left(\frac{1}{z} + \color{blue}{-1}\right) \]
      3. distribute-rgt-in94.5%

        \[\leadsto \color{blue}{\frac{1}{z} \cdot x + -1 \cdot x} \]
      4. associate-*l/94.6%

        \[\leadsto \color{blue}{\frac{1 \cdot x}{z}} + -1 \cdot x \]
      5. *-lft-identity94.6%

        \[\leadsto \frac{\color{blue}{x}}{z} + -1 \cdot x \]
      6. neg-mul-194.6%

        \[\leadsto \frac{x}{z} + \color{blue}{\left(-x\right)} \]
      7. unsub-neg94.6%

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    7. Simplified94.6%

      \[\leadsto \color{blue}{\frac{x}{z} - x} \]

    if 2.3e21 < y < 3.20000000000000007e65 or 2.49999999999999983e145 < y

    1. Initial program 93.6%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num83.3%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{z}{\left(y - z\right) + 1}}} \]
      2. un-div-inv88.1%

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + \left(y - z\right)}}} \]
    7. Taylor expanded in y around inf 83.6%

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    8. Step-by-step derivation
      1. *-commutative83.6%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{z} \]
      2. associate-*r/81.1%

        \[\leadsto \color{blue}{y \cdot \frac{x}{z}} \]
    9. Simplified81.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.06 \cdot 10^{+15}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{+21} \lor \neg \left(y \leq 3.2 \cdot 10^{+65}\right) \land y \leq 2.5 \cdot 10^{+145}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 84.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot y}{z}\\ t_1 := \frac{x}{z} - x\\ \mathbf{if}\;y \leq -4.35 \cdot 10^{+15}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 7 \cdot 10^{+15}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{+66}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;y \leq 3.85 \cdot 10^{+145}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* x y) z)) (t_1 (- (/ x z) x)))
   (if (<= y -4.35e+15)
     t_0
     (if (<= y 7e+15)
       t_1
       (if (<= y 5.8e+66) (/ y (/ z x)) (if (<= y 3.85e+145) t_1 t_0))))))
double code(double x, double y, double z) {
	double t_0 = (x * y) / z;
	double t_1 = (x / z) - x;
	double tmp;
	if (y <= -4.35e+15) {
		tmp = t_0;
	} else if (y <= 7e+15) {
		tmp = t_1;
	} else if (y <= 5.8e+66) {
		tmp = y / (z / x);
	} else if (y <= 3.85e+145) {
		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 = (x * y) / z
    t_1 = (x / z) - x
    if (y <= (-4.35d+15)) then
        tmp = t_0
    else if (y <= 7d+15) then
        tmp = t_1
    else if (y <= 5.8d+66) then
        tmp = y / (z / x)
    else if (y <= 3.85d+145) 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 = (x * y) / z;
	double t_1 = (x / z) - x;
	double tmp;
	if (y <= -4.35e+15) {
		tmp = t_0;
	} else if (y <= 7e+15) {
		tmp = t_1;
	} else if (y <= 5.8e+66) {
		tmp = y / (z / x);
	} else if (y <= 3.85e+145) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x * y) / z
	t_1 = (x / z) - x
	tmp = 0
	if y <= -4.35e+15:
		tmp = t_0
	elif y <= 7e+15:
		tmp = t_1
	elif y <= 5.8e+66:
		tmp = y / (z / x)
	elif y <= 3.85e+145:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(x * y) / z)
	t_1 = Float64(Float64(x / z) - x)
	tmp = 0.0
	if (y <= -4.35e+15)
		tmp = t_0;
	elseif (y <= 7e+15)
		tmp = t_1;
	elseif (y <= 5.8e+66)
		tmp = Float64(y / Float64(z / x));
	elseif (y <= 3.85e+145)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (x * y) / z;
	t_1 = (x / z) - x;
	tmp = 0.0;
	if (y <= -4.35e+15)
		tmp = t_0;
	elseif (y <= 7e+15)
		tmp = t_1;
	elseif (y <= 5.8e+66)
		tmp = y / (z / x);
	elseif (y <= 3.85e+145)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[y, -4.35e+15], t$95$0, If[LessEqual[y, 7e+15], t$95$1, If[LessEqual[y, 5.8e+66], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.85e+145], t$95$1, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x \cdot y}{z}\\
t_1 := \frac{x}{z} - x\\
\mathbf{if}\;y \leq -4.35 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 7 \cdot 10^{+15}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 5.8 \cdot 10^{+66}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\

\mathbf{elif}\;y \leq 3.85 \cdot 10^{+145}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -4.35e15 or 3.85000000000000022e145 < y

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 76.6%

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

    if -4.35e15 < y < 7e15 or 5.79999999999999972e66 < y < 3.85000000000000022e145

    1. Initial program 87.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 94.5%

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{z} - 1\right)} \]
    6. Step-by-step derivation
      1. sub-neg94.5%

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{z} + \left(-1\right)\right)} \]
      2. metadata-eval94.5%

        \[\leadsto x \cdot \left(\frac{1}{z} + \color{blue}{-1}\right) \]
      3. distribute-rgt-in94.5%

        \[\leadsto \color{blue}{\frac{1}{z} \cdot x + -1 \cdot x} \]
      4. associate-*l/94.6%

        \[\leadsto \color{blue}{\frac{1 \cdot x}{z}} + -1 \cdot x \]
      5. *-lft-identity94.6%

        \[\leadsto \frac{\color{blue}{x}}{z} + -1 \cdot x \]
      6. neg-mul-194.6%

        \[\leadsto \frac{x}{z} + \color{blue}{\left(-x\right)} \]
      7. unsub-neg94.6%

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    7. Simplified94.6%

      \[\leadsto \color{blue}{\frac{x}{z} - x} \]

    if 7e15 < y < 5.79999999999999972e66

    1. Initial program 99.7%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num90.9%

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + \left(y - z\right)}}} \]
    7. Taylor expanded in y around inf 89.6%

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{y}}} \]
    8. Step-by-step derivation
      1. associate-/r/90.6%

        \[\leadsto \color{blue}{\frac{x}{z} \cdot y} \]
    9. Applied egg-rr90.6%

      \[\leadsto \color{blue}{\frac{x}{z} \cdot y} \]
    10. Step-by-step derivation
      1. *-commutative90.6%

        \[\leadsto \color{blue}{y \cdot \frac{x}{z}} \]
      2. clear-num90.6%

        \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{z}{x}}} \]
      3. un-div-inv91.2%

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
    11. Applied egg-rr91.2%

      \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 7: 64.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -8000:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -1.62 \cdot 10^{-149}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{-135}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{+59}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= z -8000.0)
     (- x)
     (if (<= z -1.62e-149)
       t_0
       (if (<= z 1.05e-135) (/ x z) (if (<= z 1.1e+59) t_0 (- x)))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -8000.0) {
		tmp = -x;
	} else if (z <= -1.62e-149) {
		tmp = t_0;
	} else if (z <= 1.05e-135) {
		tmp = x / z;
	} else if (z <= 1.1e+59) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = y * (x / z)
    if (z <= (-8000.0d0)) then
        tmp = -x
    else if (z <= (-1.62d-149)) then
        tmp = t_0
    else if (z <= 1.05d-135) then
        tmp = x / z
    else if (z <= 1.1d+59) then
        tmp = t_0
    else
        tmp = -x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -8000.0) {
		tmp = -x;
	} else if (z <= -1.62e-149) {
		tmp = t_0;
	} else if (z <= 1.05e-135) {
		tmp = x / z;
	} else if (z <= 1.1e+59) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if z <= -8000.0:
		tmp = -x
	elif z <= -1.62e-149:
		tmp = t_0
	elif z <= 1.05e-135:
		tmp = x / z
	elif z <= 1.1e+59:
		tmp = t_0
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(x / z))
	tmp = 0.0
	if (z <= -8000.0)
		tmp = Float64(-x);
	elseif (z <= -1.62e-149)
		tmp = t_0;
	elseif (z <= 1.05e-135)
		tmp = Float64(x / z);
	elseif (z <= 1.1e+59)
		tmp = t_0;
	else
		tmp = Float64(-x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (x / z);
	tmp = 0.0;
	if (z <= -8000.0)
		tmp = -x;
	elseif (z <= -1.62e-149)
		tmp = t_0;
	elseif (z <= 1.05e-135)
		tmp = x / z;
	elseif (z <= 1.1e+59)
		tmp = t_0;
	else
		tmp = -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -8000.0], (-x), If[LessEqual[z, -1.62e-149], t$95$0, If[LessEqual[z, 1.05e-135], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.1e+59], t$95$0, (-x)]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -8000:\\
\;\;\;\;-x\\

\mathbf{elif}\;z \leq -1.62 \cdot 10^{-149}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 1.05 \cdot 10^{-135}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 1.1 \cdot 10^{+59}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;-x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -8e3 or 1.1e59 < z

    1. Initial program 75.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 79.3%

      \[\leadsto \color{blue}{-1 \cdot x} \]
    6. Step-by-step derivation
      1. neg-mul-179.3%

        \[\leadsto \color{blue}{-x} \]
    7. Simplified79.3%

      \[\leadsto \color{blue}{-x} \]

    if -8e3 < z < -1.6200000000000001e-149 or 1.05e-135 < z < 1.1e59

    1. Initial program 99.7%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num88.7%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{z}{\left(y - z\right) + 1}}} \]
      2. un-div-inv92.1%

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + \left(y - z\right)}}} \]
    7. Taylor expanded in y around inf 55.2%

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    8. Step-by-step derivation
      1. *-commutative55.2%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{z} \]
      2. associate-*r/60.6%

        \[\leadsto \color{blue}{y \cdot \frac{x}{z}} \]
    9. Simplified60.6%

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

    if -1.6200000000000001e-149 < z < 1.05e-135

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 99.9%

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

        \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} \]
    7. Simplified91.3%

      \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} \]
    8. Taylor expanded in y around 0 73.9%

      \[\leadsto \color{blue}{\frac{x}{z}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 65.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.22:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{-131}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{-102}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 1200:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -0.22)
   (- x)
   (if (<= z 1.65e-131)
     (/ x z)
     (if (<= z 5.2e-102) (* x (/ y z)) (if (<= z 1200.0) (/ x z) (- x))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -0.22) {
		tmp = -x;
	} else if (z <= 1.65e-131) {
		tmp = x / z;
	} else if (z <= 5.2e-102) {
		tmp = x * (y / z);
	} else if (z <= 1200.0) {
		tmp = x / z;
	} else {
		tmp = -x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-0.22d0)) then
        tmp = -x
    else if (z <= 1.65d-131) then
        tmp = x / z
    else if (z <= 5.2d-102) then
        tmp = x * (y / z)
    else if (z <= 1200.0d0) then
        tmp = x / z
    else
        tmp = -x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -0.22) {
		tmp = -x;
	} else if (z <= 1.65e-131) {
		tmp = x / z;
	} else if (z <= 5.2e-102) {
		tmp = x * (y / z);
	} else if (z <= 1200.0) {
		tmp = x / z;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -0.22:
		tmp = -x
	elif z <= 1.65e-131:
		tmp = x / z
	elif z <= 5.2e-102:
		tmp = x * (y / z)
	elif z <= 1200.0:
		tmp = x / z
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -0.22)
		tmp = Float64(-x);
	elseif (z <= 1.65e-131)
		tmp = Float64(x / z);
	elseif (z <= 5.2e-102)
		tmp = Float64(x * Float64(y / z));
	elseif (z <= 1200.0)
		tmp = Float64(x / z);
	else
		tmp = Float64(-x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -0.22)
		tmp = -x;
	elseif (z <= 1.65e-131)
		tmp = x / z;
	elseif (z <= 5.2e-102)
		tmp = x * (y / z);
	elseif (z <= 1200.0)
		tmp = x / z;
	else
		tmp = -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -0.22], (-x), If[LessEqual[z, 1.65e-131], N[(x / z), $MachinePrecision], If[LessEqual[z, 5.2e-102], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1200.0], N[(x / z), $MachinePrecision], (-x)]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.22:\\
\;\;\;\;-x\\

\mathbf{elif}\;z \leq 1.65 \cdot 10^{-131}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 5.2 \cdot 10^{-102}:\\
\;\;\;\;x \cdot \frac{y}{z}\\

\mathbf{elif}\;z \leq 1200:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{else}:\\
\;\;\;\;-x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -0.220000000000000001 or 1200 < z

    1. Initial program 77.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 76.7%

      \[\leadsto \color{blue}{-1 \cdot x} \]
    6. Step-by-step derivation
      1. neg-mul-176.7%

        \[\leadsto \color{blue}{-x} \]
    7. Simplified76.7%

      \[\leadsto \color{blue}{-x} \]

    if -0.220000000000000001 < z < 1.6500000000000001e-131 or 5.19999999999999973e-102 < z < 1200

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 97.0%

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

        \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} \]
    7. Simplified86.9%

      \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} \]
    8. Taylor expanded in y around 0 62.2%

      \[\leadsto \color{blue}{\frac{x}{z}} \]

    if 1.6500000000000001e-131 < z < 5.19999999999999973e-102

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 92.1%

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    6. Step-by-step derivation
      1. associate-/l*77.0%

        \[\leadsto \color{blue}{x \cdot \frac{y}{z}} \]
    7. Simplified77.0%

      \[\leadsto \color{blue}{x \cdot \frac{y}{z}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 9: 95.4% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2:\\
\;\;\;\;x \cdot \frac{y - z}{z}\\

\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\frac{x}{z} - x\\

\mathbf{elif}\;y \leq 1.22 \cdot 10^{+238}:\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{z}{x \cdot y}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -4.20000000000000018

    1. Initial program 85.4%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 89.3%

      \[\leadsto x \cdot \frac{\color{blue}{y \cdot \left(\left(1 + \frac{1}{y}\right) - \frac{z}{y}\right)}}{z} \]
    6. Step-by-step derivation
      1. associate--l+89.3%

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

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

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

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

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

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

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

      \[\leadsto x \cdot \frac{\color{blue}{y + -1 \cdot z}}{z} \]
    12. Step-by-step derivation
      1. neg-mul-187.0%

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

        \[\leadsto x \cdot \frac{\color{blue}{y - z}}{z} \]
    13. Simplified87.0%

      \[\leadsto x \cdot \frac{\color{blue}{y - z}}{z} \]

    if -4.20000000000000018 < y < 1

    1. Initial program 88.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 99.0%

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{z} - 1\right)} \]
    6. Step-by-step derivation
      1. sub-neg99.0%

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{z} + \left(-1\right)\right)} \]
      2. metadata-eval99.0%

        \[\leadsto x \cdot \left(\frac{1}{z} + \color{blue}{-1}\right) \]
      3. distribute-rgt-in99.0%

        \[\leadsto \color{blue}{\frac{1}{z} \cdot x + -1 \cdot x} \]
      4. associate-*l/99.1%

        \[\leadsto \color{blue}{\frac{1 \cdot x}{z}} + -1 \cdot x \]
      5. *-lft-identity99.1%

        \[\leadsto \frac{\color{blue}{x}}{z} + -1 \cdot x \]
      6. neg-mul-199.1%

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    7. Simplified99.1%

      \[\leadsto \color{blue}{\frac{x}{z} - x} \]

    if 1 < y < 1.2200000000000001e238

    1. Initial program 89.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 94.8%

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

    if 1.2200000000000001e238 < y

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 93.7%

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    6. Step-by-step derivation
      1. associate-/l*50.4%

        \[\leadsto \color{blue}{x \cdot \frac{y}{z}} \]
      2. *-commutative50.4%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x} \]
    7. Applied egg-rr50.4%

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x} \]
    8. Step-by-step derivation
      1. associate-*l/93.7%

        \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]
      2. clear-num94.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{z}{y \cdot x}}} \]
    9. Applied egg-rr94.0%

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

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

Alternative 10: 95.4% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2:\\
\;\;\;\;x \cdot \frac{y - z}{z}\\

\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\frac{x}{z} - x\\

\mathbf{elif}\;y \leq 9 \cdot 10^{+237}:\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -4.20000000000000018

    1. Initial program 85.4%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 89.3%

      \[\leadsto x \cdot \frac{\color{blue}{y \cdot \left(\left(1 + \frac{1}{y}\right) - \frac{z}{y}\right)}}{z} \]
    6. Step-by-step derivation
      1. associate--l+89.3%

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

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

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

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

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

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

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

      \[\leadsto x \cdot \frac{\color{blue}{y + -1 \cdot z}}{z} \]
    12. Step-by-step derivation
      1. neg-mul-187.0%

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

        \[\leadsto x \cdot \frac{\color{blue}{y - z}}{z} \]
    13. Simplified87.0%

      \[\leadsto x \cdot \frac{\color{blue}{y - z}}{z} \]

    if -4.20000000000000018 < y < 1

    1. Initial program 88.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 99.0%

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{z} - 1\right)} \]
    6. Step-by-step derivation
      1. sub-neg99.0%

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{z} + \left(-1\right)\right)} \]
      2. metadata-eval99.0%

        \[\leadsto x \cdot \left(\frac{1}{z} + \color{blue}{-1}\right) \]
      3. distribute-rgt-in99.0%

        \[\leadsto \color{blue}{\frac{1}{z} \cdot x + -1 \cdot x} \]
      4. associate-*l/99.1%

        \[\leadsto \color{blue}{\frac{1 \cdot x}{z}} + -1 \cdot x \]
      5. *-lft-identity99.1%

        \[\leadsto \frac{\color{blue}{x}}{z} + -1 \cdot x \]
      6. neg-mul-199.1%

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    7. Simplified99.1%

      \[\leadsto \color{blue}{\frac{x}{z} - x} \]

    if 1 < y < 8.99999999999999928e237

    1. Initial program 89.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 94.8%

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

    if 8.99999999999999928e237 < y

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 93.7%

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

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

Alternative 11: 95.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(-1 + \frac{y}{z}\right)\\ \mathbf{if}\;y \leq -4.2:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{+238}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (+ -1.0 (/ y z)))))
   (if (<= y -4.2)
     t_0
     (if (<= y 1.0) (- (/ x z) x) (if (<= y 1.1e+238) t_0 (/ (* x y) z))))))
double code(double x, double y, double z) {
	double t_0 = x * (-1.0 + (y / z));
	double tmp;
	if (y <= -4.2) {
		tmp = t_0;
	} else if (y <= 1.0) {
		tmp = (x / z) - x;
	} else if (y <= 1.1e+238) {
		tmp = t_0;
	} else {
		tmp = (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) :: t_0
    real(8) :: tmp
    t_0 = x * ((-1.0d0) + (y / z))
    if (y <= (-4.2d0)) then
        tmp = t_0
    else if (y <= 1.0d0) then
        tmp = (x / z) - x
    else if (y <= 1.1d+238) then
        tmp = t_0
    else
        tmp = (x * y) / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (-1.0 + (y / z));
	double tmp;
	if (y <= -4.2) {
		tmp = t_0;
	} else if (y <= 1.0) {
		tmp = (x / z) - x;
	} else if (y <= 1.1e+238) {
		tmp = t_0;
	} else {
		tmp = (x * y) / z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (-1.0 + (y / z))
	tmp = 0
	if y <= -4.2:
		tmp = t_0
	elif y <= 1.0:
		tmp = (x / z) - x
	elif y <= 1.1e+238:
		tmp = t_0
	else:
		tmp = (x * y) / z
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(-1.0 + Float64(y / z)))
	tmp = 0.0
	if (y <= -4.2)
		tmp = t_0;
	elseif (y <= 1.0)
		tmp = Float64(Float64(x / z) - x);
	elseif (y <= 1.1e+238)
		tmp = t_0;
	else
		tmp = Float64(Float64(x * y) / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (-1.0 + (y / z));
	tmp = 0.0;
	if (y <= -4.2)
		tmp = t_0;
	elseif (y <= 1.0)
		tmp = (x / z) - x;
	elseif (y <= 1.1e+238)
		tmp = t_0;
	else
		tmp = (x * y) / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.2], t$95$0, If[LessEqual[y, 1.0], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[y, 1.1e+238], t$95$0, N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(-1 + \frac{y}{z}\right)\\
\mathbf{if}\;y \leq -4.2:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\frac{x}{z} - x\\

\mathbf{elif}\;y \leq 1.1 \cdot 10^{+238}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -4.20000000000000018 or 1 < y < 1.1e238

    1. Initial program 87.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 91.0%

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

    if -4.20000000000000018 < y < 1

    1. Initial program 88.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 99.0%

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{z} - 1\right)} \]
    6. Step-by-step derivation
      1. sub-neg99.0%

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{z} + \left(-1\right)\right)} \]
      2. metadata-eval99.0%

        \[\leadsto x \cdot \left(\frac{1}{z} + \color{blue}{-1}\right) \]
      3. distribute-rgt-in99.0%

        \[\leadsto \color{blue}{\frac{1}{z} \cdot x + -1 \cdot x} \]
      4. associate-*l/99.1%

        \[\leadsto \color{blue}{\frac{1 \cdot x}{z}} + -1 \cdot x \]
      5. *-lft-identity99.1%

        \[\leadsto \frac{\color{blue}{x}}{z} + -1 \cdot x \]
      6. neg-mul-199.1%

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    7. Simplified99.1%

      \[\leadsto \color{blue}{\frac{x}{z} - x} \]

    if 1.1e238 < y

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 93.7%

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

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

Alternative 12: 99.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{-16} \lor \neg \left(z \leq 2.1 \cdot 10^{-71}\right):\\
\;\;\;\;x \cdot \left(\frac{y + 1}{z} + -1\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.2000000000000002e-16 or 2.1000000000000001e-71 < z

    1. Initial program 80.3%

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

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

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

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

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

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

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

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

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

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

    if -4.2000000000000002e-16 < z < 2.1000000000000001e-71

    1. Initial program 99.9%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. distribute-lft-in99.9%

        \[\leadsto \frac{\color{blue}{x \cdot \left(y - z\right) + x \cdot 1}}{z} \]
      2. fma-define99.9%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y - z, x \cdot 1\right)}}{z} \]
      3. *-rgt-identity99.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{-16} \lor \neg \left(z \leq 2.1 \cdot 10^{-71}\right):\\ \;\;\;\;x \cdot \left(\frac{y + 1}{z} + -1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x + x \cdot y}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 99.7% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \leq 5 \cdot 10^{-72}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -8.99999999999999987e-18

    1. Initial program 75.9%

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

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

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

    if -8.99999999999999987e-18 < z < 4.9999999999999996e-72

    1. Initial program 99.9%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. distribute-lft-in99.9%

        \[\leadsto \frac{\color{blue}{x \cdot \left(y - z\right) + x \cdot 1}}{z} \]
      2. fma-define99.9%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y - z, x \cdot 1\right)}}{z} \]
      3. *-rgt-identity99.9%

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

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

      \[\leadsto \color{blue}{\frac{x + x \cdot y}{z}} \]

    if 4.9999999999999996e-72 < z

    1. Initial program 84.8%

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

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

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

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

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

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

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

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

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

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

Alternative 14: 98.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.05:\\ \;\;\;\;x \cdot \frac{y}{z} - x\\ \mathbf{elif}\;z \leq 1200:\\ \;\;\;\;\frac{x + x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -1.05)
   (- (* x (/ y z)) x)
   (if (<= z 1200.0) (/ (+ x (* x y)) z) (* x (+ -1.0 (/ y z))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.05) {
		tmp = (x * (y / z)) - x;
	} else if (z <= 1200.0) {
		tmp = (x + (x * y)) / z;
	} else {
		tmp = x * (-1.0 + (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 (z <= (-1.05d0)) then
        tmp = (x * (y / z)) - x
    else if (z <= 1200.0d0) then
        tmp = (x + (x * y)) / z
    else
        tmp = x * ((-1.0d0) + (y / z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.05) {
		tmp = (x * (y / z)) - x;
	} else if (z <= 1200.0) {
		tmp = (x + (x * y)) / z;
	} else {
		tmp = x * (-1.0 + (y / z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -1.05:
		tmp = (x * (y / z)) - x
	elif z <= 1200.0:
		tmp = (x + (x * y)) / z
	else:
		tmp = x * (-1.0 + (y / z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -1.05)
		tmp = Float64(Float64(x * Float64(y / z)) - x);
	elseif (z <= 1200.0)
		tmp = Float64(Float64(x + Float64(x * y)) / z);
	else
		tmp = Float64(x * Float64(-1.0 + Float64(y / z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -1.05)
		tmp = (x * (y / z)) - x;
	elseif (z <= 1200.0)
		tmp = (x + (x * y)) / z;
	else
		tmp = x * (-1.0 + (y / z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -1.05], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[z, 1200.0], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05:\\
\;\;\;\;x \cdot \frac{y}{z} - x\\

\mathbf{elif}\;z \leq 1200:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\

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


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

    1. Initial program 74.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-lft-in99.9%

        \[\leadsto \color{blue}{x \cdot \frac{y + 1}{z} + x \cdot -1} \]
      2. *-commutative99.9%

        \[\leadsto x \cdot \frac{y + 1}{z} + \color{blue}{-1 \cdot x} \]
      3. mul-1-neg99.9%

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

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

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

    if -1.05000000000000004 < z < 1200

    1. Initial program 99.8%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. distribute-lft-in99.8%

        \[\leadsto \frac{\color{blue}{x \cdot \left(y - z\right) + x \cdot 1}}{z} \]
      2. fma-define99.8%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y - z, x \cdot 1\right)}}{z} \]
      3. *-rgt-identity99.8%

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

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

      \[\leadsto \color{blue}{\frac{x + x \cdot y}{z}} \]

    if 1200 < z

    1. Initial program 80.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 98.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.05:\\ \;\;\;\;x \cdot \frac{y}{z} - x\\ \mathbf{elif}\;z \leq 1200:\\ \;\;\;\;\frac{x + x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 98.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;x \cdot \frac{y - z}{z}\\ \mathbf{elif}\;z \leq 1200:\\ \;\;\;\;\frac{x + x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -1.0)
   (* x (/ (- y z) z))
   (if (<= z 1200.0) (/ (+ x (* x y)) z) (* x (+ -1.0 (/ y z))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.0) {
		tmp = x * ((y - z) / z);
	} else if (z <= 1200.0) {
		tmp = (x + (x * y)) / z;
	} else {
		tmp = x * (-1.0 + (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 (z <= (-1.0d0)) then
        tmp = x * ((y - z) / z)
    else if (z <= 1200.0d0) then
        tmp = (x + (x * y)) / z
    else
        tmp = x * ((-1.0d0) + (y / z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.0) {
		tmp = x * ((y - z) / z);
	} else if (z <= 1200.0) {
		tmp = (x + (x * y)) / z;
	} else {
		tmp = x * (-1.0 + (y / z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -1.0:
		tmp = x * ((y - z) / z)
	elif z <= 1200.0:
		tmp = (x + (x * y)) / z
	else:
		tmp = x * (-1.0 + (y / z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -1.0)
		tmp = Float64(x * Float64(Float64(y - z) / z));
	elseif (z <= 1200.0)
		tmp = Float64(Float64(x + Float64(x * y)) / z);
	else
		tmp = Float64(x * Float64(-1.0 + Float64(y / z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -1.0)
		tmp = x * ((y - z) / z);
	elseif (z <= 1200.0)
		tmp = (x + (x * y)) / z;
	else
		tmp = x * (-1.0 + (y / z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -1.0], N[(x * N[(N[(y - z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1200.0], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;x \cdot \frac{y - z}{z}\\

\mathbf{elif}\;z \leq 1200:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\

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


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

    1. Initial program 74.2%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 75.2%

      \[\leadsto x \cdot \frac{\color{blue}{y \cdot \left(\left(1 + \frac{1}{y}\right) - \frac{z}{y}\right)}}{z} \]
    6. Step-by-step derivation
      1. associate--l+75.2%

        \[\leadsto x \cdot \frac{y \cdot \color{blue}{\left(1 + \left(\frac{1}{y} - \frac{z}{y}\right)\right)}}{z} \]
      2. div-sub75.2%

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

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

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

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

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

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

      \[\leadsto x \cdot \frac{\color{blue}{y + -1 \cdot z}}{z} \]
    12. Step-by-step derivation
      1. neg-mul-198.4%

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

        \[\leadsto x \cdot \frac{\color{blue}{y - z}}{z} \]
    13. Simplified98.4%

      \[\leadsto x \cdot \frac{\color{blue}{y - z}}{z} \]

    if -1 < z < 1200

    1. Initial program 99.8%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. distribute-lft-in99.8%

        \[\leadsto \frac{\color{blue}{x \cdot \left(y - z\right) + x \cdot 1}}{z} \]
      2. fma-define99.8%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y - z, x \cdot 1\right)}}{z} \]
      3. *-rgt-identity99.8%

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

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

      \[\leadsto \color{blue}{\frac{x + x \cdot y}{z}} \]

    if 1200 < z

    1. Initial program 80.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 98.3%

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

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

Alternative 16: 93.8% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 93.8%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Add Preprocessing

    if 1.6e-15 < x

    1. Initial program 73.6%

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

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

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

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

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

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

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

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

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

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

Alternative 17: 65.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.22 \lor \neg \left(z \leq 1200\right):\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -0.22) (not (<= z 1200.0))) (- x) (/ x z)))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -0.22) || !(z <= 1200.0)) {
		tmp = -x;
	} else {
		tmp = x / z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((z <= (-0.22d0)) .or. (.not. (z <= 1200.0d0))) then
        tmp = -x
    else
        tmp = x / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -0.22) || !(z <= 1200.0)) {
		tmp = -x;
	} else {
		tmp = x / z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -0.22) or not (z <= 1200.0):
		tmp = -x
	else:
		tmp = x / z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -0.22) || !(z <= 1200.0))
		tmp = Float64(-x);
	else
		tmp = Float64(x / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -0.22) || ~((z <= 1200.0)))
		tmp = -x;
	else
		tmp = x / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.22], N[Not[LessEqual[z, 1200.0]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.22 \lor \neg \left(z \leq 1200\right):\\
\;\;\;\;-x\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -0.220000000000000001 or 1200 < z

    1. Initial program 77.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 76.7%

      \[\leadsto \color{blue}{-1 \cdot x} \]
    6. Step-by-step derivation
      1. neg-mul-176.7%

        \[\leadsto \color{blue}{-x} \]
    7. Simplified76.7%

      \[\leadsto \color{blue}{-x} \]

    if -0.220000000000000001 < z < 1200

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 97.1%

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

        \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} \]
    7. Simplified86.8%

      \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} \]
    8. Taylor expanded in y around 0 59.4%

      \[\leadsto \color{blue}{\frac{x}{z}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.22 \lor \neg \left(z \leq 1200\right):\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 39.5% accurate, 4.5× speedup?

\[\begin{array}{l} \\ -x \end{array} \]
(FPCore (x y z) :precision binary64 (- x))
double code(double x, double y, double z) {
	return -x;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = -x
end function
public static double code(double x, double y, double z) {
	return -x;
}
def code(x, y, z):
	return -x
function code(x, y, z)
	return Float64(-x)
end
function tmp = code(x, y, z)
	tmp = -x;
end
code[x_, y_, z_] := (-x)
\begin{array}{l}

\\
-x
\end{array}
Derivation
  1. Initial program 88.4%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{x \cdot \left(\frac{y + 1}{z} + -1\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in z around inf 40.1%

    \[\leadsto \color{blue}{-1 \cdot x} \]
  6. Step-by-step derivation
    1. neg-mul-140.1%

      \[\leadsto \color{blue}{-x} \]
  7. Simplified40.1%

    \[\leadsto \color{blue}{-x} \]
  8. Add Preprocessing

Developer target: 99.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\ \mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\ \;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (* (+ 1.0 y) (/ x z)) x)))
   (if (< x -2.71483106713436e-162)
     t_0
     (if (< x 3.874108816439546e-197)
       (* (* x (+ (- y z) 1.0)) (/ 1.0 z))
       t_0))))
double code(double x, double y, double z) {
	double t_0 = ((1.0 + y) * (x / z)) - x;
	double tmp;
	if (x < -2.71483106713436e-162) {
		tmp = t_0;
	} else if (x < 3.874108816439546e-197) {
		tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
	} 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 = ((1.0d0 + y) * (x / z)) - x
    if (x < (-2.71483106713436d-162)) then
        tmp = t_0
    else if (x < 3.874108816439546d-197) then
        tmp = (x * ((y - z) + 1.0d0)) * (1.0d0 / z)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = ((1.0 + y) * (x / z)) - x;
	double tmp;
	if (x < -2.71483106713436e-162) {
		tmp = t_0;
	} else if (x < 3.874108816439546e-197) {
		tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = ((1.0 + y) * (x / z)) - x
	tmp = 0
	if x < -2.71483106713436e-162:
		tmp = t_0
	elif x < 3.874108816439546e-197:
		tmp = (x * ((y - z) + 1.0)) * (1.0 / z)
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(Float64(1.0 + y) * Float64(x / z)) - x)
	tmp = 0.0
	if (x < -2.71483106713436e-162)
		tmp = t_0;
	elseif (x < 3.874108816439546e-197)
		tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) * Float64(1.0 / z));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = ((1.0 + y) * (x / z)) - x;
	tmp = 0.0;
	if (x < -2.71483106713436e-162)
		tmp = t_0;
	elseif (x < 3.874108816439546e-197)
		tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[Less[x, -2.71483106713436e-162], t$95$0, If[Less[x, 3.874108816439546e-197], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\
\mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\
\;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024108 
(FPCore (x y z)
  :name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
  :precision binary64

  :alt
  (if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))

  (/ (* x (+ (- y z) 1.0)) z))