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

Percentage Accurate: 88.3% → 96.2%
Time: 4.6s
Alternatives: 8
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 8 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.3% 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: 96.2% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 2: 65.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{-298}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{-259}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-83}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{+34}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= z -1.0)
     (- x)
     (if (<= z 3.4e-298)
       (/ x z)
       (if (<= z 4.3e-259)
         t_0
         (if (<= z 2.8e-83) (/ x z) (if (<= z 1.55e+34) t_0 (- x))))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -1.0) {
		tmp = -x;
	} else if (z <= 3.4e-298) {
		tmp = x / z;
	} else if (z <= 4.3e-259) {
		tmp = t_0;
	} else if (z <= 2.8e-83) {
		tmp = x / z;
	} else if (z <= 1.55e+34) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = y * (x / z)
    if (z <= (-1.0d0)) then
        tmp = -x
    else if (z <= 3.4d-298) then
        tmp = x / z
    else if (z <= 4.3d-259) then
        tmp = t_0
    else if (z <= 2.8d-83) then
        tmp = x / z
    else if (z <= 1.55d+34) then
        tmp = t_0
    else
        tmp = -x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -1.0) {
		tmp = -x;
	} else if (z <= 3.4e-298) {
		tmp = x / z;
	} else if (z <= 4.3e-259) {
		tmp = t_0;
	} else if (z <= 2.8e-83) {
		tmp = x / z;
	} else if (z <= 1.55e+34) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if z <= -1.0:
		tmp = -x
	elif z <= 3.4e-298:
		tmp = x / z
	elif z <= 4.3e-259:
		tmp = t_0
	elif z <= 2.8e-83:
		tmp = x / z
	elif z <= 1.55e+34:
		tmp = t_0
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(x / z))
	tmp = 0.0
	if (z <= -1.0)
		tmp = Float64(-x);
	elseif (z <= 3.4e-298)
		tmp = Float64(x / z);
	elseif (z <= 4.3e-259)
		tmp = t_0;
	elseif (z <= 2.8e-83)
		tmp = Float64(x / z);
	elseif (z <= 1.55e+34)
		tmp = t_0;
	else
		tmp = Float64(-x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (x / z);
	tmp = 0.0;
	if (z <= -1.0)
		tmp = -x;
	elseif (z <= 3.4e-298)
		tmp = x / z;
	elseif (z <= 4.3e-259)
		tmp = t_0;
	elseif (z <= 2.8e-83)
		tmp = x / z;
	elseif (z <= 1.55e+34)
		tmp = t_0;
	else
		tmp = -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.0], (-x), If[LessEqual[z, 3.4e-298], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.3e-259], t$95$0, If[LessEqual[z, 2.8e-83], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.55e+34], t$95$0, (-x)]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 3.4 \cdot 10^{-298}:\\
\;\;\;\;\frac{x}{z}\\

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

