Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, B

Percentage Accurate: 96.6% → 96.6%
Time: 3.8s
Alternatives: 10
Speedup: 1.0×

Specification

?
\[\mathsf{TRUE}\left(\right)\]
\[\begin{array}{l} \\ x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))))))
double code(double x, double y, double z, double t, double a, double b) {
	return x * exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - b))));
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = x * exp(((y * (log(z) - t)) + (a * (log((1.0d0 - z)) - b))))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return x * Math.exp(((y * (Math.log(z) - t)) + (a * (Math.log((1.0 - z)) - b))));
}
def code(x, y, z, t, a, b):
	return x * math.exp(((y * (math.log(z) - t)) + (a * (math.log((1.0 - z)) - b))))
function code(x, y, z, t, a, b)
	return Float64(x * exp(Float64(Float64(y * Float64(log(z) - t)) + Float64(a * Float64(log(Float64(1.0 - z)) - b)))))
end
function tmp = code(x, y, z, t, a, b)
	tmp = x * exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - b))));
end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Exp[N[(N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\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 10 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: 96.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))))))
double code(double x, double y, double z, double t, double a, double b) {
	return x * exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - b))));
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = x * exp(((y * (log(z) - t)) + (a * (log((1.0d0 - z)) - b))))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return x * Math.exp(((y * (Math.log(z) - t)) + (a * (Math.log((1.0 - z)) - b))));
}
def code(x, y, z, t, a, b):
	return x * math.exp(((y * (math.log(z) - t)) + (a * (math.log((1.0 - z)) - b))))
function code(x, y, z, t, a, b)
	return Float64(x * exp(Float64(Float64(y * Float64(log(z) - t)) + Float64(a * Float64(log(Float64(1.0 - z)) - b)))))
end
function tmp = code(x, y, z, t, a, b)
	tmp = x * exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - b))));
end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Exp[N[(N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}
\end{array}

Alternative 1: 96.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))))))
double code(double x, double y, double z, double t, double a, double b) {
	return x * exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - b))));
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = x * exp(((y * (log(z) - t)) + (a * (log((1.0d0 - z)) - b))))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return x * Math.exp(((y * (Math.log(z) - t)) + (a * (Math.log((1.0 - z)) - b))));
}
def code(x, y, z, t, a, b):
	return x * math.exp(((y * (math.log(z) - t)) + (a * (math.log((1.0 - z)) - b))))
function code(x, y, z, t, a, b)
	return Float64(x * exp(Float64(Float64(y * Float64(log(z) - t)) + Float64(a * Float64(log(Float64(1.0 - z)) - b)))))
end
function tmp = code(x, y, z, t, a, b)
	tmp = x * exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - b))));
