
(FPCore (wj x) :precision binary64 (let* ((t_0 (* wj (exp wj)))) (- wj (/ (- t_0 x) (+ (exp wj) t_0)))))
double code(double wj, double x) {
double t_0 = wj * exp(wj);
return wj - ((t_0 - x) / (exp(wj) + t_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(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: t_0
t_0 = wj * exp(wj)
code = wj - ((t_0 - x) / (exp(wj) + t_0))
end function
public static double code(double wj, double x) {
double t_0 = wj * Math.exp(wj);
return wj - ((t_0 - x) / (Math.exp(wj) + t_0));
}
def code(wj, x): t_0 = wj * math.exp(wj) return wj - ((t_0 - x) / (math.exp(wj) + t_0))
function code(wj, x) t_0 = Float64(wj * exp(wj)) return Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0))) end
function tmp = code(wj, x) t_0 = wj * exp(wj); tmp = wj - ((t_0 - x) / (exp(wj) + t_0)); end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
wj - \frac{t\_0 - x}{e^{wj} + t\_0}
\end{array}
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (wj x) :precision binary64 (let* ((t_0 (* wj (exp wj)))) (- wj (/ (- t_0 x) (+ (exp wj) t_0)))))
double code(double wj, double x) {
double t_0 = wj * exp(wj);
return wj - ((t_0 - x) / (exp(wj) + t_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(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: t_0
t_0 = wj * exp(wj)
code = wj - ((t_0 - x) / (exp(wj) + t_0))
end function
public static double code(double wj, double x) {
double t_0 = wj * Math.exp(wj);
return wj - ((t_0 - x) / (Math.exp(wj) + t_0));
}
def code(wj, x): t_0 = wj * math.exp(wj) return wj - ((t_0 - x) / (math.exp(wj) + t_0))
function code(wj, x) t_0 = Float64(wj * exp(wj)) return Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0))) end
function tmp = code(wj, x) t_0 = wj * exp(wj); tmp = wj - ((t_0 - x) / (exp(wj) + t_0)); end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
wj - \frac{t\_0 - x}{e^{wj} + t\_0}
\end{array}
\end{array}
(FPCore (wj x)
:precision binary64
(let* ((t_0 (* wj (exp wj)))
(t_1 (- wj (/ (- t_0 x) (+ (exp wj) t_0))))
(t_2 (exp (- wj))))
(if (<= t_1 -4.0)
(/ (fma t_2 x (- (fma wj wj wj) wj)) (- wj -1.0))
(if (<= t_1 5e-12)
(fma 1.0 x (fma wj wj (* (* (* (- wj 1.0) wj) wj) wj)))
(/ (fma (- t_2) x (fma wj (- -1.0 wj) wj)) (- -1.0 wj))))))
double code(double wj, double x) {
double t_0 = wj * exp(wj);
double t_1 = wj - ((t_0 - x) / (exp(wj) + t_0));
double t_2 = exp(-wj);
double tmp;
if (t_1 <= -4.0) {
tmp = fma(t_2, x, (fma(wj, wj, wj) - wj)) / (wj - -1.0);
} else if (t_1 <= 5e-12) {
tmp = fma(1.0, x, fma(wj, wj, ((((wj - 1.0) * wj) * wj) * wj)));
} else {
tmp = fma(-t_2, x, fma(wj, (-1.0 - wj), wj)) / (-1.0 - wj);
}
return tmp;
}
function code(wj, x) t_0 = Float64(wj * exp(wj)) t_1 = Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0))) t_2 = exp(Float64(-wj)) tmp = 0.0 if (t_1 <= -4.0) tmp = Float64(fma(t_2, x, Float64(fma(wj, wj, wj) - wj)) / Float64(wj - -1.0)); elseif (t_1 <= 5e-12) tmp = fma(1.0, x, fma(wj, wj, Float64(Float64(Float64(Float64(wj - 1.0) * wj) * wj) * wj))); else tmp = Float64(fma(Float64(-t_2), x, fma(wj, Float64(-1.0 - wj), wj)) / Float64(-1.0 - wj)); end return tmp end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Exp[(-wj)], $MachinePrecision]}, If[LessEqual[t$95$1, -4.0], N[(N[(t$95$2 * x + N[(N[(wj * wj + wj), $MachinePrecision] - wj), $MachinePrecision]), $MachinePrecision] / N[(wj - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-12], N[(1.0 * x + N[(wj * wj + N[(N[(N[(N[(wj - 1.0), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-t$95$2) * x + N[(wj * N[(-1.0 - wj), $MachinePrecision] + wj), $MachinePrecision]), $MachinePrecision] / N[(-1.0 - wj), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
t_1 := wj - \frac{t\_0 - x}{e^{wj} + t\_0}\\
t_2 := e^{-wj}\\
\mathbf{if}\;t\_1 \leq -4:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_2, x, \mathsf{fma}\left(wj, wj, wj\right) - wj\right)}{wj - -1}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(1, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-t\_2, x, \mathsf{fma}\left(wj, -1 - wj, wj\right)\right)}{-1 - wj}\\
\end{array}
\end{array}
if (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < -4Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
lift-fma.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-flipN/A
metadata-evalN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6488.8
Applied rewrites88.8%
if -4 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 4.9999999999999997e-12Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
Taylor expanded in wj around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6498.2
Applied rewrites98.2%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lift-pow.f64N/A
unpow2N/A
lower-fma.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
Taylor expanded in wj around 0
Applied rewrites95.6%
if 4.9999999999999997e-12 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
lift-fma.f64N/A
lift-/.f64N/A
frac-2negN/A
associate-*l/N/A
lift--.f64N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
sub-to-fractionN/A
div-add-revN/A
lower-/.f64N/A
Applied rewrites88.8%
(FPCore (wj x)
:precision binary64
(let* ((t_0 (* wj (exp wj)))
(t_1 (- wj (/ (- t_0 x) (+ (exp wj) t_0))))
(t_2 (/ (fma (exp (- wj)) x (- (fma wj wj wj) wj)) (- wj -1.0))))
(if (<= t_1 -4.0)
t_2
(if (<= t_1 5e-12)
(fma 1.0 x (fma wj wj (* (* (* (- wj 1.0) wj) wj) wj)))
t_2))))
double code(double wj, double x) {
double t_0 = wj * exp(wj);
double t_1 = wj - ((t_0 - x) / (exp(wj) + t_0));
double t_2 = fma(exp(-wj), x, (fma(wj, wj, wj) - wj)) / (wj - -1.0);
double tmp;
if (t_1 <= -4.0) {
tmp = t_2;
} else if (t_1 <= 5e-12) {
tmp = fma(1.0, x, fma(wj, wj, ((((wj - 1.0) * wj) * wj) * wj)));
} else {
tmp = t_2;
}
return tmp;
}
function code(wj, x) t_0 = Float64(wj * exp(wj)) t_1 = Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0))) t_2 = Float64(fma(exp(Float64(-wj)), x, Float64(fma(wj, wj, wj) - wj)) / Float64(wj - -1.0)) tmp = 0.0 if (t_1 <= -4.0) tmp = t_2; elseif (t_1 <= 5e-12) tmp = fma(1.0, x, fma(wj, wj, Float64(Float64(Float64(Float64(wj - 1.0) * wj) * wj) * wj))); else tmp = t_2; end return tmp end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Exp[(-wj)], $MachinePrecision] * x + N[(N[(wj * wj + wj), $MachinePrecision] - wj), $MachinePrecision]), $MachinePrecision] / N[(wj - -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4.0], t$95$2, If[LessEqual[t$95$1, 5e-12], N[(1.0 * x + N[(wj * wj + N[(N[(N[(N[(wj - 1.0), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
t_1 := wj - \frac{t\_0 - x}{e^{wj} + t\_0}\\
t_2 := \frac{\mathsf{fma}\left(e^{-wj}, x, \mathsf{fma}\left(wj, wj, wj\right) - wj\right)}{wj - -1}\\
\mathbf{if}\;t\_1 \leq -4:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(1, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < -4 or 4.9999999999999997e-12 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
lift-fma.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-flipN/A
metadata-evalN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6488.8
Applied rewrites88.8%
if -4 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 4.9999999999999997e-12Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
Taylor expanded in wj around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6498.2
Applied rewrites98.2%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lift-pow.f64N/A
unpow2N/A
lower-fma.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
Taylor expanded in wj around 0
Applied rewrites95.6%
(FPCore (wj x)
:precision binary64
(let* ((t_0 (* wj (exp wj)))
(t_1 (- wj (/ (- t_0 x) (+ (exp wj) t_0))))
(t_2 (/ x (exp wj))))
(if (<= t_1 -4.0)
(fma (- t_2 wj) (/ 1.0 (- wj -1.0)) wj)
(if (<= t_1 5e-12)
(fma 1.0 x (fma wj wj (* (* (* (- wj 1.0) wj) wj) wj)))
(- wj (/ (- wj t_2) (- wj -1.0)))))))
double code(double wj, double x) {
double t_0 = wj * exp(wj);
double t_1 = wj - ((t_0 - x) / (exp(wj) + t_0));
double t_2 = x / exp(wj);
double tmp;
if (t_1 <= -4.0) {
tmp = fma((t_2 - wj), (1.0 / (wj - -1.0)), wj);
} else if (t_1 <= 5e-12) {
tmp = fma(1.0, x, fma(wj, wj, ((((wj - 1.0) * wj) * wj) * wj)));
} else {
tmp = wj - ((wj - t_2) / (wj - -1.0));
}
return tmp;
}
function code(wj, x) t_0 = Float64(wj * exp(wj)) t_1 = Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0))) t_2 = Float64(x / exp(wj)) tmp = 0.0 if (t_1 <= -4.0) tmp = fma(Float64(t_2 - wj), Float64(1.0 / Float64(wj - -1.0)), wj); elseif (t_1 <= 5e-12) tmp = fma(1.0, x, fma(wj, wj, Float64(Float64(Float64(Float64(wj - 1.0) * wj) * wj) * wj))); else tmp = Float64(wj - Float64(Float64(wj - t_2) / Float64(wj - -1.0))); end return tmp end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4.0], N[(N[(t$95$2 - wj), $MachinePrecision] * N[(1.0 / N[(wj - -1.0), $MachinePrecision]), $MachinePrecision] + wj), $MachinePrecision], If[LessEqual[t$95$1, 5e-12], N[(1.0 * x + N[(wj * wj + N[(N[(N[(N[(wj - 1.0), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj - N[(N[(wj - t$95$2), $MachinePrecision] / N[(wj - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
t_1 := wj - \frac{t\_0 - x}{e^{wj} + t\_0}\\
t_2 := \frac{x}{e^{wj}}\\
\mathbf{if}\;t\_1 \leq -4:\\
\;\;\;\;\mathsf{fma}\left(t\_2 - wj, \frac{1}{wj - -1}, wj\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(1, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj - t\_2}{wj - -1}\\
\end{array}
\end{array}
if (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < -4Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
lift-fma.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flipN/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6479.7
Applied rewrites79.7%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lower-/.f6479.7
Applied rewrites79.7%
if -4 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 4.9999999999999997e-12Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
Taylor expanded in wj around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6498.2
Applied rewrites98.2%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lift-pow.f64N/A
unpow2N/A
lower-fma.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
Taylor expanded in wj around 0
Applied rewrites95.6%
if 4.9999999999999997e-12 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
lift-fma.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flipN/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6479.7
Applied rewrites79.7%
(FPCore (wj x)
:precision binary64
(let* ((t_0 (* wj (exp wj)))
(t_1 (- wj (/ (- t_0 x) (+ (exp wj) t_0))))
(t_2 (- wj (/ (- wj (/ x (exp wj))) (- wj -1.0)))))
(if (<= t_1 -4.0)
t_2
(if (<= t_1 5e-12)
(fma 1.0 x (fma wj wj (* (* (* (- wj 1.0) wj) wj) wj)))
t_2))))
double code(double wj, double x) {
double t_0 = wj * exp(wj);
double t_1 = wj - ((t_0 - x) / (exp(wj) + t_0));
double t_2 = wj - ((wj - (x / exp(wj))) / (wj - -1.0));
double tmp;
if (t_1 <= -4.0) {
tmp = t_2;
} else if (t_1 <= 5e-12) {
tmp = fma(1.0, x, fma(wj, wj, ((((wj - 1.0) * wj) * wj) * wj)));
} else {
tmp = t_2;
}
return tmp;
}
function code(wj, x) t_0 = Float64(wj * exp(wj)) t_1 = Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0))) t_2 = Float64(wj - Float64(Float64(wj - Float64(x / exp(wj))) / Float64(wj - -1.0))) tmp = 0.0 if (t_1 <= -4.0) tmp = t_2; elseif (t_1 <= 5e-12) tmp = fma(1.0, x, fma(wj, wj, Float64(Float64(Float64(Float64(wj - 1.0) * wj) * wj) * wj))); else tmp = t_2; end return tmp end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(wj - N[(N[(wj - N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(wj - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4.0], t$95$2, If[LessEqual[t$95$1, 5e-12], N[(1.0 * x + N[(wj * wj + N[(N[(N[(N[(wj - 1.0), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
t_1 := wj - \frac{t\_0 - x}{e^{wj} + t\_0}\\
t_2 := wj - \frac{wj - \frac{x}{e^{wj}}}{wj - -1}\\
\mathbf{if}\;t\_1 \leq -4:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(1, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < -4 or 4.9999999999999997e-12 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
lift-fma.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flipN/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6479.7
Applied rewrites79.7%
if -4 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 4.9999999999999997e-12Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
Taylor expanded in wj around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6498.2
Applied rewrites98.2%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lift-pow.f64N/A
unpow2N/A
lower-fma.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
Taylor expanded in wj around 0
Applied rewrites95.6%
(FPCore (wj x) :precision binary64 (fma (/ (exp (- wj)) (- wj -1.0)) x (fma wj wj (* (* (* (- wj 1.0) wj) wj) wj))))
double code(double wj, double x) {
return fma((exp(-wj) / (wj - -1.0)), x, fma(wj, wj, ((((wj - 1.0) * wj) * wj) * wj)));
}
function code(wj, x) return fma(Float64(exp(Float64(-wj)) / Float64(wj - -1.0)), x, fma(wj, wj, Float64(Float64(Float64(Float64(wj - 1.0) * wj) * wj) * wj))) end
code[wj_, x_] := N[(N[(N[Exp[(-wj)], $MachinePrecision] / N[(wj - -1.0), $MachinePrecision]), $MachinePrecision] * x + N[(wj * wj + N[(N[(N[(N[(wj - 1.0), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{e^{-wj}}{wj - -1}, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right)
\end{array}
Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
Taylor expanded in wj around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6498.2
Applied rewrites98.2%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lift-pow.f64N/A
unpow2N/A
lower-fma.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
(FPCore (wj x) :precision binary64 (fma 1.0 x (fma wj wj (* (* (* (- wj 1.0) wj) wj) wj))))
double code(double wj, double x) {
return fma(1.0, x, fma(wj, wj, ((((wj - 1.0) * wj) * wj) * wj)));
}
function code(wj, x) return fma(1.0, x, fma(wj, wj, Float64(Float64(Float64(Float64(wj - 1.0) * wj) * wj) * wj))) end
code[wj_, x_] := N[(1.0 * x + N[(wj * wj + N[(N[(N[(N[(wj - 1.0), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision] * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(1, x, \mathsf{fma}\left(wj, wj, \left(\left(\left(wj - 1\right) \cdot wj\right) \cdot wj\right) \cdot wj\right)\right)
\end{array}
Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
Taylor expanded in wj around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6498.2
Applied rewrites98.2%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lift-pow.f64N/A
unpow2N/A
lower-fma.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
Taylor expanded in wj around 0
Applied rewrites95.6%
(FPCore (wj x) :precision binary64 (/ (* x (exp (- wj))) (+ 1.0 wj)))
double code(double wj, double x) {
return (x * exp(-wj)) / (1.0 + wj);
}
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(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = (x * exp(-wj)) / (1.0d0 + wj)
end function
public static double code(double wj, double x) {
return (x * Math.exp(-wj)) / (1.0 + wj);
}
def code(wj, x): return (x * math.exp(-wj)) / (1.0 + wj)
function code(wj, x) return Float64(Float64(x * exp(Float64(-wj))) / Float64(1.0 + wj)) end
function tmp = code(wj, x) tmp = (x * exp(-wj)) / (1.0 + wj); end
code[wj_, x_] := N[(N[(x * N[Exp[(-wj)], $MachinePrecision]), $MachinePrecision] / N[(1.0 + wj), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot e^{-wj}}{1 + wj}
\end{array}
Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f6485.9
Applied rewrites85.9%
(FPCore (wj x) :precision binary64 (* (/ (exp (- wj)) (- wj -1.0)) x))
double code(double wj, double x) {
return (exp(-wj) / (wj - -1.0)) * x;
}
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(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = (exp(-wj) / (wj - (-1.0d0))) * x
end function
public static double code(double wj, double x) {
return (Math.exp(-wj) / (wj - -1.0)) * x;
}
def code(wj, x): return (math.exp(-wj) / (wj - -1.0)) * x
function code(wj, x) return Float64(Float64(exp(Float64(-wj)) / Float64(wj - -1.0)) * x) end
function tmp = code(wj, x) tmp = (exp(-wj) / (wj - -1.0)) * x; end
code[wj_, x_] := N[(N[(N[Exp[(-wj)], $MachinePrecision] / N[(wj - -1.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{-wj}}{wj - -1} \cdot x
\end{array}
Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
lift-fma.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flipN/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6479.7
Applied rewrites79.7%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-+.f6485.9
Applied rewrites85.9%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
associate-/l/N/A
mult-flipN/A
lift-exp.f64N/A
exp-negN/A
lift-neg.f64N/A
lift-exp.f64N/A
associate-/l*N/A
lift-/.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6485.9
Applied rewrites85.9%
(FPCore (wj x) :precision binary64 (/ x (* (exp wj) (- wj -1.0))))
double code(double wj, double x) {
return x / (exp(wj) * (wj - -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(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x / (exp(wj) * (wj - (-1.0d0)))
end function
public static double code(double wj, double x) {
return x / (Math.exp(wj) * (wj - -1.0));
}
def code(wj, x): return x / (math.exp(wj) * (wj - -1.0))
function code(wj, x) return Float64(x / Float64(exp(wj) * Float64(wj - -1.0))) end
function tmp = code(wj, x) tmp = x / (exp(wj) * (wj - -1.0)); end
code[wj_, x_] := N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{e^{wj} \cdot \left(wj - -1\right)}
\end{array}
Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
lift-fma.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flipN/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6479.7
Applied rewrites79.7%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-+.f6485.9
Applied rewrites85.9%
lift-exp.f64N/A
sub-to-fractionN/A
lift-exp.f64N/A
associate-/l/N/A
*-commutativeN/A
sub-flipN/A
metadata-evalN/A
distribute-rgt1-inN/A
lift-exp.f64N/A
lift-exp.f6485.9
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f6485.9
Applied rewrites85.9%
(FPCore (wj x) :precision binary64 (/ x (+ 1.0 (* wj (+ 2.0 (* 1.5 wj))))))
double code(double wj, double x) {
return x / (1.0 + (wj * (2.0 + (1.5 * wj))));
}
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(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x / (1.0d0 + (wj * (2.0d0 + (1.5d0 * wj))))
end function
public static double code(double wj, double x) {
return x / (1.0 + (wj * (2.0 + (1.5 * wj))));
}
def code(wj, x): return x / (1.0 + (wj * (2.0 + (1.5 * wj))))
function code(wj, x) return Float64(x / Float64(1.0 + Float64(wj * Float64(2.0 + Float64(1.5 * wj))))) end
function tmp = code(wj, x) tmp = x / (1.0 + (wj * (2.0 + (1.5 * wj)))); end
code[wj_, x_] := N[(x / N[(1.0 + N[(wj * N[(2.0 + N[(1.5 * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1 + wj \cdot \left(2 + 1.5 \cdot wj\right)}
\end{array}
Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
lift-fma.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flipN/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6479.7
Applied rewrites79.7%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-+.f6485.9
Applied rewrites85.9%
Taylor expanded in wj around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6484.2
Applied rewrites84.2%
(FPCore (wj x) :precision binary64 (/ x (+ 1.0 (* 2.0 wj))))
double code(double wj, double x) {
return x / (1.0 + (2.0 * wj));
}
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(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x / (1.0d0 + (2.0d0 * wj))
end function
public static double code(double wj, double x) {
return x / (1.0 + (2.0 * wj));
}
def code(wj, x): return x / (1.0 + (2.0 * wj))
function code(wj, x) return Float64(x / Float64(1.0 + Float64(2.0 * wj))) end
function tmp = code(wj, x) tmp = x / (1.0 + (2.0 * wj)); end
code[wj_, x_] := N[(x / N[(1.0 + N[(2.0 * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1 + 2 \cdot wj}
\end{array}
Initial program 77.6%
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
lift--.f64N/A
associate--r-N/A
div-addN/A
+-commutativeN/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites88.8%
lift-fma.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flipN/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6479.7
Applied rewrites79.7%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-+.f6485.9
Applied rewrites85.9%
Taylor expanded in wj around 0
lower-+.f64N/A
lower-*.f6484.0
Applied rewrites84.0%
(FPCore (wj x) :precision binary64 (+ x (* -2.0 (* wj x))))
double code(double wj, double x) {
return x + (-2.0 * (wj * x));
}
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(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x + ((-2.0d0) * (wj * x))
end function
public static double code(double wj, double x) {
return x + (-2.0 * (wj * x));
}
def code(wj, x): return x + (-2.0 * (wj * x))
function code(wj, x) return Float64(x + Float64(-2.0 * Float64(wj * x))) end
function tmp = code(wj, x) tmp = x + (-2.0 * (wj * x)); end
code[wj_, x_] := N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + -2 \cdot \left(wj \cdot x\right)
\end{array}
Initial program 77.6%
Taylor expanded in wj around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6483.9
Applied rewrites83.9%
(FPCore (wj x) :precision binary64 x)
double code(double wj, double x) {
return x;
}
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(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x
end function
public static double code(double wj, double x) {
return x;
}
def code(wj, x): return x
function code(wj, x) return x end
function tmp = code(wj, x) tmp = x; end
code[wj_, x_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 77.6%
Taylor expanded in wj around 0
Applied rewrites83.4%
(FPCore (wj x) :precision binary64 (- wj (- (/ wj (+ wj 1.0)) (/ x (+ (exp wj) (* wj (exp wj)))))))
double code(double wj, double x) {
return wj - ((wj / (wj + 1.0)) - (x / (exp(wj) + (wj * exp(wj)))));
}
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(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = wj - ((wj / (wj + 1.0d0)) - (x / (exp(wj) + (wj * exp(wj)))))
end function
public static double code(double wj, double x) {
return wj - ((wj / (wj + 1.0)) - (x / (Math.exp(wj) + (wj * Math.exp(wj)))));
}
def code(wj, x): return wj - ((wj / (wj + 1.0)) - (x / (math.exp(wj) + (wj * math.exp(wj)))))
function code(wj, x) return Float64(wj - Float64(Float64(wj / Float64(wj + 1.0)) - Float64(x / Float64(exp(wj) + Float64(wj * exp(wj)))))) end
function tmp = code(wj, x) tmp = wj - ((wj / (wj + 1.0)) - (x / (exp(wj) + (wj * exp(wj))))); end
code[wj_, x_] := N[(wj - N[(N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision] - N[(x / N[(N[Exp[wj], $MachinePrecision] + N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)
\end{array}
herbie shell --seed 2025156
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:precision binary64
:alt
(! :herbie-platform c (let ((ew (exp wj))) (- wj (- (/ wj (+ wj 1)) (/ x (+ ew (* wj ew)))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))