\mathbf{elif}\;z \leq 2.8 \cdot 10^{-83}:\\
\;\;\;\;\frac{x}{z}\\

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

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


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

    1. Initial program 74.9%

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

      \[\leadsto \color{blue}{-1 \cdot x} \]
    3. Step-by-step derivation
      1. mul-1-neg81.8%

        \[\leadsto \color{blue}{-x} \]
    4. Simplified81.8%

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

    if -1 < z < 3.4e-298 or 4.3000000000000001e-259 < z < 2.8000000000000001e-83

    1. Initial program 100.0%

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

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

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

    if 3.4e-298 < z < 4.3000000000000001e-259 or 2.8000000000000001e-83 < z < 1.54999999999999989e34

    1. Initial program 99.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{-298}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{-259}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-83}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{+34}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 3: 84.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;y \leq -6800000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+51}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+148} \lor \neg \left(y \leq 3.6 \cdot 10^{+176}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= y -6800000.0)
     t_0
     (if (<= y 1.2e+51)
       (- (/ x z) x)
       (if (or (<= y 6.5e+148) (not (<= y 3.6e+176))) t_0 (- x))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (y <= -6800000.0) {
		tmp = t_0;
	} else if (y <= 1.2e+51) {
		tmp = (x / z) - x;
	} else if ((y <= 6.5e+148) || !(y <= 3.6e+176)) {
		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 (y <= (-6800000.0d0)) then
        tmp = t_0
    else if (y <= 1.2d+51) then
        tmp = (x / z) - x
    else if ((y <= 6.5d+148) .or. (.not. (y <= 3.6d+176))) 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 (y <= -6800000.0) {
		tmp = t_0;
	} else if (y <= 1.2e+51) {
		tmp = (x / z) - x;
	} else if ((y <= 6.5e+148) || !(y <= 3.6e+176)) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if y <= -6800000.0:
		tmp = t_0
	elif y <= 1.2e+51:
		tmp = (x / z) - x
	elif (y <= 6.5e+148) or not (y <= 3.6e+176):
		tmp = t_0
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(x / z))
	tmp = 0.0
	if (y <= -6800000.0)
		tmp = t_0;
	elseif (y <= 1.2e+51)
		tmp = Float64(Float64(x / z) - x);
	elseif ((y <= 6.5e+148) || !(y <= 3.6e+176))
		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 (y <= -6800000.0)
		tmp = t_0;
	elseif (y <= 1.2e+51)
		tmp = (x / z) - x;
	elseif ((y <= 6.5e+148) || ~((y <= 3.6e+176)))
		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[y, -6800000.0], t$95$0, If[LessEqual[y, 1.2e+51], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], If[Or[LessEqual[y, 6.5e+148], N[Not[LessEqual[y, 3.6e+176]], $MachinePrecision]], t$95$0, (-x)]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq 6.5 \cdot 10^{+148} \lor \neg \left(y \leq 3.6 \cdot 10^{+176}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -6.8e6 or 1.1999999999999999e51 < y < 6.49999999999999947e148 or 3.59999999999999991e176 < y

    1. Initial program 92.7%

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

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

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

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

    if -6.8e6 < y < 1.1999999999999999e51

    1. Initial program 84.7%

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 - z}}} \]
    5. Taylor expanded in x around 0 83.0%

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

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

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

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

        \[\leadsto 1 \cdot \frac{x}{z} + \color{blue}{\frac{\left(-z\right) \cdot x}{z}} \]
      5. distribute-lft-neg-out83.0%

        \[\leadsto 1 \cdot \frac{x}{z} + \frac{\color{blue}{-z \cdot x}}{z} \]
      6. *-commutative83.0%

        \[\leadsto 1 \cdot \frac{x}{z} + \frac{-\color{blue}{x \cdot z}}{z} \]
      7. distribute-lft-neg-in83.0%

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

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

        \[\leadsto 1 \cdot \frac{x}{z} + \frac{-x}{\color{blue}{1}} \]
      10. distribute-neg-frac98.4%

        \[\leadsto 1 \cdot \frac{x}{z} + \color{blue}{\left(-\frac{x}{1}\right)} \]
      11. /-rgt-identity98.4%

        \[\leadsto 1 \cdot \frac{x}{z} + \left(-\color{blue}{x}\right) \]
      12. *-lft-identity98.4%

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

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

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

    if 6.49999999999999947e148 < y < 3.59999999999999991e176

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-1 \cdot x} \]
    3. Step-by-step derivation
      1. mul-1-neg100.0%

        \[\leadsto \color{blue}{-x} \]
    4. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6800000:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+51}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+148} \lor \neg \left(y \leq 3.6 \cdot 10^{+176}\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 4: 84.3% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{\frac{z}{x}}\\ \mathbf{if}\;y \leq -14500000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+51}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{elif}\;y \leq 10^{+146} \lor \neg \left(y \leq 3.6 \cdot 10^{+176}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ y (/ z x))))
   (if (<= y -14500000.0)
     t_0
     (if (<= y 1.05e+51)
       (- (/ x z) x)
       (if (or (<= y 1e+146) (not (<= y 3.6e+176))) t_0 (- x))))))
