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

Percentage Accurate: 88.1% → 99.5%
Time: 5.2s
Alternatives: 10
Speedup: 0.8×

Specification

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

\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 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.1% 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.5% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 73.5%

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

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

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

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

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

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

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

    if -6.0000000000000001e85 < z < 0.10000000000000001

    1. Initial program 99.2%

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

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

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

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

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

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

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

    if 0.10000000000000001 < z

    1. Initial program 83.3%

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

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

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

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

Alternative 2: 96.0% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \frac{\mathsf{fma}\left(x, y, x\right)}{z} - x \end{array} \]
(FPCore (x y z) :precision binary64 (- (/ (fma x y x) z) x))
double code(double x, double y, double z) {
	return (fma(x, y, x) / z) - x;
}
function code(x, y, z)
	return Float64(Float64(fma(x, y, x) / z) - x)
end
code[x_, y_, z_] := N[(N[(N[(x * y + x), $MachinePrecision] / z), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}

\\
\frac{\mathsf{fma}\left(x, y, x\right)}{z} - x
\end{array}
Derivation
  1. Initial program 90.3%

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, y, x\right)}{z} - x} \]
  3. Final simplification97.4%

    \[\leadsto \frac{\mathsf{fma}\left(x, y, x\right)}{z} - x \]

Alternative 3: 64.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -1.7 \cdot 10^{+41}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -9.8 \cdot 10^{-163}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{-264}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{+72}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= z -1.7e+41)
     (- x)
     (if (<= z -9.8e-163)
       t_0
       (if (<= z 3.5e-264) (/ x z) (if (<= z 1.3e+72) t_0 (- x)))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -1.7e+41) {
		tmp = -x;
	} else if (z <= -9.8e-163) {
		tmp = t_0;
	} else if (z <= 3.5e-264) {
		tmp = x / z;
	} else if (z <= 1.3e+72) {
		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.7d+41)) then
        tmp = -x
    else if (z <= (-9.8d-163)) then
        tmp = t_0
    else if (z <= 3.5d-264) then
        tmp = x / z
    else if (z <= 1.3d+72) 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.7e+41) {
		tmp = -x;
	} else if (z <= -9.8e-163) {
		tmp = t_0;
	} else if (z <= 3.5e-264) {
		tmp = x / z;
	} else if (z <= 1.3e+72) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if z <= -1.7e+41:
		tmp = -x
	elif z <= -9.8e-163:
		tmp = t_0
	elif z <= 3.5e-264:
		tmp = x / z
	elif z <= 1.3e+72:
		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.7e+41)
		tmp = Float64(-x);
	elseif (z <= -9.8e-163)
		tmp = t_0;
	elseif (z <= 3.5e-264)
		tmp = Float64(x / z);
	elseif (z <= 1.3e+72)
		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.7e+41)
		tmp = -x;
	elseif (z <= -9.8e-163)
		tmp = t_0;
	elseif (z <= 3.5e-264)
		tmp = x / z;
	elseif (z <= 1.3e+72)
		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.7e+41], (-x), If[LessEqual[z, -9.8e-163], t$95$0, If[LessEqual[z, 3.5e-264], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.3e+72], t$95$0, (-x)]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;z \leq 3.5 \cdot 10^{-264}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 1.3 \cdot 10^{+72}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.69999999999999999e41 or 1.29999999999999991e72 < z

    1. Initial program 79.2%

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

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

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

        \[\leadsto \color{blue}{-x} \]
    5. Simplified82.4%

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

    if -1.69999999999999999e41 < z < -9.8000000000000005e-163 or 3.5e-264 < z < 1.29999999999999991e72

    1. Initial program 97.9%

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{\left(y - z\right) + 1}}} \]
    4. Step-by-step derivation
      1. associate-/r/98.0%

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

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

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

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

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

    if -9.8000000000000005e-163 < z < 3.5e-264

    1. Initial program 100.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.7 \cdot 10^{+41}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -9.8 \cdot 10^{-163}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{-264}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{+72}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 4: 99.5% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 78.6%

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

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

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

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

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

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

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

    if -5.50000000000000008e85 < z < 1.26e14

    1. Initial program 99.2%

      \[\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. Step-by-step derivation
      1. associate-/r/99.9%

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

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

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

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

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

Alternative 5: 95.0% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.45e10 or 2.0000000000000001e-4 < y

    1. Initial program 90.0%

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

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

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

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

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

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

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

    if -2.45e10 < y < 2.0000000000000001e-4

    1. Initial program 90.7%

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

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

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

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

Alternative 6: 98.8% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 81.9%

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

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

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

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

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

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

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

    if -1 < z < 0.92000000000000004

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

Alternative 7: 85.1% accurate, 1.0× speedup?

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

    1. Initial program 91.7%

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{\left(y - z\right) + 1}}} \]
    4. Step-by-step derivation
      1. associate-/r/89.3%

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

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

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

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

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

    if -6.19999999999999986e32 < y < 1.9000000000000001e66

    1. Initial program 89.4%

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

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

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

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

Alternative 8: 85.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{+33} \lor \neg \left(y \leq 8.5 \cdot 10^{+60}\right):\\
\;\;\;\;\frac{x \cdot y}{z}\\

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


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

    1. Initial program 91.7%

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

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

    if -1.45000000000000012e33 < y < 8.50000000000000064e60

    1. Initial program 89.4%

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

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

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

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

Alternative 9: 65.1% accurate, 1.3× speedup?

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

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

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

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


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

    1. Initial program 82.0%

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

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

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

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

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

    if -4.80000000000000012e-4 < z < 0.92000000000000004

    1. Initial program 99.8%

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

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

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

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

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

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

Alternative 10: 38.7% 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 90.3%

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

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

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

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

    \[\leadsto \color{blue}{-x} \]
  6. Final simplification40.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 2023227 
(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))