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

Percentage Accurate: 88.5% → 99.7%
Time: 7.4s
Alternatives: 15
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 15 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: 88.5% 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 -1 \cdot 10^{-21}:\\ \;\;\;\;x \cdot \left(-1 + \frac{y + 1}{z}\right)\\ \mathbf{elif}\;z \leq 3 \cdot 10^{+62}:\\ \;\;\;\;\left(\left(y - z\right) + 1\right) \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -1e-21)
   (* x (+ -1.0 (/ (+ y 1.0) z)))
   (if (<= z 3e+62) (* (+ (- y z) 1.0) (/ x z)) (* x (+ -1.0 (/ y z))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -1e-21) {
		tmp = x * (-1.0 + ((y + 1.0) / z));
	} else if (z <= 3e+62) {
		tmp = ((y - z) + 1.0) * (x / 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 <= (-1d-21)) then
        tmp = x * ((-1.0d0) + ((y + 1.0d0) / z))
    else if (z <= 3d+62) then
        tmp = ((y - z) + 1.0d0) * (x / 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 <= -1e-21) {
		tmp = x * (-1.0 + ((y + 1.0) / z));
	} else if (z <= 3e+62) {
		tmp = ((y - z) + 1.0) * (x / z);
	} else {
		tmp = x * (-1.0 + (y / z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -1e-21:
		tmp = x * (-1.0 + ((y + 1.0) / z))
	elif z <= 3e+62:
		tmp = ((y - z) + 1.0) * (x / z)
	else:
		tmp = x * (-1.0 + (y / z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -1e-21)
		tmp = Float64(x * Float64(-1.0 + Float64(Float64(y + 1.0) / z)));
	elseif (z <= 3e+62)
		tmp = Float64(Float64(Float64(y - z) + 1.0) * Float64(x / 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 <= -1e-21)
		tmp = x * (-1.0 + ((y + 1.0) / z));
	elseif (z <= 3e+62)
		tmp = ((y - z) + 1.0) * (x / z);
	else
		tmp = x * (-1.0 + (y / z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -1e-21], N[(x * N[(-1.0 + N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3e+62], N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 3 \cdot 10^{+62}:\\
\;\;\;\;\left(\left(y - z\right) + 1\right) \cdot \frac{x}{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 < -9.99999999999999908e-22

    1. Initial program 77.3%

      \[\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. +-commutative99.9%

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

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

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

    if -9.99999999999999908e-22 < z < 3e62

    1. Initial program 99.9%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative99.9%

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

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

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

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

    if 3e62 < z

    1. Initial program 69.7%

      \[\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. +-commutative100.0%

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

        \[\leadsto x \cdot \left(\frac{y + 1}{z} + \color{blue}{-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 100.0%

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

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

Alternative 2: 65.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -1.06 \cdot 10^{+39}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{-280}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{-101}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 15:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= z -1.06e+39)
     (- x)
     (if (<= z 5.2e-280)
       t_0
       (if (<= z 8.2e-101) (/ x z) (if (<= z 15.0) t_0 (- x)))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -1.06e+39) {
		tmp = -x;
	} else if (z <= 5.2e-280) {
		tmp = t_0;
	} else if (z <= 8.2e-101) {
		tmp = x / z;
	} else if (z <= 15.0) {
		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 <= (-1.06d+39)) then
        tmp = -x
    else if (z <= 5.2d-280) then
        tmp = t_0
    else if (z <= 8.2d-101) then
        tmp = x / z
    else if (z <= 15.0d0) 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 <= -1.06e+39) {
		tmp = -x;
	} else if (z <= 5.2e-280) {
		tmp = t_0;
	} else if (z <= 8.2e-101) {
		tmp = x / z;
	} else if (z <= 15.0) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if z <= -1.06e+39:
		tmp = -x
	elif z <= 5.2e-280:
		tmp = t_0
	elif z <= 8.2e-101:
		tmp = x / z
	elif z <= 15.0:
		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 <= -1.06e+39)
		tmp = Float64(-x);
	elseif (z <= 5.2e-280)
		tmp = t_0;
	elseif (z <= 8.2e-101)
		tmp = Float64(x / z);
	elseif (z <= 15.0)
		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 <= -1.06e+39)
		tmp = -x;
	elseif (z <= 5.2e-280)
		tmp = t_0;
	elseif (z <= 8.2e-101)
		tmp = x / z;
	elseif (z <= 15.0)
		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, -1.06e+39], (-x), If[LessEqual[z, 5.2e-280], t$95$0, If[LessEqual[z, 8.2e-101], N[(x / z), $MachinePrecision], If[LessEqual[z, 15.0], t$95$0, (-x)]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 5.2 \cdot 10^{-280}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 8.2 \cdot 10^{-101}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 15:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 74.0%

      \[\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. +-commutative100.0%

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

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

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

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

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

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

    if -1.06000000000000005e39 < z < 5.2e-280 or 8.20000000000000052e-101 < z < 15

    1. Initial program 99.8%

      \[\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}} \]
      2. +-commutative90.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.2e-280 < z < 8.20000000000000052e-101

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 61.9% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -8.5 \cdot 10^{+36}:\\
\;\;\;\;-x\\

\mathbf{elif}\;z \leq 1.6 \cdot 10^{-282}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 8.5 \cdot 10^{-101}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 15:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 74.0%

      \[\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. +-commutative100.0%

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

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

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

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

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

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

    if -8.50000000000000014e36 < z < 1.59999999999999991e-282 or 8.49999999999999941e-101 < z < 15

    1. Initial program 99.8%

      \[\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}} \]
      2. +-commutative90.8%

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

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

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

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

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

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

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

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

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

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

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

    if 1.59999999999999991e-282 < z < 8.49999999999999941e-101

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.8% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{-23} \lor \neg \left(z \leq 5.5 \cdot 10^{-37}\right):\\
\;\;\;\;x \cdot \left(-1 + \frac{y + 1}{z}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.4999999999999996e-23 or 5.4999999999999998e-37 < z

    1. Initial program 78.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. +-commutative99.9%

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

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

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

    if -8.4999999999999996e-23 < z < 5.4999999999999998e-37

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

      \[\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}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

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

Alternative 5: 98.4% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 75.7%

      \[\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. +-commutative99.9%

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

        \[\leadsto x \cdot \left(\frac{y + 1}{z} + \color{blue}{-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 inf 99.3%

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

    if -5.8e14 < z < 1

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 94.6% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2120000000 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\

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


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

    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.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. +-commutative99.9%

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

        \[\leadsto x \cdot \left(\frac{y + 1}{z} + \color{blue}{-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 inf 99.3%

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

    if -2.12e9 < z < 1

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} \]
    8. Step-by-step derivation
      1. clear-num89.4%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{z}{1 + y}}} \]
      2. +-commutative89.4%

        \[\leadsto x \cdot \frac{1}{\frac{z}{\color{blue}{y + 1}}} \]
      3. div-inv90.0%

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

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

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

Alternative 7: 94.0% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 75.7%

      \[\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. +-commutative99.9%

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

        \[\leadsto x \cdot \left(\frac{y + 1}{z} + \color{blue}{-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 inf 99.3%

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

    if -5.8e14 < z < 1

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 84.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.4 \cdot 10^{+55} \lor \neg \left(y \leq 3.6 \cdot 10^{+93}\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 -1.4e+55) (not (<= y 3.6e+93))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.4e+55) || !(y <= 3.6e+93)) {
		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 <= (-1.4d+55)) .or. (.not. (y <= 3.6d+93))) 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 <= -1.4e+55) || !(y <= 3.6e+93)) {
		tmp = y * (x / z);
	} else {
		tmp = (x / z) - x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -1.4e+55) or not (y <= 3.6e+93):
		tmp = y * (x / z)
	else:
		tmp = (x / z) - x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -1.4e+55) || !(y <= 3.6e+93))
		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 <= -1.4e+55) || ~((y <= 3.6e+93)))
		tmp = y * (x / z);
	else
		tmp = (x / z) - x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.4e+55], N[Not[LessEqual[y, 3.6e+93]], $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 -1.4 \cdot 10^{+55} \lor \neg \left(y \leq 3.6 \cdot 10^{+93}\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 < -1.4e55 or 3.5999999999999999e93 < y

    1. Initial program 91.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.4e55 < y < 3.5999999999999999e93

    1. Initial program 86.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. +-commutative99.9%

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

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

      \[\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. clear-num99.9%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.4 \cdot 10^{+55} \lor \neg \left(y \leq 3.6 \cdot 10^{+93}\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} - x\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 89.8% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 86.0%

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

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

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

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

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

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

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

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

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

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

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

    if -1 < y < 8.49999999999999984e99

    1. Initial program 87.4%

      \[\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. +-commutative99.9%

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

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

      \[\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. clear-num99.8%

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + 1}}} + x \cdot -1 \]
      4. *-commutative100.0%

        \[\leadsto \frac{x}{\frac{z}{y + 1}} + \color{blue}{-1 \cdot x} \]
      5. mul-1-neg100.0%

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

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

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

    if 8.49999999999999984e99 < y

    1. Initial program 95.8%

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

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

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

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

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

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

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

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

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

      \[\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 simplification93.2%

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

Alternative 10: 84.5% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 88.9%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \left(\frac{y + 1}{z} + \color{blue}{-1}\right) \]
    3. Simplified89.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}} \]
    6. Step-by-step derivation
      1. *-commutative76.6%

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

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

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

    if -9.19999999999999977e54 < y < 1.60000000000000003e101

    1. Initial program 86.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. +-commutative99.9%

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

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

      \[\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. clear-num99.9%

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

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

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

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

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

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

    if 1.60000000000000003e101 < y

    1. Initial program 95.8%

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

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

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

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

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

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

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

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

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

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

Alternative 11: 94.2% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 90.5%

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

    if 1.1800000000000001e-103 < x

    1. Initial program 85.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.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. +-commutative99.8%

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

        \[\leadsto x \cdot \left(\frac{y + 1}{z} + \color{blue}{-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.8%

        \[\leadsto \color{blue}{x \cdot \frac{y + 1}{z} + x \cdot -1} \]
      2. clear-num99.8%

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

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

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

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

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

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

Alternative 12: 94.3% accurate, 0.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.10000000000000004e26

    1. Initial program 92.2%

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

    if 1.10000000000000004e26 < x

    1. Initial program 76.6%

      \[\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. +-commutative99.9%

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

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

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

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

Alternative 13: 63.7% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+14} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;-x\\

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


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

    1. Initial program 75.7%

      \[\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. +-commutative99.9%

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

        \[\leadsto x \cdot \left(\frac{y + 1}{z} + \color{blue}{-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 74.9%

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

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

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

    if -5.8e14 < z < 1

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 38.2% 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.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 3.0% accurate, 9.0× 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 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.6%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-x} \]
  8. Step-by-step derivation
    1. neg-sub036.5%

      \[\leadsto \color{blue}{0 - x} \]
    2. sub-neg36.5%

      \[\leadsto \color{blue}{0 + \left(-x\right)} \]
    3. add-sqr-sqrt17.2%

      \[\leadsto 0 + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}} \]
    4. sqrt-unprod19.3%

      \[\leadsto 0 + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}} \]
    5. sqr-neg19.3%

      \[\leadsto 0 + \sqrt{\color{blue}{x \cdot x}} \]
    6. sqrt-unprod1.9%

      \[\leadsto 0 + \color{blue}{\sqrt{x} \cdot \sqrt{x}} \]
    7. add-sqr-sqrt3.2%

      \[\leadsto 0 + \color{blue}{x} \]
  9. Applied egg-rr3.2%

    \[\leadsto \color{blue}{0 + x} \]
  10. Step-by-step derivation
    1. +-lft-identity3.2%

      \[\leadsto \color{blue}{x} \]
  11. Simplified3.2%

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

Developer Target 1: 99.5% 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 2024149 
(FPCore (x y z)
  :name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
  :precision binary64

  :alt
  (! :herbie-platform default (if (< x -67870776678359/25000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (+ 1 y) (/ x z)) x) (if (< x 1937054408219773/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (* x (+ (- y z) 1)) (/ 1 z)) (- (* (+ 1 y) (/ x z)) x))))

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