
(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 (- (* x (* (log (/ (cbrt x) (cbrt y))) 3.0)) z))
double code(double x, double y, double z) {
return (x * (log((cbrt(x) / cbrt(y))) * 3.0)) - z;
}
public static double code(double x, double y, double z) {
return (x * (Math.log((Math.cbrt(x) / Math.cbrt(y))) * 3.0)) - z;
}
function code(x, y, z) return Float64(Float64(x * Float64(log(Float64(cbrt(x) / cbrt(y))) * 3.0)) - z) end
code[x_, y_, z_] := N[(N[(x * N[(N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right) \cdot 3\right) - z
\end{array}
Initial program 74.9%
add-cube-cbrt74.8%
log-prod74.8%
pow274.8%
metadata-eval74.8%
log-pow74.8%
metadata-eval74.8%
Applied egg-rr74.8%
distribute-lft1-in74.8%
metadata-eval74.8%
*-commutative74.8%
Simplified74.8%
cbrt-div99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))) (t_1 (* x (log (* x y)))))
(if (<= t_0 (- INFINITY))
(- t_1 z)
(if (<= t_0 INFINITY) (- t_0 z) (- (fabs t_1) z)))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double t_1 = x * log((x * y));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_1 - z;
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_0 - z;
} else {
tmp = fabs(t_1) - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * Math.log((x / y));
double t_1 = x * Math.log((x * y));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = t_1 - z;
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 - z;
} else {
tmp = Math.abs(t_1) - z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) t_1 = x * math.log((x * y)) tmp = 0 if t_0 <= -math.inf: tmp = t_1 - z elif t_0 <= math.inf: tmp = t_0 - z else: tmp = math.fabs(t_1) - z return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) t_1 = Float64(x * log(Float64(x * y))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(t_1 - z); elseif (t_0 <= Inf) tmp = Float64(t_0 - z); else tmp = Float64(abs(t_1) - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); t_1 = x * log((x * y)); tmp = 0.0; if (t_0 <= -Inf) tmp = t_1 - z; elseif (t_0 <= Inf) tmp = t_0 - z; else tmp = abs(t_1) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[Log[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(t$95$1 - z), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(t$95$0 - z), $MachinePrecision], N[(N[Abs[t$95$1], $MachinePrecision] - z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
t_1 := x \cdot \log \left(x \cdot y\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;t\_1 - z\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;\left|t\_1\right| - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 4.5%
add-cube-cbrt4.5%
log-prod4.5%
pow24.5%
metadata-eval4.5%
log-pow4.5%
metadata-eval4.5%
Applied egg-rr4.5%
distribute-lft1-in4.5%
metadata-eval4.5%
*-commutative4.5%
Simplified4.5%
add-log-exp4.5%
exp-to-pow4.5%
pow34.5%
add-cube-cbrt4.5%
log-div51.7%
add-cube-cbrt51.7%
unpow251.7%
fma-neg51.7%
add-log-exp47.0%
add047.0%
Applied egg-rr49.7%
log-pow55.5%
add055.5%
Simplified55.5%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < +inf.0Initial program 83.8%
if +inf.0 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 74.9%
add-cube-cbrt74.8%
log-prod74.8%
pow274.8%
metadata-eval74.8%
log-pow74.8%
metadata-eval74.8%
Applied egg-rr74.8%
distribute-lft1-in74.8%
metadata-eval74.8%
*-commutative74.8%
Simplified74.8%
add-log-exp74.8%
exp-to-pow74.8%
pow374.8%
add-cube-cbrt74.9%
log-div48.2%
add-cube-cbrt47.9%
unpow247.9%
fma-neg47.9%
add-sqr-sqrt25.8%
sqrt-unprod26.7%
pow226.7%
Applied egg-rr28.5%
unpow228.5%
rem-sqrt-square28.5%
log-pow40.7%
Simplified40.7%
Final simplification80.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))) (t_1 (log (* x y))))
(if (<= t_0 (- INFINITY))
(- (* x (fabs t_1)) z)
(if (<= t_0 INFINITY) (- t_0 z) (- (fabs (* x t_1)) z)))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double t_1 = log((x * y));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (x * fabs(t_1)) - z;
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_0 - z;
} else {
tmp = fabs((x * t_1)) - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * Math.log((x / y));
double t_1 = Math.log((x * y));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (x * Math.abs(t_1)) - z;
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 - z;
} else {
tmp = Math.abs((x * t_1)) - z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) t_1 = math.log((x * y)) tmp = 0 if t_0 <= -math.inf: tmp = (x * math.fabs(t_1)) - z elif t_0 <= math.inf: tmp = t_0 - z else: tmp = math.fabs((x * t_1)) - z return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) t_1 = log(Float64(x * y)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(x * abs(t_1)) - z); elseif (t_0 <= Inf) tmp = Float64(t_0 - z); else tmp = Float64(abs(Float64(x * t_1)) - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); t_1 = log((x * y)); tmp = 0.0; if (t_0 <= -Inf) tmp = (x * abs(t_1)) - z; elseif (t_0 <= Inf) tmp = t_0 - z; else tmp = abs((x * t_1)) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Log[N[(x * y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(x * N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(t$95$0 - z), $MachinePrecision], N[(N[Abs[N[(x * t$95$1), $MachinePrecision]], $MachinePrecision] - z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
t_1 := \log \left(x \cdot y\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;x \cdot \left|t\_1\right| - z\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot t\_1\right| - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 4.5%
add-cube-cbrt4.5%
log-prod4.5%
pow24.5%
metadata-eval4.5%
log-pow4.5%
metadata-eval4.5%
Applied egg-rr4.5%
distribute-lft1-in4.5%
metadata-eval4.5%
*-commutative4.5%
Simplified4.5%
add-log-exp4.5%
exp-to-pow4.5%
pow34.5%
add-cube-cbrt4.5%
add-sqr-sqrt3.2%
pow1/23.2%
pow1/24.4%
pow-prod-down4.4%
Applied egg-rr57.6%
unpow1/257.6%
unpow257.6%
rem-sqrt-square57.6%
Simplified57.6%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < +inf.0Initial program 83.8%
if +inf.0 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 74.9%
add-cube-cbrt74.8%
log-prod74.8%
pow274.8%
metadata-eval74.8%
log-pow74.8%
metadata-eval74.8%
Applied egg-rr74.8%
distribute-lft1-in74.8%
metadata-eval74.8%
*-commutative74.8%
Simplified74.8%
add-log-exp74.8%
exp-to-pow74.8%
pow374.8%
add-cube-cbrt74.9%
log-div48.2%
add-cube-cbrt47.9%
unpow247.9%
fma-neg47.9%
add-sqr-sqrt25.8%
sqrt-unprod26.7%
pow226.7%
Applied egg-rr28.5%
unpow228.5%
rem-sqrt-square28.5%
log-pow40.7%
Simplified40.7%
Final simplification80.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 INFINITY)))
(- (* x (log (* x y))) 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 = (x * log((x * y))) - 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 = (x * Math.log((x * y))) - 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 = (x * math.log((x * y))) - 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(Float64(x * log(Float64(x * y))) - 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 = (x * log((x * y))) - 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]], N[(N[(x * N[Log[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], 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):\\
\;\;\;\;x \cdot \log \left(x \cdot y\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 4.5%
add-cube-cbrt4.5%
log-prod4.5%
pow24.5%
metadata-eval4.5%
log-pow4.5%
metadata-eval4.5%
Applied egg-rr4.5%
distribute-lft1-in4.5%
metadata-eval4.5%
*-commutative4.5%
Simplified4.5%
add-log-exp4.5%
exp-to-pow4.5%
pow34.5%
add-cube-cbrt4.5%
log-div51.7%
add-cube-cbrt51.7%
unpow251.7%
fma-neg51.7%
add-log-exp47.0%
add047.0%
Applied egg-rr49.7%
log-pow55.5%
add055.5%
Simplified55.5%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < +inf.0Initial program 83.8%
Final simplification80.6%
(FPCore (x y z) :precision binary64 (if (<= x -8.4e-195) (- (- z) (* x (log (/ y x)))) (if (<= x -5e-309) (- z) (- (* x (- (log x) (log y))) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -8.4e-195) {
tmp = -z - (x * log((y / x)));
} else if (x <= -5e-309) {
tmp = -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 (x <= (-8.4d-195)) then
tmp = -z - (x * log((y / x)))
else if (x <= (-5d-309)) then
tmp = -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 (x <= -8.4e-195) {
tmp = -z - (x * Math.log((y / x)));
} else if (x <= -5e-309) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -8.4e-195: tmp = -z - (x * math.log((y / x))) elif x <= -5e-309: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -8.4e-195) tmp = Float64(Float64(-z) - Float64(x * log(Float64(y / x)))); elseif (x <= -5e-309) tmp = Float64(-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 (x <= -8.4e-195) tmp = -z - (x * log((y / x))); elseif (x <= -5e-309) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -8.4e-195], N[((-z) - N[(x * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5e-309], (-z), N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.4 \cdot 10^{-195}:\\
\;\;\;\;\left(-z\right) - x \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -8.4e-195Initial program 83.1%
clear-num83.1%
neg-log84.4%
Applied egg-rr84.4%
if -8.4e-195 < x < -4.9999999999999995e-309Initial program 41.3%
add-cube-cbrt41.3%
log-prod41.3%
pow241.3%
metadata-eval41.3%
log-pow41.3%
metadata-eval41.3%
Applied egg-rr41.3%
distribute-lft1-in41.3%
metadata-eval41.3%
*-commutative41.3%
Simplified41.3%
add-log-exp41.3%
exp-to-pow41.3%
pow341.3%
add-cube-cbrt41.3%
log-div0.0%
add-cube-cbrt0.0%
unpow20.0%
fma-neg0.0%
add-log-exp0.0%
add00.0%
Applied egg-rr76.2%
log-pow76.6%
add076.6%
Simplified76.6%
Taylor expanded in x around 0 90.6%
neg-mul-190.6%
Simplified90.6%
if -4.9999999999999995e-309 < x Initial program 72.8%
log-div99.4%
Applied egg-rr99.4%
Final simplification92.2%
(FPCore (x y z) :precision binary64 (if (<= x -5e-310) (- (* x (- (log (- x)) (log (- y)))) z) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (x <= -5e-310) {
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 (x <= (-5d-310)) 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 (x <= -5e-310) {
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 x <= -5e-310: 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 (x <= -5e-310) 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 (x <= -5e-310) 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[x, -5e-310], 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}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;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 x < -4.999999999999985e-310Initial program 76.7%
frac-2neg76.7%
log-div99.4%
Applied egg-rr99.4%
if -4.999999999999985e-310 < x Initial program 72.8%
log-div99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x y z) :precision binary64 (if (<= x -4.8e-29) (- (* x (log (* x y))) z) (- z)))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.8e-29) {
tmp = (x * log((x * y))) - z;
} 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 <= (-4.8d-29)) then
tmp = (x * log((x * y))) - z
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -4.8e-29) {
tmp = (x * Math.log((x * y))) - z;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -4.8e-29: tmp = (x * math.log((x * y))) - z else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -4.8e-29) tmp = Float64(Float64(x * log(Float64(x * y))) - z); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -4.8e-29) tmp = (x * log((x * y))) - z; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -4.8e-29], N[(N[(x * N[Log[N[(x * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{-29}:\\
\;\;\;\;x \cdot \log \left(x \cdot y\right) - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -4.79999999999999984e-29Initial program 82.8%
add-cube-cbrt82.7%
log-prod82.7%
pow282.7%
metadata-eval82.7%
log-pow82.7%
metadata-eval82.7%
Applied egg-rr82.7%
distribute-lft1-in82.7%
metadata-eval82.7%
*-commutative82.7%
Simplified82.7%
add-log-exp82.7%
exp-to-pow82.7%
pow382.7%
add-cube-cbrt82.8%
log-div0.0%
add-cube-cbrt0.0%
unpow20.0%
fma-neg0.0%
add-log-exp0.0%
add00.0%
Applied egg-rr5.5%
log-pow30.5%
add030.5%
Simplified30.5%
if -4.79999999999999984e-29 < x Initial program 71.4%
add-cube-cbrt71.4%
log-prod71.4%
pow271.4%
metadata-eval71.4%
log-pow71.4%
metadata-eval71.4%
Applied egg-rr71.4%
distribute-lft1-in71.4%
metadata-eval71.4%
*-commutative71.4%
Simplified71.4%
add-log-exp71.4%
exp-to-pow71.4%
pow371.4%
add-cube-cbrt71.4%
log-div68.9%
add-cube-cbrt68.5%
unpow268.5%
fma-neg68.5%
add-log-exp26.8%
add026.8%
Applied egg-rr38.5%
log-pow45.5%
add045.5%
Simplified45.5%
Taylor expanded in x around 0 53.6%
neg-mul-153.6%
Simplified53.6%
Final simplification46.6%
(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 74.9%
add-cube-cbrt74.8%
log-prod74.8%
pow274.8%
metadata-eval74.8%
log-pow74.8%
metadata-eval74.8%
Applied egg-rr74.8%
distribute-lft1-in74.8%
metadata-eval74.8%
*-commutative74.8%
Simplified74.8%
add-log-exp74.8%
exp-to-pow74.8%
pow374.8%
add-cube-cbrt74.9%
log-div48.2%
add-cube-cbrt47.9%
unpow247.9%
fma-neg47.9%
add-log-exp18.7%
add018.7%
Applied egg-rr28.6%
log-pow41.0%
add041.0%
Simplified41.0%
Taylor expanded in x around 0 44.9%
neg-mul-144.9%
Simplified44.9%
Final simplification44.9%
(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 2024034
(FPCore (x y z)
:name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< y 7.595077799083773e-308) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z))
(- (* x (log (/ x y))) z))