
(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;
}
real(8) function code(x)
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}
Sampling outcomes in binary64 precision:
Herbie found 15 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;
}
real(8) function code(x)
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
(if (or (<= x -0.0075) (not (<= x 0.0055)))
(- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0)
(fma
(* (- (* (* x x) 0.13333333333333333) 0.3333333333333333) (* x x))
x
x)))
double code(double x) {
double tmp;
if ((x <= -0.0075) || !(x <= 0.0055)) {
tmp = (2.0 / (1.0 + exp((-2.0 * x)))) - 1.0;
} else {
tmp = fma(((((x * x) * 0.13333333333333333) - 0.3333333333333333) * (x * x)), x, x);
}
return tmp;
}
function code(x) tmp = 0.0 if ((x <= -0.0075) || !(x <= 0.0055)) tmp = Float64(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) - 1.0); else tmp = fma(Float64(Float64(Float64(Float64(x * x) * 0.13333333333333333) - 0.3333333333333333) * Float64(x * x)), x, x); end return tmp end
code[x_] := If[Or[LessEqual[x, -0.0075], N[Not[LessEqual[x, 0.0055]], $MachinePrecision]], N[(N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0075 \lor \neg \left(x \leq 0.0055\right):\\
\;\;\;\;\frac{2}{1 + e^{-2 \cdot x}} - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot 0.13333333333333333 - 0.3333333333333333\right) \cdot \left(x \cdot x\right), x, x\right)\\
\end{array}
\end{array}
if x < -0.0074999999999999997 or 0.0054999999999999997 < x Initial program 100.0%
if -0.0074999999999999997 < x < 0.0054999999999999997Initial program 7.5%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
pow-plusN/A
lower-pow.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(if (<= (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0) -1.0)
(- (/ 2.0 (* (fma (* x -4.0) x -2.0) (- x))) 1.0)
(fma
(* (- (* (* x x) 0.13333333333333333) 0.3333333333333333) (* x x))
x
x)))
double code(double x) {
double tmp;
if (((2.0 / (1.0 + exp((-2.0 * x)))) - 1.0) <= -1.0) {
tmp = (2.0 / (fma((x * -4.0), x, -2.0) * -x)) - 1.0;
} else {
tmp = fma(((((x * x) * 0.13333333333333333) - 0.3333333333333333) * (x * x)), x, x);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) - 1.0) <= -1.0) tmp = Float64(Float64(2.0 / Float64(fma(Float64(x * -4.0), x, -2.0) * Float64(-x))) - 1.0); else tmp = fma(Float64(Float64(Float64(Float64(x * x) * 0.13333333333333333) - 0.3333333333333333) * Float64(x * x)), x, x); end return tmp end
code[x_] := If[LessEqual[N[(N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], -1.0], N[(N[(2.0 / N[(N[(N[(x * -4.0), $MachinePrecision] * x + -2.0), $MachinePrecision] * (-x)), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{2}{1 + e^{-2 \cdot x}} - 1 \leq -1:\\
\;\;\;\;\frac{2}{\mathsf{fma}\left(x \cdot -4, x, -2\right) \cdot \left(-x\right)} - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot 0.13333333333333333 - 0.3333333333333333\right) \cdot \left(x \cdot x\right), x, x\right)\\
\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)) < -1Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
Taylor expanded in x around inf
Applied rewrites99.1%
Applied rewrites99.1%
Applied rewrites99.4%
if -1 < (-.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 36.7%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
pow-plusN/A
lower-pow.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6469.5
Applied rewrites69.5%
Applied rewrites69.5%
(FPCore (x)
:precision binary64
(if (<= (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0) -1.0)
(- (/ 2.0 (* (* x -4.0) (* x -4.0))) 1.0)
(fma
(* (- (* (* x x) 0.13333333333333333) 0.3333333333333333) (* x x))
x
x)))
double code(double x) {
double tmp;
if (((2.0 / (1.0 + exp((-2.0 * x)))) - 1.0) <= -1.0) {
tmp = (2.0 / ((x * -4.0) * (x * -4.0))) - 1.0;
} else {
tmp = fma(((((x * x) * 0.13333333333333333) - 0.3333333333333333) * (x * x)), x, x);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) - 1.0) <= -1.0) tmp = Float64(Float64(2.0 / Float64(Float64(x * -4.0) * Float64(x * -4.0))) - 1.0); else tmp = fma(Float64(Float64(Float64(Float64(x * x) * 0.13333333333333333) - 0.3333333333333333) * Float64(x * x)), x, x); end return tmp end
code[x_] := If[LessEqual[N[(N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], -1.0], N[(N[(2.0 / N[(N[(x * -4.0), $MachinePrecision] * N[(x * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{2}{1 + e^{-2 \cdot x}} - 1 \leq -1:\\
\;\;\;\;\frac{2}{\left(x \cdot -4\right) \cdot \left(x \cdot -4\right)} - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot 0.13333333333333333 - 0.3333333333333333\right) \cdot \left(x \cdot x\right), x, x\right)\\
\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)) < -1Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
Taylor expanded in x around inf
Applied rewrites99.1%
Applied rewrites99.1%
Applied rewrites99.2%
if -1 < (-.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 36.7%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
pow-plusN/A
lower-pow.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6469.5
Applied rewrites69.5%
Applied rewrites69.5%
(FPCore (x)
:precision binary64
(if (<= (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0) -1.0)
(- (/ 2.0 (* (fma x 4.0 -2.0) (- x))) 1.0)
(fma
(* (- (* (* x x) 0.13333333333333333) 0.3333333333333333) (* x x))
x
x)))
double code(double x) {
double tmp;
if (((2.0 / (1.0 + exp((-2.0 * x)))) - 1.0) <= -1.0) {
tmp = (2.0 / (fma(x, 4.0, -2.0) * -x)) - 1.0;
} else {
tmp = fma(((((x * x) * 0.13333333333333333) - 0.3333333333333333) * (x * x)), x, x);
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) - 1.0) <= -1.0) tmp = Float64(Float64(2.0 / Float64(fma(x, 4.0, -2.0) * Float64(-x))) - 1.0); else tmp = fma(Float64(Float64(Float64(Float64(x * x) * 0.13333333333333333) - 0.3333333333333333) * Float64(x * x)), x, x); end return tmp end
code[x_] := If[LessEqual[N[(N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], -1.0], N[(N[(2.0 / N[(N[(x * 4.0 + -2.0), $MachinePrecision] * (-x)), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{2}{1 + e^{-2 \cdot x}} - 1 \leq -1:\\
\;\;\;\;\frac{2}{\mathsf{fma}\left(x, 4, -2\right) \cdot \left(-x\right)} - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot 0.13333333333333333 - 0.3333333333333333\right) \cdot \left(x \cdot x\right), x, x\right)\\
\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)) < -1Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
Taylor expanded in x around inf
Applied rewrites99.1%
Applied rewrites99.1%
Applied rewrites99.1%
if -1 < (-.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 36.7%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
pow-plusN/A
lower-pow.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6469.5
Applied rewrites69.5%
Applied rewrites69.5%
(FPCore (x)
:precision binary64
(if (<= x -1.22)
(- (/ 2.0 (pow (* x -4.0) 3.0)) 1.0)
(fma
(* (- (* (* x x) 0.13333333333333333) 0.3333333333333333) (* x x))
x
x)))
double code(double x) {
double tmp;
if (x <= -1.22) {
tmp = (2.0 / pow((x * -4.0), 3.0)) - 1.0;
} else {
tmp = fma(((((x * x) * 0.13333333333333333) - 0.3333333333333333) * (x * x)), x, x);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -1.22) tmp = Float64(Float64(2.0 / (Float64(x * -4.0) ^ 3.0)) - 1.0); else tmp = fma(Float64(Float64(Float64(Float64(x * x) * 0.13333333333333333) - 0.3333333333333333) * Float64(x * x)), x, x); end return tmp end
code[x_] := If[LessEqual[x, -1.22], N[(N[(2.0 / N[Power[N[(x * -4.0), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.22:\\
\;\;\;\;\frac{2}{{\left(x \cdot -4\right)}^{3}} - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot 0.13333333333333333 - 0.3333333333333333\right) \cdot \left(x \cdot x\right), x, x\right)\\
\end{array}
\end{array}
if x < -1.21999999999999997Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
Taylor expanded in x around inf
Applied rewrites99.1%
Applied rewrites99.1%
Applied rewrites99.4%
if -1.21999999999999997 < x Initial program 36.7%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
pow-plusN/A
lower-pow.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6469.5
Applied rewrites69.5%
Applied rewrites69.5%
(FPCore (x)
:precision binary64
(if (<= x -1.15)
(- (/ 2.0 (* (fma (* x -4.0) (* x -4.0) -2.0) (- x))) 1.0)
(fma
(* (- (* (* x x) 0.13333333333333333) 0.3333333333333333) (* x x))
x
x)))
double code(double x) {
double tmp;
if (x <= -1.15) {
tmp = (2.0 / (fma((x * -4.0), (x * -4.0), -2.0) * -x)) - 1.0;
} else {
tmp = fma(((((x * x) * 0.13333333333333333) - 0.3333333333333333) * (x * x)), x, x);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -1.15) tmp = Float64(Float64(2.0 / Float64(fma(Float64(x * -4.0), Float64(x * -4.0), -2.0) * Float64(-x))) - 1.0); else tmp = fma(Float64(Float64(Float64(Float64(x * x) * 0.13333333333333333) - 0.3333333333333333) * Float64(x * x)), x, x); end return tmp end
code[x_] := If[LessEqual[x, -1.15], N[(N[(2.0 / N[(N[(N[(x * -4.0), $MachinePrecision] * N[(x * -4.0), $MachinePrecision] + -2.0), $MachinePrecision] * (-x)), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 0.13333333333333333), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15:\\
\;\;\;\;\frac{2}{\mathsf{fma}\left(x \cdot -4, x \cdot -4, -2\right) \cdot \left(-x\right)} - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot 0.13333333333333333 - 0.3333333333333333\right) \cdot \left(x \cdot x\right), x, x\right)\\
\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
lower--.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
Taylor expanded in x around inf
Applied rewrites99.1%
Applied rewrites99.1%
Applied rewrites99.4%
if -1.1499999999999999 < x Initial program 36.7%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
pow-plusN/A
lower-pow.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6469.5
Applied rewrites69.5%
Applied rewrites69.5%
(FPCore (x) :precision binary64 (if (<= x -1.25) (- (/ 2.0 (* (fma x 4.0 -2.0) (- x))) 1.0) (fma (* -0.3333333333333333 (* x x)) x x)))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = (2.0 / (fma(x, 4.0, -2.0) * -x)) - 1.0;
} else {
tmp = fma((-0.3333333333333333 * (x * x)), x, x);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -1.25) tmp = Float64(Float64(2.0 / Float64(fma(x, 4.0, -2.0) * Float64(-x))) - 1.0); else tmp = fma(Float64(-0.3333333333333333 * Float64(x * x)), x, x); end return tmp end
code[x_] := If[LessEqual[x, -1.25], N[(N[(2.0 / N[(N[(x * 4.0 + -2.0), $MachinePrecision] * (-x)), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(-0.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;\frac{2}{\mathsf{fma}\left(x, 4, -2\right) \cdot \left(-x\right)} - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333 \cdot \left(x \cdot x\right), x, x\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
Taylor expanded in x around inf
Applied rewrites99.1%
Applied rewrites99.1%
Applied rewrites99.1%
if -1.25 < x Initial program 36.7%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
pow-plusN/A
lower-pow.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6469.5
Applied rewrites69.5%
Applied rewrites69.5%
Taylor expanded in x around 0
Applied rewrites68.5%
(FPCore (x) :precision binary64 (if (<= x -1.3) (- (/ 2.0 (* (* x -4.0) x)) 1.0) (fma (* -0.3333333333333333 (* x x)) x x)))
double code(double x) {
double tmp;
if (x <= -1.3) {
tmp = (2.0 / ((x * -4.0) * x)) - 1.0;
} else {
tmp = fma((-0.3333333333333333 * (x * x)), x, x);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -1.3) tmp = Float64(Float64(2.0 / Float64(Float64(x * -4.0) * x)) - 1.0); else tmp = fma(Float64(-0.3333333333333333 * Float64(x * x)), x, x); end return tmp end
code[x_] := If[LessEqual[x, -1.3], N[(N[(2.0 / N[(N[(x * -4.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(-0.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3:\\
\;\;\;\;\frac{2}{\left(x \cdot -4\right) \cdot x} - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333 \cdot \left(x \cdot x\right), x, x\right)\\
\end{array}
\end{array}
if x < -1.30000000000000004Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
Taylor expanded in x around inf
Applied rewrites99.1%
Applied rewrites99.1%
Applied rewrites99.1%
if -1.30000000000000004 < x Initial program 36.7%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
pow-plusN/A
lower-pow.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6469.5
Applied rewrites69.5%
Applied rewrites69.5%
Taylor expanded in x around 0
Applied rewrites68.5%
(FPCore (x) :precision binary64 (if (<= x -1.4) (- (/ 2.0 (* (+ x x) x)) 1.0) (fma (* -0.3333333333333333 (* x x)) x x)))
double code(double x) {
double tmp;
if (x <= -1.4) {
tmp = (2.0 / ((x + x) * x)) - 1.0;
} else {
tmp = fma((-0.3333333333333333 * (x * x)), x, x);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -1.4) tmp = Float64(Float64(2.0 / Float64(Float64(x + x) * x)) - 1.0); else tmp = fma(Float64(-0.3333333333333333 * Float64(x * x)), x, x); end return tmp end
code[x_] := If[LessEqual[x, -1.4], N[(N[(2.0 / N[(N[(x + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(-0.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4:\\
\;\;\;\;\frac{2}{\left(x + x\right) \cdot x} - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333 \cdot \left(x \cdot x\right), x, x\right)\\
\end{array}
\end{array}
if x < -1.3999999999999999Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
Taylor expanded in x around inf
Applied rewrites99.1%
Applied rewrites99.1%
if -1.3999999999999999 < x Initial program 36.7%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
pow-plusN/A
lower-pow.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6469.5
Applied rewrites69.5%
Applied rewrites69.5%
Taylor expanded in x around 0
Applied rewrites68.5%
(FPCore (x) :precision binary64 (if (<= x -1.32) (- (/ 2.0 (* x 4.0)) 1.0) (fma (* -0.3333333333333333 (* x x)) x x)))
double code(double x) {
double tmp;
if (x <= -1.32) {
tmp = (2.0 / (x * 4.0)) - 1.0;
} else {
tmp = fma((-0.3333333333333333 * (x * x)), x, x);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -1.32) tmp = Float64(Float64(2.0 / Float64(x * 4.0)) - 1.0); else tmp = fma(Float64(-0.3333333333333333 * Float64(x * x)), x, x); end return tmp end
code[x_] := If[LessEqual[x, -1.32], N[(N[(2.0 / N[(x * 4.0), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(-0.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.32:\\
\;\;\;\;\frac{2}{x \cdot 4} - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333 \cdot \left(x \cdot x\right), x, x\right)\\
\end{array}
\end{array}
if x < -1.32000000000000006Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
Taylor expanded in x around inf
Applied rewrites99.1%
Applied rewrites99.1%
Applied rewrites98.7%
if -1.32000000000000006 < x Initial program 36.7%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
pow-plusN/A
lower-pow.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6469.5
Applied rewrites69.5%
Applied rewrites69.5%
Taylor expanded in x around 0
Applied rewrites68.5%
(FPCore (x) :precision binary64 (if (<= x -1.42) (- (/ 2.0 (+ x x)) 1.0) (fma (* -0.3333333333333333 (* x x)) x x)))
double code(double x) {
double tmp;
if (x <= -1.42) {
tmp = (2.0 / (x + x)) - 1.0;
} else {
tmp = fma((-0.3333333333333333 * (x * x)), x, x);
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -1.42) tmp = Float64(Float64(2.0 / Float64(x + x)) - 1.0); else tmp = fma(Float64(-0.3333333333333333 * Float64(x * x)), x, x); end return tmp end
code[x_] := If[LessEqual[x, -1.42], N[(N[(2.0 / N[(x + x), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(-0.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.42:\\
\;\;\;\;\frac{2}{x + x} - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333 \cdot \left(x \cdot x\right), x, x\right)\\
\end{array}
\end{array}
if x < -1.4199999999999999Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
Taylor expanded in x around inf
Applied rewrites99.1%
Applied rewrites99.1%
Applied rewrites98.6%
if -1.4199999999999999 < x Initial program 36.7%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
pow-plusN/A
lower-pow.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6469.5
Applied rewrites69.5%
Applied rewrites69.5%
Taylor expanded in x around 0
Applied rewrites68.5%
(FPCore (x) :precision binary64 (fma (* -0.3333333333333333 (* x x)) x x))
double code(double x) {
return fma((-0.3333333333333333 * (x * x)), x, x);
}
function code(x) return fma(Float64(-0.3333333333333333 * Float64(x * x)), x, x) end
code[x_] := N[(N[(-0.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.3333333333333333 \cdot \left(x \cdot x\right), x, x\right)
\end{array}
Initial program 51.6%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
pow-plusN/A
lower-pow.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6454.0
Applied rewrites54.0%
Applied rewrites54.0%
Taylor expanded in x around 0
Applied rewrites52.6%
(FPCore (x) :precision binary64 (- (+ 1.0 x) 1.0))
double code(double x) {
return (1.0 + x) - 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 + x) - 1.0d0
end function
public static double code(double x) {
return (1.0 + x) - 1.0;
}
def code(x): return (1.0 + x) - 1.0
function code(x) return Float64(Float64(1.0 + x) - 1.0) end
function tmp = code(x) tmp = (1.0 + x) - 1.0; end
code[x_] := N[(N[(1.0 + x), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(1 + x\right) - 1
\end{array}
Initial program 51.6%
Taylor expanded in x around 0
lower-+.f646.3
Applied rewrites6.3%
(FPCore (x) :precision binary64 (- x 1.0))
double code(double x) {
return x - 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = x - 1.0d0
end function
public static double code(double x) {
return x - 1.0;
}
def code(x): return x - 1.0
function code(x) return Float64(x - 1.0) end
function tmp = code(x) tmp = x - 1.0; end
code[x_] := N[(x - 1.0), $MachinePrecision]
\begin{array}{l}
\\
x - 1
\end{array}
Initial program 51.6%
Taylor expanded in x around 0
lower-+.f646.3
Applied rewrites6.3%
Applied rewrites2.9%
Taylor expanded in x around -inf
Applied rewrites4.5%
(FPCore (x) :precision binary64 (- 1.0 1.0))
double code(double x) {
return 1.0 - 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - 1.0d0
end function
public static double code(double x) {
return 1.0 - 1.0;
}
def code(x): return 1.0 - 1.0
function code(x) return Float64(1.0 - 1.0) end
function tmp = code(x) tmp = 1.0 - 1.0; end
code[x_] := N[(1.0 - 1.0), $MachinePrecision]
\begin{array}{l}
\\
1 - 1
\end{array}
Initial program 51.6%
Taylor expanded in x around 0
Applied rewrites4.2%
herbie shell --seed 2024339
(FPCore (x)
:name "Logistic function from Lakshay Garg"
:precision binary64
(- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))