Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C

Percentage Accurate: 94.6% → 98.6%
Time: 8.7s
Alternatives: 9
Speedup: 0.2×

Specification

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

\\
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\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 9 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: 94.6% accurate, 1.0× speedup?

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

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

Alternative 1: 98.6% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \frac{x}{z}\\ t_2 := \frac{y}{z} + \frac{t}{z + -1}\\ t_3 := t\_2 \cdot x\\ \mathbf{if}\;t\_2 \leq -\infty:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq -1 \cdot 10^{-180}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-130}:\\ \;\;\;\;\frac{x \cdot \left(y + t\right)}{z}\\ \mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+294}:\\ \;\;\;\;t\_3\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* y (/ x z))) (t_2 (+ (/ y z) (/ t (+ z -1.0)))) (t_3 (* t_2 x)))
   (if (<= t_2 (- INFINITY))
     t_1
     (if (<= t_2 -1e-180)
       t_3
       (if (<= t_2 2e-130)
         (/ (* x (+ y t)) z)
         (if (<= t_2 4e+294) t_3 t_1))))))
double code(double x, double y, double z, double t) {
	double t_1 = y * (x / z);
	double t_2 = (y / z) + (t / (z + -1.0));
	double t_3 = t_2 * x;
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_2 <= -1e-180) {
		tmp = t_3;
	} else if (t_2 <= 2e-130) {
		tmp = (x * (y + t)) / z;
	} else if (t_2 <= 4e+294) {
		tmp = t_3;
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	double t_1 = y * (x / z);
	double t_2 = (y / z) + (t / (z + -1.0));
	double t_3 = t_2 * x;
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_2 <= -1e-180) {
		tmp = t_3;
	} else if (t_2 <= 2e-130) {
		tmp = (x * (y + t)) / z;
	} else if (t_2 <= 4e+294) {
		tmp = t_3;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = y * (x / z)
	t_2 = (y / z) + (t / (z + -1.0))
	t_3 = t_2 * x
	tmp = 0
	if t_2 <= -math.inf:
		tmp = t_1
	elif t_2 <= -1e-180:
		tmp = t_3
	elif t_2 <= 2e-130:
		tmp = (x * (y + t)) / z
	elif t_2 <= 4e+294:
		tmp = t_3
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(y * Float64(x / z))
	t_2 = Float64(Float64(y / z) + Float64(t / Float64(z + -1.0)))
	t_3 = Float64(t_2 * x)
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_2 <= -1e-180)
		tmp = t_3;
	elseif (t_2 <= 2e-130)
		tmp = Float64(Float64(x * Float64(y + t)) / z);
	elseif (t_2 <= 4e+294)
		tmp = t_3;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = y * (x / z);
	t_2 = (y / z) + (t / (z + -1.0));
	t_3 = t_2 * x;
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = t_1;
	elseif (t_2 <= -1e-180)
		tmp = t_3;
	elseif (t_2 <= 2e-130)
		tmp = (x * (y + t)) / z;
	elseif (t_2 <= 4e+294)
		tmp = t_3;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y / z), $MachinePrecision] + N[(t / N[(z + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * x), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, -1e-180], t$95$3, If[LessEqual[t$95$2, 2e-130], N[(N[(x * N[(y + t), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$2, 4e+294], t$95$3, t$95$1]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := y \cdot \frac{x}{z}\\
t_2 := \frac{y}{z} + \frac{t}{z + -1}\\
t_3 := t\_2 \cdot x\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 \leq -1 \cdot 10^{-180}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-130}:\\
\;\;\;\;\frac{x \cdot \left(y + t\right)}{z}\\

\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+294}:\\
\;\;\;\;t\_3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) < -inf.0 or 4.00000000000000027e294 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z)))

    1. Initial program 70.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
    8. Step-by-step derivation
      1. associate-/r/99.8%

        \[\leadsto \color{blue}{\frac{x}{z} \cdot y} \]
    9. Simplified99.8%

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

    if -inf.0 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) < -1e-180 or 2.0000000000000002e-130 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) < 4.00000000000000027e294

    1. Initial program 99.7%

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

    if -1e-180 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 #s(literal 1 binary64) z))) < 2.0000000000000002e-130

    1. Initial program 81.0%

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

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

      \[\leadsto \frac{\color{blue}{t \cdot x + x \cdot y}}{z} \]
    5. Step-by-step derivation
      1. +-commutative99.9%

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

        \[\leadsto \frac{x \cdot y + \color{blue}{x \cdot t}}{z} \]
      3. distribute-lft-in99.9%

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

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

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

