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

Percentage Accurate: 88.4% → 98.8%
Time: 5.6s
Alternatives: 10
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 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.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: 98.8% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 81.2%

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

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

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

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

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

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

    if -4.2e5 < z < 1

    1. Initial program 99.9%

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

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

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

Alternative 2: 65.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -200000000:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{-66}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-195}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-180}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-73}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{+16}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= z -200000000.0)
     (- x)
     (if (<= z -1.65e-66)
       t_0
       (if (<= z 8.5e-195)
         (/ x z)
         (if (<= z 2.8e-180)
           t_0
           (if (<= z 2.8e-73) (/ x z) (if (<= z 4.2e+16) t_0 (- x)))))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -200000000.0) {
		tmp = -x;
	} else if (z <= -1.65e-66) {
		tmp = t_0;
	} else if (z <= 8.5e-195) {
		tmp = x / z;
	} else if (z <= 2.8e-180) {
		tmp = t_0;
	} else if (z <= 2.8e-73) {
		tmp = x / z;
	} else if (z <= 4.2e+16) {
		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 <= (-200000000.0d0)) then
        tmp = -x
    else if (z <= (-1.65d-66)) then
        tmp = t_0
    else if (z <= 8.5d-195) then
        tmp = x / z
    else if (z <= 2.8d-180) then
        tmp = t_0
    else if (z <= 2.8d-73) then
        tmp = x / z
    else if (z <= 4.2d+16) 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 <= -200000000.0) {
		tmp = -x;
	} else if (z <= -1.65e-66) {
		tmp = t_0;
	} else if (z <= 8.5e-195) {
		tmp = x / z;
	} else if (z <= 2.8e-180) {
		tmp = t_0;
	} else if (z <= 2.8e-73) {
		tmp = x / z;
	} else if (z <= 4.2e+16) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if z <= -200000000.0:
		tmp = -x
	elif z <= -1.65e-66:
		tmp = t_0
	elif z <= 8.5e-195:
		tmp = x / z
	elif z <= 2.8e-180:
		tmp = t_0
	elif z <= 2.8e-73:
		tmp = x / z
	elif z <= 4.2e+16:
		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 <= -200000000.0)
		tmp = Float64(-x);
	elseif (z <= -1.65e-66)
		tmp = t_0;
	elseif (z <= 8.5e-195)
		tmp = Float64(x / z);
	elseif (z <= 2.8e-180)
		tmp = t_0;
	elseif (z <= 2.8e-73)
		tmp = Float64(x / z);
	elseif (z <= 4.2e+16)
		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 <= -200000000.0)
		tmp = -x;
	elseif (z <= -1.65e-66)
		tmp = t_0;
	elseif (z <= 8.5e-195)
		tmp = x / z;
	elseif (z <= 2.8e-180)
		tmp = t_0;
	elseif (z <= 2.8e-73)
		tmp = x / z;
	elseif (z <= 4.2e+16)
		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, -200000000.0], (-x), If[LessEqual[z, -1.65e-66], t$95$0, If[LessEqual[z, 8.5e-195], N[(x / z), $MachinePrecision], If[LessEqual[z, 2.8e-180], t$95$0, If[LessEqual[z, 2.8e-73], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.2e+16], t$95$0, (-x)]]]]]]]
\begin{array}{l}

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

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

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

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

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

\mathbf{elif}\;z \leq 4.2 \cdot 10^{+16}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 81.0%

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

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

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

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

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

    if -2e8 < z < -1.6499999999999999e-66 or 8.50000000000000023e-195 < z < 2.79999999999999997e-180 or 2.80000000000000012e-73 < z < 4.2e16

    1. Initial program 99.7%

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

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

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

        \[\leadsto \color{blue}{y \cdot \frac{1}{\frac{z}{x}}} \]
      3. clear-num76.9%

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

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

    if -1.6499999999999999e-66 < z < 8.50000000000000023e-195 or 2.79999999999999997e-180 < z < 2.80000000000000012e-73

    1. Initial program 100.0%

      \[\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 76.8%

      \[\leadsto \color{blue}{\frac{x}{z}} - x \]
    4. Taylor expanded in z around 0 76.8%

      \[\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 -200000000:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{-66}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-195}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-180}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-73}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{+16}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 3: 94.1% accurate, 0.8× speedup?

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

    1. Initial program 90.8%

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

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

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

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

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

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

    if -4.00000000000000036e25 < y < 4.7e-7

    1. Initial program 92.0%

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

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

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

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

Alternative 4: 95.9% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.00000000000000036e25 or 4.7e-7 < y

    1. Initial program 90.8%

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

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

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

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

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

    if -4.00000000000000036e25 < y < 4.7e-7

    1. Initial program 92.0%

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

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

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

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