double code(double x, double y, double z) {
	double t_0 = y / (z / x);
	double tmp;
	if (y <= -14500000.0) {
		tmp = t_0;
	} else if (y <= 1.05e+51) {
		tmp = (x / z) - x;
	} else if ((y <= 1e+146) || !(y <= 3.6e+176)) {
		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 / (z / x)
    if (y <= (-14500000.0d0)) then
        tmp = t_0
    else if (y <= 1.05d+51) then
        tmp = (x / z) - x
    else if ((y <= 1d+146) .or. (.not. (y <= 3.6d+176))) 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 / (z / x);
	double tmp;
	if (y <= -14500000.0) {
		tmp = t_0;
	} else if (y <= 1.05e+51) {
		tmp = (x / z) - x;
	} else if ((y <= 1e+146) || !(y <= 3.6e+176)) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y / (z / x)
	tmp = 0
	if y <= -14500000.0:
		tmp = t_0
	elif y <= 1.05e+51:
		tmp = (x / z) - x
	elif (y <= 1e+146) or not (y <= 3.6e+176):
		tmp = t_0
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(y / Float64(z / x))
	tmp = 0.0
	if (y <= -14500000.0)
		tmp = t_0;
	elseif (y <= 1.05e+51)
		tmp = Float64(Float64(x / z) - x);
	elseif ((y <= 1e+146) || !(y <= 3.6e+176))
		tmp = t_0;
	else
		tmp = Float64(-x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y / (z / x);
	tmp = 0.0;
	if (y <= -14500000.0)
		tmp = t_0;
	elseif (y <= 1.05e+51)
		tmp = (x / z) - x;
	elseif ((y <= 1e+146) || ~((y <= 3.6e+176)))
		tmp = t_0;
	else
		tmp = -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -14500000.0], t$95$0, If[LessEqual[y, 1.05e+51], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], If[Or[LessEqual[y, 1e+146], N[Not[LessEqual[y, 3.6e+176]], $MachinePrecision]], t$95$0, (-x)]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq 10^{+146} \lor \neg \left(y \leq 3.6 \cdot 10^{+176}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.45e7 or 1.0500000000000001e51 < y < 9.99999999999999934e145 or 3.59999999999999991e176 < y

    1. Initial program 92.7%

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

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
    4. Simplified74.6%

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

    if -1.45e7 < y < 1.0500000000000001e51

    1. Initial program 84.7%

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 - z}}} \]
    5. Taylor expanded in x around 0 83.0%

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

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

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

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

        \[\leadsto 1 \cdot \frac{x}{z} + \color{blue}{\frac{\left(-z\right) \cdot x}{z}} \]
      5. distribute-lft-neg-out83.0%

        \[\leadsto 1 \cdot \frac{x}{z} + \frac{\color{blue}{-z \cdot x}}{z} \]
      6. *-commutative83.0%

        \[\leadsto 1 \cdot \frac{x}{z} + \frac{-\color{blue}{x \cdot z}}{z} \]
      7. distribute-lft-neg-in83.0%

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

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

        \[\leadsto 1 \cdot \frac{x}{z} + \frac{-x}{\color{blue}{1}} \]
      10. distribute-neg-frac98.4%

        \[\leadsto 1 \cdot \frac{x}{z} + \color{blue}{\left(-\frac{x}{1}\right)} \]
      11. /-rgt-identity98.4%

        \[\leadsto 1 \cdot \frac{x}{z} + \left(-\color{blue}{x}\right) \]
      12. *-lft-identity98.4%

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

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

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

    if 9.99999999999999934e145 < y < 3.59999999999999991e176

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-1 \cdot x} \]
    3. Step-by-step derivation
      1. mul-1-neg100.0%

        \[\leadsto \color{blue}{-x} \]
    4. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -14500000:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+51}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{elif}\;y \leq 10^{+146} \lor \neg \left(y \leq 3.6 \cdot 10^{+176}\right):\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 5: 84.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot y}{z}\\ \mathbf{if}\;y \leq -14000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 6.3 \cdot 10^{+50}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{elif}\;y \leq 6 \cdot 10^{+149} \lor \neg \left(y \leq 3.6 \cdot 10^{+176}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* x y) z)))
   (if (<= y -14000000.0)
     t_0
     (if (<= y 6.3e+50)
       (- (/ x z) x)
       (if (or (<= y 6e+149) (not (<= y 3.6e+176))) t_0 (- x))))))
