
(FPCore (x y z t a b) :precision binary64 (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))
double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * log(t))) + ((a - 0.5) * 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 + y) + z) - (z * log(t))) + ((a - 0.5d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * Math.log(t))) + ((a - 0.5) * b);
}
def code(x, y, z, t, a, b): return (((x + y) + z) - (z * math.log(t))) + ((a - 0.5) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))
double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * log(t))) + ((a - 0.5) * 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 + y) + z) - (z * log(t))) + ((a - 0.5d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * Math.log(t))) + ((a - 0.5) * b);
}
def code(x, y, z, t, a, b): return (((x + y) + z) - (z * math.log(t))) + ((a - 0.5) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
\end{array}
(FPCore (x y z t a b) :precision binary64 (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))
double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * log(t))) + ((a - 0.5) * 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 + y) + z) - (z * log(t))) + ((a - 0.5d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * Math.log(t))) + ((a - 0.5) * b);
}
def code(x, y, z, t, a, b): return (((x + y) + z) - (z * math.log(t))) + ((a - 0.5) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
\end{array}
Initial program 99.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))) (t_2 (* (- a 0.5) b)))
(if (<= t_2 -2e+39)
(fma (- a 0.5) b (+ y x))
(if (<= t_2 2e+133)
(+ (fma t_1 z y) (fma -0.5 b x))
(fma t_1 z (fma (+ -0.5 a) b x))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 - log(t);
double t_2 = (a - 0.5) * b;
double tmp;
if (t_2 <= -2e+39) {
tmp = fma((a - 0.5), b, (y + x));
} else if (t_2 <= 2e+133) {
tmp = fma(t_1, z, y) + fma(-0.5, b, x);
} else {
tmp = fma(t_1, z, fma((-0.5 + a), b, x));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) t_2 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if (t_2 <= -2e+39) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); elseif (t_2 <= 2e+133) tmp = Float64(fma(t_1, z, y) + fma(-0.5, b, x)); else tmp = fma(t_1, z, fma(Float64(-0.5 + a), b, x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+39], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+133], N[(N[(t$95$1 * z + y), $MachinePrecision] + N[(-0.5 * b + x), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * z + N[(N[(-0.5 + a), $MachinePrecision] * b + x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
t_2 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+39}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+133}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, y\right) + \mathsf{fma}\left(-0.5, b, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, \mathsf{fma}\left(-0.5 + a, b, x\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1.99999999999999988e39Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6492.8
Applied rewrites92.8%
if -1.99999999999999988e39 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2e133Initial program 99.9%
Taylor expanded in a around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
+-commutativeN/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
+-commutativeN/A
log-recN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
Applied rewrites97.9%
if 2e133 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites97.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))) (t_2 (* (- a 0.5) b)))
(if (<= t_2 -2e+39)
(fma (- a 0.5) b (+ y x))
(if (<= t_2 2e+133)
(+ (fma t_1 z y) (fma -0.5 b x))
(fma t_1 z (* b (- a 0.5)))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 - log(t);
double t_2 = (a - 0.5) * b;
double tmp;
if (t_2 <= -2e+39) {
tmp = fma((a - 0.5), b, (y + x));
} else if (t_2 <= 2e+133) {
tmp = fma(t_1, z, y) + fma(-0.5, b, x);
} else {
tmp = fma(t_1, z, (b * (a - 0.5)));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) t_2 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if (t_2 <= -2e+39) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); elseif (t_2 <= 2e+133) tmp = Float64(fma(t_1, z, y) + fma(-0.5, b, x)); else tmp = fma(t_1, z, Float64(b * Float64(a - 0.5))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+39], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+133], N[(N[(t$95$1 * z + y), $MachinePrecision] + N[(-0.5 * b + x), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * z + N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
t_2 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+39}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+133}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, y\right) + \mathsf{fma}\left(-0.5, b, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, b \cdot \left(a - 0.5\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1.99999999999999988e39Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6492.8
Applied rewrites92.8%
if -1.99999999999999988e39 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2e133Initial program 99.9%
Taylor expanded in a around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
+-commutativeN/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
+-commutativeN/A
log-recN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
Applied rewrites97.9%
if 2e133 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites97.8%
Taylor expanded in x around 0
Applied rewrites97.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- a 0.5) b)))
(if (<= t_1 -2e+39)
(fma (- a 0.5) b (+ y x))
(if (<= t_1 2e+133)
(fma (- z) (log t) (+ (+ z y) x))
(fma (- 1.0 (log t)) z (* b (- a 0.5)))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double tmp;
if (t_1 <= -2e+39) {
tmp = fma((a - 0.5), b, (y + x));
} else if (t_1 <= 2e+133) {
tmp = fma(-z, log(t), ((z + y) + x));
} else {
tmp = fma((1.0 - log(t)), z, (b * (a - 0.5)));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if (t_1 <= -2e+39) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); elseif (t_1 <= 2e+133) tmp = fma(Float64(-z), log(t), Float64(Float64(z + y) + x)); else tmp = fma(Float64(1.0 - log(t)), z, Float64(b * Float64(a - 0.5))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+39], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+133], N[((-z) * N[Log[t], $MachinePrecision] + N[(N[(z + y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+39}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+133}:\\
\;\;\;\;\mathsf{fma}\left(-z, \log t, \left(z + y\right) + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, b \cdot \left(a - 0.5\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1.99999999999999988e39Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6492.8
Applied rewrites92.8%
if -1.99999999999999988e39 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2e133Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6465.3
Applied rewrites65.3%
Taylor expanded in b around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
log-recN/A
*-commutativeN/A
+-commutativeN/A
log-recN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6494.5
Applied rewrites94.5%
if 2e133 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites97.8%
Taylor expanded in x around 0
Applied rewrites97.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- a 0.5) b)))
(if (<= t_1 -2e+39)
(fma (- a 0.5) b (+ y x))
(if (<= t_1 1e+147)
(fma (- z) (log t) (+ (+ z y) x))
(fma b (- a 0.5) y)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double tmp;
if (t_1 <= -2e+39) {
tmp = fma((a - 0.5), b, (y + x));
} else if (t_1 <= 1e+147) {
tmp = fma(-z, log(t), ((z + y) + x));
} else {
tmp = fma(b, (a - 0.5), y);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if (t_1 <= -2e+39) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); elseif (t_1 <= 1e+147) tmp = fma(Float64(-z), log(t), Float64(Float64(z + y) + x)); else tmp = fma(b, Float64(a - 0.5), y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+39], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+147], N[((-z) * N[Log[t], $MachinePrecision] + N[(N[(z + y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(b * N[(a - 0.5), $MachinePrecision] + y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+39}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{elif}\;t\_1 \leq 10^{+147}:\\
\;\;\;\;\mathsf{fma}\left(-z, \log t, \left(z + y\right) + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a - 0.5, y\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1.99999999999999988e39Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6492.8
Applied rewrites92.8%
if -1.99999999999999988e39 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 9.9999999999999998e146Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6464.9
Applied rewrites64.9%
Taylor expanded in b around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
log-recN/A
*-commutativeN/A
+-commutativeN/A
log-recN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6494.5
Applied rewrites94.5%
if 9.9999999999999998e146 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6488.8
Applied rewrites88.8%
Taylor expanded in x around 0
Applied rewrites88.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ (+ x y) z) (* z (log t))) -2e-161) (fma b (- a 0.5) x) (fma b (- a 0.5) y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((((x + y) + z) - (z * log(t))) <= -2e-161) {
tmp = fma(b, (a - 0.5), x);
} else {
tmp = fma(b, (a - 0.5), y);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) <= -2e-161) tmp = fma(b, Float64(a - 0.5), x); else tmp = fma(b, Float64(a - 0.5), y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-161], N[(b * N[(a - 0.5), $MachinePrecision] + x), $MachinePrecision], N[(b * N[(a - 0.5), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(x + y\right) + z\right) - z \cdot \log t \leq -2 \cdot 10^{-161}:\\
\;\;\;\;\mathsf{fma}\left(b, a - 0.5, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a - 0.5, y\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) < -2.00000000000000006e-161Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites82.7%
Taylor expanded in z around 0
Applied rewrites56.3%
if -2.00000000000000006e-161 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6479.6
Applied rewrites79.6%
Taylor expanded in x around 0
Applied rewrites53.4%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -9.4e+219) (not (<= z 1.6e+153))) (fma (- 1.0 (log t)) z x) (fma (- a 0.5) b (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -9.4e+219) || !(z <= 1.6e+153)) {
tmp = fma((1.0 - log(t)), z, x);
} else {
tmp = fma((a - 0.5), b, (y + x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -9.4e+219) || !(z <= 1.6e+153)) tmp = fma(Float64(1.0 - log(t)), z, x); else tmp = fma(Float64(a - 0.5), b, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -9.4e+219], N[Not[LessEqual[z, 1.6e+153]], $MachinePrecision]], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.4 \cdot 10^{+219} \lor \neg \left(z \leq 1.6 \cdot 10^{+153}\right):\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\end{array}
\end{array}
if z < -9.40000000000000027e219 or 1.6000000000000001e153 < z Initial program 99.6%
Taylor expanded in y around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites93.7%
Taylor expanded in b around 0
Applied rewrites87.6%
if -9.40000000000000027e219 < z < 1.6000000000000001e153Initial program 100.0%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6488.4
Applied rewrites88.4%
Final simplification88.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))))
(if (<= z -9.4e+219)
(fma -0.5 b (* t_1 z))
(if (<= z 1.6e+153) (fma (- a 0.5) b (+ y x)) (fma t_1 z x)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 - log(t);
double tmp;
if (z <= -9.4e+219) {
tmp = fma(-0.5, b, (t_1 * z));
} else if (z <= 1.6e+153) {
tmp = fma((a - 0.5), b, (y + x));
} else {
tmp = fma(t_1, z, x);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) tmp = 0.0 if (z <= -9.4e+219) tmp = fma(-0.5, b, Float64(t_1 * z)); elseif (z <= 1.6e+153) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); else tmp = fma(t_1, z, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -9.4e+219], N[(-0.5 * b + N[(t$95$1 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.6e+153], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * z + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
\mathbf{if}\;z \leq -9.4 \cdot 10^{+219}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, b, t\_1 \cdot z\right)\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, x\right)\\
\end{array}
\end{array}
if z < -9.40000000000000027e219Initial program 99.7%
Taylor expanded in y around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites99.5%
Taylor expanded in a around 0
Applied rewrites99.5%
Taylor expanded in x around 0
Applied rewrites93.8%
if -9.40000000000000027e219 < z < 1.6000000000000001e153Initial program 100.0%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6488.4
Applied rewrites88.4%
if 1.6000000000000001e153 < z Initial program 99.5%
Taylor expanded in y around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites90.9%
Taylor expanded in b around 0
Applied rewrites84.6%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -9.4e+219) (not (<= z 2.35e+179))) (* (- 1.0 (log t)) z) (fma (- a 0.5) b (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -9.4e+219) || !(z <= 2.35e+179)) {
tmp = (1.0 - log(t)) * z;
} else {
tmp = fma((a - 0.5), b, (y + x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -9.4e+219) || !(z <= 2.35e+179)) tmp = Float64(Float64(1.0 - log(t)) * z); else tmp = fma(Float64(a - 0.5), b, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -9.4e+219], N[Not[LessEqual[z, 2.35e+179]], $MachinePrecision]], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.4 \cdot 10^{+219} \lor \neg \left(z \leq 2.35 \cdot 10^{+179}\right):\\
\;\;\;\;\left(1 - \log t\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\end{array}
\end{array}
if z < -9.40000000000000027e219 or 2.35000000000000003e179 < z Initial program 99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6484.4
Applied rewrites84.4%
if -9.40000000000000027e219 < z < 2.35000000000000003e179Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6487.9
Applied rewrites87.9%
Final simplification87.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- a 0.5) b)))
(if (or (<= t_1 -2e+158) (not (<= t_1 5e+90)))
(* b (- a 0.5))
(fma b -0.5 x))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double tmp;
if ((t_1 <= -2e+158) || !(t_1 <= 5e+90)) {
tmp = b * (a - 0.5);
} else {
tmp = fma(b, -0.5, x);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if ((t_1 <= -2e+158) || !(t_1 <= 5e+90)) tmp = Float64(b * Float64(a - 0.5)); else tmp = fma(b, -0.5, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+158], N[Not[LessEqual[t$95$1, 5e+90]], $MachinePrecision]], N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision], N[(b * -0.5 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+158} \lor \neg \left(t\_1 \leq 5 \cdot 10^{+90}\right):\\
\;\;\;\;b \cdot \left(a - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, -0.5, x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1.99999999999999991e158 or 5.0000000000000004e90 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in y around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites93.9%
Taylor expanded in z around 0
Applied rewrites83.8%
Taylor expanded in x around 0
Applied rewrites78.0%
if -1.99999999999999991e158 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 5.0000000000000004e90Initial program 99.8%
Taylor expanded in y around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites76.0%
Taylor expanded in z around 0
Applied rewrites44.6%
Taylor expanded in a around 0
Applied rewrites40.3%
Final simplification54.3%
(FPCore (x y z t a b) :precision binary64 (if (or (<= a -1.75e+134) (not (<= a 5.1e+63))) (* b a) (fma b -0.5 x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a <= -1.75e+134) || !(a <= 5.1e+63)) {
tmp = b * a;
} else {
tmp = fma(b, -0.5, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((a <= -1.75e+134) || !(a <= 5.1e+63)) tmp = Float64(b * a); else tmp = fma(b, -0.5, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[a, -1.75e+134], N[Not[LessEqual[a, 5.1e+63]], $MachinePrecision]], N[(b * a), $MachinePrecision], N[(b * -0.5 + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.75 \cdot 10^{+134} \lor \neg \left(a \leq 5.1 \cdot 10^{+63}\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, -0.5, x\right)\\
\end{array}
\end{array}
if a < -1.75000000000000001e134 or 5.0999999999999998e63 < a Initial program 100.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6468.1
Applied rewrites68.1%
if -1.75000000000000001e134 < a < 5.0999999999999998e63Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites81.2%
Taylor expanded in z around 0
Applied rewrites50.1%
Taylor expanded in a around 0
Applied rewrites45.4%
Final simplification52.0%
(FPCore (x y z t a b) :precision binary64 (fma (- a 0.5) b (+ y x)))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a - 0.5), b, (y + x));
}
function code(x, y, z, t, a, b) return fma(Float64(a - 0.5), b, Float64(y + x)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, y + x\right)
\end{array}
Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6476.0
Applied rewrites76.0%
(FPCore (x y z t a b) :precision binary64 (fma b (- a 0.5) x))
double code(double x, double y, double z, double t, double a, double b) {
return fma(b, (a - 0.5), x);
}
function code(x, y, z, t, a, b) return fma(b, Float64(a - 0.5), x) end
code[x_, y_, z_, t_, a_, b_] := N[(b * N[(a - 0.5), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(b, a - 0.5, x\right)
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites82.7%
Taylor expanded in z around 0
Applied rewrites59.1%
(FPCore (x y z t a b) :precision binary64 (* b a))
double code(double x, double y, double z, double t, double a, double b) {
return b * a;
}
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 = b * a
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return b * a;
}
def code(x, y, z, t, a, b): return b * a
function code(x, y, z, t, a, b) return Float64(b * a) end
function tmp = code(x, y, z, t, a, b) tmp = b * a; end
code[x_, y_, z_, t_, a_, b_] := N[(b * a), $MachinePrecision]
\begin{array}{l}
\\
b \cdot a
\end{array}
Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6424.3
Applied rewrites24.3%
(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x y) (/ (* (- 1.0 (pow (log t) 2.0)) z) (+ 1.0 (log t)))) (* (- a 0.5) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + y) + (((1.0 - pow(log(t), 2.0)) * z) / (1.0 + log(t)))) + ((a - 0.5) * 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 + y) + (((1.0d0 - (log(t) ** 2.0d0)) * z) / (1.0d0 + log(t)))) + ((a - 0.5d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x + y) + (((1.0 - Math.pow(Math.log(t), 2.0)) * z) / (1.0 + Math.log(t)))) + ((a - 0.5) * b);
}
def code(x, y, z, t, a, b): return ((x + y) + (((1.0 - math.pow(math.log(t), 2.0)) * z) / (1.0 + math.log(t)))) + ((a - 0.5) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x + y) + Float64(Float64(Float64(1.0 - (log(t) ^ 2.0)) * z) / Float64(1.0 + log(t)))) + Float64(Float64(a - 0.5) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x + y) + (((1.0 - (log(t) ^ 2.0)) * z) / (1.0 + log(t)))) + ((a - 0.5) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + y), $MachinePrecision] + N[(N[(N[(1.0 - N[Power[N[Log[t], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision] / N[(1.0 + N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y\right) + \frac{\left(1 - {\log t}^{2}\right) \cdot z}{1 + \log t}\right) + \left(a - 0.5\right) \cdot b
\end{array}
herbie shell --seed 2024326
(FPCore (x y z t a b)
:name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, A"
:precision binary64
:alt
(! :herbie-platform default (+ (+ (+ x y) (/ (* (- 1 (pow (log t) 2)) z) (+ 1 (log t)))) (* (- a 1/2) b)))
(+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))