Alternative 2: 92.5% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;z \leq -8 \cdot 10^{-238}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;z \leq 1:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 94.9%

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

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

        \[\leadsto \frac{\color{blue}{\left(y - -1 \cdot t\right) \cdot x}}{z} \]
      2. remove-double-neg87.5%

        \[\leadsto \frac{\color{blue}{\left(-\left(-\left(y - -1 \cdot t\right)\right)\right)} \cdot x}{z} \]
      3. cancel-sign-sub-inv87.5%

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

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

        \[\leadsto \frac{\left(-\left(-\left(y + \color{blue}{t}\right)\right)\right) \cdot x}{z} \]
      6. distribute-neg-out87.5%

        \[\leadsto \frac{\left(-\color{blue}{\left(\left(-y\right) + \left(-t\right)\right)}\right) \cdot x}{z} \]
      7. neg-mul-187.5%

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

        \[\leadsto \frac{\left(-\color{blue}{\left(-1 \cdot y - t\right)}\right) \cdot x}{z} \]
      9. distribute-lft-neg-in87.5%

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

        \[\leadsto \frac{-\color{blue}{x \cdot \left(-1 \cdot y - t\right)}}{z} \]
      11. distribute-neg-frac87.5%

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

        \[\leadsto -\color{blue}{x \cdot \frac{-1 \cdot y - t}{z}} \]
      13. distribute-rgt-neg-in93.4%

        \[\leadsto \color{blue}{x \cdot \left(-\frac{-1 \cdot y - t}{z}\right)} \]
      14. distribute-neg-frac93.4%

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

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

    if -1 < z < -7.9999999999999999e-238 or 1.7000000000000001e-233 < z < 1

    1. Initial program 94.7%

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

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

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

        \[\leadsto x \cdot \frac{\color{blue}{y - t \cdot z}}{z} \]
      3. div-sub94.6%

        \[\leadsto x \cdot \color{blue}{\left(\frac{y}{z} - \frac{t \cdot z}{z}\right)} \]
      4. associate-/l*94.6%

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

        \[\leadsto x \cdot \left(\frac{y}{z} - t \cdot \color{blue}{1}\right) \]
      6. *-rgt-identity94.6%

        \[\leadsto x \cdot \left(\frac{y}{z} - \color{blue}{t}\right) \]
    5. Simplified94.6%

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

    if -7.9999999999999999e-238 < z < 1.7000000000000001e-233

    1. Initial program 79.2%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \]
    8. Step-by-step derivation
      1. associate-/r/92.4%

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

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

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

Alternative 3: 71.9% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.4 \cdot 10^{+88} \lor \neg \left(t \leq 1.42 \cdot 10^{+150}\right):\\
\;\;\;\;t \cdot \frac{x}{z + -1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -2.3999999999999999e88 or 1.42e150 < t

    1. Initial program 95.6%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{t \cdot x}{1 - z}} \]
    4. Step-by-step derivation
      1. mul-1-neg72.8%

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

        \[\leadsto -\color{blue}{t \cdot \frac{x}{1 - z}} \]
      3. distribute-rgt-neg-in76.8%

        \[\leadsto \color{blue}{t \cdot \left(-\frac{x}{1 - z}\right)} \]
      4. distribute-neg-frac276.8%

        \[\leadsto t \cdot \color{blue}{\frac{x}{-\left(1 - z\right)}} \]
      5. neg-sub076.8%

        \[\leadsto t \cdot \frac{x}{\color{blue}{0 - \left(1 - z\right)}} \]
      6. associate--r-76.8%

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

        \[\leadsto t \cdot \frac{x}{\color{blue}{-1} + z} \]
    5. Simplified76.8%

      \[\leadsto \color{blue}{t \cdot \frac{x}{-1 + z}} \]

    if -2.3999999999999999e88 < t < 1.42e150

    1. Initial program 90.5%

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

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

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

