
(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:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (x y z t a b) :precision binary64 (* x (exp (- (* y (- (log z) t)) (* a (+ z b))))))
double code(double x, double y, double z, double t, double a, double b) {
return x * exp(((y * (log(z) - t)) - (a * (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 * (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 * (z + b))));
}
def code(x, y, z, t, a, b): return x * math.exp(((y * (math.log(z) - t)) - (a * (z + b))))
function code(x, y, z, t, a, b) return Float64(x * exp(Float64(Float64(y * Float64(log(z) - t)) - Float64(a * Float64(z + b))))) end
function tmp = code(x, y, z, t, a, b) tmp = x * exp(((y * (log(z) - t)) - (a * (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[(z + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{y \cdot \left(\log z - t\right) - a \cdot \left(z + b\right)}
\end{array}
Initial program 97.7%
Taylor expanded in z around 0 100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-lft-out100.0%
neg-mul-1100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z t a b) :precision binary64 (* x (exp (- (* y (- (log z) t)) (* a b)))))
double code(double x, double y, double z, double t, double a, double b) {
return x * exp(((y * (log(z) - t)) - (a * 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 * 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 * b)));
}
def code(x, y, z, t, a, b): return x * math.exp(((y * (math.log(z) - t)) - (a * b)))
function code(x, y, z, t, a, b) return Float64(x * exp(Float64(Float64(y * Float64(log(z) - t)) - Float64(a * b)))) end
function tmp = code(x, y, z, t, a, b) tmp = x * exp(((y * (log(z) - t)) - (a * 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 * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{y \cdot \left(\log z - t\right) - a \cdot b}
\end{array}
Initial program 97.7%
Taylor expanded in z around 0 97.7%
+-commutative97.7%
mul-1-neg97.7%
sub-neg97.7%
Simplified97.7%
Final simplification97.7%
(FPCore (x y z t a b) :precision binary64 (* x (exp (- (* y (- t)) (* a b)))))
double code(double x, double y, double z, double t, double a, double b) {
return x * exp(((y * -t) - (a * 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 * -t) - (a * b)))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x * Math.exp(((y * -t) - (a * b)));
}
def code(x, y, z, t, a, b): return x * math.exp(((y * -t) - (a * b)))
function code(x, y, z, t, a, b) return Float64(x * exp(Float64(Float64(y * Float64(-t)) - Float64(a * b)))) end
function tmp = code(x, y, z, t, a, b) tmp = x * exp(((y * -t) - (a * b))); end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Exp[N[(N[(y * (-t)), $MachinePrecision] - N[(a * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{y \cdot \left(-t\right) - a \cdot b}
\end{array}
Initial program 97.7%
Taylor expanded in z around 0 97.7%
+-commutative97.7%
mul-1-neg97.7%
sub-neg97.7%
Simplified97.7%
Taylor expanded in t around inf 88.0%
mul-1-neg57.1%
distribute-lft-neg-out57.1%
*-commutative57.1%
Simplified88.0%
Final simplification88.0%
(FPCore (x y z t a b) :precision binary64 (* x (exp (* a (- (- b) z)))))
double code(double x, double y, double z, double t, double a, double b) {
return x * exp((a * (-b - 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 = x * exp((a * (-b - z)))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x * Math.exp((a * (-b - z)));
}
def code(x, y, z, t, a, b): return x * math.exp((a * (-b - z)))
function code(x, y, z, t, a, b) return Float64(x * exp(Float64(a * Float64(Float64(-b) - z)))) end
function tmp = code(x, y, z, t, a, b) tmp = x * exp((a * (-b - z))); end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Exp[N[(a * N[((-b) - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{a \cdot \left(\left(-b\right) - z\right)}
\end{array}
Initial program 97.7%
Taylor expanded in z around 0 100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-lft-out100.0%
neg-mul-1100.0%
Simplified100.0%
Taylor expanded in y around 0 62.9%
*-commutative62.9%
mul-1-neg62.9%
distribute-rgt-neg-in62.9%
Simplified62.9%
Final simplification62.9%
(FPCore (x y z t a b) :precision binary64 (* x (exp (* a (- b)))))
double code(double x, double y, double z, double t, double a, double b) {
return x * exp((a * -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((a * -b))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x * Math.exp((a * -b));
}
def code(x, y, z, t, a, b): return x * math.exp((a * -b))
function code(x, y, z, t, a, b) return Float64(x * exp(Float64(a * Float64(-b)))) end
function tmp = code(x, y, z, t, a, b) tmp = x * exp((a * -b)); end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Exp[N[(a * (-b)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{a \cdot \left(-b\right)}
\end{array}
Initial program 97.7%
Taylor expanded in y around 0 61.4%
Taylor expanded in z around 0 61.0%
neg-mul-161.0%
distribute-rgt-neg-in61.0%
Simplified61.0%
Final simplification61.0%
(FPCore (x y z t a b) :precision binary64 (* x (pow z y)))
double code(double x, double y, double z, double t, double a, double b) {
return x * pow(z, y);
}
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 * (z ** y)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x * Math.pow(z, y);
}
def code(x, y, z, t, a, b): return x * math.pow(z, y)
function code(x, y, z, t, a, b) return Float64(x * (z ^ y)) end
function tmp = code(x, y, z, t, a, b) tmp = x * (z ^ y); end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Power[z, y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot {z}^{y}
\end{array}
Initial program 97.7%
Taylor expanded in a around 0 73.1%
Taylor expanded in t around 0 47.6%
Final simplification47.6%
(FPCore (x y z t a b) :precision binary64 (- x (* a (* x (+ z b)))))
double code(double x, double y, double z, double t, double a, double b) {
return x - (a * (x * (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 - (a * (x * (z + b)))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x - (a * (x * (z + b)));
}
def code(x, y, z, t, a, b): return x - (a * (x * (z + b)))
function code(x, y, z, t, a, b) return Float64(x - Float64(a * Float64(x * Float64(z + b)))) end
function tmp = code(x, y, z, t, a, b) tmp = x - (a * (x * (z + b))); end
code[x_, y_, z_, t_, a_, b_] := N[(x - N[(a * N[(x * N[(z + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - a \cdot \left(x \cdot \left(z + b\right)\right)
\end{array}
Initial program 97.7%
Taylor expanded in z around 0 100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-lft-out100.0%
neg-mul-1100.0%
Simplified100.0%
Taylor expanded in y around 0 62.9%
*-commutative62.9%
mul-1-neg62.9%
distribute-rgt-neg-in62.9%
Simplified62.9%
Taylor expanded in a around 0 23.7%
mul-1-neg23.7%
unsub-neg23.7%
+-commutative23.7%
Simplified23.7%
Final simplification23.7%
(FPCore (x y z t a b) :precision binary64 (* x (- 1.0 (* a (+ z b)))))
double code(double x, double y, double z, double t, double a, double b) {
return x * (1.0 - (a * (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 * (1.0d0 - (a * (z + b)))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x * (1.0 - (a * (z + b)));
}
def code(x, y, z, t, a, b): return x * (1.0 - (a * (z + b)))
function code(x, y, z, t, a, b) return Float64(x * Float64(1.0 - Float64(a * Float64(z + b)))) end
function tmp = code(x, y, z, t, a, b) tmp = x * (1.0 - (a * (z + b))); end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[(1.0 - N[(a * N[(z + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - a \cdot \left(z + b\right)\right)
\end{array}
Initial program 97.7%
Taylor expanded in z around 0 100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-lft-out100.0%
neg-mul-1100.0%
Simplified100.0%
Taylor expanded in y around 0 62.9%
*-commutative62.9%
mul-1-neg62.9%
distribute-rgt-neg-in62.9%
Simplified62.9%
Taylor expanded in a around 0 25.9%
associate-*r*25.9%
neg-mul-125.9%
+-commutative25.9%
Simplified25.9%
Final simplification25.9%
(FPCore (x y z t a b) :precision binary64 (* x (- 1.0 (* y t))))
double code(double x, double y, double z, double t, double a, double b) {
return x * (1.0 - (y * 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 = x * (1.0d0 - (y * t))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x * (1.0 - (y * t));
}
def code(x, y, z, t, a, b): return x * (1.0 - (y * t))
function code(x, y, z, t, a, b) return Float64(x * Float64(1.0 - Float64(y * t))) end
function tmp = code(x, y, z, t, a, b) tmp = x * (1.0 - (y * t)); end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[(1.0 - N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - y \cdot t\right)
\end{array}
Initial program 97.7%
Taylor expanded in a around 0 73.1%
Taylor expanded in t around inf 57.1%
mul-1-neg57.1%
distribute-lft-neg-out57.1%
*-commutative57.1%
Simplified57.1%
Taylor expanded in y around 0 22.9%
mul-1-neg22.9%
*-commutative22.9%
unsub-neg22.9%
Simplified22.9%
Final simplification22.9%
(FPCore (x y z t a b) :precision binary64 x)
double code(double x, double y, double z, double t, double a, double b) {
return 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 = x
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x;
}
def code(x, y, z, t, a, b): return x
function code(x, y, z, t, a, b) return x end
function tmp = code(x, y, z, t, a, b) tmp = x; end
code[x_, y_, z_, t_, a_, b_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 97.7%
Taylor expanded in a around 0 73.1%
Taylor expanded in y around 0 15.7%
Final simplification15.7%
herbie shell --seed 2024033
(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))))))