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

Percentage Accurate: 87.9% → 99.8%
Time: 6.4s
Alternatives: 12
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 87.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+35} \lor \neg \left(z \leq 5 \cdot 10^{+30}\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 -1e+35) (not (<= z 5e+30)))
   (- (* x (/ y z)) x)
   (* (/ x z) (+ 1.0 (- y z)))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1e+35) || !(z <= 5e+30)) {
		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 <= (-1d+35)) .or. (.not. (z <= 5d+30))) 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 <= -1e+35) || !(z <= 5e+30)) {
		tmp = (x * (y / z)) - x;
	} else {
		tmp = (x / z) * (1.0 + (y - z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1e+35) or not (z <= 5e+30):
		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 <= -1e+35) || !(z <= 5e+30))
		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 <= -1e+35) || ~((z <= 5e+30)))
		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, -1e+35], N[Not[LessEqual[z, 5e+30]], $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 \cdot 10^{+35} \lor \neg \left(z \leq 5 \cdot 10^{+30}\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 < -9.9999999999999997e34 or 4.9999999999999998e30 < z

    1. Initial program 75.3%

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

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

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

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

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

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

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

        \[\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 \]
    6. Simplified99.9%

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

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

    if -9.9999999999999997e34 < z < 4.9999999999999998e30

    1. Initial program 99.9%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(\left(y - z\right) + 1\right)} \]
    5. 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 \cdot 10^{+35} \lor \neg \left(z \leq 5 \cdot 10^{+30}\right):\\ \;\;\;\;x \cdot \frac{y}{z} - x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \left(1 + \left(y - z\right)\right)\\ \end{array} \]

