
(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]
\begin{array}{l}
\\
e^{-w} \cdot {\ell}^{\left(e^{w}\right)}
\end{array}
Herbie found 9 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]
\begin{array}{l}
\\
e^{-w} \cdot {\ell}^{\left(e^{w}\right)}
\end{array}
(FPCore (w l) :precision binary64 (if (<= l 1.0) (* (exp (- w)) (fma (* (log l) w) l l)) (* (fma (fma 0.5 w -1.0) w 1.0) (pow l (fma (fma 0.5 w 1.0) w 1.0)))))
double code(double w, double l) {
double tmp;
if (l <= 1.0) {
tmp = exp(-w) * fma((log(l) * w), l, l);
} else {
tmp = fma(fma(0.5, w, -1.0), w, 1.0) * pow(l, fma(fma(0.5, w, 1.0), w, 1.0));
}
return tmp;
}
function code(w, l) tmp = 0.0 if (l <= 1.0) tmp = Float64(exp(Float64(-w)) * fma(Float64(log(l) * w), l, l)); else tmp = Float64(fma(fma(0.5, w, -1.0), w, 1.0) * (l ^ fma(fma(0.5, w, 1.0), w, 1.0))); end return tmp end
code[w_, l_] := If[LessEqual[l, 1.0], N[(N[Exp[(-w)], $MachinePrecision] * N[(N[(N[Log[l], $MachinePrecision] * w), $MachinePrecision] * l + l), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 * w + -1.0), $MachinePrecision] * w + 1.0), $MachinePrecision] * N[Power[l, N[(N[(0.5 * w + 1.0), $MachinePrecision] * w + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1:\\
\;\;\;\;e^{-w} \cdot \mathsf{fma}\left(\log \ell \cdot w, \ell, \ell\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5, w, -1\right), w, 1\right) \cdot {\ell}^{\left(\mathsf{fma}\left(\mathsf{fma}\left(0.5, w, 1\right), w, 1\right)\right)}\\
\end{array}
\end{array}
if l < 1Initial program 99.5%
Taylor expanded in w around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6483.4
Applied rewrites83.4%
if 1 < l Initial program 99.5%
Taylor expanded in w around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-flipN/A
metadata-evalN/A
lower-fma.f6479.2
Applied rewrites79.2%
Taylor expanded in w around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6478.7
Applied rewrites78.7%
(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]
\begin{array}{l}
\\
e^{-w} \cdot {\ell}^{\left(e^{w}\right)}
\end{array}
Initial program 99.5%
(FPCore (w l) :precision binary64 (if (<= w -350.0) (exp (+ (- w) (- (- (log l))))) (* (pow l (exp w)) (- 1.0 w))))
double code(double w, double l) {
double tmp;
if (w <= -350.0) {
tmp = exp((-w + -(-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 <= (-350.0d0)) then
tmp = exp((-w + -(-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 <= -350.0) {
tmp = Math.exp((-w + -(-Math.log(l))));
} else {
tmp = Math.pow(l, Math.exp(w)) * (1.0 - w);
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -350.0: tmp = math.exp((-w + -(-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 <= -350.0) tmp = exp(Float64(Float64(-w) + Float64(-Float64(-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 <= -350.0) tmp = exp((-w + -(-log(l)))); else tmp = (l ^ exp(w)) * (1.0 - w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -350.0], N[Exp[N[((-w) + (-(-N[Log[l], $MachinePrecision]))), $MachinePrecision]], $MachinePrecision], N[(N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision] * N[(1.0 - w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -350:\\
\;\;\;\;e^{\left(-w\right) + \left(-\left(-\log \ell\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;{\ell}^{\left(e^{w}\right)} \cdot \left(1 - w\right)\\
\end{array}
\end{array}
if w < -350Initial program 99.5%
Taylor expanded in l around inf
lift-neg.f64N/A
prod-expN/A
lower-exp.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lift-exp.f6494.8
Applied rewrites94.8%
Taylor expanded in w around 0
mul-1-negN/A
lift-neg.f64N/A
lift-log.f6492.8
Applied rewrites92.8%
if -350 < w Initial program 99.5%
Taylor expanded in w around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f6471.5
Applied rewrites71.5%
lift-*.f64N/A
lift-exp.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
lift-exp.f6471.5
lift-+.f64N/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6471.5
Applied rewrites71.5%
(FPCore (w l)
:precision binary64
(if (<= w -0.0019)
(exp (+ (- w) (- (- (log l)))))
(if (<= w 5.4e-10)
(* (fma (* (log l) w) l l) (- 1.0 w))
(exp (+ (- w) (* (log l) (- w -1.0)))))))
double code(double w, double l) {
double tmp;
if (w <= -0.0019) {
tmp = exp((-w + -(-log(l))));
} else if (w <= 5.4e-10) {
tmp = fma((log(l) * w), l, l) * (1.0 - w);
} else {
tmp = exp((-w + (log(l) * (w - -1.0))));
}
return tmp;
}
function code(w, l) tmp = 0.0 if (w <= -0.0019) tmp = exp(Float64(Float64(-w) + Float64(-Float64(-log(l))))); elseif (w <= 5.4e-10) tmp = Float64(fma(Float64(log(l) * w), l, l) * Float64(1.0 - w)); else tmp = exp(Float64(Float64(-w) + Float64(log(l) * Float64(w - -1.0)))); end return tmp end
code[w_, l_] := If[LessEqual[w, -0.0019], N[Exp[N[((-w) + (-(-N[Log[l], $MachinePrecision]))), $MachinePrecision]], $MachinePrecision], If[LessEqual[w, 5.4e-10], N[(N[(N[(N[Log[l], $MachinePrecision] * w), $MachinePrecision] * l + l), $MachinePrecision] * N[(1.0 - w), $MachinePrecision]), $MachinePrecision], N[Exp[N[((-w) + N[(N[Log[l], $MachinePrecision] * N[(w - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -0.0019:\\
\;\;\;\;e^{\left(-w\right) + \left(-\left(-\log \ell\right)\right)}\\
\mathbf{elif}\;w \leq 5.4 \cdot 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(\log \ell \cdot w, \ell, \ell\right) \cdot \left(1 - w\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\left(-w\right) + \log \ell \cdot \left(w - -1\right)}\\
\end{array}
\end{array}
if w < -0.0019Initial program 99.5%
Taylor expanded in l around inf
lift-neg.f64N/A
prod-expN/A
lower-exp.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lift-exp.f6494.8
Applied rewrites94.8%
Taylor expanded in w around 0
mul-1-negN/A
lift-neg.f64N/A
lift-log.f6492.8
Applied rewrites92.8%
if -0.0019 < w < 5.4e-10Initial program 99.5%
Taylor expanded in w around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6483.4
Applied rewrites83.4%
Taylor expanded in w around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f6460.4
Applied rewrites60.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.4
lift-+.f64N/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6460.4
Applied rewrites60.4%
if 5.4e-10 < w Initial program 99.5%
Taylor expanded in l around inf
lift-neg.f64N/A
prod-expN/A
lower-exp.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lift-exp.f6494.8
Applied rewrites94.8%
Taylor expanded in w around 0
distribute-rgt-out--N/A
lower-*.f64N/A
lift-log.f64N/A
lower--.f6479.4
Applied rewrites79.4%
(FPCore (w l) :precision binary64 (if (<= w -1.6) (exp (+ (- w) (- (- (log l))))) (* (+ 1.0 (- w)) (pow l (+ 1.0 w)))))
double code(double w, double l) {
double tmp;
if (w <= -1.6) {
tmp = exp((-w + -(-log(l))));
} else {
tmp = (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 <= (-1.6d0)) then
tmp = exp((-w + -(-log(l))))
else
tmp = (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 <= -1.6) {
tmp = Math.exp((-w + -(-Math.log(l))));
} else {
tmp = (1.0 + -w) * Math.pow(l, (1.0 + w));
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -1.6: tmp = math.exp((-w + -(-math.log(l)))) else: tmp = (1.0 + -w) * math.pow(l, (1.0 + w)) return tmp
function code(w, l) tmp = 0.0 if (w <= -1.6) tmp = exp(Float64(Float64(-w) + Float64(-Float64(-log(l))))); else tmp = Float64(Float64(1.0 + Float64(-w)) * (l ^ Float64(1.0 + w))); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -1.6) tmp = exp((-w + -(-log(l)))); else tmp = (1.0 + -w) * (l ^ (1.0 + w)); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -1.6], N[Exp[N[((-w) + (-(-N[Log[l], $MachinePrecision]))), $MachinePrecision]], $MachinePrecision], N[(N[(1.0 + (-w)), $MachinePrecision] * N[Power[l, N[(1.0 + w), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -1.6:\\
\;\;\;\;e^{\left(-w\right) + \left(-\left(-\log \ell\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(-w\right)\right) \cdot {\ell}^{\left(1 + w\right)}\\
\end{array}
\end{array}
if w < -1.6000000000000001Initial program 99.5%
Taylor expanded in l around inf
lift-neg.f64N/A
prod-expN/A
lower-exp.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lift-exp.f6494.8
Applied rewrites94.8%
Taylor expanded in w around 0
mul-1-negN/A
lift-neg.f64N/A
lift-log.f6492.8
Applied rewrites92.8%
if -1.6000000000000001 < w Initial program 99.5%
Taylor expanded in w around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f6471.5
Applied rewrites71.5%
Taylor expanded in w around 0
lower-+.f6483.9
Applied rewrites83.9%
(FPCore (w l)
:precision binary64
(let* ((t_0 (exp (+ (- w) (- (- (log l)))))))
(if (<= w -0.0019)
t_0
(if (<= w 0.0022) (* (fma (* (log l) w) l l) (- 1.0 w)) t_0))))
double code(double w, double l) {
double t_0 = exp((-w + -(-log(l))));
double tmp;
if (w <= -0.0019) {
tmp = t_0;
} else if (w <= 0.0022) {
tmp = fma((log(l) * w), l, l) * (1.0 - w);
} else {
tmp = t_0;
}
return tmp;
}
function code(w, l) t_0 = exp(Float64(Float64(-w) + Float64(-Float64(-log(l))))) tmp = 0.0 if (w <= -0.0019) tmp = t_0; elseif (w <= 0.0022) tmp = Float64(fma(Float64(log(l) * w), l, l) * Float64(1.0 - w)); else tmp = t_0; end return tmp end
code[w_, l_] := Block[{t$95$0 = N[Exp[N[((-w) + (-(-N[Log[l], $MachinePrecision]))), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[w, -0.0019], t$95$0, If[LessEqual[w, 0.0022], N[(N[(N[(N[Log[l], $MachinePrecision] * w), $MachinePrecision] * l + l), $MachinePrecision] * N[(1.0 - w), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\left(-w\right) + \left(-\left(-\log \ell\right)\right)}\\
\mathbf{if}\;w \leq -0.0019:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;w \leq 0.0022:\\
\;\;\;\;\mathsf{fma}\left(\log \ell \cdot w, \ell, \ell\right) \cdot \left(1 - w\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if w < -0.0019 or 0.00220000000000000013 < w Initial program 99.5%
Taylor expanded in l around inf
lift-neg.f64N/A
prod-expN/A
lower-exp.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
log-recN/A
lower-neg.f64N/A
lower-log.f64N/A
lift-exp.f6494.8
Applied rewrites94.8%
Taylor expanded in w around 0
mul-1-negN/A
lift-neg.f64N/A
lift-log.f6492.8
Applied rewrites92.8%
if -0.0019 < w < 0.00220000000000000013Initial program 99.5%
Taylor expanded in w around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6483.4
Applied rewrites83.4%
Taylor expanded in w around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f6460.4
Applied rewrites60.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.4
lift-+.f64N/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6460.4
Applied rewrites60.4%
(FPCore (w l) :precision binary64 (if (<= w -5.2e+174) (* (- 1.0 w) (* (* (log l) w) l)) l))
double code(double w, double l) {
double tmp;
if (w <= -5.2e+174) {
tmp = (1.0 - w) * ((log(l) * w) * l);
} else {
tmp = l;
}
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+174)) then
tmp = (1.0d0 - w) * ((log(l) * w) * l)
else
tmp = l
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (w <= -5.2e+174) {
tmp = (1.0 - w) * ((Math.log(l) * w) * l);
} else {
tmp = l;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -5.2e+174: tmp = (1.0 - w) * ((math.log(l) * w) * l) else: tmp = l return tmp
function code(w, l) tmp = 0.0 if (w <= -5.2e+174) tmp = Float64(Float64(1.0 - w) * Float64(Float64(log(l) * w) * l)); else tmp = l; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -5.2e+174) tmp = (1.0 - w) * ((log(l) * w) * l); else tmp = l; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -5.2e+174], N[(N[(1.0 - w), $MachinePrecision] * N[(N[(N[Log[l], $MachinePrecision] * w), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision], l]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -5.2 \cdot 10^{+174}:\\
\;\;\;\;\left(1 - w\right) \cdot \left(\left(\log \ell \cdot w\right) \cdot \ell\right)\\
\mathbf{else}:\\
\;\;\;\;\ell\\
\end{array}
\end{array}
if w < -5.1999999999999997e174Initial program 99.5%
Taylor expanded in w around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6483.4
Applied rewrites83.4%
Taylor expanded in w around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f6460.4
Applied rewrites60.4%
Taylor expanded in w around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift-*.f647.0
Applied rewrites7.0%
lift-+.f64N/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f647.0
Applied rewrites7.0%
if -5.1999999999999997e174 < w Initial program 99.5%
Taylor expanded in w around 0
Applied rewrites57.3%
(FPCore (w l) :precision binary64 (* (fma (* (log l) w) l l) (- 1.0 w)))
double code(double w, double l) {
return fma((log(l) * w), l, l) * (1.0 - w);
}
function code(w, l) return Float64(fma(Float64(log(l) * w), l, l) * Float64(1.0 - w)) end
code[w_, l_] := N[(N[(N[(N[Log[l], $MachinePrecision] * w), $MachinePrecision] * l + l), $MachinePrecision] * N[(1.0 - w), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log \ell \cdot w, \ell, \ell\right) \cdot \left(1 - w\right)
\end{array}
Initial program 99.5%
Taylor expanded in w around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6483.4
Applied rewrites83.4%
Taylor expanded in w around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f6460.4
Applied rewrites60.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.4
lift-+.f64N/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6460.4
Applied rewrites60.4%
(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
\begin{array}{l}
\\
\ell
\end{array}
Initial program 99.5%
Taylor expanded in w around 0
Applied rewrites57.3%
herbie shell --seed 2025134
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))