
(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 9 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-310) (- (* 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-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 (y <= (-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 (y <= -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 y <= -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 (y <= -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 (y <= -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[y, -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}\;y \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 y < -4.999999999999985e-310Initial program 83.2%
Taylor expanded in y around -inf 99.3%
metadata-eval99.3%
distribute-neg-frac99.3%
distribute-frac-neg299.3%
neg-mul-199.3%
log-rec99.3%
sub-neg99.3%
Simplified99.3%
if -4.999999999999985e-310 < y Initial program 77.0%
Taylor expanded in x around 0 99.5%
log-rec99.5%
sub-neg99.5%
Simplified99.5%
Final simplification99.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (log (/ x y))) (t_1 (* x t_0)))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e+293)))
(* z (+ (* (/ x z) (log (* y x))) -1.0))
(fma x t_0 (- z)))))
double code(double x, double y, double z) {
double t_0 = log((x / y));
double t_1 = x * t_0;
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 5e+293)) {
tmp = z * (((x / z) * log((y * x))) + -1.0);
} else {
tmp = fma(x, t_0, -z);
}
return tmp;
}
function code(x, y, z) t_0 = log(Float64(x / y)) t_1 = Float64(x * t_0) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 5e+293)) tmp = Float64(z * Float64(Float64(Float64(x / z) * log(Float64(y * x))) + -1.0)); else tmp = fma(x, t_0, Float64(-z)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x * t$95$0), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e+293]], $MachinePrecision]], N[(z * N[(N[(N[(x / z), $MachinePrecision] * N[Log[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(x * t$95$0 + (-z)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\frac{x}{y}\right)\\
t_1 := x \cdot t\_0\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 5 \cdot 10^{+293}\right):\\
\;\;\;\;z \cdot \left(\frac{x}{z} \cdot \log \left(y \cdot x\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, t\_0, -z\right)\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5.00000000000000033e293 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 5.9%
Taylor expanded in z around inf 5.9%
sub-neg5.9%
associate-/l*5.9%
metadata-eval5.9%
Simplified5.9%
clear-num5.9%
un-div-inv5.9%
log-div48.7%
sub-neg48.7%
add-log-exp48.7%
sum-log4.2%
add-sqr-sqrt2.0%
sqrt-unprod23.4%
sqr-neg23.4%
sqrt-unprod21.5%
add-sqr-sqrt32.2%
add-exp-log53.7%
Applied egg-rr53.7%
associate-/r/53.7%
Simplified53.7%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5.00000000000000033e293Initial program 99.8%
fma-neg99.8%
Simplified99.8%
Final simplification90.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e+293)))
(* z (+ (* (/ x z) (log (* y x))) -1.0))
(- 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 <= 5e+293)) {
tmp = z * (((x / z) * log((y * x))) + -1.0);
} 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 <= 5e+293)) {
tmp = z * (((x / z) * Math.log((y * x))) + -1.0);
} 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 <= 5e+293): tmp = z * (((x / z) * math.log((y * x))) + -1.0) 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 <= 5e+293)) tmp = Float64(z * Float64(Float64(Float64(x / z) * log(Float64(y * x))) + -1.0)); 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 <= 5e+293))) tmp = z * (((x / z) * log((y * x))) + -1.0); 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, 5e+293]], $MachinePrecision]], N[(z * N[(N[(N[(x / z), $MachinePrecision] * N[Log[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $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 5 \cdot 10^{+293}\right):\\
\;\;\;\;z \cdot \left(\frac{x}{z} \cdot \log \left(y \cdot x\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5.00000000000000033e293 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 5.9%
Taylor expanded in z around inf 5.9%
sub-neg5.9%
associate-/l*5.9%
metadata-eval5.9%
Simplified5.9%
clear-num5.9%
un-div-inv5.9%
log-div48.7%
sub-neg48.7%
add-log-exp48.7%
sum-log4.2%
add-sqr-sqrt2.0%
sqrt-unprod23.4%
sqr-neg23.4%
sqrt-unprod21.5%
add-sqr-sqrt32.2%
add-exp-log53.7%
Applied egg-rr53.7%
associate-/r/53.7%
Simplified53.7%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5.00000000000000033e293Initial program 99.8%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e+293))) (- 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 <= 5e+293)) {
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 <= 5e+293)) {
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 <= 5e+293): 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 <= 5e+293)) 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 <= 5e+293))) 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, 5e+293]], $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 5 \cdot 10^{+293}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5.00000000000000033e293 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 5.9%
Taylor expanded in x around 0 50.9%
mul-1-neg50.9%
Simplified50.9%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5.00000000000000033e293Initial program 99.8%
Final simplification89.5%
(FPCore (x y z) :precision binary64 (if (<= x -6.5e-178) (- (- z) (* x (log (/ y x)))) (if (<= x -1e-308) (- z) (- (* x (- (log x) (log y))) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -6.5e-178) {
tmp = -z - (x * log((y / x)));
} else if (x <= -1e-308) {
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 <= (-6.5d-178)) then
tmp = -z - (x * log((y / x)))
else if (x <= (-1d-308)) 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 <= -6.5e-178) {
tmp = -z - (x * Math.log((y / x)));
} else if (x <= -1e-308) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -6.5e-178: tmp = -z - (x * math.log((y / x))) elif x <= -1e-308: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -6.5e-178) tmp = Float64(Float64(-z) - Float64(x * log(Float64(y / x)))); elseif (x <= -1e-308) 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 <= -6.5e-178) tmp = -z - (x * log((y / x))); elseif (x <= -1e-308) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -6.5e-178], N[((-z) - N[(x * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1e-308], (-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 -6.5 \cdot 10^{-178}:\\
\;\;\;\;\left(-z\right) - x \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-308}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -6.5000000000000002e-178Initial program 87.7%
clear-num87.7%
log-div88.8%
metadata-eval88.8%
Applied egg-rr88.8%
neg-sub088.8%
Simplified88.8%
if -6.5000000000000002e-178 < x < -9.9999999999999991e-309Initial program 69.8%
Taylor expanded in x around 0 82.5%
mul-1-neg82.5%
Simplified82.5%
if -9.9999999999999991e-309 < x Initial program 77.0%
Taylor expanded in x around 0 99.5%
log-rec99.5%
sub-neg99.5%
Simplified99.5%
Final simplification93.5%
(FPCore (x y z)
:precision binary64
(if (<= z -0.015)
(- z)
(if (<= z -1.05e-139)
(* x (log (/ x y)))
(if (or (<= z -1.3e-188) (not (<= z 8.5e-59)))
(- z)
(* x (- (log (/ y x))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.015) {
tmp = -z;
} else if (z <= -1.05e-139) {
tmp = x * log((x / y));
} else if ((z <= -1.3e-188) || !(z <= 8.5e-59)) {
tmp = -z;
} else {
tmp = x * -log((y / x));
}
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 (z <= (-0.015d0)) then
tmp = -z
else if (z <= (-1.05d-139)) then
tmp = x * log((x / y))
else if ((z <= (-1.3d-188)) .or. (.not. (z <= 8.5d-59))) then
tmp = -z
else
tmp = x * -log((y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -0.015) {
tmp = -z;
} else if (z <= -1.05e-139) {
tmp = x * Math.log((x / y));
} else if ((z <= -1.3e-188) || !(z <= 8.5e-59)) {
tmp = -z;
} else {
tmp = x * -Math.log((y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.015: tmp = -z elif z <= -1.05e-139: tmp = x * math.log((x / y)) elif (z <= -1.3e-188) or not (z <= 8.5e-59): tmp = -z else: tmp = x * -math.log((y / x)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.015) tmp = Float64(-z); elseif (z <= -1.05e-139) tmp = Float64(x * log(Float64(x / y))); elseif ((z <= -1.3e-188) || !(z <= 8.5e-59)) tmp = Float64(-z); else tmp = Float64(x * Float64(-log(Float64(y / x)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.015) tmp = -z; elseif (z <= -1.05e-139) tmp = x * log((x / y)); elseif ((z <= -1.3e-188) || ~((z <= 8.5e-59))) tmp = -z; else tmp = x * -log((y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.015], (-z), If[LessEqual[z, -1.05e-139], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -1.3e-188], N[Not[LessEqual[z, 8.5e-59]], $MachinePrecision]], (-z), N[(x * (-N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.015:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq -1.05 \cdot 10^{-139}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{elif}\;z \leq -1.3 \cdot 10^{-188} \lor \neg \left(z \leq 8.5 \cdot 10^{-59}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-\log \left(\frac{y}{x}\right)\right)\\
\end{array}
\end{array}
if z < -0.014999999999999999 or -1.05000000000000004e-139 < z < -1.3e-188 or 8.49999999999999933e-59 < z Initial program 79.8%
Taylor expanded in x around 0 77.2%
mul-1-neg77.2%
Simplified77.2%
if -0.014999999999999999 < z < -1.05000000000000004e-139Initial program 77.3%
Taylor expanded in z around 0 62.8%
if -1.3e-188 < z < 8.49999999999999933e-59Initial program 81.4%
flip--53.5%
clear-num53.4%
fma-define53.4%
difference-of-squares53.4%
add-sqr-sqrt37.9%
sqrt-unprod53.4%
sqr-neg53.4%
sqrt-unprod15.5%
add-sqr-sqrt50.9%
sub-neg50.9%
pow250.9%
fma-neg50.9%
add-sqr-sqrt15.5%
sqrt-unprod50.9%
sqr-neg50.9%
sqrt-unprod35.5%
add-sqr-sqrt50.9%
Applied egg-rr50.9%
Taylor expanded in z around 0 72.8%
associate-/r*72.6%
Simplified72.6%
frac-2neg72.6%
metadata-eval72.6%
div-inv72.6%
distribute-neg-frac272.6%
neg-log72.6%
clear-num73.6%
Applied egg-rr73.6%
mul-1-neg73.6%
associate-/l/73.8%
remove-double-div73.9%
distribute-rgt-neg-out73.9%
Simplified73.9%
Final simplification74.7%
(FPCore (x y z)
:precision binary64
(if (or (<= z -0.045)
(and (not (<= z -8.5e-140))
(or (<= z -1.3e-188) (not (<= z 3.9e-59)))))
(- z)
(* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.045) || (!(z <= -8.5e-140) && ((z <= -1.3e-188) || !(z <= 3.9e-59)))) {
tmp = -z;
} else {
tmp = x * log((x / y));
}
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 ((z <= (-0.045d0)) .or. (.not. (z <= (-8.5d-140))) .and. (z <= (-1.3d-188)) .or. (.not. (z <= 3.9d-59))) then
tmp = -z
else
tmp = x * log((x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.045) || (!(z <= -8.5e-140) && ((z <= -1.3e-188) || !(z <= 3.9e-59)))) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.045) or (not (z <= -8.5e-140) and ((z <= -1.3e-188) or not (z <= 3.9e-59))): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.045) || (!(z <= -8.5e-140) && ((z <= -1.3e-188) || !(z <= 3.9e-59)))) tmp = Float64(-z); else tmp = Float64(x * log(Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.045) || (~((z <= -8.5e-140)) && ((z <= -1.3e-188) || ~((z <= 3.9e-59))))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.045], And[N[Not[LessEqual[z, -8.5e-140]], $MachinePrecision], Or[LessEqual[z, -1.3e-188], N[Not[LessEqual[z, 3.9e-59]], $MachinePrecision]]]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.045 \lor \neg \left(z \leq -8.5 \cdot 10^{-140}\right) \land \left(z \leq -1.3 \cdot 10^{-188} \lor \neg \left(z \leq 3.9 \cdot 10^{-59}\right)\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -0.044999999999999998 or -8.49999999999999997e-140 < z < -1.3e-188 or 3.90000000000000019e-59 < z Initial program 79.8%
Taylor expanded in x around 0 77.2%
mul-1-neg77.2%
Simplified77.2%
if -0.044999999999999998 < z < -8.49999999999999997e-140 or -1.3e-188 < z < 3.90000000000000019e-59Initial program 80.3%
Taylor expanded in z around 0 70.3%
Final simplification74.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 80.0%
Taylor expanded in x around 0 54.1%
mul-1-neg54.1%
Simplified54.1%
Final simplification54.1%
(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 z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 80.0%
flip--41.7%
clear-num41.6%
fma-define41.6%
difference-of-squares42.2%
add-sqr-sqrt22.6%
sqrt-unprod31.5%
sqr-neg31.5%
sqrt-unprod8.8%
add-sqr-sqrt21.2%
sub-neg21.2%
pow221.2%
fma-neg21.2%
add-sqr-sqrt8.8%
sqrt-unprod21.2%
sqr-neg21.2%
sqrt-unprod12.3%
add-sqr-sqrt21.2%
Applied egg-rr21.2%
Taylor expanded in x around 0 2.2%
Final simplification2.2%
(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 2024067
(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))