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

Percentage Accurate: 88.0% → 99.9%
Time: 5.6s
Alternatives: 12
Speedup: 0.8×

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 12 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 88.0% 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.9% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{+32} \lor \neg \left(z \leq 5 \cdot 10^{+16}\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.5000000000000001e32 or 5e16 < z

    1. Initial program 77.5%

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

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

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

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

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

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

    if -3.5000000000000001e32 < z < 5e16

    1. Initial program 99.8%

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

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

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

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

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

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

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

Alternative 2: 65.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -2.4 \cdot 10^{+58}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -2.8 \cdot 10^{-12}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4.1 \cdot 10^{-132}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-154}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.16 \cdot 10^{-250}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-187}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-45}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{+36}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= z -2.4e+58)
     (- x)
     (if (<= z -2.8e-12)
       t_0
       (if (<= z -4.1e-132)
         (/ x z)
         (if (<= z -3.6e-154)
           t_0
           (if (<= z 1.16e-250)
             (/ x z)
             (if (<= z 5.5e-187)
               t_0
               (if (<= z 8.5e-45)
                 (/ x z)
                 (if (<= z 2.3e+36) t_0 (- x)))))))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -2.4e+58) {
		tmp = -x;
	} else if (z <= -2.8e-12) {
		tmp = t_0;
	} else if (z <= -4.1e-132) {
		tmp = x / z;
	} else if (z <= -3.6e-154) {
		tmp = t_0;
	} else if (z <= 1.16e-250) {
		tmp = x / z;
	} else if (z <= 5.5e-187) {
		tmp = t_0;
	} else if (z <= 8.5e-45) {
		tmp = x / z;
	} else if (z <= 2.3e+36) {
		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 <= (-2.4d+58)) then
        tmp = -x
    else if (z <= (-2.8d-12)) then
        tmp = t_0
    else if (z <= (-4.1d-132)) then
        tmp = x / z
    else if (z <= (-3.6d-154)) then
        tmp = t_0
    else if (z <= 1.16d-250) then
        tmp = x / z
    else if (z <= 5.5d-187) then
        tmp = t_0
    else if (z <= 8.5d-45) then
        tmp = x / z
    else if (z <= 2.3d+36) 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 <= -2.4e+58) {
		tmp = -x;
	} else if (z <= -2.8e-12) {
		tmp = t_0;
	} else if (z <= -4.1e-132) {
		tmp = x / z;
	} else if (z <= -3.6e-154) {
		tmp = t_0;
	} else if (z <= 1.16e-250) {
		tmp = x / z;
	} else if (z <= 5.5e-187) {
		tmp = t_0;
	} else if (z <= 8.5e-45) {
		tmp = x / z;
	} else if (z <= 2.3e+36) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if z <= -2.4e+58:
		tmp = -x
	elif z <= -2.8e-12:
		tmp = t_0
	elif z <= -4.1e-132:
		tmp = x / z
	elif z <= -3.6e-154:
		tmp = t_0
	elif z <= 1.16e-250:
		tmp = x / z
	elif z <= 5.5e-187:
		tmp = t_0
	elif z <= 8.5e-45:
		tmp = x / z
	elif z <= 2.3e+36:
		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 <= -2.4e+58)
		tmp = Float64(-x);
	elseif (z <= -2.8e-12)
		tmp = t_0;
	elseif (z <= -4.1e-132)
		tmp = Float64(x / z);
	elseif (z <= -3.6e-154)
		tmp = t_0;
	elseif (z <= 1.16e-250)
		tmp = Float64(x / z);
	elseif (z <= 5.5e-187)
		tmp = t_0;
	elseif (z <= 8.5e-45)
		tmp = Float64(x / z);
	elseif (z <= 2.3e+36)
		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 <= -2.4e+58)
		tmp = -x;
	elseif (z <= -2.8e-12)
		tmp = t_0;
	elseif (z <= -4.1e-132)
		tmp = x / z;
	elseif (z <= -3.6e-154)
		tmp = t_0;
	elseif (z <= 1.16e-250)
		tmp = x / z;
	elseif (z <= 5.5e-187)
		tmp = t_0;
	elseif (z <= 8.5e-45)
		tmp = x / z;
	elseif (z <= 2.3e+36)
		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, -2.4e+58], (-x), If[LessEqual[z, -2.8e-12], t$95$0, If[LessEqual[z, -4.1e-132], N[(x / z), $MachinePrecision], If[LessEqual[z, -3.6e-154], t$95$0, If[LessEqual[z, 1.16e-250], N[(x / z), $MachinePrecision], If[LessEqual[z, 5.5e-187], t$95$0, If[LessEqual[z, 8.5e-45], N[(x / z), $MachinePrecision], If[LessEqual[z, 2.3e+36], t$95$0, (-x)]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -2.8 \cdot 10^{-12}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -4.1 \cdot 10^{-132}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq -3.6 \cdot 10^{-154}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 1.16 \cdot 10^{-250}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 5.5 \cdot 10^{-187}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;z \leq 2.3 \cdot 10^{+36}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 75.8%

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

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

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

        \[\leadsto \color{blue}{-x} \]
    5. Simplified72.3%

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

    if -2.4e58 < z < -2.8000000000000002e-12 or -4.10000000000000007e-132 < z < -3.6000000000000003e-154 or 1.16e-250 < z < 5.50000000000000033e-187 or 8.50000000000000041e-45 < z < 2.29999999999999996e36

    1. Initial program 99.7%

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

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

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

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

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

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

    if -2.8000000000000002e-12 < z < -4.10000000000000007e-132 or -3.6000000000000003e-154 < z < 1.16e-250 or 5.50000000000000033e-187 < z < 8.50000000000000041e-45

    1. Initial program 99.8%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Taylor expanded in z around 0 99.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.4 \cdot 10^{+58}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -2.8 \cdot 10^{-12}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq -4.1 \cdot 10^{-132}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-154}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 1.16 \cdot 10^{-250}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-187}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-45}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{+36}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 3: 65.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{y}{z}\\ t_1 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -5 \cdot 10^{+58}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -1.55 \cdot 10^{-10}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.35 \cdot 10^{-133}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-151}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 10^{-250}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 3.45 \cdot 10^{-189}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-42}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 7.4 \cdot 10^{+31}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (/ y z))) (t_1 (* y (/ x z))))
   (if (<= z -5e+58)
     (- x)
     (if (<= z -1.55e-10)
       t_0
       (if (<= z -3.35e-133)
         (/ x z)
         (if (<= z -2.5e-151)
           t_0
           (if (<= z 1e-250)
             (/ x z)
             (if (<= z 3.45e-189)
               t_1
               (if (<= z 1.3e-42)
                 (/ x z)
                 (if (<= z 7.4e+31) t_1 (- x)))))))))))
