
(FPCore (x y z t) :precision binary64 (- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))
double code(double x, double y, double z, double t) {
return ((x * log(y)) + (z * log((1.0 - y)))) - 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)) + (z * log((1.0d0 - y)))) - t
end function
public static double code(double x, double y, double z, double t) {
return ((x * Math.log(y)) + (z * Math.log((1.0 - y)))) - t;
}
def code(x, y, z, t): return ((x * math.log(y)) + (z * math.log((1.0 - y)))) - t
function code(x, y, z, t) return Float64(Float64(Float64(x * log(y)) + Float64(z * log(Float64(1.0 - y)))) - t) end
function tmp = code(x, y, z, t) tmp = ((x * log(y)) + (z * log((1.0 - y)))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))
double code(double x, double y, double z, double t) {
return ((x * log(y)) + (z * log((1.0 - y)))) - 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)) + (z * log((1.0d0 - y)))) - t
end function
public static double code(double x, double y, double z, double t) {
return ((x * Math.log(y)) + (z * Math.log((1.0 - y)))) - t;
}
def code(x, y, z, t): return ((x * math.log(y)) + (z * math.log((1.0 - y)))) - t
function code(x, y, z, t) return Float64(Float64(Float64(x * log(y)) + Float64(z * log(Float64(1.0 - y)))) - t) end
function tmp = code(x, y, z, t) tmp = ((x * log(y)) + (z * log((1.0 - y)))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\end{array}
(FPCore (x y z t) :precision binary64 (fma z (log1p (- y)) (- (* x (log y)) t)))
double code(double x, double y, double z, double t) {
return fma(z, log1p(-y), ((x * log(y)) - t));
}
function code(x, y, z, t) return fma(z, log1p(Float64(-y)), Float64(Float64(x * log(y)) - t)) end
code[x_, y_, z_, t_] := N[(z * N[Log[1 + (-y)], $MachinePrecision] + N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, \mathsf{log1p}\left(-y\right), x \cdot \log y - t\right)
\end{array}
Initial program 83.1%
+-commutative83.1%
associate--l+83.1%
fma-define83.1%
sub-neg83.1%
log1p-define99.8%
Simplified99.8%
(FPCore (x y z t)
:precision binary64
(if (<= x -7.5e-41)
(fma x (log y) (- t))
(if (<= x -1.4e-184)
(- (* y (* z (+ (* y -0.5) -1.0))) t)
(if (<= x -2.6e-204)
(* t (+ (* x (/ (log y) t)) -1.0))
(if (<= x 3.7e-146)
(- (* z (log1p (- y))) t)
(- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -7.5e-41) {
tmp = fma(x, log(y), -t);
} else if (x <= -1.4e-184) {
tmp = (y * (z * ((y * -0.5) + -1.0))) - t;
} else if (x <= -2.6e-204) {
tmp = t * ((x * (log(y) / t)) + -1.0);
} else if (x <= 3.7e-146) {
tmp = (z * log1p(-y)) - t;
} else {
tmp = ((x * log(y)) + (z * log((1.0 - y)))) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -7.5e-41) tmp = fma(x, log(y), Float64(-t)); elseif (x <= -1.4e-184) tmp = Float64(Float64(y * Float64(z * Float64(Float64(y * -0.5) + -1.0))) - t); elseif (x <= -2.6e-204) tmp = Float64(t * Float64(Float64(x * Float64(log(y) / t)) + -1.0)); elseif (x <= 3.7e-146) tmp = Float64(Float64(z * log1p(Float64(-y))) - t); else tmp = Float64(Float64(Float64(x * log(y)) + Float64(z * log(Float64(1.0 - y)))) - t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -7.5e-41], N[(x * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision], If[LessEqual[x, -1.4e-184], N[(N[(y * N[(z * N[(N[(y * -0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[x, -2.6e-204], N[(t * N[(N[(x * N[(N[Log[y], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.7e-146], N[(N[(z * N[Log[1 + (-y)], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{-41}:\\
\;\;\;\;\mathsf{fma}\left(x, \log y, -t\right)\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{-184}:\\
\;\;\;\;y \cdot \left(z \cdot \left(y \cdot -0.5 + -1\right)\right) - t\\
\mathbf{elif}\;x \leq -2.6 \cdot 10^{-204}:\\
\;\;\;\;t \cdot \left(x \cdot \frac{\log y}{t} + -1\right)\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{-146}:\\
\;\;\;\;z \cdot \mathsf{log1p}\left(-y\right) - t\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t\\
\end{array}
\end{array}
if x < -7.50000000000000049e-41Initial program 98.3%
Taylor expanded in y around 0 98.3%
fma-neg98.3%
Simplified98.3%
if -7.50000000000000049e-41 < x < -1.3999999999999999e-184Initial program 62.7%
Taylor expanded in x around 0 49.9%
sub-neg49.9%
log1p-undefine87.2%
Simplified87.2%
Taylor expanded in y around 0 87.2%
Taylor expanded in z around 0 87.2%
Taylor expanded in y around 0 87.2%
*-commutative87.2%
Simplified87.2%
if -1.3999999999999999e-184 < x < -2.59999999999999983e-204Initial program 86.3%
Taylor expanded in y around 0 86.3%
fma-neg86.3%
Simplified86.3%
Taylor expanded in t around inf 86.3%
sub-neg86.3%
associate-/l*86.5%
metadata-eval86.5%
Simplified86.5%
if -2.59999999999999983e-204 < x < 3.69999999999999986e-146Initial program 60.1%
Taylor expanded in x around 0 52.3%
sub-neg52.3%
log1p-undefine92.3%
Simplified92.3%
if 3.69999999999999986e-146 < x Initial program 90.2%
Final simplification92.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (log1p (- y))))
(if (or (<= t -2.1e+70) (not (<= t 1.5e-161)))
(* t (+ (* x (/ (log y) t)) (+ (* z (/ t_1 t)) -1.0)))
(* x (+ (log y) (/ (- (* z t_1) t) x))))))
double code(double x, double y, double z, double t) {
double t_1 = log1p(-y);
double tmp;
if ((t <= -2.1e+70) || !(t <= 1.5e-161)) {
tmp = t * ((x * (log(y) / t)) + ((z * (t_1 / t)) + -1.0));
} else {
tmp = x * (log(y) + (((z * t_1) - t) / x));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = Math.log1p(-y);
double tmp;
if ((t <= -2.1e+70) || !(t <= 1.5e-161)) {
tmp = t * ((x * (Math.log(y) / t)) + ((z * (t_1 / t)) + -1.0));
} else {
tmp = x * (Math.log(y) + (((z * t_1) - t) / x));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.log1p(-y) tmp = 0 if (t <= -2.1e+70) or not (t <= 1.5e-161): tmp = t * ((x * (math.log(y) / t)) + ((z * (t_1 / t)) + -1.0)) else: tmp = x * (math.log(y) + (((z * t_1) - t) / x)) return tmp
function code(x, y, z, t) t_1 = log1p(Float64(-y)) tmp = 0.0 if ((t <= -2.1e+70) || !(t <= 1.5e-161)) tmp = Float64(t * Float64(Float64(x * Float64(log(y) / t)) + Float64(Float64(z * Float64(t_1 / t)) + -1.0))); else tmp = Float64(x * Float64(log(y) + Float64(Float64(Float64(z * t_1) - t) / x))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Log[1 + (-y)], $MachinePrecision]}, If[Or[LessEqual[t, -2.1e+70], N[Not[LessEqual[t, 1.5e-161]], $MachinePrecision]], N[(t * N[(N[(x * N[(N[Log[y], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] + N[(N[(z * N[(t$95$1 / t), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[Log[y], $MachinePrecision] + N[(N[(N[(z * t$95$1), $MachinePrecision] - t), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{log1p}\left(-y\right)\\
\mathbf{if}\;t \leq -2.1 \cdot 10^{+70} \lor \neg \left(t \leq 1.5 \cdot 10^{-161}\right):\\
\;\;\;\;t \cdot \left(x \cdot \frac{\log y}{t} + \left(z \cdot \frac{t\_1}{t} + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log y + \frac{z \cdot t\_1 - t}{x}\right)\\
\end{array}
\end{array}
if t < -2.10000000000000008e70 or 1.49999999999999994e-161 < t Initial program 90.1%
Taylor expanded in t around inf 88.8%
associate--l+88.8%
associate-/l*88.8%
associate-/l*88.8%
sub-neg88.8%
log1p-undefine98.5%
Simplified98.5%
if -2.10000000000000008e70 < t < 1.49999999999999994e-161Initial program 72.4%
Taylor expanded in x around inf 72.0%
associate--l+72.0%
div-sub72.0%
sub-neg72.0%
log1p-undefine94.0%
Simplified94.0%
Final simplification96.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* z (log1p (- y))) t)))
(if (or (<= x -3.1e-167) (not (<= x 6e-138)))
(* x (+ (log y) (/ t_1 x)))
t_1)))
double code(double x, double y, double z, double t) {
double t_1 = (z * log1p(-y)) - t;
double tmp;
if ((x <= -3.1e-167) || !(x <= 6e-138)) {
tmp = x * (log(y) + (t_1 / x));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (z * Math.log1p(-y)) - t;
double tmp;
if ((x <= -3.1e-167) || !(x <= 6e-138)) {
tmp = x * (Math.log(y) + (t_1 / x));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * math.log1p(-y)) - t tmp = 0 if (x <= -3.1e-167) or not (x <= 6e-138): tmp = x * (math.log(y) + (t_1 / x)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * log1p(Float64(-y))) - t) tmp = 0.0 if ((x <= -3.1e-167) || !(x <= 6e-138)) tmp = Float64(x * Float64(log(y) + Float64(t_1 / x))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * N[Log[1 + (-y)], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]}, If[Or[LessEqual[x, -3.1e-167], N[Not[LessEqual[x, 6e-138]], $MachinePrecision]], N[(x * N[(N[Log[y], $MachinePrecision] + N[(t$95$1 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \mathsf{log1p}\left(-y\right) - t\\
\mathbf{if}\;x \leq -3.1 \cdot 10^{-167} \lor \neg \left(x \leq 6 \cdot 10^{-138}\right):\\
\;\;\;\;x \cdot \left(\log y + \frac{t\_1}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.1e-167 or 6.0000000000000001e-138 < x Initial program 89.5%
Taylor expanded in x around inf 88.9%
associate--l+88.9%
div-sub88.9%
sub-neg88.9%
log1p-undefine98.3%
Simplified98.3%
if -3.1e-167 < x < 6.0000000000000001e-138Initial program 62.0%
Taylor expanded in x around 0 53.1%
sub-neg53.1%
log1p-undefine91.1%
Simplified91.1%
Final simplification96.6%
(FPCore (x y z t)
:precision binary64
(if (or (<= x -1.5e-40) (not (<= x 5.6e-9)))
(fma x (log y) (- t))
(-
(* y (* z (+ -1.0 (* y (- (* y (- (* y -0.25) 0.3333333333333333)) 0.5)))))
t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.5e-40) || !(x <= 5.6e-9)) {
tmp = fma(x, log(y), -t);
} else {
tmp = (y * (z * (-1.0 + (y * ((y * ((y * -0.25) - 0.3333333333333333)) - 0.5))))) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.5e-40) || !(x <= 5.6e-9)) tmp = fma(x, log(y), Float64(-t)); else tmp = Float64(Float64(y * Float64(z * Float64(-1.0 + Float64(y * Float64(Float64(y * Float64(Float64(y * -0.25) - 0.3333333333333333)) - 0.5))))) - t); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.5e-40], N[Not[LessEqual[x, 5.6e-9]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision], N[(N[(y * N[(z * N[(-1.0 + N[(y * N[(N[(y * N[(N[(y * -0.25), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{-40} \lor \neg \left(x \leq 5.6 \cdot 10^{-9}\right):\\
\;\;\;\;\mathsf{fma}\left(x, \log y, -t\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot \left(-1 + y \cdot \left(y \cdot \left(y \cdot -0.25 - 0.3333333333333333\right) - 0.5\right)\right)\right) - t\\
\end{array}
\end{array}
if x < -1.5000000000000001e-40 or 5.59999999999999969e-9 < x Initial program 97.5%
Taylor expanded in y around 0 97.5%
fma-neg97.6%
Simplified97.6%
if -1.5000000000000001e-40 < x < 5.59999999999999969e-9Initial program 67.1%
Taylor expanded in x around 0 54.9%
sub-neg54.9%
log1p-undefine87.8%
Simplified87.8%
Taylor expanded in y around 0 87.8%
Taylor expanded in z around 0 87.8%
Final simplification92.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (log y))))
(if (<= x -200000.0)
t_1
(if (<= x -2.7e-78)
(- (- t) (* z y))
(if (or (<= x -1.65e-79) (not (<= x 2.45e+61)))
t_1
(-
(*
y
(*
z
(+ -1.0 (* y (- (* y (- (* y -0.25) 0.3333333333333333)) 0.5)))))
t))))))
double code(double x, double y, double z, double t) {
double t_1 = x * log(y);
double tmp;
if (x <= -200000.0) {
tmp = t_1;
} else if (x <= -2.7e-78) {
tmp = -t - (z * y);
} else if ((x <= -1.65e-79) || !(x <= 2.45e+61)) {
tmp = t_1;
} else {
tmp = (y * (z * (-1.0 + (y * ((y * ((y * -0.25) - 0.3333333333333333)) - 0.5))))) - t;
}
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 <= (-200000.0d0)) then
tmp = t_1
else if (x <= (-2.7d-78)) then
tmp = -t - (z * y)
else if ((x <= (-1.65d-79)) .or. (.not. (x <= 2.45d+61))) then
tmp = t_1
else
tmp = (y * (z * ((-1.0d0) + (y * ((y * ((y * (-0.25d0)) - 0.3333333333333333d0)) - 0.5d0))))) - t
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 <= -200000.0) {
tmp = t_1;
} else if (x <= -2.7e-78) {
tmp = -t - (z * y);
} else if ((x <= -1.65e-79) || !(x <= 2.45e+61)) {
tmp = t_1;
} else {
tmp = (y * (z * (-1.0 + (y * ((y * ((y * -0.25) - 0.3333333333333333)) - 0.5))))) - t;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * math.log(y) tmp = 0 if x <= -200000.0: tmp = t_1 elif x <= -2.7e-78: tmp = -t - (z * y) elif (x <= -1.65e-79) or not (x <= 2.45e+61): tmp = t_1 else: tmp = (y * (z * (-1.0 + (y * ((y * ((y * -0.25) - 0.3333333333333333)) - 0.5))))) - t return tmp
function code(x, y, z, t) t_1 = Float64(x * log(y)) tmp = 0.0 if (x <= -200000.0) tmp = t_1; elseif (x <= -2.7e-78) tmp = Float64(Float64(-t) - Float64(z * y)); elseif ((x <= -1.65e-79) || !(x <= 2.45e+61)) tmp = t_1; else tmp = Float64(Float64(y * Float64(z * Float64(-1.0 + Float64(y * Float64(Float64(y * Float64(Float64(y * -0.25) - 0.3333333333333333)) - 0.5))))) - t); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * log(y); tmp = 0.0; if (x <= -200000.0) tmp = t_1; elseif (x <= -2.7e-78) tmp = -t - (z * y); elseif ((x <= -1.65e-79) || ~((x <= 2.45e+61))) tmp = t_1; else tmp = (y * (z * (-1.0 + (y * ((y * ((y * -0.25) - 0.3333333333333333)) - 0.5))))) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -200000.0], t$95$1, If[LessEqual[x, -2.7e-78], N[((-t) - N[(z * y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -1.65e-79], N[Not[LessEqual[x, 2.45e+61]], $MachinePrecision]], t$95$1, N[(N[(y * N[(z * N[(-1.0 + N[(y * N[(N[(y * N[(N[(y * -0.25), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x \leq -200000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -2.7 \cdot 10^{-78}:\\
\;\;\;\;\left(-t\right) - z \cdot y\\
\mathbf{elif}\;x \leq -1.65 \cdot 10^{-79} \lor \neg \left(x \leq 2.45 \cdot 10^{+61}\right):\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot \left(-1 + y \cdot \left(y \cdot \left(y \cdot -0.25 - 0.3333333333333333\right) - 0.5\right)\right)\right) - t\\
\end{array}
\end{array}
if x < -2e5 or -2.69999999999999994e-78 < x < -1.6499999999999999e-79 or 2.45000000000000013e61 < x Initial program 98.1%
Taylor expanded in y around 0 98.1%
fma-neg98.1%
Simplified98.1%
Taylor expanded in x around inf 81.0%
if -2e5 < x < -2.69999999999999994e-78Initial program 84.6%
Taylor expanded in x around 0 71.3%
sub-neg71.3%
log1p-undefine86.8%
Simplified86.8%
Taylor expanded in y around 0 86.8%
mul-1-neg86.8%
distribute-rgt-neg-in86.8%
Simplified86.8%
if -1.6499999999999999e-79 < x < 2.45000000000000013e61Initial program 67.3%
Taylor expanded in x around 0 56.3%
sub-neg56.3%
log1p-undefine88.9%
Simplified88.9%
Taylor expanded in y around 0 88.9%
Taylor expanded in z around 0 88.9%
Final simplification85.0%
(FPCore (x y z t)
:precision binary64
(if (or (<= x -1.2e-40) (not (<= x 3.7e-7)))
(- (* x (log y)) t)
(-
(* y (* z (+ -1.0 (* y (- (* y (- (* y -0.25) 0.3333333333333333)) 0.5)))))
t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.2e-40) || !(x <= 3.7e-7)) {
tmp = (x * log(y)) - t;
} else {
tmp = (y * (z * (-1.0 + (y * ((y * ((y * -0.25) - 0.3333333333333333)) - 0.5))))) - t;
}
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 <= (-1.2d-40)) .or. (.not. (x <= 3.7d-7))) then
tmp = (x * log(y)) - t
else
tmp = (y * (z * ((-1.0d0) + (y * ((y * ((y * (-0.25d0)) - 0.3333333333333333d0)) - 0.5d0))))) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.2e-40) || !(x <= 3.7e-7)) {
tmp = (x * Math.log(y)) - t;
} else {
tmp = (y * (z * (-1.0 + (y * ((y * ((y * -0.25) - 0.3333333333333333)) - 0.5))))) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.2e-40) or not (x <= 3.7e-7): tmp = (x * math.log(y)) - t else: tmp = (y * (z * (-1.0 + (y * ((y * ((y * -0.25) - 0.3333333333333333)) - 0.5))))) - t return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.2e-40) || !(x <= 3.7e-7)) tmp = Float64(Float64(x * log(y)) - t); else tmp = Float64(Float64(y * Float64(z * Float64(-1.0 + Float64(y * Float64(Float64(y * Float64(Float64(y * -0.25) - 0.3333333333333333)) - 0.5))))) - t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -1.2e-40) || ~((x <= 3.7e-7))) tmp = (x * log(y)) - t; else tmp = (y * (z * (-1.0 + (y * ((y * ((y * -0.25) - 0.3333333333333333)) - 0.5))))) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.2e-40], N[Not[LessEqual[x, 3.7e-7]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(y * N[(z * N[(-1.0 + N[(y * N[(N[(y * N[(N[(y * -0.25), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{-40} \lor \neg \left(x \leq 3.7 \cdot 10^{-7}\right):\\
\;\;\;\;x \cdot \log y - t\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot \left(-1 + y \cdot \left(y \cdot \left(y \cdot -0.25 - 0.3333333333333333\right) - 0.5\right)\right)\right) - t\\
\end{array}
\end{array}
if x < -1.19999999999999996e-40 or 3.70000000000000004e-7 < x Initial program 97.5%
Taylor expanded in y around 0 97.5%
if -1.19999999999999996e-40 < x < 3.70000000000000004e-7Initial program 67.1%
Taylor expanded in x around 0 54.9%
sub-neg54.9%
log1p-undefine87.8%
Simplified87.8%
Taylor expanded in y around 0 87.8%
Taylor expanded in z around 0 87.8%
Final simplification92.9%
(FPCore (x y z t) :precision binary64 (- (* y (* z (+ -1.0 (* y (- (* y (- (* y -0.25) 0.3333333333333333)) 0.5))))) t))
double code(double x, double y, double z, double t) {
return (y * (z * (-1.0 + (y * ((y * ((y * -0.25) - 0.3333333333333333)) - 0.5))))) - 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 = (y * (z * ((-1.0d0) + (y * ((y * ((y * (-0.25d0)) - 0.3333333333333333d0)) - 0.5d0))))) - t
end function
public static double code(double x, double y, double z, double t) {
return (y * (z * (-1.0 + (y * ((y * ((y * -0.25) - 0.3333333333333333)) - 0.5))))) - t;
}
def code(x, y, z, t): return (y * (z * (-1.0 + (y * ((y * ((y * -0.25) - 0.3333333333333333)) - 0.5))))) - t
function code(x, y, z, t) return Float64(Float64(y * Float64(z * Float64(-1.0 + Float64(y * Float64(Float64(y * Float64(Float64(y * -0.25) - 0.3333333333333333)) - 0.5))))) - t) end
function tmp = code(x, y, z, t) tmp = (y * (z * (-1.0 + (y * ((y * ((y * -0.25) - 0.3333333333333333)) - 0.5))))) - t; end
code[x_, y_, z_, t_] := N[(N[(y * N[(z * N[(-1.0 + N[(y * N[(N[(y * N[(N[(y * -0.25), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(z \cdot \left(-1 + y \cdot \left(y \cdot \left(y \cdot -0.25 - 0.3333333333333333\right) - 0.5\right)\right)\right) - t
\end{array}
Initial program 83.1%
Taylor expanded in x around 0 39.3%
sub-neg39.3%
log1p-undefine56.0%
Simplified56.0%
Taylor expanded in y around 0 56.0%
Taylor expanded in z around 0 56.0%
Final simplification56.0%
(FPCore (x y z t) :precision binary64 (- (* y (* z (+ -1.0 (* y (- (* y -0.3333333333333333) 0.5))))) t))
double code(double x, double y, double z, double t) {
return (y * (z * (-1.0 + (y * ((y * -0.3333333333333333) - 0.5))))) - 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 = (y * (z * ((-1.0d0) + (y * ((y * (-0.3333333333333333d0)) - 0.5d0))))) - t
end function
public static double code(double x, double y, double z, double t) {
return (y * (z * (-1.0 + (y * ((y * -0.3333333333333333) - 0.5))))) - t;
}
def code(x, y, z, t): return (y * (z * (-1.0 + (y * ((y * -0.3333333333333333) - 0.5))))) - t
function code(x, y, z, t) return Float64(Float64(y * Float64(z * Float64(-1.0 + Float64(y * Float64(Float64(y * -0.3333333333333333) - 0.5))))) - t) end
function tmp = code(x, y, z, t) tmp = (y * (z * (-1.0 + (y * ((y * -0.3333333333333333) - 0.5))))) - t; end
code[x_, y_, z_, t_] := N[(N[(y * N[(z * N[(-1.0 + N[(y * N[(N[(y * -0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(z \cdot \left(-1 + y \cdot \left(y \cdot -0.3333333333333333 - 0.5\right)\right)\right) - t
\end{array}
Initial program 83.1%
Taylor expanded in x around 0 39.3%
sub-neg39.3%
log1p-undefine56.0%
Simplified56.0%
Taylor expanded in y around 0 56.0%
Taylor expanded in z around 0 56.0%
Taylor expanded in y around 0 56.0%
*-commutative56.0%
Simplified56.0%
Final simplification56.0%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.75e-38) (not (<= t 1.45e-126))) (- t) (* z (- y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.75e-38) || !(t <= 1.45e-126)) {
tmp = -t;
} else {
tmp = z * -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 ((t <= (-1.75d-38)) .or. (.not. (t <= 1.45d-126))) then
tmp = -t
else
tmp = z * -y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.75e-38) || !(t <= 1.45e-126)) {
tmp = -t;
} else {
tmp = z * -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.75e-38) or not (t <= 1.45e-126): tmp = -t else: tmp = z * -y return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.75e-38) || !(t <= 1.45e-126)) tmp = Float64(-t); else tmp = Float64(z * Float64(-y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.75e-38) || ~((t <= 1.45e-126))) tmp = -t; else tmp = z * -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.75e-38], N[Not[LessEqual[t, 1.45e-126]], $MachinePrecision]], (-t), N[(z * (-y)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.75 \cdot 10^{-38} \lor \neg \left(t \leq 1.45 \cdot 10^{-126}\right):\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-y\right)\\
\end{array}
\end{array}
if t < -1.7500000000000001e-38 or 1.44999999999999994e-126 < t Initial program 90.6%
Taylor expanded in t around inf 54.2%
neg-mul-154.2%
Simplified54.2%
if -1.7500000000000001e-38 < t < 1.44999999999999994e-126Initial program 69.3%
Taylor expanded in x around 0 10.8%
sub-neg10.8%
log1p-undefine41.2%
Simplified41.2%
Taylor expanded in y around 0 41.2%
Taylor expanded in y around 0 40.3%
associate-*r*40.3%
neg-mul-140.3%
*-commutative40.3%
Simplified40.3%
Taylor expanded in z around inf 33.5%
mul-1-neg33.5%
distribute-rgt-neg-in33.5%
Simplified33.5%
Final simplification46.9%
(FPCore (x y z t) :precision binary64 (- (* y (* z (+ (* y -0.5) -1.0))) t))
double code(double x, double y, double z, double t) {
return (y * (z * ((y * -0.5) + -1.0))) - 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 = (y * (z * ((y * (-0.5d0)) + (-1.0d0)))) - t
end function
public static double code(double x, double y, double z, double t) {
return (y * (z * ((y * -0.5) + -1.0))) - t;
}
def code(x, y, z, t): return (y * (z * ((y * -0.5) + -1.0))) - t
function code(x, y, z, t) return Float64(Float64(y * Float64(z * Float64(Float64(y * -0.5) + -1.0))) - t) end
function tmp = code(x, y, z, t) tmp = (y * (z * ((y * -0.5) + -1.0))) - t; end
code[x_, y_, z_, t_] := N[(N[(y * N[(z * N[(N[(y * -0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(z \cdot \left(y \cdot -0.5 + -1\right)\right) - t
\end{array}
Initial program 83.1%
Taylor expanded in x around 0 39.3%
sub-neg39.3%
log1p-undefine56.0%
Simplified56.0%
Taylor expanded in y around 0 56.0%
Taylor expanded in z around 0 56.0%
Taylor expanded in y around 0 55.9%
*-commutative55.9%
Simplified55.9%
Final simplification55.9%
(FPCore (x y z t) :precision binary64 (- (- t) (* z y)))
double code(double x, double y, double z, double t) {
return -t - (z * 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 = -t - (z * y)
end function
public static double code(double x, double y, double z, double t) {
return -t - (z * y);
}
def code(x, y, z, t): return -t - (z * y)
function code(x, y, z, t) return Float64(Float64(-t) - Float64(z * y)) end
function tmp = code(x, y, z, t) tmp = -t - (z * y); end
code[x_, y_, z_, t_] := N[((-t) - N[(z * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-t\right) - z \cdot y
\end{array}
Initial program 83.1%
Taylor expanded in x around 0 39.3%
sub-neg39.3%
log1p-undefine56.0%
Simplified56.0%
Taylor expanded in y around 0 55.4%
mul-1-neg55.4%
distribute-rgt-neg-in55.4%
Simplified55.4%
Final simplification55.4%
(FPCore (x y z t) :precision binary64 (- t))
double code(double x, double y, double z, double t) {
return -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 = -t
end function
public static double code(double x, double y, double z, double t) {
return -t;
}
def code(x, y, z, t): return -t
function code(x, y, z, t) return Float64(-t) end
function tmp = code(x, y, z, t) tmp = -t; end
code[x_, y_, z_, t_] := (-t)
\begin{array}{l}
\\
-t
\end{array}
Initial program 83.1%
Taylor expanded in t around inf 38.3%
neg-mul-138.3%
Simplified38.3%
(FPCore (x y z t) :precision binary64 t)
double code(double x, double y, double z, double t) {
return 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 = t
end function
public static double code(double x, double y, double z, double t) {
return t;
}
def code(x, y, z, t): return t
function code(x, y, z, t) return t end
function tmp = code(x, y, z, t) tmp = t; end
code[x_, y_, z_, t_] := t
\begin{array}{l}
\\
t
\end{array}
Initial program 83.1%
Taylor expanded in z around inf 64.5%
Taylor expanded in t around inf 30.1%
associate-*r/30.1%
mul-1-neg30.1%
Simplified30.1%
expm1-log1p-u16.5%
expm1-undefine12.2%
distribute-frac-neg12.2%
Applied egg-rr12.2%
sub-neg12.2%
metadata-eval12.2%
+-commutative12.2%
log1p-undefine12.2%
rem-exp-log25.9%
distribute-neg-frac25.9%
associate-/l*28.2%
*-commutative28.2%
associate-/l*34.1%
*-inverses34.1%
*-rgt-identity34.1%
unsub-neg34.1%
Simplified34.1%
associate-+r-38.3%
metadata-eval38.3%
neg-sub038.3%
add-sqr-sqrt16.7%
sqrt-unprod11.7%
sqr-neg11.7%
sqrt-unprod1.3%
add-sqr-sqrt2.3%
*-un-lft-identity2.3%
Applied egg-rr2.3%
*-lft-identity2.3%
Simplified2.3%
(FPCore (x y z t)
:precision binary64
(-
(*
(- z)
(+
(+ (* 0.5 (* y y)) y)
(* (/ 0.3333333333333333 (* 1.0 (* 1.0 1.0))) (* y (* y y)))))
(- t (* x (log y)))))
double code(double x, double y, double z, double t) {
return (-z * (((0.5 * (y * y)) + y) + ((0.3333333333333333 / (1.0 * (1.0 * 1.0))) * (y * (y * y))))) - (t - (x * log(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 = (-z * (((0.5d0 * (y * y)) + y) + ((0.3333333333333333d0 / (1.0d0 * (1.0d0 * 1.0d0))) * (y * (y * y))))) - (t - (x * log(y)))
end function
public static double code(double x, double y, double z, double t) {
return (-z * (((0.5 * (y * y)) + y) + ((0.3333333333333333 / (1.0 * (1.0 * 1.0))) * (y * (y * y))))) - (t - (x * Math.log(y)));
}
def code(x, y, z, t): return (-z * (((0.5 * (y * y)) + y) + ((0.3333333333333333 / (1.0 * (1.0 * 1.0))) * (y * (y * y))))) - (t - (x * math.log(y)))
function code(x, y, z, t) return Float64(Float64(Float64(-z) * Float64(Float64(Float64(0.5 * Float64(y * y)) + y) + Float64(Float64(0.3333333333333333 / Float64(1.0 * Float64(1.0 * 1.0))) * Float64(y * Float64(y * y))))) - Float64(t - Float64(x * log(y)))) end
function tmp = code(x, y, z, t) tmp = (-z * (((0.5 * (y * y)) + y) + ((0.3333333333333333 / (1.0 * (1.0 * 1.0))) * (y * (y * y))))) - (t - (x * log(y))); end
code[x_, y_, z_, t_] := N[(N[((-z) * N[(N[(N[(0.5 * N[(y * y), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] + N[(N[(0.3333333333333333 / N[(1.0 * N[(1.0 * 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(y * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t - N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-z\right) \cdot \left(\left(0.5 \cdot \left(y \cdot y\right) + y\right) + \frac{0.3333333333333333}{1 \cdot \left(1 \cdot 1\right)} \cdot \left(y \cdot \left(y \cdot y\right)\right)\right) - \left(t - x \cdot \log y\right)
\end{array}
herbie shell --seed 2024107
(FPCore (x y z t)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, B"
:precision binary64
:alt
(- (* (- z) (+ (+ (* 0.5 (* y y)) y) (* (/ 0.3333333333333333 (* 1.0 (* 1.0 1.0))) (* y (* y y))))) (- t (* x (log y))))
(- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))