
(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
(let* ((t_0 (/ 2.0 (+ 1.0 (exp (* -2.0 x))))))
(if (<= t_0 0.0)
-1.0
(if (<= t_0 1.0)
(+ x (* -0.3333333333333333 (pow x 3.0)))
(+ (/ 2.0 (/ (expm1 (* x -4.0)) (expm1 (* -2.0 x)))) -1.0)))))
double code(double x, double y) {
double t_0 = 2.0 / (1.0 + exp((-2.0 * x)));
double tmp;
if (t_0 <= 0.0) {
tmp = -1.0;
} else if (t_0 <= 1.0) {
tmp = x + (-0.3333333333333333 * pow(x, 3.0));
} else {
tmp = (2.0 / (expm1((x * -4.0)) / expm1((-2.0 * x)))) + -1.0;
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = 2.0 / (1.0 + Math.exp((-2.0 * x)));
double tmp;
if (t_0 <= 0.0) {
tmp = -1.0;
} else if (t_0 <= 1.0) {
tmp = x + (-0.3333333333333333 * Math.pow(x, 3.0));
} else {
tmp = (2.0 / (Math.expm1((x * -4.0)) / Math.expm1((-2.0 * x)))) + -1.0;
}
return tmp;
}
def code(x, y): t_0 = 2.0 / (1.0 + math.exp((-2.0 * x))) tmp = 0 if t_0 <= 0.0: tmp = -1.0 elif t_0 <= 1.0: tmp = x + (-0.3333333333333333 * math.pow(x, 3.0)) else: tmp = (2.0 / (math.expm1((x * -4.0)) / math.expm1((-2.0 * x)))) + -1.0 return tmp
function code(x, y) t_0 = Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) tmp = 0.0 if (t_0 <= 0.0) tmp = -1.0; elseif (t_0 <= 1.0) tmp = Float64(x + Float64(-0.3333333333333333 * (x ^ 3.0))); else tmp = Float64(Float64(2.0 / Float64(expm1(Float64(x * -4.0)) / expm1(Float64(-2.0 * x)))) + -1.0); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], -1.0, If[LessEqual[t$95$0, 1.0], N[(x + N[(-0.3333333333333333 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / N[(N[(Exp[N[(x * -4.0), $MachinePrecision]] - 1), $MachinePrecision] / N[(Exp[N[(-2.0 * x), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{1 + e^{-2 \cdot x}}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;-1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;x + -0.3333333333333333 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\mathsf{expm1}\left(x \cdot -4\right)}{\mathsf{expm1}\left(-2 \cdot x\right)}} + -1\\
\end{array}
\end{array}
if (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) < 0.0Initial program 100.0%
Taylor expanded in x around 0 99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in x around inf 100.0%
if 0.0 < (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) < 1Initial program 7.8%
expm1-log1p-u7.7%
expm1-undefine7.7%
log1p-undefine7.7%
+-commutative7.7%
add-exp-log7.7%
+-commutative7.7%
exp-prod7.7%
Applied egg-rr7.7%
Taylor expanded in x around 0 100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-*l*100.0%
unpow2100.0%
unpow3100.0%
Simplified100.0%
if 1 < (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) Initial program 98.0%
flip-+96.7%
metadata-eval96.7%
div-sub96.7%
exp-prod96.7%
pow296.7%
*-commutative96.7%
exp-prod96.7%
pow-pow96.7%
metadata-eval96.7%
exp-prod96.7%
Applied egg-rr96.7%
div-sub96.7%
remove-double-neg96.7%
distribute-neg-frac296.7%
distribute-frac-neg96.7%
sub-neg96.7%
+-commutative96.7%
distribute-neg-in96.7%
remove-double-neg96.7%
exp-prod96.7%
*-commutative96.7%
metadata-eval96.7%
associate-*r*96.7%
sub-neg96.7%
sub-neg96.7%
+-commutative96.7%
distribute-neg-in96.7%
remove-double-neg96.7%
sub-neg96.7%
exp-prod96.7%
expm1-undefine96.8%
Simplified98.0%
Final simplification99.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ 2.0 (+ 1.0 (exp (* -2.0 x))))))
(if (<= t_0 0.0)
-1.0
(if (<= t_0 1.0)
(+ x (* -0.3333333333333333 (pow x 3.0)))
(+ t_0 -1.0)))))
double code(double x, double y) {
double t_0 = 2.0 / (1.0 + exp((-2.0 * x)));
double tmp;
if (t_0 <= 0.0) {
tmp = -1.0;
} else if (t_0 <= 1.0) {
tmp = x + (-0.3333333333333333 * pow(x, 3.0));
} else {
tmp = t_0 + -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (1.0d0 + exp(((-2.0d0) * x)))
if (t_0 <= 0.0d0) then
tmp = -1.0d0
else if (t_0 <= 1.0d0) then
tmp = x + ((-0.3333333333333333d0) * (x ** 3.0d0))
else
tmp = t_0 + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 2.0 / (1.0 + Math.exp((-2.0 * x)));
double tmp;
if (t_0 <= 0.0) {
tmp = -1.0;
} else if (t_0 <= 1.0) {
tmp = x + (-0.3333333333333333 * Math.pow(x, 3.0));
} else {
tmp = t_0 + -1.0;
}
return tmp;
}
def code(x, y): t_0 = 2.0 / (1.0 + math.exp((-2.0 * x))) tmp = 0 if t_0 <= 0.0: tmp = -1.0 elif t_0 <= 1.0: tmp = x + (-0.3333333333333333 * math.pow(x, 3.0)) else: tmp = t_0 + -1.0 return tmp
function code(x, y) t_0 = Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) tmp = 0.0 if (t_0 <= 0.0) tmp = -1.0; elseif (t_0 <= 1.0) tmp = Float64(x + Float64(-0.3333333333333333 * (x ^ 3.0))); else tmp = Float64(t_0 + -1.0); end return tmp end
function tmp_2 = code(x, y) t_0 = 2.0 / (1.0 + exp((-2.0 * x))); tmp = 0.0; if (t_0 <= 0.0) tmp = -1.0; elseif (t_0 <= 1.0) tmp = x + (-0.3333333333333333 * (x ^ 3.0)); else tmp = t_0 + -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], -1.0, If[LessEqual[t$95$0, 1.0], N[(x + N[(-0.3333333333333333 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + -1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{1 + e^{-2 \cdot x}}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;-1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;x + -0.3333333333333333 \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;t\_0 + -1\\
\end{array}
\end{array}
if (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) < 0.0Initial program 100.0%
Taylor expanded in x around 0 99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in x around inf 100.0%
if 0.0 < (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) < 1Initial program 7.8%
expm1-log1p-u7.7%
expm1-undefine7.7%
log1p-undefine7.7%
+-commutative7.7%
add-exp-log7.7%
+-commutative7.7%
exp-prod7.7%
Applied egg-rr7.7%
Taylor expanded in x around 0 100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-*l*100.0%
unpow2100.0%
unpow3100.0%
Simplified100.0%
if 1 < (/.f64 #s(literal 2 binary64) (+.f64 #s(literal 1 binary64) (exp.f64 (*.f64 #s(literal -2 binary64) x)))) Initial program 98.0%
Final simplification99.5%
(FPCore (x y)
:precision binary64
(if (<= x -2.55e-5)
(+
(/ 2.0 (+ 2.0 (* x (- (* x (+ 2.0 (* x -1.3333333333333333))) 2.0))))
-1.0)
(/ (* 2.0 x) (+ 2.0 x))))
double code(double x, double y) {
double tmp;
if (x <= -2.55e-5) {
tmp = (2.0 / (2.0 + (x * ((x * (2.0 + (x * -1.3333333333333333))) - 2.0)))) + -1.0;
} else {
tmp = (2.0 * x) / (2.0 + x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-2.55d-5)) then
tmp = (2.0d0 / (2.0d0 + (x * ((x * (2.0d0 + (x * (-1.3333333333333333d0)))) - 2.0d0)))) + (-1.0d0)
else
tmp = (2.0d0 * x) / (2.0d0 + x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2.55e-5) {
tmp = (2.0 / (2.0 + (x * ((x * (2.0 + (x * -1.3333333333333333))) - 2.0)))) + -1.0;
} else {
tmp = (2.0 * x) / (2.0 + x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.55e-5: tmp = (2.0 / (2.0 + (x * ((x * (2.0 + (x * -1.3333333333333333))) - 2.0)))) + -1.0 else: tmp = (2.0 * x) / (2.0 + x) return tmp
function code(x, y) tmp = 0.0 if (x <= -2.55e-5) tmp = Float64(Float64(2.0 / Float64(2.0 + Float64(x * Float64(Float64(x * Float64(2.0 + Float64(x * -1.3333333333333333))) - 2.0)))) + -1.0); else tmp = Float64(Float64(2.0 * x) / Float64(2.0 + x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.55e-5) tmp = (2.0 / (2.0 + (x * ((x * (2.0 + (x * -1.3333333333333333))) - 2.0)))) + -1.0; else tmp = (2.0 * x) / (2.0 + x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.55e-5], N[(N[(2.0 / N[(2.0 + N[(x * N[(N[(x * N[(2.0 + N[(x * -1.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(2.0 * x), $MachinePrecision] / N[(2.0 + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.55 \cdot 10^{-5}:\\
\;\;\;\;\frac{2}{2 + x \cdot \left(x \cdot \left(2 + x \cdot -1.3333333333333333\right) - 2\right)} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot x}{2 + x}\\
\end{array}
\end{array}
if x < -2.54999999999999998e-5Initial program 99.7%
Taylor expanded in x around 0 99.7%
if -2.54999999999999998e-5 < x Initial program 37.5%
Taylor expanded in x around 0 7.3%
+-commutative7.3%
Simplified7.3%
flip--7.3%
pow27.3%
+-commutative7.3%
metadata-eval7.3%
+-commutative7.3%
Applied egg-rr7.3%
unpow27.3%
difference-of-sqr-17.3%
+-commutative7.3%
associate-+l+7.3%
metadata-eval7.3%
sub-neg7.3%
metadata-eval7.3%
+-commutative7.3%
associate-+r+69.5%
metadata-eval69.5%
+-lft-identity69.5%
+-commutative69.5%
associate-+l+69.5%
metadata-eval69.5%
Simplified69.5%
Taylor expanded in x around 0 72.9%
*-commutative72.9%
Simplified72.9%
Final simplification80.2%
(FPCore (x y) :precision binary64 (if (<= x -2.55e-5) (+ (/ 2.0 (+ 2.0 (* x (- (* 2.0 x) 2.0)))) -1.0) (/ (* 2.0 x) (+ 2.0 x))))
double code(double x, double y) {
double tmp;
if (x <= -2.55e-5) {
tmp = (2.0 / (2.0 + (x * ((2.0 * x) - 2.0)))) + -1.0;
} else {
tmp = (2.0 * x) / (2.0 + x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-2.55d-5)) then
tmp = (2.0d0 / (2.0d0 + (x * ((2.0d0 * x) - 2.0d0)))) + (-1.0d0)
else
tmp = (2.0d0 * x) / (2.0d0 + x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2.55e-5) {
tmp = (2.0 / (2.0 + (x * ((2.0 * x) - 2.0)))) + -1.0;
} else {
tmp = (2.0 * x) / (2.0 + x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.55e-5: tmp = (2.0 / (2.0 + (x * ((2.0 * x) - 2.0)))) + -1.0 else: tmp = (2.0 * x) / (2.0 + x) return tmp
function code(x, y) tmp = 0.0 if (x <= -2.55e-5) tmp = Float64(Float64(2.0 / Float64(2.0 + Float64(x * Float64(Float64(2.0 * x) - 2.0)))) + -1.0); else tmp = Float64(Float64(2.0 * x) / Float64(2.0 + x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.55e-5) tmp = (2.0 / (2.0 + (x * ((2.0 * x) - 2.0)))) + -1.0; else tmp = (2.0 * x) / (2.0 + x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.55e-5], N[(N[(2.0 / N[(2.0 + N[(x * N[(N[(2.0 * x), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(2.0 * x), $MachinePrecision] / N[(2.0 + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.55 \cdot 10^{-5}:\\
\;\;\;\;\frac{2}{2 + x \cdot \left(2 \cdot x - 2\right)} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot x}{2 + x}\\
\end{array}
\end{array}
if x < -2.54999999999999998e-5Initial program 99.7%
Taylor expanded in x around 0 99.5%
if -2.54999999999999998e-5 < x Initial program 37.5%
Taylor expanded in x around 0 7.3%
+-commutative7.3%
Simplified7.3%
flip--7.3%
pow27.3%
+-commutative7.3%
metadata-eval7.3%
+-commutative7.3%
Applied egg-rr7.3%
unpow27.3%
difference-of-sqr-17.3%
+-commutative7.3%
associate-+l+7.3%
metadata-eval7.3%
sub-neg7.3%
metadata-eval7.3%
+-commutative7.3%
associate-+r+69.5%
metadata-eval69.5%
+-lft-identity69.5%
+-commutative69.5%
associate-+l+69.5%
metadata-eval69.5%
Simplified69.5%
Taylor expanded in x around 0 72.9%
*-commutative72.9%
Simplified72.9%
Final simplification80.1%
(FPCore (x y) :precision binary64 (if (<= x -1.0) -1.0 (if (<= x -3e-27) x (/ (* 2.0 x) (+ 2.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = -1.0;
} else if (x <= -3e-27) {
tmp = x;
} else {
tmp = (2.0 * x) / (2.0 + x);
}
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 <= (-3d-27)) then
tmp = x
else
tmp = (2.0d0 * x) / (2.0d0 + x)
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 <= -3e-27) {
tmp = x;
} else {
tmp = (2.0 * x) / (2.0 + x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = -1.0 elif x <= -3e-27: tmp = x else: tmp = (2.0 * x) / (2.0 + x) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = -1.0; elseif (x <= -3e-27) tmp = x; else tmp = Float64(Float64(2.0 * x) / Float64(2.0 + x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = -1.0; elseif (x <= -3e-27) tmp = x; else tmp = (2.0 * x) / (2.0 + x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], -1.0, If[LessEqual[x, -3e-27], x, N[(N[(2.0 * x), $MachinePrecision] / N[(2.0 + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-27}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot x}{2 + x}\\
\end{array}
\end{array}
if x < -1Initial program 100.0%
Taylor expanded in x around 0 99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in x around inf 100.0%
if -1 < x < -3.0000000000000001e-27Initial program 46.1%
Taylor expanded in x around 0 87.8%
if -3.0000000000000001e-27 < x Initial program 37.4%
Taylor expanded in x around 0 6.3%
+-commutative6.3%
Simplified6.3%
flip--6.2%
pow26.2%
+-commutative6.2%
metadata-eval6.2%
+-commutative6.2%
Applied egg-rr6.2%
unpow26.2%
difference-of-sqr-16.2%
+-commutative6.2%
associate-+l+6.2%
metadata-eval6.2%
sub-neg6.2%
metadata-eval6.2%
+-commutative6.2%
associate-+r+68.8%
metadata-eval68.8%
+-lft-identity68.8%
+-commutative68.8%
associate-+l+68.8%
metadata-eval68.8%
Simplified68.8%
Taylor expanded in x around 0 72.8%
*-commutative72.8%
Simplified72.8%
Final simplification80.5%
(FPCore (x y) :precision binary64 (if (<= x -2.9e+32) -1.0 x))
double code(double x, double y) {
double tmp;
if (x <= -2.9e+32) {
tmp = -1.0;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-2.9d+32)) then
tmp = -1.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2.9e+32) {
tmp = -1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.9e+32: tmp = -1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (x <= -2.9e+32) tmp = -1.0; else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.9e+32) tmp = -1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.9e+32], -1.0, x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{+32}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.90000000000000003e32Initial program 100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
if -2.90000000000000003e32 < x Initial program 39.0%
Taylor expanded in x around 0 68.3%
(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 54.5%
Taylor expanded in x around 0 31.0%
*-commutative31.0%
Simplified31.0%
Taylor expanded in x around inf 29.2%
herbie shell --seed 2024103
(FPCore (x y)
:name "Logistic function from Lakshay Garg"
:precision binary64
(- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))