
(FPCore (w l) :precision binary64 (* (exp (- w)) (pow l (exp w))))
double code(double w, double l) {
return exp(-w) * pow(l, exp(w));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w, l)
use fmin_fmax_functions
real(8), intent (in) :: w
real(8), intent (in) :: l
code = exp(-w) * (l ** exp(w))
end function
public static double code(double w, double l) {
return Math.exp(-w) * Math.pow(l, Math.exp(w));
}
def code(w, l): return math.exp(-w) * math.pow(l, math.exp(w))
function code(w, l) return Float64(exp(Float64(-w)) * (l ^ exp(w))) end
function tmp = code(w, l) tmp = exp(-w) * (l ^ exp(w)); end
code[w_, l_] := N[(N[Exp[(-w)], $MachinePrecision] * N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
e^{-w} \cdot {\ell}^{\left(e^{w}\right)}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (w l) :precision binary64 (* (exp (- w)) (pow l (exp w))))
double code(double w, double l) {
return exp(-w) * pow(l, exp(w));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w, l)
use fmin_fmax_functions
real(8), intent (in) :: w
real(8), intent (in) :: l
code = exp(-w) * (l ** exp(w))
end function
public static double code(double w, double l) {
return Math.exp(-w) * Math.pow(l, Math.exp(w));
}
def code(w, l): return math.exp(-w) * math.pow(l, math.exp(w))
function code(w, l) return Float64(exp(Float64(-w)) * (l ^ exp(w))) end
function tmp = code(w, l) tmp = exp(-w) * (l ^ exp(w)); end
code[w_, l_] := N[(N[Exp[(-w)], $MachinePrecision] * N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
e^{-w} \cdot {\ell}^{\left(e^{w}\right)}
(FPCore (w l) :precision binary64 (/ (pow l (exp w)) (exp w)))
double code(double w, double l) {
return pow(l, exp(w)) / exp(w);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w, l)
use fmin_fmax_functions
real(8), intent (in) :: w
real(8), intent (in) :: l
code = (l ** exp(w)) / exp(w)
end function
public static double code(double w, double l) {
return Math.pow(l, Math.exp(w)) / Math.exp(w);
}
def code(w, l): return math.pow(l, math.exp(w)) / math.exp(w)
function code(w, l) return Float64((l ^ exp(w)) / exp(w)) end
function tmp = code(w, l) tmp = (l ^ exp(w)) / exp(w); end
code[w_, l_] := N[(N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision] / N[Exp[w], $MachinePrecision]), $MachinePrecision]
\frac{{\ell}^{\left(e^{w}\right)}}{e^{w}}
Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-exp.64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.64N/A
mult-flip-revN/A
lower-/.f6499.4%
Applied rewrites99.4%
(FPCore (w l) :precision binary64 (if (<= w -2.1e-14) (exp (fma (log l) (exp w) (* w -1.0))) (* (pow l (exp w)) (- 1.0 w))))
double code(double w, double l) {
double tmp;
if (w <= -2.1e-14) {
tmp = exp(fma(log(l), exp(w), (w * -1.0)));
} else {
tmp = pow(l, exp(w)) * (1.0 - w);
}
return tmp;
}
function code(w, l) tmp = 0.0 if (w <= -2.1e-14) tmp = exp(fma(log(l), exp(w), Float64(w * -1.0))); else tmp = Float64((l ^ exp(w)) * Float64(1.0 - w)); end return tmp end
code[w_, l_] := If[LessEqual[w, -2.1e-14], N[Exp[N[(N[Log[l], $MachinePrecision] * N[Exp[w], $MachinePrecision] + N[(w * -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision] * N[(1.0 - w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;w \leq -2.1 \cdot 10^{-14}:\\
\;\;\;\;e^{\mathsf{fma}\left(\log \ell, e^{w}, w \cdot -1\right)}\\
\mathbf{else}:\\
\;\;\;\;{\ell}^{\left(e^{w}\right)} \cdot \left(1 - w\right)\\
\end{array}
if w < -2.0999999999999999e-14Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-exp.64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.64N/A
mult-flip-revN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6499.3%
Applied rewrites99.3%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lower-/.f6499.4%
lift-pow.64N/A
lift-exp.64N/A
sinh-+-cosh-revN/A
lift-cosh.64N/A
lift-sinh.64N/A
pow-prod-upN/A
lift-pow.64N/A
lift-pow.64N/A
*-commutativeN/A
lift-*.f6470.7%
lift-/.f64N/A
mult-flipN/A
Applied rewrites94.8%
if -2.0999999999999999e-14 < w Initial program 99.4%
Taylor expanded in w around 0
lower-+.f64N/A
lower-*.f6471.5%
Applied rewrites71.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.5%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6471.5%
Applied rewrites71.5%
(FPCore (w l) :precision binary64 (if (<= w -5.2e-11) (exp (- (* (log l) (exp w)) w)) (* (pow l (exp w)) (- 1.0 w))))
double code(double w, double l) {
double tmp;
if (w <= -5.2e-11) {
tmp = exp(((log(l) * exp(w)) - w));
} else {
tmp = pow(l, exp(w)) * (1.0 - w);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w, l)
use fmin_fmax_functions
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: tmp
if (w <= (-5.2d-11)) then
tmp = exp(((log(l) * exp(w)) - w))
else
tmp = (l ** exp(w)) * (1.0d0 - w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -5.2e-11) {
tmp = Math.exp(((Math.log(l) * Math.exp(w)) - w));
} else {
tmp = Math.pow(l, Math.exp(w)) * (1.0 - w);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -5.2e-11: tmp = math.exp(((math.log(l) * math.exp(w)) - w)) else: tmp = math.pow(l, math.exp(w)) * (1.0 - w) return tmp
function code(w, l) tmp = 0.0 if (w <= -5.2e-11) tmp = exp(Float64(Float64(log(l) * exp(w)) - w)); else tmp = Float64((l ^ exp(w)) * Float64(1.0 - w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -5.2e-11) tmp = exp(((log(l) * exp(w)) - w)); else tmp = (l ^ exp(w)) * (1.0 - w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -5.2e-11], N[Exp[N[(N[(N[Log[l], $MachinePrecision] * N[Exp[w], $MachinePrecision]), $MachinePrecision] - w), $MachinePrecision]], $MachinePrecision], N[(N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision] * N[(1.0 - w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;w \leq -5.2 \cdot 10^{-11}:\\
\;\;\;\;e^{\log \ell \cdot e^{w} - w}\\
\mathbf{else}:\\
\;\;\;\;{\ell}^{\left(e^{w}\right)} \cdot \left(1 - w\right)\\
\end{array}
if w < -5.2000000000000001e-11Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-exp.64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.64N/A
mult-flip-revN/A
lower-/.f6499.4%
Applied rewrites99.4%
lift-/.f64N/A
lift-pow.64N/A
exp-to-powN/A
lift-log.64N/A
lift-*.f64N/A
lift-exp.64N/A
div-expN/A
sub-flip-reverseN/A
lift-neg.f64N/A
+-commutativeN/A
lower-exp.64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6494.8%
Applied rewrites94.8%
if -5.2000000000000001e-11 < w Initial program 99.4%
Taylor expanded in w around 0
lower-+.f64N/A
lower-*.f6471.5%
Applied rewrites71.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.5%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6471.5%
Applied rewrites71.5%
(FPCore (w l) :precision binary64 (if (<= w -550.0) (* (exp (- w)) (exp (log l))) (* (pow l (exp w)) (- 1.0 w))))
double code(double w, double l) {
double tmp;
if (w <= -550.0) {
tmp = exp(-w) * exp(log(l));
} else {
tmp = pow(l, exp(w)) * (1.0 - w);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w, l)
use fmin_fmax_functions
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: tmp
if (w <= (-550.0d0)) then
tmp = exp(-w) * exp(log(l))
else
tmp = (l ** exp(w)) * (1.0d0 - w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -550.0) {
tmp = Math.exp(-w) * Math.exp(Math.log(l));
} else {
tmp = Math.pow(l, Math.exp(w)) * (1.0 - w);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -550.0: tmp = math.exp(-w) * math.exp(math.log(l)) else: tmp = math.pow(l, math.exp(w)) * (1.0 - w) return tmp
function code(w, l) tmp = 0.0 if (w <= -550.0) tmp = Float64(exp(Float64(-w)) * exp(log(l))); else tmp = Float64((l ^ exp(w)) * Float64(1.0 - w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -550.0) tmp = exp(-w) * exp(log(l)); else tmp = (l ^ exp(w)) * (1.0 - w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -550.0], N[(N[Exp[(-w)], $MachinePrecision] * N[Exp[N[Log[l], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision] * N[(1.0 - w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;w \leq -550:\\
\;\;\;\;e^{-w} \cdot e^{\log \ell}\\
\mathbf{else}:\\
\;\;\;\;{\ell}^{\left(e^{w}\right)} \cdot \left(1 - w\right)\\
\end{array}
if w < -550Initial program 99.4%
lift-pow.64N/A
pow-to-expN/A
lower-unsound-exp.64N/A
lower-unsound-*.f64N/A
lower-unsound-log.6494.5%
Applied rewrites94.5%
Taylor expanded in w around 0
lower-log.6492.7%
Applied rewrites92.7%
if -550 < w Initial program 99.4%
Taylor expanded in w around 0
lower-+.f64N/A
lower-*.f6471.5%
Applied rewrites71.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.5%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6471.5%
Applied rewrites71.5%
(FPCore (w l) :precision binary64 (if (<= w -0.019) (* (exp (- w)) (exp (log l))) (* (+ 1.0 (* -1.0 w)) (pow l (+ 1.0 w)))))
double code(double w, double l) {
double tmp;
if (w <= -0.019) {
tmp = exp(-w) * exp(log(l));
} else {
tmp = (1.0 + (-1.0 * w)) * pow(l, (1.0 + w));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w, l)
use fmin_fmax_functions
real(8), intent (in) :: w
real(8), intent (in) :: l
real(8) :: tmp
if (w <= (-0.019d0)) then
tmp = exp(-w) * exp(log(l))
else
tmp = (1.0d0 + ((-1.0d0) * w)) * (l ** (1.0d0 + w))
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -0.019) {
tmp = Math.exp(-w) * Math.exp(Math.log(l));
} else {
tmp = (1.0 + (-1.0 * w)) * Math.pow(l, (1.0 + w));
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -0.019: tmp = math.exp(-w) * math.exp(math.log(l)) else: tmp = (1.0 + (-1.0 * w)) * math.pow(l, (1.0 + w)) return tmp
function code(w, l) tmp = 0.0 if (w <= -0.019) tmp = Float64(exp(Float64(-w)) * exp(log(l))); else tmp = Float64(Float64(1.0 + Float64(-1.0 * w)) * (l ^ Float64(1.0 + w))); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -0.019) tmp = exp(-w) * exp(log(l)); else tmp = (1.0 + (-1.0 * w)) * (l ^ (1.0 + w)); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -0.019], N[(N[Exp[(-w)], $MachinePrecision] * N[Exp[N[Log[l], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(-1.0 * w), $MachinePrecision]), $MachinePrecision] * N[Power[l, N[(1.0 + w), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;w \leq -0.019:\\
\;\;\;\;e^{-w} \cdot e^{\log \ell}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + -1 \cdot w\right) \cdot {\ell}^{\left(1 + w\right)}\\
\end{array}
if w < -0.0189999999999999995Initial program 99.4%
lift-pow.64N/A
pow-to-expN/A
lower-unsound-exp.64N/A
lower-unsound-*.f64N/A
lower-unsound-log.6494.5%
Applied rewrites94.5%
Taylor expanded in w around 0
lower-log.6492.7%
Applied rewrites92.7%
if -0.0189999999999999995 < w Initial program 99.4%
Taylor expanded in w around 0
lower-+.f6484.5%
Applied rewrites84.5%
Taylor expanded in w around 0
lower-+.f64N/A
lower-*.f6484.5%
Applied rewrites84.5%
(FPCore (w l) :precision binary64 (if (<= l 3.5e+49) (* (+ 1.0 (* -1.0 w)) (pow l (+ 1.0 w))) (+ l (fma (* (log l) l) w (* (- l) w)))))
double code(double w, double l) {
double tmp;
if (l <= 3.5e+49) {
tmp = (1.0 + (-1.0 * w)) * pow(l, (1.0 + w));
} else {
tmp = l + fma((log(l) * l), w, (-l * w));
}
return tmp;
}
function code(w, l) tmp = 0.0 if (l <= 3.5e+49) tmp = Float64(Float64(1.0 + Float64(-1.0 * w)) * (l ^ Float64(1.0 + w))); else tmp = Float64(l + fma(Float64(log(l) * l), w, Float64(Float64(-l) * w))); end return tmp end
code[w_, l_] := If[LessEqual[l, 3.5e+49], N[(N[(1.0 + N[(-1.0 * w), $MachinePrecision]), $MachinePrecision] * N[Power[l, N[(1.0 + w), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(l + N[(N[(N[Log[l], $MachinePrecision] * l), $MachinePrecision] * w + N[((-l) * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\ell \leq 3.5 \cdot 10^{+49}:\\
\;\;\;\;\left(1 + -1 \cdot w\right) \cdot {\ell}^{\left(1 + w\right)}\\
\mathbf{else}:\\
\;\;\;\;\ell + \mathsf{fma}\left(\log \ell \cdot \ell, w, \left(-\ell\right) \cdot w\right)\\
\end{array}
if l < 3.49999999999999975e49Initial program 99.4%
Taylor expanded in w around 0
lower-+.f6484.5%
Applied rewrites84.5%
Taylor expanded in w around 0
lower-+.f64N/A
lower-*.f6484.5%
Applied rewrites84.5%
if 3.49999999999999975e49 < l Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-exp.64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.64N/A
mult-flip-revN/A
lower-/.f6499.4%
Applied rewrites99.4%
Taylor expanded in w around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.6456.6%
Applied rewrites56.6%
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-neg.f6463.6%
Applied rewrites63.6%
(FPCore (w l) :precision binary64 (if (<= w -260.0) (+ l (fma (* (log l) l) w (* (- l) w))) (/ (pow l (- w -1.0)) (- w -1.0))))
double code(double w, double l) {
double tmp;
if (w <= -260.0) {
tmp = l + fma((log(l) * l), w, (-l * w));
} else {
tmp = pow(l, (w - -1.0)) / (w - -1.0);
}
return tmp;
}
function code(w, l) tmp = 0.0 if (w <= -260.0) tmp = Float64(l + fma(Float64(log(l) * l), w, Float64(Float64(-l) * w))); else tmp = Float64((l ^ Float64(w - -1.0)) / Float64(w - -1.0)); end return tmp end
code[w_, l_] := If[LessEqual[w, -260.0], N[(l + N[(N[(N[Log[l], $MachinePrecision] * l), $MachinePrecision] * w + N[((-l) * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[l, N[(w - -1.0), $MachinePrecision]], $MachinePrecision] / N[(w - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;w \leq -260:\\
\;\;\;\;\ell + \mathsf{fma}\left(\log \ell \cdot \ell, w, \left(-\ell\right) \cdot w\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{\ell}^{\left(w - -1\right)}}{w - -1}\\
\end{array}
if w < -260Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-exp.64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.64N/A
mult-flip-revN/A
lower-/.f6499.4%
Applied rewrites99.4%
Taylor expanded in w around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.6456.6%
Applied rewrites56.6%
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-neg.f6463.6%
Applied rewrites63.6%
if -260 < w Initial program 99.4%
lift-exp.64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.64N/A
lower-/.f6499.4%
Applied rewrites99.4%
Taylor expanded in w around 0
lower-+.f6470.8%
Applied rewrites70.8%
Taylor expanded in w around 0
lower-+.f6470.5%
Applied rewrites70.5%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6470.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6470.5%
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
lower--.f64N/A
Applied rewrites70.5%
(FPCore (w l) :precision binary64 (if (<= l 0.00018) (* (+ 1.0 (* -1.0 w)) (+ l (* l (* w (log l))))) (+ l (fma (* (log l) l) w (* (- l) w)))))
double code(double w, double l) {
double tmp;
if (l <= 0.00018) {
tmp = (1.0 + (-1.0 * w)) * (l + (l * (w * log(l))));
} else {
tmp = l + fma((log(l) * l), w, (-l * w));
}
return tmp;
}
function code(w, l) tmp = 0.0 if (l <= 0.00018) tmp = Float64(Float64(1.0 + Float64(-1.0 * w)) * Float64(l + Float64(l * Float64(w * log(l))))); else tmp = Float64(l + fma(Float64(log(l) * l), w, Float64(Float64(-l) * w))); end return tmp end
code[w_, l_] := If[LessEqual[l, 0.00018], N[(N[(1.0 + N[(-1.0 * w), $MachinePrecision]), $MachinePrecision] * N[(l + N[(l * N[(w * N[Log[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(l + N[(N[(N[Log[l], $MachinePrecision] * l), $MachinePrecision] * w + N[((-l) * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\ell \leq 0.00018:\\
\;\;\;\;\left(1 + -1 \cdot w\right) \cdot \left(\ell + \ell \cdot \left(w \cdot \log \ell\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\ell + \mathsf{fma}\left(\log \ell \cdot \ell, w, \left(-\ell\right) \cdot w\right)\\
\end{array}
if l < 1.80000000000000011e-4Initial program 99.4%
Taylor expanded in w around 0
lower-+.f64N/A
lower-*.f6471.5%
Applied rewrites71.5%
Taylor expanded in w around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-log.6460.3%
Applied rewrites60.3%
if 1.80000000000000011e-4 < l Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-exp.64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.64N/A
mult-flip-revN/A
lower-/.f6499.4%
Applied rewrites99.4%
Taylor expanded in w around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.6456.6%
Applied rewrites56.6%
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-neg.f6463.6%
Applied rewrites63.6%
(FPCore (w l) :precision binary64 (+ l (fma (* (log l) l) w (* (- l) w))))
double code(double w, double l) {
return l + fma((log(l) * l), w, (-l * w));
}
function code(w, l) return Float64(l + fma(Float64(log(l) * l), w, Float64(Float64(-l) * w))) end
code[w_, l_] := N[(l + N[(N[(N[Log[l], $MachinePrecision] * l), $MachinePrecision] * w + N[((-l) * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\ell + \mathsf{fma}\left(\log \ell \cdot \ell, w, \left(-\ell\right) \cdot w\right)
Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-exp.64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.64N/A
mult-flip-revN/A
lower-/.f6499.4%
Applied rewrites99.4%
Taylor expanded in w around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.6456.6%
Applied rewrites56.6%
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-neg.f6463.6%
Applied rewrites63.6%
(FPCore (w l) :precision binary64 (+ l (* l (* w (- (log l) 1.0)))))
double code(double w, double l) {
return l + (l * (w * (log(l) - 1.0)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w, l)
use fmin_fmax_functions
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l + (l * (w * (log(l) - 1.0d0)))
end function
public static double code(double w, double l) {
return l + (l * (w * (Math.log(l) - 1.0)));
}
def code(w, l): return l + (l * (w * (math.log(l) - 1.0)))
function code(w, l) return Float64(l + Float64(l * Float64(w * Float64(log(l) - 1.0)))) end
function tmp = code(w, l) tmp = l + (l * (w * (log(l) - 1.0))); end
code[w_, l_] := N[(l + N[(l * N[(w * N[(N[Log[l], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\ell + \ell \cdot \left(w \cdot \left(\log \ell - 1\right)\right)
Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-exp.64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.64N/A
mult-flip-revN/A
lower-/.f6499.4%
Applied rewrites99.4%
Taylor expanded in w around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.6456.6%
Applied rewrites56.6%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-log.6457.1%
Applied rewrites57.1%
(FPCore (w l) :precision binary64 l)
double code(double w, double l) {
return l;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w, l)
use fmin_fmax_functions
real(8), intent (in) :: w
real(8), intent (in) :: l
code = l
end function
public static double code(double w, double l) {
return l;
}
def code(w, l): return l
function code(w, l) return l end
function tmp = code(w, l) tmp = l; end
code[w_, l_] := l
\ell
Initial program 99.4%
Taylor expanded in w around 0
Applied rewrites57.2%
herbie shell --seed 2025183
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))