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

Percentage Accurate: 88.1% → 99.9%
Time: 8.4s
Alternatives: 13
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 13 alternatives:

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

Initial Program: 88.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.0000000000000003e-15 or 2.49999999999999986e-21 < z

    1. Initial program 76.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}} \]
      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. metadata-eval99.9%

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

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

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

    if -4.0000000000000003e-15 < z < 2.49999999999999986e-21

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 66.0% accurate, 0.3× speedup?

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

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

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

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

\mathbf{elif}\;z \leq 4.2 \cdot 10^{-195}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;z \leq 7 \cdot 10^{+18}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.2e20 or 7e18 < z

    1. Initial program 73.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.2e20 < z < -0.029499999999999998 or -3.49999999999999988e-230 < z < 4.2e-195 or 2.14999999999999983e-30 < z < 7e18

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.029499999999999998 < z < -3.49999999999999988e-230 or 4.2e-195 < z < 2.14999999999999983e-30

    1. Initial program 99.9%

      \[\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*96.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. metadata-eval96.2%

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

        \[\leadsto x \cdot \left(\frac{\color{blue}{y + 1}}{z} + -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 0 97.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.2 \cdot 10^{+20}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -0.0295:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{-230}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-195}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 2.15 \cdot 10^{-30}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 7 \cdot 10^{+18}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 64.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{y}{z}\\ \mathbf{if}\;z \leq -9.5 \cdot 10^{+24}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -0.0295:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 9.2 \cdot 10^{-241}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-195}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (/ y z))))
   (if (<= z -9.5e+24)
     (- x)
     (if (<= z -0.0295)
       t_0
       (if (<= z 9.2e-241)
         (/ x z)
         (if (<= z 6.6e-195) t_0 (if (<= z 1.0) (/ x z) (- x))))))))
double code(double x, double y, double z) {
	double t_0 = x * (y / z);
	double tmp;
	if (z <= -9.5e+24) {
		tmp = -x;
	} else if (z <= -0.0295) {
		tmp = t_0;
	} else if (z <= 9.2e-241) {
		tmp = x / z;
	} else if (z <= 6.6e-195) {
		tmp = t_0;
	} else if (z <= 1.0) {
		tmp = x / z;
	} else {
		tmp = -x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x * (y / z)
    if (z <= (-9.5d+24)) then
        tmp = -x
    else if (z <= (-0.0295d0)) then
        tmp = t_0
    else if (z <= 9.2d-241) then
        tmp = x / z
    else if (z <= 6.6d-195) then
        tmp = t_0
    else if (z <= 1.0d0) then
        tmp = x / z
    else
        tmp = -x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (y / z);
	double tmp;
	if (z <= -9.5e+24) {
		tmp = -x;
	} else if (z <= -0.0295) {
		tmp = t_0;
	} else if (z <= 9.2e-241) {
		tmp = x / z;
	} else if (z <= 6.6e-195) {
		tmp = t_0;
	} else if (z <= 1.0) {
		tmp = x / z;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (y / z)
	tmp = 0
	if z <= -9.5e+24:
		tmp = -x
	elif z <= -0.0295:
		tmp = t_0
	elif z <= 9.2e-241:
		tmp = x / z
	elif z <= 6.6e-195:
		tmp = t_0
	elif z <= 1.0:
		tmp = x / z
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(y / z))
	tmp = 0.0
	if (z <= -9.5e+24)
		tmp = Float64(-x);
	elseif (z <= -0.0295)
		tmp = t_0;
	elseif (z <= 9.2e-241)
		tmp = Float64(x / z);
	elseif (z <= 6.6e-195)
		tmp = t_0;
	elseif (z <= 1.0)
		tmp = Float64(x / z);
	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 <= -9.5e+24)
		tmp = -x;
	elseif (z <= -0.0295)
		tmp = t_0;
	elseif (z <= 9.2e-241)
		tmp = x / z;
	elseif (z <= 6.6e-195)
		tmp = t_0;
	elseif (z <= 1.0)
		tmp = x / z;
	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, -9.5e+24], (-x), If[LessEqual[z, -0.0295], t$95$0, If[LessEqual[z, 9.2e-241], N[(x / z), $MachinePrecision], If[LessEqual[z, 6.6e-195], t$95$0, If[LessEqual[z, 1.0], N[(x / z), $MachinePrecision], (-x)]]]]]]
\begin{array}{l}

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

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

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

