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

Percentage Accurate: 88.0% → 99.5%
Time: 10.0s
Alternatives: 11
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 11 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.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.6× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.0000000000000004e-19

    1. Initial program 72.6%

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{1}{\frac{z}{\left(y - z\right) + 1}}} \]
    4. Step-by-step derivation
      1. un-div-inv99.9%

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

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

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

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

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

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

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

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

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

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

    if -5.0000000000000004e-19 < z < 3.49999999999999998e-94

    1. Initial program 99.9%

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{1}{\frac{z}{\left(y - z\right) + 1}}} \]
    4. Step-by-step derivation
      1. un-div-inv89.7%

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

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

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

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

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

    if 3.49999999999999998e-94 < z

    1. Initial program 72.9%

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y - z, x \cdot 1\right)}}{z} \]
      3. *-rgt-identity72.9%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 65.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -51000000:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{-232}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.22 \cdot 10^{-80}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{+79}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= z -51000000.0)
     (- x)
     (if (<= z 1.45e-232)
       t_0
       (if (<= z 1.22e-80) (/ x z) (if (<= z 4.4e+79) t_0 (- x)))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -51000000.0) {
		tmp = -x;
	} else if (z <= 1.45e-232) {
		tmp = t_0;
	} else if (z <= 1.22e-80) {
		tmp = x / z;
	} else if (z <= 4.4e+79) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = y * (x / z)
    if (z <= (-51000000.0d0)) then
        tmp = -x
    else if (z <= 1.45d-232) then
        tmp = t_0
    else if (z <= 1.22d-80) then
        tmp = x / z
    else if (z <= 4.4d+79) then
        tmp = t_0
    else
        tmp = -x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -51000000.0) {
		tmp = -x;
	} else if (z <= 1.45e-232) {
		tmp = t_0;
	} else if (z <= 1.22e-80) {
		tmp = x / z;
	} else if (z <= 4.4e+79) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if z <= -51000000.0:
		tmp = -x
	elif z <= 1.45e-232:
		tmp = t_0
	elif z <= 1.22e-80:
		tmp = x / z
	elif z <= 4.4e+79:
		tmp = t_0
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(x / z))
	tmp = 0.0
	if (z <= -51000000.0)
		tmp = Float64(-x);
	elseif (z <= 1.45e-232)
		tmp = t_0;
	elseif (z <= 1.22e-80)
		tmp = Float64(x / z);
	elseif (z <= 4.4e+79)
		tmp = t_0;
	else
		tmp = Float64(-x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (x / z);
	tmp = 0.0;
	if (z <= -51000000.0)
		tmp = -x;
	elseif (z <= 1.45e-232)
		tmp = t_0;
	elseif (z <= 1.22e-80)
		tmp = x / z;
	elseif (z <= 4.4e+79)
		tmp = t_0;
	else
		tmp = -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -51000000.0], (-x), If[LessEqual[z, 1.45e-232], t$95$0, If[LessEqual[z, 1.22e-80], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.4e+79], t$95$0, (-x)]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 1.45 \cdot 10^{-232}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 1.22 \cdot 10^{-80}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 4.4 \cdot 10^{+79}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.1e7 or 4.3999999999999998e79 < z

    1. Initial program 65.9%

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

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

        \[\leadsto \color{blue}{-x} \]
    4. Simplified81.6%

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

    if -5.1e7 < z < 1.45e-232 or 1.22e-80 < z < 4.3999999999999998e79

    1. Initial program 99.0%

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

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

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

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

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

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

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

    if 1.45e-232 < z < 1.22e-80

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -51000000:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{-232}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 1.22 \cdot 10^{-80}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{+79}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 3: 65.7% accurate, 0.7× speedup?

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

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

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

\mathbf{elif}\;z \leq 1.28 \cdot 10^{-80}:\\
\;\;\;\;\frac{x}{z}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -7e7 or 1.49999999999999993e80 < z

    1. Initial program 65.9%

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

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

        \[\leadsto \color{blue}{-x} \]
    4. Simplified81.6%

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

    if -7e7 < z < 1.29999999999999998e-232

    1. Initial program 99.9%

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

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

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

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

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

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

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

    if 1.29999999999999998e-232 < z < 1.28e-80

    1. Initial program 100.0%

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

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

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

    if 1.28e-80 < z < 1.49999999999999993e80

    1. Initial program 96.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -70000000:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-232}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 1.28 \cdot 10^{-80}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{+80}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 4: 99.9% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 67.1%

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{1}{\frac{z}{\left(y - z\right) + 1}}} \]
    4. Step-by-step derivation
      1. un-div-inv99.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1 + y}{z} \cdot x - x} \]
    9. Taylor expanded in y around inf 100.0%

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

    if -1.35e16 < z < 3.3e15

    1. Initial program 99.9%

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

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

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

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

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