end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Exp[N[(N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}
\end{array}
Derivation
  1. Initial program 97.4%

    \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 53.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \log \left(1 - z\right)\\ t_2 := a \cdot \left(t\_1 - b\right)\\ t_3 := x \cdot e^{y \cdot \left(\log z - t\right) + t\_2}\\ t_4 := x \cdot t\_2\\ \mathbf{if}\;t\_3 \leq -10000000000:\\ \;\;\;\;t\_4\\ \mathbf{elif}\;t\_3 \leq 5 \cdot 10^{-180}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;e^{t\_4}\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (log (- 1.0 z)))
        (t_2 (* a (- t_1 b)))
        (t_3 (* x (exp (+ (* y (- (log z) t)) t_2))))
        (t_4 (* x t_2)))
   (if (<= t_3 -10000000000.0) t_4 (if (<= t_3 5e-180) t_1 (exp t_4)))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = log((1.0 - z));
	double t_2 = a * (t_1 - b);
	double t_3 = x * exp(((y * (log(z) - t)) + t_2));
	double t_4 = x * t_2;
	double tmp;
	if (t_3 <= -10000000000.0) {
		tmp = t_4;
	} else if (t_3 <= 5e-180) {
		tmp = t_1;
	} else {
		tmp = exp(t_4);
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: t_4
    real(8) :: tmp
    t_1 = log((1.0d0 - z))
    t_2 = a * (t_1 - b)
    t_3 = x * exp(((y * (log(z) - t)) + t_2))
    t_4 = x * t_2
    if (t_3 <= (-10000000000.0d0)) then
        tmp = t_4
    else if (t_3 <= 5d-180) then
        tmp = t_1
    else
        tmp = exp(t_4)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = Math.log((1.0 - z));
	double t_2 = a * (t_1 - b);
	double t_3 = x * Math.exp(((y * (Math.log(z) - t)) + t_2));
	double t_4 = x * t_2;
	double tmp;
	if (t_3 <= -10000000000.0) {
		tmp = t_4;
	} else if (t_3 <= 5e-180) {
		tmp = t_1;
	} else {
		tmp = Math.exp(t_4);
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = math.log((1.0 - z))
	t_2 = a * (t_1 - b)
	t_3 = x * math.exp(((y * (math.log(z) - t)) + t_2))
	t_4 = x * t_2
	tmp = 0
	if t_3 <= -10000000000.0:
		tmp = t_4
	elif t_3 <= 5e-180:
		tmp = t_1
	else:
		tmp = math.exp(t_4)
	return tmp
function code(x, y, z, t, a, b)
	t_1 = log(Float64(1.0 - z))
	t_2 = Float64(a * Float64(t_1 - b))
	t_3 = Float64(x * exp(Float64(Float64(y * Float64(log(z) - t)) + t_2)))
	t_4 = Float64(x * t_2)
	tmp = 0.0
	if (t_3 <= -10000000000.0)
		tmp = t_4;
	elseif (t_3 <= 5e-180)
		tmp = t_1;
	else
		tmp = exp(t_4);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = log((1.0 - z));
	t_2 = a * (t_1 - b);
	t_3 = x * exp(((y * (log(z) - t)) + t_2));
	t_4 = x * t_2;
	tmp = 0.0;
	if (t_3 <= -10000000000.0)
		tmp = t_4;
	elseif (t_3 <= 5e-180)
		tmp = t_1;
	else
		tmp = exp(t_4);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(a * N[(t$95$1 - b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(x * N[Exp[N[(N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(x * t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, -10000000000.0], t$95$4, If[LessEqual[t$95$3, 5e-180], t$95$1, N[Exp[t$95$4], $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \log \left(1 - z\right)\\
t_2 := a \cdot \left(t\_1 - b\right)\\
t_3 := x \cdot e^{y \cdot \left(\log z - t\right) + t\_2}\\
t_4 := x \cdot t\_2\\
\mathbf{if}\;t\_3 \leq -10000000000:\\
\;\;\;\;t\_4\\

\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{-180}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;e^{t\_4}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))))) < -1e10

    1. Initial program 100.0%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto x \cdot \color{blue}{e^{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
    4. Applied rewrites24.0%

      \[\leadsto x \cdot \color{blue}{\left(a \cdot \left(\log \left(1 - z\right) - b\right)\right)} \]

    if -1e10 < (*.f64 x (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))))) < 5.0000000000000001e-180

    1. Initial program 97.6%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(\log \left(1 - z\right) - b\right)} + y \cdot \left(x \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot \left(\log z - t\right)\right) + y \cdot \left(\frac{1}{6} \cdot \left(x \cdot \left(y \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot {\left(\log z - t\right)}^{3}\right)\right)\right) + \frac{1}{2} \cdot \left(x \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot {\left(\log z - t\right)}^{2}\right)\right)\right)\right)} \]
    4. Applied rewrites80.8%

      \[\leadsto \color{blue}{\log \left(1 - z\right)} \]

    if 5.0000000000000001e-180 < (*.f64 x (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b)))))

    1. Initial program 94.8%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
    4. Applied rewrites72.2%

      \[\leadsto \color{blue}{e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
    5. Taylor expanded in y around 0

      \[\leadsto e^{a \cdot \left(\log \left(1 - z\right) - b\right) + y \cdot \left(\log z - t\right)} \]
    6. Applied rewrites42.4%

      \[\leadsto e^{x \cdot \left(a \cdot \left(\log \left(1 - z\right) - b\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 49.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \log \left(1 - z\right)\\ t_2 := a \cdot \left(t\_1 - b\right)\\ t_3 := \log z - t\\ t_4 := x \cdot e^{y \cdot t\_3 + t\_2}\\ \mathbf{if}\;t\_4 \leq -10000000000:\\ \;\;\;\;x \cdot t\_2\\ \mathbf{elif}\;t\_4 \leq 5 \cdot 10^{-153}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;e^{t\_3}\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (log (- 1.0 z)))
        (t_2 (* a (- t_1 b)))
        (t_3 (- (log z) t))
        (t_4 (* x (exp (+ (* y t_3) t_2)))))
   (if (<= t_4 -10000000000.0) (* x t_2) (if (<= t_4 5e-153) t_1 (exp t_3)))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = log((1.0 - z));
	double t_2 = a * (t_1 - b);
	double t_3 = log(z) - t;
	double t_4 = x * exp(((y * t_3) + t_2));
	double tmp;
	if (t_4 <= -10000000000.0) {
		tmp = x * t_2;
	} else if (t_4 <= 5e-153) {
		tmp = t_1;
	} else {
		tmp = exp(t_3);
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: t_4
    real(8) :: tmp
    t_1 = log((1.0d0 - z))
    t_2 = a * (t_1 - b)
    t_3 = log(z) - t
    t_4 = x * exp(((y * t_3) + t_2))
    if (t_4 <= (-10000000000.0d0)) then
        tmp = x * t_2
    else if (t_4 <= 5d-153) then
        tmp = t_1
    else
        tmp = exp(t_3)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = Math.log((1.0 - z));
	double t_2 = a * (t_1 - b);
	double t_3 = Math.log(z) - t;
	double t_4 = x * Math.exp(((y * t_3) + t_2));
	double tmp;
	if (t_4 <= -10000000000.0) {
		tmp = x * t_2;
	} else if (t_4 <= 5e-153) {
		tmp = t_1;
	} else {
		tmp = Math.exp(t_3);
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = math.log((1.0 - z))
	t_2 = a * (t_1 - b)
	t_3 = math.log(z) - t
	t_4 = x * math.exp(((y * t_3) + t_2))
	tmp = 0
	if t_4 <= -10000000000.0:
		tmp = x * t_2
	elif t_4 <= 5e-153:
		tmp = t_1
	else:
		tmp = math.exp(t_3)
	return tmp
function code(x, y, z, t, a, b)
	t_1 = log(Float64(1.0 - z))
	t_2 = Float64(a * Float64(t_1 - b))
	t_3 = Float64(log(z) - t)
	t_4 = Float64(x * exp(Float64(Float64(y * t_3) + t_2)))
	tmp = 0.0
	if (t_4 <= -10000000000.0)
		tmp = Float64(x * t_2);
	elseif (t_4 <= 5e-153)
		tmp = t_1;
	else
		tmp = exp(t_3);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = log((1.0 - z));
	t_2 = a * (t_1 - b);
	t_3 = log(z) - t;
	t_4 = x * exp(((y * t_3) + t_2));
	tmp = 0.0;
	if (t_4 <= -10000000000.0)
		tmp = x * t_2;
	elseif (t_4 <= 5e-153)
		tmp = t_1;
	else
		tmp = exp(t_3);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(a * N[(t$95$1 - b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]}, Block[{t$95$4 = N[(x * N[Exp[N[(N[(y * t$95$3), $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, -10000000000.0], N[(x * t$95$2), $MachinePrecision], If[LessEqual[t$95$4, 5e-153], t$95$1, N[Exp[t$95$3], $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \log \left(1 - z\right)\\
t_2 := a \cdot \left(t\_1 - b\right)\\
t_3 := \log z - t\\
t_4 := x \cdot e^{y \cdot t\_3 + t\_2}\\
\mathbf{if}\;t\_4 \leq -10000000000:\\
\;\;\;\;x \cdot t\_2\\

\mathbf{elif}\;t\_4 \leq 5 \cdot 10^{-153}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;e^{t\_3}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))))) < -1e10

    1. Initial program 100.0%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto x \cdot \color{blue}{e^{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
    4. Applied rewrites24.0%

      \[\leadsto x \cdot \color{blue}{\left(a \cdot \left(\log \left(1 - z\right) - b\right)\right)} \]

    if -1e10 < (*.f64 x (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))))) < 5.00000000000000033e-153

    1. Initial program 97.6%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(\log \left(1 - z\right) - b\right)} + y \cdot \left(x \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot \left(\log z - t\right)\right) + y \cdot \left(\frac{1}{6} \cdot \left(x \cdot \left(y \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot {\left(\log z - t\right)}^{3}\right)\right)\right) + \frac{1}{2} \cdot \left(x \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot {\left(\log z - t\right)}^{2}\right)\right)\right)\right)} \]
    4. Applied rewrites80.2%

      \[\leadsto \color{blue}{\log \left(1 - z\right)} \]

    if 5.00000000000000033e-153 < (*.f64 x (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b)))))

    1. Initial program 94.7%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
    4. Applied rewrites73.1%

      \[\leadsto \color{blue}{e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
    5. Taylor expanded in y around 0

      \[\leadsto e^{a \cdot \left(\log \left(1 - z\right) - b\right) + y \cdot \left(\log z - t\right)} \]
    6. Applied rewrites42.9%

      \[\leadsto e^{x \cdot \left(a \cdot \left(\log \left(1 - z\right) - b\right)\right)} \]
    7. Taylor expanded in y around 0

      \[\leadsto e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    8. Applied rewrites27.5%

      \[\leadsto e^{\log z - t} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 65.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := a \cdot \left(\log \left(1 - z\right) - b\right)\\ t_2 := e^{y \cdot \left(\log z - t\right) + t\_1}\\ \mathbf{if}\;x \cdot t\_2 \leq -2 \cdot 10^{-304}:\\ \;\;\;\;x \cdot t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* a (- (log (- 1.0 z)) b)))
        (t_2 (exp (+ (* y (- (log z) t)) t_1))))
   (if (<= (* x t_2) -2e-304) (* x t_1) t_2)))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = a * (log((1.0 - z)) - b);
	double t_2 = exp(((y * (log(z) - t)) + t_1));
	double tmp;
	if ((x * t_2) <= -2e-304) {
		tmp = x * t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = a * (log((1.0d0 - z)) - b)
    t_2 = exp(((y * (log(z) - t)) + t_1))
    if ((x * t_2) <= (-2d-304)) then
        tmp = x * 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 a, double b) {
	double t_1 = a * (Math.log((1.0 - z)) - b);
	double t_2 = Math.exp(((y * (Math.log(z) - t)) + t_1));
	double tmp;
	if ((x * t_2) <= -2e-304) {
		tmp = x * t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = a * (math.log((1.0 - z)) - b)
	t_2 = math.exp(((y * (math.log(z) - t)) + t_1))
	tmp = 0
	if (x * t_2) <= -2e-304:
		tmp = x * t_1
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t, a, b)
	t_1 = Float64(a * Float64(log(Float64(1.0 - z)) - b))
	t_2 = exp(Float64(Float64(y * Float64(log(z) - t)) + t_1))
	tmp = 0.0
	if (Float64(x * t_2) <= -2e-304)
		tmp = Float64(x * t_1);
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = a * (log((1.0 - z)) - b);
	t_2 = exp(((y * (log(z) - t)) + t_1));
	tmp = 0.0;
	if ((x * t_2) <= -2e-304)
		tmp = x * t_1;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a * N[(N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(x * t$95$2), $MachinePrecision], -2e-304], N[(x * t$95$1), $MachinePrecision], t$95$2]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := a \cdot \left(\log \left(1 - z\right) - b\right)\\
t_2 := e^{y \cdot \left(\log z - t\right) + t\_1}\\
\mathbf{if}\;x \cdot t\_2 \leq -2 \cdot 10^{-304}:\\
\;\;\;\;x \cdot t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))))) < -1.99999999999999994e-304

    1. Initial program 98.7%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto x \cdot \color{blue}{e^{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
    4. Applied rewrites21.2%

      \[\leadsto x \cdot \color{blue}{\left(a \cdot \left(\log \left(1 - z\right) - b\right)\right)} \]

    if -1.99999999999999994e-304 < (*.f64 x (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b)))))

    1. Initial program 96.8%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
    4. Applied rewrites84.8%

      \[\leadsto \color{blue}{e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 49.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \log \left(1 - z\right)\\ t_2 := a \cdot \left(t\_1 - b\right)\\ \mathbf{if}\;y \cdot \left(\log z - t\right) + t\_2 \leq 20000000000000:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot t\_2\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (log (- 1.0 z))) (t_2 (* a (- t_1 b))))
   (if (<= (+ (* y (- (log z) t)) t_2) 20000000000000.0) t_1 (* x t_2))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = log((1.0 - z));
	double t_2 = a * (t_1 - b);
	double tmp;
	if (((y * (log(z) - t)) + t_2) <= 20000000000000.0) {
		tmp = t_1;
	} else {
		tmp = x * t_2;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = log((1.0d0 - z))
    t_2 = a * (t_1 - b)
    if (((y * (log(z) - t)) + t_2) <= 20000000000000.0d0) then
        tmp = t_1
    else
        tmp = x * t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = Math.log((1.0 - z));
	double t_2 = a * (t_1 - b);
	double tmp;
	if (((y * (Math.log(z) - t)) + t_2) <= 20000000000000.0) {
		tmp = t_1;
	} else {
		tmp = x * t_2;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = math.log((1.0 - z))
	t_2 = a * (t_1 - b)
	tmp = 0
	if ((y * (math.log(z) - t)) + t_2) <= 20000000000000.0:
		tmp = t_1
	else:
		tmp = x * t_2
	return tmp
function code(x, y, z, t, a, b)
	t_1 = log(Float64(1.0 - z))
	t_2 = Float64(a * Float64(t_1 - b))
	tmp = 0.0
	if (Float64(Float64(y * Float64(log(z) - t)) + t_2) <= 20000000000000.0)
		tmp = t_1;
	else
		tmp = Float64(x * t_2);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = log((1.0 - z));
	t_2 = a * (t_1 - b);
	tmp = 0.0;
	if (((y * (log(z) - t)) + t_2) <= 20000000000000.0)
		tmp = t_1;
	else
		tmp = x * t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(a * N[(t$95$1 - b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision], 20000000000000.0], t$95$1, N[(x * t$95$2), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \log \left(1 - z\right)\\
t_2 := a \cdot \left(t\_1 - b\right)\\
\mathbf{if}\;y \cdot \left(\log z - t\right) + t\_2 \leq 20000000000000:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) < 2e13

    1. Initial program 96.8%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(\log \left(1 - z\right) - b\right)} + y \cdot \left(x \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot \left(\log z - t\right)\right) + y \cdot \left(\frac{1}{6} \cdot \left(x \cdot \left(y \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot {\left(\log z - t\right)}^{3}\right)\right)\right) + \frac{1}{2} \cdot \left(x \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot {\left(\log z - t\right)}^{2}\right)\right)\right)\right)} \]
    4. Applied rewrites64.1%

      \[\leadsto \color{blue}{\log \left(1 - z\right)} \]

    if 2e13 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b)))

    1. Initial program 98.1%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto x \cdot \color{blue}{e^{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
    4. Applied rewrites28.4%

      \[\leadsto x \cdot \color{blue}{\left(a \cdot \left(\log \left(1 - z\right) - b\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 43.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \log \left(1 - z\right)\\ t_2 := a \cdot \left(t\_1 - b\right)\\ \mathbf{if}\;y \cdot \left(\log z - t\right) + t\_2 \leq 2.5 \cdot 10^{+133}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (log (- 1.0 z))) (t_2 (* a (- t_1 b))))
   (if (<= (+ (* y (- (log z) t)) t_2) 2.5e+133) t_1 t_2)))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = log((1.0 - z));
	double t_2 = a * (t_1 - b);
	double tmp;
	if (((y * (log(z) - t)) + t_2) <= 2.5e+133) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = log((1.0d0 - z))
    t_2 = a * (t_1 - b)
    if (((y * (log(z) - t)) + t_2) <= 2.5d+133) 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 a, double b) {
	double t_1 = Math.log((1.0 - z));
	double t_2 = a * (t_1 - b);
	double tmp;
	if (((y * (Math.log(z) - t)) + t_2) <= 2.5e+133) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = math.log((1.0 - z))
	t_2 = a * (t_1 - b)
	tmp = 0
	if ((y * (math.log(z) - t)) + t_2) <= 2.5e+133:
		tmp = t_1
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t, a, b)
	t_1 = log(Float64(1.0 - z))
	t_2 = Float64(a * Float64(t_1 - b))
	tmp = 0.0
	if (Float64(Float64(y * Float64(log(z) - t)) + t_2) <= 2.5e+133)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = log((1.0 - z));
	t_2 = a * (t_1 - b);
	tmp = 0.0;
	if (((y * (log(z) - t)) + t_2) <= 2.5e+133)
		tmp = t_1;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(a * N[(t$95$1 - b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision], 2.5e+133], t$95$1, t$95$2]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \log \left(1 - z\right)\\
t_2 := a \cdot \left(t\_1 - b\right)\\
\mathbf{if}\;y \cdot \left(\log z - t\right) + t\_2 \leq 2.5 \cdot 10^{+133}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) < 2.4999999999999998e133

    1. Initial program 96.7%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(\log \left(1 - z\right) - b\right)} + y \cdot \left(x \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot \left(\log z - t\right)\right) + y \cdot \left(\frac{1}{6} \cdot \left(x \cdot \left(y \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot {\left(\log z - t\right)}^{3}\right)\right)\right) + \frac{1}{2} \cdot \left(x \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot {\left(\log z - t\right)}^{2}\right)\right)\right)\right)} \]
    4. Applied rewrites55.1%

      \[\leadsto \color{blue}{\log \left(1 - z\right)} \]

    if 2.4999999999999998e133 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b)))

    1. Initial program 98.7%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
    4. Applied rewrites55.7%

      \[\leadsto \color{blue}{e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
    5. Taylor expanded in y around inf

      \[\leadsto \color{blue}{x \cdot e^{\left(a \cdot \left(\log \left(1 - z\right) - b\right) + y \cdot \log z\right) - t \cdot y}} \]
    6. Applied rewrites14.0%

      \[\leadsto \color{blue}{a \cdot \left(\log \left(1 - z\right) - b\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 43.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \log \left(1 - z\right)\\ t_2 := y \cdot \left(\log z - t\right)\\ \mathbf{if}\;t\_2 + a \cdot \left(t\_1 - b\right) \leq 5 \cdot 10^{+178}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (log (- 1.0 z))) (t_2 (* y (- (log z) t))))
   (if (<= (+ t_2 (* a (- t_1 b))) 5e+178) t_1 t_2)))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = log((1.0 - z));
	double t_2 = y * (log(z) - t);
	double tmp;
	if ((t_2 + (a * (t_1 - b))) <= 5e+178) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = log((1.0d0 - z))
    t_2 = y * (log(z) - t)
    if ((t_2 + (a * (t_1 - b))) <= 5d+178) 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 a, double b) {
	double t_1 = Math.log((1.0 - z));
	double t_2 = y * (Math.log(z) - t);
	double tmp;
	if ((t_2 + (a * (t_1 - b))) <= 5e+178) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = math.log((1.0 - z))
	t_2 = y * (math.log(z) - t)
	tmp = 0
	if (t_2 + (a * (t_1 - b))) <= 5e+178:
		tmp = t_1
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t, a, b)
	t_1 = log(Float64(1.0 - z))
	t_2 = Float64(y * Float64(log(z) - t))
	tmp = 0.0
	if (Float64(t_2 + Float64(a * Float64(t_1 - b))) <= 5e+178)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = log((1.0 - z));
	t_2 = y * (log(z) - t);
	tmp = 0.0;
	if ((t_2 + (a * (t_1 - b))) <= 5e+178)
		tmp = t_1;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$2 + N[(a * N[(t$95$1 - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+178], t$95$1, t$95$2]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \log \left(1 - z\right)\\
t_2 := y \cdot \left(\log z - t\right)\\
\mathbf{if}\;t\_2 + a \cdot \left(t\_1 - b\right) \leq 5 \cdot 10^{+178}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) < 4.9999999999999999e178

    1. Initial program 96.9%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(\log \left(1 - z\right) - b\right)} + y \cdot \left(x \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot \left(\log z - t\right)\right) + y \cdot \left(\frac{1}{6} \cdot \left(x \cdot \left(y \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot {\left(\log z - t\right)}^{3}\right)\right)\right) + \frac{1}{2} \cdot \left(x \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot {\left(\log z - t\right)}^{2}\right)\right)\right)\right)} \]
    4. Applied rewrites52.0%

      \[\leadsto \color{blue}{\log \left(1 - z\right)} \]

    if 4.9999999999999999e178 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b)))

    1. Initial program 98.5%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(\log \left(1 - z\right) - b\right)} + y \cdot \left(\frac{1}{2} \cdot \left(x \cdot \left(y \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot {\left(\log z - t\right)}^{2}\right)\right)\right) + x \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot \left(\log z - t\right)\right)\right)} \]
    4. Applied rewrites14.9%

      \[\leadsto \color{blue}{y \cdot \left(\log z - t\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 40.6% accurate, 3.2× speedup?

\[\begin{array}{l} \\ \log \left(1 - z\right) \end{array} \]
(FPCore (x y z t a b) :precision binary64 (log (- 1.0 z)))
double code(double x, double y, double z, double t, double a, double b) {
	return log((1.0 - z));
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = log((1.0d0 - z))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return Math.log((1.0 - z));
}
def code(x, y, z, t, a, b):
	return math.log((1.0 - z))
function code(x, y, z, t, a, b)
	return log(Float64(1.0 - z))
end
function tmp = code(x, y, z, t, a, b)
	tmp = log((1.0 - z));
end
code[x_, y_, z_, t_, a_, b_] := N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\log \left(1 - z\right)
\end{array}
Derivation
  1. Initial program 97.4%

    \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in y around 0

    \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(\log \left(1 - z\right) - b\right)} + y \cdot \left(x \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot \left(\log z - t\right)\right) + y \cdot \left(\frac{1}{6} \cdot \left(x \cdot \left(y \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot {\left(\log z - t\right)}^{3}\right)\right)\right) + \frac{1}{2} \cdot \left(x \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot {\left(\log z - t\right)}^{2}\right)\right)\right)\right)} \]
  4. Applied rewrites38.6%

    \[\leadsto \color{blue}{\log \left(1 - z\right)} \]
  5. Add Preprocessing

