
(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 12 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.8%
Final simplification99.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* b (- a 0.5)) (- (+ z (+ y x)) (* (log t) z))))
(t_2 (- 1.0 (log t))))
(if (<= t_1 1e-85)
(fma t_2 z (fma (- a 0.5) b x))
(if (<= t_1 2e+283)
(fma t_2 z (fma -0.5 b y))
(+ (fma (- a 0.5) b y) x)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (b * (a - 0.5)) + ((z + (y + x)) - (log(t) * z));
double t_2 = 1.0 - log(t);
double tmp;
if (t_1 <= 1e-85) {
tmp = fma(t_2, z, fma((a - 0.5), b, x));
} else if (t_1 <= 2e+283) {
tmp = fma(t_2, z, fma(-0.5, b, y));
} else {
tmp = fma((a - 0.5), b, y) + x;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(b * Float64(a - 0.5)) + Float64(Float64(z + Float64(y + x)) - Float64(log(t) * z))) t_2 = Float64(1.0 - log(t)) tmp = 0.0 if (t_1 <= 1e-85) tmp = fma(t_2, z, fma(Float64(a - 0.5), b, x)); elseif (t_1 <= 2e+283) tmp = fma(t_2, z, fma(-0.5, b, y)); else tmp = Float64(fma(Float64(a - 0.5), b, y) + x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = 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]}, Block[{t$95$2 = N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e-85], N[(t$95$2 * z + N[(N[(a - 0.5), $MachinePrecision] * b + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+283], N[(t$95$2 * z + N[(-0.5 * b + y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := b \cdot \left(a - 0.5\right) + \left(\left(z + \left(y + x\right)\right) - \log t \cdot z\right)\\
t_2 := 1 - \log t\\
\mathbf{if}\;t\_1 \leq 10^{-85}:\\
\;\;\;\;\mathsf{fma}\left(t\_2, z, \mathsf{fma}\left(a - 0.5, b, x\right)\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+283}:\\
\;\;\;\;\mathsf{fma}\left(t\_2, z, \mathsf{fma}\left(-0.5, b, y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\end{array}
\end{array}
if (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < 9.9999999999999998e-86Initial 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 rewrites81.9%
if 9.9999999999999998e-86 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) < 1.99999999999999991e283Initial program 99.8%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
Applied rewrites99.6%
Taylor expanded in x around 0
mul-1-negN/A
+-commutativeN/A
associate-+r+N/A
associate-+r+N/A
+-commutativeN/A
associate-+r+N/A
associate-+r+N/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
log-recN/A
distribute-rgt-inN/A
log-recN/A
sub-negN/A
Applied rewrites79.1%
Taylor expanded in a around 0
Applied rewrites71.5%
if 1.99999999999999991e283 < (+.f64 (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)) Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6494.8
Applied rewrites94.8%
Final simplification80.3%
(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 -5e+182)
t_2
(if (<= t_1 5e+128) (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 <= -5e+182) {
tmp = t_2;
} else if (t_1 <= 5e+128) {
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 = Float64(fma(Float64(a - 0.5), b, y) + x) tmp = 0.0 if (t_1 <= -5e+182) tmp = t_2; elseif (t_1 <= 5e+128) 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[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+182], t$95$2, If[LessEqual[t$95$1, 5e+128], 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\right) + x\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+182}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+128}:\\
\;\;\;\;\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) < -4.99999999999999973e182 or 5e128 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6499.1
Applied rewrites99.1%
if -4.99999999999999973e182 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 5e128Initial program 99.8%
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
lower-fma.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6491.6
Applied rewrites91.6%
Final simplification94.5%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ z (+ y x)) (* (log t) z)) -4e-86) (fma (- a 0.5) b x) (fma (- a 0.5) b y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((z + (y + x)) - (log(t) * z)) <= -4e-86) {
tmp = fma((a - 0.5), b, x);
} else {
tmp = fma((a - 0.5), b, 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)) <= -4e-86) tmp = fma(Float64(a - 0.5), b, x); else tmp = fma(Float64(a - 0.5), b, 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], -4e-86], N[(N[(a - 0.5), $MachinePrecision] * b + x), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(z + \left(y + x\right)\right) - \log t \cdot z \leq -4 \cdot 10^{-86}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) < -4.00000000000000034e-86Initial program 99.8%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6477.1
Applied rewrites77.1%
Taylor expanded in y around 0
Applied rewrites58.4%
if -4.00000000000000034e-86 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.8%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in x around 0
mul-1-negN/A
+-commutativeN/A
associate-+r+N/A
associate-+r+N/A
+-commutativeN/A
associate-+r+N/A
associate-+r+N/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
log-recN/A
distribute-rgt-inN/A
log-recN/A
sub-negN/A
Applied rewrites83.4%
Taylor expanded in z around 0
Applied rewrites61.9%
Final simplification60.1%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ z (+ y x)) (* (log t) z)) -4e+71) (+ (* b a) x) (fma (- a 0.5) b y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((z + (y + x)) - (log(t) * z)) <= -4e+71) {
tmp = (b * a) + x;
} else {
tmp = fma((a - 0.5), b, 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)) <= -4e+71) tmp = Float64(Float64(b * a) + x); else tmp = fma(Float64(a - 0.5), b, 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], -4e+71], N[(N[(b * a), $MachinePrecision] + x), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(z + \left(y + x\right)\right) - \log t \cdot z \leq -4 \cdot 10^{+71}:\\
\;\;\;\;b \cdot a + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) < -4.0000000000000002e71Initial program 99.8%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6476.8
Applied rewrites76.8%
Taylor expanded in a around inf
Applied rewrites49.8%
if -4.0000000000000002e71 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.8%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in x around 0
mul-1-negN/A
+-commutativeN/A
associate-+r+N/A
associate-+r+N/A
+-commutativeN/A
associate-+r+N/A
associate-+r+N/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
log-recN/A
distribute-rgt-inN/A
log-recN/A
sub-negN/A
Applied rewrites81.9%
Taylor expanded in z around 0
Applied rewrites60.4%
Final simplification56.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))))
(if (<= (+ y x) -1e-94)
(fma t_1 z (fma (- a 0.5) b x))
(fma t_1 z (fma (- a 0.5) b y)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 - log(t);
double tmp;
if ((y + x) <= -1e-94) {
tmp = fma(t_1, z, fma((a - 0.5), b, x));
} else {
tmp = fma(t_1, z, fma((a - 0.5), b, y));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) tmp = 0.0 if (Float64(y + x) <= -1e-94) tmp = fma(t_1, z, fma(Float64(a - 0.5), b, x)); else tmp = fma(t_1, z, fma(Float64(a - 0.5), b, y)); 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[N[(y + x), $MachinePrecision], -1e-94], N[(t$95$1 * z + N[(N[(a - 0.5), $MachinePrecision] * b + x), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * z + N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
\mathbf{if}\;y + x \leq -1 \cdot 10^{-94}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, \mathsf{fma}\left(a - 0.5, b, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, \mathsf{fma}\left(a - 0.5, b, y\right)\right)\\
\end{array}
\end{array}
if (+.f64 x y) < -9.9999999999999996e-95Initial 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 rewrites76.6%
if -9.9999999999999996e-95 < (+.f64 x y) Initial program 99.8%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
Applied rewrites99.6%
Taylor expanded in x around 0
mul-1-negN/A
+-commutativeN/A
associate-+r+N/A
associate-+r+N/A
+-commutativeN/A
associate-+r+N/A
associate-+r+N/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
log-recN/A
distribute-rgt-inN/A
log-recN/A
sub-negN/A
Applied rewrites85.5%
Final simplification81.8%
(FPCore (x y z t a b) :precision binary64 (if (<= z -7.2e+238) (- z (* (log t) z)) (if (<= z 6.3e+127) (+ (fma (- a 0.5) b y) x) (fma (- (log t)) z z))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -7.2e+238) {
tmp = z - (log(t) * z);
} else if (z <= 6.3e+127) {
tmp = fma((a - 0.5), b, y) + x;
} else {
tmp = fma(-log(t), z, z);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -7.2e+238) tmp = Float64(z - Float64(log(t) * z)); elseif (z <= 6.3e+127) tmp = Float64(fma(Float64(a - 0.5), b, y) + x); else tmp = fma(Float64(-log(t)), z, z); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -7.2e+238], N[(z - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.3e+127], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision], N[((-N[Log[t], $MachinePrecision]) * z + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.2 \cdot 10^{+238}:\\
\;\;\;\;z - \log t \cdot z\\
\mathbf{elif}\;z \leq 6.3 \cdot 10^{+127}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-\log t, z, z\right)\\
\end{array}
\end{array}
if z < -7.19999999999999942e238Initial program 99.7%
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
*-commutativeN/A
lower-*.f64N/A
lower-log.f6486.4
Applied rewrites86.4%
if -7.19999999999999942e238 < z < 6.30000000000000047e127Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6488.9
Applied rewrites88.9%
if 6.30000000000000047e127 < z Initial program 99.5%
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
*-commutativeN/A
lower-*.f64N/A
lower-log.f6461.4
Applied rewrites61.4%
Applied rewrites61.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- z (* (log t) z))))
(if (<= z -7.2e+238)
t_1
(if (<= z 6.3e+127) (+ (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 = z - (log(t) * z);
double tmp;
if (z <= -7.2e+238) {
tmp = t_1;
} else if (z <= 6.3e+127) {
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(z - Float64(log(t) * z)) tmp = 0.0 if (z <= -7.2e+238) tmp = t_1; elseif (z <= 6.3e+127) tmp = Float64(fma(Float64(a - 0.5), b, y) + x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(z - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -7.2e+238], t$95$1, If[LessEqual[z, 6.3e+127], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z - \log t \cdot z\\
\mathbf{if}\;z \leq -7.2 \cdot 10^{+238}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 6.3 \cdot 10^{+127}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -7.19999999999999942e238 or 6.30000000000000047e127 < z Initial program 99.5%
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
*-commutativeN/A
lower-*.f64N/A
lower-log.f6466.8
Applied rewrites66.8%
if -7.19999999999999942e238 < z < 6.30000000000000047e127Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6488.9
Applied rewrites88.9%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* b (- a 0.5)))) (if (<= t_1 -1e+196) t_1 (if (<= t_1 2e+163) (+ 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 <= -1e+196) {
tmp = t_1;
} else if (t_1 <= 2e+163) {
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 <= (-1d+196)) then
tmp = t_1
else if (t_1 <= 2d+163) 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 <= -1e+196) {
tmp = t_1;
} else if (t_1 <= 2e+163) {
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 <= -1e+196: tmp = t_1 elif t_1 <= 2e+163: 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 <= -1e+196) tmp = t_1; elseif (t_1 <= 2e+163) 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 <= -1e+196) tmp = t_1; elseif (t_1 <= 2e+163) 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, -1e+196], t$95$1, If[LessEqual[t$95$1, 2e+163], 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 -1 \cdot 10^{+196}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+163}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -9.9999999999999995e195 or 1.9999999999999999e163 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6484.7
Applied rewrites84.7%
if -9.9999999999999995e195 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 1.9999999999999999e163Initial program 99.8%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
Applied rewrites99.6%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6466.0
Applied rewrites66.0%
Taylor expanded in b around 0
Applied rewrites58.1%
Final simplification67.6%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* b (- a 0.5)))) (if (<= t_1 -4e+223) (* b a) (if (<= t_1 2e+229) (+ 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 <= -4e+223) {
tmp = b * a;
} else if (t_1 <= 2e+229) {
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 <= (-4d+223)) then
tmp = b * a
else if (t_1 <= 2d+229) 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 <= -4e+223) {
tmp = b * a;
} else if (t_1 <= 2e+229) {
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 <= -4e+223: tmp = b * a elif t_1 <= 2e+229: 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 <= -4e+223) tmp = Float64(b * a); elseif (t_1 <= 2e+229) 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 <= -4e+223) tmp = b * a; elseif (t_1 <= 2e+229) 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, -4e+223], N[(b * a), $MachinePrecision], If[LessEqual[t$95$1, 2e+229], 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 -4 \cdot 10^{+223}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+229}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;b \cdot a\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -4.00000000000000019e223 or 2e229 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Taylor expanded in a around inf
lower-*.f6473.3
Applied rewrites73.3%
if -4.00000000000000019e223 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2e229Initial program 99.8%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
Applied rewrites99.6%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6469.0
Applied rewrites69.0%
Taylor expanded in b around 0
Applied rewrites56.0%
Final simplification61.1%
(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 Float64(fma(Float64(a - 0.5), b, y) + x) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, y\right) + x
\end{array}
Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6477.8
Applied rewrites77.8%
(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.8%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6477.8
Applied rewrites77.8%
Taylor expanded in b around 0
Applied rewrites41.6%
(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 2024278
(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)))