
(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 13 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 (fma (+ a -0.5) b (fma (log t) (- z) (+ x (+ z y)))))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a + -0.5), b, fma(log(t), -z, (x + (z + y))));
}
function code(x, y, z, t, a, b) return fma(Float64(a + -0.5), b, fma(log(t), Float64(-z), Float64(x + Float64(z + y)))) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a + -0.5), $MachinePrecision] * b + N[(N[Log[t], $MachinePrecision] * (-z) + N[(x + N[(z + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a + -0.5, b, \mathsf{fma}\left(\log t, -z, x + \left(z + y\right)\right)\right)
\end{array}
Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.5
lift--.f64N/A
sub-negN/A
lower-+.f64N/A
metadata-eval99.5
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f6499.5
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lower-+.f64N/A
lower-+.f6499.5
Applied rewrites99.5%
Final simplification99.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* b (- a 0.5))) (t_2 (+ y (fma b (+ a -0.5) x))))
(if (<= t_1 -4e+196)
t_2
(if (<= t_1 4e+97) (+ x (fma b -0.5 (fma z (- 1.0 (log t)) y))) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = b * (a - 0.5);
double t_2 = y + fma(b, (a + -0.5), x);
double tmp;
if (t_1 <= -4e+196) {
tmp = t_2;
} else if (t_1 <= 4e+97) {
tmp = x + fma(b, -0.5, fma(z, (1.0 - log(t)), y));
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(b * Float64(a - 0.5)) t_2 = Float64(y + fma(b, Float64(a + -0.5), x)) tmp = 0.0 if (t_1 <= -4e+196) tmp = t_2; elseif (t_1 <= 4e+97) tmp = Float64(x + fma(b, -0.5, fma(z, Float64(1.0 - log(t)), y))); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y + N[(b * N[(a + -0.5), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+196], t$95$2, If[LessEqual[t$95$1, 4e+97], N[(x + N[(b * -0.5 + N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := b \cdot \left(a - 0.5\right)\\
t_2 := y + \mathsf{fma}\left(b, a + -0.5, x\right)\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+196}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+97}:\\
\;\;\;\;x + \mathsf{fma}\left(b, -0.5, \mathsf{fma}\left(z, 1 - \log t, y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -3.9999999999999998e196 or 4.0000000000000003e97 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 98.9%
Taylor expanded in z around 0
+-commutativeN/A
associate-+l+N/A
lower-+.f64N/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6496.2
Applied rewrites96.2%
if -3.9999999999999998e196 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 4.0000000000000003e97Initial program 99.8%
Taylor expanded in a around 0
associate--l+N/A
lower-+.f64N/A
associate-+r+N/A
+-commutativeN/A
remove-double-negN/A
log-recN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
associate--l+N/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
log-recN/A
remove-double-negN/A
lower-fma.f64N/A
cancel-sign-sub-invN/A
associate-+l+N/A
cancel-sign-sub-invN/A
Applied rewrites92.9%
Final simplification94.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* b (- a 0.5))))
(if (<= t_1 -1e-12)
(fma (+ a -0.5) b (+ x y))
(if (<= t_1 4e+97)
(+ x (fma z (- 1.0 (log t)) y))
(+ y (fma b (+ a -0.5) x))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = b * (a - 0.5);
double tmp;
if (t_1 <= -1e-12) {
tmp = fma((a + -0.5), b, (x + y));
} else if (t_1 <= 4e+97) {
tmp = x + fma(z, (1.0 - log(t)), y);
} else {
tmp = y + fma(b, (a + -0.5), x);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(b * Float64(a - 0.5)) tmp = 0.0 if (t_1 <= -1e-12) tmp = fma(Float64(a + -0.5), b, Float64(x + y)); elseif (t_1 <= 4e+97) tmp = Float64(x + fma(z, Float64(1.0 - log(t)), y)); else tmp = Float64(y + fma(b, Float64(a + -0.5), x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-12], N[(N[(a + -0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+97], N[(x + N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision], N[(y + N[(b * N[(a + -0.5), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := b \cdot \left(a - 0.5\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(a + -0.5, b, x + y\right)\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+97}:\\
\;\;\;\;x + \mathsf{fma}\left(z, 1 - \log t, y\right)\\
\mathbf{else}:\\
\;\;\;\;y + \mathsf{fma}\left(b, a + -0.5, x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -9.9999999999999998e-13Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.9
lift--.f64N/A
sub-negN/A
lower-+.f64N/A
metadata-eval99.9
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f6499.9
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lower-+.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6486.5
Applied rewrites86.5%
if -9.9999999999999998e-13 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 4.0000000000000003e97Initial program 99.8%
Taylor expanded in b around inf
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f643.1
Applied rewrites3.1%
Taylor expanded in b around 0
associate--l+N/A
sub-negN/A
associate-+r+N/A
mul-1-negN/A
lower-+.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-negN/A
*-rgt-identityN/A
distribute-lft-out--N/A
sub-negN/A
mul-1-negN/A
mul-1-negN/A
sub-negN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f6498.5
Applied rewrites98.5%
if 4.0000000000000003e97 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 97.9%
Taylor expanded in z around 0
+-commutativeN/A
associate-+l+N/A
lower-+.f64N/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6494.4
Applied rewrites94.4%
Final simplification92.7%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) -1.35e+42) (+ y (fma b (+ a -0.5) x)) (fma z (- 1.0 (log t)) (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) <= -1.35e+42) {
tmp = y + fma(b, (a + -0.5), x);
} else {
tmp = fma(z, (1.0 - log(t)), fma(b, (a + -0.5), y));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= -1.35e+42) tmp = Float64(y + fma(b, Float64(a + -0.5), x)); else tmp = fma(z, Float64(1.0 - log(t)), fma(b, Float64(a + -0.5), y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], -1.35e+42], N[(y + N[(b * N[(a + -0.5), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] + N[(b * N[(a + -0.5), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -1.35 \cdot 10^{+42}:\\
\;\;\;\;y + \mathsf{fma}\left(b, a + -0.5, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, 1 - \log t, \mathsf{fma}\left(b, a + -0.5, y\right)\right)\\
\end{array}
\end{array}
if (+.f64 x y) < -1.35e42Initial program 98.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-+l+N/A
lower-+.f64N/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6488.3
Applied rewrites88.3%
if -1.35e42 < (+.f64 x y) Initial program 99.8%
Taylor expanded in x around 0
*-commutativeN/A
cancel-sign-sub-invN/A
log-recN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
*-rgt-identityN/A
distribute-lft-inN/A
log-recN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites77.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma z (- 1.0 (log t)) y)))
(if (<= z -3.1e+75)
t_1
(if (<= z 9.5e+115) (fma (+ a -0.5) b (+ x y)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(z, (1.0 - log(t)), y);
double tmp;
if (z <= -3.1e+75) {
tmp = t_1;
} else if (z <= 9.5e+115) {
tmp = fma((a + -0.5), b, (x + y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(z, Float64(1.0 - log(t)), y) tmp = 0.0 if (z <= -3.1e+75) tmp = t_1; elseif (z <= 9.5e+115) tmp = fma(Float64(a + -0.5), b, Float64(x + y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[z, -3.1e+75], t$95$1, If[LessEqual[z, 9.5e+115], N[(N[(a + -0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, 1 - \log t, y\right)\\
\mathbf{if}\;z \leq -3.1 \cdot 10^{+75}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{+115}:\\
\;\;\;\;\mathsf{fma}\left(a + -0.5, b, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.1000000000000001e75 or 9.4999999999999997e115 < z Initial program 98.4%
Taylor expanded in x around 0
*-commutativeN/A
cancel-sign-sub-invN/A
log-recN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
*-rgt-identityN/A
distribute-lft-inN/A
log-recN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites86.6%
Taylor expanded in b around 0
Applied rewrites62.6%
if -3.1000000000000001e75 < z < 9.4999999999999997e115Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
lift--.f64N/A
sub-negN/A
lower-+.f64N/A
metadata-eval100.0
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f64100.0
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lower-+.f64N/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in z around 0
lower-+.f6496.6
Applied rewrites96.6%
(FPCore (x y z t a b) :precision binary64 (if (<= z -4.3e+237) (- z (* (log t) z)) (fma (+ a -0.5) b (+ x y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -4.3e+237) {
tmp = z - (log(t) * z);
} else {
tmp = fma((a + -0.5), b, (x + y));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -4.3e+237) tmp = Float64(z - Float64(log(t) * z)); else tmp = fma(Float64(a + -0.5), b, Float64(x + y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -4.3e+237], N[(z - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(a + -0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.3 \cdot 10^{+237}:\\
\;\;\;\;z - \log t \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a + -0.5, b, x + y\right)\\
\end{array}
\end{array}
if z < -4.2999999999999998e237Initial program 92.6%
Taylor expanded in z around inf
sub-negN/A
log-recN/A
distribute-lft-inN/A
*-rgt-identityN/A
remove-double-negN/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
mul-1-negN/A
distribute-rgt-neg-inN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower-log.f6482.8
Applied rewrites82.8%
if -4.2999999999999998e237 < z Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.9
lift--.f64N/A
sub-negN/A
lower-+.f64N/A
metadata-eval99.9
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f6499.9
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lower-+.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6483.7
Applied rewrites83.7%
Final simplification83.7%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* b (- a 0.5))) (t_2 (fma b (+ a -0.5) y))) (if (<= t_1 -1e+107) t_2 (if (<= t_1 2e+80) (fma -0.5 b (+ x y)) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = b * (a - 0.5);
double t_2 = fma(b, (a + -0.5), y);
double tmp;
if (t_1 <= -1e+107) {
tmp = t_2;
} else if (t_1 <= 2e+80) {
tmp = fma(-0.5, b, (x + y));
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(b * Float64(a - 0.5)) t_2 = fma(b, Float64(a + -0.5), y) tmp = 0.0 if (t_1 <= -1e+107) tmp = t_2; elseif (t_1 <= 2e+80) tmp = fma(-0.5, b, Float64(x + y)); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(b * N[(a + -0.5), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+107], t$95$2, If[LessEqual[t$95$1, 2e+80], N[(-0.5 * b + N[(x + y), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := b \cdot \left(a - 0.5\right)\\
t_2 := \mathsf{fma}\left(b, a + -0.5, y\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+107}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, b, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -9.9999999999999997e106 or 2e80 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.1%
Taylor expanded in x around 0
*-commutativeN/A
cancel-sign-sub-invN/A
log-recN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
*-rgt-identityN/A
distribute-lft-inN/A
log-recN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites88.4%
Taylor expanded in z around 0
Applied rewrites77.5%
if -9.9999999999999997e106 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2e80Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift--.f64N/A
sub-negN/A
lower-+.f64N/A
metadata-eval99.8
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f6499.9
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lower-+.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6471.3
Applied rewrites71.3%
Taylor expanded in a around 0
Applied rewrites67.2%
Final simplification72.2%
(FPCore (x y z t a b) :precision binary64 (if (<= a -0.5) (* a b) (if (<= a 0.0082) (* b -0.5) (* a b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -0.5) {
tmp = a * b;
} else if (a <= 0.0082) {
tmp = b * -0.5;
} else {
tmp = a * b;
}
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) :: tmp
if (a <= (-0.5d0)) then
tmp = a * b
else if (a <= 0.0082d0) then
tmp = b * (-0.5d0)
else
tmp = a * b
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -0.5) {
tmp = a * b;
} else if (a <= 0.0082) {
tmp = b * -0.5;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if a <= -0.5: tmp = a * b elif a <= 0.0082: tmp = b * -0.5 else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -0.5) tmp = Float64(a * b); elseif (a <= 0.0082) tmp = Float64(b * -0.5); else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (a <= -0.5) tmp = a * b; elseif (a <= 0.0082) tmp = b * -0.5; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -0.5], N[(a * b), $MachinePrecision], If[LessEqual[a, 0.0082], N[(b * -0.5), $MachinePrecision], N[(a * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.5:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \leq 0.0082:\\
\;\;\;\;b \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if a < -0.5 or 0.00820000000000000069 < a Initial program 99.2%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6450.8
Applied rewrites50.8%
if -0.5 < a < 0.00820000000000000069Initial program 99.8%
Taylor expanded in b around inf
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6420.5
Applied rewrites20.5%
Taylor expanded in a around 0
Applied rewrites19.9%
Final simplification37.1%
(FPCore (x y z t a b) :precision binary64 (fma (+ a -0.5) b (+ x y)))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a + -0.5), b, (x + y));
}
function code(x, y, z, t, a, b) return fma(Float64(a + -0.5), b, Float64(x + y)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a + -0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a + -0.5, b, x + y\right)
\end{array}
Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.5
lift--.f64N/A
sub-negN/A
lower-+.f64N/A
metadata-eval99.5
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f6499.5
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lower-+.f64N/A
lower-+.f6499.5
Applied rewrites99.5%
Taylor expanded in z around 0
lower-+.f6479.5
Applied rewrites79.5%
(FPCore (x y z t a b) :precision binary64 (+ y (fma b (+ a -0.5) x)))
double code(double x, double y, double z, double t, double a, double b) {
return y + fma(b, (a + -0.5), x);
}
function code(x, y, z, t, a, b) return Float64(y + fma(b, Float64(a + -0.5), x)) end
code[x_, y_, z_, t_, a_, b_] := N[(y + N[(b * N[(a + -0.5), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y + \mathsf{fma}\left(b, a + -0.5, x\right)
\end{array}
Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-+l+N/A
lower-+.f64N/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6479.5
Applied rewrites79.5%
(FPCore (x y z t a b) :precision binary64 (fma b (+ a -0.5) y))
double code(double x, double y, double z, double t, double a, double b) {
return fma(b, (a + -0.5), y);
}
function code(x, y, z, t, a, b) return fma(b, Float64(a + -0.5), y) end
code[x_, y_, z_, t_, a_, b_] := N[(b * N[(a + -0.5), $MachinePrecision] + y), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(b, a + -0.5, y\right)
\end{array}
Initial program 99.5%
Taylor expanded in x around 0
*-commutativeN/A
cancel-sign-sub-invN/A
log-recN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
*-rgt-identityN/A
distribute-lft-inN/A
log-recN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites77.8%
Taylor expanded in z around 0
Applied rewrites58.2%
Final simplification58.2%
(FPCore (x y z t a b) :precision binary64 (* (+ a -0.5) b))
double code(double x, double y, double z, double t, double a, double b) {
return (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 = (a + (-0.5d0)) * b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (a + -0.5) * b;
}
def code(x, y, z, t, a, b): return (a + -0.5) * b
function code(x, y, z, t, a, b) return Float64(Float64(a + -0.5) * b) end
function tmp = code(x, y, z, t, a, b) tmp = (a + -0.5) * b; end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a + -0.5), $MachinePrecision] * b), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.5\right) \cdot b
\end{array}
Initial program 99.5%
Taylor expanded in b around inf
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6437.9
Applied rewrites37.9%
Final simplification37.9%
(FPCore (x y z t a b) :precision binary64 (* a b))
double code(double x, double y, double z, double t, double a, double b) {
return 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 = a * b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a * b;
}
def code(x, y, z, t, a, b): return a * b
function code(x, y, z, t, a, b) return Float64(a * b) end
function tmp = code(x, y, z, t, a, b) tmp = a * b; end
code[x_, y_, z_, t_, a_, b_] := N[(a * b), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b
\end{array}
Initial program 99.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6429.3
Applied rewrites29.3%
Final simplification29.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 2024221
(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)))