
(FPCore (x) :precision binary64 (let* ((t_0 (exp (- x)))) (/ (- (exp x) t_0) (+ (exp x) t_0))))
double code(double x) {
double t_0 = exp(-x);
return (exp(x) - t_0) / (exp(x) + t_0);
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = exp(-x)
code = (exp(x) - t_0) / (exp(x) + t_0)
end function
public static double code(double x) {
double t_0 = Math.exp(-x);
return (Math.exp(x) - t_0) / (Math.exp(x) + t_0);
}
def code(x): t_0 = math.exp(-x) return (math.exp(x) - t_0) / (math.exp(x) + t_0)
function code(x) t_0 = exp(Float64(-x)) return Float64(Float64(exp(x) - t_0) / Float64(exp(x) + t_0)) end
function tmp = code(x) t_0 = exp(-x); tmp = (exp(x) - t_0) / (exp(x) + t_0); end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, N[(N[(N[Exp[x], $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\frac{e^{x} - t\_0}{e^{x} + t\_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (let* ((t_0 (exp (- x)))) (/ (- (exp x) t_0) (+ (exp x) t_0))))
double code(double x) {
double t_0 = exp(-x);
return (exp(x) - t_0) / (exp(x) + t_0);
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = exp(-x)
code = (exp(x) - t_0) / (exp(x) + t_0)
end function
public static double code(double x) {
double t_0 = Math.exp(-x);
return (Math.exp(x) - t_0) / (Math.exp(x) + t_0);
}
def code(x): t_0 = math.exp(-x) return (math.exp(x) - t_0) / (math.exp(x) + t_0)
function code(x) t_0 = exp(Float64(-x)) return Float64(Float64(exp(x) - t_0) / Float64(exp(x) + t_0)) end
function tmp = code(x) t_0 = exp(-x); tmp = (exp(x) - t_0) / (exp(x) + t_0); end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, N[(N[(N[Exp[x], $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\frac{e^{x} - t\_0}{e^{x} + t\_0}
\end{array}
\end{array}
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m)
:precision binary64
(let* ((t_0 (exp (- x_m))))
(*
x_s
(if (<= (/ (- (exp x_m) t_0) (+ (exp x_m) t_0)) 0.6)
(+
x_m
(+
(* -0.3333333333333333 (pow x_m 3.0))
(+
(* -0.05396825396825397 (pow x_m 7.0))
(* 0.13333333333333333 (pow x_m 5.0)))))
1.0))))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double t_0 = exp(-x_m);
double tmp;
if (((exp(x_m) - t_0) / (exp(x_m) + t_0)) <= 0.6) {
tmp = x_m + ((-0.3333333333333333 * pow(x_m, 3.0)) + ((-0.05396825396825397 * pow(x_m, 7.0)) + (0.13333333333333333 * pow(x_m, 5.0))));
} else {
tmp = 1.0;
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-x_m)
if (((exp(x_m) - t_0) / (exp(x_m) + t_0)) <= 0.6d0) then
tmp = x_m + (((-0.3333333333333333d0) * (x_m ** 3.0d0)) + (((-0.05396825396825397d0) * (x_m ** 7.0d0)) + (0.13333333333333333d0 * (x_m ** 5.0d0))))
else
tmp = 1.0d0
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
double t_0 = Math.exp(-x_m);
double tmp;
if (((Math.exp(x_m) - t_0) / (Math.exp(x_m) + t_0)) <= 0.6) {
tmp = x_m + ((-0.3333333333333333 * Math.pow(x_m, 3.0)) + ((-0.05396825396825397 * Math.pow(x_m, 7.0)) + (0.13333333333333333 * Math.pow(x_m, 5.0))));
} else {
tmp = 1.0;
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): t_0 = math.exp(-x_m) tmp = 0 if ((math.exp(x_m) - t_0) / (math.exp(x_m) + t_0)) <= 0.6: tmp = x_m + ((-0.3333333333333333 * math.pow(x_m, 3.0)) + ((-0.05396825396825397 * math.pow(x_m, 7.0)) + (0.13333333333333333 * math.pow(x_m, 5.0)))) else: tmp = 1.0 return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) t_0 = exp(Float64(-x_m)) tmp = 0.0 if (Float64(Float64(exp(x_m) - t_0) / Float64(exp(x_m) + t_0)) <= 0.6) tmp = Float64(x_m + Float64(Float64(-0.3333333333333333 * (x_m ^ 3.0)) + Float64(Float64(-0.05396825396825397 * (x_m ^ 7.0)) + Float64(0.13333333333333333 * (x_m ^ 5.0))))); else tmp = 1.0; end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m) t_0 = exp(-x_m); tmp = 0.0; if (((exp(x_m) - t_0) / (exp(x_m) + t_0)) <= 0.6) tmp = x_m + ((-0.3333333333333333 * (x_m ^ 3.0)) + ((-0.05396825396825397 * (x_m ^ 7.0)) + (0.13333333333333333 * (x_m ^ 5.0)))); else tmp = 1.0; end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := Block[{t$95$0 = N[Exp[(-x$95$m)], $MachinePrecision]}, N[(x$95$s * If[LessEqual[N[(N[(N[Exp[x$95$m], $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[Exp[x$95$m], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], 0.6], N[(x$95$m + N[(N[(-0.3333333333333333 * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-0.05396825396825397 * N[Power[x$95$m, 7.0], $MachinePrecision]), $MachinePrecision] + N[(0.13333333333333333 * N[Power[x$95$m, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_0 := e^{-x\_m}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{e^{x\_m} - t\_0}{e^{x\_m} + t\_0} \leq 0.6:\\
\;\;\;\;x\_m + \left(-0.3333333333333333 \cdot {x\_m}^{3} + \left(-0.05396825396825397 \cdot {x\_m}^{7} + 0.13333333333333333 \cdot {x\_m}^{5}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
\end{array}
if (/.f64 (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) (+.f64 (exp.f64 x) (exp.f64 (neg.f64 x)))) < 0.599999999999999978Initial program 7.5%
Taylor expanded in x around 0 99.3%
if 0.599999999999999978 < (/.f64 (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) (+.f64 (exp.f64 x) (exp.f64 (neg.f64 x)))) Initial program 33.3%
Taylor expanded in x around 0 5.7%
Taylor expanded in x around inf 5.7%
associate-*r/5.7%
*-commutative5.7%
cube-mult5.7%
associate-*l*5.7%
associate-*l/5.7%
*-commutative5.7%
distribute-rgt-in5.7%
associate-*l*5.7%
Simplified5.7%
Applied egg-rr6.7%
Applied egg-rr59.7%
Final simplification98.0%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m)
:precision binary64
(*
x_s
(if (<= x_m 1.25)
(+ x_m (+ (* -0.3333333333333333 (pow x_m 3.0)) (* (pow x_m 5.0) 0.125)))
1.0)))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 1.25) {
tmp = x_m + ((-0.3333333333333333 * pow(x_m, 3.0)) + (pow(x_m, 5.0) * 0.125));
} else {
tmp = 1.0;
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8) :: tmp
if (x_m <= 1.25d0) then
tmp = x_m + (((-0.3333333333333333d0) * (x_m ** 3.0d0)) + ((x_m ** 5.0d0) * 0.125d0))
else
tmp = 1.0d0
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
double tmp;
if (x_m <= 1.25) {
tmp = x_m + ((-0.3333333333333333 * Math.pow(x_m, 3.0)) + (Math.pow(x_m, 5.0) * 0.125));
} else {
tmp = 1.0;
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): tmp = 0 if x_m <= 1.25: tmp = x_m + ((-0.3333333333333333 * math.pow(x_m, 3.0)) + (math.pow(x_m, 5.0) * 0.125)) else: tmp = 1.0 return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) tmp = 0.0 if (x_m <= 1.25) tmp = Float64(x_m + Float64(Float64(-0.3333333333333333 * (x_m ^ 3.0)) + Float64((x_m ^ 5.0) * 0.125))); else tmp = 1.0; end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m) tmp = 0.0; if (x_m <= 1.25) tmp = x_m + ((-0.3333333333333333 * (x_m ^ 3.0)) + ((x_m ^ 5.0) * 0.125)); else tmp = 1.0; end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * If[LessEqual[x$95$m, 1.25], N[(x$95$m + N[(N[(-0.3333333333333333 * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[x$95$m, 5.0], $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1.25:\\
\;\;\;\;x\_m + \left(-0.3333333333333333 \cdot {x\_m}^{3} + {x\_m}^{5} \cdot 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 1.25Initial program 7.4%
Taylor expanded in x around 0 98.2%
Taylor expanded in x around 0 98.2%
if 1.25 < x Initial program 50.0%
Taylor expanded in x around 0 7.0%
Taylor expanded in x around inf 7.0%
associate-*r/7.0%
*-commutative7.0%
cube-mult7.0%
associate-*l*7.0%
associate-*l/7.0%
*-commutative7.0%
distribute-rgt-in7.0%
associate-*l*7.0%
Simplified7.0%
Applied egg-rr8.4%
Applied egg-rr88.8%
Final simplification98.0%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m)
:precision binary64
(*
x_s
(if (<= x_m 1.25)
(+
x_m
(+
(* -0.3333333333333333 (pow x_m 3.0))
(* 0.13333333333333333 (pow x_m 5.0))))
1.0)))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 1.25) {
tmp = x_m + ((-0.3333333333333333 * pow(x_m, 3.0)) + (0.13333333333333333 * pow(x_m, 5.0)));
} else {
tmp = 1.0;
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8) :: tmp
if (x_m <= 1.25d0) then
tmp = x_m + (((-0.3333333333333333d0) * (x_m ** 3.0d0)) + (0.13333333333333333d0 * (x_m ** 5.0d0)))
else
tmp = 1.0d0
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
double tmp;
if (x_m <= 1.25) {
tmp = x_m + ((-0.3333333333333333 * Math.pow(x_m, 3.0)) + (0.13333333333333333 * Math.pow(x_m, 5.0)));
} else {
tmp = 1.0;
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): tmp = 0 if x_m <= 1.25: tmp = x_m + ((-0.3333333333333333 * math.pow(x_m, 3.0)) + (0.13333333333333333 * math.pow(x_m, 5.0))) else: tmp = 1.0 return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) tmp = 0.0 if (x_m <= 1.25) tmp = Float64(x_m + Float64(Float64(-0.3333333333333333 * (x_m ^ 3.0)) + Float64(0.13333333333333333 * (x_m ^ 5.0)))); else tmp = 1.0; end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m) tmp = 0.0; if (x_m <= 1.25) tmp = x_m + ((-0.3333333333333333 * (x_m ^ 3.0)) + (0.13333333333333333 * (x_m ^ 5.0))); else tmp = 1.0; end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * If[LessEqual[x$95$m, 1.25], N[(x$95$m + N[(N[(-0.3333333333333333 * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision] + N[(0.13333333333333333 * N[Power[x$95$m, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1.25:\\
\;\;\;\;x\_m + \left(-0.3333333333333333 \cdot {x\_m}^{3} + 0.13333333333333333 \cdot {x\_m}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 1.25Initial program 7.4%
Taylor expanded in x around 0 98.3%
if 1.25 < x Initial program 50.0%
Taylor expanded in x around 0 7.0%
Taylor expanded in x around inf 7.0%
associate-*r/7.0%
*-commutative7.0%
cube-mult7.0%
associate-*l*7.0%
associate-*l/7.0%
*-commutative7.0%
distribute-rgt-in7.0%
associate-*l*7.0%
Simplified7.0%
Applied egg-rr8.4%
Applied egg-rr88.8%
Final simplification98.0%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m) :precision binary64 (* x_s (if (<= x_m 1.15) (+ x_m (* -0.3333333333333333 (pow x_m 3.0))) 1.0)))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 1.15) {
tmp = x_m + (-0.3333333333333333 * pow(x_m, 3.0));
} else {
tmp = 1.0;
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8) :: tmp
if (x_m <= 1.15d0) then
tmp = x_m + ((-0.3333333333333333d0) * (x_m ** 3.0d0))
else
tmp = 1.0d0
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
double tmp;
if (x_m <= 1.15) {
tmp = x_m + (-0.3333333333333333 * Math.pow(x_m, 3.0));
} else {
tmp = 1.0;
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): tmp = 0 if x_m <= 1.15: tmp = x_m + (-0.3333333333333333 * math.pow(x_m, 3.0)) else: tmp = 1.0 return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) tmp = 0.0 if (x_m <= 1.15) tmp = Float64(x_m + Float64(-0.3333333333333333 * (x_m ^ 3.0))); else tmp = 1.0; end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m) tmp = 0.0; if (x_m <= 1.15) tmp = x_m + (-0.3333333333333333 * (x_m ^ 3.0)); else tmp = 1.0; end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * If[LessEqual[x$95$m, 1.15], N[(x$95$m + N[(-0.3333333333333333 * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1.15:\\
\;\;\;\;x\_m + -0.3333333333333333 \cdot {x\_m}^{3}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 1.1499999999999999Initial program 7.4%
Taylor expanded in x around 0 98.1%
*-commutative98.1%
Simplified98.1%
if 1.1499999999999999 < x Initial program 50.0%
Taylor expanded in x around 0 7.0%
Taylor expanded in x around inf 7.0%
associate-*r/7.0%
*-commutative7.0%
cube-mult7.0%
associate-*l*7.0%
associate-*l/7.0%
*-commutative7.0%
distribute-rgt-in7.0%
associate-*l*7.0%
Simplified7.0%
Applied egg-rr8.4%
Applied egg-rr88.8%
Final simplification97.9%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m) :precision binary64 (* x_s (if (<= x_m 1.0) x_m 1.0)))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 1.0) {
tmp = x_m;
} else {
tmp = 1.0;
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8) :: tmp
if (x_m <= 1.0d0) then
tmp = x_m
else
tmp = 1.0d0
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
double tmp;
if (x_m <= 1.0) {
tmp = x_m;
} else {
tmp = 1.0;
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): tmp = 0 if x_m <= 1.0: tmp = x_m else: tmp = 1.0 return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) tmp = 0.0 if (x_m <= 1.0) tmp = x_m; else tmp = 1.0; end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m) tmp = 0.0; if (x_m <= 1.0) tmp = x_m; else tmp = 1.0; end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * If[LessEqual[x$95$m, 1.0], x$95$m, 1.0]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 1Initial program 7.4%
Taylor expanded in x around 0 98.1%
if 1 < x Initial program 50.0%
Taylor expanded in x around 0 7.0%
Taylor expanded in x around inf 7.0%
associate-*r/7.0%
*-commutative7.0%
cube-mult7.0%
associate-*l*7.0%
associate-*l/7.0%
*-commutative7.0%
distribute-rgt-in7.0%
associate-*l*7.0%
Simplified7.0%
Applied egg-rr8.4%
Applied egg-rr88.8%
Final simplification97.9%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m) :precision binary64 (* x_s 0.5))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
return x_s * 0.5;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
code = x_s * 0.5d0
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
return x_s * 0.5;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): return x_s * 0.5
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) return Float64(x_s * 0.5) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m) tmp = x_s * 0.5; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * 0.5), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot 0.5
\end{array}
Initial program 8.4%
Taylor expanded in x around 0 96.0%
Taylor expanded in x around inf 96.0%
associate-*r/96.0%
*-commutative96.0%
cube-mult96.0%
associate-*l*96.0%
associate-*l/96.0%
*-commutative96.0%
distribute-rgt-in96.0%
associate-*l*96.0%
Simplified96.0%
Applied egg-rr95.3%
Applied egg-rr4.0%
Final simplification4.0%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m) :precision binary64 (* x_s 1.0))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
return x_s * 1.0;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
code = x_s * 1.0d0
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
return x_s * 1.0;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): return x_s * 1.0
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) return Float64(x_s * 1.0) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m) tmp = x_s * 1.0; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * 1.0), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot 1
\end{array}
Initial program 8.4%
Taylor expanded in x around 0 96.0%
Taylor expanded in x around inf 96.0%
associate-*r/96.0%
*-commutative96.0%
cube-mult96.0%
associate-*l*96.0%
associate-*l/96.0%
*-commutative96.0%
distribute-rgt-in96.0%
associate-*l*96.0%
Simplified96.0%
Applied egg-rr95.3%
Applied egg-rr5.6%
Final simplification5.6%
herbie shell --seed 2024029
(FPCore (x)
:name "Hyperbolic tangent"
:precision binary64
(/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))