double code(double x, double y, double z) {
	double t_0 = (x * y) / z;
	double tmp;
	if (y <= -14000000.0) {
		tmp = t_0;
	} else if (y <= 6.3e+50) {
		tmp = (x / z) - x;
	} else if ((y <= 6e+149) || !(y <= 3.6e+176)) {
		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 (y <= (-14000000.0d0)) then
        tmp = t_0
    else if (y <= 6.3d+50) then
        tmp = (x / z) - x
    else if ((y <= 6d+149) .or. (.not. (y <= 3.6d+176))) 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 (y <= -14000000.0) {
		tmp = t_0;
	} else if (y <= 6.3e+50) {
		tmp = (x / z) - x;
	} else if ((y <= 6e+149) || !(y <= 3.6e+176)) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x * y) / z
	tmp = 0
	if y <= -14000000.0:
		tmp = t_0
	elif y <= 6.3e+50:
		tmp = (x / z) - x
	elif (y <= 6e+149) or not (y <= 3.6e+176):
		tmp = t_0
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(x * y) / z)
	tmp = 0.0
	if (y <= -14000000.0)
		tmp = t_0;
	elseif (y <= 6.3e+50)
		tmp = Float64(Float64(x / z) - x);
	elseif ((y <= 6e+149) || !(y <= 3.6e+176))
		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 (y <= -14000000.0)
		tmp = t_0;
	elseif (y <= 6.3e+50)
		tmp = (x / z) - x;
	elseif ((y <= 6e+149) || ~((y <= 3.6e+176)))
		tmp = t_0;
	else
		tmp = -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[y, -14000000.0], t$95$0, If[LessEqual[y, 6.3e+50], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], If[Or[LessEqual[y, 6e+149], N[Not[LessEqual[y, 3.6e+176]], $MachinePrecision]], t$95$0, (-x)]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq 6 \cdot 10^{+149} \lor \neg \left(y \leq 3.6 \cdot 10^{+176}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.4e7 or 6.29999999999999986e50 < y < 6.00000000000000007e149 or 3.59999999999999991e176 < y

    1. Initial program 92.7%

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

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

    if -1.4e7 < y < 6.29999999999999986e50

    1. Initial program 84.7%

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 - z}}} \]
    5. Taylor expanded in x around 0 83.0%

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

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

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

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

        \[\leadsto 1 \cdot \frac{x}{z} + \color{blue}{\frac{\left(-z\right) \cdot x}{z}} \]
      5. distribute-lft-neg-out83.0%

        \[\leadsto 1 \cdot \frac{x}{z} + \frac{\color{blue}{-z \cdot x}}{z} \]
      6. *-commutative83.0%

        \[\leadsto 1 \cdot \frac{x}{z} + \frac{-\color{blue}{x \cdot z}}{z} \]
      7. distribute-lft-neg-in83.0%

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

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

        \[\leadsto 1 \cdot \frac{x}{z} + \frac{-x}{\color{blue}{1}} \]
      10. distribute-neg-frac98.4%

        \[\leadsto 1 \cdot \frac{x}{z} + \color{blue}{\left(-\frac{x}{1}\right)} \]
      11. /-rgt-identity98.4%

        \[\leadsto 1 \cdot \frac{x}{z} + \left(-\color{blue}{x}\right) \]
      12. *-lft-identity98.4%

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

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

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

    if 6.00000000000000007e149 < y < 3.59999999999999991e176

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-1 \cdot x} \]
    3. Step-by-step derivation
      1. mul-1-neg100.0%

        \[\leadsto \color{blue}{-x} \]
    4. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -14000000:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;y \leq 6.3 \cdot 10^{+50}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{elif}\;y \leq 6 \cdot 10^{+149} \lor \neg \left(y \leq 3.6 \cdot 10^{+176}\right):\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 6: 86.4% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 73.6%

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

      \[\leadsto \color{blue}{-1 \cdot x} \]
    3. Step-by-step derivation
      1. mul-1-neg84.1%

        \[\leadsto \color{blue}{-x} \]
    4. Simplified84.1%

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

    if -1.12e67 < z < 7.7000000000000004e-7

    1. Initial program 100.0%

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

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

    if 7.7000000000000004e-7 < z

    1. Initial program 75.8%

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 - z}}} \]
    4. Simplified83.6%

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 - z}}} \]
    5. Taylor expanded in x around 0 59.4%

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

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

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

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

        \[\leadsto 1 \cdot \frac{x}{z} + \color{blue}{\frac{\left(-z\right) \cdot x}{z}} \]
      5. distribute-lft-neg-out59.5%

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

        \[\leadsto 1 \cdot \frac{x}{z} + \frac{-\color{blue}{x \cdot z}}{z} \]
      7. distribute-lft-neg-in59.5%

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

        \[\leadsto 1 \cdot \frac{x}{z} + \color{blue}{\frac{-x}{\frac{z}{z}}} \]
      9. *-inverses83.6%

        \[\leadsto 1 \cdot \frac{x}{z} + \frac{-x}{\color{blue}{1}} \]
      10. distribute-neg-frac83.6%

        \[\leadsto 1 \cdot \frac{x}{z} + \color{blue}{\left(-\frac{x}{1}\right)} \]
      11. /-rgt-identity83.6%

        \[\leadsto 1 \cdot \frac{x}{z} + \left(-\color{blue}{x}\right) \]
      12. *-lft-identity83.6%

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

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

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

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

Alternative 7: 65.5% accurate, 1.3× speedup?

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

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

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


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

    1. Initial program 76.5%

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

      \[\leadsto \color{blue}{-1 \cdot x} \]
    3. Step-by-step derivation
      1. mul-1-neg78.8%

        \[\leadsto \color{blue}{-x} \]
    4. Simplified78.8%

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

    if -1 < z < 1

    1. Initial program 100.0%

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

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

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

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

Alternative 8: 39.0% accurate, 4.5× speedup?

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

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

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

    \[\leadsto \color{blue}{-1 \cdot x} \]
  3. Step-by-step derivation
    1. mul-1-neg41.1%

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

    \[\leadsto \color{blue}{-x} \]
  5. Final simplification41.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 2023310 
(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))