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

Percentage Accurate: 96.8% → 96.8%
Time: 9.9s
Alternatives: 7
Speedup: 1.0×

Specification

?
\[\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 7 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.8% 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.8% accurate, 1.0× speedup?

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

\\
e^{\left(\log \left(1 - z\right) - b\right) \cdot a + \left(\log z - t\right) \cdot y} \cdot x
\end{array}
Derivation
  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. Final simplification96.7%

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

Alternative 2: 76.0% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_1 := e^{\log z \cdot y} \cdot x\\
\mathbf{if}\;y \leq -6500000000:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 10^{+26}:\\
\;\;\;\;e^{\left(\left(-b\right) - z\right) \cdot a} \cdot x\\

\mathbf{elif}\;y \leq 4.9 \cdot 10^{+225}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -6.5e9 or 1.00000000000000005e26 < y < 4.90000000000000032e225

    1. Initial program 96.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 a around 0

      \[\leadsto x \cdot e^{\color{blue}{y \cdot \left(\log z - t\right)}} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto x \cdot e^{\color{blue}{\left(\log z - t\right) \cdot y}} \]
      2. lower-*.f64N/A

        \[\leadsto x \cdot e^{\color{blue}{\left(\log z - t\right) \cdot y}} \]
      3. lower--.f64N/A

        \[\leadsto x \cdot e^{\color{blue}{\left(\log z - t\right)} \cdot y} \]
      4. lower-log.f6490.7

        \[\leadsto x \cdot e^{\left(\color{blue}{\log z} - t\right) \cdot y} \]
    5. Applied rewrites90.7%

      \[\leadsto x \cdot e^{\color{blue}{\left(\log z - t\right) \cdot y}} \]
    6. Taylor expanded in t around 0

      \[\leadsto x \cdot e^{\log z \cdot y} \]
    7. Step-by-step derivation
      1. Applied rewrites72.8%

        \[\leadsto x \cdot e^{\log z \cdot y} \]

      if -6.5e9 < y < 1.00000000000000005e26

      1. Initial program 97.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 a around inf

        \[\leadsto x \cdot e^{\color{blue}{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto x \cdot e^{\color{blue}{\left(\log \left(1 - z\right) - b\right) \cdot a}} \]
        2. lower-*.f64N/A

          \[\leadsto x \cdot e^{\color{blue}{\left(\log \left(1 - z\right) - b\right) \cdot a}} \]
        3. lower--.f64N/A

          \[\leadsto x \cdot e^{\color{blue}{\left(\log \left(1 - z\right) - b\right)} \cdot a} \]
        4. sub-negN/A

          \[\leadsto x \cdot e^{\left(\log \color{blue}{\left(1 + \left(\mathsf{neg}\left(z\right)\right)\right)} - b\right) \cdot a} \]
        5. lower-log1p.f64N/A

          \[\leadsto x \cdot e^{\left(\color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(z\right)\right)} - b\right) \cdot a} \]
        6. lower-neg.f6483.2

          \[\leadsto x \cdot e^{\left(\mathsf{log1p}\left(\color{blue}{-z}\right) - b\right) \cdot a} \]
      5. Applied rewrites83.2%

        \[\leadsto x \cdot e^{\color{blue}{\left(\mathsf{log1p}\left(-z\right) - b\right) \cdot a}} \]
      6. Taylor expanded in z around 0

        \[\leadsto x \cdot e^{\left(-1 \cdot z - b\right) \cdot a} \]
      7. Step-by-step derivation
        1. Applied rewrites83.2%

          \[\leadsto x \cdot e^{\left(\left(-b\right) - z\right) \cdot a} \]

        if 4.90000000000000032e225 < y

        1. Initial program 86.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 t around inf

          \[\leadsto x \cdot e^{\color{blue}{-1 \cdot \left(t \cdot y\right)}} \]
        4. Step-by-step derivation
          1. associate-*r*N/A

            \[\leadsto x \cdot e^{\color{blue}{\left(-1 \cdot t\right) \cdot y}} \]
          2. mul-1-negN/A

            \[\leadsto x \cdot e^{\color{blue}{\left(\mathsf{neg}\left(t\right)\right)} \cdot y} \]
          3. lower-*.f64N/A

            \[\leadsto x \cdot e^{\color{blue}{\left(\mathsf{neg}\left(t\right)\right) \cdot y}} \]
          4. lower-neg.f6480.3

            \[\leadsto x \cdot e^{\color{blue}{\left(-t\right)} \cdot y} \]
        5. Applied rewrites80.3%

          \[\leadsto x \cdot e^{\color{blue}{\left(-t\right) \cdot y}} \]
      8. Recombined 3 regimes into one program.
      9. Final simplification78.3%

        \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6500000000:\\ \;\;\;\;e^{\log z \cdot y} \cdot x\\ \mathbf{elif}\;y \leq 10^{+26}:\\ \;\;\;\;e^{\left(\left(-b\right) - z\right) \cdot a} \cdot x\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{+225}:\\ \;\;\;\;e^{\log z \cdot y} \cdot x\\ \mathbf{else}:\\ \;\;\;\;e^{\left(-t\right) \cdot y} \cdot x\\ \end{array} \]
      10. Add Preprocessing

      Alternative 3: 86.9% accurate, 1.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_1 := e^{\left(\log z - t\right) \cdot y} \cdot x\\ \mathbf{if}\;y \leq -2.55 \cdot 10^{-14}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 3 \cdot 10^{-38}:\\ \;\;\;\;e^{\left(\left(-b\right) - z\right) \cdot a} \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
      (FPCore (x y z t a b)
       :precision binary64
       (let* ((t_1 (* (exp (* (- (log z) t) y)) x)))
         (if (<= y -2.55e-14)
           t_1
           (if (<= y 3e-38) (* (exp (* (- (- b) z) a)) x) t_1))))
      double code(double x, double y, double z, double t, double a, double b) {
      	double t_1 = exp(((log(z) - t) * y)) * x;
      	double tmp;
      	if (y <= -2.55e-14) {
      		tmp = t_1;
      	} else if (y <= 3e-38) {
      		tmp = exp(((-b - z) * a)) * x;
      	} else {
      		tmp = t_1;
      	}
      	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) :: tmp
          t_1 = exp(((log(z) - t) * y)) * x
          if (y <= (-2.55d-14)) then
              tmp = t_1
          else if (y <= 3d-38) then
              tmp = exp(((-b - z) * a)) * x
          else
              tmp = t_1
          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.exp(((Math.log(z) - t) * y)) * x;
      	double tmp;
      	if (y <= -2.55e-14) {
      		tmp = t_1;
      	} else if (y <= 3e-38) {
      		tmp = Math.exp(((-b - z) * a)) * x;
      	} else {
      		tmp = t_1;
      	}
      	return tmp;
      }
      
      def code(x, y, z, t, a, b):
      	t_1 = math.exp(((math.log(z) - t) * y)) * x
      	tmp = 0
      	if y <= -2.55e-14:
      		tmp = t_1
      	elif y <= 3e-38:
      		tmp = math.exp(((-b - z) * a)) * x
      	else:
      		tmp = t_1
      	return tmp
      
      function code(x, y, z, t, a, b)
      	t_1 = Float64(exp(Float64(Float64(log(z) - t) * y)) * x)
      	tmp = 0.0
      	if (y <= -2.55e-14)
      		tmp = t_1;
      	elseif (y <= 3e-38)
      		tmp = Float64(exp(Float64(Float64(Float64(-b) - z) * a)) * x);
      	else
      		tmp = t_1;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z, t, a, b)
      	t_1 = exp(((log(z) - t) * y)) * x;
      	tmp = 0.0;
      	if (y <= -2.55e-14)
      		tmp = t_1;
      	elseif (y <= 3e-38)
      		tmp = exp(((-b - z) * a)) * x;
      	else
      		tmp = t_1;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[Exp[N[(N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[y, -2.55e-14], t$95$1, If[LessEqual[y, 3e-38], N[(N[Exp[N[(N[((-b) - z), $MachinePrecision] * a), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision], t$95$1]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_1 := e^{\left(\log z - t\right) \cdot y} \cdot x\\
      \mathbf{if}\;y \leq -2.55 \cdot 10^{-14}:\\
      \;\;\;\;t\_1\\
      
      \mathbf{elif}\;y \leq 3 \cdot 10^{-38}:\\
      \;\;\;\;e^{\left(\left(-b\right) - z\right) \cdot a} \cdot x\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_1\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if y < -2.5499999999999999e-14 or 2.99999999999999989e-38 < y

        1. Initial program 95.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 a around 0

          \[\leadsto x \cdot e^{\color{blue}{y \cdot \left(\log z - t\right)}} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto x \cdot e^{\color{blue}{\left(\log z - t\right) \cdot y}} \]
          2. lower-*.f64N/A

            \[\leadsto x \cdot e^{\color{blue}{\left(\log z - t\right) \cdot y}} \]
          3. lower--.f64N/A

            \[\leadsto x \cdot e^{\color{blue}{\left(\log z - t\right)} \cdot y} \]
          4. lower-log.f6489.9

            \[\leadsto x \cdot e^{\left(\color{blue}{\log z} - t\right) \cdot y} \]
        5. Applied rewrites89.9%

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

        if -2.5499999999999999e-14 < y < 2.99999999999999989e-38

        1. Initial program 97.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 a around inf

          \[\leadsto x \cdot e^{\color{blue}{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto x \cdot e^{\color{blue}{\left(\log \left(1 - z\right) - b\right) \cdot a}} \]
          2. lower-*.f64N/A

            \[\leadsto x \cdot e^{\color{blue}{\left(\log \left(1 - z\right) - b\right) \cdot a}} \]
          3. lower--.f64N/A

            \[\leadsto x \cdot e^{\color{blue}{\left(\log \left(1 - z\right) - b\right)} \cdot a} \]
          4. sub-negN/A

            \[\leadsto x \cdot e^{\left(\log \color{blue}{\left(1 + \left(\mathsf{neg}\left(z\right)\right)\right)} - b\right) \cdot a} \]
          5. lower-log1p.f64N/A

            \[\leadsto x \cdot e^{\left(\color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(z\right)\right)} - b\right) \cdot a} \]
          6. lower-neg.f6487.0

            \[\leadsto x \cdot e^{\left(\mathsf{log1p}\left(\color{blue}{-z}\right) - b\right) \cdot a} \]
        5. Applied rewrites87.0%

          \[\leadsto x \cdot e^{\color{blue}{\left(\mathsf{log1p}\left(-z\right) - b\right) \cdot a}} \]
        6. Taylor expanded in z around 0

          \[\leadsto x \cdot e^{\left(-1 \cdot z - b\right) \cdot a} \]
        7. Step-by-step derivation
          1. Applied rewrites87.0%

            \[\leadsto x \cdot e^{\left(\left(-b\right) - z\right) \cdot a} \]
        8. Recombined 2 regimes into one program.
        9. Final simplification88.7%

          \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.55 \cdot 10^{-14}:\\ \;\;\;\;e^{\left(\log z - t\right) \cdot y} \cdot x\\ \mathbf{elif}\;y \leq 3 \cdot 10^{-38}:\\ \;\;\;\;e^{\left(\left(-b\right) - z\right) \cdot a} \cdot x\\ \mathbf{else}:\\ \;\;\;\;e^{\left(\log z - t\right) \cdot y} \cdot x\\ \end{array} \]
        10. Add Preprocessing

        Alternative 4: 73.1% accurate, 2.6× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_1 := e^{\left(-t\right) \cdot y} \cdot x\\ \mathbf{if}\;t \leq -7.5 \cdot 10^{+163}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 8 \cdot 10^{-41}:\\ \;\;\;\;e^{\left(\left(-b\right) - z\right) \cdot a} \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
        (FPCore (x y z t a b)
         :precision binary64
         (let* ((t_1 (* (exp (* (- t) y)) x)))
           (if (<= t -7.5e+163)
             t_1
             (if (<= t 8e-41) (* (exp (* (- (- b) z) a)) x) t_1))))
        double code(double x, double y, double z, double t, double a, double b) {
        	double t_1 = exp((-t * y)) * x;
        	double tmp;
        	if (t <= -7.5e+163) {
        		tmp = t_1;
        	} else if (t <= 8e-41) {
        		tmp = exp(((-b - z) * a)) * x;
        	} else {
        		tmp = t_1;
        	}
        	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) :: tmp
            t_1 = exp((-t * y)) * x
            if (t <= (-7.5d+163)) then
                tmp = t_1
            else if (t <= 8d-41) then
                tmp = exp(((-b - z) * a)) * x
            else
                tmp = t_1
            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.exp((-t * y)) * x;
        	double tmp;
        	if (t <= -7.5e+163) {
        		tmp = t_1;
        	} else if (t <= 8e-41) {
        		tmp = Math.exp(((-b - z) * a)) * x;
        	} else {
        		tmp = t_1;
        	}
        	return tmp;
        }
        
        def code(x, y, z, t, a, b):
        	t_1 = math.exp((-t * y)) * x
        	tmp = 0
        	if t <= -7.5e+163:
        		tmp = t_1
        	elif t <= 8e-41:
        		tmp = math.exp(((-b - z) * a)) * x
        	else:
        		tmp = t_1
        	return tmp
        
        function code(x, y, z, t, a, b)
        	t_1 = Float64(exp(Float64(Float64(-t) * y)) * x)
        	tmp = 0.0
        	if (t <= -7.5e+163)
        		tmp = t_1;
        	elseif (t <= 8e-41)
        		tmp = Float64(exp(Float64(Float64(Float64(-b) - z) * a)) * x);
        	else
        		tmp = t_1;
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z, t, a, b)
        	t_1 = exp((-t * y)) * x;
        	tmp = 0.0;
        	if (t <= -7.5e+163)
        		tmp = t_1;
        	elseif (t <= 8e-41)
        		tmp = exp(((-b - z) * a)) * x;
        	else
        		tmp = t_1;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[Exp[N[((-t) * y), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[t, -7.5e+163], t$95$1, If[LessEqual[t, 8e-41], N[(N[Exp[N[(N[((-b) - z), $MachinePrecision] * a), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision], t$95$1]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_1 := e^{\left(-t\right) \cdot y} \cdot x\\
        \mathbf{if}\;t \leq -7.5 \cdot 10^{+163}:\\
        \;\;\;\;t\_1\\
        
        \mathbf{elif}\;t \leq 8 \cdot 10^{-41}:\\
        \;\;\;\;e^{\left(\left(-b\right) - z\right) \cdot a} \cdot x\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_1\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if t < -7.50000000000000001e163 or 8.00000000000000005e-41 < t

          1. Initial program 95.3%

            \[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 t around inf

            \[\leadsto x \cdot e^{\color{blue}{-1 \cdot \left(t \cdot y\right)}} \]
          4. Step-by-step derivation
            1. associate-*r*N/A

              \[\leadsto x \cdot e^{\color{blue}{\left(-1 \cdot t\right) \cdot y}} \]
            2. mul-1-negN/A

              \[\leadsto x \cdot e^{\color{blue}{\left(\mathsf{neg}\left(t\right)\right)} \cdot y} \]
            3. lower-*.f64N/A

              \[\leadsto x \cdot e^{\color{blue}{\left(\mathsf{neg}\left(t\right)\right) \cdot y}} \]
            4. lower-neg.f6487.0

              \[\leadsto x \cdot e^{\color{blue}{\left(-t\right)} \cdot y} \]
          5. Applied rewrites87.0%

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

          if -7.50000000000000001e163 < t < 8.00000000000000005e-41

          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 a around inf

            \[\leadsto x \cdot e^{\color{blue}{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto x \cdot e^{\color{blue}{\left(\log \left(1 - z\right) - b\right) \cdot a}} \]
            2. lower-*.f64N/A

              \[\leadsto x \cdot e^{\color{blue}{\left(\log \left(1 - z\right) - b\right) \cdot a}} \]
            3. lower--.f64N/A

              \[\leadsto x \cdot e^{\color{blue}{\left(\log \left(1 - z\right) - b\right)} \cdot a} \]
            4. sub-negN/A

              \[\leadsto x \cdot e^{\left(\log \color{blue}{\left(1 + \left(\mathsf{neg}\left(z\right)\right)\right)} - b\right) \cdot a} \]
            5. lower-log1p.f64N/A

              \[\leadsto x \cdot e^{\left(\color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(z\right)\right)} - b\right) \cdot a} \]
            6. lower-neg.f6465.5

              \[\leadsto x \cdot e^{\left(\mathsf{log1p}\left(\color{blue}{-z}\right) - b\right) \cdot a} \]
          5. Applied rewrites65.5%

            \[\leadsto x \cdot e^{\color{blue}{\left(\mathsf{log1p}\left(-z\right) - b\right) \cdot a}} \]
          6. Taylor expanded in z around 0

            \[\leadsto x \cdot e^{\left(-1 \cdot z - b\right) \cdot a} \]
          7. Step-by-step derivation
            1. Applied rewrites65.5%

              \[\leadsto x \cdot e^{\left(\left(-b\right) - z\right) \cdot a} \]
          8. Recombined 2 regimes into one program.
          9. Final simplification74.5%

            \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -7.5 \cdot 10^{+163}:\\ \;\;\;\;e^{\left(-t\right) \cdot y} \cdot x\\ \mathbf{elif}\;t \leq 8 \cdot 10^{-41}:\\ \;\;\;\;e^{\left(\left(-b\right) - z\right) \cdot a} \cdot x\\ \mathbf{else}:\\ \;\;\;\;e^{\left(-t\right) \cdot y} \cdot x\\ \end{array} \]
          10. Add Preprocessing

          Alternative 5: 70.3% accurate, 2.6× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_1 := e^{\left(-t\right) \cdot y} \cdot x\\ \mathbf{if}\;t \leq -7.5 \cdot 10^{+163}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 8 \cdot 10^{-41}:\\ \;\;\;\;e^{\left(-b\right) \cdot a} \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
          (FPCore (x y z t a b)
           :precision binary64
           (let* ((t_1 (* (exp (* (- t) y)) x)))
             (if (<= t -7.5e+163) t_1 (if (<= t 8e-41) (* (exp (* (- b) a)) x) t_1))))
          double code(double x, double y, double z, double t, double a, double b) {
          	double t_1 = exp((-t * y)) * x;
          	double tmp;
          	if (t <= -7.5e+163) {
          		tmp = t_1;
          	} else if (t <= 8e-41) {
          		tmp = exp((-b * a)) * x;
          	} else {
          		tmp = t_1;
          	}
          	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) :: tmp
              t_1 = exp((-t * y)) * x
              if (t <= (-7.5d+163)) then
                  tmp = t_1
              else if (t <= 8d-41) then
                  tmp = exp((-b * a)) * x
              else
                  tmp = t_1
              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.exp((-t * y)) * x;
          	double tmp;
          	if (t <= -7.5e+163) {
          		tmp = t_1;
          	} else if (t <= 8e-41) {
          		tmp = Math.exp((-b * a)) * x;
          	} else {
          		tmp = t_1;
          	}
          	return tmp;
          }
          
          def code(x, y, z, t, a, b):
          	t_1 = math.exp((-t * y)) * x
          	tmp = 0
          	if t <= -7.5e+163:
          		tmp = t_1
          	elif t <= 8e-41:
          		tmp = math.exp((-b * a)) * x
          	else:
          		tmp = t_1
          	return tmp
          
          function code(x, y, z, t, a, b)
          	t_1 = Float64(exp(Float64(Float64(-t) * y)) * x)
          	tmp = 0.0
          	if (t <= -7.5e+163)
          		tmp = t_1;
          	elseif (t <= 8e-41)
          		tmp = Float64(exp(Float64(Float64(-b) * a)) * x);
          	else
          		tmp = t_1;
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y, z, t, a, b)
          	t_1 = exp((-t * y)) * x;
          	tmp = 0.0;
          	if (t <= -7.5e+163)
          		tmp = t_1;
          	elseif (t <= 8e-41)
          		tmp = exp((-b * a)) * x;
          	else
          		tmp = t_1;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[Exp[N[((-t) * y), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[t, -7.5e+163], t$95$1, If[LessEqual[t, 8e-41], N[(N[Exp[N[((-b) * a), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision], t$95$1]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_1 := e^{\left(-t\right) \cdot y} \cdot x\\
          \mathbf{if}\;t \leq -7.5 \cdot 10^{+163}:\\
          \;\;\;\;t\_1\\
          
          \mathbf{elif}\;t \leq 8 \cdot 10^{-41}:\\
          \;\;\;\;e^{\left(-b\right) \cdot a} \cdot x\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if t < -7.50000000000000001e163 or 8.00000000000000005e-41 < t

            1. Initial program 95.3%

              \[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 t around inf

              \[\leadsto x \cdot e^{\color{blue}{-1 \cdot \left(t \cdot y\right)}} \]
            4. Step-by-step derivation
              1. associate-*r*N/A

                \[\leadsto x \cdot e^{\color{blue}{\left(-1 \cdot t\right) \cdot y}} \]
              2. mul-1-negN/A

                \[\leadsto x \cdot e^{\color{blue}{\left(\mathsf{neg}\left(t\right)\right)} \cdot y} \]
              3. lower-*.f64N/A

                \[\leadsto x \cdot e^{\color{blue}{\left(\mathsf{neg}\left(t\right)\right) \cdot y}} \]
              4. lower-neg.f6487.0

                \[\leadsto x \cdot e^{\color{blue}{\left(-t\right)} \cdot y} \]
            5. Applied rewrites87.0%

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

            if -7.50000000000000001e163 < t < 8.00000000000000005e-41

            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 b around inf

              \[\leadsto x \cdot e^{\color{blue}{-1 \cdot \left(a \cdot b\right)}} \]
            4. Step-by-step derivation
              1. mul-1-negN/A

                \[\leadsto x \cdot e^{\color{blue}{\mathsf{neg}\left(a \cdot b\right)}} \]
              2. *-commutativeN/A

                \[\leadsto x \cdot e^{\mathsf{neg}\left(\color{blue}{b \cdot a}\right)} \]
              3. distribute-lft-neg-inN/A

                \[\leadsto x \cdot e^{\color{blue}{\left(\mathsf{neg}\left(b\right)\right) \cdot a}} \]
              4. lower-*.f64N/A

                \[\leadsto x \cdot e^{\color{blue}{\left(\mathsf{neg}\left(b\right)\right) \cdot a}} \]
              5. lower-neg.f6463.8

                \[\leadsto x \cdot e^{\color{blue}{\left(-b\right)} \cdot a} \]
            5. Applied rewrites63.8%

              \[\leadsto x \cdot e^{\color{blue}{\left(-b\right) \cdot a}} \]
          3. Recombined 2 regimes into one program.
          4. Final simplification73.5%

            \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -7.5 \cdot 10^{+163}:\\ \;\;\;\;e^{\left(-t\right) \cdot y} \cdot x\\ \mathbf{elif}\;t \leq 8 \cdot 10^{-41}:\\ \;\;\;\;e^{\left(-b\right) \cdot a} \cdot x\\ \mathbf{else}:\\ \;\;\;\;e^{\left(-t\right) \cdot y} \cdot x\\ \end{array} \]
          5. Add Preprocessing

          Alternative 6: 59.2% accurate, 2.9× speedup?

          \[\begin{array}{l} \\ e^{\left(-b\right) \cdot a} \cdot x \end{array} \]
          (FPCore (x y z t a b) :precision binary64 (* (exp (* (- b) a)) x))
          double code(double x, double y, double z, double t, double a, double b) {
          	return exp((-b * a)) * x;
          }
          
          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 = exp((-b * a)) * x
          end function
          
          public static double code(double x, double y, double z, double t, double a, double b) {
          	return Math.exp((-b * a)) * x;
          }
          
          def code(x, y, z, t, a, b):
          	return math.exp((-b * a)) * x
          
          function code(x, y, z, t, a, b)
          	return Float64(exp(Float64(Float64(-b) * a)) * x)
          end
          
          function tmp = code(x, y, z, t, a, b)
          	tmp = exp((-b * a)) * x;
          end
          
          code[x_, y_, z_, t_, a_, b_] := N[(N[Exp[N[((-b) * a), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          e^{\left(-b\right) \cdot a} \cdot x
          \end{array}
          
          Derivation
          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 b around inf

            \[\leadsto x \cdot e^{\color{blue}{-1 \cdot \left(a \cdot b\right)}} \]
          4. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto x \cdot e^{\color{blue}{\mathsf{neg}\left(a \cdot b\right)}} \]
            2. *-commutativeN/A

              \[\leadsto x \cdot e^{\mathsf{neg}\left(\color{blue}{b \cdot a}\right)} \]
            3. distribute-lft-neg-inN/A

              \[\leadsto x \cdot e^{\color{blue}{\left(\mathsf{neg}\left(b\right)\right) \cdot a}} \]
            4. lower-*.f64N/A

              \[\leadsto x \cdot e^{\color{blue}{\left(\mathsf{neg}\left(b\right)\right) \cdot a}} \]
            5. lower-neg.f6455.5

              \[\leadsto x \cdot e^{\color{blue}{\left(-b\right)} \cdot a} \]
          5. Applied rewrites55.5%

            \[\leadsto x \cdot e^{\color{blue}{\left(-b\right) \cdot a}} \]
          6. Final simplification55.5%

            \[\leadsto e^{\left(-b\right) \cdot a} \cdot x \]
          7. Add Preprocessing

          Alternative 7: 27.4% accurate, 3.0× speedup?

          \[\begin{array}{l} \\ e^{b \cdot a} \cdot x \end{array} \]
          (FPCore (x y z t a b) :precision binary64 (* (exp (* b a)) x))
          double code(double x, double y, double z, double t, double a, double b) {
          	return exp((b * a)) * x;
          }
          
          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 = exp((b * a)) * x
          end function
          
          public static double code(double x, double y, double z, double t, double a, double b) {
          	return Math.exp((b * a)) * x;
          }
          
          def code(x, y, z, t, a, b):
          	return math.exp((b * a)) * x
          
          function code(x, y, z, t, a, b)
          	return Float64(exp(Float64(b * a)) * x)
          end
          
          function tmp = code(x, y, z, t, a, b)
          	tmp = exp((b * a)) * x;
          end
          
          code[x_, y_, z_, t_, a_, b_] := N[(N[Exp[N[(b * a), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          e^{b \cdot a} \cdot x
          \end{array}
          
          Derivation
          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 b around inf

            \[\leadsto x \cdot e^{\color{blue}{-1 \cdot \left(a \cdot b\right)}} \]
          4. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto x \cdot e^{\color{blue}{\mathsf{neg}\left(a \cdot b\right)}} \]
            2. *-commutativeN/A

              \[\leadsto x \cdot e^{\mathsf{neg}\left(\color{blue}{b \cdot a}\right)} \]
            3. distribute-lft-neg-inN/A

              \[\leadsto x \cdot e^{\color{blue}{\left(\mathsf{neg}\left(b\right)\right) \cdot a}} \]
            4. lower-*.f64N/A

              \[\leadsto x \cdot e^{\color{blue}{\left(\mathsf{neg}\left(b\right)\right) \cdot a}} \]
            5. lower-neg.f6455.5

              \[\leadsto x \cdot e^{\color{blue}{\left(-b\right)} \cdot a} \]
          5. Applied rewrites55.5%

            \[\leadsto x \cdot e^{\color{blue}{\left(-b\right) \cdot a}} \]
          6. Step-by-step derivation
            1. Applied rewrites51.4%

              \[\leadsto x \cdot e^{\frac{\left(\left(-b\right) \cdot b\right) \cdot a}{\color{blue}{b}}} \]
            2. Step-by-step derivation
              1. lift-*.f64N/A

                \[\leadsto \color{blue}{x \cdot e^{\frac{\left(\left(-b\right) \cdot b\right) \cdot a}{b}}} \]
              2. *-commutativeN/A

                \[\leadsto \color{blue}{e^{\frac{\left(\left(-b\right) \cdot b\right) \cdot a}{b}} \cdot x} \]
              3. lower-*.f6451.4

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

              \[\leadsto \color{blue}{e^{b \cdot a} \cdot x} \]
            4. Add Preprocessing

            Reproduce

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