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

Percentage Accurate: 87.9% → 98.4%
Time: 8.6s
Alternatives: 13
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 13 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.9% 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.4% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 78.2%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + y}}} - x \]
      5. associate-/r/94.2%

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

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

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

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

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

    if -1.35e19 < 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 98.6%

      \[\leadsto \frac{\color{blue}{x \cdot \left(1 + y\right)}}{z} \]
    3. Step-by-step derivation
      1. distribute-lft-in98.6%

        \[\leadsto \frac{\color{blue}{x \cdot 1 + x \cdot y}}{z} \]
      2. *-rgt-identity98.6%

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

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

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

Alternative 2: 60.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{z} \cdot y\\ \mathbf{if}\;y \leq -5.5 \cdot 10^{+39}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.85 \cdot 10^{-42}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -1.5 \cdot 10^{-76}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq -3.6 \cdot 10^{-143}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{-10}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+75}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (/ x z) y)))
   (if (<= y -5.5e+39)
     t_0
     (if (<= y -1.85e-42)
       (- x)
       (if (<= y -1.5e-76)
         (/ x z)
         (if (<= y -3.6e-143)
           (- x)
           (if (<= y 7.6e-10) (/ x z) (if (<= y 1.8e+75) (- x) t_0))))))))
double code(double x, double y, double z) {
	double t_0 = (x / z) * y;
	double tmp;
	if (y <= -5.5e+39) {
		tmp = t_0;
	} else if (y <= -1.85e-42) {
		tmp = -x;
	} else if (y <= -1.5e-76) {
		tmp = x / z;
	} else if (y <= -3.6e-143) {
		tmp = -x;
	} else if (y <= 7.6e-10) {
		tmp = x / z;
	} else if (y <= 1.8e+75) {
		tmp = -x;
	} 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 = (x / z) * y
    if (y <= (-5.5d+39)) then
        tmp = t_0
    else if (y <= (-1.85d-42)) then
        tmp = -x
    else if (y <= (-1.5d-76)) then
        tmp = x / z
    else if (y <= (-3.6d-143)) then
        tmp = -x
    else if (y <= 7.6d-10) then
        tmp = x / z
    else if (y <= 1.8d+75) then
        tmp = -x
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (x / z) * y;
	double tmp;
	if (y <= -5.5e+39) {
		tmp = t_0;
	} else if (y <= -1.85e-42) {
		tmp = -x;
	} else if (y <= -1.5e-76) {
		tmp = x / z;
	} else if (y <= -3.6e-143) {
		tmp = -x;
	} else if (y <= 7.6e-10) {
		tmp = x / z;
	} else if (y <= 1.8e+75) {
		tmp = -x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x / z) * y
	tmp = 0
	if y <= -5.5e+39:
		tmp = t_0
	elif y <= -1.85e-42:
		tmp = -x
	elif y <= -1.5e-76:
		tmp = x / z
	elif y <= -3.6e-143:
		tmp = -x
	elif y <= 7.6e-10:
		tmp = x / z
	elif y <= 1.8e+75:
		tmp = -x
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(x / z) * y)
	tmp = 0.0
	if (y <= -5.5e+39)
		tmp = t_0;
	elseif (y <= -1.85e-42)
		tmp = Float64(-x);
	elseif (y <= -1.5e-76)
		tmp = Float64(x / z);
	elseif (y <= -3.6e-143)
		tmp = Float64(-x);
	elseif (y <= 7.6e-10)
		tmp = Float64(x / z);
	elseif (y <= 1.8e+75)
		tmp = Float64(-x);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (x / z) * y;
	tmp = 0.0;
	if (y <= -5.5e+39)
		tmp = t_0;
	elseif (y <= -1.85e-42)
		tmp = -x;
	elseif (y <= -1.5e-76)
		tmp = x / z;
	elseif (y <= -3.6e-143)
		tmp = -x;
	elseif (y <= 7.6e-10)
		tmp = x / z;
	elseif (y <= 1.8e+75)
		tmp = -x;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -5.5e+39], t$95$0, If[LessEqual[y, -1.85e-42], (-x), If[LessEqual[y, -1.5e-76], N[(x / z), $MachinePrecision], If[LessEqual[y, -3.6e-143], (-x), If[LessEqual[y, 7.6e-10], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.8e+75], (-x), t$95$0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -1.85 \cdot 10^{-42}:\\
\;\;\;\;-x\\

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

\mathbf{elif}\;y \leq -3.6 \cdot 10^{-143}:\\
\;\;\;\;-x\\

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

\mathbf{elif}\;y \leq 1.8 \cdot 10^{+75}:\\
\;\;\;\;-x\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.4999999999999997e39 or 1.8e75 < y

    1. Initial program 94.2%

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

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

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

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

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

    if -5.4999999999999997e39 < y < -1.8500000000000001e-42 or -1.50000000000000012e-76 < y < -3.5999999999999998e-143 or 7.5999999999999996e-10 < y < 1.8e75

    1. Initial program 82.5%

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

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

        \[\leadsto \color{blue}{-x} \]
    4. Simplified70.9%

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

    if -1.8500000000000001e-42 < y < -1.50000000000000012e-76 or -3.5999999999999998e-143 < y < 7.5999999999999996e-10

    1. Initial program 89.0%

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

      \[\leadsto \frac{\color{blue}{x \cdot \left(1 + y\right)}}{z} \]
    3. Step-by-step derivation
      1. distribute-lft-in63.8%

        \[\leadsto \frac{\color{blue}{x \cdot 1 + x \cdot y}}{z} \]
      2. *-rgt-identity63.8%

        \[\leadsto \frac{\color{blue}{x} + x \cdot y}{z} \]
    4. Simplified63.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.5 \cdot 10^{+39}:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \mathbf{elif}\;y \leq -1.85 \cdot 10^{-42}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -1.5 \cdot 10^{-76}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq -3.6 \cdot 10^{-143}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{-10}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+75}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \end{array} \]

Alternative 3: 94.0% accurate, 0.7× speedup?

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

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

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

\mathbf{elif}\;y \leq 2.5 \cdot 10^{+137}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1 or 1 < y < 2.5000000000000001e137

    1. Initial program 90.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + y}}} - x \]
      5. associate-/r/97.2%

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

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

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

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

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

    if -1 < y < 1

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

    if 2.5000000000000001e137 < y

    1. Initial program 92.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x \cdot \frac{y}{z} - x\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{+137}:\\ \;\;\;\;x \cdot \frac{y}{z} - x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \end{array} \]

