
(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 11 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 85.5%
+-commutative85.5%
associate--l+85.5%
fma-define85.5%
sub-neg85.5%
log1p-define99.8%
Simplified99.8%
(FPCore (x y z t) :precision binary64 (if (or (<= x -51.0) (not (<= x 1.8e-157))) (- (* x (log y)) t) (- (* z (log1p (- y))) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -51.0) || !(x <= 1.8e-157)) {
tmp = (x * log(y)) - t;
} else {
tmp = (z * log1p(-y)) - t;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -51.0) || !(x <= 1.8e-157)) {
tmp = (x * Math.log(y)) - t;
} else {
tmp = (z * Math.log1p(-y)) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -51.0) or not (x <= 1.8e-157): tmp = (x * math.log(y)) - t else: tmp = (z * math.log1p(-y)) - t return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -51.0) || !(x <= 1.8e-157)) tmp = Float64(Float64(x * log(y)) - t); else tmp = Float64(Float64(z * log1p(Float64(-y))) - t); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -51.0], N[Not[LessEqual[x, 1.8e-157]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(z * N[Log[1 + (-y)], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -51 \lor \neg \left(x \leq 1.8 \cdot 10^{-157}\right):\\
\;\;\;\;x \cdot \log y - t\\
\mathbf{else}:\\
\;\;\;\;z \cdot \mathsf{log1p}\left(-y\right) - t\\
\end{array}
\end{array}
if x < -51 or 1.8e-157 < x Initial program 93.2%
+-commutative93.2%
associate--l+93.2%
fma-define93.2%
sub-neg93.2%
log1p-define99.7%
Simplified99.7%
Taylor expanded in z around 0 92.1%
if -51 < x < 1.8e-157Initial program 72.4%
+-commutative72.4%
associate--l+72.4%
fma-define72.4%
sub-neg72.4%
log1p-define99.9%
Simplified99.9%
Taylor expanded in x around 0 65.1%
sub-neg65.1%
log1p-define92.7%
Simplified92.7%
Final simplification92.3%
(FPCore (x y z t) :precision binary64 (- (+ (* x (log y)) (* y (- (* -0.5 (* z y)) z))) t))
double code(double x, double y, double z, double t) {
return ((x * log(y)) + (y * ((-0.5 * (z * y)) - z))) - 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 * (((-0.5d0) * (z * y)) - z))) - t
end function
public static double code(double x, double y, double z, double t) {
return ((x * Math.log(y)) + (y * ((-0.5 * (z * y)) - z))) - t;
}
def code(x, y, z, t): return ((x * math.log(y)) + (y * ((-0.5 * (z * y)) - z))) - t
function code(x, y, z, t) return Float64(Float64(Float64(x * log(y)) + Float64(y * Float64(Float64(-0.5 * Float64(z * y)) - z))) - t) end
function tmp = code(x, y, z, t) tmp = ((x * log(y)) + (y * ((-0.5 * (z * y)) - z))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(y * N[(N[(-0.5 * N[(z * y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y + y \cdot \left(-0.5 \cdot \left(z \cdot y\right) - z\right)\right) - t
\end{array}
Initial program 85.5%
Taylor expanded in y around 0 99.4%
Final simplification99.4%
(FPCore (x y z t) :precision binary64 (- (+ (* x (log y)) (* y (* z (+ -1.0 (* y -0.5))))) t))
double code(double x, double y, double z, double t) {
return ((x * log(y)) + (y * (z * (-1.0 + (y * -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 = ((x * log(y)) + (y * (z * ((-1.0d0) + (y * (-0.5d0)))))) - t
end function
public static double code(double x, double y, double z, double t) {
return ((x * Math.log(y)) + (y * (z * (-1.0 + (y * -0.5))))) - t;
}
def code(x, y, z, t): return ((x * math.log(y)) + (y * (z * (-1.0 + (y * -0.5))))) - t
function code(x, y, z, t) return Float64(Float64(Float64(x * log(y)) + Float64(y * Float64(z * Float64(-1.0 + Float64(y * -0.5))))) - t) end
function tmp = code(x, y, z, t) tmp = ((x * log(y)) + (y * (z * (-1.0 + (y * -0.5))))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(y * N[(z * N[(-1.0 + N[(y * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y + y \cdot \left(z \cdot \left(-1 + y \cdot -0.5\right)\right)\right) - t
\end{array}
Initial program 85.5%
Taylor expanded in y around 0 99.4%
Taylor expanded in z around 0 99.3%
Final simplification99.3%
(FPCore (x y z t) :precision binary64 (if (or (<= x -2.4e+25) (not (<= x 1.25e+78))) (* x (log y)) (- t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.4e+25) || !(x <= 1.25e+78)) {
tmp = x * log(y);
} else {
tmp = -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 <= (-2.4d+25)) .or. (.not. (x <= 1.25d+78))) then
tmp = x * log(y)
else
tmp = -t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.4e+25) || !(x <= 1.25e+78)) {
tmp = x * Math.log(y);
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -2.4e+25) or not (x <= 1.25e+78): tmp = x * math.log(y) else: tmp = -t return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -2.4e+25) || !(x <= 1.25e+78)) tmp = Float64(x * log(y)); else tmp = Float64(-t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -2.4e+25) || ~((x <= 1.25e+78))) tmp = x * log(y); else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -2.4e+25], N[Not[LessEqual[x, 1.25e+78]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], (-t)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \cdot 10^{+25} \lor \neg \left(x \leq 1.25 \cdot 10^{+78}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if x < -2.39999999999999996e25 or 1.24999999999999996e78 < x Initial program 95.7%
+-commutative95.7%
associate--l+95.7%
fma-define95.7%
sub-neg95.7%
log1p-define99.7%
Simplified99.7%
Taylor expanded in x around inf 95.6%
associate--l+95.6%
div-sub95.6%
sub-neg95.6%
log1p-define99.6%
Simplified99.6%
Taylor expanded in x around inf 74.7%
if -2.39999999999999996e25 < x < 1.24999999999999996e78Initial program 76.9%
+-commutative76.9%
associate--l+76.9%
fma-define76.9%
sub-neg76.9%
log1p-define99.9%
Simplified99.9%
Taylor expanded in t around inf 59.4%
neg-mul-159.4%
Simplified59.4%
Final simplification66.5%
(FPCore (x y z t) :precision binary64 (if (<= z 3.9e+254) (- (* x (log y)) t) (* y (- (* -0.5 (* z y)) z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 3.9e+254) {
tmp = (x * log(y)) - t;
} else {
tmp = y * ((-0.5 * (z * 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 (z <= 3.9d+254) then
tmp = (x * log(y)) - t
else
tmp = y * (((-0.5d0) * (z * y)) - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= 3.9e+254) {
tmp = (x * Math.log(y)) - t;
} else {
tmp = y * ((-0.5 * (z * y)) - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 3.9e+254: tmp = (x * math.log(y)) - t else: tmp = y * ((-0.5 * (z * y)) - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 3.9e+254) tmp = Float64(Float64(x * log(y)) - t); else tmp = Float64(y * Float64(Float64(-0.5 * Float64(z * y)) - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= 3.9e+254) tmp = (x * log(y)) - t; else tmp = y * ((-0.5 * (z * y)) - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 3.9e+254], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(y * N[(N[(-0.5 * N[(z * y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.9 \cdot 10^{+254}:\\
\;\;\;\;x \cdot \log y - t\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-0.5 \cdot \left(z \cdot y\right) - z\right)\\
\end{array}
\end{array}
if z < 3.9000000000000001e254Initial program 88.0%
+-commutative88.0%
associate--l+88.0%
fma-define88.0%
sub-neg88.0%
log1p-define99.8%
Simplified99.8%
Taylor expanded in z around 0 86.2%
if 3.9000000000000001e254 < z Initial program 35.2%
+-commutative35.2%
associate--l+35.2%
fma-define35.2%
sub-neg35.2%
log1p-define100.0%
Simplified100.0%
Taylor expanded in z around inf 2.1%
sub-neg2.1%
log1p-define68.6%
Simplified68.6%
Taylor expanded in y around 0 68.6%
Final simplification85.4%
(FPCore (x y z t) :precision binary64 (- (- (* x (log y)) (* z y)) t))
double code(double x, double y, double z, double t) {
return ((x * log(y)) - (z * 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 * y)) - t
end function
public static double code(double x, double y, double z, double t) {
return ((x * Math.log(y)) - (z * y)) - t;
}
def code(x, y, z, t): return ((x * math.log(y)) - (z * y)) - t
function code(x, y, z, t) return Float64(Float64(Float64(x * log(y)) - Float64(z * y)) - t) end
function tmp = code(x, y, z, t) tmp = ((x * log(y)) - (z * y)) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y - z \cdot y\right) - t
\end{array}
Initial program 85.5%
+-commutative85.5%
associate--l+85.5%
fma-define85.5%
sub-neg85.5%
log1p-define99.8%
Simplified99.8%
Taylor expanded in y around 0 98.7%
+-commutative98.7%
mul-1-neg98.7%
unsub-neg98.7%
Simplified98.7%
Final simplification98.7%
(FPCore (x y z t)
:precision binary64
(if (or (<= t -4.4e-65) (not (<= t 2.25e-119)))
(- t)
(*
y
(-
(* y (+ (* z -0.5) (* y (+ (* z -0.3333333333333333) (* (* z y) -0.25)))))
z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -4.4e-65) || !(t <= 2.25e-119)) {
tmp = -t;
} else {
tmp = y * ((y * ((z * -0.5) + (y * ((z * -0.3333333333333333) + ((z * y) * -0.25))))) - 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 ((t <= (-4.4d-65)) .or. (.not. (t <= 2.25d-119))) then
tmp = -t
else
tmp = y * ((y * ((z * (-0.5d0)) + (y * ((z * (-0.3333333333333333d0)) + ((z * y) * (-0.25d0)))))) - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -4.4e-65) || !(t <= 2.25e-119)) {
tmp = -t;
} else {
tmp = y * ((y * ((z * -0.5) + (y * ((z * -0.3333333333333333) + ((z * y) * -0.25))))) - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -4.4e-65) or not (t <= 2.25e-119): tmp = -t else: tmp = y * ((y * ((z * -0.5) + (y * ((z * -0.3333333333333333) + ((z * y) * -0.25))))) - z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -4.4e-65) || !(t <= 2.25e-119)) tmp = Float64(-t); else tmp = Float64(y * Float64(Float64(y * Float64(Float64(z * -0.5) + Float64(y * Float64(Float64(z * -0.3333333333333333) + Float64(Float64(z * y) * -0.25))))) - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -4.4e-65) || ~((t <= 2.25e-119))) tmp = -t; else tmp = y * ((y * ((z * -0.5) + (y * ((z * -0.3333333333333333) + ((z * y) * -0.25))))) - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -4.4e-65], N[Not[LessEqual[t, 2.25e-119]], $MachinePrecision]], (-t), N[(y * N[(N[(y * N[(N[(z * -0.5), $MachinePrecision] + N[(y * N[(N[(z * -0.3333333333333333), $MachinePrecision] + N[(N[(z * y), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.4 \cdot 10^{-65} \lor \neg \left(t \leq 2.25 \cdot 10^{-119}\right):\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(y \cdot \left(z \cdot -0.5 + y \cdot \left(z \cdot -0.3333333333333333 + \left(z \cdot y\right) \cdot -0.25\right)\right) - z\right)\\
\end{array}
\end{array}
if t < -4.40000000000000042e-65 or 2.2500000000000001e-119 < t Initial program 94.5%
+-commutative94.5%
associate--l+94.5%
fma-define94.5%
sub-neg94.5%
log1p-define99.9%
Simplified99.9%
Taylor expanded in t around inf 57.7%
neg-mul-157.7%
Simplified57.7%
if -4.40000000000000042e-65 < t < 2.2500000000000001e-119Initial program 68.1%
+-commutative68.1%
associate--l+68.1%
fma-define68.1%
sub-neg68.1%
log1p-define99.7%
Simplified99.7%
Taylor expanded in z around inf 5.9%
sub-neg5.9%
log1p-define36.4%
Simplified36.4%
Taylor expanded in y around 0 35.7%
Final simplification50.2%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.75e-65) (not (<= t 2.15e-119))) (- t) (* y (- (* y (+ (* z -0.5) (* (* z y) -0.3333333333333333))) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.75e-65) || !(t <= 2.15e-119)) {
tmp = -t;
} else {
tmp = y * ((y * ((z * -0.5) + ((z * y) * -0.3333333333333333))) - 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 ((t <= (-1.75d-65)) .or. (.not. (t <= 2.15d-119))) then
tmp = -t
else
tmp = y * ((y * ((z * (-0.5d0)) + ((z * y) * (-0.3333333333333333d0)))) - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.75e-65) || !(t <= 2.15e-119)) {
tmp = -t;
} else {
tmp = y * ((y * ((z * -0.5) + ((z * y) * -0.3333333333333333))) - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.75e-65) or not (t <= 2.15e-119): tmp = -t else: tmp = y * ((y * ((z * -0.5) + ((z * y) * -0.3333333333333333))) - z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.75e-65) || !(t <= 2.15e-119)) tmp = Float64(-t); else tmp = Float64(y * Float64(Float64(y * Float64(Float64(z * -0.5) + Float64(Float64(z * y) * -0.3333333333333333))) - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.75e-65) || ~((t <= 2.15e-119))) tmp = -t; else tmp = y * ((y * ((z * -0.5) + ((z * y) * -0.3333333333333333))) - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.75e-65], N[Not[LessEqual[t, 2.15e-119]], $MachinePrecision]], (-t), N[(y * N[(N[(y * N[(N[(z * -0.5), $MachinePrecision] + N[(N[(z * y), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.75 \cdot 10^{-65} \lor \neg \left(t \leq 2.15 \cdot 10^{-119}\right):\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(y \cdot \left(z \cdot -0.5 + \left(z \cdot y\right) \cdot -0.3333333333333333\right) - z\right)\\
\end{array}
\end{array}
if t < -1.75000000000000002e-65 or 2.15e-119 < t Initial program 94.5%
+-commutative94.5%
associate--l+94.5%
fma-define94.5%
sub-neg94.5%
log1p-define99.9%
Simplified99.9%
Taylor expanded in t around inf 57.7%
neg-mul-157.7%
Simplified57.7%
if -1.75000000000000002e-65 < t < 2.15e-119Initial program 68.1%
+-commutative68.1%
associate--l+68.1%
fma-define68.1%
sub-neg68.1%
log1p-define99.7%
Simplified99.7%
Taylor expanded in z around inf 5.9%
sub-neg5.9%
log1p-define36.4%
Simplified36.4%
Taylor expanded in y around 0 35.7%
Final simplification50.2%
(FPCore (x y z t) :precision binary64 (if (or (<= t -8.8e-64) (not (<= t 1.05e-118))) (- t) (* y (- (* -0.5 (* z y)) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -8.8e-64) || !(t <= 1.05e-118)) {
tmp = -t;
} else {
tmp = y * ((-0.5 * (z * 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 ((t <= (-8.8d-64)) .or. (.not. (t <= 1.05d-118))) then
tmp = -t
else
tmp = y * (((-0.5d0) * (z * y)) - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -8.8e-64) || !(t <= 1.05e-118)) {
tmp = -t;
} else {
tmp = y * ((-0.5 * (z * y)) - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -8.8e-64) or not (t <= 1.05e-118): tmp = -t else: tmp = y * ((-0.5 * (z * y)) - z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -8.8e-64) || !(t <= 1.05e-118)) tmp = Float64(-t); else tmp = Float64(y * Float64(Float64(-0.5 * Float64(z * y)) - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -8.8e-64) || ~((t <= 1.05e-118))) tmp = -t; else tmp = y * ((-0.5 * (z * y)) - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -8.8e-64], N[Not[LessEqual[t, 1.05e-118]], $MachinePrecision]], (-t), N[(y * N[(N[(-0.5 * N[(z * y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -8.8 \cdot 10^{-64} \lor \neg \left(t \leq 1.05 \cdot 10^{-118}\right):\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-0.5 \cdot \left(z \cdot y\right) - z\right)\\
\end{array}
\end{array}
if t < -8.7999999999999998e-64 or 1.05e-118 < t Initial program 94.5%
+-commutative94.5%
associate--l+94.5%
fma-define94.5%
sub-neg94.5%
log1p-define99.9%
Simplified99.9%
Taylor expanded in t around inf 57.7%
neg-mul-157.7%
Simplified57.7%
if -8.7999999999999998e-64 < t < 1.05e-118Initial program 68.1%
+-commutative68.1%
associate--l+68.1%
fma-define68.1%
sub-neg68.1%
log1p-define99.7%
Simplified99.7%
Taylor expanded in z around inf 5.9%
sub-neg5.9%
log1p-define36.4%
Simplified36.4%
Taylor expanded in y around 0 35.5%
Final simplification50.1%
(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 85.5%
+-commutative85.5%
associate--l+85.5%
fma-define85.5%
sub-neg85.5%
log1p-define99.8%
Simplified99.8%
Taylor expanded in t around inf 41.3%
neg-mul-141.3%
Simplified41.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 2024086
(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))