Alternative 9: 2.7% accurate, 3.2× speedup?

\[\begin{array}{l} \\ \log z - t \end{array} \]
(FPCore (x y z t a b) :precision binary64 (- (log z) t))
double code(double x, double y, double z, double t, double a, double b) {
	return log(z) - t;
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = log(z) - t
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return Math.log(z) - t;
}
def code(x, y, z, t, a, b):
	return math.log(z) - t
function code(x, y, z, t, a, b)
	return Float64(log(z) - t)
end
function tmp = code(x, y, z, t, a, b)
	tmp = log(z) - t;
end
code[x_, y_, z_, t_, a_, b_] := N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}

\\
\log z - t
\end{array}
Derivation
  1. Initial program 97.4%

    \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in y around 0

    \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
  4. Applied rewrites60.1%

    \[\leadsto \color{blue}{e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
  5. Taylor expanded in y around 0

    \[\leadsto e^{a \cdot \left(\log \left(1 - z\right) - b\right)} + \color{blue}{y \cdot \left(y \cdot \left(\frac{1}{6} \cdot \left(y \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot {\left(\log z - t\right)}^{3}\right)\right) + \frac{1}{2} \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot {\left(\log z - t\right)}^{2}\right)\right) + e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot \left(\log z - t\right)\right)} \]
  6. Applied rewrites2.9%

    \[\leadsto \log z - \color{blue}{t} \]
  7. Add Preprocessing

Alternative 10: 2.7% accurate, 82.0× speedup?

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

\\
1 - z
\end{array}
Derivation
  1. Initial program 97.4%

    \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in y around 0

    \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
  4. Applied rewrites60.1%

    \[\leadsto \color{blue}{e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
  5. Taylor expanded in y around 0

    \[\leadsto e^{a \cdot \left(\log \left(1 - z\right) - b\right)} + \color{blue}{y \cdot \left(e^{a \cdot \left(\log \left(1 - z\right) - b\right)} \cdot \left(\log z - t\right)\right)} \]
  6. Applied rewrites2.7%

    \[\leadsto 1 - \color{blue}{z} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2024321 
(FPCore (x y z t a b)
  :name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, B"
  :precision binary64
  :pre (TRUE)
  (* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))))))