Alternative 4: 94.1% accurate, 0.7× speedup?

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

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

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

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

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


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

    1. Initial program 93.3%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + y}}} - x \]
      5. associate-/r/95.9%

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

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

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

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

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

    if -1 < y < 1

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

    if 1 < y < 2.5000000000000001e137

    1. Initial program 85.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + y}}} - x \]
      5. associate-/r/99.8%

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{y}{z}} - x \]
    7. Simplified97.3%

      \[\leadsto \color{blue}{x \cdot \frac{y}{z}} - x \]
    8. Step-by-step derivation
      1. clear-num97.4%

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

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

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

    if 2.5000000000000001e137 < y

    1. Initial program 92.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x \cdot \frac{y}{z} - x\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{+137}:\\ \;\;\;\;\frac{x}{\frac{z}{y}} - x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \end{array} \]

Alternative 5: 94.1% accurate, 0.7× speedup?

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

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

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

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

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


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

    1. Initial program 93.3%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + y}}} - x \]
      5. associate-/r/95.9%

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

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

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

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

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

    if -1 < y < 1

    1. Initial program 87.8%

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

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

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

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

    if 1 < y < 2.45000000000000016e137

    1. Initial program 85.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + y}}} - x \]
      5. associate-/r/99.8%

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{y}{z}} - x \]
    7. Simplified97.3%

      \[\leadsto \color{blue}{x \cdot \frac{y}{z}} - x \]
    8. Step-by-step derivation
      1. clear-num97.4%

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

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

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

    if 2.45000000000000016e137 < y

    1. Initial program 92.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x \cdot \frac{y}{z} - x\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;\frac{x}{\frac{z}{1 - z}}\\ \mathbf{elif}\;y \leq 2.45 \cdot 10^{+137}:\\ \;\;\;\;\frac{x}{\frac{z}{y}} - x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \end{array} \]

Alternative 6: 98.5% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 92.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + y}}} - x \]
      5. associate-/r/98.2%

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

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

    if 5.00000000000000027e-129 < z

    1. Initial program 85.4%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. *-un-lft-identity85.4%

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

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

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

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

Alternative 7: 98.9% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 93.1%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + y}}} - x \]
      5. associate-/r/98.4%

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

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

    if 5.4e10 < z

    1. Initial program 78.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + y}}} - x \]
      5. associate-/r/93.3%

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

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

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

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

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

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

Alternative 8: 85.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{+40} \lor \neg \left(y \leq 1.55 \cdot 10^{+75}\right):\\
\;\;\;\;\frac{x}{z} \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.7e40 or 1.5500000000000001e75 < y

    1. Initial program 94.2%

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

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

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

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

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

    if -3.7e40 < y < 1.5500000000000001e75

    1. Initial program 86.8%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{+40} \lor \neg \left(y \leq 1.55 \cdot 10^{+75}\right):\\ \;\;\;\;\frac{x}{z} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} - x\\ \end{array} \]

Alternative 9: 85.0% accurate, 1.0× speedup?

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

    1. Initial program 94.2%

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

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

    if -1.16000000000000007e41 < y < 1.04999999999999999e75

    1. Initial program 86.8%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.16 \cdot 10^{+41} \lor \neg \left(y \leq 1.05 \cdot 10^{+75}\right):\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} - x\\ \end{array} \]

Alternative 10: 84.7% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 94.1%

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
    4. Simplified84.1%

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

    if -3.7e40 < y < 8.60000000000000001e74

    1. Initial program 86.8%

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

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

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

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

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

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

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

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

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

    if 8.60000000000000001e74 < y

    1. Initial program 94.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{+40}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{+74}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \end{array} \]

Alternative 11: 84.7% accurate, 1.0× speedup?

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

\mathbf{elif}\;y \leq 1.05 \cdot 10^{+75}:\\
\;\;\;\;\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.80000000000000059e39

    1. Initial program 94.1%

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
    4. Simplified84.1%

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

    if -5.80000000000000059e39 < y < 1.04999999999999999e75

    1. Initial program 86.8%

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

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

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

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

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

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

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

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

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

    if 1.04999999999999999e75 < y

    1. Initial program 94.2%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
    6. Applied egg-rr80.3%

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

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

Alternative 12: 65.2% accurate, 1.3× speedup?

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

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

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

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


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

    1. Initial program 78.2%

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

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

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

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

    if -1 < z < 4.1e6

    1. Initial program 99.9%

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

      \[\leadsto \frac{\color{blue}{x \cdot \left(1 + y\right)}}{z} \]
    3. Step-by-step derivation
      1. distribute-lft-in98.5%

        \[\leadsto \frac{\color{blue}{x \cdot 1 + x \cdot y}}{z} \]
      2. *-rgt-identity98.5%

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

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

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

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

Alternative 13: 39.2% 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 89.7%

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

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

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

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

    \[\leadsto -x \]

Developer target: 99.5% 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 2023277 
(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))