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

Percentage Accurate: 88.0% → 99.8%
Time: 8.2s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 88.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.42e-5 or 1.8500000000000002e-30 < z

    1. Initial program 67.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.42e-5 < z < 1.8500000000000002e-30

    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-def99.9%

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

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

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

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

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

Alternative 2: 84.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;y \leq -1.15 \cdot 10^{+69}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{+47}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{+16} \lor \neg \left(y \leq 1.65 \cdot 10^{+15}\right) \land \left(y \leq 1.86 \cdot 10^{+56} \lor \neg \left(y \leq 4.6 \cdot 10^{+116}\right)\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} - x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= y -1.15e+69)
     t_0
     (if (<= y -5.8e+47)
       (- x)
       (if (or (<= y -6.5e+16)
               (and (not (<= y 1.65e+15))
                    (or (<= y 1.86e+56) (not (<= y 4.6e+116)))))
         t_0
         (- (/ x z) x))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (y <= -1.15e+69) {
		tmp = t_0;
	} else if (y <= -5.8e+47) {
		tmp = -x;
	} else if ((y <= -6.5e+16) || (!(y <= 1.65e+15) && ((y <= 1.86e+56) || !(y <= 4.6e+116)))) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = y * (x / z)
    if (y <= (-1.15d+69)) then
        tmp = t_0
    else if (y <= (-5.8d+47)) then
        tmp = -x
    else if ((y <= (-6.5d+16)) .or. (.not. (y <= 1.65d+15)) .and. (y <= 1.86d+56) .or. (.not. (y <= 4.6d+116))) then
        tmp = t_0
    else
        tmp = (x / z) - 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 (y <= -1.15e+69) {
		tmp = t_0;
	} else if (y <= -5.8e+47) {
		tmp = -x;
	} else if ((y <= -6.5e+16) || (!(y <= 1.65e+15) && ((y <= 1.86e+56) || !(y <= 4.6e+116)))) {
		tmp = t_0;
	} else {
		tmp = (x / z) - x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if y <= -1.15e+69:
		tmp = t_0
	elif y <= -5.8e+47:
		tmp = -x
	elif (y <= -6.5e+16) or (not (y <= 1.65e+15) and ((y <= 1.86e+56) or not (y <= 4.6e+116))):
		tmp = t_0
	else:
		tmp = (x / z) - x
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(x / z))
	tmp = 0.0
	if (y <= -1.15e+69)
		tmp = t_0;
	elseif (y <= -5.8e+47)
		tmp = Float64(-x);
	elseif ((y <= -6.5e+16) || (!(y <= 1.65e+15) && ((y <= 1.86e+56) || !(y <= 4.6e+116))))
		tmp = t_0;
	else
		tmp = Float64(Float64(x / z) - x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (x / z);
	tmp = 0.0;
	if (y <= -1.15e+69)
		tmp = t_0;
	elseif (y <= -5.8e+47)
		tmp = -x;
	elseif ((y <= -6.5e+16) || (~((y <= 1.65e+15)) && ((y <= 1.86e+56) || ~((y <= 4.6e+116)))))
		tmp = t_0;
	else
		tmp = (x / z) - x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.15e+69], t$95$0, If[LessEqual[y, -5.8e+47], (-x), If[Or[LessEqual[y, -6.5e+16], And[N[Not[LessEqual[y, 1.65e+15]], $MachinePrecision], Or[LessEqual[y, 1.86e+56], N[Not[LessEqual[y, 4.6e+116]], $MachinePrecision]]]], t$95$0, N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;y \leq -1.15 \cdot 10^{+69}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -5.8 \cdot 10^{+47}:\\
\;\;\;\;-x\\

\mathbf{elif}\;y \leq -6.5 \cdot 10^{+16} \lor \neg \left(y \leq 1.65 \cdot 10^{+15}\right) \land \left(y \leq 1.86 \cdot 10^{+56} \lor \neg \left(y \leq 4.6 \cdot 10^{+116}\right)\right):\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.15000000000000008e69 or -5.79999999999999961e47 < y < -6.5e16 or 1.65e15 < y < 1.86000000000000007e56 or 4.5999999999999999e116 < y

    1. Initial program 90.1%

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

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

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

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

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

    if -1.15000000000000008e69 < y < -5.79999999999999961e47

    1. Initial program 42.9%

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

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

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

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

    if -6.5e16 < y < 1.65e15 or 1.86000000000000007e56 < y < 4.5999999999999999e116

    1. Initial program 81.2%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    6. Simplified96.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.15 \cdot 10^{+69}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{+47}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{+16} \lor \neg \left(y \leq 1.65 \cdot 10^{+15}\right) \land \left(y \leq 1.86 \cdot 10^{+56} \lor \neg \left(y \leq 4.6 \cdot 10^{+116}\right)\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} - x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 84.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;y \leq -1.1 \cdot 10^{+69}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{+50}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{+16}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{+16} \lor \neg \left(y \leq 1.25 \cdot 10^{+55}\right) \land y \leq 9.2 \cdot 10^{+115}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= y -1.1e+69)
     t_0
     (if (<= y -1.3e+50)
       (- x)
       (if (<= y -1.45e+16)
         (/ y (/ z x))
         (if (or (<= y 1.7e+16) (and (not (<= y 1.25e+55)) (<= y 9.2e+115)))
           (- (/ x z) x)
           t_0))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (y <= -1.1e+69) {
		tmp = t_0;
	} else if (y <= -1.3e+50) {
		tmp = -x;
	} else if (y <= -1.45e+16) {
		tmp = y / (z / x);
	} else if ((y <= 1.7e+16) || (!(y <= 1.25e+55) && (y <= 9.2e+115))) {
		tmp = (x / z) - x;
	} 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 = y * (x / z)
    if (y <= (-1.1d+69)) then
        tmp = t_0
    else if (y <= (-1.3d+50)) then
        tmp = -x
    else if (y <= (-1.45d+16)) then
        tmp = y / (z / x)
    else if ((y <= 1.7d+16) .or. (.not. (y <= 1.25d+55)) .and. (y <= 9.2d+115)) then
        tmp = (x / z) - x
    else
        tmp = t_0
    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 (y <= -1.1e+69) {
		tmp = t_0;
	} else if (y <= -1.3e+50) {
		tmp = -x;
	} else if (y <= -1.45e+16) {
		tmp = y / (z / x);
	} else if ((y <= 1.7e+16) || (!(y <= 1.25e+55) && (y <= 9.2e+115))) {
		tmp = (x / z) - x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if y <= -1.1e+69:
		tmp = t_0
	elif y <= -1.3e+50:
		tmp = -x
	elif y <= -1.45e+16:
		tmp = y / (z / x)
	elif (y <= 1.7e+16) or (not (y <= 1.25e+55) and (y <= 9.2e+115)):
		tmp = (x / z) - x
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(x / z))
	tmp = 0.0
	if (y <= -1.1e+69)
		tmp = t_0;
	elseif (y <= -1.3e+50)
		tmp = Float64(-x);
	elseif (y <= -1.45e+16)
		tmp = Float64(y / Float64(z / x));
	elseif ((y <= 1.7e+16) || (!(y <= 1.25e+55) && (y <= 9.2e+115)))
		tmp = Float64(Float64(x / z) - x);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (x / z);
	tmp = 0.0;
	if (y <= -1.1e+69)
		tmp = t_0;
	elseif (y <= -1.3e+50)
		tmp = -x;
	elseif (y <= -1.45e+16)
		tmp = y / (z / x);
	elseif ((y <= 1.7e+16) || (~((y <= 1.25e+55)) && (y <= 9.2e+115)))
		tmp = (x / z) - x;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.1e+69], t$95$0, If[LessEqual[y, -1.3e+50], (-x), If[LessEqual[y, -1.45e+16], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.7e+16], And[N[Not[LessEqual[y, 1.25e+55]], $MachinePrecision], LessEqual[y, 9.2e+115]]], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;y \leq -1.1 \cdot 10^{+69}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -1.3 \cdot 10^{+50}:\\
\;\;\;\;-x\\

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

\mathbf{elif}\;y \leq 1.7 \cdot 10^{+16} \lor \neg \left(y \leq 1.25 \cdot 10^{+55}\right) \land y \leq 9.2 \cdot 10^{+115}:\\
\;\;\;\;\frac{x}{z} - x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.1000000000000001e69 or 1.7e16 < y < 1.25000000000000011e55 or 9.20000000000000014e115 < y

    1. Initial program 89.1%

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

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

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

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

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

    if -1.1000000000000001e69 < y < -1.3000000000000001e50

    1. Initial program 42.9%

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

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

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

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

    if -1.3000000000000001e50 < y < -1.45e16

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

    if -1.45e16 < y < 1.7e16 or 1.25000000000000011e55 < y < 9.20000000000000014e115

    1. Initial program 81.2%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{z} - x} \]
    6. Simplified96.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.1 \cdot 10^{+69}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{+50}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{+16}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{+16} \lor \neg \left(y \leq 1.25 \cdot 10^{+55}\right) \land y \leq 9.2 \cdot 10^{+115}:\\ \;\;\;\;\frac{x}{z} - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 64.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -5.9 \cdot 10^{+23}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -1.18 \cdot 10^{-225}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{-287}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 6.4 \cdot 10^{-150}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{+19}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (/ x z))))
   (if (<= z -5.9e+23)
     (- x)
     (if (<= z -1.18e-225)
       t_0
       (if (<= z 1.85e-287)
         (/ x z)
         (if (<= z 6.4e-150) t_0 (if (<= z 3.3e+19) (/ x z) (- x))))))))
