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

Percentage Accurate: 88.1% → 99.7%
Time: 5.0s
Alternatives: 11
Speedup: 0.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 88.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 73.2%

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

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

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

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

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

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

    if -1.0999999999999999e35 < z < 950

    1. Initial program 99.9%

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

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

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

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

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

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

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

Alternative 2: 98.0% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 4e4

    1. Initial program 88.0%

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

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

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

    if 4e4 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z)

    1. Initial program 79.2%

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

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

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

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

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

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

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

Alternative 3: 64.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -2.65 \cdot 10^{+17}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-227}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.05 \cdot 10^{-140}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{-95}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{-5}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{+23}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= z -2.65e+17)
     (- x)
     (if (<= z 3.6e-227)
       t_0
       (if (<= z 2.05e-140)
         (/ x z)
         (if (<= z 4.6e-95)
           t_0
           (if (<= z 1.15e-5) (/ x z) (if (<= z 3.8e+23) t_0 (- x)))))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -2.65e+17) {
		tmp = -x;
	} else if (z <= 3.6e-227) {
		tmp = t_0;
	} else if (z <= 2.05e-140) {
		tmp = x / z;
	} else if (z <= 4.6e-95) {
		tmp = t_0;
	} else if (z <= 1.15e-5) {
		tmp = x / z;
	} else if (z <= 3.8e+23) {
		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 <= (-2.65d+17)) then
        tmp = -x
    else if (z <= 3.6d-227) then
        tmp = t_0
    else if (z <= 2.05d-140) then
        tmp = x / z
    else if (z <= 4.6d-95) then
        tmp = t_0
    else if (z <= 1.15d-5) then
        tmp = x / z
    else if (z <= 3.8d+23) 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 <= -2.65e+17) {
		tmp = -x;
	} else if (z <= 3.6e-227) {
		tmp = t_0;
	} else if (z <= 2.05e-140) {
		tmp = x / z;
	} else if (z <= 4.6e-95) {
		tmp = t_0;
	} else if (z <= 1.15e-5) {
		tmp = x / z;
	} else if (z <= 3.8e+23) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if z <= -2.65e+17:
		tmp = -x
	elif z <= 3.6e-227:
		tmp = t_0
	elif z <= 2.05e-140:
		tmp = x / z
	elif z <= 4.6e-95:
		tmp = t_0
	elif z <= 1.15e-5:
		tmp = x / z
	elif z <= 3.8e+23:
		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 <= -2.65e+17)
		tmp = Float64(-x);
	elseif (z <= 3.6e-227)
		tmp = t_0;
	elseif (z <= 2.05e-140)
		tmp = Float64(x / z);
	elseif (z <= 4.6e-95)
		tmp = t_0;
	elseif (z <= 1.15e-5)
		tmp = Float64(x / z);
	elseif (z <= 3.8e+23)
		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 <= -2.65e+17)
		tmp = -x;
	elseif (z <= 3.6e-227)
		tmp = t_0;
	elseif (z <= 2.05e-140)
		tmp = x / z;
	elseif (z <= 4.6e-95)
		tmp = t_0;
	elseif (z <= 1.15e-5)
		tmp = x / z;
	elseif (z <= 3.8e+23)
		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, -2.65e+17], (-x), If[LessEqual[z, 3.6e-227], t$95$0, If[LessEqual[z, 2.05e-140], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.6e-95], t$95$0, If[LessEqual[z, 1.15e-5], N[(x / z), $MachinePrecision], If[LessEqual[z, 3.8e+23], t$95$0, (-x)]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 3.6 \cdot 10^{-227}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;z \leq 4.6 \cdot 10^{-95}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;z \leq 3.8 \cdot 10^{+23}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.65e17 or 3.79999999999999975e23 < z

    1. Initial program 73.0%

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

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

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

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

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

    if -2.65e17 < z < 3.5999999999999999e-227 or 2.0500000000000001e-140 < z < 4.59999999999999998e-95 or 1.15e-5 < z < 3.79999999999999975e23

    1. Initial program 99.8%

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

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

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

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

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

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

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

    if 3.5999999999999999e-227 < z < 2.0500000000000001e-140 or 4.59999999999999998e-95 < z < 1.15e-5

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.65 \cdot 10^{+17}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-227}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 2.05 \cdot 10^{-140}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{-95}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{-5}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{+23}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]

Alternative 4: 95.2% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 88.5%

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x} - x \]
    5. Simplified90.5%

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

    if -1 < y < 1

    1. Initial program 82.3%

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

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

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

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

Alternative 5: 98.9% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 74.8%

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

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

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

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

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

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

    if -1 < z < 0.0015

    1. Initial program 99.9%

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

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

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

Alternative 6: 96.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;\frac{y}{\frac{z}{x}} - x\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;\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)
   (- (/ y (/ z x)) x)
   (if (<= y 1.0) (- (/ x z) x) (- (* x (/ y z)) x))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.0) {
		tmp = (y / (z / x)) - x;
	} else if (y <= 1.0) {
		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 = (y / (z / x)) - x
    else if (y <= 1.0d0) 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 = (y / (z / x)) - x;
	} else if (y <= 1.0) {
		tmp = (x / z) - x;
	} else {
		tmp = (x * (y / z)) - x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -1.0:
		tmp = (y / (z / x)) - x
	elif y <= 1.0:
		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(y / Float64(z / x)) - x);
	elseif (y <= 1.0)
		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 = (y / (z / x)) - x;
	elseif (y <= 1.0)
		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[(y / N[(z / x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[y, 1.0], 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{y}{\frac{z}{x}} - x\\

\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\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.5%

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

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} - x \]
    5. Simplified92.6%

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

    if -1 < y < 1

    1. Initial program 82.3%

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

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

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

    if 1 < y

    1. Initial program 90.5%

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x} - x \]
    5. Simplified94.1%

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

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

Alternative 7: 85.0% accurate, 1.0× speedup?

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

    1. Initial program 87.5%

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

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

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

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

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

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

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

    if -29500 < y < 1.54999999999999998e44

    1. Initial program 83.5%

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

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

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

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

Alternative 8: 85.0% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

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

    if -13200 < y < 7.9999999999999994e45

    1. Initial program 83.5%

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

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

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

    if 7.9999999999999994e45 < y

    1. Initial program 88.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 x around 0 88.6%

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

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

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

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

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

Alternative 9: 85.0% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

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

    if -3e4 < y < 3.9000000000000003e44

    1. Initial program 83.5%

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

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

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

    if 3.9000000000000003e44 < y

    1. Initial program 88.6%

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

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

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

Alternative 10: 65.5% accurate, 1.3× speedup?

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

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

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

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


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

    1. Initial program 74.6%

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

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

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

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

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

    if -2.1e9 < z < 0.0015

    1. Initial program 99.9%

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

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

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

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

Alternative 11: 38.8% 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 85.2%

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

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

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

      \[\leadsto \color{blue}{-x} \]
  5. Simplified44.6%

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

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