
(FPCore (x y) :precision binary64 (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))
double code(double x, double y) {
return (2.0 / (1.0 + exp((-2.0 * x)))) - 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (2.0d0 / (1.0d0 + exp(((-2.0d0) * x)))) - 1.0d0
end function
public static double code(double x, double y) {
return (2.0 / (1.0 + Math.exp((-2.0 * x)))) - 1.0;
}
def code(x, y): return (2.0 / (1.0 + math.exp((-2.0 * x)))) - 1.0
function code(x, y) return Float64(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) - 1.0) end
function tmp = code(x, y) tmp = (2.0 / (1.0 + exp((-2.0 * x)))) - 1.0; end
code[x_, y_] := 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 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))
double code(double x, double y) {
return (2.0 / (1.0 + exp((-2.0 * x)))) - 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (2.0d0 / (1.0d0 + exp(((-2.0d0) * x)))) - 1.0d0
end function
public static double code(double x, double y) {
return (2.0 / (1.0 + Math.exp((-2.0 * x)))) - 1.0;
}
def code(x, y): return (2.0 / (1.0 + math.exp((-2.0 * x)))) - 1.0
function code(x, y) return Float64(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) - 1.0) end
function tmp = code(x, y) tmp = (2.0 / (1.0 + exp((-2.0 * x)))) - 1.0; end
code[x_, y_] := 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 y)
:precision binary64
(if (<= (* -2.0 x) -1e+24)
1.0
(if (<= (* -2.0 x) 2e-7)
(+ x (* -0.3333333333333333 (pow x 3.0)))
(+ (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) -1.0))))
double code(double x, double y) {
double tmp;
if ((-2.0 * x) <= -1e+24) {
tmp = 1.0;
} else if ((-2.0 * x) <= 2e-7) {
tmp = x + (-0.3333333333333333 * pow(x, 3.0));
} else {
tmp = (2.0 / (1.0 + exp((-2.0 * x)))) + -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (((-2.0d0) * x) <= (-1d+24)) then
tmp = 1.0d0
else if (((-2.0d0) * x) <= 2d-7) then
tmp = x + ((-0.3333333333333333d0) * (x ** 3.0d0))
else
tmp = (2.0d0 / (1.0d0 + exp(((-2.0d0) * x)))) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((-2.0 * x) <= -1e+24) {
tmp = 1.0;
} else if ((-2.0 * x) <= 2e-7) {
tmp = x + (-0.3333333333333333 * Math.pow(x, 3.0));
} else {
tmp = (2.0 / (1.0 + Math.exp((-2.0 * x)))) + -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (-2.0 * x) <= -1e+24: tmp = 1.0 elif (-2.0 * x) <= 2e-7: tmp = x + (-0.3333333333333333 * math.pow(x, 3.0)) else: tmp = (2.0 / (1.0 + math.exp((-2.0 * x)))) + -1.0 return tmp
function code(x, y) tmp = 0.0 if (Float64(-2.0 * x) <= -1e+24) tmp = 1.0; elseif (Float64(-2.0 * x) <= 2e-7) tmp = Float64(x + Float64(-0.3333333333333333 * (x ^ 3.0))); else tmp = Float64(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) + -1.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((-2.0 * x) <= -1e+24) tmp = 1.0; elseif ((-2.0 * x) <= 2e-7) tmp = x + (-0.3333333333333333 * (x ^ 3.0)); else tmp = (2.0 / (1.0 + exp((-2.0 * x)))) + -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(-2.0 * x), $MachinePrecision], -1e+24], 1.0, If[LessEqual[N[(-2.0 * x), $MachinePrecision], 2e-7], N[(x + N[(-0.3333333333333333 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \leq -1 \cdot 10^{+24}:\\
\;\;\;\;1\\
\mathbf{elif}\;-2 \cdot x \leq 2 \cdot 10^{-7}:\\
\;\;\;\;x + -0.3333333333333333 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{1 + e^{-2 \cdot x}} + -1\\
\end{array}
\end{array}
if (*.f64 -2 x) < -9.9999999999999998e23Initial program 100.0%
Taylor expanded in x around 0 4.9%
+-commutative4.9%
Simplified4.9%
flip--4.6%
div-inv4.6%
metadata-eval4.6%
difference-of-sqr-14.6%
associate-+l+4.6%
metadata-eval4.6%
associate--l+4.6%
metadata-eval4.6%
+-rgt-identity4.6%
associate-+l+4.6%
metadata-eval4.6%
Applied egg-rr4.6%
Taylor expanded in x around 0 18.8%
*-commutative18.8%
rem-log-exp3.1%
exp-lft-sqr3.1%
log-prod3.1%
rem-log-exp3.1%
rem-log-exp18.8%
Simplified18.8%
Applied egg-rr100.0%
if -9.9999999999999998e23 < (*.f64 -2 x) < 1.9999999999999999e-7Initial program 7.2%
Taylor expanded in x around 0 100.0%
if 1.9999999999999999e-7 < (*.f64 -2 x) Initial program 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= x -1.15) -1.0 (if (<= x 1.2) (+ x (* -0.3333333333333333 (pow x 3.0))) 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.15) {
tmp = -1.0;
} else if (x <= 1.2) {
tmp = x + (-0.3333333333333333 * pow(x, 3.0));
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.15d0)) then
tmp = -1.0d0
else if (x <= 1.2d0) then
tmp = x + ((-0.3333333333333333d0) * (x ** 3.0d0))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.15) {
tmp = -1.0;
} else if (x <= 1.2) {
tmp = x + (-0.3333333333333333 * Math.pow(x, 3.0));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.15: tmp = -1.0 elif x <= 1.2: tmp = x + (-0.3333333333333333 * math.pow(x, 3.0)) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.15) tmp = -1.0; elseif (x <= 1.2) tmp = Float64(x + Float64(-0.3333333333333333 * (x ^ 3.0))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.15) tmp = -1.0; elseif (x <= 1.2) tmp = x + (-0.3333333333333333 * (x ^ 3.0)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.15], -1.0, If[LessEqual[x, 1.2], N[(x + N[(-0.3333333333333333 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.2:\\
\;\;\;\;x + -0.3333333333333333 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1.1499999999999999Initial program 100.0%
Taylor expanded in x around 0 5.4%
+-commutative5.4%
Simplified5.4%
flip--5.1%
div-inv5.1%
metadata-eval5.1%
difference-of-sqr-15.1%
associate-+l+5.1%
metadata-eval5.1%
associate--l+5.1%
metadata-eval5.1%
+-rgt-identity5.1%
associate-+l+5.1%
metadata-eval5.1%
Applied egg-rr5.1%
Taylor expanded in x around 0 1.6%
*-commutative1.6%
rem-log-exp0.6%
exp-lft-sqr0.6%
log-prod0.6%
rem-log-exp0.6%
rem-log-exp1.6%
Simplified1.6%
Applied egg-rr100.0%
if -1.1499999999999999 < x < 1.19999999999999996Initial program 7.9%
Taylor expanded in x around 0 99.7%
if 1.19999999999999996 < x Initial program 100.0%
Taylor expanded in x around 0 4.9%
+-commutative4.9%
Simplified4.9%
flip--4.6%
div-inv4.6%
metadata-eval4.6%
difference-of-sqr-14.6%
associate-+l+4.6%
metadata-eval4.6%
associate--l+4.6%
metadata-eval4.6%
+-rgt-identity4.6%
associate-+l+4.6%
metadata-eval4.6%
Applied egg-rr4.6%
Taylor expanded in x around 0 18.8%
*-commutative18.8%
rem-log-exp3.1%
exp-lft-sqr3.1%
log-prod3.1%
rem-log-exp3.1%
rem-log-exp18.8%
Simplified18.8%
Applied egg-rr100.0%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (<= x -1.35) -1.0 (if (<= x 1.35) (* (+ (* x x) (* x 2.0)) (+ 0.5 (* x -0.25))) 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.35) {
tmp = -1.0;
} else if (x <= 1.35) {
tmp = ((x * x) + (x * 2.0)) * (0.5 + (x * -0.25));
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.35d0)) then
tmp = -1.0d0
else if (x <= 1.35d0) then
tmp = ((x * x) + (x * 2.0d0)) * (0.5d0 + (x * (-0.25d0)))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.35) {
tmp = -1.0;
} else if (x <= 1.35) {
tmp = ((x * x) + (x * 2.0)) * (0.5 + (x * -0.25));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.35: tmp = -1.0 elif x <= 1.35: tmp = ((x * x) + (x * 2.0)) * (0.5 + (x * -0.25)) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.35) tmp = -1.0; elseif (x <= 1.35) tmp = Float64(Float64(Float64(x * x) + Float64(x * 2.0)) * Float64(0.5 + Float64(x * -0.25))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.35) tmp = -1.0; elseif (x <= 1.35) tmp = ((x * x) + (x * 2.0)) * (0.5 + (x * -0.25)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.35], -1.0, If[LessEqual[x, 1.35], N[(N[(N[(x * x), $MachinePrecision] + N[(x * 2.0), $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(x * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.35:\\
\;\;\;\;\left(x \cdot x + x \cdot 2\right) \cdot \left(0.5 + x \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1.3500000000000001Initial program 100.0%
Taylor expanded in x around 0 5.4%
+-commutative5.4%
Simplified5.4%
flip--5.1%
div-inv5.1%
metadata-eval5.1%
difference-of-sqr-15.1%
associate-+l+5.1%
metadata-eval5.1%
associate--l+5.1%
metadata-eval5.1%
+-rgt-identity5.1%
associate-+l+5.1%
metadata-eval5.1%
Applied egg-rr5.1%
Taylor expanded in x around 0 1.6%
*-commutative1.6%
rem-log-exp0.6%
exp-lft-sqr0.6%
log-prod0.6%
rem-log-exp0.6%
rem-log-exp1.6%
Simplified1.6%
Applied egg-rr100.0%
if -1.3500000000000001 < x < 1.3500000000000001Initial program 7.9%
Taylor expanded in x around 0 7.5%
+-commutative7.5%
Simplified7.5%
flip--7.4%
div-inv7.4%
metadata-eval7.4%
difference-of-sqr-17.5%
associate-+l+7.5%
metadata-eval7.5%
associate--l+99.5%
metadata-eval99.5%
+-rgt-identity99.5%
associate-+l+99.5%
metadata-eval99.5%
Applied egg-rr99.5%
Taylor expanded in x around 0 99.5%
*-commutative99.5%
Simplified99.5%
*-commutative99.5%
distribute-lft-in99.6%
Applied egg-rr99.6%
if 1.3500000000000001 < x Initial program 100.0%
Taylor expanded in x around 0 4.9%
+-commutative4.9%
Simplified4.9%
flip--4.6%
div-inv4.6%
metadata-eval4.6%
difference-of-sqr-14.6%
associate-+l+4.6%
metadata-eval4.6%
associate--l+4.6%
metadata-eval4.6%
+-rgt-identity4.6%
associate-+l+4.6%
metadata-eval4.6%
Applied egg-rr4.6%
Taylor expanded in x around 0 18.8%
*-commutative18.8%
rem-log-exp3.1%
exp-lft-sqr3.1%
log-prod3.1%
rem-log-exp3.1%
rem-log-exp18.8%
Simplified18.8%
Applied egg-rr100.0%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (<= x -1.35) -1.0 (if (<= x 1.35) (* (+ 0.5 (* x -0.25)) (* x (+ x 2.0))) 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.35) {
tmp = -1.0;
} else if (x <= 1.35) {
tmp = (0.5 + (x * -0.25)) * (x * (x + 2.0));
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.35d0)) then
tmp = -1.0d0
else if (x <= 1.35d0) then
tmp = (0.5d0 + (x * (-0.25d0))) * (x * (x + 2.0d0))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.35) {
tmp = -1.0;
} else if (x <= 1.35) {
tmp = (0.5 + (x * -0.25)) * (x * (x + 2.0));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.35: tmp = -1.0 elif x <= 1.35: tmp = (0.5 + (x * -0.25)) * (x * (x + 2.0)) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.35) tmp = -1.0; elseif (x <= 1.35) tmp = Float64(Float64(0.5 + Float64(x * -0.25)) * Float64(x * Float64(x + 2.0))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.35) tmp = -1.0; elseif (x <= 1.35) tmp = (0.5 + (x * -0.25)) * (x * (x + 2.0)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.35], -1.0, If[LessEqual[x, 1.35], N[(N[(0.5 + N[(x * -0.25), $MachinePrecision]), $MachinePrecision] * N[(x * N[(x + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.35:\\
\;\;\;\;\left(0.5 + x \cdot -0.25\right) \cdot \left(x \cdot \left(x + 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1.3500000000000001Initial program 100.0%
Taylor expanded in x around 0 5.4%
+-commutative5.4%
Simplified5.4%
flip--5.1%
div-inv5.1%
metadata-eval5.1%
difference-of-sqr-15.1%
associate-+l+5.1%
metadata-eval5.1%
associate--l+5.1%
metadata-eval5.1%
+-rgt-identity5.1%
associate-+l+5.1%
metadata-eval5.1%
Applied egg-rr5.1%
Taylor expanded in x around 0 1.6%
*-commutative1.6%
rem-log-exp0.6%
exp-lft-sqr0.6%
log-prod0.6%
rem-log-exp0.6%
rem-log-exp1.6%
Simplified1.6%
Applied egg-rr100.0%
if -1.3500000000000001 < x < 1.3500000000000001Initial program 7.9%
Taylor expanded in x around 0 7.5%
+-commutative7.5%
Simplified7.5%
flip--7.4%
div-inv7.4%
metadata-eval7.4%
difference-of-sqr-17.5%
associate-+l+7.5%
metadata-eval7.5%
associate--l+99.5%
metadata-eval99.5%
+-rgt-identity99.5%
associate-+l+99.5%
metadata-eval99.5%
Applied egg-rr99.5%
Taylor expanded in x around 0 99.5%
*-commutative99.5%
Simplified99.5%
if 1.3500000000000001 < x Initial program 100.0%
Taylor expanded in x around 0 4.9%
+-commutative4.9%
Simplified4.9%
flip--4.6%
div-inv4.6%
metadata-eval4.6%
difference-of-sqr-14.6%
associate-+l+4.6%
metadata-eval4.6%
associate--l+4.6%
metadata-eval4.6%
+-rgt-identity4.6%
associate-+l+4.6%
metadata-eval4.6%
Applied egg-rr4.6%
Taylor expanded in x around 0 18.8%
*-commutative18.8%
rem-log-exp3.1%
exp-lft-sqr3.1%
log-prod3.1%
rem-log-exp3.1%
rem-log-exp18.8%
Simplified18.8%
Applied egg-rr100.0%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (<= x -1.0) -1.0 (if (<= x 1.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = -1.0;
} else if (x <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = -1.0d0
else if (x <= 1.0d0) then
tmp = x
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = -1.0;
} else if (x <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = -1.0 elif x <= 1.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = -1.0; elseif (x <= 1.0) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = -1.0; elseif (x <= 1.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], -1.0, If[LessEqual[x, 1.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1Initial program 100.0%
Taylor expanded in x around 0 5.4%
+-commutative5.4%
Simplified5.4%
flip--5.1%
div-inv5.1%
metadata-eval5.1%
difference-of-sqr-15.1%
associate-+l+5.1%
metadata-eval5.1%
associate--l+5.1%
metadata-eval5.1%
+-rgt-identity5.1%
associate-+l+5.1%
metadata-eval5.1%
Applied egg-rr5.1%
Taylor expanded in x around 0 1.6%
*-commutative1.6%
rem-log-exp0.6%
exp-lft-sqr0.6%
log-prod0.6%
rem-log-exp0.6%
rem-log-exp1.6%
Simplified1.6%
Applied egg-rr100.0%
if -1 < x < 1Initial program 7.9%
Taylor expanded in x around 0 99.5%
if 1 < x Initial program 100.0%
Taylor expanded in x around 0 4.9%
+-commutative4.9%
Simplified4.9%
flip--4.6%
div-inv4.6%
metadata-eval4.6%
difference-of-sqr-14.6%
associate-+l+4.6%
metadata-eval4.6%
associate--l+4.6%
metadata-eval4.6%
+-rgt-identity4.6%
associate-+l+4.6%
metadata-eval4.6%
Applied egg-rr4.6%
Taylor expanded in x around 0 18.8%
*-commutative18.8%
rem-log-exp3.1%
exp-lft-sqr3.1%
log-prod3.1%
rem-log-exp3.1%
rem-log-exp18.8%
Simplified18.8%
Applied egg-rr100.0%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (<= x -5e-310) -1.0 1.0))
double code(double x, double y) {
double tmp;
if (x <= -5e-310) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-5d-310)) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -5e-310) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5e-310: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -5e-310) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5e-310) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5e-310], -1.0, 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -4.999999999999985e-310Initial program 49.5%
Taylor expanded in x around 0 6.9%
+-commutative6.9%
Simplified6.9%
flip--6.8%
div-inv6.8%
metadata-eval6.8%
difference-of-sqr-16.8%
associate-+l+6.8%
metadata-eval6.8%
associate--l+57.1%
metadata-eval57.1%
+-rgt-identity57.1%
associate-+l+57.2%
metadata-eval57.2%
Applied egg-rr57.2%
Taylor expanded in x around 0 54.8%
*-commutative54.8%
rem-log-exp4.7%
exp-lft-sqr4.6%
log-prod4.6%
rem-log-exp11.6%
rem-log-exp54.8%
Simplified54.8%
Applied egg-rr47.7%
if -4.999999999999985e-310 < x Initial program 47.5%
Taylor expanded in x around 0 6.0%
+-commutative6.0%
Simplified6.0%
flip--5.8%
div-inv5.8%
metadata-eval5.8%
difference-of-sqr-15.9%
associate-+l+5.9%
metadata-eval5.9%
associate--l+58.4%
metadata-eval58.4%
+-rgt-identity58.4%
associate-+l+58.4%
metadata-eval58.4%
Applied egg-rr58.4%
Taylor expanded in x around 0 64.2%
*-commutative64.2%
rem-log-exp5.2%
exp-lft-sqr5.1%
log-prod5.2%
rem-log-exp12.3%
rem-log-exp64.2%
Simplified64.2%
Applied egg-rr46.4%
Final simplification47.1%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 48.5%
Taylor expanded in x around 0 6.5%
+-commutative6.5%
Simplified6.5%
flip--6.3%
div-inv6.3%
metadata-eval6.3%
difference-of-sqr-16.3%
associate-+l+6.3%
metadata-eval6.3%
associate--l+57.7%
metadata-eval57.7%
+-rgt-identity57.7%
associate-+l+57.8%
metadata-eval57.8%
Applied egg-rr57.8%
Taylor expanded in x around 0 59.4%
*-commutative59.4%
rem-log-exp4.9%
exp-lft-sqr4.9%
log-prod4.9%
rem-log-exp11.9%
rem-log-exp59.4%
Simplified59.4%
Applied egg-rr25.2%
Final simplification25.2%
herbie shell --seed 2023199
(FPCore (x y)
:name "Logistic function from Lakshay Garg"
:precision binary64
(- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))