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

Percentage Accurate: 88.4% → 99.5%
Time: 7.9s
Alternatives: 14
Speedup: 0.6×

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 14 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.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 85.2%

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

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

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

    if -13.5 < z < 9.9999999999999996e-39

    1. Initial program 99.9%

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

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

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

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

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

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

    if 9.9999999999999996e-39 < z

    1. Initial program 81.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}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    3. Simplified99.8%

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

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

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

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

Alternative 2: 94.2% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-26}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y - z, x\right)}{z}\\

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


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

    1. Initial program 93.9%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, y - z, x\right)}{z}} \]
    4. Add Preprocessing

    if 1e-26 < x

    1. Initial program 82.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}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    3. Simplified99.9%

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

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

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

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

Alternative 3: 63.9% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;z \leq -5.6 \cdot 10^{-102}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;z \leq 1.3:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 80.9%

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

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

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

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

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

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

    if -5.79999999999999968e62 < z < -5.60000000000000026e-102 or 1.85e-99 < z < 1.30000000000000004

    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.8%

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

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

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

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

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

    if -5.60000000000000026e-102 < z < 1.85e-99

    1. Initial program 99.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{z}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 99.5% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 83.1%

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

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

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

    if -13.5 < z < 2.4999999999999999e-37

    1. Initial program 99.9%

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

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

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

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

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

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

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

Alternative 5: 92.9% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 93.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.3e23 < y < 1.5999999999999999e24

    1. Initial program 89.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot x}{z}} + -1 \cdot x \]
      8. *-lft-identity96.4%

        \[\leadsto \frac{\color{blue}{x}}{z} + -1 \cdot x \]
      9. neg-mul-196.4%

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

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

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

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

Alternative 6: 86.0% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \leq 0.017:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\

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


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

    1. Initial program 84.1%

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

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

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

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

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

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

    if -1.10000000000000001e80 < z < 0.017000000000000001

    1. Initial program 99.2%

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

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

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

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

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

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

    if 0.017000000000000001 < z

    1. Initial program 78.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{1 - z}{z}} \]
      2. div-sub76.3%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot x}{z}} + -1 \cdot x \]
      8. *-lft-identity76.3%

        \[\leadsto \frac{\color{blue}{x}}{z} + -1 \cdot x \]
      9. neg-mul-176.3%

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    11. Simplified76.3%

      \[\leadsto \color{blue}{\frac{x}{z} - x} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 7: 86.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.45 \cdot 10^{+24} \lor \neg \left(y \leq 1.7 \cdot 10^{+49}\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 -1.45e+24) (not (<= y 1.7e+49))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.45e+24) || !(y <= 1.7e+49)) {
		tmp = y * (x / z);
	} else {
		tmp = (x / z) - x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-1.45d+24)) .or. (.not. (y <= 1.7d+49))) then
        tmp = y * (x / z)
    else
        tmp = (x / z) - x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.45e+24) || !(y <= 1.7e+49)) {
		tmp = y * (x / z);
	} else {
		tmp = (x / z) - x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -1.45e+24) or not (y <= 1.7e+49):
		tmp = y * (x / z)
	else:
		tmp = (x / z) - x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -1.45e+24) || !(y <= 1.7e+49))
		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 <= -1.45e+24) || ~((y <= 1.7e+49)))
		tmp = y * (x / z);
	else
		tmp = (x / z) - x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.45e+24], N[Not[LessEqual[y, 1.7e+49]], $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 -1.45 \cdot 10^{+24} \lor \neg \left(y \leq 1.7 \cdot 10^{+49}\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 < -1.4499999999999999e24 or 1.7e49 < y

    1. Initial program 93.4%

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

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

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

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

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

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

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

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

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

    if -1.4499999999999999e24 < y < 1.7e49

    1. Initial program 89.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{1 - z}{z}} \]
      2. div-sub96.3%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot x}{z}} + -1 \cdot x \]
      8. *-lft-identity96.4%

        \[\leadsto \frac{\color{blue}{x}}{z} + -1 \cdot x \]
      9. neg-mul-196.4%

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

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

      \[\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 -1.45 \cdot 10^{+24} \lor \neg \left(y \leq 1.7 \cdot 10^{+49}\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} - x\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 65.5% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{+62} \lor \neg \left(z \leq 1.3\right):\\
\;\;\;\;-x\\

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


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

    1. Initial program 80.9%

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

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

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

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

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

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

    if -6.20000000000000029e62 < z < 1.30000000000000004

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

Alternative 9: 85.6% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;y \leq 2.8 \cdot 10^{+51}:\\
\;\;\;\;\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 < -1.50000000000000003e25

    1. Initial program 92.2%

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

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

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

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

    if -1.50000000000000003e25 < y < 2.80000000000000005e51

    1. Initial program 89.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{1 - z}{z}} \]
      2. div-sub96.3%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot x}{z}} + -1 \cdot x \]
      8. *-lft-identity96.4%

        \[\leadsto \frac{\color{blue}{x}}{z} + -1 \cdot x \]
      9. neg-mul-196.4%

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

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

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

    if 2.80000000000000005e51 < y

    1. Initial program 94.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{+25}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{+51}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 85.9% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;y \leq 1.65 \cdot 10^{+53}:\\
