
(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 15 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 (+ (* b (- a 0.5)) (- (+ z (+ y x)) (* (log t) z))))
double code(double x, double y, double z, double t, double a, double b) {
return (b * (a - 0.5)) + ((z + (y + x)) - (log(t) * 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 = (b * (a - 0.5d0)) + ((z + (y + x)) - (log(t) * z))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (b * (a - 0.5)) + ((z + (y + x)) - (Math.log(t) * z));
}
def code(x, y, z, t, a, b): return (b * (a - 0.5)) + ((z + (y + x)) - (math.log(t) * z))
function code(x, y, z, t, a, b) return Float64(Float64(b * Float64(a - 0.5)) + Float64(Float64(z + Float64(y + x)) - Float64(log(t) * z))) end
function tmp = code(x, y, z, t, a, b) tmp = (b * (a - 0.5)) + ((z + (y + x)) - (log(t) * z)); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision] + N[(N[(z + N[(y + x), $MachinePrecision]), $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot \left(a - 0.5\right) + \left(\left(z + \left(y + x\right)\right) - \log t \cdot z\right)
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* b (- a 0.5))) (t_2 (fma (- a 0.5) b (+ y x))))
(if (<= t_1 -2e+95)
t_2
(if (<= t_1 5e+147) (+ (fma -0.5 b x) (fma (- 1.0 (log t)) z 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((a - 0.5), b, (y + x));
double tmp;
if (t_1 <= -2e+95) {
tmp = t_2;
} else if (t_1 <= 5e+147) {
tmp = fma(-0.5, b, x) + fma((1.0 - log(t)), z, 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(Float64(a - 0.5), b, Float64(y + x)) tmp = 0.0 if (t_1 <= -2e+95) tmp = t_2; elseif (t_1 <= 5e+147) tmp = Float64(fma(-0.5, b, x) + fma(Float64(1.0 - log(t)), z, 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[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+95], t$95$2, If[LessEqual[t$95$1, 5e+147], N[(N[(-0.5 * b + x), $MachinePrecision] + N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + 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(a - 0.5, b, y + x\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+95}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+147}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, b, x\right) + \mathsf{fma}\left(1 - \log t, z, y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -2.00000000000000004e95 or 5.0000000000000002e147 < (*.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-+.f6493.5
Applied rewrites93.5%
if -2.00000000000000004e95 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 5.0000000000000002e147Initial program 99.8%
Taylor expanded in a around 0
*-commutativeN/A
cancel-sign-sub-invN/A
log-recN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
log-recN/A
cancel-sign-sub-invN/A
*-commutativeN/A
lower-+.f64N/A
Applied rewrites92.8%
Final simplification93.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* b (- a 0.5))) (t_2 (fma (- a 0.5) b (+ y x))))
(if (<= t_1 -2e+95)
t_2
(if (<= t_1 5e+60) (fma (- 1.0 (log t)) z (+ y x)) 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((a - 0.5), b, (y + x));
double tmp;
if (t_1 <= -2e+95) {
tmp = t_2;
} else if (t_1 <= 5e+60) {
tmp = fma((1.0 - log(t)), z, (y + x));
} 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(Float64(a - 0.5), b, Float64(y + x)) tmp = 0.0 if (t_1 <= -2e+95) tmp = t_2; elseif (t_1 <= 5e+60) tmp = fma(Float64(1.0 - log(t)), z, Float64(y + x)); 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[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+95], t$95$2, If[LessEqual[t$95$1, 5e+60], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(y + x), $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(a - 0.5, b, y + x\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+95}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+60}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -2.00000000000000004e95 or 4.99999999999999975e60 < (*.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-+.f6490.5
Applied rewrites90.5%
if -2.00000000000000004e95 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 4.99999999999999975e60Initial program 99.8%
Taylor expanded in y around 0
*-commutativeN/A
cancel-sign-sub-invN/A
log-recN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
log-recN/A
sub-negN/A
*-commutativeN/A
sub-negN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites67.4%
Taylor expanded in b around 0
cancel-sign-sub-invN/A
associate-+r+N/A
associate-+l+N/A
cancel-sign-sub-invN/A
*-rgt-identityN/A
distribute-lft-out--N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6491.6
Applied rewrites91.6%
Final simplification91.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (- a 0.5) b (+ y x))))
(if (<= (+ y x) -5e+97)
t_1
(if (<= (+ y x) 5e+16) (fma (- 1.0 (log t)) z (* b (- a 0.5))) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma((a - 0.5), b, (y + x));
double tmp;
if ((y + x) <= -5e+97) {
tmp = t_1;
} else if ((y + x) <= 5e+16) {
tmp = fma((1.0 - log(t)), z, (b * (a - 0.5)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(a - 0.5), b, Float64(y + x)) tmp = 0.0 if (Float64(y + x) <= -5e+97) tmp = t_1; elseif (Float64(y + x) <= 5e+16) tmp = fma(Float64(1.0 - log(t)), z, Float64(b * Float64(a - 0.5))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y + x), $MachinePrecision], -5e+97], t$95$1, If[LessEqual[N[(y + x), $MachinePrecision], 5e+16], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{if}\;y + x \leq -5 \cdot 10^{+97}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y + x \leq 5 \cdot 10^{+16}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, b \cdot \left(a - 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x y) < -4.99999999999999999e97 or 5e16 < (+.f64 x y) 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-+.f6491.9
Applied rewrites91.9%
if -4.99999999999999999e97 < (+.f64 x y) < 5e16Initial program 99.8%
Taylor expanded in y around 0
*-commutativeN/A
cancel-sign-sub-invN/A
log-recN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
log-recN/A
sub-negN/A
*-commutativeN/A
sub-negN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites97.3%
Taylor expanded in x around 0
Applied rewrites93.7%
Final simplification92.6%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ z (+ y x)) (* (log t) z)) -5e-121) (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 (((z + (y + x)) - (log(t) * z)) <= -5e-121) {
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(z + Float64(y + x)) - Float64(log(t) * z)) <= -5e-121) 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[(z + N[(y + x), $MachinePrecision]), $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], -5e-121], 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(z + \left(y + x\right)\right) - \log t \cdot z \leq -5 \cdot 10^{-121}:\\
\;\;\;\;\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))) < -4.99999999999999989e-121Initial 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.9
Applied rewrites79.9%
Taylor expanded in y around 0
Applied rewrites55.8%
if -4.99999999999999989e-121 < (-.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-+.f6481.2
Applied rewrites81.2%
Taylor expanded in x around 0
Applied rewrites60.9%
Final simplification58.6%
(FPCore (x y z t a b) :precision binary64 (if (<= y 1.25e+18) (fma (- 1.0 (log t)) z (fma (- a 0.5) b 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 (y <= 1.25e+18) {
tmp = fma((1.0 - log(t)), z, fma((a - 0.5), b, x));
} else {
tmp = fma((a - 0.5), b, (y + x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= 1.25e+18) tmp = fma(Float64(1.0 - log(t)), z, fma(Float64(a - 0.5), b, x)); else tmp = fma(Float64(a - 0.5), b, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, 1.25e+18], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(N[(a - 0.5), $MachinePrecision] * b + x), $MachinePrecision]), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.25 \cdot 10^{+18}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\end{array}
\end{array}
if y < 1.25e18Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
cancel-sign-sub-invN/A
log-recN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
log-recN/A
sub-negN/A
*-commutativeN/A
sub-negN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites86.3%
if 1.25e18 < y 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-+.f6491.5
Applied rewrites91.5%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (- 1.0 (log t)) z x))) (if (<= z -1.9e+208) t_1 (if (<= z 2e+185) (fma (- a 0.5) b (+ y x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma((1.0 - log(t)), z, x);
double tmp;
if (z <= -1.9e+208) {
tmp = t_1;
} else if (z <= 2e+185) {
tmp = fma((a - 0.5), b, (y + x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(1.0 - log(t)), z, x) tmp = 0.0 if (z <= -1.9e+208) tmp = t_1; elseif (z <= 2e+185) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[z, -1.9e+208], t$95$1, If[LessEqual[z, 2e+185], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1 - \log t, z, x\right)\\
\mathbf{if}\;z \leq -1.9 \cdot 10^{+208}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2 \cdot 10^{+185}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.9000000000000001e208 or 2e185 < z Initial program 99.6%
Taylor expanded in y around 0
*-commutativeN/A
cancel-sign-sub-invN/A
log-recN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
log-recN/A
sub-negN/A
*-commutativeN/A
sub-negN/A
mul-1-negN/A
lower-fma.f64N/A
Applied rewrites95.1%
Taylor expanded in b around 0
Applied rewrites83.5%
if -1.9000000000000001e208 < z < 2e185Initial 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-+.f6490.2
Applied rewrites90.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- 1.0 (log t)) z)))
(if (<= z -3.1e+208)
t_1
(if (<= z 1.2e+257) (fma (- a 0.5) b (+ y x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (1.0 - log(t)) * z;
double tmp;
if (z <= -3.1e+208) {
tmp = t_1;
} else if (z <= 1.2e+257) {
tmp = fma((a - 0.5), b, (y + x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(1.0 - log(t)) * z) tmp = 0.0 if (z <= -3.1e+208) tmp = t_1; elseif (z <= 1.2e+257) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -3.1e+208], t$95$1, If[LessEqual[z, 1.2e+257], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(1 - \log t\right) \cdot z\\
\mathbf{if}\;z \leq -3.1 \cdot 10^{+208}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{+257}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.09999999999999981e208 or 1.2e257 < z Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
sub-negN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
lower-log.f6482.7
Applied rewrites82.7%
if -3.09999999999999981e208 < z < 1.2e257Initial 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-+.f6488.2
Applied rewrites88.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* b (- a 0.5))))
(if (<= t_1 -5e+233)
(* b a)
(if (<= t_1 5e+43) (+ y x) (if (<= t_1 4e+297) (fma b -0.5 x) (* b a))))))
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 <= -5e+233) {
tmp = b * a;
} else if (t_1 <= 5e+43) {
tmp = y + x;
} else if (t_1 <= 4e+297) {
tmp = fma(b, -0.5, x);
} else {
tmp = b * a;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(b * Float64(a - 0.5)) tmp = 0.0 if (t_1 <= -5e+233) tmp = Float64(b * a); elseif (t_1 <= 5e+43) tmp = Float64(y + x); elseif (t_1 <= 4e+297) tmp = fma(b, -0.5, x); else tmp = Float64(b * a); 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, -5e+233], N[(b * a), $MachinePrecision], If[LessEqual[t$95$1, 5e+43], N[(y + x), $MachinePrecision], If[LessEqual[t$95$1, 4e+297], N[(b * -0.5 + x), $MachinePrecision], N[(b * a), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := b \cdot \left(a - 0.5\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+233}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+43}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+297}:\\
\;\;\;\;\mathsf{fma}\left(b, -0.5, x\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot a\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -5.00000000000000009e233 or 4.0000000000000001e297 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6482.7
Applied rewrites82.7%
if -5.00000000000000009e233 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 5.0000000000000004e43Initial 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-+.f6473.1
Applied rewrites73.1%
Applied rewrites64.1%
Taylor expanded in b around inf
Applied rewrites12.9%
Taylor expanded in b around 0
Applied rewrites58.5%
if 5.0000000000000004e43 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 4.0000000000000001e297Initial 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-+.f6485.5
Applied rewrites85.5%
Taylor expanded in y around 0
Applied rewrites72.7%
Taylor expanded in a around 0
Applied rewrites50.6%
Final simplification60.8%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* b (- a 0.5)))) (if (<= t_1 -5e+122) t_1 (if (<= t_1 1e+149) (+ y x) t_1))))
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 <= -5e+122) {
tmp = t_1;
} else if (t_1 <= 1e+149) {
tmp = y + 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 = b * (a - 0.5d0)
if (t_1 <= (-5d+122)) then
tmp = t_1
else if (t_1 <= 1d+149) then
tmp = y + 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 = b * (a - 0.5);
double tmp;
if (t_1 <= -5e+122) {
tmp = t_1;
} else if (t_1 <= 1e+149) {
tmp = y + x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = b * (a - 0.5) tmp = 0 if t_1 <= -5e+122: tmp = t_1 elif t_1 <= 1e+149: tmp = y + x else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(b * Float64(a - 0.5)) tmp = 0.0 if (t_1 <= -5e+122) tmp = t_1; elseif (t_1 <= 1e+149) tmp = Float64(y + x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = b * (a - 0.5); tmp = 0.0; if (t_1 <= -5e+122) tmp = t_1; elseif (t_1 <= 1e+149) tmp = y + x; else tmp = t_1; end tmp_2 = 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, -5e+122], t$95$1, If[LessEqual[t$95$1, 1e+149], N[(y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := b \cdot \left(a - 0.5\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+122}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_1 \leq 10^{+149}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -4.99999999999999989e122 or 1.00000000000000005e149 < (*.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-+.f6493.2
Applied rewrites93.2%
Taylor expanded in y around 0
Applied rewrites85.5%
Taylor expanded in x around 0
Applied rewrites79.2%
if -4.99999999999999989e122 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 1.00000000000000005e149Initial program 99.8%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6472.4
Applied rewrites72.4%
Applied rewrites62.3%
Taylor expanded in b around inf
Applied rewrites9.7%
Taylor expanded in b around 0
Applied rewrites60.8%
Final simplification68.1%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* b (- a 0.5)))) (if (<= t_1 -5e+233) (* b a) (if (<= t_1 1e+167) (+ y x) (* b a)))))
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 <= -5e+233) {
tmp = b * a;
} else if (t_1 <= 1e+167) {
tmp = y + x;
} else {
tmp = b * a;
}
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 = b * (a - 0.5d0)
if (t_1 <= (-5d+233)) then
tmp = b * a
else if (t_1 <= 1d+167) then
tmp = y + x
else
tmp = b * a
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 = b * (a - 0.5);
double tmp;
if (t_1 <= -5e+233) {
tmp = b * a;
} else if (t_1 <= 1e+167) {
tmp = y + x;
} else {
tmp = b * a;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = b * (a - 0.5) tmp = 0 if t_1 <= -5e+233: tmp = b * a elif t_1 <= 1e+167: tmp = y + x else: tmp = b * a return tmp
function code(x, y, z, t, a, b) t_1 = Float64(b * Float64(a - 0.5)) tmp = 0.0 if (t_1 <= -5e+233) tmp = Float64(b * a); elseif (t_1 <= 1e+167) tmp = Float64(y + x); else tmp = Float64(b * a); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = b * (a - 0.5); tmp = 0.0; if (t_1 <= -5e+233) tmp = b * a; elseif (t_1 <= 1e+167) tmp = y + x; else tmp = b * a; end tmp_2 = 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, -5e+233], N[(b * a), $MachinePrecision], If[LessEqual[t$95$1, 1e+167], N[(y + x), $MachinePrecision], N[(b * a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := b \cdot \left(a - 0.5\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+233}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;t\_1 \leq 10^{+167}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;b \cdot a\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -5.00000000000000009e233 or 1e167 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6463.7
Applied rewrites63.7%
if -5.00000000000000009e233 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 1e167Initial 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-+.f6473.8
Applied rewrites73.8%
Applied rewrites62.9%
Taylor expanded in b around inf
Applied rewrites14.9%
Taylor expanded in b around 0
Applied rewrites56.8%
Final simplification58.9%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ y x) -5e+29) (+ y x) (if (<= (+ y x) 5e+28) (* -0.5 b) (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y + x) <= -5e+29) {
tmp = y + x;
} else if ((y + x) <= 5e+28) {
tmp = -0.5 * b;
} else {
tmp = 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) :: tmp
if ((y + x) <= (-5d+29)) then
tmp = y + x
else if ((y + x) <= 5d+28) then
tmp = (-0.5d0) * b
else
tmp = 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 tmp;
if ((y + x) <= -5e+29) {
tmp = y + x;
} else if ((y + x) <= 5e+28) {
tmp = -0.5 * b;
} else {
tmp = y + x;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (y + x) <= -5e+29: tmp = y + x elif (y + x) <= 5e+28: tmp = -0.5 * b else: tmp = y + x return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(y + x) <= -5e+29) tmp = Float64(y + x); elseif (Float64(y + x) <= 5e+28) tmp = Float64(-0.5 * b); else tmp = Float64(y + x); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((y + x) <= -5e+29) tmp = y + x; elseif ((y + x) <= 5e+28) tmp = -0.5 * b; else tmp = y + x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(y + x), $MachinePrecision], -5e+29], N[(y + x), $MachinePrecision], If[LessEqual[N[(y + x), $MachinePrecision], 5e+28], N[(-0.5 * b), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + x \leq -5 \cdot 10^{+29}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;y + x \leq 5 \cdot 10^{+28}:\\
\;\;\;\;-0.5 \cdot b\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if (+.f64 x y) < -5.0000000000000001e29 or 4.99999999999999957e28 < (+.f64 x y) 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.6
Applied rewrites88.6%
Applied rewrites76.3%
Taylor expanded in b around inf
Applied rewrites25.3%
Taylor expanded in b around 0
Applied rewrites61.3%
if -5.0000000000000001e29 < (+.f64 x y) < 4.99999999999999957e28Initial program 99.8%
Taylor expanded in a around 0
*-commutativeN/A
cancel-sign-sub-invN/A
log-recN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
log-recN/A
cancel-sign-sub-invN/A
*-commutativeN/A
lower-+.f64N/A
Applied rewrites64.8%
Taylor expanded in y around -inf
Applied rewrites47.2%
Taylor expanded in b around inf
Applied rewrites26.7%
Final simplification49.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ y x) 1e+46) (fma b (- a 0.5) x) (+ y x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y + x) <= 1e+46) {
tmp = fma(b, (a - 0.5), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(y + x) <= 1e+46) tmp = fma(b, Float64(a - 0.5), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(y + x), $MachinePrecision], 1e+46], N[(b * N[(a - 0.5), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + x \leq 10^{+46}:\\
\;\;\;\;\mathsf{fma}\left(b, a - 0.5, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if (+.f64 x y) < 9.9999999999999999e45Initial 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.5
Applied rewrites76.5%
Taylor expanded in y around 0
Applied rewrites60.0%
if 9.9999999999999999e45 < (+.f64 x y) 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-+.f6490.6
Applied rewrites90.6%
Applied rewrites84.1%
Taylor expanded in b around inf
Applied rewrites24.6%
Taylor expanded in b around 0
Applied rewrites67.4%
Final simplification62.2%
(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-+.f6480.6
Applied rewrites80.6%
(FPCore (x y z t a b) :precision binary64 (+ y x))
double code(double x, double y, double z, double t, double a, double b) {
return 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 = y + x
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return y + x;
}
def code(x, y, z, t, a, b): return y + x
function code(x, y, z, t, a, b) return Float64(y + x) end
function tmp = code(x, y, z, t, a, b) tmp = y + x; end
code[x_, y_, z_, t_, a_, b_] := N[(y + x), $MachinePrecision]
\begin{array}{l}
\\
y + x
\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-+.f6480.6
Applied rewrites80.6%
Applied rewrites68.7%
Taylor expanded in b around inf
Applied rewrites32.7%
Taylor expanded in b around 0
Applied rewrites43.0%
(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 2024296
(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)))