Alternative 2: 64.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -8.2 \cdot 10^{+32}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-66}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{-260}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-180}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-17}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{+37}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.66 \cdot 10^{+74}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+141}:\\ \;\;\;\;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 -8.2e+32)
     (- x)
     (if (<= z -3.2e-66)
       t_0
       (if (<= z -4.5e-260)
         (/ x z)
         (if (<= z 1.2e-180)
           t_0
           (if (<= z 9e-17)
             (/ x z)
             (if (<= z 8.5e+37)
               t_0
               (if (<= z 1.66e+74)
                 (- x)
                 (if (<= z 5e+141) (* x (/ y z)) (- x)))))))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -8.2e+32) {
		tmp = -x;
	} else if (z <= -3.2e-66) {
		tmp = t_0;
	} else if (z <= -4.5e-260) {
		tmp = x / z;
	} else if (z <= 1.2e-180) {
		tmp = t_0;
	} else if (z <= 9e-17) {
		tmp = x / z;
	} else if (z <= 8.5e+37) {
		tmp = t_0;
	} else if (z <= 1.66e+74) {
		tmp = -x;
	} else if (z <= 5e+141) {
		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 <= (-8.2d+32)) then
        tmp = -x
    else if (z <= (-3.2d-66)) then
        tmp = t_0
    else if (z <= (-4.5d-260)) then
        tmp = x / z
    else if (z <= 1.2d-180) then
        tmp = t_0
    else if (z <= 9d-17) then
        tmp = x / z
    else if (z <= 8.5d+37) then
        tmp = t_0
    else if (z <= 1.66d+74) then
        tmp = -x
    else if (z <= 5d+141) 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 <= -8.2e+32) {
		tmp = -x;
	} else if (z <= -3.2e-66) {
		tmp = t_0;
	} else if (z <= -4.5e-260) {
		tmp = x / z;
	} else if (z <= 1.2e-180) {
		tmp = t_0;
	} else if (z <= 9e-17) {
		tmp = x / z;
	} else if (z <= 8.5e+37) {
		tmp = t_0;
	} else if (z <= 1.66e+74) {
		tmp = -x;
	} else if (z <= 5e+141) {
		tmp = x * (y / z);
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if z <= -8.2e+32:
		tmp = -x
	elif z <= -3.2e-66:
		tmp = t_0
	elif z <= -4.5e-260:
		tmp = x / z
	elif z <= 1.2e-180:
		tmp = t_0
	elif z <= 9e-17:
		tmp = x / z
	elif z <= 8.5e+37:
		tmp = t_0
	elif z <= 1.66e+74:
		tmp = -x
	elif z <= 5e+141:
		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 <= -8.2e+32)
		tmp = Float64(-x);
	elseif (z <= -3.2e-66)
		tmp = t_0;
	elseif (z <= -4.5e-260)
		tmp = Float64(x / z);
	elseif (z <= 1.2e-180)
		tmp = t_0;
	elseif (z <= 9e-17)
		tmp = Float64(x / z);
	elseif (z <= 8.5e+37)
		tmp = t_0;
	elseif (z <= 1.66e+74)
		tmp = Float64(-x);
	elseif (z <= 5e+141)
		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 <= -8.2e+32)
		tmp = -x;
	elseif (z <= -3.2e-66)
		tmp = t_0;
	elseif (z <= -4.5e-260)
		tmp = x / z;
	elseif (z <= 1.2e-180)
		tmp = t_0;
	elseif (z <= 9e-17)
		tmp = x / z;
	elseif (z <= 8.5e+37)
		tmp = t_0;
	elseif (z <= 1.66e+74)
		tmp = -x;
	elseif (z <= 5e+141)
		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, -8.2e+32], (-x), If[LessEqual[z, -3.2e-66], t$95$0, If[LessEqual[z, -4.5e-260], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.2e-180], t$95$0, If[LessEqual[z, 9e-17], N[(x / z), $MachinePrecision], If[LessEqual[z, 8.5e+37], t$95$0, If[LessEqual[z, 1.66e+74], (-x), If[LessEqual[z, 5e+141], 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 -8.2 \cdot 10^{+32}:\\
\;\;\;\;-x\\

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

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

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

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

\mathbf{elif}\;z \leq 8.5 \cdot 10^{+37}:\\
\;\;\;\;t_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -8.19999999999999961e32 or 8.4999999999999999e37 < z < 1.66000000000000001e74 or 5.00000000000000025e141 < z

    1. Initial program 72.9%

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

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

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

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

        \[\leadsto \color{blue}{-x} \]
    6. Simplified76.1%

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

    if -8.19999999999999961e32 < z < -3.19999999999999982e-66 or -4.4999999999999997e-260 < z < 1.1999999999999999e-180 or 8.99999999999999957e-17 < z < 8.4999999999999999e37

    1. Initial program 99.8%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
    6. Simplified62.2%

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
    7. Step-by-step derivation
      1. associate-/r/73.4%

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

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

    if -3.19999999999999982e-66 < z < -4.4999999999999997e-260 or 1.1999999999999999e-180 < z < 8.99999999999999957e-17

    1. Initial program 99.9%

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

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

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

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

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

    if 1.66000000000000001e74 < z < 5.00000000000000025e141

    1. Initial program 92.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8.2 \cdot 10^{+32}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-66}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{-260}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-180}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-17}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{+37}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 1.66 \cdot 10^{+74}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+141}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 3: 66.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -5.2 \cdot 10^{+32}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -3.1 \cdot 10^{-62}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.6 \cdot 10^{-259}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 10^{-181}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{-16}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{+38}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= z -5.2e+32)
     (- x)
     (if (<= z -3.1e-62)
       t_0
       (if (<= z -1.6e-259)
         (/ x z)
         (if (<= z 1e-181)
           t_0
           (if (<= z 3.5e-16) (/ x z) (if (<= z 1.65e+38) t_0 (- x)))))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -5.2e+32) {
		tmp = -x;
	} else if (z <= -3.1e-62) {
		tmp = t_0;
	} else if (z <= -1.6e-259) {
		tmp = x / z;
	} else if (z <= 1e-181) {
		tmp = t_0;
	} else if (z <= 3.5e-16) {
		tmp = x / z;
	} else if (z <= 1.65e+38) {
		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 <= (-5.2d+32)) then
        tmp = -x
    else if (z <= (-3.1d-62)) then
        tmp = t_0
    else if (z <= (-1.6d-259)) then
        tmp = x / z
    else if (z <= 1d-181) then
        tmp = t_0
    else if (z <= 3.5d-16) then
        tmp = x / z
    else if (z <= 1.65d+38) 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 <= -5.2e+32) {
		tmp = -x;
	} else if (z <= -3.1e-62) {
		tmp = t_0;
	} else if (z <= -1.6e-259) {
		tmp = x / z;
	} else if (z <= 1e-181) {
		tmp = t_0;
	} else if (z <= 3.5e-16) {
		tmp = x / z;
	} else if (z <= 1.65e+38) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if z <= -5.2e+32:
		tmp = -x
	elif z <= -3.1e-62:
		tmp = t_0
	elif z <= -1.6e-259:
		tmp = x / z
	elif z <= 1e-181:
		tmp = t_0
	elif z <= 3.5e-16:
		tmp = x / z
	elif z <= 1.65e+38:
		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 <= -5.2e+32)
		tmp = Float64(-x);
	elseif (z <= -3.1e-62)
		tmp = t_0;
	elseif (z <= -1.6e-259)
		tmp = Float64(x / z);
	elseif (z <= 1e-181)
		tmp = t_0;
	elseif (z <= 3.5e-16)
		tmp = Float64(x / z);
	elseif (z <= 1.65e+38)
		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 <= -5.2e+32)
		tmp = -x;
	elseif (z <= -3.1e-62)
		tmp = t_0;
	elseif (z <= -1.6e-259)
		tmp = x / z;
	elseif (z <= 1e-181)
		tmp = t_0;
	elseif (z <= 3.5e-16)
		tmp = x / z;
	elseif (z <= 1.65e+38)
		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, -5.2e+32], (-x), If[LessEqual[z, -3.1e-62], t$95$0, If[LessEqual[z, -1.6e-259], N[(x / z), $MachinePrecision], If[LessEqual[z, 1e-181], t$95$0, If[LessEqual[z, 3.5e-16], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.65e+38], t$95$0, (-x)]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -3.1 \cdot 10^{-62}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;z \leq 10^{-181}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;z \leq 1.65 \cdot 10^{+38}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.2000000000000004e32 or 1.65e38 < z

    1. Initial program 74.9%

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

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

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

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

        \[\leadsto \color{blue}{-x} \]
    6. Simplified71.1%

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

    if -5.2000000000000004e32 < z < -3.0999999999999999e-62 or -1.59999999999999994e-259 < z < 1.00000000000000005e-181 or 3.50000000000000017e-16 < z < 1.65e38

    1. Initial program 99.8%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
    6. Simplified62.2%

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
    7. Step-by-step derivation
      1. associate-/r/73.4%

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

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

    if -3.0999999999999999e-62 < z < -1.59999999999999994e-259 or 1.00000000000000005e-181 < z < 3.50000000000000017e-16

    1. Initial program 99.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.2 \cdot 10^{+32}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -3.1 \cdot 10^{-62}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq -1.6 \cdot 10^{-259}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 10^{-181}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{-16}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{+38}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 4: 94.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 2.5 \cdot 10^{-43}\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 2.5e-43))) (- (* x (/ y z)) x) (- (/ x z) x)))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.0) || !(y <= 2.5e-43)) {
		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 <= 2.5d-43))) 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 <= 2.5e-43)) {
		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 <= 2.5e-43):
		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 <= 2.5e-43))
		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 <= 2.5e-43)))
		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, 2.5e-43]], $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 2.5 \cdot 10^{-43}\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 2.50000000000000009e-43 < y

    1. Initial program 86.8%

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

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

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

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

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

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

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

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

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

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

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

    if -1 < y < 2.50000000000000009e-43

    1. Initial program 90.4%

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

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

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

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

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

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

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

        \[\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 \]
    6. Simplified99.9%

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

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

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

