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

Percentage Accurate: 87.6% → 99.8%
Time: 9.7s
Alternatives: 9
Speedup: 0.7×

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 9 alternatives:

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

Initial Program: 87.6% 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.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.0002 \lor \neg \left(z \leq 4.6 \cdot 10^{+16}\right):\\ \;\;\;\;\frac{x}{\frac{z}{1 + \left(y - z\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, y - z, x\right)}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -0.0002) (not (<= z 4.6e+16)))
   (/ x (/ z (+ 1.0 (- y z))))
   (/ (fma x (- y z) x) z)))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -0.0002) || !(z <= 4.6e+16)) {
		tmp = x / (z / (1.0 + (y - z)));
	} else {
		tmp = fma(x, (y - z), x) / z;
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if ((z <= -0.0002) || !(z <= 4.6e+16))
		tmp = Float64(x / Float64(z / Float64(1.0 + Float64(y - z))));
	else
		tmp = Float64(fma(x, Float64(y - z), x) / z);
	end
	return tmp
end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.0002], N[Not[LessEqual[z, 4.6e+16]], $MachinePrecision]], N[(x / N[(z / N[(1.0 + N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y - z), $MachinePrecision] + x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y - z, x\right)}{z}\\


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

    1. Initial program 78.3%

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-4 < z < 4.6e16

    1. Initial program 99.9%

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

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

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

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

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

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

Alternative 2: 64.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{y}{z}\\ \mathbf{if}\;z \leq -6.8 \cdot 10^{+31}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -6 \cdot 10^{-61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-150}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq -3.05 \cdot 10^{-192}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-178}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 6.1 \cdot 10^{-32}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-10}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{+62}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (/ y z))))
   (if (<= z -6.8e+31)
     (- x)
     (if (<= z -6e-61)
       t_0
       (if (<= z -2.6e-150)
         (/ x z)
         (if (<= z -3.05e-192)
           t_0
           (if (<= z 2.4e-178)
             (/ x z)
             (if (<= z 6.1e-32)
               t_0
               (if (<= z 3.3e-10)
                 (/ x z)
                 (if (<= z 4.2e+62) t_0 (- x)))))))))))
