
(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 (+ (- (+ (+ 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 (* (- a 0.5) b)) (t_2 (+ y (fma b (+ a -0.5) x))))
(if (<= t_1 -1e+76)
t_2
(if (<= t_1 2e-6) (fma z (- 1.0 (log t)) (+ x y)) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double t_2 = y + fma(b, (a + -0.5), x);
double tmp;
if (t_1 <= -1e+76) {
tmp = t_2;
} else if (t_1 <= 2e-6) {
tmp = fma(z, (1.0 - log(t)), (x + y));
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) t_2 = Float64(y + fma(b, Float64(a + -0.5), x)) tmp = 0.0 if (t_1 <= -1e+76) tmp = t_2; elseif (t_1 <= 2e-6) tmp = fma(z, Float64(1.0 - log(t)), Float64(x + y)); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$2 = N[(y + N[(b * N[(a + -0.5), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+76], t$95$2, If[LessEqual[t$95$1, 2e-6], N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] + N[(x + y), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
t_2 := y + \mathsf{fma}\left(b, a + -0.5, x\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+76}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(z, 1 - \log t, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1e76 or 1.99999999999999991e-6 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6491.3
Applied rewrites91.3%
if -1e76 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 1.99999999999999991e-6Initial program 99.9%
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
sub-negN/A
mul-1-negN/A
*-commutativeN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6494.1
Applied rewrites94.1%
Final simplification92.5%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) -5e+17) (+ (- (+ (+ x y) z) (* z (log t))) (* a b)) (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) <= -5e+17) {
tmp = (((x + y) + z) - (z * log(t))) + (a * b);
} 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) <= -5e+17) tmp = Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(a * b)); 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], -5e+17], N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * b), $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 -5 \cdot 10^{+17}:\\
\;\;\;\;\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + a \cdot b\\
\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) < -5e17Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6493.0
Applied rewrites93.0%
if -5e17 < (+.f64 x y) Initial program 99.9%
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
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
log-recN/A
sub-negN/A
Applied rewrites82.6%
Final simplification86.4%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) -5e+17) (+ (* a b) (- (+ x z) (* z (log t)))) (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) <= -5e+17) {
tmp = (a * b) + ((x + z) - (z * log(t)));
} 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) <= -5e+17) tmp = Float64(Float64(a * b) + Float64(Float64(x + z) - Float64(z * log(t)))); 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], -5e+17], N[(N[(a * b), $MachinePrecision] + N[(N[(x + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $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 -5 \cdot 10^{+17}:\\
\;\;\;\;a \cdot b + \left(\left(x + z\right) - z \cdot \log t\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) < -5e17Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6493.0
Applied rewrites93.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6463.6
Applied rewrites63.6%
if -5e17 < (+.f64 x y) Initial program 99.9%
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
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
log-recN/A
sub-negN/A
Applied rewrites82.6%
Final simplification75.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) -2e+20) (+ 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) <= -2e+20) {
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) <= -2e+20) 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], -2e+20], 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 -2 \cdot 10^{+20}:\\
\;\;\;\;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) < -2e20Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6487.0
Applied rewrites87.0%
if -2e20 < (+.f64 x y) Initial program 99.9%
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
*-rgt-identityN/A
distribute-lft-inN/A
+-commutativeN/A
log-recN/A
sub-negN/A
Applied rewrites82.2%
(FPCore (x y z t a b) :precision binary64 (if (<= z -5.5e+188) (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 tmp;
if (z <= -5.5e+188) {
tmp = 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) tmp = 0.0 if (z <= -5.5e+188) tmp = 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_] := If[LessEqual[z, -5.5e+188], N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision], N[(y + N[(b * N[(a + -0.5), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+188}:\\
\;\;\;\;\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 z < -5.50000000000000013e188Initial program 99.9%
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
sub-negN/A
mul-1-negN/A
*-commutativeN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6480.4
Applied rewrites80.4%
Taylor expanded in x around 0
Applied rewrites74.6%
if -5.50000000000000013e188 < z Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6489.3
Applied rewrites89.3%
(FPCore (x y z t a b) :precision binary64 (if (<= z -5.8e+188) (fma z (- 1.0 (log t)) x) (+ y (fma b (+ a -0.5) x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -5.8e+188) {
tmp = fma(z, (1.0 - log(t)), x);
} else {
tmp = y + fma(b, (a + -0.5), x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -5.8e+188) tmp = fma(z, Float64(1.0 - log(t)), x); else tmp = Float64(y + fma(b, Float64(a + -0.5), x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -5.8e+188], N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(y + N[(b * N[(a + -0.5), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+188}:\\
\;\;\;\;\mathsf{fma}\left(z, 1 - \log t, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + \mathsf{fma}\left(b, a + -0.5, x\right)\\
\end{array}
\end{array}
if z < -5.7999999999999999e188Initial program 99.9%
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
sub-negN/A
mul-1-negN/A
*-commutativeN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6480.4
Applied rewrites80.4%
Taylor expanded in y around 0
Applied rewrites75.7%
if -5.7999999999999999e188 < z Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6489.3
Applied rewrites89.3%
(FPCore (x y z t a b) :precision binary64 (if (<= z -5.8e+188) (fma (log t) (- z) z) (+ y (fma b (+ a -0.5) x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -5.8e+188) {
tmp = fma(log(t), -z, z);
} else {
tmp = y + fma(b, (a + -0.5), x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -5.8e+188) tmp = fma(log(t), Float64(-z), z); else tmp = Float64(y + fma(b, Float64(a + -0.5), x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -5.8e+188], N[(N[Log[t], $MachinePrecision] * (-z) + z), $MachinePrecision], N[(y + N[(b * N[(a + -0.5), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+188}:\\
\;\;\;\;\mathsf{fma}\left(\log t, -z, z\right)\\
\mathbf{else}:\\
\;\;\;\;y + \mathsf{fma}\left(b, a + -0.5, x\right)\\
\end{array}
\end{array}
if z < -5.7999999999999999e188Initial program 99.9%
Taylor expanded in z around inf
sub-negN/A
log-recN/A
+-commutativeN/A
distribute-rgt-inN/A
log-recN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
neg-mul-1N/A
*-lft-identityN/A
lower-fma.f64N/A
lower-log.f64N/A
neg-mul-1N/A
lower-neg.f6470.0
Applied rewrites70.0%
if -5.7999999999999999e188 < z Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6489.3
Applied rewrites89.3%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b)) (t_2 (* b (+ a -0.5)))) (if (<= t_1 -1e+155) t_2 (if (<= t_1 4e+146) (+ x y) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double t_2 = b * (a + -0.5);
double tmp;
if (t_1 <= -1e+155) {
tmp = t_2;
} else if (t_1 <= 4e+146) {
tmp = x + y;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_1 = (a - 0.5d0) * b
t_2 = b * (a + (-0.5d0))
if (t_1 <= (-1d+155)) then
tmp = t_2
else if (t_1 <= 4d+146) then
tmp = x + y
else
tmp = t_2
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 = (a - 0.5) * b;
double t_2 = b * (a + -0.5);
double tmp;
if (t_1 <= -1e+155) {
tmp = t_2;
} else if (t_1 <= 4e+146) {
tmp = x + y;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a - 0.5) * b t_2 = b * (a + -0.5) tmp = 0 if t_1 <= -1e+155: tmp = t_2 elif t_1 <= 4e+146: tmp = x + y else: tmp = t_2 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) t_2 = Float64(b * Float64(a + -0.5)) tmp = 0.0 if (t_1 <= -1e+155) tmp = t_2; elseif (t_1 <= 4e+146) tmp = Float64(x + y); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a - 0.5) * b; t_2 = b * (a + -0.5); tmp = 0.0; if (t_1 <= -1e+155) tmp = t_2; elseif (t_1 <= 4e+146) tmp = x + y; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$2 = N[(b * N[(a + -0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+155], t$95$2, If[LessEqual[t$95$1, 4e+146], N[(x + y), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
t_2 := b \cdot \left(a + -0.5\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+155}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+146}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1.00000000000000001e155 or 3.99999999999999973e146 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in b around inf
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6487.4
Applied rewrites87.4%
if -1.00000000000000001e155 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 3.99999999999999973e146Initial program 99.9%
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
sub-negN/A
mul-1-negN/A
*-commutativeN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6486.5
Applied rewrites86.5%
Taylor expanded in z around 0
Applied rewrites65.1%
Final simplification73.5%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b))) (if (<= t_1 -5e+186) (* a b) (if (<= t_1 4e+146) (+ x y) (* a b)))))
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 <= -5e+186) {
tmp = a * b;
} else if (t_1 <= 4e+146) {
tmp = x + y;
} 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) :: t_1
real(8) :: tmp
t_1 = (a - 0.5d0) * b
if (t_1 <= (-5d+186)) then
tmp = a * b
else if (t_1 <= 4d+146) then
tmp = x + y
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 t_1 = (a - 0.5) * b;
double tmp;
if (t_1 <= -5e+186) {
tmp = a * b;
} else if (t_1 <= 4e+146) {
tmp = x + y;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a - 0.5) * b tmp = 0 if t_1 <= -5e+186: tmp = a * b elif t_1 <= 4e+146: tmp = x + y else: tmp = a * b return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if (t_1 <= -5e+186) tmp = Float64(a * b); elseif (t_1 <= 4e+146) tmp = Float64(x + y); else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a - 0.5) * b; tmp = 0.0; if (t_1 <= -5e+186) tmp = a * b; elseif (t_1 <= 4e+146) tmp = x + y; else tmp = a * b; end tmp_2 = 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, -5e+186], N[(a * b), $MachinePrecision], If[LessEqual[t$95$1, 4e+146], N[(x + y), $MachinePrecision], N[(a * b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+186}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+146}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -4.99999999999999954e186 or 3.99999999999999973e146 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6469.2
Applied rewrites69.2%
if -4.99999999999999954e186 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 3.99999999999999973e146Initial program 99.9%
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
sub-negN/A
mul-1-negN/A
*-commutativeN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6485.7
Applied rewrites85.7%
Taylor expanded in z around 0
Applied rewrites63.8%
Final simplification65.7%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) 2e+25) (fma b (+ a -0.5) x) (+ y (* a b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x + y) <= 2e+25) {
tmp = fma(b, (a + -0.5), x);
} else {
tmp = y + (a * b);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= 2e+25) tmp = fma(b, Float64(a + -0.5), x); else tmp = Float64(y + Float64(a * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], 2e+25], N[(b * N[(a + -0.5), $MachinePrecision] + x), $MachinePrecision], N[(y + N[(a * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq 2 \cdot 10^{+25}:\\
\;\;\;\;\mathsf{fma}\left(b, a + -0.5, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + a \cdot b\\
\end{array}
\end{array}
if (+.f64 x y) < 2.00000000000000018e25Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6479.6
Applied rewrites79.6%
Taylor expanded in y around 0
Applied rewrites62.2%
if 2.00000000000000018e25 < (+.f64 x y) Initial program 100.0%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6492.9
Applied rewrites92.9%
Taylor expanded in a around inf
Applied rewrites60.5%
Final simplification61.6%
(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.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6484.6
Applied rewrites84.6%
(FPCore (x y z t a b) :precision binary64 (+ x y))
double code(double x, double y, double z, double t, double a, double b) {
return x + 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 + y
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x + y;
}
def code(x, y, z, t, a, b): return x + y
function code(x, y, z, t, a, b) return Float64(x + y) end
function tmp = code(x, y, z, t, a, b) tmp = x + y; end
code[x_, y_, z_, t_, a_, b_] := N[(x + y), $MachinePrecision]
\begin{array}{l}
\\
x + y
\end{array}
Initial program 99.9%
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
sub-negN/A
mul-1-negN/A
*-commutativeN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6459.7
Applied rewrites59.7%
Taylor expanded in z around 0
Applied rewrites44.5%
Final simplification44.5%
(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 2024234
(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)))