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

Percentage Accurate: 88.7% → 99.6%
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.7% 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.6% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.2e-16 or 4.99999999999999979e-75 < z

    1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

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

    if -2.2e-16 < z < 4.99999999999999979e-75

    1. Initial program 99.9%

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

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

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

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

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

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

Alternative 2: 60.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{y}{z}\\ \mathbf{if}\;z \leq -1.05 \cdot 10^{+117}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -47000000000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-264}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{+21}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (/ y z))))
   (if (<= z -1.05e+117)
     (- x)
     (if (<= z -47000000000000.0)
       t_0
       (if (<= z 1.35e-264) (/ x z) (if (<= z 1.8e+21) t_0 (- x)))))))
double code(double x, double y, double z) {
	double t_0 = x * (y / z);
	double tmp;
	if (z <= -1.05e+117) {
		tmp = -x;
	} else if (z <= -47000000000000.0) {
		tmp = t_0;
	} else if (z <= 1.35e-264) {
		tmp = x / z;
	} else if (z <= 1.8e+21) {
		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 <= (-1.05d+117)) then
        tmp = -x
    else if (z <= (-47000000000000.0d0)) then
        tmp = t_0
    else if (z <= 1.35d-264) then
        tmp = x / z
    else if (z <= 1.8d+21) 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 <= -1.05e+117) {
		tmp = -x;
	} else if (z <= -47000000000000.0) {
		tmp = t_0;
	} else if (z <= 1.35e-264) {
		tmp = x / z;
	} else if (z <= 1.8e+21) {
		tmp = t_0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (y / z)
	tmp = 0
	if z <= -1.05e+117:
		tmp = -x
	elif z <= -47000000000000.0:
		tmp = t_0
	elif z <= 1.35e-264:
		tmp = x / z
	elif z <= 1.8e+21:
		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 <= -1.05e+117)
		tmp = Float64(-x);
	elseif (z <= -47000000000000.0)
		tmp = t_0;
	elseif (z <= 1.35e-264)
		tmp = Float64(x / z);
	elseif (z <= 1.8e+21)
		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 <= -1.05e+117)
		tmp = -x;
	elseif (z <= -47000000000000.0)
		tmp = t_0;
	elseif (z <= 1.35e-264)
		tmp = x / z;
	elseif (z <= 1.8e+21)
		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, -1.05e+117], (-x), If[LessEqual[z, -47000000000000.0], t$95$0, If[LessEqual[z, 1.35e-264], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.8e+21], t$95$0, (-x)]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -47000000000000:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;z \leq 1.8 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.0500000000000001e117 or 1.8e21 < z

    1. Initial program 61.0%

      \[\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}} \]
      2. +-commutative99.9%

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

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

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

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

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

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

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

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

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

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

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

    if -1.0500000000000001e117 < z < -4.7e13 or 1.34999999999999997e-264 < z < 1.8e21

    1. Initial program 95.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.7e13 < z < 1.34999999999999997e-264

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x}{z} + \color{blue}{\left(-x\right)} \]
      7. unsub-neg61.5%

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    7. Simplified61.5%

      \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    8. Taylor expanded in z around 0 57.0%

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

Alternative 3: 98.7% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 68.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}} \]
      2. +-commutative99.8%

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

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

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

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

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

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

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

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

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

    if -0.81000000000000005 < z < 1

    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 98.4%

      \[\leadsto \color{blue}{\frac{x + x \cdot y}{z}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity98.4%

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

        \[\leadsto \frac{1 \cdot x + \color{blue}{y \cdot x}}{z} \]
      3. distribute-rgt-out98.4%

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

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

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

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

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

Alternative 4: 94.7% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 85.8%

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

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

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

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

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

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

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

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

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

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

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

    if -2.35e7 < y < 0.0051999999999999998

    1. Initial program 83.7%

      \[\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}} \]
      2. +-commutative99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x}{z} + \color{blue}{\left(-x\right)} \]
      7. unsub-neg98.8%

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    7. Simplified98.8%

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

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

Alternative 5: 98.7% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 66.4%

      \[\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}} \]
      2. +-commutative99.8%

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

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

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

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

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

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

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

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

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

    if -0.94999999999999996 < z < 1

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

    if 1 < z

    1. Initial program 69.6%

      \[\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}} \]
      2. +-commutative99.8%

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

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

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

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

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

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

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

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

      \[\leadsto x \cdot \left(\frac{\color{blue}{y}}{z} + -1\right) \]
    6. Step-by-step derivation
      1. distribute-rgt-in98.8%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x + -1 \cdot x} \]
      2. neg-mul-198.8%

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

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x - x} \]
      4. *-commutative98.8%

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

      \[\leadsto \color{blue}{x \cdot \frac{y}{z} - x} \]
    8. Step-by-step derivation
      1. clear-num98.7%

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

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

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

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

