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

Percentage Accurate: 88.2% → 99.8%
Time: 7.9s
Alternatives: 11
Speedup: 1.0×

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

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

Initial Program: 88.2% 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.8% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6.8000000000000001e-12 or 4.4999999999999998e-29 < z

    1. Initial program 61.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}} \]
    3. Simplified99.9%

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

    if -6.8000000000000001e-12 < z < 4.4999999999999998e-29

    1. Initial program 99.9%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    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 -6.8 \cdot 10^{-12} \lor \neg \left(z \leq 4.5 \cdot 10^{-29}\right):\\ \;\;\;\;x \cdot \frac{\left(y - z\right) + 1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 65.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{y}{z}\\ \mathbf{if}\;z \leq -7.5 \cdot 10^{+22}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-82}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-29}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 19000000:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (/ y z))))
   (if (<= z -7.5e+22)
     (- x)
     (if (<= z -6.8e-82)
       t_0
       (if (<= z 4.4e-29) (/ x z) (if (<= z 19000000.0) t_0 (- x)))))))
double code(double x, double y, double z) {
	double t_0 = x * (y / z);
	double tmp;
	if (z <= -7.5e+22) {
		tmp = -x;
	} else if (z <= -6.8e-82) {
		tmp = t_0;
	} else if (z <= 4.4e-29) {
		tmp = x / z;
	} else if (z <= 19000000.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 <= (-7.5d+22)) then
        tmp = -x
    else if (z <= (-6.8d-82)) then
        tmp = t_0
    else if (z <= 4.4d-29) then
        tmp = x / z
    else if (z <= 19000000.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 <= -7.5e+22) {
		tmp = -x;
	} else if (z <= -6.8e-82) {
		tmp = t_0;
	} else if (z <= 4.4e-29) {
		tmp = x / z;
	} else if (z <= 19000000.0) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (y / z)
	tmp = 0
	if z <= -7.5e+22:
		tmp = -x
	elif z <= -6.8e-82:
		tmp = t_0
	elif z <= 4.4e-29:
		tmp = x / z
	elif z <= 19000000.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 <= -7.5e+22)
		tmp = Float64(-x);
	elseif (z <= -6.8e-82)
		tmp = t_0;
	elseif (z <= 4.4e-29)
		tmp = Float64(x / z);
	elseif (z <= 19000000.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 <= -7.5e+22)
		tmp = -x;
	elseif (z <= -6.8e-82)
		tmp = t_0;
	elseif (z <= 4.4e-29)
		tmp = x / z;
	elseif (z <= 19000000.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, -7.5e+22], (-x), If[LessEqual[z, -6.8e-82], t$95$0, If[LessEqual[z, 4.4e-29], N[(x / z), $MachinePrecision], If[LessEqual[z, 19000000.0], t$95$0, (-x)]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -6.8 \cdot 10^{-82}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 4.4 \cdot 10^{-29}:\\
\;\;\;\;\frac{x}{z}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -7.5000000000000002e22 or 1.9e7 < z

    1. Initial program 57.8%

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

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

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

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

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

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

    if -7.5000000000000002e22 < z < -6.7999999999999995e-82 or 4.39999999999999981e-29 < z < 1.9e7

    1. Initial program 99.6%

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

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

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

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

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

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

    if -6.7999999999999995e-82 < z < 4.39999999999999981e-29

    1. Initial program 99.9%

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

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

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

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

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

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

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

Alternative 3: 86.6% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.1 \cdot 10^{+23}:\\
\;\;\;\;-x\\

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

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


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

    1. Initial program 55.5%

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

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

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

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

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

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

    if -4.09999999999999996e23 < z < 7e4

    1. Initial program 99.9%

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

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

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

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

    if 7e4 < z

    1. Initial program 59.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}} \]
    3. Simplified99.9%

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

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

      \[\leadsto \color{blue}{-1 \cdot x + \frac{x}{z}} \]
    7. Step-by-step derivation
      1. +-commutative85.2%

        \[\leadsto \color{blue}{\frac{x}{z} + -1 \cdot x} \]
      2. mul-1-neg85.2%

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    8. Simplified85.2%

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

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

Alternative 4: 82.6% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+21}:\\
\;\;\;\;-x\\

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

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


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

    1. Initial program 55.5%

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

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

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

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

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

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

    if -5.5e21 < z < 12000

    1. Initial program 99.9%

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

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

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

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

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

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

    if 12000 < z

    1. Initial program 59.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}} \]
    3. Simplified99.9%

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

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

      \[\leadsto \color{blue}{-1 \cdot x + \frac{x}{z}} \]
    7. Step-by-step derivation
      1. +-commutative85.2%

        \[\leadsto \color{blue}{\frac{x}{z} + -1 \cdot x} \]
      2. mul-1-neg85.2%

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    8. Simplified85.2%

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

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

Alternative 5: 85.3% accurate, 0.6× speedup?

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

    1. Initial program 82.3%

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

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

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

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

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

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

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

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

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

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

    if -2.9e16 < y < 1.25e50

    1. Initial program 78.6%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot x + \frac{x}{z}} \]
    7. Step-by-step derivation
      1. +-commutative97.2%

        \[\leadsto \color{blue}{\frac{x}{z} + -1 \cdot x} \]
      2. mul-1-neg97.2%

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    8. Simplified97.2%

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

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

Alternative 6: 85.3% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 81.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.4e16 < y < 1.7600000000000001e50

    1. Initial program 78.6%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot x + \frac{x}{z}} \]
    7. Step-by-step derivation
      1. +-commutative97.2%

        \[\leadsto \color{blue}{\frac{x}{z} + -1 \cdot x} \]
      2. mul-1-neg97.2%

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    8. Simplified97.2%

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

    if 1.7600000000000001e50 < y

    1. Initial program 83.1%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 94.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(y - z\right) + 1\\ \mathbf{if}\;x \leq 200:\\ \;\;\;\;\frac{x \cdot t\_0}{z}\\ \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 200.0) (/ (* x t_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 <= 200.0) {
		tmp = (x * t_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 <= 200.0d0) then
        tmp = (x * t_0) / 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 <= 200.0) {
		tmp = (x * t_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 <= 200.0:
		tmp = (x * t_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 (x <= 200.0)
		tmp = Float64(Float64(x * t_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 <= 200.0)
		tmp = (x * t_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[x, 200.0], N[(N[(x * t$95$0), $MachinePrecision] / z), $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}\;x \leq 200:\\
\;\;\;\;\frac{x \cdot t\_0}{z}\\

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


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

    1. Initial program 83.9%

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

    if 200 < x

    1. Initial program 66.6%

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

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

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

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

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

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

Alternative 8: 64.3% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.2 \cdot 10^{-6} \lor \neg \left(z \leq 2.6 \cdot 10^{-17}\right):\\
\;\;\;\;-x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.1999999999999999e-6 or 2.60000000000000003e-17 < z

    1. Initial program 60.4%

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

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

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

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

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

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

    if -3.1999999999999999e-6 < z < 2.60000000000000003e-17

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

Alternative 9: 96.2% accurate, 1.0× speedup?

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

\\
\frac{x}{\frac{z}{\left(y - z\right) + 1}}
\end{array}
Derivation
  1. Initial program 80.2%

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

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

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

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

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

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

Alternative 10: 38.5% accurate, 4.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0 - x} \]
    2. sub-neg41.1%

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

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

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

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

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

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

    \[\leadsto \color{blue}{0 + x} \]
  10. Taylor expanded in x around 0 2.8%

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

Developer Target 1: 99.4% accurate, 0.4× speedup?

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

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

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

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024181 
(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))