double code(double x, double y, double z) {
	double t_0 = x * (y / z);
	double t_1 = y * (x / z);
	double tmp;
	if (z <= -5e+58) {
		tmp = -x;
	} else if (z <= -1.55e-10) {
		tmp = t_0;
	} else if (z <= -3.35e-133) {
		tmp = x / z;
	} else if (z <= -2.5e-151) {
		tmp = t_0;
	} else if (z <= 1e-250) {
		tmp = x / z;
	} else if (z <= 3.45e-189) {
		tmp = t_1;
	} else if (z <= 1.3e-42) {
		tmp = x / z;
	} else if (z <= 7.4e+31) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_0 = x * (y / z)
    t_1 = y * (x / z)
    if (z <= (-5d+58)) then
        tmp = -x
    else if (z <= (-1.55d-10)) then
        tmp = t_0
    else if (z <= (-3.35d-133)) then
        tmp = x / z
    else if (z <= (-2.5d-151)) then
        tmp = t_0
    else if (z <= 1d-250) then
        tmp = x / z
    else if (z <= 3.45d-189) then
        tmp = t_1
    else if (z <= 1.3d-42) then
        tmp = x / z
    else if (z <= 7.4d+31) then
        tmp = t_1
    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 t_1 = y * (x / z);
	double tmp;
	if (z <= -5e+58) {
		tmp = -x;
	} else if (z <= -1.55e-10) {
		tmp = t_0;
	} else if (z <= -3.35e-133) {
		tmp = x / z;
	} else if (z <= -2.5e-151) {
		tmp = t_0;
	} else if (z <= 1e-250) {
		tmp = x / z;
	} else if (z <= 3.45e-189) {
		tmp = t_1;
	} else if (z <= 1.3e-42) {
		tmp = x / z;
	} else if (z <= 7.4e+31) {
		tmp = t_1;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (y / z)
	t_1 = y * (x / z)
	tmp = 0
	if z <= -5e+58:
		tmp = -x
	elif z <= -1.55e-10:
		tmp = t_0
	elif z <= -3.35e-133:
		tmp = x / z
	elif z <= -2.5e-151:
		tmp = t_0
	elif z <= 1e-250:
		tmp = x / z
	elif z <= 3.45e-189:
		tmp = t_1
	elif z <= 1.3e-42:
		tmp = x / z
	elif z <= 7.4e+31:
		tmp = t_1
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(y / z))
	t_1 = Float64(y * Float64(x / z))
	tmp = 0.0
	if (z <= -5e+58)
		tmp = Float64(-x);
	elseif (z <= -1.55e-10)
		tmp = t_0;
	elseif (z <= -3.35e-133)
		tmp = Float64(x / z);
	elseif (z <= -2.5e-151)
		tmp = t_0;
	elseif (z <= 1e-250)
		tmp = Float64(x / z);
	elseif (z <= 3.45e-189)
		tmp = t_1;
	elseif (z <= 1.3e-42)
		tmp = Float64(x / z);
	elseif (z <= 7.4e+31)
		tmp = t_1;
	else
		tmp = Float64(-x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (y / z);
	t_1 = y * (x / z);
	tmp = 0.0;
	if (z <= -5e+58)
		tmp = -x;
	elseif (z <= -1.55e-10)
		tmp = t_0;
	elseif (z <= -3.35e-133)
		tmp = x / z;
	elseif (z <= -2.5e-151)
		tmp = t_0;
	elseif (z <= 1e-250)
		tmp = x / z;
	elseif (z <= 3.45e-189)
		tmp = t_1;
	elseif (z <= 1.3e-42)
		tmp = x / z;
	elseif (z <= 7.4e+31)
		tmp = t_1;
	else
		tmp = -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5e+58], (-x), If[LessEqual[z, -1.55e-10], t$95$0, If[LessEqual[z, -3.35e-133], N[(x / z), $MachinePrecision], If[LessEqual[z, -2.5e-151], t$95$0, If[LessEqual[z, 1e-250], N[(x / z), $MachinePrecision], If[LessEqual[z, 3.45e-189], t$95$1, If[LessEqual[z, 1.3e-42], N[(x / z), $MachinePrecision], If[LessEqual[z, 7.4e+31], t$95$1, (-x)]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -1.55 \cdot 10^{-10}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -3.35 \cdot 10^{-133}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq -2.5 \cdot 10^{-151}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 10^{-250}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 3.45 \cdot 10^{-189}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 1.3 \cdot 10^{-42}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 7.4 \cdot 10^{+31}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -4.99999999999999986e58 or 7.3999999999999996e31 < z

    1. Initial program 75.8%

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

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

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

        \[\leadsto \color{blue}{-x} \]
    5. Simplified72.3%

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

    if -4.99999999999999986e58 < z < -1.55000000000000008e-10 or -3.3500000000000001e-133 < z < -2.50000000000000002e-151

    1. Initial program 99.5%

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{y}}} \]
    5. Step-by-step derivation
      1. div-inv65.7%

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

        \[\leadsto x \cdot \color{blue}{\frac{y}{z}} \]
      3. *-commutative66.1%

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

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

    if -1.55000000000000008e-10 < z < -3.3500000000000001e-133 or -2.50000000000000002e-151 < z < 1.0000000000000001e-250 or 3.4500000000000001e-189 < z < 1.3e-42

    1. Initial program 99.8%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Taylor expanded in z around 0 99.6%

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

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

    if 1.0000000000000001e-250 < z < 3.4500000000000001e-189 or 1.3e-42 < z < 7.3999999999999996e31

    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}{\frac{x}{\frac{z}{\left(y - z\right) + 1}}} \]
    3. Simplified90.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{+58}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -1.55 \cdot 10^{-10}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -3.35 \cdot 10^{-133}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-151}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 10^{-250}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 3.45 \cdot 10^{-189}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-42}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 7.4 \cdot 10^{+31}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 4: 97.6% accurate, 0.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -5.00000000000000011e63

    1. Initial program 80.3%

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

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

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

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

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

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

    if -5.00000000000000011e63 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z)

    1. Initial program 92.7%

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

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

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

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