Alternative 6: 98.7% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 66.4%

      \[\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}} \]
      2. +-commutative99.8%

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

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

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

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

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

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

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

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

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

    if -0.95999999999999996 < z < 1

    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 98.4%

      \[\leadsto \color{blue}{\frac{x + x \cdot y}{z}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity98.4%

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

        \[\leadsto \frac{1 \cdot x + \color{blue}{y \cdot x}}{z} \]
      3. distribute-rgt-out98.4%

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

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

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

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

    if 1 < z

    1. Initial program 69.6%

      \[\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}} \]
      2. +-commutative99.8%

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

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

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

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

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

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

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

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

      \[\leadsto x \cdot \left(\frac{\color{blue}{y}}{z} + -1\right) \]
    6. Step-by-step derivation
      1. distribute-rgt-in98.8%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x + -1 \cdot x} \]
      2. neg-mul-198.8%

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

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x - x} \]
      4. *-commutative98.8%

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

      \[\leadsto \color{blue}{x \cdot \frac{y}{z} - x} \]
    8. Step-by-step derivation
      1. clear-num98.7%

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

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

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

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

Alternative 7: 98.7% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 66.4%

      \[\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}} \]
      2. +-commutative99.8%

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

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

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

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

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

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

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

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

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

    if -0.880000000000000004 < z < 1

    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 98.4%

      \[\leadsto \color{blue}{\frac{x + x \cdot y}{z}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity98.4%

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

        \[\leadsto \frac{1 \cdot x + \color{blue}{y \cdot x}}{z} \]
      3. distribute-rgt-out98.4%

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

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

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

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

    if 1 < z

    1. Initial program 69.6%

      \[\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}} \]
      2. +-commutative99.8%

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

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

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

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

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

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

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

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

      \[\leadsto x \cdot \left(\frac{\color{blue}{y}}{z} + -1\right) \]
    6. Step-by-step derivation
      1. distribute-rgt-in98.8%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x + -1 \cdot x} \]
      2. neg-mul-198.8%

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

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x - x} \]
      4. *-commutative98.8%

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

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

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

Alternative 8: 85.1% accurate, 0.6× speedup?

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

    1. Initial program 87.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x + x \cdot y}{z}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity74.3%

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

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

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

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

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

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

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

    if -7.00000000000000003e38 < y < 1.6e17

    1. Initial program 82.0%

      \[\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}} \]
      2. +-commutative99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    7. Simplified97.3%

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

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

Alternative 9: 63.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{+117} \lor \neg \left(z \leq 1.1 \cdot 10^{+20}\right):\\
\;\;\;\;-x\\

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


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

    1. Initial program 61.0%

      \[\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}} \]
      2. +-commutative99.9%

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

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

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

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

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

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

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

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

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

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

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

    if -1.0500000000000001e117 < z < 1.1e20

    1. Initial program 97.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x + x \cdot y}{z}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity90.2%

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

        \[\leadsto \frac{1 \cdot x + \color{blue}{y \cdot x}}{z} \]
      3. distribute-rgt-out90.2%

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

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

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

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

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

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

Alternative 10: 94.1% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.2 \cdot 10^{-36}:\\
\;\;\;\;\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\\

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


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

    1. Initial program 91.0%

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

    if 9.19999999999999986e-36 < x

    1. Initial program 72.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + 1}}} + x \cdot -1 \]
      4. *-commutative100.0%

        \[\leadsto \frac{x}{\frac{z}{y + 1}} + \color{blue}{-1 \cdot x} \]
      5. mul-1-neg100.0%

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

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

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

Alternative 11: 94.0% accurate, 0.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4.59999999999999993e36

    1. Initial program 91.8%

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

    if 4.59999999999999993e36 < x

    1. Initial program 66.4%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative66.4%

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

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

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

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

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

Alternative 12: 64.4% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 67.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}} \]
      2. +-commutative99.8%

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

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

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

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

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

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

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

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

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

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

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

    if -1 < z < 15.199999999999999

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x}{z} + \color{blue}{\left(-x\right)} \]
      7. unsub-neg53.6%

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

      \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    8. Taylor expanded in z around 0 52.1%

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

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

Alternative 13: 38.5% 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 84.9%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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 84.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0 - x} \]
    2. sub-neg34.6%

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

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

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

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

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

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

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

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

Developer Target 1: 99.4% 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 2024123 
(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))