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

Percentage Accurate: 87.4% → 96.3%
Time: 5.3s
Alternatives: 7
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 7 alternatives:

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

Initial Program: 87.4% 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.3% 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 87.4%

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

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

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

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

Alternative 2: 64.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -4.1 \cdot 10^{+73}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{-44}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-208}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{-270}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.06 \cdot 10^{-191}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-65}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= z -4.1e+73)
     (- x)
     (if (<= z -1.25e-44)
       t_0
       (if (<= z -3e-208)
         (/ x z)
         (if (<= z -5.8e-270)
           t_0
           (if (<= z 1.06e-191)
             (/ x z)
             (if (<= z 6.2e-65) t_0 (if (<= z 1.0) (/ x z) (- x))))))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -4.1e+73) {
		tmp = -x;
	} else if (z <= -1.25e-44) {
		tmp = t_0;
	} else if (z <= -3e-208) {
		tmp = x / z;
	} else if (z <= -5.8e-270) {
		tmp = t_0;
	} else if (z <= 1.06e-191) {
		tmp = x / z;
	} else if (z <= 6.2e-65) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = y * (x / z)
    if (z <= (-4.1d+73)) then
        tmp = -x
    else if (z <= (-1.25d-44)) then
        tmp = t_0
    else if (z <= (-3d-208)) then
        tmp = x / z
    else if (z <= (-5.8d-270)) then
        tmp = t_0
    else if (z <= 1.06d-191) then
        tmp = x / z
    else if (z <= 6.2d-65) then
        tmp = t_0
    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 t_0 = y * (x / z);
	double tmp;
	if (z <= -4.1e+73) {
		tmp = -x;
	} else if (z <= -1.25e-44) {
		tmp = t_0;
	} else if (z <= -3e-208) {
		tmp = x / z;
	} else if (z <= -5.8e-270) {
		tmp = t_0;
	} else if (z <= 1.06e-191) {
		tmp = x / z;
	} else if (z <= 6.2e-65) {
		tmp = t_0;
	} else if (z <= 1.0) {
		tmp = x / z;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if z <= -4.1e+73:
		tmp = -x
	elif z <= -1.25e-44:
		tmp = t_0
	elif z <= -3e-208:
		tmp = x / z
	elif z <= -5.8e-270:
		tmp = t_0
	elif z <= 1.06e-191:
		tmp = x / z
	elif z <= 6.2e-65:
		tmp = t_0
	elif z <= 1.0:
		tmp = x / z
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(x / z))
	tmp = 0.0
	if (z <= -4.1e+73)
		tmp = Float64(-x);
	elseif (z <= -1.25e-44)
		tmp = t_0;
	elseif (z <= -3e-208)
		tmp = Float64(x / z);
	elseif (z <= -5.8e-270)
		tmp = t_0;
	elseif (z <= 1.06e-191)
		tmp = Float64(x / z);
	elseif (z <= 6.2e-65)
		tmp = t_0;
	elseif (z <= 1.0)
		tmp = Float64(x / z);
	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 <= -4.1e+73)
		tmp = -x;
	elseif (z <= -1.25e-44)
		tmp = t_0;
	elseif (z <= -3e-208)
		tmp = x / z;
	elseif (z <= -5.8e-270)
		tmp = t_0;
	elseif (z <= 1.06e-191)
		tmp = x / z;
	elseif (z <= 6.2e-65)
		tmp = t_0;
	elseif (z <= 1.0)
		tmp = x / z;
	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, -4.1e+73], (-x), If[LessEqual[z, -1.25e-44], t$95$0, If[LessEqual[z, -3e-208], N[(x / z), $MachinePrecision], If[LessEqual[z, -5.8e-270], t$95$0, If[LessEqual[z, 1.06e-191], N[(x / z), $MachinePrecision], If[LessEqual[z, 6.2e-65], t$95$0, If[LessEqual[z, 1.0], N[(x / z), $MachinePrecision], (-x)]]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;z \leq -3 \cdot 10^{-208}:\\
\;\;\;\;\frac{x}{z}\\

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

\mathbf{elif}\;z \leq 1.06 \cdot 10^{-191}:\\
\;\;\;\;\frac{x}{z}\\

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

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

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


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

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

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

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

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

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

    if -4.0999999999999998e73 < z < -1.2500000000000001e-44 or -2.99999999999999986e-208 < z < -5.79999999999999965e-270 or 1.05999999999999994e-191 < z < 6.20000000000000032e-65

    1. Initial program 96.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
    6. Simplified64.1%

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

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

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

    if -1.2500000000000001e-44 < z < -2.99999999999999986e-208 or -5.79999999999999965e-270 < z < 1.05999999999999994e-191 or 6.20000000000000032e-65 < z < 1

    1. Initial program 99.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.1 \cdot 10^{+73}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{-44}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-208}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{-270}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 1.06 \cdot 10^{-191}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-65}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 3: 64.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -1.7 \cdot 10^{+74}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{-43}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{-208}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-270}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-191}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-65}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= z -1.7e+74)
     (- x)
     (if (<= z -5.8e-43)
       (* x (/ y z))
       (if (<= z -1.25e-208)
         (/ x z)
         (if (<= z -3.6e-270)
           t_0
           (if (<= z 4.8e-191)
             (/ x z)
             (if (<= z 4e-65) t_0 (if (<= z 1.0) (/ x z) (- x))))))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -1.7e+74) {
		tmp = -x;
	} else if (z <= -5.8e-43) {
		tmp = x * (y / z);
	} else if (z <= -1.25e-208) {
		tmp = x / z;
	} else if (z <= -3.6e-270) {
		tmp = t_0;
	} else if (z <= 4.8e-191) {
		tmp = x / z;
	} else if (z <= 4e-65) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = y * (x / z)
    if (z <= (-1.7d+74)) then
        tmp = -x
    else if (z <= (-5.8d-43)) then
        tmp = x * (y / z)
    else if (z <= (-1.25d-208)) then
        tmp = x / z
    else if (z <= (-3.6d-270)) then
        tmp = t_0
    else if (z <= 4.8d-191) then
        tmp = x / z
    else if (z <= 4d-65) then
        tmp = t_0
    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 t_0 = y * (x / z);
	double tmp;
	if (z <= -1.7e+74) {
		tmp = -x;
	} else if (z <= -5.8e-43) {
		tmp = x * (y / z);
	} else if (z <= -1.25e-208) {
		tmp = x / z;
	} else if (z <= -3.6e-270) {
		tmp = t_0;
	} else if (z <= 4.8e-191) {
		tmp = x / z;
	} else if (z <= 4e-65) {
		tmp = t_0;
	} else if (z <= 1.0) {
		tmp = x / z;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if z <= -1.7e+74:
		tmp = -x
	elif z <= -5.8e-43:
		tmp = x * (y / z)
	elif z <= -1.25e-208:
		tmp = x / z
	elif z <= -3.6e-270:
		tmp = t_0
	elif z <= 4.8e-191:
		tmp = x / z
	elif z <= 4e-65:
		tmp = t_0
	elif z <= 1.0:
		tmp = x / z
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(x / z))
	tmp = 0.0
	if (z <= -1.7e+74)
		tmp = Float64(-x);
	elseif (z <= -5.8e-43)
		tmp = Float64(x * Float64(y / z));
	elseif (z <= -1.25e-208)
		tmp = Float64(x / z);
	elseif (z <= -3.6e-270)
		tmp = t_0;
	elseif (z <= 4.8e-191)
		tmp = Float64(x / z);
	elseif (z <= 4e-65)
		tmp = t_0;
	elseif (z <= 1.0)
		tmp = Float64(x / z);
	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.7e+74)
		tmp = -x;
	elseif (z <= -5.8e-43)
		tmp = x * (y / z);
	elseif (z <= -1.25e-208)
		tmp = x / z;
	elseif (z <= -3.6e-270)
		tmp = t_0;
	elseif (z <= 4.8e-191)
		tmp = x / z;
	elseif (z <= 4e-65)
		tmp = t_0;
	elseif (z <= 1.0)
		tmp = x / z;
	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.7e+74], (-x), If[LessEqual[z, -5.8e-43], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -1.25e-208], N[(x / z), $MachinePrecision], If[LessEqual[z, -3.6e-270], t$95$0, If[LessEqual[z, 4.8e-191], N[(x / z), $MachinePrecision], If[LessEqual[z, 4e-65], t$95$0, If[LessEqual[z, 1.0], N[(x / z), $MachinePrecision], (-x)]]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;z \leq -1.25 \cdot 10^{-208}:\\
\;\;\;\;\frac{x}{z}\\

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

\mathbf{elif}\;z \leq 4.8 \cdot 10^{-191}:\\
\;\;\;\;\frac{x}{z}\\

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

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

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


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

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

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

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

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

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

    if -1.7e74 < z < -5.8000000000000003e-43

    1. Initial program 89.5%

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

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

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

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

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

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

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

    if -5.8000000000000003e-43 < z < -1.24999999999999991e-208 or -3.5999999999999998e-270 < z < 4.7999999999999998e-191 or 3.99999999999999969e-65 < z < 1

    1. Initial program 99.9%

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

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

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

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

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

    if -1.24999999999999991e-208 < z < -3.5999999999999998e-270 or 4.7999999999999998e-191 < z < 3.99999999999999969e-65

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.7 \cdot 10^{+74}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{-43}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{-208}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-270}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-191}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-65}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 4: 85.2% accurate, 1.0× speedup?

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

    1. Initial program 86.1%

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

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

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

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

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

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

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

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

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

    if -7.5e19 < y < 5.7999999999999997e69

    1. Initial program 88.4%

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

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

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

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

        \[\leadsto \frac{\color{blue}{x \cdot 1 + x \cdot \left(-z\right)}}{z} \]
      4. *-rgt-identity84.2%

        \[\leadsto \frac{\color{blue}{x} + x \cdot \left(-z\right)}{z} \]
      5. distribute-rgt-neg-in84.2%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{x \cdot 1 + x \cdot \left(-z\right)}}{z} \]
      4. *-rgt-identity84.2%

        \[\leadsto \frac{\color{blue}{x} + x \cdot \left(-z\right)}{z} \]
      5. distribute-rgt-neg-out84.2%

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

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

        \[\leadsto \color{blue}{\frac{x}{z} - \frac{x \cdot z}{z}} \]
      8. associate-*l/79.7%

        \[\leadsto \frac{x}{z} - \color{blue}{\frac{x}{z} \cdot z} \]
      9. associate-/r/95.7%

        \[\leadsto \frac{x}{z} - \color{blue}{\frac{x}{\frac{z}{z}}} \]
      10. *-inverses95.7%

        \[\leadsto \frac{x}{z} - \frac{x}{\color{blue}{1}} \]
      11. /-rgt-identity95.7%

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

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

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