\;\;\;\;\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 < -3.60000000000000015e25

    1. Initial program 92.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.60000000000000015e25 < y < 1.6500000000000001e53

    1. Initial program 89.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{1 - z}{z}} \]
      2. div-sub96.3%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot x}{z}} + -1 \cdot x \]
      8. *-lft-identity96.4%

        \[\leadsto \frac{\color{blue}{x}}{z} + -1 \cdot x \]
      9. neg-mul-196.4%

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

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

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

    if 1.6500000000000001e53 < y

    1. Initial program 94.7%

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

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

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

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

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

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

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

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

      \[\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 -3.6 \cdot 10^{+25}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{+53}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 94.2% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 93.9%

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

    if 4.4999999999999998e-28 < x

    1. Initial program 82.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}{x \cdot \frac{\left(y - z\right) + 1}{z}} \]
    3. Simplified99.9%

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

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

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

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

Alternative 12: 64.0% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 81.9%

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

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

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

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

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

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

    if -13.5 < z < 1e-8

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

Alternative 13: 38.0% 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 91.0%

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

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

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

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

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

    \[\leadsto \color{blue}{-x} \]
  8. Add Preprocessing

Alternative 14: 3.0% accurate, 9.0× 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 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 91.0%

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

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

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

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

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

    \[\leadsto \color{blue}{-x} \]
  8. Step-by-step derivation
    1. neg-sub038.4%

      \[\leadsto \color{blue}{0 - x} \]
    2. sub-neg38.4%

      \[\leadsto \color{blue}{0 + \left(-x\right)} \]
    3. add-sqr-sqrt20.5%

      \[\leadsto 0 + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}} \]
    4. sqrt-unprod21.2%

      \[\leadsto 0 + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}} \]
    5. sqr-neg21.2%

      \[\leadsto 0 + \sqrt{\color{blue}{x \cdot x}} \]
    6. sqrt-unprod1.5%

      \[\leadsto 0 + \color{blue}{\sqrt{x} \cdot \sqrt{x}} \]
    7. add-sqr-sqrt3.0%

      \[\leadsto 0 + \color{blue}{x} \]
  9. Applied egg-rr3.0%

    \[\leadsto \color{blue}{0 + x} \]
  10. Taylor expanded in x around 0 3.0%

    \[\leadsto \color{blue}{x} \]
  11. Add Preprocessing

Developer Target 1: 99.5% accurate, 0.4× speedup?

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

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

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

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024172 
(FPCore (x y z)
  :name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
  :precision binary64

  :alt
  (! :herbie-platform default (if (< x -67870776678359/25000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (+ 1 y) (/ x z)) x) (if (< x 1937054408219773/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (* x (+ (- y z) 1)) (/ 1 z)) (- (* (+ 1 y) (/ x z)) x))))

  (/ (* x (+ (- y z) 1.0)) z))