Alternative 5: 94.2% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 86.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + y}}} - x \]
    8. Applied egg-rr97.3%

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

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

    if -1 < y < 2.50000000000000009e-43

    1. Initial program 90.4%

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

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

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

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

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

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

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

        \[\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 \]
    6. Simplified99.9%

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

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

    if 2.50000000000000009e-43 < y

    1. Initial program 86.6%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 98.6% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 79.5%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(1 + y\right) \cdot x}{z} - x} \]
      4. associate-/l*96.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 \]
    6. Simplified99.9%

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

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

    if -1.1000000000000001 < z < 5.1999999999999997e-16

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

    if 5.1999999999999997e-16 < z

    1. Initial program 76.5%

      \[\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}}} \]
    3. Simplified99.9%

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

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

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

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

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

        \[\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 \]
    6. Simplified99.9%

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

        \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} - x \]
      2. clear-num99.9%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{z}{1 + y}}} - x \]
      3. un-div-inv99.9%

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

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

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

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

Alternative 7: 83.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 87.6%

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

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

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

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

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

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

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

    if -320 < y < 4.6999999999999999e39

    1. Initial program 89.3%

      \[\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}}} \]
    3. Simplified100.0%

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

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

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

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

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

        \[\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 \]
    6. Simplified99.9%

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

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

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