double code(double x, double y, double z) {
	double t_0 = y * (x / z);
	double tmp;
	if (z <= -5.9e+23) {
		tmp = -x;
	} else if (z <= -1.18e-225) {
		tmp = t_0;
	} else if (z <= 1.85e-287) {
		tmp = x / z;
	} else if (z <= 6.4e-150) {
		tmp = t_0;
	} else if (z <= 3.3e+19) {
		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 = y * (x / z)
    if (z <= (-5.9d+23)) then
        tmp = -x
    else if (z <= (-1.18d-225)) then
        tmp = t_0
    else if (z <= 1.85d-287) then
        tmp = x / z
    else if (z <= 6.4d-150) then
        tmp = t_0
    else if (z <= 3.3d+19) 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 = y * (x / z);
	double tmp;
	if (z <= -5.9e+23) {
		tmp = -x;
	} else if (z <= -1.18e-225) {
		tmp = t_0;
	} else if (z <= 1.85e-287) {
		tmp = x / z;
	} else if (z <= 6.4e-150) {
		tmp = t_0;
	} else if (z <= 3.3e+19) {
		tmp = x / z;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (x / z)
	tmp = 0
	if z <= -5.9e+23:
		tmp = -x
	elif z <= -1.18e-225:
		tmp = t_0
	elif z <= 1.85e-287:
		tmp = x / z
	elif z <= 6.4e-150:
		tmp = t_0
	elif z <= 3.3e+19:
		tmp = x / z
	else:
		tmp = -x
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(x / z))
	tmp = 0.0
	if (z <= -5.9e+23)
		tmp = Float64(-x);
	elseif (z <= -1.18e-225)
		tmp = t_0;
	elseif (z <= 1.85e-287)
		tmp = Float64(x / z);
	elseif (z <= 6.4e-150)
		tmp = t_0;
	elseif (z <= 3.3e+19)
		tmp = Float64(x / z);
	else
		tmp = Float64(-x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (x / z);
	tmp = 0.0;
	if (z <= -5.9e+23)
		tmp = -x;
	elseif (z <= -1.18e-225)
		tmp = t_0;
	elseif (z <= 1.85e-287)
		tmp = x / z;
	elseif (z <= 6.4e-150)
		tmp = t_0;
	elseif (z <= 3.3e+19)
		tmp = x / z;
	else
		tmp = -x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5.9e+23], (-x), If[LessEqual[z, -1.18e-225], t$95$0, If[LessEqual[z, 1.85e-287], N[(x / z), $MachinePrecision], If[LessEqual[z, 6.4e-150], t$95$0, If[LessEqual[z, 3.3e+19], N[(x / z), $MachinePrecision], (-x)]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -1.18 \cdot 10^{-225}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;z \leq 6.4 \cdot 10^{-150}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 3.3 \cdot 10^{+19}:\\
\;\;\;\;\frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.89999999999999987e23 or 3.3e19 < z

    1. Initial program 64.4%

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

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

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

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

    if -5.89999999999999987e23 < z < -1.18e-225 or 1.85000000000000013e-287 < z < 6.3999999999999996e-150

    1. Initial program 98.9%

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

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

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

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

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

    if -1.18e-225 < z < 1.85000000000000013e-287 or 6.3999999999999996e-150 < z < 3.3e19

    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-def99.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.9 \cdot 10^{+23}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq -1.18 \cdot 10^{-225}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{-287}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 6.4 \cdot 10^{-150}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{+19}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 94.8% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 95.9%

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

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

    if -4.79999999999999971e187 < y < -1 or 0.00730000000000000007 < y

    1. Initial program 85.0%

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

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

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

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

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

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

    if -1 < y < 0.00730000000000000007

    1. Initial program 81.2%

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

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

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

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

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

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

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

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

Alternative 6: 94.8% accurate, 0.4× speedup?

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

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

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

\mathbf{elif}\;y \leq 0.0073:\\
\;\;\;\;\frac{x}{z} - x\\

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


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

    1. Initial program 95.9%

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

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

    if -3.99999999999999963e187 < y < -1

    1. Initial program 84.8%

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

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

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

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

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

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

    if -1 < y < 0.00730000000000000007

    1. Initial program 81.2%

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

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

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

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

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

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

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

    if 0.00730000000000000007 < y

    1. Initial program 85.1%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 98.9% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 66.9%

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

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

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

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

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

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

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

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

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

    if -1.1000000000000001 < 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-def99.9%

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

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

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

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

    if 1 < z

    1. Initial program 66.3%

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

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

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

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

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

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

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

Alternative 8: 98.0% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 91.1%

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

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

    if 3.2000000000000002e-8 < x

    1. Initial program 63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 93.8% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 90.8%

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

    if 2.20000000000000017e-62 < x

    1. Initial program 66.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 93.9% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 91.1%

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

    if 2e-8 < x

    1. Initial program 63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 64.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 3.3 \cdot 10^{+19}\right):\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1.0) (not (<= z 3.3e+19))) (- x) (/ x z)))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 3.3e+19)) {
		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 <= 3.3d+19))) 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 <= 3.3e+19)) {
		tmp = -x;
	} else {
		tmp = x / z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1.0) or not (z <= 3.3e+19):
		tmp = -x
	else:
		tmp = x / z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.0) || !(z <= 3.3e+19))
		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 <= 3.3e+19)))
		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, 3.3e+19]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 66.1%

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

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

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

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

    if -1 < z < 3.3e19

    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-def99.9%

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

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

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

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

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

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

Alternative 12: 39.0% accurate, 4.5× speedup?

\[\begin{array}{l} \\ -x \end{array} \]
(FPCore (x y z) :precision binary64 (- x))
double code(double x, double y, double z) {
	return -x;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = -x
end function
public static double code(double x, double y, double z) {
	return -x;
}
def code(x, y, z):
	return -x
function code(x, y, z)
	return Float64(-x)
end
function tmp = code(x, y, z)
	tmp = -x;
end
code[x_, y_, z_] := (-x)
\begin{array}{l}

\\
-x
\end{array}
Derivation
  1. Initial program 84.2%

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

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

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

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

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

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

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

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