
(FPCore (x) :precision binary64 (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))
double code(double x) {
return (2.0 / (1.0 + exp((-2.0 * x)))) - 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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (2.0d0 / (1.0d0 + exp(((-2.0d0) * x)))) - 1.0d0
end function
public static double code(double x) {
return (2.0 / (1.0 + Math.exp((-2.0 * x)))) - 1.0;
}
def code(x): return (2.0 / (1.0 + math.exp((-2.0 * x)))) - 1.0
function code(x) return Float64(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) - 1.0) end
function tmp = code(x) tmp = (2.0 / (1.0 + exp((-2.0 * x)))) - 1.0; end
code[x_] := N[(N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{1 + e^{-2 \cdot x}} - 1
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))
double code(double x) {
return (2.0 / (1.0 + exp((-2.0 * x)))) - 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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (2.0d0 / (1.0d0 + exp(((-2.0d0) * x)))) - 1.0d0
end function
public static double code(double x) {
return (2.0 / (1.0 + Math.exp((-2.0 * x)))) - 1.0;
}
def code(x): return (2.0 / (1.0 + math.exp((-2.0 * x)))) - 1.0
function code(x) return Float64(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) - 1.0) end
function tmp = code(x) tmp = (2.0 / (1.0 + exp((-2.0 * x)))) - 1.0; end
code[x_] := N[(N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{1 + e^{-2 \cdot x}} - 1
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (- (/ 2.0 (- (exp (* x -2.0)) -1.0)) 1.0)))
(if (<= x -0.006)
t_0
(if (<= x 0.0076)
(fma
(fma (* x x) 0.13333333333333333 -0.3333333333333333)
(* (* x x) x)
x)
t_0))))
double code(double x) {
double t_0 = (2.0 / (exp((x * -2.0)) - -1.0)) - 1.0;
double tmp;
if (x <= -0.006) {
tmp = t_0;
} else if (x <= 0.0076) {
tmp = fma(fma((x * x), 0.13333333333333333, -0.3333333333333333), ((x * x) * x), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x) t_0 = Float64(Float64(2.0 / Float64(exp(Float64(x * -2.0)) - -1.0)) - 1.0) tmp = 0.0 if (x <= -0.006) tmp = t_0; elseif (x <= 0.0076) tmp = fma(fma(Float64(x * x), 0.13333333333333333, -0.3333333333333333), Float64(Float64(x * x) * x), x); else tmp = t_0; end return tmp end
code[x_] := Block[{t$95$0 = N[(N[(2.0 / N[(N[Exp[N[(x * -2.0), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[x, -0.006], t$95$0, If[LessEqual[x, 0.0076], N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333 + -0.3333333333333333), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{e^{x \cdot -2} - -1} - 1\\
\mathbf{if}\;x \leq -0.006:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 0.0076:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), \left(x \cdot x\right) \cdot x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -0.0060000000000000001 or 0.00759999999999999998 < x Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift-exp.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
if -0.0060000000000000001 < x < 0.00759999999999999998Initial program 8.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
pow2N/A
pow2N/A
*-commutativeN/A
distribute-rgt-inN/A
Applied rewrites100.0%
(FPCore (x)
:precision binary64
(if (<= x -0.98)
(- (/ 2.0 (fma (fma (fma -1.3333333333333333 x 2.0) x -2.0) x 2.0)) 1.0)
(if (<= x 1.35)
(fma
(fma (* x x) 0.13333333333333333 -0.3333333333333333)
(* (* x x) x)
x)
(/ (+ x x) (- x -1.0)))))
double code(double x) {
double tmp;
if (x <= -0.98) {
tmp = (2.0 / fma(fma(fma(-1.3333333333333333, x, 2.0), x, -2.0), x, 2.0)) - 1.0;
} else if (x <= 1.35) {
tmp = fma(fma((x * x), 0.13333333333333333, -0.3333333333333333), ((x * x) * x), x);
} else {
tmp = (x + x) / (x - -1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -0.98) tmp = Float64(Float64(2.0 / fma(fma(fma(-1.3333333333333333, x, 2.0), x, -2.0), x, 2.0)) - 1.0); elseif (x <= 1.35) tmp = fma(fma(Float64(x * x), 0.13333333333333333, -0.3333333333333333), Float64(Float64(x * x) * x), x); else tmp = Float64(Float64(x + x) / Float64(x - -1.0)); end return tmp end
code[x_] := If[LessEqual[x, -0.98], N[(N[(2.0 / N[(N[(N[(-1.3333333333333333 * x + 2.0), $MachinePrecision] * x + -2.0), $MachinePrecision] * x + 2.0), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], If[LessEqual[x, 1.35], N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333 + -0.3333333333333333), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] + x), $MachinePrecision], N[(N[(x + x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.98:\\
\;\;\;\;\frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-1.3333333333333333, x, 2\right), x, -2\right), x, 2\right)} - 1\\
\mathbf{elif}\;x \leq 1.35:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), \left(x \cdot x\right) \cdot x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x}{x - -1}\\
\end{array}
\end{array}
if x < -0.97999999999999998Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6499.1
Applied rewrites99.1%
if -0.97999999999999998 < x < 1.3500000000000001Initial program 8.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
pow2N/A
pow2N/A
*-commutativeN/A
distribute-rgt-inN/A
Applied rewrites99.6%
if 1.3500000000000001 < x Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f645.4
Applied rewrites5.4%
Taylor expanded in x around inf
Applied rewrites5.4%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
Applied rewrites5.1%
Taylor expanded in x around 0
count-2-revN/A
lower-+.f6418.7
Applied rewrites18.7%
(FPCore (x)
:precision binary64
(if (<= x -1.15)
(- (/ 2.0 (fma (fma x 2.0 -2.0) x 2.0)) 1.0)
(if (<= x 1.35)
(fma
(fma (* x x) 0.13333333333333333 -0.3333333333333333)
(* (* x x) x)
x)
(/ (+ x x) (- x -1.0)))))
double code(double x) {
double tmp;
if (x <= -1.15) {
tmp = (2.0 / fma(fma(x, 2.0, -2.0), x, 2.0)) - 1.0;
} else if (x <= 1.35) {
tmp = fma(fma((x * x), 0.13333333333333333, -0.3333333333333333), ((x * x) * x), x);
} else {
tmp = (x + x) / (x - -1.0);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -1.15) tmp = Float64(Float64(2.0 / fma(fma(x, 2.0, -2.0), x, 2.0)) - 1.0); elseif (x <= 1.35) tmp = fma(fma(Float64(x * x), 0.13333333333333333, -0.3333333333333333), Float64(Float64(x * x) * x), x); else tmp = Float64(Float64(x + x) / Float64(x - -1.0)); end return tmp end
code[x_] := If[LessEqual[x, -1.15], N[(N[(2.0 / N[(N[(x * 2.0 + -2.0), $MachinePrecision] * x + 2.0), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], If[LessEqual[x, 1.35], N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333 + -0.3333333333333333), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] + x), $MachinePrecision], N[(N[(x + x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15:\\
\;\;\;\;\frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x, 2, -2\right), x, 2\right)} - 1\\
\mathbf{elif}\;x \leq 1.35:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.13333333333333333, -0.3333333333333333\right), \left(x \cdot x\right) \cdot x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x}{x - -1}\\
\end{array}
\end{array}
if x < -1.1499999999999999Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6498.8
Applied rewrites98.8%
if -1.1499999999999999 < x < 1.3500000000000001Initial program 8.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.5
Applied rewrites99.5%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
pow2N/A
pow2N/A
*-commutativeN/A
distribute-rgt-inN/A
Applied rewrites99.6%
if 1.3500000000000001 < x Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f645.4
Applied rewrites5.4%
Taylor expanded in x around inf
Applied rewrites5.4%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
Applied rewrites5.1%
Taylor expanded in x around 0
count-2-revN/A
lower-+.f6418.7
Applied rewrites18.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0)))
(if (<= t_0 -0.5)
(- (/ 2.0 (fma (fma x 2.0 -2.0) x 2.0)) 1.0)
(if (<= t_0 1e-7)
(fma (* (* x x) x) -0.3333333333333333 x)
(/ (+ x x) (- x -1.0))))))
double code(double x) {
double t_0 = (2.0 / (1.0 + exp((-2.0 * x)))) - 1.0;
double tmp;
if (t_0 <= -0.5) {
tmp = (2.0 / fma(fma(x, 2.0, -2.0), x, 2.0)) - 1.0;
} else if (t_0 <= 1e-7) {
tmp = fma(((x * x) * x), -0.3333333333333333, x);
} else {
tmp = (x + x) / (x - -1.0);
}
return tmp;
}
function code(x) t_0 = Float64(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) - 1.0) tmp = 0.0 if (t_0 <= -0.5) tmp = Float64(Float64(2.0 / fma(fma(x, 2.0, -2.0), x, 2.0)) - 1.0); elseif (t_0 <= 1e-7) tmp = fma(Float64(Float64(x * x) * x), -0.3333333333333333, x); else tmp = Float64(Float64(x + x) / Float64(x - -1.0)); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[t$95$0, -0.5], N[(N[(2.0 / N[(N[(x * 2.0 + -2.0), $MachinePrecision] * x + 2.0), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], If[LessEqual[t$95$0, 1e-7], N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * -0.3333333333333333 + x), $MachinePrecision], N[(N[(x + x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{1 + e^{-2 \cdot x}} - 1\\
\mathbf{if}\;t\_0 \leq -0.5:\\
\;\;\;\;\frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x, 2, -2\right), x, 2\right)} - 1\\
\mathbf{elif}\;t\_0 \leq 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(\left(x \cdot x\right) \cdot x, -0.3333333333333333, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x}{x - -1}\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) #s(literal 1 binary64)) < -0.5Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6498.7
Applied rewrites98.7%
if -0.5 < (-.f64 (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) #s(literal 1 binary64)) < 9.9999999999999995e-8Initial program 7.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
+-commutativeN/A
pow2N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
cube-multN/A
*-rgt-identityN/A
lower-fma.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f6499.7
Applied rewrites99.7%
if 9.9999999999999995e-8 < (-.f64 (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) #s(literal 1 binary64)) Initial program 99.5%
Taylor expanded in x around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f646.7
Applied rewrites6.7%
Taylor expanded in x around inf
Applied rewrites5.3%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
Applied rewrites5.0%
Taylor expanded in x around 0
count-2-revN/A
lower-+.f6418.7
Applied rewrites18.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ 1.0 (exp (* -2.0 x)))))
(if (<= t_0 1.5)
(/ (+ x x) (- x -1.0))
(if (<= t_0 4.0)
(fma (* (* x x) x) -0.3333333333333333 x)
(- (/ 2.0 (fma (+ x x) x 2.0)) 1.0)))))
double code(double x) {
double t_0 = 1.0 + exp((-2.0 * x));
double tmp;
if (t_0 <= 1.5) {
tmp = (x + x) / (x - -1.0);
} else if (t_0 <= 4.0) {
tmp = fma(((x * x) * x), -0.3333333333333333, x);
} else {
tmp = (2.0 / fma((x + x), x, 2.0)) - 1.0;
}
return tmp;
}
function code(x) t_0 = Float64(1.0 + exp(Float64(-2.0 * x))) tmp = 0.0 if (t_0 <= 1.5) tmp = Float64(Float64(x + x) / Float64(x - -1.0)); elseif (t_0 <= 4.0) tmp = fma(Float64(Float64(x * x) * x), -0.3333333333333333, x); else tmp = Float64(Float64(2.0 / fma(Float64(x + x), x, 2.0)) - 1.0); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1.5], N[(N[(x + x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4.0], N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * -0.3333333333333333 + x), $MachinePrecision], N[(N[(2.0 / N[(N[(x + x), $MachinePrecision] * x + 2.0), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + e^{-2 \cdot x}\\
\mathbf{if}\;t\_0 \leq 1.5:\\
\;\;\;\;\frac{x + x}{x - -1}\\
\mathbf{elif}\;t\_0 \leq 4:\\
\;\;\;\;\mathsf{fma}\left(\left(x \cdot x\right) \cdot x, -0.3333333333333333, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\mathsf{fma}\left(x + x, x, 2\right)} - 1\\
\end{array}
\end{array}
if (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x))) < 1.5Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f645.5
Applied rewrites5.5%
Taylor expanded in x around inf
Applied rewrites5.4%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
Applied rewrites5.1%
Taylor expanded in x around 0
count-2-revN/A
lower-+.f6418.7
Applied rewrites18.7%
if 1.5 < (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x))) < 4Initial program 8.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
+-commutativeN/A
pow2N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
cube-multN/A
*-rgt-identityN/A
lower-fma.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f6499.6
Applied rewrites99.6%
if 4 < (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x))) Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6498.7
Applied rewrites98.7%
Taylor expanded in x around inf
count-2-revN/A
lower-+.f6498.7
Applied rewrites98.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ 1.0 (exp (* -2.0 x)))))
(if (<= t_0 1.5)
(/ (+ x x) (- x -1.0))
(if (<= t_0 4.0)
(fma (* (* x x) x) -0.3333333333333333 x)
(- (/ 2.0 (* (+ x x) x)) 1.0)))))
double code(double x) {
double t_0 = 1.0 + exp((-2.0 * x));
double tmp;
if (t_0 <= 1.5) {
tmp = (x + x) / (x - -1.0);
} else if (t_0 <= 4.0) {
tmp = fma(((x * x) * x), -0.3333333333333333, x);
} else {
tmp = (2.0 / ((x + x) * x)) - 1.0;
}
return tmp;
}
function code(x) t_0 = Float64(1.0 + exp(Float64(-2.0 * x))) tmp = 0.0 if (t_0 <= 1.5) tmp = Float64(Float64(x + x) / Float64(x - -1.0)); elseif (t_0 <= 4.0) tmp = fma(Float64(Float64(x * x) * x), -0.3333333333333333, x); else tmp = Float64(Float64(2.0 / Float64(Float64(x + x) * x)) - 1.0); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1.5], N[(N[(x + x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4.0], N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * -0.3333333333333333 + x), $MachinePrecision], N[(N[(2.0 / N[(N[(x + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + e^{-2 \cdot x}\\
\mathbf{if}\;t\_0 \leq 1.5:\\
\;\;\;\;\frac{x + x}{x - -1}\\
\mathbf{elif}\;t\_0 \leq 4:\\
\;\;\;\;\mathsf{fma}\left(\left(x \cdot x\right) \cdot x, -0.3333333333333333, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\left(x + x\right) \cdot x} - 1\\
\end{array}
\end{array}
if (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x))) < 1.5Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f645.5
Applied rewrites5.5%
Taylor expanded in x around inf
Applied rewrites5.4%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
Applied rewrites5.1%
Taylor expanded in x around 0
count-2-revN/A
lower-+.f6418.7
Applied rewrites18.7%
if 1.5 < (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x))) < 4Initial program 8.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
+-commutativeN/A
pow2N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
cube-multN/A
*-rgt-identityN/A
lower-fma.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f6499.6
Applied rewrites99.6%
if 4 < (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x))) Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6498.7
Applied rewrites98.7%
Taylor expanded in x around inf
pow2N/A
associate-*r*N/A
lower-*.f64N/A
count-2-revN/A
lower-+.f6498.7
Applied rewrites98.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ 1.0 (exp (* -2.0 x)))))
(if (<= t_0 1.5)
(/ (+ x x) (- x -1.0))
(if (<= t_0 4.0)
(fma (* (* x x) x) -0.3333333333333333 x)
(- (/ -1.0 (- x 1.0)) 1.0)))))
double code(double x) {
double t_0 = 1.0 + exp((-2.0 * x));
double tmp;
if (t_0 <= 1.5) {
tmp = (x + x) / (x - -1.0);
} else if (t_0 <= 4.0) {
tmp = fma(((x * x) * x), -0.3333333333333333, x);
} else {
tmp = (-1.0 / (x - 1.0)) - 1.0;
}
return tmp;
}
function code(x) t_0 = Float64(1.0 + exp(Float64(-2.0 * x))) tmp = 0.0 if (t_0 <= 1.5) tmp = Float64(Float64(x + x) / Float64(x - -1.0)); elseif (t_0 <= 4.0) tmp = fma(Float64(Float64(x * x) * x), -0.3333333333333333, x); else tmp = Float64(Float64(-1.0 / Float64(x - 1.0)) - 1.0); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1.5], N[(N[(x + x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4.0], N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * -0.3333333333333333 + x), $MachinePrecision], N[(N[(-1.0 / N[(x - 1.0), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + e^{-2 \cdot x}\\
\mathbf{if}\;t\_0 \leq 1.5:\\
\;\;\;\;\frac{x + x}{x - -1}\\
\mathbf{elif}\;t\_0 \leq 4:\\
\;\;\;\;\mathsf{fma}\left(\left(x \cdot x\right) \cdot x, -0.3333333333333333, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{x - 1} - 1\\
\end{array}
\end{array}
if (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x))) < 1.5Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f645.5
Applied rewrites5.5%
Taylor expanded in x around inf
Applied rewrites5.4%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
Applied rewrites5.1%
Taylor expanded in x around 0
count-2-revN/A
lower-+.f6418.7
Applied rewrites18.7%
if 1.5 < (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x))) < 4Initial program 8.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
+-commutativeN/A
pow2N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
associate-*r*N/A
pow2N/A
cube-multN/A
*-rgt-identityN/A
lower-fma.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f6499.6
Applied rewrites99.6%
if 4 < (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x))) Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f645.4
Applied rewrites5.4%
lift--.f64N/A
metadata-evalN/A
fp-cancel-sub-signN/A
metadata-evalN/A
metadata-evalN/A
flip-+N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
pow2N/A
metadata-evalN/A
fp-cancel-sign-subN/A
metadata-evalN/A
pow2N/A
lower-fma.f64N/A
lower--.f645.0
Applied rewrites5.0%
Taylor expanded in x around 0
Applied rewrites97.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0)))
(if (<= t_0 -0.5)
(- (/ -1.0 (- x 1.0)) 1.0)
(if (<= t_0 1e-7)
(* (fma (* x x) -0.3333333333333333 1.0) x)
(/ (+ x x) (- x -1.0))))))
double code(double x) {
double t_0 = (2.0 / (1.0 + exp((-2.0 * x)))) - 1.0;
double tmp;
if (t_0 <= -0.5) {
tmp = (-1.0 / (x - 1.0)) - 1.0;
} else if (t_0 <= 1e-7) {
tmp = fma((x * x), -0.3333333333333333, 1.0) * x;
} else {
tmp = (x + x) / (x - -1.0);
}
return tmp;
}
function code(x) t_0 = Float64(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) - 1.0) tmp = 0.0 if (t_0 <= -0.5) tmp = Float64(Float64(-1.0 / Float64(x - 1.0)) - 1.0); elseif (t_0 <= 1e-7) tmp = Float64(fma(Float64(x * x), -0.3333333333333333, 1.0) * x); else tmp = Float64(Float64(x + x) / Float64(x - -1.0)); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[t$95$0, -0.5], N[(N[(-1.0 / N[(x - 1.0), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], If[LessEqual[t$95$0, 1e-7], N[(N[(N[(x * x), $MachinePrecision] * -0.3333333333333333 + 1.0), $MachinePrecision] * x), $MachinePrecision], N[(N[(x + x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{1 + e^{-2 \cdot x}} - 1\\
\mathbf{if}\;t\_0 \leq -0.5:\\
\;\;\;\;\frac{-1}{x - 1} - 1\\
\mathbf{elif}\;t\_0 \leq 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, -0.3333333333333333, 1\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x}{x - -1}\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) #s(literal 1 binary64)) < -0.5Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f645.4
Applied rewrites5.4%
lift--.f64N/A
metadata-evalN/A
fp-cancel-sub-signN/A
metadata-evalN/A
metadata-evalN/A
flip-+N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
pow2N/A
metadata-evalN/A
fp-cancel-sign-subN/A
metadata-evalN/A
pow2N/A
lower-fma.f64N/A
lower--.f645.0
Applied rewrites5.0%
Taylor expanded in x around 0
Applied rewrites97.7%
if -0.5 < (-.f64 (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) #s(literal 1 binary64)) < 9.9999999999999995e-8Initial program 7.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.7
Applied rewrites99.7%
if 9.9999999999999995e-8 < (-.f64 (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) #s(literal 1 binary64)) Initial program 99.5%
Taylor expanded in x around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f646.7
Applied rewrites6.7%
Taylor expanded in x around inf
Applied rewrites5.3%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
Applied rewrites5.0%
Taylor expanded in x around 0
count-2-revN/A
lower-+.f6418.7
Applied rewrites18.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0)))
(if (<= t_0 -0.5)
(- (/ -1.0 (- x 1.0)) 1.0)
(if (<= t_0 1e-7) x (/ (+ x x) (- x -1.0))))))
double code(double x) {
double t_0 = (2.0 / (1.0 + exp((-2.0 * x)))) - 1.0;
double tmp;
if (t_0 <= -0.5) {
tmp = (-1.0 / (x - 1.0)) - 1.0;
} else if (t_0 <= 1e-7) {
tmp = x;
} else {
tmp = (x + x) / (x - -1.0);
}
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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (2.0d0 / (1.0d0 + exp(((-2.0d0) * x)))) - 1.0d0
if (t_0 <= (-0.5d0)) then
tmp = ((-1.0d0) / (x - 1.0d0)) - 1.0d0
else if (t_0 <= 1d-7) then
tmp = x
else
tmp = (x + x) / (x - (-1.0d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (2.0 / (1.0 + Math.exp((-2.0 * x)))) - 1.0;
double tmp;
if (t_0 <= -0.5) {
tmp = (-1.0 / (x - 1.0)) - 1.0;
} else if (t_0 <= 1e-7) {
tmp = x;
} else {
tmp = (x + x) / (x - -1.0);
}
return tmp;
}
def code(x): t_0 = (2.0 / (1.0 + math.exp((-2.0 * x)))) - 1.0 tmp = 0 if t_0 <= -0.5: tmp = (-1.0 / (x - 1.0)) - 1.0 elif t_0 <= 1e-7: tmp = x else: tmp = (x + x) / (x - -1.0) return tmp
function code(x) t_0 = Float64(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) - 1.0) tmp = 0.0 if (t_0 <= -0.5) tmp = Float64(Float64(-1.0 / Float64(x - 1.0)) - 1.0); elseif (t_0 <= 1e-7) tmp = x; else tmp = Float64(Float64(x + x) / Float64(x - -1.0)); end return tmp end
function tmp_2 = code(x) t_0 = (2.0 / (1.0 + exp((-2.0 * x)))) - 1.0; tmp = 0.0; if (t_0 <= -0.5) tmp = (-1.0 / (x - 1.0)) - 1.0; elseif (t_0 <= 1e-7) tmp = x; else tmp = (x + x) / (x - -1.0); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[t$95$0, -0.5], N[(N[(-1.0 / N[(x - 1.0), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], If[LessEqual[t$95$0, 1e-7], x, N[(N[(x + x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{1 + e^{-2 \cdot x}} - 1\\
\mathbf{if}\;t\_0 \leq -0.5:\\
\;\;\;\;\frac{-1}{x - 1} - 1\\
\mathbf{elif}\;t\_0 \leq 10^{-7}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x}{x - -1}\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) #s(literal 1 binary64)) < -0.5Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f645.4
Applied rewrites5.4%
lift--.f64N/A
metadata-evalN/A
fp-cancel-sub-signN/A
metadata-evalN/A
metadata-evalN/A
flip-+N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
pow2N/A
metadata-evalN/A
fp-cancel-sign-subN/A
metadata-evalN/A
pow2N/A
lower-fma.f64N/A
lower--.f645.0
Applied rewrites5.0%
Taylor expanded in x around 0
Applied rewrites97.7%
if -0.5 < (-.f64 (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) #s(literal 1 binary64)) < 9.9999999999999995e-8Initial program 7.8%
Taylor expanded in x around 0
Applied rewrites99.4%
if 9.9999999999999995e-8 < (-.f64 (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) #s(literal 1 binary64)) Initial program 99.5%
Taylor expanded in x around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f646.7
Applied rewrites6.7%
Taylor expanded in x around inf
Applied rewrites5.3%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
Applied rewrites5.0%
Taylor expanded in x around 0
count-2-revN/A
lower-+.f6418.7
Applied rewrites18.7%
(FPCore (x) :precision binary64 (if (<= x -1.35) (- (/ -1.0 (- x 1.0)) 1.0) x))
double code(double x) {
double tmp;
if (x <= -1.35) {
tmp = (-1.0 / (x - 1.0)) - 1.0;
} else {
tmp = x;
}
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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.35d0)) then
tmp = ((-1.0d0) / (x - 1.0d0)) - 1.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.35) {
tmp = (-1.0 / (x - 1.0)) - 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.35: tmp = (-1.0 / (x - 1.0)) - 1.0 else: tmp = x return tmp
function code(x) tmp = 0.0 if (x <= -1.35) tmp = Float64(Float64(-1.0 / Float64(x - 1.0)) - 1.0); else tmp = x; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.35) tmp = (-1.0 / (x - 1.0)) - 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.35], N[(N[(-1.0 / N[(x - 1.0), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35:\\
\;\;\;\;\frac{-1}{x - 1} - 1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.3500000000000001Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f645.4
Applied rewrites5.4%
lift--.f64N/A
metadata-evalN/A
fp-cancel-sub-signN/A
metadata-evalN/A
metadata-evalN/A
flip-+N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
pow2N/A
metadata-evalN/A
fp-cancel-sign-subN/A
metadata-evalN/A
pow2N/A
lower-fma.f64N/A
lower--.f645.0
Applied rewrites5.0%
Taylor expanded in x around 0
Applied rewrites97.9%
if -1.3500000000000001 < x Initial program 38.8%
Taylor expanded in x around 0
Applied rewrites68.1%
(FPCore (x) :precision binary64 (if (<= x -1.95) (- (/ -1.0 x) 1.0) x))
double code(double x) {
double tmp;
if (x <= -1.95) {
tmp = (-1.0 / x) - 1.0;
} else {
tmp = x;
}
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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.95d0)) then
tmp = ((-1.0d0) / x) - 1.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.95) {
tmp = (-1.0 / x) - 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.95: tmp = (-1.0 / x) - 1.0 else: tmp = x return tmp
function code(x) tmp = 0.0 if (x <= -1.95) tmp = Float64(Float64(-1.0 / x) - 1.0); else tmp = x; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.95) tmp = (-1.0 / x) - 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.95], N[(N[(-1.0 / x), $MachinePrecision] - 1.0), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.95:\\
\;\;\;\;\frac{-1}{x} - 1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.94999999999999996Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f645.4
Applied rewrites5.4%
lift--.f64N/A
metadata-evalN/A
fp-cancel-sub-signN/A
metadata-evalN/A
metadata-evalN/A
flip-+N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
pow2N/A
metadata-evalN/A
fp-cancel-sign-subN/A
metadata-evalN/A
pow2N/A
lower-fma.f64N/A
lower--.f645.0
Applied rewrites5.0%
Taylor expanded in x around 0
Applied rewrites97.9%
Taylor expanded in x around inf
Applied rewrites97.9%
if -1.94999999999999996 < x Initial program 38.8%
Taylor expanded in x around 0
Applied rewrites68.1%
(FPCore (x) :precision binary64 x)
double code(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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = x
end function
public static double code(double x) {
return x;
}
def code(x): return x
function code(x) return x end
function tmp = code(x) tmp = x; end
code[x_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 54.5%
Taylor expanded in x around 0
Applied rewrites52.0%
herbie shell --seed 2025114
(FPCore (x)
:name "Logistic function from Lakshay Garg"
:precision binary64
(- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))