double code(double x, double y, double z) {
	double t_0 = x * (y / z);
	double tmp;
	if (z <= -6.8e+31) {
		tmp = -x;
	} else if (z <= -6e-61) {
		tmp = t_0;
	} else if (z <= -2.6e-150) {
		tmp = x / z;
	} else if (z <= -3.05e-192) {
		tmp = t_0;
	} else if (z <= 2.4e-178) {
		tmp = x / z;
	} else if (z <= 6.1e-32) {
		tmp = t_0;
	} else if (z <= 3.3e-10) {
		tmp = x / z;
	} else if (z <= 4.2e+62) {
		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 = x * (y / z)
    if (z <= (-6.8d+31)) then
        tmp = -x
    else if (z <= (-6d-61)) then
        tmp = t_0
    else if (z <= (-2.6d-150)) then
        tmp = x / z
    else if (z <= (-3.05d-192)) then
        tmp = t_0
    else if (z <= 2.4d-178) then
        tmp = x / z
    else if (z <= 6.1d-32) then
        tmp = t_0
    else if (z <= 3.3d-10) then
        tmp = x / z
    else if (z <= 4.2d+62) 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 = x * (y / z);
	double tmp;
	if (z <= -6.8e+31) {
		tmp = -x;
	} else if (z <= -6e-61) {
		tmp = t_0;
	} else if (z <= -2.6e-150) {
		tmp = x / z;
	} else if (z <= -3.05e-192) {
		tmp = t_0;
	} else if (z <= 2.4e-178) {
		tmp = x / z;
	} else if (z <= 6.1e-32) {
		tmp = t_0;
	} else if (z <= 3.3e-10) {
		tmp = x / z;
	} else if (z <= 4.2e+62) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (y / z)
	tmp = 0
	if z <= -6.8e+31:
		tmp = -x
	elif z <= -6e-61:
		tmp = t_0
	elif z <= -2.6e-150:
		tmp = x / z
	elif z <= -3.05e-192:
		tmp = t_0
	elif z <= 2.4e-178:
		tmp = x / z
	elif z <= 6.1e-32:
		tmp = t_0
	elif z <= 3.3e-10:
		tmp = x / z
	elif z <= 4.2e+62:
		tmp = t_0
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(y / z))
	tmp = 0.0
	if (z <= -6.8e+31)
		tmp = Float64(-x);
	elseif (z <= -6e-61)
		tmp = t_0;
	elseif (z <= -2.6e-150)
		tmp = Float64(x / z);
	elseif (z <= -3.05e-192)
		tmp = t_0;
	elseif (z <= 2.4e-178)
		tmp = Float64(x / z);
	elseif (z <= 6.1e-32)
		tmp = t_0;
	elseif (z <= 3.3e-10)
		tmp = Float64(x / z);
	elseif (z <= 4.2e+62)
		tmp = t_0;
	else
		tmp = Float64(-x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (y / z);
	tmp = 0.0;
	if (z <= -6.8e+31)
		tmp = -x;
	elseif (z <= -6e-61)
		tmp = t_0;
	elseif (z <= -2.6e-150)
		tmp = x / z;
	elseif (z <= -3.05e-192)
		tmp = t_0;
	elseif (z <= 2.4e-178)
		tmp = x / z;
	elseif (z <= 6.1e-32)
		tmp = t_0;
	elseif (z <= 3.3e-10)
		tmp = x / z;
	elseif (z <= 4.2e+62)
		tmp = t_0;
	else
		tmp = -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.8e+31], (-x), If[LessEqual[z, -6e-61], t$95$0, If[LessEqual[z, -2.6e-150], N[(x / z), $MachinePrecision], If[LessEqual[z, -3.05e-192], t$95$0, If[LessEqual[z, 2.4e-178], N[(x / z), $MachinePrecision], If[LessEqual[z, 6.1e-32], t$95$0, If[LessEqual[z, 3.3e-10], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.2e+62], t$95$0, (-x)]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -6 \cdot 10^{-61}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -2.6 \cdot 10^{-150}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq -3.05 \cdot 10^{-192}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 2.4 \cdot 10^{-178}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 6.1 \cdot 10^{-32}:\\
\;\;\;\;t_0\\

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

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

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


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

    1. Initial program 74.5%

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

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

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

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

    if -6.7999999999999996e31 < z < -6.00000000000000024e-61 or -2.5999999999999998e-150 < z < -3.05e-192 or 2.40000000000000005e-178 < z < 6.09999999999999959e-32 or 3.3e-10 < z < 4.2e62

    1. Initial program 98.6%

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

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

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

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

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

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

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

    if -6.00000000000000024e-61 < z < -2.5999999999999998e-150 or -3.05e-192 < z < 2.40000000000000005e-178 or 6.09999999999999959e-32 < z < 3.3e-10

    1. Initial program 99.9%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6.8 \cdot 10^{+31}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -6 \cdot 10^{-61}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-150}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq -3.05 \cdot 10^{-192}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-178}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 6.1 \cdot 10^{-32}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-10}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{+62}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 3: 65.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -4.3 \cdot 10^{+26}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -2.3 \cdot 10^{-68}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-147}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 3.7 \cdot 10^{-296}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-175}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-36}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{-9}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 5.9 \cdot 10^{+63}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= z -4.3e+26)
     (- x)
     (if (<= z -2.3e-68)
       t_0
       (if (<= z -5e-147)
         (/ x z)
         (if (<= z 3.7e-296)
           t_0
           (if (<= z 5e-175)
             (/ x z)
             (if (<= z 6e-36)
               t_0
               (if (<= z 1.9e-9)
                 (/ x z)
                 (if (<= z 5.9e+63) (* x (/ y z)) (- x)))))))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -4.3e+26) {
		tmp = -x;
	} else if (z <= -2.3e-68) {
		tmp = t_0;
	} else if (z <= -5e-147) {
		tmp = x / z;
	} else if (z <= 3.7e-296) {
		tmp = t_0;
	} else if (z <= 5e-175) {
		tmp = x / z;
	} else if (z <= 6e-36) {
		tmp = t_0;
	} else if (z <= 1.9e-9) {
		tmp = x / z;
	} else if (z <= 5.9e+63) {
		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) :: t_0
    real(8) :: tmp
    t_0 = y * (x / z)
    if (z <= (-4.3d+26)) then
        tmp = -x
    else if (z <= (-2.3d-68)) then
        tmp = t_0
    else if (z <= (-5d-147)) then
        tmp = x / z
    else if (z <= 3.7d-296) then
        tmp = t_0
    else if (z <= 5d-175) then
        tmp = x / z
    else if (z <= 6d-36) then
        tmp = t_0
    else if (z <= 1.9d-9) then
        tmp = x / z
    else if (z <= 5.9d+63) 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 t_0 = y * (x / z);
	double tmp;
	if (z <= -4.3e+26) {
		tmp = -x;
	} else if (z <= -2.3e-68) {
		tmp = t_0;
	} else if (z <= -5e-147) {
		tmp = x / z;
	} else if (z <= 3.7e-296) {
		tmp = t_0;
	} else if (z <= 5e-175) {
		tmp = x / z;
	} else if (z <= 6e-36) {
		tmp = t_0;
	} else if (z <= 1.9e-9) {
		tmp = x / z;
	} else if (z <= 5.9e+63) {
		tmp = x * (y / z);
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if z <= -4.3e+26:
		tmp = -x
	elif z <= -2.3e-68:
		tmp = t_0
	elif z <= -5e-147:
		tmp = x / z
	elif z <= 3.7e-296:
		tmp = t_0
	elif z <= 5e-175:
		tmp = x / z
	elif z <= 6e-36:
		tmp = t_0
	elif z <= 1.9e-9:
		tmp = x / z
	elif z <= 5.9e+63:
		tmp = x * (y / z)
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(x / z))
	tmp = 0.0
	if (z <= -4.3e+26)
		tmp = Float64(-x);
	elseif (z <= -2.3e-68)
		tmp = t_0;
	elseif (z <= -5e-147)
		tmp = Float64(x / z);
	elseif (z <= 3.7e-296)
		tmp = t_0;
	elseif (z <= 5e-175)
		tmp = Float64(x / z);
	elseif (z <= 6e-36)
		tmp = t_0;
	elseif (z <= 1.9e-9)
		tmp = Float64(x / z);
	elseif (z <= 5.9e+63)
		tmp = Float64(x * Float64(y / z));
	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 <= -4.3e+26)
		tmp = -x;
	elseif (z <= -2.3e-68)
		tmp = t_0;
	elseif (z <= -5e-147)
		tmp = x / z;
	elseif (z <= 3.7e-296)
		tmp = t_0;
	elseif (z <= 5e-175)
		tmp = x / z;
	elseif (z <= 6e-36)
		tmp = t_0;
	elseif (z <= 1.9e-9)
		tmp = x / z;
	elseif (z <= 5.9e+63)
		tmp = x * (y / z);
	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, -4.3e+26], (-x), If[LessEqual[z, -2.3e-68], t$95$0, If[LessEqual[z, -5e-147], N[(x / z), $MachinePrecision], If[LessEqual[z, 3.7e-296], t$95$0, If[LessEqual[z, 5e-175], N[(x / z), $MachinePrecision], If[LessEqual[z, 6e-36], t$95$0, If[LessEqual[z, 1.9e-9], N[(x / z), $MachinePrecision], If[LessEqual[z, 5.9e+63], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], (-x)]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -2.3 \cdot 10^{-68}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -5 \cdot 10^{-147}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 3.7 \cdot 10^{-296}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 5 \cdot 10^{-175}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 6 \cdot 10^{-36}:\\
\;\;\;\;t_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -4.2999999999999998e26 or 5.90000000000000029e63 < z

    1. Initial program 75.0%

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

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

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

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

    if -4.2999999999999998e26 < z < -2.29999999999999997e-68 or -5.00000000000000013e-147 < z < 3.70000000000000027e-296 or 5e-175 < z < 6.0000000000000003e-36

    1. Initial program 99.8%

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

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

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

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

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

    if -2.29999999999999997e-68 < z < -5.00000000000000013e-147 or 3.70000000000000027e-296 < z < 5e-175 or 6.0000000000000003e-36 < z < 1.90000000000000006e-9

    1. Initial program 100.0%

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

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

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

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

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

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

    if 1.90000000000000006e-9 < z < 5.90000000000000029e63

    1. Initial program 94.5%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.3 \cdot 10^{+26}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -2.3 \cdot 10^{-68}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-147}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 3.7 \cdot 10^{-296}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-175}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-36}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{-9}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 5.9 \cdot 10^{+63}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 4: 99.6% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_0 := 1 + \left(y - z\right)\\
\mathbf{if}\;z \leq -6 \cdot 10^{+27} \lor \neg \left(z \leq 1.8 \cdot 10^{-111}\right):\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.99999999999999953e27 or 1.80000000000000005e-111 < z

    1. Initial program 80.4%

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

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

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

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

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

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

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

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

    if -5.99999999999999953e27 < z < 1.80000000000000005e-111

    1. Initial program 99.8%

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

        \[\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 -6 \cdot 10^{+27} \lor \neg \left(z \leq 1.8 \cdot 10^{-111}\right):\\ \;\;\;\;\frac{x}{\frac{z}{1 + \left(y - z\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(y - z\right)\right) \cdot \frac{x}{z}\\ \end{array} \]

Alternative 5: 94.1% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.0599999999999999e182 or 7.0000000000000002e146 < z

    1. Initial program 72.1%

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

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

        \[\leadsto \color{blue}{-x} \]
    4. Simplified84.3%

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

    if -1.0599999999999999e182 < z < 7.0000000000000002e146

    1. Initial program 93.7%

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

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

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

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

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

Alternative 6: 85.4% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 91.4%

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

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

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

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

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

    if -6.20000000000000035e38 < y < 1.14e24

    1. Initial program 86.5%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 - z}{\frac{z}{x}}} \]
      3. div-sub74.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{z}{x}} - \frac{z}{\frac{z}{x}}} \]
      4. associate-/r/74.3%

        \[\leadsto \color{blue}{\frac{1}{z} \cdot x} - \frac{z}{\frac{z}{x}} \]
      5. associate-*l/74.5%

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

        \[\leadsto \frac{\color{blue}{x}}{z} - \frac{z}{\frac{z}{x}} \]
      7. associate-/r/95.3%

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

        \[\leadsto \frac{x}{z} - \color{blue}{1} \cdot x \]
      9. *-lft-identity95.3%

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

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

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

Alternative 7: 85.1% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 91.4%

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

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

    if -1.4e41 < y < 1.10000000000000001e24

    1. Initial program 86.5%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 - z}{\frac{z}{x}}} \]
      3. div-sub74.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{z}{x}} - \frac{z}{\frac{z}{x}}} \]
      4. associate-/r/74.3%

        \[\leadsto \color{blue}{\frac{1}{z} \cdot x} - \frac{z}{\frac{z}{x}} \]
      5. associate-*l/74.5%

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

        \[\leadsto \frac{\color{blue}{x}}{z} - \frac{z}{\frac{z}{x}} \]
      7. associate-/r/95.3%

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

        \[\leadsto \frac{x}{z} - \color{blue}{1} \cdot x \]
      9. *-lft-identity95.3%

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

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

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

Alternative 8: 64.7% accurate, 1.3× speedup?

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

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

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

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


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

    1. Initial program 78.6%

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

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

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

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

    if -1 < z < 1

    1. Initial program 99.9%

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

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

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

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

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

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

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

Alternative 9: 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 88.8%

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

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

      \[\leadsto \color{blue}{-x} \]
  4. Simplified37.2%

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

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