Alternative 5: 99.9% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2e-14 or 1.99999999999999996e-12 < z

    1. Initial program 70.1%

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{1}{\frac{z}{\left(y - z\right) + 1}}} \]
    4. Step-by-step derivation
      1. un-div-inv99.9%

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

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

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

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

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

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

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

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

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

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

    if -2e-14 < z < 1.99999999999999996e-12

    1. Initial program 99.9%

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

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

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

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

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

Alternative 6: 95.2% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 82.3%

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{1}{\frac{z}{\left(y - z\right) + 1}}} \]
    4. Step-by-step derivation
      1. un-div-inv92.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1 + y}{z} \cdot x - x} \]
    9. Taylor expanded in y around inf 91.6%

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

    if -1 < y < 1

    1. Initial program 84.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{x + \left(-z\right) \cdot x}}{z} \]
      4. cancel-sign-sub-inv84.2%

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

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

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

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

        \[\leadsto \frac{x}{z} - \color{blue}{\frac{x}{\frac{z}{z}}} \]
      9. *-inverses99.6%

        \[\leadsto \frac{x}{z} - \frac{x}{\color{blue}{1}} \]
      10. /-rgt-identity99.6%

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

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

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

Alternative 7: 97.9% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 69.9%

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{1}{\frac{z}{\left(y - z\right) + 1}}} \]
    4. Step-by-step derivation
      1. un-div-inv99.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1 + y}{z} \cdot x - x} \]
    9. Taylor expanded in y around inf 97.8%

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

    if -1 < z < 7.49999999999999975e-31

    1. Initial program 99.9%

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

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

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

Alternative 8: 84.8% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.9999999999999999e23 or 3.99999999999999996e132 < y

    1. Initial program 85.1%

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

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

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

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

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

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

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

    if -4.9999999999999999e23 < y < 3.99999999999999996e132

    1. Initial program 82.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{x + \left(-z\right) \cdot x}}{z} \]
      4. cancel-sign-sub-inv75.6%

        \[\leadsto \frac{\color{blue}{x - z \cdot x}}{z} \]
      5. *-commutative75.6%

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

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

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

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

        \[\leadsto \frac{x}{z} - \frac{x}{\color{blue}{1}} \]
      10. /-rgt-identity93.2%

        \[\leadsto \frac{x}{z} - \color{blue}{x} \]
    6. Simplified93.2%

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

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

Alternative 9: 84.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.65 \cdot 10^{+24} \lor \neg \left(y \leq 1.6 \cdot 10^{+138}\right):\\
\;\;\;\;\frac{y \cdot x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.6499999999999999e24 or 1.6000000000000001e138 < y

    1. Initial program 85.1%

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

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

    if -1.6499999999999999e24 < y < 1.6000000000000001e138

    1. Initial program 82.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{x + \left(-z\right) \cdot x}}{z} \]
      4. cancel-sign-sub-inv75.6%

        \[\leadsto \frac{\color{blue}{x - z \cdot x}}{z} \]
      5. *-commutative75.6%

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

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

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

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

        \[\leadsto \frac{x}{z} - \frac{x}{\color{blue}{1}} \]
      10. /-rgt-identity93.2%

        \[\leadsto \frac{x}{z} - \color{blue}{x} \]
    6. Simplified93.2%

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

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

Alternative 10: 64.3% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;z \leq 3.4 \cdot 10^{-42}:\\
\;\;\;\;\frac{x}{z}\\

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


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

    1. Initial program 70.1%

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

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

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

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

    if -1 < z < 3.40000000000000022e-42

    1. Initial program 99.9%

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

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

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

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

Alternative 11: 39.4% 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 83.4%

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

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

      \[\leadsto \color{blue}{-x} \]
  4. Simplified42.1%

    \[\leadsto \color{blue}{-x} \]
  5. Final simplification42.1%

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