\mathbf{elif}\;z \leq 6.6 \cdot 10^{-195}:\\
\;\;\;\;t\_0\\

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

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


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

    1. Initial program 74.4%

      \[\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-sub100.0%

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

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

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

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

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

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

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

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

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

    if -9.5000000000000001e24 < z < -0.029499999999999998 or 9.1999999999999997e-241 < z < 6.6e-195

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.029499999999999998 < z < 9.1999999999999997e-241 or 6.6e-195 < 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*92.8%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -9.5 \cdot 10^{+24}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -0.0295:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 9.2 \cdot 10^{-241}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{-195}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 93.9% accurate, 0.5× speedup?

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

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

    if -1.49999999999999988e27 < y < 1

    1. Initial program 86.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}} \]
      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. metadata-eval99.9%

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

        \[\leadsto x \cdot \left(\frac{\color{blue}{y + 1}}{z} + -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 98.8%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 98.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{+20} \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 -4e+20) (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 <= -4e+20) || !(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 <= (-4d+20)) .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 <= -4e+20) || !(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 <= -4e+20) 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 <= -4e+20) || !(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 <= -4e+20) || ~((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, -4e+20], 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 -4 \cdot 10^{+20} \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 < -4e20 or 1 < z

    1. Initial program 74.4%

      \[\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-sub100.0%

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

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

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

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

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

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

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

    if -4e20 < 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-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. metadata-eval93.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{+20} \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 6: 98.2% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 74.6%

      \[\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-sub100.0%

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

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

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

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

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

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

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

    if -4.5e18 < 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-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. metadata-eval93.0%

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

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

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

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

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

Alternative 7: 98.2% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 74.8%

      \[\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. metadata-eval99.9%

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

        \[\leadsto x \cdot \left(\frac{\color{blue}{y + 1}}{z} + -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-num100.0%

        \[\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)} \]
    7. Taylor expanded in y around inf 99.5%

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

    if -6.4e16 < 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*92.9%

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

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

        \[\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. metadata-eval92.9%

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

        \[\leadsto x \cdot \left(\frac{\color{blue}{y + 1}}{z} + -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.0%

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

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

Alternative 8: 85.3% accurate, 0.6× speedup?

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

    1. Initial program 89.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.85000000000000001e27 < y < 4.1999999999999999e111

    1. Initial program 85.4%

      \[\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. metadata-eval99.9%

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

        \[\leadsto x \cdot \left(\frac{\color{blue}{y + 1}}{z} + -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 98.4%

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

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

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

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

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

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

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

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

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

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

Alternative 9: 85.2% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{+27} \lor \neg \left(y \leq 2.7 \cdot 10^{+110}\right):\\
\;\;\;\;\frac{x \cdot y}{z}\\

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


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

    1. Initial program 89.9%

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

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

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

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

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

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

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

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

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

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

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

    if -1.85000000000000001e27 < y < 2.7000000000000001e110

    1. Initial program 85.4%

      \[\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. metadata-eval99.9%

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

        \[\leadsto x \cdot \left(\frac{\color{blue}{y + 1}}{z} + -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 98.4%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 94.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 5 \cdot 10^{-54}:\\ \;\;\;\;\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 5e-54) (/ (* x (+ (- y z) 1.0)) z) (- (/ x (/ z (+ y 1.0))) x)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= 5e-54) {
		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 <= 5d-54) 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 <= 5e-54) {
		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 <= 5e-54:
		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 <= 5e-54)
		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 <= 5e-54)
		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, 5e-54], 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 5 \cdot 10^{-54}:\\
\;\;\;\;\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 < 5.00000000000000015e-54

    1. Initial program 89.8%

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

    if 5.00000000000000015e-54 < x

    1. Initial program 81.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. metadata-eval99.8%

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

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

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

        \[\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-inv99.9%

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

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

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

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

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

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

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


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

    1. Initial program 89.8%

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

    if 6.00000000000000018e-54 < x

    1. Initial program 81.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. metadata-eval99.8%

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

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

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

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

Alternative 12: 64.6% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 75.2%

      \[\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. metadata-eval99.9%

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

        \[\leadsto x \cdot \left(\frac{\color{blue}{y + 1}}{z} + -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 79.3%

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

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

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

    if -6 < 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*92.8%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6 \lor \neg \left(z \leq 1\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 87.1%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-x} \]
  8. Final simplification43.0%

    \[\leadsto -x \]
  9. Add Preprocessing

Developer target: 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 2024071 
(FPCore (x y z)
  :name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
  :precision binary64

  :alt
  (if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))

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