
(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 (+ (* 0.0 z) (- (* 3.0 (* x (log (/ (cbrt x) (cbrt y))))) z)))
double code(double x, double y, double z) {
return (0.0 * z) + ((3.0 * (x * log((cbrt(x) / cbrt(y))))) - z);
}
public static double code(double x, double y, double z) {
return (0.0 * z) + ((3.0 * (x * Math.log((Math.cbrt(x) / Math.cbrt(y))))) - z);
}
function code(x, y, z) return Float64(Float64(0.0 * z) + Float64(Float64(3.0 * Float64(x * log(Float64(cbrt(x) / cbrt(y))))) - z)) end
code[x_, y_, z_] := N[(N[(0.0 * z), $MachinePrecision] + N[(N[(3.0 * N[(x * N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0 \cdot z + \left(3 \cdot \left(x \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)\right) - z\right)
\end{array}
Initial program 78.7%
add-sqr-sqrt37.0%
pow237.0%
Applied egg-rr37.0%
unpow237.0%
add-sqr-sqrt78.7%
*-commutative78.7%
*-un-lft-identity78.7%
*-un-lft-identity78.7%
metadata-eval78.7%
associate-*r*78.5%
log-pow78.5%
unpow1/378.6%
cbrt-undiv99.6%
associate-*l*99.7%
prod-diff99.7%
cbrt-undiv78.6%
*-commutative78.6%
*-un-lft-identity78.6%
*-commutative78.6%
Applied egg-rr78.6%
fma-udef78.6%
associate-+l+78.6%
*-commutative78.6%
associate-*r*78.6%
*-commutative78.6%
associate-+l+78.6%
fma-udef78.6%
+-commutative78.6%
fma-udef78.6%
*-rgt-identity78.6%
neg-mul-178.6%
distribute-lft1-in78.6%
metadata-eval78.6%
fma-neg78.6%
*-commutative78.6%
associate-*r*78.6%
Simplified78.6%
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))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e+305))) (- 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+305)) {
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+305)) {
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+305): 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+305)) 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+305))) 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+305]], $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^{+305}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5.00000000000000009e305 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 5.1%
remove-double-neg5.1%
sub-neg5.1%
distribute-neg-in5.1%
distribute-rgt-neg-in5.1%
remove-double-neg5.1%
fma-udef5.1%
log-div43.8%
sub-neg43.8%
distribute-neg-in43.8%
remove-double-neg43.8%
+-commutative43.8%
sub-neg43.8%
log-div6.9%
Simplified6.9%
Taylor expanded in x around 0 56.7%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5.00000000000000009e305Initial program 99.8%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (if (<= y -4e-310) (- (* x (- (log (- x)) (log (- y)))) z) (- (fma x (- (log y) (log x)) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4e-310) {
tmp = (x * (log(-x) - log(-y))) - z;
} else {
tmp = -fma(x, (log(y) - log(x)), z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -4e-310) tmp = Float64(Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))) - z); else tmp = Float64(-fma(x, Float64(log(y) - log(x)), z)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -4e-310], N[(N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], (-N[(x * N[(N[Log[y], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{-310}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(x, \log y - \log x, z\right)\\
\end{array}
\end{array}
if y < -3.999999999999988e-310Initial program 75.9%
frac-2neg42.8%
log-div51.9%
Applied egg-rr99.4%
if -3.999999999999988e-310 < y Initial program 81.5%
remove-double-neg81.5%
sub-neg81.5%
distribute-neg-in81.5%
distribute-rgt-neg-in81.5%
remove-double-neg81.5%
fma-udef81.5%
log-div99.4%
sub-neg99.4%
distribute-neg-in99.4%
remove-double-neg99.4%
+-commutative99.4%
sub-neg99.4%
log-div80.4%
Simplified80.4%
log-div99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x y z) :precision binary64 (- (* x (* 3.0 (log (/ (cbrt x) (cbrt y))))) z))
double code(double x, double y, double z) {
return (x * (3.0 * log((cbrt(x) / cbrt(y))))) - z;
}
public static double code(double x, double y, double z) {
return (x * (3.0 * Math.log((Math.cbrt(x) / Math.cbrt(y))))) - z;
}
function code(x, y, z) return Float64(Float64(x * Float64(3.0 * log(Float64(cbrt(x) / cbrt(y))))) - z) end
code[x_, y_, z_] := N[(N[(x * N[(3.0 * N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(3 \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)\right) - z
\end{array}
Initial program 78.7%
add-cube-cbrt78.7%
log-prod78.6%
pow278.6%
Applied egg-rr78.6%
log-pow78.6%
distribute-lft1-in78.6%
metadata-eval78.6%
Simplified78.6%
cbrt-div99.7%
div-inv99.7%
Applied egg-rr99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.6%
Final simplification99.6%
(FPCore (x y z)
:precision binary64
(if (<= x -2.2e+138)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.86e-218)
(- (* x (log (/ x y))) z)
(if (<= x -5e-310) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.2e+138) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.86e-218) {
tmp = (x * log((x / y))) - z;
} else if (x <= -5e-310) {
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 <= (-2.2d+138)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-1.86d-218)) then
tmp = (x * log((x / y))) - z
else if (x <= (-5d-310)) 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 <= -2.2e+138) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -1.86e-218) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -5e-310) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.2e+138: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -1.86e-218: tmp = (x * math.log((x / y))) - z elif x <= -5e-310: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.2e+138) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.86e-218) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -5e-310) 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 <= -2.2e+138) tmp = x * (log(-x) - log(-y)); elseif (x <= -1.86e-218) tmp = (x * log((x / y))) - z; elseif (x <= -5e-310) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.2e+138], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.86e-218], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -5e-310], (-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 -2.2 \cdot 10^{+138}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.86 \cdot 10^{-218}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -2.2000000000000001e138Initial program 64.3%
Taylor expanded in z around 0 61.4%
frac-2neg61.4%
log-div90.1%
Applied egg-rr90.1%
if -2.2000000000000001e138 < x < -1.8600000000000001e-218Initial program 90.1%
if -1.8600000000000001e-218 < x < -4.999999999999985e-310Initial program 51.5%
remove-double-neg51.5%
sub-neg51.5%
distribute-neg-in51.5%
distribute-rgt-neg-in51.5%
remove-double-neg51.5%
fma-udef51.5%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div47.4%
Simplified47.4%
Taylor expanded in x around 0 100.0%
if -4.999999999999985e-310 < x Initial program 81.5%
log-div99.4%
Applied egg-rr99.4%
Final simplification95.7%
(FPCore (x y z) :precision binary64 (if (<= y -4e-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 <= -4e-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 <= (-4d-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 <= -4e-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 <= -4e-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 <= -4e-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 <= -4e-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, -4e-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 -4 \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 < -3.999999999999988e-310Initial program 75.9%
frac-2neg42.8%
log-div51.9%
Applied egg-rr99.4%
if -3.999999999999988e-310 < y Initial program 81.5%
log-div99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -980000.0) (not (<= z 2.3e-99))) (- z) (* (- x) (log (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -980000.0) || !(z <= 2.3e-99)) {
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 <= (-980000.0d0)) .or. (.not. (z <= 2.3d-99))) 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 <= -980000.0) || !(z <= 2.3e-99)) {
tmp = -z;
} else {
tmp = -x * Math.log((y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -980000.0) or not (z <= 2.3e-99): tmp = -z else: tmp = -x * math.log((y / x)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -980000.0) || !(z <= 2.3e-99)) tmp = Float64(-z); else tmp = Float64(Float64(-x) * log(Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -980000.0) || ~((z <= 2.3e-99))) tmp = -z; else tmp = -x * log((y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -980000.0], N[Not[LessEqual[z, 2.3e-99]], $MachinePrecision]], (-z), N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -980000 \lor \neg \left(z \leq 2.3 \cdot 10^{-99}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\end{array}
\end{array}
if z < -9.8e5 or 2.2999999999999998e-99 < z Initial program 79.2%
remove-double-neg79.2%
sub-neg79.2%
distribute-neg-in79.2%
distribute-rgt-neg-in79.2%
remove-double-neg79.2%
fma-udef79.2%
log-div50.5%
sub-neg50.5%
distribute-neg-in50.5%
remove-double-neg50.5%
+-commutative50.5%
sub-neg50.5%
log-div76.2%
Simplified76.2%
Taylor expanded in x around 0 70.7%
if -9.8e5 < z < 2.2999999999999998e-99Initial program 78.1%
remove-double-neg78.1%
sub-neg78.1%
distribute-neg-in78.1%
distribute-rgt-neg-in78.1%
remove-double-neg78.1%
fma-udef78.1%
log-div49.5%
sub-neg49.5%
distribute-neg-in49.5%
remove-double-neg49.5%
+-commutative49.5%
sub-neg49.5%
log-div78.4%
Simplified78.4%
Taylor expanded in x around inf 41.1%
log-rec41.1%
neg-mul-141.1%
neg-mul-141.1%
sub-neg41.1%
log-div68.3%
Simplified68.3%
Final simplification69.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -1400000.0) (not (<= z 1.28e-93))) (- z) (* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1400000.0) || !(z <= 1.28e-93)) {
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 <= (-1400000.0d0)) .or. (.not. (z <= 1.28d-93))) 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 <= -1400000.0) || !(z <= 1.28e-93)) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1400000.0) or not (z <= 1.28e-93): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1400000.0) || !(z <= 1.28e-93)) 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 <= -1400000.0) || ~((z <= 1.28e-93))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1400000.0], N[Not[LessEqual[z, 1.28e-93]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1400000 \lor \neg \left(z \leq 1.28 \cdot 10^{-93}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -1.4e6 or 1.27999999999999999e-93 < z Initial program 79.2%
remove-double-neg79.2%
sub-neg79.2%
distribute-neg-in79.2%
distribute-rgt-neg-in79.2%
remove-double-neg79.2%
fma-udef79.2%
log-div50.5%
sub-neg50.5%
distribute-neg-in50.5%
remove-double-neg50.5%
+-commutative50.5%
sub-neg50.5%
log-div76.2%
Simplified76.2%
Taylor expanded in x around 0 70.7%
if -1.4e6 < z < 1.27999999999999999e-93Initial program 78.1%
Taylor expanded in z around 0 67.9%
Final simplification69.5%
(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 78.7%
remove-double-neg78.7%
sub-neg78.7%
distribute-neg-in78.7%
distribute-rgt-neg-in78.7%
remove-double-neg78.7%
fma-udef78.7%
log-div50.1%
sub-neg50.1%
distribute-neg-in50.1%
remove-double-neg50.1%
+-commutative50.1%
sub-neg50.1%
log-div77.2%
Simplified77.2%
Taylor expanded in x around 0 47.1%
Final simplification47.1%
(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 2024020
(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))