Alternative 5: 85.1% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 81.0%

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

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

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

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

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

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

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

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

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

    if -5.8e20 < y < 5.50000000000000002e69

    1. Initial program 88.4%

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

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

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

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

        \[\leadsto \frac{\color{blue}{x \cdot 1 + x \cdot \left(-z\right)}}{z} \]
      4. *-rgt-identity84.2%

        \[\leadsto \frac{\color{blue}{x} + x \cdot \left(-z\right)}{z} \]
      5. distribute-rgt-neg-in84.2%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{x \cdot 1 + x \cdot \left(-z\right)}}{z} \]
      4. *-rgt-identity84.2%

        \[\leadsto \frac{\color{blue}{x} + x \cdot \left(-z\right)}{z} \]
      5. distribute-rgt-neg-out84.2%

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

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

        \[\leadsto \color{blue}{\frac{x}{z} - \frac{x \cdot z}{z}} \]
      8. associate-*l/79.7%

        \[\leadsto \frac{x}{z} - \color{blue}{\frac{x}{z} \cdot z} \]
      9. associate-/r/95.7%

        \[\leadsto \frac{x}{z} - \color{blue}{\frac{x}{\frac{z}{z}}} \]
      10. *-inverses95.7%

        \[\leadsto \frac{x}{z} - \frac{x}{\color{blue}{1}} \]
      11. /-rgt-identity95.7%

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

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

    if 5.50000000000000002e69 < y

    1. Initial program 91.2%

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
    6. Simplified81.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.8 \cdot 10^{+20}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{+69}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]

Alternative 6: 64.3% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0016:\\
\;\;\;\;-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 < -0.00160000000000000008 or 1 < z

    1. Initial program 76.1%

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

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

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

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

        \[\leadsto \color{blue}{-x} \]
    6. Simplified70.3%

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

    if -0.00160000000000000008 < z < 1

    1. Initial program 99.9%

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

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

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

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

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

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

Alternative 7: 38.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 87.4%

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

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

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

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

      \[\leadsto \color{blue}{-x} \]
  6. Simplified38.3%

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

    \[\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 2023174 
(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))