
(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 7 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 (+ (- (- (* 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}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (log y))) (t_2 (- (+ (log t) t_1) y)))
(if (<= x -1.5e+70)
t_2
(if (<= x 1.25e+42)
(- (log t) (+ y z))
(if (<= x 8.6e+154) t_2 (- t_1 z))))))
double code(double x, double y, double z, double t) {
double t_1 = x * log(y);
double t_2 = (log(t) + t_1) - y;
double tmp;
if (x <= -1.5e+70) {
tmp = t_2;
} else if (x <= 1.25e+42) {
tmp = log(t) - (y + z);
} else if (x <= 8.6e+154) {
tmp = t_2;
} else {
tmp = t_1 - 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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = x * log(y)
t_2 = (log(t) + t_1) - y
if (x <= (-1.5d+70)) then
tmp = t_2
else if (x <= 1.25d+42) then
tmp = log(t) - (y + z)
else if (x <= 8.6d+154) then
tmp = t_2
else
tmp = t_1 - z
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 t_2 = (Math.log(t) + t_1) - y;
double tmp;
if (x <= -1.5e+70) {
tmp = t_2;
} else if (x <= 1.25e+42) {
tmp = Math.log(t) - (y + z);
} else if (x <= 8.6e+154) {
tmp = t_2;
} else {
tmp = t_1 - z;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * math.log(y) t_2 = (math.log(t) + t_1) - y tmp = 0 if x <= -1.5e+70: tmp = t_2 elif x <= 1.25e+42: tmp = math.log(t) - (y + z) elif x <= 8.6e+154: tmp = t_2 else: tmp = t_1 - z return tmp
function code(x, y, z, t) t_1 = Float64(x * log(y)) t_2 = Float64(Float64(log(t) + t_1) - y) tmp = 0.0 if (x <= -1.5e+70) tmp = t_2; elseif (x <= 1.25e+42) tmp = Float64(log(t) - Float64(y + z)); elseif (x <= 8.6e+154) tmp = t_2; else tmp = Float64(t_1 - z); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * log(y); t_2 = (log(t) + t_1) - y; tmp = 0.0; if (x <= -1.5e+70) tmp = t_2; elseif (x <= 1.25e+42) tmp = log(t) - (y + z); elseif (x <= 8.6e+154) tmp = t_2; else tmp = t_1 - z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Log[t], $MachinePrecision] + t$95$1), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[x, -1.5e+70], t$95$2, If[LessEqual[x, 1.25e+42], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.6e+154], t$95$2, N[(t$95$1 - z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y\\
t_2 := \left(\log t + t_1\right) - y\\
\mathbf{if}\;x \leq -1.5 \cdot 10^{+70}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{+42}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\mathbf{elif}\;x \leq 8.6 \cdot 10^{+154}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1 - z\\
\end{array}
\end{array}
if x < -1.49999999999999988e70 or 1.25000000000000002e42 < x < 8.5999999999999995e154Initial program 99.7%
Taylor expanded in z around 0 88.9%
if -1.49999999999999988e70 < x < 1.25000000000000002e42Initial program 100.0%
Taylor expanded in x around 0 100.0%
if 8.5999999999999995e154 < x Initial program 99.7%
associate-+l-99.7%
sub-neg99.7%
associate--l+99.7%
add-cube-cbrt98.5%
fma-def98.5%
pow298.5%
Applied egg-rr98.5%
Taylor expanded in z around inf 93.3%
neg-mul-193.3%
Simplified93.3%
fma-udef93.3%
unpow293.3%
add-cube-cbrt94.4%
*-commutative94.4%
unsub-neg94.4%
Applied egg-rr94.4%
Final simplification96.0%
(FPCore (x y z t) :precision binary64 (if (or (<= x -3.2e+106) (not (<= x 2.3e+96))) (- (* x (log y)) z) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -3.2e+106) || !(x <= 2.3e+96)) {
tmp = (x * log(y)) - z;
} else {
tmp = log(t) - (y + 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 ((x <= (-3.2d+106)) .or. (.not. (x <= 2.3d+96))) then
tmp = (x * log(y)) - z
else
tmp = log(t) - (y + z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -3.2e+106) || !(x <= 2.3e+96)) {
tmp = (x * Math.log(y)) - z;
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -3.2e+106) or not (x <= 2.3e+96): tmp = (x * math.log(y)) - z else: tmp = math.log(t) - (y + z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -3.2e+106) || !(x <= 2.3e+96)) tmp = Float64(Float64(x * log(y)) - z); else tmp = Float64(log(t) - Float64(y + z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -3.2e+106) || ~((x <= 2.3e+96))) tmp = (x * log(y)) - z; else tmp = log(t) - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -3.2e+106], N[Not[LessEqual[x, 2.3e+96]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{+106} \lor \neg \left(x \leq 2.3 \cdot 10^{+96}\right):\\
\;\;\;\;x \cdot \log y - z\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if x < -3.1999999999999998e106 or 2.30000000000000015e96 < x Initial program 99.7%
associate-+l-99.7%
sub-neg99.7%
associate--l+99.7%
add-cube-cbrt98.4%
fma-def98.4%
pow298.4%
Applied egg-rr98.4%
Taylor expanded in z around inf 87.7%
neg-mul-187.7%
Simplified87.7%
fma-udef87.7%
unpow287.7%
add-cube-cbrt88.9%
*-commutative88.9%
unsub-neg88.9%
Applied egg-rr88.9%
if -3.1999999999999998e106 < x < 2.30000000000000015e96Initial program 99.9%
Taylor expanded in x around 0 96.1%
Final simplification93.5%
(FPCore (x y z t) :precision binary64 (if (<= y 1.5e+27) (- (log t) z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.5e+27) {
tmp = log(t) - z;
} else {
tmp = -y;
}
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 (y <= 1.5d+27) then
tmp = log(t) - z
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.5e+27) {
tmp = Math.log(t) - z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.5e+27: tmp = math.log(t) - z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.5e+27) tmp = Float64(log(t) - z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.5e+27) tmp = log(t) - z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.5e+27], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.5 \cdot 10^{+27}:\\
\;\;\;\;\log t - z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 1.49999999999999988e27Initial program 99.8%
Taylor expanded in y around 0 97.9%
+-commutative97.9%
*-commutative97.9%
log-pow55.0%
log-prod55.0%
Simplified55.0%
Taylor expanded in x around 0 65.7%
if 1.49999999999999988e27 < y Initial program 99.9%
Taylor expanded in y around inf 59.1%
neg-mul-159.1%
Simplified59.1%
Final simplification62.5%
(FPCore (x y z t) :precision binary64 (- (log t) (+ y z)))
double code(double x, double y, double z, double t) {
return log(t) - (y + 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 = log(t) - (y + z)
end function
public static double code(double x, double y, double z, double t) {
return Math.log(t) - (y + z);
}
def code(x, y, z, t): return math.log(t) - (y + z)
function code(x, y, z, t) return Float64(log(t) - Float64(y + z)) end
function tmp = code(x, y, z, t) tmp = log(t) - (y + z); end
code[x_, y_, z_, t_] := N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log t - \left(y + z\right)
\end{array}
Initial program 99.8%
Taylor expanded in x around 0 71.3%
Final simplification71.3%
(FPCore (x y z t) :precision binary64 (if (<= y 1.05e+26) (- z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.05e+26) {
tmp = -z;
} else {
tmp = -y;
}
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 (y <= 1.05d+26) then
tmp = -z
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.05e+26) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.05e+26: tmp = -z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.05e+26) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.05e+26) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.05e+26], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.05 \cdot 10^{+26}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 1.05e26Initial program 99.8%
Taylor expanded in z around inf 47.5%
mul-1-neg47.5%
Simplified47.5%
if 1.05e26 < y Initial program 99.9%
Taylor expanded in y around inf 59.1%
neg-mul-159.1%
Simplified59.1%
Final simplification53.2%
(FPCore (x y z t) :precision binary64 (- y))
double code(double x, double y, double z, double t) {
return -y;
}
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 = -y
end function
public static double code(double x, double y, double z, double t) {
return -y;
}
def code(x, y, z, t): return -y
function code(x, y, z, t) return Float64(-y) end
function tmp = code(x, y, z, t) tmp = -y; end
code[x_, y_, z_, t_] := (-y)
\begin{array}{l}
\\
-y
\end{array}
Initial program 99.8%
Taylor expanded in y around inf 30.6%
neg-mul-130.6%
Simplified30.6%
Final simplification30.6%
herbie shell --seed 2023196
(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)))