
(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 (- 1.0 (log t))))
(if (<= (+ x y) -5e+84)
(fma (- a 0.5) b (+ y x))
(if (<= (+ x y) 5e+25)
(fma t_1 z (* b (- a 0.5)))
(if (<= (+ x y) 1e+174)
(fma t_1 z (fma -0.5 b y))
(fma (- a 0.5) b (fma (/ x y) y 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 ((x + y) <= -5e+84) {
tmp = fma((a - 0.5), b, (y + x));
} else if ((x + y) <= 5e+25) {
tmp = fma(t_1, z, (b * (a - 0.5)));
} else if ((x + y) <= 1e+174) {
tmp = fma(t_1, z, fma(-0.5, b, y));
} else {
tmp = fma((a - 0.5), b, fma((x / y), y, y));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) tmp = 0.0 if (Float64(x + y) <= -5e+84) tmp = fma(Float64(a - 0.5), b, Float64(y + x)); elseif (Float64(x + y) <= 5e+25) tmp = fma(t_1, z, Float64(b * Float64(a - 0.5))); elseif (Float64(x + y) <= 1e+174) tmp = fma(t_1, z, fma(-0.5, b, y)); else tmp = fma(Float64(a - 0.5), b, fma(Float64(x / y), y, 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[(x + y), $MachinePrecision], -5e+84], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x + y), $MachinePrecision], 5e+25], N[(t$95$1 * z + N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x + y), $MachinePrecision], 1e+174], N[(t$95$1 * z + N[(-0.5 * b + y), $MachinePrecision]), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + N[(N[(x / y), $MachinePrecision] * y + y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
\mathbf{if}\;x + y \leq -5 \cdot 10^{+84}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\mathbf{elif}\;x + y \leq 5 \cdot 10^{+25}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, b \cdot \left(a - 0.5\right)\right)\\
\mathbf{elif}\;x + y \leq 10^{+174}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, \mathsf{fma}\left(-0.5, b, y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, \mathsf{fma}\left(\frac{x}{y}, y, y\right)\right)\\
\end{array}
\end{array}
if (+.f64 x y) < -5.0000000000000001e84Initial 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-+.f6492.2
Applied rewrites92.2%
if -5.0000000000000001e84 < (+.f64 x y) < 5.00000000000000024e25Initial program 99.8%
Taylor expanded in x around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+r+N/A
Applied rewrites98.6%
Taylor expanded in y around 0
Applied rewrites94.6%
if 5.00000000000000024e25 < (+.f64 x y) < 1.00000000000000007e174Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+r+N/A
Applied rewrites91.7%
Taylor expanded in a around 0
Applied rewrites81.2%
if 1.00000000000000007e174 < (+.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-+.f6495.2
Applied rewrites95.2%
Taylor expanded in y around inf
Applied rewrites77.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))))
(if (<= (+ x y) 5e+25)
(fma t_1 z (fma (+ -0.5 a) b x))
(if (<= (+ x y) 1e+174)
(fma t_1 z (fma -0.5 b y))
(fma (- a 0.5) b (fma (/ x y) y 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 ((x + y) <= 5e+25) {
tmp = fma(t_1, z, fma((-0.5 + a), b, x));
} else if ((x + y) <= 1e+174) {
tmp = fma(t_1, z, fma(-0.5, b, y));
} else {
tmp = fma((a - 0.5), b, fma((x / y), y, y));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) tmp = 0.0 if (Float64(x + y) <= 5e+25) tmp = fma(t_1, z, fma(Float64(-0.5 + a), b, x)); elseif (Float64(x + y) <= 1e+174) tmp = fma(t_1, z, fma(-0.5, b, y)); else tmp = fma(Float64(a - 0.5), b, fma(Float64(x / y), y, 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[(x + y), $MachinePrecision], 5e+25], N[(t$95$1 * z + N[(N[(-0.5 + a), $MachinePrecision] * b + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x + y), $MachinePrecision], 1e+174], N[(t$95$1 * z + N[(-0.5 * b + y), $MachinePrecision]), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + N[(N[(x / y), $MachinePrecision] * y + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
\mathbf{if}\;x + y \leq 5 \cdot 10^{+25}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, \mathsf{fma}\left(-0.5 + a, b, x\right)\right)\\
\mathbf{elif}\;x + y \leq 10^{+174}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, \mathsf{fma}\left(-0.5, b, y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, \mathsf{fma}\left(\frac{x}{y}, y, y\right)\right)\\
\end{array}
\end{array}
if (+.f64 x y) < 5.00000000000000024e25Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites83.3%
if 5.00000000000000024e25 < (+.f64 x y) < 1.00000000000000007e174Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+r+N/A
Applied rewrites91.7%
Taylor expanded in a around 0
Applied rewrites81.2%
if 1.00000000000000007e174 < (+.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-+.f6495.2
Applied rewrites95.2%
Taylor expanded in y around inf
Applied rewrites77.0%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ (+ x y) z) (* z (log t))) -5000.0) (fma b (- a 0.5) x) (fma b (- a 0.5) y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((((x + y) + z) - (z * log(t))) <= -5000.0) {
tmp = fma(b, (a - 0.5), x);
} else {
tmp = fma(b, (a - 0.5), y);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) <= -5000.0) tmp = fma(b, Float64(a - 0.5), x); else tmp = fma(b, Float64(a - 0.5), y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5000.0], N[(b * N[(a - 0.5), $MachinePrecision] + x), $MachinePrecision], N[(b * N[(a - 0.5), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(x + y\right) + z\right) - z \cdot \log t \leq -5000:\\
\;\;\;\;\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))) < -5e3Initial 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.1
Applied rewrites76.1%
Taylor expanded in y around 0
Applied rewrites56.2%
if -5e3 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6479.3
Applied rewrites79.3%
Taylor expanded in x around 0
Applied rewrites61.4%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -5.2e+217) (not (<= z 3.8e+168))) (fma (- 1.0 (log t)) 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 tmp;
if ((z <= -5.2e+217) || !(z <= 3.8e+168)) {
tmp = fma((1.0 - log(t)), 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) tmp = 0.0 if ((z <= -5.2e+217) || !(z <= 3.8e+168)) tmp = fma(Float64(1.0 - log(t)), z, fma(-0.5, b, y)); else tmp = fma(Float64(a - 0.5), b, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -5.2e+217], N[Not[LessEqual[z, 3.8e+168]], $MachinePrecision]], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(-0.5 * b + y), $MachinePrecision]), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+217} \lor \neg \left(z \leq 3.8 \cdot 10^{+168}\right):\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(-0.5, b, y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\end{array}
\end{array}
if z < -5.20000000000000023e217 or 3.8000000000000003e168 < z Initial program 99.6%
Taylor expanded in x around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+r+N/A
Applied rewrites94.2%
Taylor expanded in a around 0
Applied rewrites77.2%
if -5.20000000000000023e217 < z < 3.8000000000000003e168Initial 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-+.f6489.8
Applied rewrites89.8%
Final simplification87.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))))
(if (<= (+ x y) -5e+24)
(fma t_1 z (fma (+ -0.5 a) 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 ((x + y) <= -5e+24) {
tmp = fma(t_1, z, fma((-0.5 + a), 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(x + y) <= -5e+24) tmp = fma(t_1, z, fma(Float64(-0.5 + a), 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[(x + y), $MachinePrecision], -5e+24], N[(t$95$1 * z + N[(N[(-0.5 + a), $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}\;x + y \leq -5 \cdot 10^{+24}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, \mathsf{fma}\left(-0.5 + a, 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) < -5.00000000000000045e24Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
associate-+r+N/A
Applied rewrites75.2%
if -5.00000000000000045e24 < (+.f64 x y) Initial program 99.8%
Taylor expanded in x around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+r+N/A
Applied rewrites84.4%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -5.4e+217) (not (<= z 2.1e+170))) (fma (- 1.0 (log t)) z y) (fma (- a 0.5) b (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -5.4e+217) || !(z <= 2.1e+170)) {
tmp = fma((1.0 - log(t)), z, y);
} else {
tmp = fma((a - 0.5), b, (y + x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -5.4e+217) || !(z <= 2.1e+170)) tmp = fma(Float64(1.0 - log(t)), z, y); else tmp = fma(Float64(a - 0.5), b, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -5.4e+217], N[Not[LessEqual[z, 2.1e+170]], $MachinePrecision]], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + y), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.4 \cdot 10^{+217} \lor \neg \left(z \leq 2.1 \cdot 10^{+170}\right):\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\end{array}
\end{array}
if z < -5.40000000000000005e217 or 2.09999999999999998e170 < z Initial program 99.6%
Taylor expanded in x around 0
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
log-recN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+r+N/A
Applied rewrites94.2%
Taylor expanded in y around inf
Applied rewrites64.9%
Taylor expanded in b around 0
Applied rewrites73.0%
if -5.40000000000000005e217 < z < 2.09999999999999998e170Initial 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-+.f6489.8
Applied rewrites89.8%
Final simplification86.5%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -9e+221) (not (<= z 1.6e+172))) (* (- 1.0 (log t)) z) (fma (- a 0.5) b (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -9e+221) || !(z <= 1.6e+172)) {
tmp = (1.0 - log(t)) * z;
} else {
tmp = fma((a - 0.5), b, (y + x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -9e+221) || !(z <= 1.6e+172)) tmp = Float64(Float64(1.0 - log(t)) * z); else tmp = fma(Float64(a - 0.5), b, Float64(y + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -9e+221], N[Not[LessEqual[z, 1.6e+172]], $MachinePrecision]], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+221} \lor \neg \left(z \leq 1.6 \cdot 10^{+172}\right):\\
\;\;\;\;\left(1 - \log t\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y + x\right)\\
\end{array}
\end{array}
if z < -9.0000000000000004e221 or 1.59999999999999993e172 < z Initial program 99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6472.8
Applied rewrites72.8%
if -9.0000000000000004e221 < z < 1.59999999999999993e172Initial 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-+.f6489.8
Applied rewrites89.8%
Final simplification86.4%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (- a 0.5) -0.5002) (not (<= (- a 0.5) -0.49998))) (* b a) (* -0.5 b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a - 0.5) <= -0.5002) || !((a - 0.5) <= -0.49998)) {
tmp = b * a;
} else {
tmp = -0.5 * b;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (((a - 0.5d0) <= (-0.5002d0)) .or. (.not. ((a - 0.5d0) <= (-0.49998d0)))) then
tmp = b * a
else
tmp = (-0.5d0) * b
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a - 0.5) <= -0.5002) || !((a - 0.5) <= -0.49998)) {
tmp = b * a;
} else {
tmp = -0.5 * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a - 0.5) <= -0.5002) or not ((a - 0.5) <= -0.49998): tmp = b * a else: tmp = -0.5 * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a - 0.5) <= -0.5002) || !(Float64(a - 0.5) <= -0.49998)) tmp = Float64(b * a); else tmp = Float64(-0.5 * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (((a - 0.5) <= -0.5002) || ~(((a - 0.5) <= -0.49998))) tmp = b * a; else tmp = -0.5 * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(a - 0.5), $MachinePrecision], -0.5002], N[Not[LessEqual[N[(a - 0.5), $MachinePrecision], -0.49998]], $MachinePrecision]], N[(b * a), $MachinePrecision], N[(-0.5 * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a - 0.5 \leq -0.5002 \lor \neg \left(a - 0.5 \leq -0.49998\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot b\\
\end{array}
\end{array}
if (-.f64 a #s(literal 1/2 binary64)) < -0.50019999999999998 or -0.49997999999999998 < (-.f64 a #s(literal 1/2 binary64)) Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6452.1
Applied rewrites52.1%
if -0.50019999999999998 < (-.f64 a #s(literal 1/2 binary64)) < -0.49997999999999998Initial program 99.8%
Taylor expanded in a around inf
Applied rewrites37.9%
Taylor expanded in b around -inf
Applied rewrites25.2%
Taylor expanded in a around 0
Applied rewrites25.9%
Final simplification37.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-+.f6477.8
Applied rewrites77.8%
(FPCore (x y z t a b) :precision binary64 (fma b (- a 0.5) x))
double code(double x, double y, double z, double t, double a, double b) {
return fma(b, (a - 0.5), x);
}
function code(x, y, z, t, a, b) return fma(b, Float64(a - 0.5), x) end
code[x_, y_, z_, t_, a_, b_] := N[(b * N[(a - 0.5), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(b, a - 0.5, x\right)
\end{array}
Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6477.8
Applied rewrites77.8%
Taylor expanded in y around 0
Applied rewrites57.2%
(FPCore (x y z t a b) :precision binary64 (* (+ -0.5 a) b))
double code(double x, double y, double z, double t, double a, double b) {
return (-0.5 + a) * b;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((-0.5d0) + a) * b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (-0.5 + a) * b;
}
def code(x, y, z, t, a, b): return (-0.5 + a) * b
function code(x, y, z, t, a, b) return Float64(Float64(-0.5 + a) * b) end
function tmp = code(x, y, z, t, a, b) tmp = (-0.5 + a) * b; end
code[x_, y_, z_, t_, a_, b_] := N[(N[(-0.5 + a), $MachinePrecision] * b), $MachinePrecision]
\begin{array}{l}
\\
\left(-0.5 + a\right) \cdot b
\end{array}
Initial program 99.9%
Taylor expanded in a around inf
Applied rewrites64.8%
Taylor expanded in b around -inf
Applied rewrites37.5%
Taylor expanded in a around 0
Applied rewrites38.0%
(FPCore (x y z t a b) :precision binary64 (* -0.5 b))
double code(double x, double y, double z, double t, double a, double b) {
return -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 = (-0.5d0) * b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return -0.5 * b;
}
def code(x, y, z, t, a, b): return -0.5 * b
function code(x, y, z, t, a, b) return Float64(-0.5 * b) end
function tmp = code(x, y, z, t, a, b) tmp = -0.5 * b; end
code[x_, y_, z_, t_, a_, b_] := N[(-0.5 * b), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot b
\end{array}
Initial program 99.9%
Taylor expanded in a around inf
Applied rewrites64.8%
Taylor expanded in b around -inf
Applied rewrites37.5%
Taylor expanded in a around 0
Applied rewrites16.1%
(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 2024338
(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)))