Alternative 8: 83.9% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 86.5%

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

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

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

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

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

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

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

    if -310 < y < 3.59999999999999984e39

    1. Initial program 89.3%

      \[\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}}} \]
    3. Simplified100.0%

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

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

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

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

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

        \[\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 \]
    6. Simplified99.9%

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

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

    if 3.59999999999999984e39 < y

    1. Initial program 88.7%

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

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

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

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

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

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

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

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

Alternative 9: 96.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x}{\frac{z}{1 + y}} - x \end{array} \]
(FPCore (x y z) :precision binary64 (- (/ x (/ z (+ 1.0 y))) x))
double code(double x, double y, double z) {
	return (x / (z / (1.0 + y))) - 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 / (z / (1.0d0 + y))) - x
end function
public static double code(double x, double y, double z) {
	return (x / (z / (1.0 + y))) - x;
}
def code(x, y, z):
	return (x / (z / (1.0 + y))) - x
function code(x, y, z)
	return Float64(Float64(x / Float64(z / Float64(1.0 + y))) - x)
end
function tmp = code(x, y, z)
	tmp = (x / (z / (1.0 + y))) - x;
end
code[x_, y_, z_] := N[(N[(x / N[(z / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}

\\
\frac{x}{\frac{z}{1 + y}} - x
\end{array}
Derivation
  1. Initial program 88.4%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1 + y}{z} \cdot x - x} \]
  7. Step-by-step derivation
    1. *-commutative98.0%

      \[\leadsto \color{blue}{x \cdot \frac{1 + y}{z}} - x \]
    2. clear-num97.9%

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + y}}} - x \]
  8. Applied egg-rr98.2%

    \[\leadsto \color{blue}{\frac{x}{\frac{z}{1 + y}}} - x \]
  9. Final simplification98.2%

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

Alternative 10: 96.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \frac{1 + y}{z} - x \end{array} \]
(FPCore (x y z) :precision binary64 (- (* x (/ (+ 1.0 y) z)) x))
double code(double x, double y, double z) {
	return (x * ((1.0 + y) / z)) - 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 * ((1.0d0 + y) / z)) - x
end function
public static double code(double x, double y, double z) {
	return (x * ((1.0 + y) / z)) - x;
}
def code(x, y, z):
	return (x * ((1.0 + y) / z)) - x
function code(x, y, z)
	return Float64(Float64(x * Float64(Float64(1.0 + y) / z)) - x)
end
function tmp = code(x, y, z)
	tmp = (x * ((1.0 + y) / z)) - x;
end
code[x_, y_, z_] := N[(N[(x * N[(N[(1.0 + y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \frac{1 + y}{z} - x
\end{array}
Derivation
  1. Initial program 88.4%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1 + y}{z} \cdot x - x} \]
  7. Final simplification98.0%

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

Alternative 11: 65.3% 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 77.2%

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

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

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

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

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

      \[\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. Step-by-step derivation
      1. associate-/l*96.4%

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

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

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

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

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

Alternative 12: 38.9% 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.4%

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

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

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

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

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

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

    \[\leadsto -x \]

Developer target: 99.5% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\
\mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\
\;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023258 
(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))