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

Percentage Accurate: 88.2% → 99.9%
Time: 13.3s
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.2% 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} t_0 := y + \left(1 - z\right)\\ t_1 := \frac{x}{\frac{z}{t\_0}}\\ \mathbf{if}\;z \leq -5 \cdot 10^{-14}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-35}:\\ \;\;\;\;t\_0 \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ y (- 1.0 z))) (t_1 (/ x (/ z t_0))))
   (if (<= z -5e-14) t_1 (if (<= z 3e-35) (* t_0 (/ x z)) t_1))))
double code(double x, double y, double z) {
	double t_0 = y + (1.0 - z);
	double t_1 = x / (z / t_0);
	double tmp;
	if (z <= -5e-14) {
		tmp = t_1;
	} else if (z <= 3e-35) {
		tmp = t_0 * (x / z);
	} else {
		tmp = t_1;
	}
	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) :: t_1
    real(8) :: tmp
    t_0 = y + (1.0d0 - z)
    t_1 = x / (z / t_0)
    if (z <= (-5d-14)) then
        tmp = t_1
    else if (z <= 3d-35) then
        tmp = t_0 * (x / z)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y + (1.0 - z);
	double t_1 = x / (z / t_0);
	double tmp;
	if (z <= -5e-14) {
		tmp = t_1;
	} else if (z <= 3e-35) {
		tmp = t_0 * (x / z);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y + (1.0 - z)
	t_1 = x / (z / t_0)
	tmp = 0
	if z <= -5e-14:
		tmp = t_1
	elif z <= 3e-35:
		tmp = t_0 * (x / z)
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(y + Float64(1.0 - z))
	t_1 = Float64(x / Float64(z / t_0))
	tmp = 0.0
	if (z <= -5e-14)
		tmp = t_1;
	elseif (z <= 3e-35)
		tmp = Float64(t_0 * Float64(x / z));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y + (1.0 - z);
	t_1 = x / (z / t_0);
	tmp = 0.0;
	if (z <= -5e-14)
		tmp = t_1;
	elseif (z <= 3e-35)
		tmp = t_0 * (x / z);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(1.0 - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5e-14], t$95$1, If[LessEqual[z, 3e-35], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 3 \cdot 10^{-35}:\\
\;\;\;\;t\_0 \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.0000000000000002e-14 or 2.99999999999999989e-35 < z

    1. Initial program 78.8%

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

      \[\leadsto expr\]

    if -5.0000000000000002e-14 < z < 2.99999999999999989e-35

    1. Initial program 99.8%

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

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 65.7% accurate, 0.3× speedup?

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

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

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

\mathbf{elif}\;z \leq 6.2 \cdot 10^{-262}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 4.3 \cdot 10^{-202}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 2.3 \cdot 10^{-71}:\\
\;\;\;\;\frac{x}{z}\\

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

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


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

    1. Initial program 74.7%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in z around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]

    if -7.19999999999999938e38 < z < -1.1499999999999999e-59

    1. Initial program 99.7%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]

    if -1.1499999999999999e-59 < z < 6.1999999999999997e-262 or 4.29999999999999993e-202 < z < 2.2999999999999998e-71

    1. Initial program 99.8%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Taylor expanded in z around 0 0

      \[\leadsto expr\]
    7. Simplified0

      \[\leadsto expr\]

    if 6.1999999999999997e-262 < z < 4.29999999999999993e-202 or 2.2999999999999998e-71 < z < 6e12

    1. Initial program 99.8%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 3: 65.5% accurate, 0.4× speedup?

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

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

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

\mathbf{elif}\;z \leq 2.1 \cdot 10^{-71}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 3.8 \cdot 10^{+16}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -9.60000000000000069e38 or 3.8e16 < z

    1. Initial program 74.7%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in z around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]

    if -9.60000000000000069e38 < z < -4.19999999999999993e-59 or 2.1000000000000001e-71 < z < 3.8e16

    1. Initial program 99.7%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]

    if -4.19999999999999993e-59 < z < 2.1000000000000001e-71

    1. Initial program 99.8%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Taylor expanded in z around 0 0

      \[\leadsto expr\]
    7. Simplified0

      \[\leadsto expr\]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 99.8% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \leq 6500000000:\\
\;\;\;\;\left(y + \left(1 - z\right)\right) \cdot \frac{x}{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 < -3.6e-12

    1. Initial program 79.0%

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

      \[\leadsto expr\]
    3. Add Preprocessing

    if -3.6e-12 < z < 6.5e9

    1. Initial program 99.8%

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

      \[\leadsto expr\]

    if 6.5e9 < z

    1. Initial program 76.5%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 99.8% accurate, 0.5× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.1599999999999999e-15 or 3.00000000000000017e-47 < z

    1. Initial program 79.3%

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

      \[\leadsto expr\]
    3. Add Preprocessing

    if -1.1599999999999999e-15 < z < 3.00000000000000017e-47

    1. Initial program 99.8%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in z around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 98.3% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 77.7%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]

    if -1 < z < 9.99999999999999945e-21

    1. Initial program 99.8%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in z around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 94.2% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 77.7%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]

    if -1 < z < 9.99999999999999945e-21

    1. Initial program 99.8%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in z around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 94.8% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 88.7%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]

    if -2020 < y < 9.80000000000000065e-13

    1. Initial program 89.0%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 85.5% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 91.1%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]

    if -1.1499999999999999e47 < y < 1.89999999999999985e29

    1. Initial program 88.3%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]

    if 1.89999999999999985e29 < y

    1. Initial program 87.9%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 10: 85.5% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x}{z} \cdot y\\
\mathbf{if}\;y \leq -1620000:\\
\;\;\;\;t\_0\\

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

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


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

    1. Initial program 88.9%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]

    if -1.62e6 < y < 1.0500000000000001e29

    1. Initial program 88.8%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 93.9% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 92.0%

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

    if 2.0000000000000001e-114 < x

    1. Initial program 82.6%

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

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 64.9% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 76.8%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in z around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]

    if -1 < z < 2e11

    1. Initial program 99.8%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in y around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Taylor expanded in z around 0 0

      \[\leadsto expr\]
    7. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 13: 38.0% accurate, 4.5× speedup?

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

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

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Taylor expanded in z around inf 0

    \[\leadsto expr\]
  5. Simplified0

    \[\leadsto expr\]
  6. Applied egg-rr0

    \[\leadsto expr\]
  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 2024110 
(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))