
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.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, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.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, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<=
(/
(-
(* (+ 1.0 (/ 1.0 eps)) (exp (* (+ -1.0 eps) x)))
(* (- (/ 1.0 eps) 1.0) (exp (* (- -1.0 eps) x))))
2.0)
0.0)
(* (fma (- x -2.0) t_0 (* t_0 x)) 0.5)
(/ (- (* 1.0 (exp (* x eps))) (* -1.0 (exp (* eps (- x))))) 2.0))))
double code(double x, double eps) {
double t_0 = exp(-x);
double tmp;
if (((((1.0 + (1.0 / eps)) * exp(((-1.0 + eps) * x))) - (((1.0 / eps) - 1.0) * exp(((-1.0 - eps) * x)))) / 2.0) <= 0.0) {
tmp = fma((x - -2.0), t_0, (t_0 * x)) * 0.5;
} else {
tmp = ((1.0 * exp((x * eps))) - (-1.0 * exp((eps * -x)))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = exp(Float64(-x)) tmp = 0.0 if (Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(Float64(-1.0 + eps) * x))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(Float64(-1.0 - eps) * x)))) / 2.0) <= 0.0) tmp = Float64(fma(Float64(x - -2.0), t_0, Float64(t_0 * x)) * 0.5); else tmp = Float64(Float64(Float64(1.0 * exp(Float64(x * eps))) - Float64(-1.0 * exp(Float64(eps * Float64(-x))))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0], N[(N[(N[(x - -2.0), $MachinePrecision] * t$95$0 + N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(1.0 * N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(-1.0 * N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(-1 + \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{\left(-1 - \varepsilon\right) \cdot x}}{2} \leq 0:\\
\;\;\;\;\mathsf{fma}\left(x - -2, t\_0, t\_0 \cdot x\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot e^{x \cdot \varepsilon} - -1 \cdot e^{\varepsilon \cdot \left(-x\right)}}{2}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) #s(literal 2 binary64)) < 0.0Initial program 41.9%
Taylor expanded in eps around inf
Applied rewrites42.0%
Taylor expanded in eps around inf
Applied rewrites98.1%
Taylor expanded in eps around 0
Applied rewrites100.0%
if 0.0 < (/.f64 (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) #s(literal 2 binary64)) Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites98.5%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= eps -1.45e+158)
(/ (- (* 1.0 (fma (- eps 1.0) x 1.0)) (* -1.0 (exp (* eps (- x))))) 2.0)
(if (or (<= eps -1.0) (not (<= eps 1.0)))
(/
(-
(* (+ 1.0 (/ 1.0 eps)) (exp (* (+ -1.0 eps) x)))
(* (- (/ 1.0 eps) 1.0) (- 1.0 (fma x eps x))))
2.0)
(* (fma (- x -2.0) t_0 (* t_0 x)) 0.5)))))
double code(double x, double eps) {
double t_0 = exp(-x);
double tmp;
if (eps <= -1.45e+158) {
tmp = ((1.0 * fma((eps - 1.0), x, 1.0)) - (-1.0 * exp((eps * -x)))) / 2.0;
} else if ((eps <= -1.0) || !(eps <= 1.0)) {
tmp = (((1.0 + (1.0 / eps)) * exp(((-1.0 + eps) * x))) - (((1.0 / eps) - 1.0) * (1.0 - fma(x, eps, x)))) / 2.0;
} else {
tmp = fma((x - -2.0), t_0, (t_0 * x)) * 0.5;
}
return tmp;
}
function code(x, eps) t_0 = exp(Float64(-x)) tmp = 0.0 if (eps <= -1.45e+158) tmp = Float64(Float64(Float64(1.0 * fma(Float64(eps - 1.0), x, 1.0)) - Float64(-1.0 * exp(Float64(eps * Float64(-x))))) / 2.0); elseif ((eps <= -1.0) || !(eps <= 1.0)) tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(Float64(-1.0 + eps) * x))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * Float64(1.0 - fma(x, eps, x)))) / 2.0); else tmp = Float64(fma(Float64(x - -2.0), t_0, Float64(t_0 * x)) * 0.5); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[eps, -1.45e+158], N[(N[(N[(1.0 * N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(-1.0 * N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[eps, -1.0], N[Not[LessEqual[eps, 1.0]], $MachinePrecision]], N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[(1.0 - N[(x * eps + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x - -2.0), $MachinePrecision] * t$95$0 + N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;\varepsilon \leq -1.45 \cdot 10^{+158}:\\
\;\;\;\;\frac{1 \cdot \mathsf{fma}\left(\varepsilon - 1, x, 1\right) - -1 \cdot e^{\varepsilon \cdot \left(-x\right)}}{2}\\
\mathbf{elif}\;\varepsilon \leq -1 \lor \neg \left(\varepsilon \leq 1\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(-1 + \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot \left(1 - \mathsf{fma}\left(x, \varepsilon, x\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - -2, t\_0, t\_0 \cdot x\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < -1.45000000000000012e158Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites85.5%
Taylor expanded in eps around inf
Applied rewrites85.5%
if -1.45000000000000012e158 < eps < -1 or 1 < eps Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites69.8%
if -1 < eps < 1Initial program 41.9%
Taylor expanded in eps around inf
Applied rewrites42.0%
Taylor expanded in eps around inf
Applied rewrites98.1%
Taylor expanded in eps around 0
Applied rewrites100.0%
Final simplification84.9%
(FPCore (x eps) :precision binary64 (/ (- (* 1.0 (exp (* (+ -1.0 eps) x))) (* -1.0 (exp (* (- -1.0 eps) x)))) 2.0))
double code(double x, double eps) {
return ((1.0 * exp(((-1.0 + eps) * x))) - (-1.0 * exp(((-1.0 - eps) * x)))) / 2.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, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((1.0d0 * exp((((-1.0d0) + eps) * x))) - ((-1.0d0) * exp((((-1.0d0) - eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return ((1.0 * Math.exp(((-1.0 + eps) * x))) - (-1.0 * Math.exp(((-1.0 - eps) * x)))) / 2.0;
}
def code(x, eps): return ((1.0 * math.exp(((-1.0 + eps) * x))) - (-1.0 * math.exp(((-1.0 - eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(1.0 * exp(Float64(Float64(-1.0 + eps) * x))) - Float64(-1.0 * exp(Float64(Float64(-1.0 - eps) * x)))) / 2.0) end
function tmp = code(x, eps) tmp = ((1.0 * exp(((-1.0 + eps) * x))) - (-1.0 * exp(((-1.0 - eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(1.0 * N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(-1.0 * N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 \cdot e^{\left(-1 + \varepsilon\right) \cdot x} - -1 \cdot e^{\left(-1 - \varepsilon\right) \cdot x}}{2}
\end{array}
Initial program 75.0%
Taylor expanded in eps around inf
Applied rewrites74.2%
Taylor expanded in eps around inf
Applied rewrites99.2%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(if (<= eps -1.45e+158)
(/ (- (* 1.0 (fma (- eps 1.0) x 1.0)) (* -1.0 (exp (* eps (- x))))) 2.0)
(if (or (<= eps -1.0) (not (<= eps 1.0)))
(/
(-
(* (+ 1.0 (/ 1.0 eps)) (exp (* (+ -1.0 eps) x)))
(* (- (/ 1.0 eps) 1.0) (- 1.0 (fma x eps x))))
2.0)
(*
(fma
(exp (- x))
(- (+ 1.0 x) -1.0)
(/ x (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0)))
0.5))))
double code(double x, double eps) {
double tmp;
if (eps <= -1.45e+158) {
tmp = ((1.0 * fma((eps - 1.0), x, 1.0)) - (-1.0 * exp((eps * -x)))) / 2.0;
} else if ((eps <= -1.0) || !(eps <= 1.0)) {
tmp = (((1.0 + (1.0 / eps)) * exp(((-1.0 + eps) * x))) - (((1.0 / eps) - 1.0) * (1.0 - fma(x, eps, x)))) / 2.0;
} else {
tmp = fma(exp(-x), ((1.0 + x) - -1.0), (x / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0))) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -1.45e+158) tmp = Float64(Float64(Float64(1.0 * fma(Float64(eps - 1.0), x, 1.0)) - Float64(-1.0 * exp(Float64(eps * Float64(-x))))) / 2.0); elseif ((eps <= -1.0) || !(eps <= 1.0)) tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(Float64(-1.0 + eps) * x))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * Float64(1.0 - fma(x, eps, x)))) / 2.0); else tmp = Float64(fma(exp(Float64(-x)), Float64(Float64(1.0 + x) - -1.0), Float64(x / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0))) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -1.45e+158], N[(N[(N[(1.0 * N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(-1.0 * N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[eps, -1.0], N[Not[LessEqual[eps, 1.0]], $MachinePrecision]], N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[(1.0 - N[(x * eps + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[(-x)], $MachinePrecision] * N[(N[(1.0 + x), $MachinePrecision] - -1.0), $MachinePrecision] + N[(x / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.45 \cdot 10^{+158}:\\
\;\;\;\;\frac{1 \cdot \mathsf{fma}\left(\varepsilon - 1, x, 1\right) - -1 \cdot e^{\varepsilon \cdot \left(-x\right)}}{2}\\
\mathbf{elif}\;\varepsilon \leq -1 \lor \neg \left(\varepsilon \leq 1\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(-1 + \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot \left(1 - \mathsf{fma}\left(x, \varepsilon, x\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(e^{-x}, \left(1 + x\right) - -1, \frac{x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)}\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < -1.45000000000000012e158Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites85.5%
Taylor expanded in eps around inf
Applied rewrites85.5%
if -1.45000000000000012e158 < eps < -1 or 1 < eps Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites69.8%
if -1 < eps < 1Initial program 41.9%
Taylor expanded in eps around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites88.2%
Final simplification79.8%
(FPCore (x eps)
:precision binary64
(if (<= eps -1.45e+158)
(/ (- (* 1.0 (fma (- eps 1.0) x 1.0)) (* -1.0 (exp (* eps (- x))))) 2.0)
(if (or (<= eps -1.0) (not (<= eps 1.0)))
(/ (- (* 1.0 (exp (* x eps))) (* -1.0 (fma (- -1.0 eps) x 1.0))) 2.0)
(*
(fma
(exp (- x))
(- (+ 1.0 x) -1.0)
(/ x (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0)))
0.5))))
double code(double x, double eps) {
double tmp;
if (eps <= -1.45e+158) {
tmp = ((1.0 * fma((eps - 1.0), x, 1.0)) - (-1.0 * exp((eps * -x)))) / 2.0;
} else if ((eps <= -1.0) || !(eps <= 1.0)) {
tmp = ((1.0 * exp((x * eps))) - (-1.0 * fma((-1.0 - eps), x, 1.0))) / 2.0;
} else {
tmp = fma(exp(-x), ((1.0 + x) - -1.0), (x / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0))) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= -1.45e+158) tmp = Float64(Float64(Float64(1.0 * fma(Float64(eps - 1.0), x, 1.0)) - Float64(-1.0 * exp(Float64(eps * Float64(-x))))) / 2.0); elseif ((eps <= -1.0) || !(eps <= 1.0)) tmp = Float64(Float64(Float64(1.0 * exp(Float64(x * eps))) - Float64(-1.0 * fma(Float64(-1.0 - eps), x, 1.0))) / 2.0); else tmp = Float64(fma(exp(Float64(-x)), Float64(Float64(1.0 + x) - -1.0), Float64(x / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0))) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[eps, -1.45e+158], N[(N[(N[(1.0 * N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(-1.0 * N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[eps, -1.0], N[Not[LessEqual[eps, 1.0]], $MachinePrecision]], N[(N[(N[(1.0 * N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(-1.0 * N[(N[(-1.0 - eps), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[(-x)], $MachinePrecision] * N[(N[(1.0 + x), $MachinePrecision] - -1.0), $MachinePrecision] + N[(x / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -1.45 \cdot 10^{+158}:\\
\;\;\;\;\frac{1 \cdot \mathsf{fma}\left(\varepsilon - 1, x, 1\right) - -1 \cdot e^{\varepsilon \cdot \left(-x\right)}}{2}\\
\mathbf{elif}\;\varepsilon \leq -1 \lor \neg \left(\varepsilon \leq 1\right):\\
\;\;\;\;\frac{1 \cdot e^{x \cdot \varepsilon} - -1 \cdot \mathsf{fma}\left(-1 - \varepsilon, x, 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(e^{-x}, \left(1 + x\right) - -1, \frac{x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)}\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < -1.45000000000000012e158Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites85.5%
Taylor expanded in eps around inf
Applied rewrites85.5%
if -1.45000000000000012e158 < eps < -1 or 1 < eps Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites98.1%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites69.8%
if -1 < eps < 1Initial program 41.9%
Taylor expanded in eps around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites88.2%
Final simplification79.8%
(FPCore (x eps)
:precision binary64
(if (<= x 1.15e+21)
(/ (- (* 1.0 (exp (* x eps))) (* -1.0 1.0)) 2.0)
(if (<= x 2.05e+213)
(/ (- (- (/ 1.0 eps) -1.0) (* (- (/ 1.0 eps) 1.0) 1.0)) 2.0)
(fma (* (fma 0.3333333333333333 x -0.5) x) x 1.0))))
double code(double x, double eps) {
double tmp;
if (x <= 1.15e+21) {
tmp = ((1.0 * exp((x * eps))) - (-1.0 * 1.0)) / 2.0;
} else if (x <= 2.05e+213) {
tmp = (((1.0 / eps) - -1.0) - (((1.0 / eps) - 1.0) * 1.0)) / 2.0;
} else {
tmp = fma((fma(0.3333333333333333, x, -0.5) * x), x, 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 1.15e+21) tmp = Float64(Float64(Float64(1.0 * exp(Float64(x * eps))) - Float64(-1.0 * 1.0)) / 2.0); elseif (x <= 2.05e+213) tmp = Float64(Float64(Float64(Float64(1.0 / eps) - -1.0) - Float64(Float64(Float64(1.0 / eps) - 1.0) * 1.0)) / 2.0); else tmp = fma(Float64(fma(0.3333333333333333, x, -0.5) * x), x, 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 1.15e+21], N[(N[(N[(1.0 * N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.05e+213], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] - -1.0), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * x), $MachinePrecision] * x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.15 \cdot 10^{+21}:\\
\;\;\;\;\frac{1 \cdot e^{x \cdot \varepsilon} - -1 \cdot 1}{2}\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{+213}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} - -1\right) - \left(\frac{1}{\varepsilon} - 1\right) \cdot 1}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right) \cdot x, x, 1\right)\\
\end{array}
\end{array}
if x < 1.15e21Initial program 64.9%
Taylor expanded in eps around inf
Applied rewrites63.7%
Taylor expanded in eps around inf
Applied rewrites98.8%
Taylor expanded in eps around inf
Applied rewrites98.4%
Taylor expanded in x around 0
Applied rewrites78.9%
if 1.15e21 < x < 2.0499999999999999e213Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites16.1%
Taylor expanded in x around 0
Applied rewrites69.0%
if 2.0499999999999999e213 < x Initial program 100.0%
Taylor expanded in eps around 0
Applied rewrites38.5%
Taylor expanded in x around 0
Applied rewrites0.6%
Taylor expanded in x around 0
Applied rewrites63.1%
Applied rewrites63.1%
Final simplification75.5%
(FPCore (x eps)
:precision binary64
(if (<= x 1220000000.0)
(/ (- (* 1.0 (fma (- eps 1.0) x 1.0)) (* -1.0 1.0)) 2.0)
(if (<= x 2.05e+213)
(/ (- (- (/ 1.0 eps) -1.0) (* (- (/ 1.0 eps) 1.0) 1.0)) 2.0)
(fma (* (fma 0.3333333333333333 x -0.5) x) x 1.0))))
double code(double x, double eps) {
double tmp;
if (x <= 1220000000.0) {
tmp = ((1.0 * fma((eps - 1.0), x, 1.0)) - (-1.0 * 1.0)) / 2.0;
} else if (x <= 2.05e+213) {
tmp = (((1.0 / eps) - -1.0) - (((1.0 / eps) - 1.0) * 1.0)) / 2.0;
} else {
tmp = fma((fma(0.3333333333333333, x, -0.5) * x), x, 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 1220000000.0) tmp = Float64(Float64(Float64(1.0 * fma(Float64(eps - 1.0), x, 1.0)) - Float64(-1.0 * 1.0)) / 2.0); elseif (x <= 2.05e+213) tmp = Float64(Float64(Float64(Float64(1.0 / eps) - -1.0) - Float64(Float64(Float64(1.0 / eps) - 1.0) * 1.0)) / 2.0); else tmp = fma(Float64(fma(0.3333333333333333, x, -0.5) * x), x, 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 1220000000.0], N[(N[(N[(1.0 * N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.05e+213], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] - -1.0), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * x), $MachinePrecision] * x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1220000000:\\
\;\;\;\;\frac{1 \cdot \mathsf{fma}\left(\varepsilon - 1, x, 1\right) - -1 \cdot 1}{2}\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{+213}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} - -1\right) - \left(\frac{1}{\varepsilon} - 1\right) \cdot 1}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right) \cdot x, x, 1\right)\\
\end{array}
\end{array}
if x < 1.22e9Initial program 64.5%
Taylor expanded in eps around inf
Applied rewrites63.3%
Taylor expanded in eps around inf
Applied rewrites98.8%
Taylor expanded in x around 0
Applied rewrites77.4%
Taylor expanded in x around 0
Applied rewrites63.9%
if 1.22e9 < x < 2.0499999999999999e213Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites15.5%
Taylor expanded in x around 0
Applied rewrites68.3%
if 2.0499999999999999e213 < x Initial program 100.0%
Taylor expanded in eps around 0
Applied rewrites38.5%
Taylor expanded in x around 0
Applied rewrites0.6%
Taylor expanded in x around 0
Applied rewrites63.1%
Applied rewrites63.1%
Final simplification64.8%
(FPCore (x eps) :precision binary64 (if (or (<= x 3.2e+110) (not (<= x 1e+213))) (fma (* (fma 0.3333333333333333 x -0.5) x) x 1.0) (/ x (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))))
double code(double x, double eps) {
double tmp;
if ((x <= 3.2e+110) || !(x <= 1e+213)) {
tmp = fma((fma(0.3333333333333333, x, -0.5) * x), x, 1.0);
} else {
tmp = x / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((x <= 3.2e+110) || !(x <= 1e+213)) tmp = fma(Float64(fma(0.3333333333333333, x, -0.5) * x), x, 1.0); else tmp = Float64(x / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)); end return tmp end
code[x_, eps_] := If[Or[LessEqual[x, 3.2e+110], N[Not[LessEqual[x, 1e+213]], $MachinePrecision]], N[(N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * x), $MachinePrecision] * x + 1.0), $MachinePrecision], N[(x / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2 \cdot 10^{+110} \lor \neg \left(x \leq 10^{+213}\right):\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right) \cdot x, x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)}\\
\end{array}
\end{array}
if x < 3.19999999999999994e110 or 9.99999999999999984e212 < x Initial program 72.1%
Taylor expanded in eps around 0
Applied rewrites54.8%
Taylor expanded in x around 0
Applied rewrites44.9%
Taylor expanded in x around 0
Applied rewrites52.7%
Applied rewrites52.7%
if 3.19999999999999994e110 < x < 9.99999999999999984e212Initial program 100.0%
Taylor expanded in eps around 0
Applied rewrites81.8%
Taylor expanded in x around inf
Applied rewrites81.8%
Taylor expanded in x around 0
Applied rewrites81.8%
Final simplification55.7%
(FPCore (x eps)
:precision binary64
(if (<= x 4.1e+109)
(/ (- (* 1.0 (fma (- eps 1.0) x 1.0)) (* -1.0 1.0)) 2.0)
(if (<= x 1e+213)
(/ x (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
(fma (* (fma 0.3333333333333333 x -0.5) x) x 1.0))))
double code(double x, double eps) {
double tmp;
if (x <= 4.1e+109) {
tmp = ((1.0 * fma((eps - 1.0), x, 1.0)) - (-1.0 * 1.0)) / 2.0;
} else if (x <= 1e+213) {
tmp = x / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0);
} else {
tmp = fma((fma(0.3333333333333333, x, -0.5) * x), x, 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 4.1e+109) tmp = Float64(Float64(Float64(1.0 * fma(Float64(eps - 1.0), x, 1.0)) - Float64(-1.0 * 1.0)) / 2.0); elseif (x <= 1e+213) tmp = Float64(x / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)); else tmp = fma(Float64(fma(0.3333333333333333, x, -0.5) * x), x, 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 4.1e+109], N[(N[(N[(1.0 * N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1e+213], N[(x / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * x), $MachinePrecision] * x + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.1 \cdot 10^{+109}:\\
\;\;\;\;\frac{1 \cdot \mathsf{fma}\left(\varepsilon - 1, x, 1\right) - -1 \cdot 1}{2}\\
\mathbf{elif}\;x \leq 10^{+213}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right) \cdot x, x, 1\right)\\
\end{array}
\end{array}
if x < 4.0999999999999997e109Initial program 68.8%
Taylor expanded in eps around inf
Applied rewrites67.8%
Taylor expanded in eps around inf
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites72.1%
Taylor expanded in x around 0
Applied rewrites58.4%
if 4.0999999999999997e109 < x < 9.99999999999999984e212Initial program 100.0%
Taylor expanded in eps around 0
Applied rewrites81.8%
Taylor expanded in x around inf
Applied rewrites81.8%
Taylor expanded in x around 0
Applied rewrites81.8%
if 9.99999999999999984e212 < x Initial program 100.0%
Taylor expanded in eps around 0
Applied rewrites38.5%
Taylor expanded in x around 0
Applied rewrites0.6%
Taylor expanded in x around 0
Applied rewrites63.1%
Applied rewrites63.1%
Final simplification61.3%
(FPCore (x eps) :precision binary64 (fma (* (fma 0.3333333333333333 x -0.5) x) x 1.0))
double code(double x, double eps) {
return fma((fma(0.3333333333333333, x, -0.5) * x), x, 1.0);
}
function code(x, eps) return fma(Float64(fma(0.3333333333333333, x, -0.5) * x), x, 1.0) end
code[x_, eps_] := N[(N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * x), $MachinePrecision] * x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right) \cdot x, x, 1\right)
\end{array}
Initial program 75.0%
Taylor expanded in eps around 0
Applied rewrites57.6%
Taylor expanded in x around 0
Applied rewrites40.3%
Taylor expanded in x around 0
Applied rewrites49.2%
Applied rewrites49.2%
Final simplification49.2%
(FPCore (x eps) :precision binary64 (fma (* 0.3333333333333333 x) (* x x) 1.0))
double code(double x, double eps) {
return fma((0.3333333333333333 * x), (x * x), 1.0);
}
function code(x, eps) return fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0) end
code[x_, eps_] := N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)
\end{array}
Initial program 75.0%
Taylor expanded in eps around 0
Applied rewrites57.6%
Taylor expanded in x around 0
Applied rewrites40.3%
Taylor expanded in x around 0
Applied rewrites49.2%
Taylor expanded in x around inf
Applied rewrites49.0%
Final simplification49.0%
(FPCore (x eps) :precision binary64 1.0)
double code(double x, double eps) {
return 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, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 1.0d0
end function
public static double code(double x, double eps) {
return 1.0;
}
def code(x, eps): return 1.0
function code(x, eps) return 1.0 end
function tmp = code(x, eps) tmp = 1.0; end
code[x_, eps_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 75.0%
Taylor expanded in x around 0
Applied rewrites41.2%
Final simplification41.2%
herbie shell --seed 2025018
(FPCore (x eps)
:name "NMSE Section 6.1 mentioned, A"
:precision binary64
(/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))