Alternative 5: 85.2% accurate, 1.0× speedup?

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

    1. Initial program 91.4%

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
      2. div-inv80.5%

        \[\leadsto \color{blue}{y \cdot \frac{1}{\frac{z}{x}}} \]
      3. clear-num80.5%

        \[\leadsto y \cdot \color{blue}{\frac{x}{z}} \]
    4. Applied egg-rr80.5%

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

    if -4.29999999999999998e25 < y < 1.32e95

    1. Initial program 91.4%

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

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

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

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

Alternative 6: 85.2% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;y \leq 7.5 \cdot 10^{+92}:\\
\;\;\;\;\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 < -1.04999999999999997e27

    1. Initial program 94.4%

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
      2. div-inv85.5%

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

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

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

    if -1.04999999999999997e27 < y < 7.49999999999999946e92

    1. Initial program 91.4%

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

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

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

    if 7.49999999999999946e92 < y

    1. Initial program 88.1%

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
      2. div-inv74.9%

        \[\leadsto \color{blue}{y \cdot \frac{1}{\frac{z}{x}}} \]
      3. clear-num74.8%

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

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
    7. Simplified75.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.05 \cdot 10^{+27}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{+92}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]

Alternative 7: 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 91.4%

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

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

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

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

Alternative 8: 64.8% accurate, 1.3× speedup?

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

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

    1. Initial program 81.2%

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

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

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

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

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

    if -4.2e5 < z < 1

    1. Initial program 99.9%

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

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

      \[\leadsto \color{blue}{\frac{x}{z}} - x \]
    4. Taylor expanded in z around 0 63.8%

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

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

Alternative 9: 38.5% accurate, 4.5× speedup?

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

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

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

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

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

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

    \[\leadsto \color{blue}{-x} \]
  6. Final simplification35.2%

    \[\leadsto -x \]

Alternative 10: 3.0% accurate, 9.0× speedup?

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\left(-z\right) \cdot x}}{z} \]
  5. Step-by-step derivation
    1. add-log-exp15.2%

      \[\leadsto \color{blue}{\log \left(e^{\frac{\left(-z\right) \cdot x}{z}}\right)} \]
    2. *-un-lft-identity15.2%

      \[\leadsto \log \color{blue}{\left(1 \cdot e^{\frac{\left(-z\right) \cdot x}{z}}\right)} \]
    3. log-prod15.2%

      \[\leadsto \color{blue}{\log 1 + \log \left(e^{\frac{\left(-z\right) \cdot x}{z}}\right)} \]
    4. metadata-eval15.2%

      \[\leadsto \color{blue}{0} + \log \left(e^{\frac{\left(-z\right) \cdot x}{z}}\right) \]
    5. add-log-exp29.3%

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

      \[\leadsto 0 + \color{blue}{\frac{-z}{\frac{z}{x}}} \]
    7. div-inv36.6%

      \[\leadsto 0 + \color{blue}{\left(-z\right) \cdot \frac{1}{\frac{z}{x}}} \]
    8. add-sqr-sqrt21.9%

      \[\leadsto 0 + \color{blue}{\left(\sqrt{-z} \cdot \sqrt{-z}\right)} \cdot \frac{1}{\frac{z}{x}} \]
    9. sqrt-unprod14.9%

      \[\leadsto 0 + \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}} \cdot \frac{1}{\frac{z}{x}} \]
    10. sqr-neg14.9%

      \[\leadsto 0 + \sqrt{\color{blue}{z \cdot z}} \cdot \frac{1}{\frac{z}{x}} \]
    11. sqrt-unprod8.6%

      \[\leadsto 0 + \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)} \cdot \frac{1}{\frac{z}{x}} \]
    12. add-sqr-sqrt10.5%

      \[\leadsto 0 + \color{blue}{z} \cdot \frac{1}{\frac{z}{x}} \]
    13. clear-num10.5%

      \[\leadsto 0 + z \cdot \color{blue}{\frac{x}{z}} \]
  6. Applied egg-rr10.5%

    \[\leadsto \color{blue}{0 + z \cdot \frac{x}{z}} \]
  7. Step-by-step derivation
    1. +-lft-identity10.5%

      \[\leadsto \color{blue}{z \cdot \frac{x}{z}} \]
    2. associate-*r/4.3%

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

      \[\leadsto \color{blue}{\frac{z}{z} \cdot x} \]
    4. *-inverses3.3%

      \[\leadsto \color{blue}{1} \cdot x \]
    5. *-lft-identity3.3%

      \[\leadsto \color{blue}{x} \]
  8. Simplified3.3%

    \[\leadsto \color{blue}{x} \]
  9. Final simplification3.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 2023200 
(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))