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

Percentage Accurate: 88.1% → 99.9%
Time: 7.3s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 88.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;z \leq -4.8 \cdot 10^{+25} \lor \neg \left(z \leq 3400\right):\\
\;\;\;\;x \cdot \frac{t\_0}{z}\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{x}{z}\\


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

    1. Initial program 76.8%

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

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

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

    if -4.79999999999999992e25 < z < 3400

    1. Initial program 99.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.8 \cdot 10^{+25} \lor \neg \left(z \leq 3400\right):\\ \;\;\;\;x \cdot \frac{\left(y - z\right) + 1}{z}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(y - z\right) + 1\right) \cdot \frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 65.3% accurate, 0.4× speedup?

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

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

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

\mathbf{elif}\;z \leq 1.9 \cdot 10^{-13}:\\
\;\;\;\;\frac{x}{z}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -1.4e32 or 1.8999999999999999e51 < z

    1. Initial program 75.2%

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

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

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

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

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

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

    if -1.4e32 < z < 7.99999999999999939e-65

    1. Initial program 98.3%

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

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

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

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

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

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

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

    if 7.99999999999999939e-65 < z < 1.9e-13

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if 1.9e-13 < z < 1.8999999999999999e51

    1. Initial program 99.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{+32}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-65}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+51}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.2% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;y \leq -1.62 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.6199999999999999e78 or 1.14999999999999998e50 < y

    1. Initial program 88.1%

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

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

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

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

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

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

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

    if -1.6199999999999999e78 < y < -2.89999999999999981e42

    1. Initial program 72.8%

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

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

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

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

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

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

    if -2.89999999999999981e42 < y < -225000

    1. Initial program 99.5%

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

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

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

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

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

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

    if -225000 < y < 1.14999999999999998e50

    1. Initial program 87.8%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot x + \frac{x}{z}} \]
    7. Step-by-step derivation
      1. neg-mul-196.8%

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

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    8. Simplified96.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.62 \cdot 10^{+78}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{+42}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -225000:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+50}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 85.2% accurate, 0.4× speedup?

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

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

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.70000000000000004e78 or 1.13999999999999994e49 < y

    1. Initial program 88.1%

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

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

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

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

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

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

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

    if -1.70000000000000004e78 < y < -1.04999999999999998e42

    1. Initial program 72.8%

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

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

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

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

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

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

    if -1.04999999999999998e42 < y < -225000

    1. Initial program 99.5%

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    6. Step-by-step derivation
      1. *-commutative70.8%

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

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

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

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

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

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

    if -225000 < y < 1.13999999999999994e49

    1. Initial program 87.8%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot x + \frac{x}{z}} \]
    7. Step-by-step derivation
      1. neg-mul-196.8%

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

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    8. Simplified96.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.7 \cdot 10^{+78}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq -1.05 \cdot 10^{+42}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -225000:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;y \leq 1.14 \cdot 10^{+49}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 85.0% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;y \leq -4.6 \cdot 10^{+41}:\\
\;\;\;\;-x\\

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

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

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


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

    1. Initial program 91.5%

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

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

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

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

    if -4.49999999999999994e79 < y < -4.5999999999999997e41

    1. Initial program 72.8%

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

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

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

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

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

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

    if -4.5999999999999997e41 < y < -225000

    1. Initial program 99.5%

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    6. Step-by-step derivation
      1. *-commutative70.8%

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

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

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

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

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

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

    if -225000 < y < 2.64999999999999996e45

    1. Initial program 87.8%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot x + \frac{x}{z}} \]
    7. Step-by-step derivation
      1. neg-mul-196.8%

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

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    8. Simplified96.8%

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

    if 2.64999999999999996e45 < y

    1. Initial program 84.1%

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    6. Step-by-step derivation
      1. *-commutative68.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.5 \cdot 10^{+79}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;y \leq -4.6 \cdot 10^{+41}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -225000:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;y \leq 2.65 \cdot 10^{+45}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 85.1% accurate, 0.4× speedup?

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

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

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

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

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

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


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

    1. Initial program 91.5%

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

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

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

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

    if -8.59999999999999962e78 < y < -6.2000000000000003e42

    1. Initial program 72.8%

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

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

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

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

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

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

    if -6.2000000000000003e42 < y < -320

    1. Initial program 99.4%

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

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

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

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

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

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

    if -320 < y < 1.04999999999999997e45

    1. Initial program 87.6%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot x + \frac{x}{z}} \]
    7. Step-by-step derivation
      1. neg-mul-197.4%

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

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

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

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

    if 1.04999999999999997e45 < y

    1. Initial program 84.1%

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} \]
    6. Step-by-step derivation
      1. *-commutative68.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.6 \cdot 10^{+78}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;y \leq -6.2 \cdot 10^{+42}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -320:\\ \;\;\;\;x \cdot \frac{y + 1}{z}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+45}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 64.5% accurate, 0.4× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -8.8e5 or 1.25e50 < z

    1. Initial program 75.7%

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

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

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

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

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

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

    if -8.8e5 < z < 1.25e-14

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} \]
    7. Simplified92.2%

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

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

    if 1.25e-14 < z < 1.25e50

    1. Initial program 99.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -880000:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{-14}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+50}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 93.6% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;x \leq 5.4 \cdot 10^{-49}:\\
\;\;\;\;\frac{x \cdot t\_0}{z}\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{x}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 5.3999999999999999e-49

    1. Initial program 91.9%

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

    if 5.3999999999999999e-49 < x

    1. Initial program 78.6%

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

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

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

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

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

Alternative 9: 64.3% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -880000 \lor \neg \left(z \leq 1.04 \cdot 10^{-10}\right):\\
\;\;\;\;-x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.8e5 or 1.04e-10 < z

    1. Initial program 77.8%

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

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

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

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

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

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

    if -8.8e5 < z < 1.04e-10

    1. Initial program 99.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -880000 \lor \neg \left(z \leq 1.04 \cdot 10^{-10}\right):\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 96.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \frac{\left(y - z\right) + 1}{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(x * Float64(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[(x * N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

    \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
  4. Add Preprocessing
  5. Final simplification96.6%

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

Alternative 11: 96.3% accurate, 1.0× speedup?

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

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

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

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

    \[\leadsto \color{blue}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. clear-num96.5%

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{\left(y - z\right) + 1}}} \]
  6. Applied egg-rr96.8%

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

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

Alternative 12: 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 87.8%

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

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

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

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

      \[\leadsto \color{blue}{-x} \]
  7. Simplified41.6%

    \[\leadsto \color{blue}{-x} \]
  8. Final simplification41.6%

    \[\leadsto -x \]
  9. Add Preprocessing

Developer target: 99.5% accurate, 0.4× 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 2024048 
(FPCore (x y z)
  :name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
  :precision binary64

  :alt
  (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))