
(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 10 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 (/ (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]
\begin{array}{l}
\\
\frac{{\ell}^{\left(e^{w}\right)}}{e^{w}}
\end{array}
Initial program 99.4%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-pow.f64N/A
*-commutativeN/A
exp-negN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-pow.f64N/A
lift-exp.f64N/A
lift-exp.f6499.4
Applied rewrites99.4%
lift-*.f64N/A
lift-exp.f64N/A
lift-pow.f64N/A
*-rgt-identityN/A
lift-pow.f64N/A
lift-exp.f6499.4
Applied rewrites99.4%
(FPCore (w l) :precision binary64 (if (<= w -1.5e-7) (exp (- (* (log l) (exp w)) w)) (* (pow l (exp w)) (- 1.0 w))))
double code(double w, double l) {
double tmp;
if (w <= -1.5e-7) {
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 <= (-1.5d-7)) 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 <= -1.5e-7) {
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 <= -1.5e-7: 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 <= -1.5e-7) 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 <= -1.5e-7) 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, -1.5e-7], 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}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -1.5 \cdot 10^{-7}:\\
\;\;\;\;e^{\log \ell \cdot e^{w} - w}\\
\mathbf{else}:\\
\;\;\;\;{\ell}^{\left(e^{w}\right)} \cdot \left(1 - w\right)\\
\end{array}
\end{array}
if w < -1.4999999999999999e-7Initial program 99.4%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-pow.f64N/A
*-commutativeN/A
exp-negN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-pow.f64N/A
lift-exp.f64N/A
lift-exp.f6499.4
Applied rewrites99.4%
lift-/.f64N/A
lift-*.f64N/A
lift-exp.f64N/A
lift-pow.f64N/A
lift-exp.f64N/A
*-rgt-identityN/A
pow-to-expN/A
div-expN/A
lower-exp.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift-log.f64N/A
lift-exp.f6494.8
Applied rewrites94.8%
if -1.4999999999999999e-7 < w Initial program 99.4%
Taylor expanded in w around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6471.9
Applied rewrites71.9%
lift-*.f64N/A
lift-exp.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
lift-exp.f6471.9
Applied rewrites71.9%
(FPCore (w l) :precision binary64 (if (<= l 0.14) (* (- 1.0 w) (pow l (+ 1.0 w))) (* (- 1.0 w) (pow l (fma (fma 0.5 w 1.0) w 1.0)))))
double code(double w, double l) {
double tmp;
if (l <= 0.14) {
tmp = (1.0 - w) * pow(l, (1.0 + w));
} else {
tmp = (1.0 - w) * pow(l, fma(fma(0.5, w, 1.0), w, 1.0));
}
return tmp;
}
function code(w, l) tmp = 0.0 if (l <= 0.14) tmp = Float64(Float64(1.0 - w) * (l ^ Float64(1.0 + w))); else tmp = Float64(Float64(1.0 - w) * (l ^ fma(fma(0.5, w, 1.0), w, 1.0))); end return tmp end
code[w_, l_] := If[LessEqual[l, 0.14], N[(N[(1.0 - w), $MachinePrecision] * N[Power[l, N[(1.0 + w), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - w), $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 0.14:\\
\;\;\;\;\left(1 - w\right) \cdot {\ell}^{\left(1 + w\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 - w\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 < 0.14000000000000001Initial program 99.4%
Taylor expanded in w around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6471.9
Applied rewrites71.9%
Taylor expanded in w around 0
lower-+.f6484.6
Applied rewrites84.6%
if 0.14000000000000001 < l Initial program 99.4%
Taylor expanded in w around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6471.9
Applied rewrites71.9%
Taylor expanded in w around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6484.6
Applied rewrites84.6%
(FPCore (w l) :precision binary64 (if (<= l 0.14) (* (- 1.0 w) (pow l (+ 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 <= 0.14) {
tmp = (1.0 - w) * pow(l, (1.0 + w));
} else {
tmp = 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 <= 0.14) tmp = Float64(Float64(1.0 - w) * (l ^ Float64(1.0 + w))); else tmp = Float64(1.0 * (l ^ fma(fma(0.5, w, 1.0), w, 1.0))); end return tmp end
code[w_, l_] := If[LessEqual[l, 0.14], N[(N[(1.0 - w), $MachinePrecision] * N[Power[l, N[(1.0 + w), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 * 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 0.14:\\
\;\;\;\;\left(1 - w\right) \cdot {\ell}^{\left(1 + w\right)}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot {\ell}^{\left(\mathsf{fma}\left(\mathsf{fma}\left(0.5, w, 1\right), w, 1\right)\right)}\\
\end{array}
\end{array}
if l < 0.14000000000000001Initial program 99.4%
Taylor expanded in w around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6471.9
Applied rewrites71.9%
Taylor expanded in w around 0
lower-+.f6484.6
Applied rewrites84.6%
if 0.14000000000000001 < l Initial program 99.4%
Taylor expanded in w around 0
Applied rewrites71.2%
Taylor expanded in w around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6484.6
Applied rewrites84.6%
(FPCore (w l) :precision binary64 (if (<= l 0.14) (* (- 1.0 w) (pow l (+ 1.0 w))) (* (pow l 1.0) (- 1.0 w))))
double code(double w, double l) {
double tmp;
if (l <= 0.14) {
tmp = (1.0 - w) * pow(l, (1.0 + w));
} else {
tmp = pow(l, 1.0) * (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 (l <= 0.14d0) then
tmp = (1.0d0 - w) * (l ** (1.0d0 + w))
else
tmp = (l ** 1.0d0) * (1.0d0 - w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (l <= 0.14) {
tmp = (1.0 - w) * Math.pow(l, (1.0 + w));
} else {
tmp = Math.pow(l, 1.0) * (1.0 - w);
}
return tmp;
}
def code(w, l): tmp = 0 if l <= 0.14: tmp = (1.0 - w) * math.pow(l, (1.0 + w)) else: tmp = math.pow(l, 1.0) * (1.0 - w) return tmp
function code(w, l) tmp = 0.0 if (l <= 0.14) tmp = Float64(Float64(1.0 - w) * (l ^ Float64(1.0 + w))); else tmp = Float64((l ^ 1.0) * Float64(1.0 - w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (l <= 0.14) tmp = (1.0 - w) * (l ^ (1.0 + w)); else tmp = (l ^ 1.0) * (1.0 - w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[l, 0.14], N[(N[(1.0 - w), $MachinePrecision] * N[Power[l, N[(1.0 + w), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[l, 1.0], $MachinePrecision] * N[(1.0 - w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 0.14:\\
\;\;\;\;\left(1 - w\right) \cdot {\ell}^{\left(1 + w\right)}\\
\mathbf{else}:\\
\;\;\;\;{\ell}^{1} \cdot \left(1 - w\right)\\
\end{array}
\end{array}
if l < 0.14000000000000001Initial program 99.4%
Taylor expanded in w around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6471.9
Applied rewrites71.9%
Taylor expanded in w around 0
lower-+.f6484.6
Applied rewrites84.6%
if 0.14000000000000001 < l Initial program 99.4%
Taylor expanded in w around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6471.9
Applied rewrites71.9%
Taylor expanded in w around 0
Applied rewrites63.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6463.6
Applied rewrites63.6%
(FPCore (w l) :precision binary64 (if (<= l 0.14) (* 1.0 (pow l (+ 1.0 w))) (* (pow l 1.0) (- 1.0 w))))
double code(double w, double l) {
double tmp;
if (l <= 0.14) {
tmp = 1.0 * pow(l, (1.0 + w));
} else {
tmp = pow(l, 1.0) * (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 (l <= 0.14d0) then
tmp = 1.0d0 * (l ** (1.0d0 + w))
else
tmp = (l ** 1.0d0) * (1.0d0 - w)
end if
code = tmp
end function
public static double code(double w, double l) {
double tmp;
if (l <= 0.14) {
tmp = 1.0 * Math.pow(l, (1.0 + w));
} else {
tmp = Math.pow(l, 1.0) * (1.0 - w);
}
return tmp;
}
def code(w, l): tmp = 0 if l <= 0.14: tmp = 1.0 * math.pow(l, (1.0 + w)) else: tmp = math.pow(l, 1.0) * (1.0 - w) return tmp
function code(w, l) tmp = 0.0 if (l <= 0.14) tmp = Float64(1.0 * (l ^ Float64(1.0 + w))); else tmp = Float64((l ^ 1.0) * Float64(1.0 - w)); end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (l <= 0.14) tmp = 1.0 * (l ^ (1.0 + w)); else tmp = (l ^ 1.0) * (1.0 - w); end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[l, 0.14], N[(1.0 * N[Power[l, N[(1.0 + w), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[l, 1.0], $MachinePrecision] * N[(1.0 - w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 0.14:\\
\;\;\;\;1 \cdot {\ell}^{\left(1 + w\right)}\\
\mathbf{else}:\\
\;\;\;\;{\ell}^{1} \cdot \left(1 - w\right)\\
\end{array}
\end{array}
if l < 0.14000000000000001Initial program 99.4%
Taylor expanded in w around 0
Applied rewrites71.2%
Taylor expanded in w around 0
lower-+.f6484.7
Applied rewrites84.7%
if 0.14000000000000001 < l Initial program 99.4%
Taylor expanded in w around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6471.9
Applied rewrites71.9%
Taylor expanded in w around 0
Applied rewrites63.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6463.6
Applied rewrites63.6%
(FPCore (w l) :precision binary64 (if (<= l 0.14) (* (+ (- w) 1.0) (fma (* l w) (log l) l)) (* (pow l 1.0) (- 1.0 w))))
double code(double w, double l) {
double tmp;
if (l <= 0.14) {
tmp = (-w + 1.0) * fma((l * w), log(l), l);
} else {
tmp = pow(l, 1.0) * (1.0 - w);
}
return tmp;
}
function code(w, l) tmp = 0.0 if (l <= 0.14) tmp = Float64(Float64(Float64(-w) + 1.0) * fma(Float64(l * w), log(l), l)); else tmp = Float64((l ^ 1.0) * Float64(1.0 - w)); end return tmp end
code[w_, l_] := If[LessEqual[l, 0.14], N[(N[((-w) + 1.0), $MachinePrecision] * N[(N[(l * w), $MachinePrecision] * N[Log[l], $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision], N[(N[Power[l, 1.0], $MachinePrecision] * N[(1.0 - w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 0.14:\\
\;\;\;\;\left(\left(-w\right) + 1\right) \cdot \mathsf{fma}\left(\ell \cdot w, \log \ell, \ell\right)\\
\mathbf{else}:\\
\;\;\;\;{\ell}^{1} \cdot \left(1 - w\right)\\
\end{array}
\end{array}
if l < 0.14000000000000001Initial program 99.4%
Taylor expanded in w around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6484.2
Applied rewrites84.2%
Taylor expanded in w around 0
mul-1-negN/A
lift-neg.f64N/A
+-commutativeN/A
lower-+.f6460.2
Applied rewrites60.2%
lift-fma.f64N/A
lift-*.f64N/A
lift-log.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-log.f6460.2
Applied rewrites60.2%
if 0.14000000000000001 < l Initial program 99.4%
Taylor expanded in w around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6471.9
Applied rewrites71.9%
Taylor expanded in w around 0
Applied rewrites63.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6463.6
Applied rewrites63.6%
(FPCore (w l) :precision binary64 (if (<= w -4.5e+248) (* (+ (- w) 1.0) (* (* (log l) w) l)) (if (<= w -1000.0) (* (- w) (pow l 1.0)) (fma (* (- (log l) 1.0) w) l l))))
double code(double w, double l) {
double tmp;
if (w <= -4.5e+248) {
tmp = (-w + 1.0) * ((log(l) * w) * l);
} else if (w <= -1000.0) {
tmp = -w * pow(l, 1.0);
} else {
tmp = fma(((log(l) - 1.0) * w), l, l);
}
return tmp;
}
function code(w, l) tmp = 0.0 if (w <= -4.5e+248) tmp = Float64(Float64(Float64(-w) + 1.0) * Float64(Float64(log(l) * w) * l)); elseif (w <= -1000.0) tmp = Float64(Float64(-w) * (l ^ 1.0)); else tmp = fma(Float64(Float64(log(l) - 1.0) * w), l, l); end return tmp end
code[w_, l_] := If[LessEqual[w, -4.5e+248], N[(N[((-w) + 1.0), $MachinePrecision] * N[(N[(N[Log[l], $MachinePrecision] * w), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[w, -1000.0], N[((-w) * N[Power[l, 1.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Log[l], $MachinePrecision] - 1.0), $MachinePrecision] * w), $MachinePrecision] * l + l), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -4.5 \cdot 10^{+248}:\\
\;\;\;\;\left(\left(-w\right) + 1\right) \cdot \left(\left(\log \ell \cdot w\right) \cdot \ell\right)\\
\mathbf{elif}\;w \leq -1000:\\
\;\;\;\;\left(-w\right) \cdot {\ell}^{1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\log \ell - 1\right) \cdot w, \ell, \ell\right)\\
\end{array}
\end{array}
if w < -4.4999999999999996e248Initial program 99.4%
Taylor expanded in w around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6484.2
Applied rewrites84.2%
Taylor expanded in w around 0
mul-1-negN/A
lift-neg.f64N/A
+-commutativeN/A
lower-+.f6460.2
Applied rewrites60.2%
Taylor expanded in w around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift-*.f647.1
Applied rewrites7.1%
if -4.4999999999999996e248 < w < -1e3Initial program 99.4%
Taylor expanded in w around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6471.9
Applied rewrites71.9%
Taylor expanded in w around 0
Applied rewrites63.6%
Taylor expanded in w around inf
mul-1-negN/A
lower-neg.f6411.0
Applied rewrites11.0%
if -1e3 < w Initial program 99.4%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-pow.f64N/A
*-commutativeN/A
exp-negN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-pow.f64N/A
lift-exp.f64N/A
lift-exp.f6499.4
Applied rewrites99.4%
lift-/.f64N/A
lift-*.f64N/A
lift-exp.f64N/A
lift-pow.f64N/A
lift-exp.f64N/A
*-rgt-identityN/A
pow-to-expN/A
div-expN/A
lower-exp.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift-log.f64N/A
lift-exp.f6494.8
Applied rewrites94.8%
Taylor expanded in w around 0
exp-diffN/A
pow-to-expN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6457.0
Applied rewrites57.0%
(FPCore (w l) :precision binary64 (if (<= w -1.3e+189) (* (+ (- w) 1.0) (* (* (log l) w) l)) l))
double code(double w, double l) {
double tmp;
if (w <= -1.3e+189) {
tmp = (-w + 1.0) * ((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 <= (-1.3d+189)) then
tmp = (-w + 1.0d0) * ((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 <= -1.3e+189) {
tmp = (-w + 1.0) * ((Math.log(l) * w) * l);
} else {
tmp = l;
}
return tmp;
}
def code(w, l): tmp = 0 if w <= -1.3e+189: tmp = (-w + 1.0) * ((math.log(l) * w) * l) else: tmp = l return tmp
function code(w, l) tmp = 0.0 if (w <= -1.3e+189) tmp = Float64(Float64(Float64(-w) + 1.0) * Float64(Float64(log(l) * w) * l)); else tmp = l; end return tmp end
function tmp_2 = code(w, l) tmp = 0.0; if (w <= -1.3e+189) tmp = (-w + 1.0) * ((log(l) * w) * l); else tmp = l; end tmp_2 = tmp; end
code[w_, l_] := If[LessEqual[w, -1.3e+189], N[(N[((-w) + 1.0), $MachinePrecision] * N[(N[(N[Log[l], $MachinePrecision] * w), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision], l]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -1.3 \cdot 10^{+189}:\\
\;\;\;\;\left(\left(-w\right) + 1\right) \cdot \left(\left(\log \ell \cdot w\right) \cdot \ell\right)\\
\mathbf{else}:\\
\;\;\;\;\ell\\
\end{array}
\end{array}
if w < -1.29999999999999991e189Initial program 99.4%
Taylor expanded in w around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6484.2
Applied rewrites84.2%
Taylor expanded in w around 0
mul-1-negN/A
lift-neg.f64N/A
+-commutativeN/A
lower-+.f6460.2
Applied rewrites60.2%
Taylor expanded in w around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift-*.f647.1
Applied rewrites7.1%
if -1.29999999999999991e189 < w Initial program 99.4%
Taylor expanded in w around 0
Applied rewrites57.0%
(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.4%
Taylor expanded in w around 0
Applied rewrites57.0%
herbie shell --seed 2025140
(FPCore (w l)
:name "exp-w (used to crash)"
:precision binary64
(* (exp (- w)) (pow l (exp w))))