Alternative 5: 97.8% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -5.00000000000000011e63

    1. Initial program 80.3%

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

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

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

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

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

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

    if -5.00000000000000011e63 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z)

    1. Initial program 92.7%

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

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

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

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

Alternative 6: 83.5% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;y \leq -1.12 \cdot 10^{+88}:\\
\;\;\;\;-x\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -3.1999999999999998e106 or 1.48000000000000006e63 < y

    1. Initial program 88.9%

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{y}}} \]
    5. Step-by-step derivation
      1. div-inv73.5%

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

        \[\leadsto x \cdot \color{blue}{\frac{y}{z}} \]
      3. *-commutative73.6%

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

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

    if -3.1999999999999998e106 < y < -1.12000000000000006e88

    1. Initial program 99.8%

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

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

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

        \[\leadsto \color{blue}{-x} \]
    5. Simplified72.3%

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

    if -1.12000000000000006e88 < y < -26

    1. Initial program 94.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}{\frac{x}{\frac{z}{\left(y - z\right) + 1}}} \]
    3. Simplified99.8%

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

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

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

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

    if -26 < y < 1.48000000000000006e63

    1. Initial program 88.1%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.2 \cdot 10^{+106}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;y \leq -1.12 \cdot 10^{+88}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -26:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq 1.48 \cdot 10^{+63}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \end{array} \]