Alternative 4: 74.5% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.9 \cdot 10^{+86} \lor \neg \left(t \leq 2.5 \cdot 10^{+146}\right):\\
\;\;\;\;x \cdot \frac{t}{z + -1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -2.8999999999999999e86 or 2.4999999999999999e146 < t

    1. Initial program 95.6%

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

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

        \[\leadsto x \cdot \color{blue}{\left(-\frac{t}{1 - z}\right)} \]
      2. distribute-neg-frac282.1%

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

        \[\leadsto x \cdot \frac{t}{\color{blue}{0 - \left(1 - z\right)}} \]
      4. associate--r-82.1%

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

        \[\leadsto x \cdot \frac{t}{\color{blue}{-1} + z} \]
    5. Simplified82.1%

      \[\leadsto x \cdot \color{blue}{\frac{t}{-1 + z}} \]

    if -2.8999999999999999e86 < t < 2.4999999999999999e146

    1. Initial program 90.5%

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

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

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

Alternative 5: 42.1% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{-12} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;t \cdot \frac{x}{z}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(-t\right)\\


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

    1. Initial program 95.1%

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

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg57.3%

        \[\leadsto x \cdot \color{blue}{\left(-\frac{t}{1 - z}\right)} \]
      2. distribute-neg-frac257.3%

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

        \[\leadsto x \cdot \frac{t}{\color{blue}{0 - \left(1 - z\right)}} \]
      4. associate--r-57.3%

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

        \[\leadsto x \cdot \frac{t}{\color{blue}{-1} + z} \]
    5. Simplified57.3%

      \[\leadsto x \cdot \color{blue}{\frac{t}{-1 + z}} \]
    6. Taylor expanded in z around inf 51.0%

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

        \[\leadsto \color{blue}{t \cdot \frac{x}{z}} \]
    8. Simplified54.6%

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

    if -1.99999999999999996e-12 < z < 1

    1. Initial program 89.6%

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

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

        \[\leadsto x \cdot \color{blue}{\left(-\frac{t}{1 - z}\right)} \]
      2. distribute-neg-frac235.6%

        \[\leadsto x \cdot \color{blue}{\frac{t}{-\left(1 - z\right)}} \]
      3. neg-sub035.6%

        \[\leadsto x \cdot \frac{t}{\color{blue}{0 - \left(1 - z\right)}} \]
      4. associate--r-35.6%

        \[\leadsto x \cdot \frac{t}{\color{blue}{\left(0 - 1\right) + z}} \]
      5. metadata-eval35.6%

        \[\leadsto x \cdot \frac{t}{\color{blue}{-1} + z} \]
    5. Simplified35.6%

      \[\leadsto x \cdot \color{blue}{\frac{t}{-1 + z}} \]
    6. Taylor expanded in z around 0 35.6%

      \[\leadsto \color{blue}{-1 \cdot \left(t \cdot x\right)} \]
    7. Step-by-step derivation
      1. *-commutative35.6%

        \[\leadsto -1 \cdot \color{blue}{\left(x \cdot t\right)} \]
      2. neg-mul-135.6%

        \[\leadsto \color{blue}{-x \cdot t} \]
      3. distribute-lft-neg-in35.6%

        \[\leadsto \color{blue}{\left(-x\right) \cdot t} \]
    8. Simplified35.6%

      \[\leadsto \color{blue}{\left(-x\right) \cdot t} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification45.1%

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

Alternative 6: 44.5% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{-12} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \frac{t}{z}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(-t\right)\\


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

    1. Initial program 95.1%

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

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg57.3%

        \[\leadsto x \cdot \color{blue}{\left(-\frac{t}{1 - z}\right)} \]
      2. distribute-neg-frac257.3%

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

        \[\leadsto x \cdot \frac{t}{\color{blue}{0 - \left(1 - z\right)}} \]
      4. associate--r-57.3%

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

        \[\leadsto x \cdot \frac{t}{\color{blue}{-1} + z} \]
    5. Simplified57.3%

      \[\leadsto x \cdot \color{blue}{\frac{t}{-1 + z}} \]
    6. Taylor expanded in z around inf 51.0%

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

        \[\leadsto \color{blue}{\frac{t}{z} \cdot x} \]
      2. *-commutative55.8%

        \[\leadsto \color{blue}{x \cdot \frac{t}{z}} \]
    8. Simplified55.8%

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

    if -1.99999999999999996e-12 < z < 1

    1. Initial program 89.6%

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

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

        \[\leadsto x \cdot \color{blue}{\left(-\frac{t}{1 - z}\right)} \]
      2. distribute-neg-frac235.6%

        \[\leadsto x \cdot \color{blue}{\frac{t}{-\left(1 - z\right)}} \]
      3. neg-sub035.6%

        \[\leadsto x \cdot \frac{t}{\color{blue}{0 - \left(1 - z\right)}} \]
      4. associate--r-35.6%

        \[\leadsto x \cdot \frac{t}{\color{blue}{\left(0 - 1\right) + z}} \]
      5. metadata-eval35.6%

        \[\leadsto x \cdot \frac{t}{\color{blue}{-1} + z} \]
    5. Simplified35.6%

      \[\leadsto x \cdot \color{blue}{\frac{t}{-1 + z}} \]
    6. Taylor expanded in z around 0 35.6%

      \[\leadsto \color{blue}{-1 \cdot \left(t \cdot x\right)} \]
    7. Step-by-step derivation
      1. *-commutative35.6%

        \[\leadsto -1 \cdot \color{blue}{\left(x \cdot t\right)} \]
      2. neg-mul-135.6%

        \[\leadsto \color{blue}{-x \cdot t} \]
      3. distribute-lft-neg-in35.6%

        \[\leadsto \color{blue}{\left(-x\right) \cdot t} \]
    8. Simplified35.6%

      \[\leadsto \color{blue}{\left(-x\right) \cdot t} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification45.7%

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

Alternative 7: 68.8% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -3 \cdot 10^{+88} \lor \neg \left(t \leq 2 \cdot 10^{+120}\right):\\
\;\;\;\;x \cdot \frac{t}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -3.00000000000000005e88 or 2e120 < t

    1. Initial program 94.2%

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

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg78.2%

        \[\leadsto x \cdot \color{blue}{\left(-\frac{t}{1 - z}\right)} \]
      2. distribute-neg-frac278.2%

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

        \[\leadsto x \cdot \frac{t}{\color{blue}{0 - \left(1 - z\right)}} \]
      4. associate--r-78.2%

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

        \[\leadsto x \cdot \frac{t}{\color{blue}{-1} + z} \]
    5. Simplified78.2%

      \[\leadsto x \cdot \color{blue}{\frac{t}{-1 + z}} \]
    6. Taylor expanded in z around inf 49.9%

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

        \[\leadsto \color{blue}{\frac{t}{z} \cdot x} \]
      2. *-commutative59.8%

        \[\leadsto \color{blue}{x \cdot \frac{t}{z}} \]
    8. Simplified59.8%

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

    if -3.00000000000000005e88 < t < 2e120

    1. Initial program 91.1%

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

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

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

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

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

Alternative 8: 67.7% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.3 \cdot 10^{+86} \lor \neg \left(t \leq 2.4 \cdot 10^{+130}\right):\\
\;\;\;\;x \cdot \frac{t}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -2.2999999999999999e86 or 2.40000000000000024e130 < t

    1. Initial program 94.2%

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

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{t}{1 - z}\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg78.2%

        \[\leadsto x \cdot \color{blue}{\left(-\frac{t}{1 - z}\right)} \]
      2. distribute-neg-frac278.2%

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

        \[\leadsto x \cdot \frac{t}{\color{blue}{0 - \left(1 - z\right)}} \]
      4. associate--r-78.2%

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

        \[\leadsto x \cdot \frac{t}{\color{blue}{-1} + z} \]
    5. Simplified78.2%

      \[\leadsto x \cdot \color{blue}{\frac{t}{-1 + z}} \]
    6. Taylor expanded in z around inf 49.9%

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

        \[\leadsto \color{blue}{\frac{t}{z} \cdot x} \]
      2. *-commutative59.8%

        \[\leadsto \color{blue}{x \cdot \frac{t}{z}} \]
    8. Simplified59.8%

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

    if -2.2999999999999999e86 < t < 2.40000000000000024e130

    1. Initial program 91.1%

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

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

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

Alternative 9: 23.4% accurate, 2.8× speedup?

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

\\
x \cdot \left(-t\right)
\end{array}
Derivation
  1. Initial program 92.3%

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

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

      \[\leadsto x \cdot \color{blue}{\left(-\frac{t}{1 - z}\right)} \]
    2. distribute-neg-frac246.4%

      \[\leadsto x \cdot \color{blue}{\frac{t}{-\left(1 - z\right)}} \]
    3. neg-sub046.4%

      \[\leadsto x \cdot \frac{t}{\color{blue}{0 - \left(1 - z\right)}} \]
    4. associate--r-46.4%

      \[\leadsto x \cdot \frac{t}{\color{blue}{\left(0 - 1\right) + z}} \]
    5. metadata-eval46.4%

      \[\leadsto x \cdot \frac{t}{\color{blue}{-1} + z} \]
  5. Simplified46.4%

    \[\leadsto x \cdot \color{blue}{\frac{t}{-1 + z}} \]
  6. Taylor expanded in z around 0 22.7%

    \[\leadsto \color{blue}{-1 \cdot \left(t \cdot x\right)} \]
  7. Step-by-step derivation
    1. *-commutative22.7%

      \[\leadsto -1 \cdot \color{blue}{\left(x \cdot t\right)} \]
    2. neg-mul-122.7%

      \[\leadsto \color{blue}{-x \cdot t} \]
    3. distribute-lft-neg-in22.7%

      \[\leadsto \color{blue}{\left(-x\right) \cdot t} \]
  8. Simplified22.7%

    \[\leadsto \color{blue}{\left(-x\right) \cdot t} \]
  9. Final simplification22.7%

    \[\leadsto x \cdot \left(-t\right) \]
  10. Add Preprocessing

Developer target: 95.2% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\
t_2 := x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\\
\mathbf{if}\;t\_2 < -7.623226303312042 \cdot 10^{-196}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 < 1.4133944927702302 \cdot 10^{-211}:\\
\;\;\;\;\frac{y \cdot x}{z} + \left(-\frac{t \cdot x}{1 - z}\right)\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024079 
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C"
  :precision binary64

  :alt
  (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) -7.623226303312042e-196) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z))))) (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) 1.4133944927702302e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1.0 z)))) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z)))))))

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