
(FPCore (x y z) :precision binary64 (- (* x (log (/ x y))) z))
double code(double x, double y, double z) {
return (x * log((x / y))) - z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * log((x / y))) - z
end function
public static double code(double x, double y, double z) {
return (x * Math.log((x / y))) - z;
}
def code(x, y, z): return (x * math.log((x / y))) - z
function code(x, y, z) return Float64(Float64(x * log(Float64(x / y))) - z) end
function tmp = code(x, y, z) tmp = (x * log((x / y))) - z; end
code[x_, y_, z_] := N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \log \left(\frac{x}{y}\right) - z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (* x (log (/ x y))) z))
double code(double x, double y, double z) {
return (x * log((x / y))) - z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * log((x / y))) - z
end function
public static double code(double x, double y, double z) {
return (x * Math.log((x / y))) - z;
}
def code(x, y, z): return (x * math.log((x / y))) - z
function code(x, y, z) return Float64(Float64(x * log(Float64(x / y))) - z) end
function tmp = code(x, y, z) tmp = (x * log((x / y))) - z; end
code[x_, y_, z_] := N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \log \left(\frac{x}{y}\right) - z
\end{array}
(FPCore (x y z) :precision binary64 (if (<= y -5e-311) (- (* x (* 2.0 (log (/ (sqrt (- x)) (sqrt (- y)))))) z) (- (* x (* 2.0 (log (/ (sqrt x) (sqrt y))))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-311) {
tmp = (x * (2.0 * log((sqrt(-x) / sqrt(-y))))) - z;
} else {
tmp = (x * (2.0 * log((sqrt(x) / sqrt(y))))) - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-5d-311)) then
tmp = (x * (2.0d0 * log((sqrt(-x) / sqrt(-y))))) - z
else
tmp = (x * (2.0d0 * log((sqrt(x) / sqrt(y))))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5e-311) {
tmp = (x * (2.0 * Math.log((Math.sqrt(-x) / Math.sqrt(-y))))) - z;
} else {
tmp = (x * (2.0 * Math.log((Math.sqrt(x) / Math.sqrt(y))))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5e-311: tmp = (x * (2.0 * math.log((math.sqrt(-x) / math.sqrt(-y))))) - z else: tmp = (x * (2.0 * math.log((math.sqrt(x) / math.sqrt(y))))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5e-311) tmp = Float64(Float64(x * Float64(2.0 * log(Float64(sqrt(Float64(-x)) / sqrt(Float64(-y)))))) - z); else tmp = Float64(Float64(x * Float64(2.0 * log(Float64(sqrt(x) / sqrt(y))))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5e-311) tmp = (x * (2.0 * log((sqrt(-x) / sqrt(-y))))) - z; else tmp = (x * (2.0 * log((sqrt(x) / sqrt(y))))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e-311], N[(N[(x * N[(2.0 * N[Log[N[(N[Sqrt[(-x)], $MachinePrecision] / N[Sqrt[(-y)], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(2.0 * N[Log[N[(N[Sqrt[x], $MachinePrecision] / N[Sqrt[y], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-311}:\\
\;\;\;\;x \cdot \left(2 \cdot \log \left(\frac{\sqrt{-x}}{\sqrt{-y}}\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(2 \cdot \log \left(\frac{\sqrt{x}}{\sqrt{y}}\right)\right) - z\\
\end{array}
\end{array}
if y < -5.00000000000023e-311Initial program 84.8%
add-sqr-sqrt84.8%
log-prod84.8%
Applied egg-rr84.8%
count-284.8%
Simplified84.8%
frac-2neg84.8%
sqrt-div99.8%
Applied egg-rr99.8%
if -5.00000000000023e-311 < y Initial program 85.1%
add-sqr-sqrt85.1%
log-prod85.1%
Applied egg-rr85.1%
count-285.1%
Simplified85.1%
sqrt-div99.8%
div-inv99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 INFINITY))) (- z) (- t_0 z))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= ((double) INFINITY))) {
tmp = -z;
} else {
tmp = t_0 - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * Math.log((x / y));
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= Double.POSITIVE_INFINITY)) {
tmp = -z;
} else {
tmp = t_0 - z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= math.inf): tmp = -z else: tmp = t_0 - z return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= Inf)) tmp = Float64(-z); else tmp = Float64(t_0 - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= Inf))) tmp = -z; else tmp = t_0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, Infinity]], $MachinePrecision]], (-z), N[(t$95$0 - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq \infty\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or +inf.0 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 8.5%
remove-double-neg8.5%
sub-neg8.5%
distribute-neg-in8.5%
sub-neg8.5%
distribute-rgt-neg-in8.5%
fma-neg8.5%
log-div39.1%
sub-neg39.1%
distribute-neg-in39.1%
remove-double-neg39.1%
+-commutative39.1%
sub-neg39.1%
log-div12.6%
remove-double-neg12.6%
Simplified12.6%
Taylor expanded in x around 0 44.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < +inf.0Initial program 92.5%
Final simplification88.2%
(FPCore (x y z) :precision binary64 (if (<= y -5e-311) (- (* x (- (log (- x)) (log (- y)))) z) (- (* x (* 2.0 (log (/ (sqrt x) (sqrt y))))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-311) {
tmp = (x * (log(-x) - log(-y))) - z;
} else {
tmp = (x * (2.0 * log((sqrt(x) / sqrt(y))))) - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-5d-311)) then
tmp = (x * (log(-x) - log(-y))) - z
else
tmp = (x * (2.0d0 * log((sqrt(x) / sqrt(y))))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5e-311) {
tmp = (x * (Math.log(-x) - Math.log(-y))) - z;
} else {
tmp = (x * (2.0 * Math.log((Math.sqrt(x) / Math.sqrt(y))))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5e-311: tmp = (x * (math.log(-x) - math.log(-y))) - z else: tmp = (x * (2.0 * math.log((math.sqrt(x) / math.sqrt(y))))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5e-311) tmp = Float64(Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))) - z); else tmp = Float64(Float64(x * Float64(2.0 * log(Float64(sqrt(x) / sqrt(y))))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5e-311) tmp = (x * (log(-x) - log(-y))) - z; else tmp = (x * (2.0 * log((sqrt(x) / sqrt(y))))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e-311], N[(N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(2.0 * N[Log[N[(N[Sqrt[x], $MachinePrecision] / N[Sqrt[y], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-311}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(2 \cdot \log \left(\frac{\sqrt{x}}{\sqrt{y}}\right)\right) - z\\
\end{array}
\end{array}
if y < -5.00000000000023e-311Initial program 84.8%
frac-2neg84.8%
log-div99.3%
Applied egg-rr99.3%
if -5.00000000000023e-311 < y Initial program 85.1%
add-sqr-sqrt85.1%
log-prod85.1%
Applied egg-rr85.1%
count-285.1%
Simplified85.1%
sqrt-div99.8%
div-inv99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= y 1.9e-301) (- (* x (* 2.0 (log (sqrt (/ x y))))) z) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.9e-301) {
tmp = (x * (2.0 * log(sqrt((x / y))))) - z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.9d-301) then
tmp = (x * (2.0d0 * log(sqrt((x / y))))) - z
else
tmp = (x * (log(x) - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.9e-301) {
tmp = (x * (2.0 * Math.log(Math.sqrt((x / y))))) - z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.9e-301: tmp = (x * (2.0 * math.log(math.sqrt((x / y))))) - z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.9e-301) tmp = Float64(Float64(x * Float64(2.0 * log(sqrt(Float64(x / y))))) - z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.9e-301) tmp = (x * (2.0 * log(sqrt((x / y))))) - z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.9e-301], N[(N[(x * N[(2.0 * N[Log[N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.9 \cdot 10^{-301}:\\
\;\;\;\;x \cdot \left(2 \cdot \log \left(\sqrt{\frac{x}{y}}\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if y < 1.89999999999999998e-301Initial program 84.9%
add-sqr-sqrt84.9%
log-prod84.9%
Applied egg-rr84.9%
count-284.9%
Simplified84.9%
if 1.89999999999999998e-301 < y Initial program 85.0%
log-div99.5%
Applied egg-rr99.5%
Final simplification92.0%
(FPCore (x y z) :precision binary64 (if (<= y -5e-311) (- (* x (- (log (- x)) (log (- y)))) z) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-311) {
tmp = (x * (log(-x) - log(-y))) - z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-5d-311)) then
tmp = (x * (log(-x) - log(-y))) - z
else
tmp = (x * (log(x) - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5e-311) {
tmp = (x * (Math.log(-x) - Math.log(-y))) - z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5e-311: tmp = (x * (math.log(-x) - math.log(-y))) - z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5e-311) tmp = Float64(Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))) - z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5e-311) tmp = (x * (log(-x) - log(-y))) - z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e-311], N[(N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-311}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if y < -5.00000000000023e-311Initial program 84.8%
frac-2neg84.8%
log-div99.3%
Applied egg-rr99.3%
if -5.00000000000023e-311 < y Initial program 85.1%
log-div99.5%
Applied egg-rr99.5%
Final simplification99.4%
(FPCore (x y z) :precision binary64 (if (<= y 1.9e-301) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.9e-301) {
tmp = (x * log((x / y))) - z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.9d-301) then
tmp = (x * log((x / y))) - z
else
tmp = (x * (log(x) - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.9e-301) {
tmp = (x * Math.log((x / y))) - z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.9e-301: tmp = (x * math.log((x / y))) - z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.9e-301) tmp = Float64(Float64(x * log(Float64(x / y))) - z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.9e-301) tmp = (x * log((x / y))) - z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.9e-301], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.9 \cdot 10^{-301}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if y < 1.89999999999999998e-301Initial program 84.9%
if 1.89999999999999998e-301 < y Initial program 85.0%
log-div99.5%
Applied egg-rr99.5%
Final simplification92.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.8e+91) (not (<= x 8e-24))) (* (- x) (log (/ y x))) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.8e+91) || !(x <= 8e-24)) {
tmp = -x * log((y / x));
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-5.8d+91)) .or. (.not. (x <= 8d-24))) then
tmp = -x * log((y / x))
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5.8e+91) || !(x <= 8e-24)) {
tmp = -x * Math.log((y / x));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.8e+91) or not (x <= 8e-24): tmp = -x * math.log((y / x)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.8e+91) || !(x <= 8e-24)) tmp = Float64(Float64(-x) * log(Float64(y / x))); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5.8e+91) || ~((x <= 8e-24))) tmp = -x * log((y / x)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.8e+91], N[Not[LessEqual[x, 8e-24]], $MachinePrecision]], N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.8 \cdot 10^{+91} \lor \neg \left(x \leq 8 \cdot 10^{-24}\right):\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -5.80000000000000028e91 or 7.99999999999999939e-24 < x Initial program 83.8%
remove-double-neg83.8%
sub-neg83.8%
distribute-neg-in83.8%
sub-neg83.8%
distribute-rgt-neg-in83.8%
fma-neg83.8%
log-div59.9%
sub-neg59.9%
distribute-neg-in59.9%
remove-double-neg59.9%
+-commutative59.9%
sub-neg59.9%
log-div84.9%
remove-double-neg84.9%
Simplified84.9%
Taylor expanded in x around inf 44.6%
log-rec44.6%
sub-neg44.6%
log-div67.2%
Simplified67.2%
if -5.80000000000000028e91 < x < 7.99999999999999939e-24Initial program 86.1%
remove-double-neg86.1%
sub-neg86.1%
distribute-neg-in86.1%
sub-neg86.1%
distribute-rgt-neg-in86.1%
fma-neg86.1%
log-div36.7%
sub-neg36.7%
distribute-neg-in36.7%
remove-double-neg36.7%
+-commutative36.7%
sub-neg36.7%
log-div81.9%
remove-double-neg81.9%
Simplified81.9%
Taylor expanded in x around 0 75.9%
Final simplification71.4%
(FPCore (x y z) :precision binary64 (- z))
double code(double x, double y, double z) {
return -z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -z
end function
public static double code(double x, double y, double z) {
return -z;
}
def code(x, y, z): return -z
function code(x, y, z) return Float64(-z) end
function tmp = code(x, y, z) tmp = -z; end
code[x_, y_, z_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 85.0%
remove-double-neg85.0%
sub-neg85.0%
distribute-neg-in85.0%
sub-neg85.0%
distribute-rgt-neg-in85.0%
fma-neg85.0%
log-div48.6%
sub-neg48.6%
distribute-neg-in48.6%
remove-double-neg48.6%
+-commutative48.6%
sub-neg48.6%
log-div83.5%
remove-double-neg83.5%
Simplified83.5%
Taylor expanded in x around 0 47.4%
Final simplification47.4%
(FPCore (x y z) :precision binary64 (if (< y 7.595077799083773e-308) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y < 7.595077799083773e-308) {
tmp = (x * log((x / y))) - z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y < 7.595077799083773d-308) then
tmp = (x * log((x / y))) - z
else
tmp = (x * (log(x) - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y < 7.595077799083773e-308) {
tmp = (x * Math.log((x / y))) - z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y < 7.595077799083773e-308: tmp = (x * math.log((x / y))) - z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y < 7.595077799083773e-308) tmp = Float64(Float64(x * log(Float64(x / y))) - z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y < 7.595077799083773e-308) tmp = (x * log((x / y))) - z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Less[y, 7.595077799083773e-308], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y < 7.595077799083773 \cdot 10^{-308}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
herbie shell --seed 2024047
(FPCore (x y z)
:name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
:precision binary64
:alt
(if (< y 7.595077799083773e-308) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z))
(- (* x (log (/ x y))) z))