Alternative 7: 95.1% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 89.4%

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x} - x \]
    5. Simplified92.6%

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

    if -1 < y < 1

    1. Initial program 88.9%

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

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

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

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

Alternative 8: 98.7% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 79.6%

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

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

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

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

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

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

    if -115 < z < 1

    1. Initial program 99.8%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Taylor expanded in z around 0 97.6%

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

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

Alternative 9: 85.6% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -26 or 4.00000000000000019e57 < y

    1. Initial program 90.4%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Taylor expanded in y around inf 73.3%

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

    if -26 < y < 4.00000000000000019e57

    1. Initial program 88.1%

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

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

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

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

Alternative 10: 83.7% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 86.5%

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

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

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

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

    if -15 < y < 1.94999999999999997e56

    1. Initial program 88.1%

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

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

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

    if 1.94999999999999997e56 < y

    1. Initial program 94.8%

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{y}}} \]
    5. Step-by-step derivation
      1. div-inv79.4%

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

        \[\leadsto x \cdot \color{blue}{\frac{y}{z}} \]
      3. *-commutative79.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -15:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{+56}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \end{array} \]

Alternative 11: 65.3% accurate, 1.3× speedup?

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

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

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

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


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

    1. Initial program 79.9%

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

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

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

        \[\leadsto \color{blue}{-x} \]
    5. Simplified66.6%

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

    if -1 < z < 1

    1. Initial program 99.8%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Taylor expanded in z around 0 97.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 12: 38.9% 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 89.2%

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

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

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

      \[\leadsto \color{blue}{-x} \]
  5. Simplified37.1%

    \[\leadsto \color{blue}{-x} \]
  6. Final simplification37.1%

    \[\leadsto -x \]

Developer target: 99.4% accurate, 0.6× 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 2023215 
(FPCore (x y z)
  :name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
  :precision binary64

  :herbie-target
  (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))