
(FPCore (x y z t) :precision binary64 (+ (- (- (* x (log y)) y) z) (log t)))
double code(double x, double y, double z, double t) {
return (((x * log(y)) - y) - z) + log(t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x * log(y)) - y) - z) + log(t)
end function
public static double code(double x, double y, double z, double t) {
return (((x * Math.log(y)) - y) - z) + Math.log(t);
}
def code(x, y, z, t): return (((x * math.log(y)) - y) - z) + math.log(t)
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * log(y)) - y) - z) + log(t)) end
function tmp = code(x, y, z, t) tmp = (((x * log(y)) - y) - z) + log(t); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (- (- (* x (log y)) y) z) (log t)))
double code(double x, double y, double z, double t) {
return (((x * log(y)) - y) - z) + log(t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x * log(y)) - y) - z) + log(t)
end function
public static double code(double x, double y, double z, double t) {
return (((x * Math.log(y)) - y) - z) + Math.log(t);
}
def code(x, y, z, t): return (((x * math.log(y)) - y) - z) + math.log(t)
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * log(y)) - y) - z) + log(t)) end
function tmp = code(x, y, z, t) tmp = (((x * log(y)) - y) - z) + log(t); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
\end{array}
(FPCore (x y z t) :precision binary64 (fma (log y) x (- (- (log t) z) y)))
double code(double x, double y, double z, double t) {
return fma(log(y), x, ((log(t) - z) - y));
}
function code(x, y, z, t) return fma(log(y), x, Float64(Float64(log(t) - z) - y)) end
code[x_, y_, z_, t_] := N[(N[Log[y], $MachinePrecision] * x + N[(N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, x, \left(\log t - z\right) - y\right)
\end{array}
Initial program 99.8%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
associate-+l-N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f64N/A
associate-+r-N/A
lower-+.f64N/A
lower--.f6499.8
Applied rewrites99.8%
lift-fma.f64N/A
lift-neg.f64N/A
unsub-negN/A
lift-+.f64N/A
associate--r+N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
associate-+l-N/A
+-commutativeN/A
associate--l-N/A
lift-log.f64N/A
*-commutativeN/A
associate-+r-N/A
+-commutativeN/A
lift-fma.f64N/A
+-commutativeN/A
associate--l-N/A
Applied rewrites99.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x (log y)) y)))
(if (<= t_1 -5e+236)
(fma (log y) x (- y))
(if (<= t_1 -4e+43) (- (- (log t) y) z) (- (fma (log y) x (log t)) z)))))
double code(double x, double y, double z, double t) {
double t_1 = (x * log(y)) - y;
double tmp;
if (t_1 <= -5e+236) {
tmp = fma(log(y), x, -y);
} else if (t_1 <= -4e+43) {
tmp = (log(t) - y) - z;
} else {
tmp = fma(log(y), x, log(t)) - z;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x * log(y)) - y) tmp = 0.0 if (t_1 <= -5e+236) tmp = fma(log(y), x, Float64(-y)); elseif (t_1 <= -4e+43) tmp = Float64(Float64(log(t) - y) - z); else tmp = Float64(fma(log(y), x, log(t)) - z); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+236], N[(N[Log[y], $MachinePrecision] * x + (-y)), $MachinePrecision], If[LessEqual[t$95$1, -4e+43], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+236}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, -y\right)\\
\mathbf{elif}\;t\_1 \leq -4 \cdot 10^{+43}:\\
\;\;\;\;\left(\log t - y\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, \log t\right) - z\\
\end{array}
\end{array}
if (-.f64 (*.f64 x (log.f64 y)) y) < -4.9999999999999997e236Initial program 99.8%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
associate-+l-N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f64N/A
associate-+r-N/A
lower-+.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6495.8
Applied rewrites95.8%
if -4.9999999999999997e236 < (-.f64 (*.f64 x (log.f64 y)) y) < -4.00000000000000006e43Initial program 99.9%
Taylor expanded in x around 0
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lower-log.f6486.0
Applied rewrites86.0%
if -4.00000000000000006e43 < (-.f64 (*.f64 x (log.f64 y)) y) Initial program 99.7%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f6496.8
Applied rewrites96.8%
(FPCore (x y z t) :precision binary64 (- (- (fma (log y) x (log t)) z) y))
double code(double x, double y, double z, double t) {
return (fma(log(y), x, log(t)) - z) - y;
}
function code(x, y, z, t) return Float64(Float64(fma(log(y), x, log(t)) - z) - y) end
code[x_, y_, z_, t_] := N[(N[(N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(\log y, x, \log t\right) - z\right) - y
\end{array}
Initial program 99.8%
Taylor expanded in x around 0
+-commutativeN/A
associate--r+N/A
associate--l+N/A
sub-negN/A
+-commutativeN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
+-commutativeN/A
sub-negN/A
associate--l+N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f6499.8
Applied rewrites99.8%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (log y) x (- y)))) (if (<= x -2.3e+134) t_1 (if (<= x 5.2e+70) (- (- (log t) y) z) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(log(y), x, -y);
double tmp;
if (x <= -2.3e+134) {
tmp = t_1;
} else if (x <= 5.2e+70) {
tmp = (log(t) - y) - z;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(log(y), x, Float64(-y)) tmp = 0.0 if (x <= -2.3e+134) tmp = t_1; elseif (x <= 5.2e+70) tmp = Float64(Float64(log(t) - y) - z); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[y], $MachinePrecision] * x + (-y)), $MachinePrecision]}, If[LessEqual[x, -2.3e+134], t$95$1, If[LessEqual[x, 5.2e+70], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\log y, x, -y\right)\\
\mathbf{if}\;x \leq -2.3 \cdot 10^{+134}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{+70}:\\
\;\;\;\;\left(\log t - y\right) - z\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.2999999999999998e134 or 5.2000000000000001e70 < x Initial program 99.5%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
associate-+l-N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f64N/A
associate-+r-N/A
lower-+.f64N/A
lower--.f6499.6
Applied rewrites99.6%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6487.1
Applied rewrites87.1%
if -2.2999999999999998e134 < x < 5.2000000000000001e70Initial program 99.9%
Taylor expanded in x around 0
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lower-log.f6494.7
Applied rewrites94.7%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* x (log y)))) (if (<= x -2.8e+134) t_1 (if (<= x 7.5e+123) (- (- (log t) y) z) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = x * log(y);
double tmp;
if (x <= -2.8e+134) {
tmp = t_1;
} else if (x <= 7.5e+123) {
tmp = (log(t) - y) - z;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = x * log(y)
if (x <= (-2.8d+134)) then
tmp = t_1
else if (x <= 7.5d+123) then
tmp = (log(t) - y) - z
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x * Math.log(y);
double tmp;
if (x <= -2.8e+134) {
tmp = t_1;
} else if (x <= 7.5e+123) {
tmp = (Math.log(t) - y) - z;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * math.log(y) tmp = 0 if x <= -2.8e+134: tmp = t_1 elif x <= 7.5e+123: tmp = (math.log(t) - y) - z else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x * log(y)) tmp = 0.0 if (x <= -2.8e+134) tmp = t_1; elseif (x <= 7.5e+123) tmp = Float64(Float64(log(t) - y) - z); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * log(y); tmp = 0.0; if (x <= -2.8e+134) tmp = t_1; elseif (x <= 7.5e+123) tmp = (log(t) - y) - z; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.8e+134], t$95$1, If[LessEqual[x, 7.5e+123], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x \leq -2.8 \cdot 10^{+134}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+123}:\\
\;\;\;\;\left(\log t - y\right) - z\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.7999999999999999e134 or 7.4999999999999999e123 < x Initial program 99.5%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
associate-+l-N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f64N/A
associate-+r-N/A
lower-+.f64N/A
lower--.f6499.6
Applied rewrites99.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6479.7
Applied rewrites79.7%
if -2.7999999999999999e134 < x < 7.4999999999999999e123Initial program 99.9%
Taylor expanded in x around 0
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lower-log.f6493.4
Applied rewrites93.4%
Final simplification89.5%
(FPCore (x y z t) :precision binary64 (if (<= z -4e+62) (- z) (if (<= z 1.65e+51) (- (log t) y) (- z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4e+62) {
tmp = -z;
} else if (z <= 1.65e+51) {
tmp = log(t) - y;
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-4d+62)) then
tmp = -z
else if (z <= 1.65d+51) then
tmp = log(t) - y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4e+62) {
tmp = -z;
} else if (z <= 1.65e+51) {
tmp = Math.log(t) - y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -4e+62: tmp = -z elif z <= 1.65e+51: tmp = math.log(t) - y else: tmp = -z return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -4e+62) tmp = Float64(-z); elseif (z <= 1.65e+51) tmp = Float64(log(t) - y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -4e+62) tmp = -z; elseif (z <= 1.65e+51) tmp = log(t) - y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -4e+62], (-z), If[LessEqual[z, 1.65e+51], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4 \cdot 10^{+62}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{+51}:\\
\;\;\;\;\log t - y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -4.00000000000000014e62 or 1.6499999999999999e51 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6465.8
Applied rewrites65.8%
if -4.00000000000000014e62 < z < 1.6499999999999999e51Initial program 99.8%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f6498.5
Applied rewrites98.5%
Taylor expanded in x around 0
Applied rewrites65.7%
(FPCore (x y z t) :precision binary64 (if (<= z -4e+62) (- z) (if (<= z 1.3e+51) (* -1.0 y) (- z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4e+62) {
tmp = -z;
} else if (z <= 1.3e+51) {
tmp = -1.0 * y;
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-4d+62)) then
tmp = -z
else if (z <= 1.3d+51) then
tmp = (-1.0d0) * y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4e+62) {
tmp = -z;
} else if (z <= 1.3e+51) {
tmp = -1.0 * y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -4e+62: tmp = -z elif z <= 1.3e+51: tmp = -1.0 * y else: tmp = -z return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -4e+62) tmp = Float64(-z); elseif (z <= 1.3e+51) tmp = Float64(-1.0 * y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -4e+62) tmp = -z; elseif (z <= 1.3e+51) tmp = -1.0 * y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -4e+62], (-z), If[LessEqual[z, 1.3e+51], N[(-1.0 * y), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4 \cdot 10^{+62}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{+51}:\\
\;\;\;\;-1 \cdot y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -4.00000000000000014e62 or 1.3000000000000001e51 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6465.8
Applied rewrites65.8%
if -4.00000000000000014e62 < z < 1.3000000000000001e51Initial program 99.8%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f6498.5
Applied rewrites98.5%
Taylor expanded in y around inf
Applied rewrites85.5%
Taylor expanded in y around inf
Applied rewrites41.3%
(FPCore (x y z t) :precision binary64 (- z))
double code(double x, double y, double z, double t) {
return -z;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = -z
end function
public static double code(double x, double y, double z, double t) {
return -z;
}
def code(x, y, z, t): return -z
function code(x, y, z, t) return Float64(-z) end
function tmp = code(x, y, z, t) tmp = -z; end
code[x_, y_, z_, t_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 99.8%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6429.4
Applied rewrites29.4%
herbie shell --seed 2024298
(FPCore (x y z t)
:name "Numeric.SpecFunctions:incompleteGamma from math-functions-0.1.5.2, A"
:precision binary64
(+ (- (- (* x (log y)) y) z) (log t)))