
(FPCore (x) :precision binary64 (/ (- (exp x) (exp (- x))) 2.0))
double code(double x) {
return (exp(x) - exp(-x)) / 2.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (exp(x) - exp(-x)) / 2.0d0
end function
public static double code(double x) {
return (Math.exp(x) - Math.exp(-x)) / 2.0;
}
def code(x): return (math.exp(x) - math.exp(-x)) / 2.0
function code(x) return Float64(Float64(exp(x) - exp(Float64(-x))) / 2.0) end
function tmp = code(x) tmp = (exp(x) - exp(-x)) / 2.0; end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{x} - e^{-x}}{2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (/ (- (exp x) (exp (- x))) 2.0))
double code(double x) {
return (exp(x) - exp(-x)) / 2.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (exp(x) - exp(-x)) / 2.0d0
end function
public static double code(double x) {
return (Math.exp(x) - Math.exp(-x)) / 2.0;
}
def code(x): return (math.exp(x) - math.exp(-x)) / 2.0
function code(x) return Float64(Float64(exp(x) - exp(Float64(-x))) / 2.0) end
function tmp = code(x) tmp = (exp(x) - exp(-x)) / 2.0; end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{x} - e^{-x}}{2}
\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) (exp (- x_m)))))
(*
x_s
(if (<= t_0 0.001)
(/ (+ (* 0.3333333333333333 (pow x_m 3.0)) (* x_m 2.0)) 2.0)
(/ t_0 2.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) - exp(-x_m);
double tmp;
if (t_0 <= 0.001) {
tmp = ((0.3333333333333333 * pow(x_m, 3.0)) + (x_m * 2.0)) / 2.0;
} else {
tmp = t_0 / 2.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) - exp(-x_m)
if (t_0 <= 0.001d0) then
tmp = ((0.3333333333333333d0 * (x_m ** 3.0d0)) + (x_m * 2.0d0)) / 2.0d0
else
tmp = t_0 / 2.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) - Math.exp(-x_m);
double tmp;
if (t_0 <= 0.001) {
tmp = ((0.3333333333333333 * Math.pow(x_m, 3.0)) + (x_m * 2.0)) / 2.0;
} else {
tmp = t_0 / 2.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) - math.exp(-x_m) tmp = 0 if t_0 <= 0.001: tmp = ((0.3333333333333333 * math.pow(x_m, 3.0)) + (x_m * 2.0)) / 2.0 else: tmp = t_0 / 2.0 return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) t_0 = Float64(exp(x_m) - exp(Float64(-x_m))) tmp = 0.0 if (t_0 <= 0.001) tmp = Float64(Float64(Float64(0.3333333333333333 * (x_m ^ 3.0)) + Float64(x_m * 2.0)) / 2.0); else tmp = Float64(t_0 / 2.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) - exp(-x_m); tmp = 0.0; if (t_0 <= 0.001) tmp = ((0.3333333333333333 * (x_m ^ 3.0)) + (x_m * 2.0)) / 2.0; else tmp = t_0 / 2.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[(N[Exp[x$95$m], $MachinePrecision] - N[Exp[(-x$95$m)], $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[t$95$0, 0.001], N[(N[(N[(0.3333333333333333 * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision] + N[(x$95$m * 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]), $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} - e^{-x\_m}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 0.001:\\
\;\;\;\;\frac{0.3333333333333333 \cdot {x\_m}^{3} + x\_m \cdot 2}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{2}\\
\end{array}
\end{array}
\end{array}
if (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) < 1e-3Initial program 37.0%
Taylor expanded in x around 0 90.8%
if 1e-3 < (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) Initial program 100.0%
Final simplification93.1%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m)
:precision binary64
(*
x_s
(if (<= x_m 1500000.0)
(/ (+ (* 0.3333333333333333 (pow x_m 3.0)) (* x_m 2.0)) 2.0)
(sqrt (* (pow x_m 6.0) 0.027777777777777776)))))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 1500000.0) {
tmp = ((0.3333333333333333 * pow(x_m, 3.0)) + (x_m * 2.0)) / 2.0;
} else {
tmp = sqrt((pow(x_m, 6.0) * 0.027777777777777776));
}
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 <= 1500000.0d0) then
tmp = ((0.3333333333333333d0 * (x_m ** 3.0d0)) + (x_m * 2.0d0)) / 2.0d0
else
tmp = sqrt(((x_m ** 6.0d0) * 0.027777777777777776d0))
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 <= 1500000.0) {
tmp = ((0.3333333333333333 * Math.pow(x_m, 3.0)) + (x_m * 2.0)) / 2.0;
} else {
tmp = Math.sqrt((Math.pow(x_m, 6.0) * 0.027777777777777776));
}
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 <= 1500000.0: tmp = ((0.3333333333333333 * math.pow(x_m, 3.0)) + (x_m * 2.0)) / 2.0 else: tmp = math.sqrt((math.pow(x_m, 6.0) * 0.027777777777777776)) 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 <= 1500000.0) tmp = Float64(Float64(Float64(0.3333333333333333 * (x_m ^ 3.0)) + Float64(x_m * 2.0)) / 2.0); else tmp = sqrt(Float64((x_m ^ 6.0) * 0.027777777777777776)); 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 <= 1500000.0) tmp = ((0.3333333333333333 * (x_m ^ 3.0)) + (x_m * 2.0)) / 2.0; else tmp = sqrt(((x_m ^ 6.0) * 0.027777777777777776)); 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, 1500000.0], N[(N[(N[(0.3333333333333333 * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision] + N[(x$95$m * 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[Sqrt[N[(N[Power[x$95$m, 6.0], $MachinePrecision] * 0.027777777777777776), $MachinePrecision]], $MachinePrecision]]), $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 1500000:\\
\;\;\;\;\frac{0.3333333333333333 \cdot {x\_m}^{3} + x\_m \cdot 2}{2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{x\_m}^{6} \cdot 0.027777777777777776}\\
\end{array}
\end{array}
if x < 1.5e6Initial program 37.3%
Taylor expanded in x around 0 90.5%
if 1.5e6 < x Initial program 100.0%
Taylor expanded in x around 0 66.4%
Taylor expanded in x around inf 66.4%
pow166.4%
sqr-pow66.4%
pow-prod-down82.9%
Applied egg-rr82.9%
unpow1/282.9%
associate-*l*82.9%
metadata-eval82.9%
Simplified82.9%
Final simplification88.6%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m)
:precision binary64
(*
x_s
(if (<= x_m 5000000000.0)
(/ (+ (* 0.3333333333333333 (pow x_m 3.0)) (* x_m 2.0)) 2.0)
(* (cbrt (pow x_m 9.0)) 0.16666666666666666))))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 5000000000.0) {
tmp = ((0.3333333333333333 * pow(x_m, 3.0)) + (x_m * 2.0)) / 2.0;
} else {
tmp = cbrt(pow(x_m, 9.0)) * 0.16666666666666666;
}
return x_s * tmp;
}
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 <= 5000000000.0) {
tmp = ((0.3333333333333333 * Math.pow(x_m, 3.0)) + (x_m * 2.0)) / 2.0;
} else {
tmp = Math.cbrt(Math.pow(x_m, 9.0)) * 0.16666666666666666;
}
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 <= 5000000000.0) tmp = Float64(Float64(Float64(0.3333333333333333 * (x_m ^ 3.0)) + Float64(x_m * 2.0)) / 2.0); else tmp = Float64(cbrt((x_m ^ 9.0)) * 0.16666666666666666); end return Float64(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, 5000000000.0], N[(N[(N[(0.3333333333333333 * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision] + N[(x$95$m * 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[Power[N[Power[x$95$m, 9.0], $MachinePrecision], 1/3], $MachinePrecision] * 0.16666666666666666), $MachinePrecision]]), $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 5000000000:\\
\;\;\;\;\frac{0.3333333333333333 \cdot {x\_m}^{3} + x\_m \cdot 2}{2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{x\_m}^{9}} \cdot 0.16666666666666666\\
\end{array}
\end{array}
if x < 5e9Initial program 37.7%
Taylor expanded in x around 0 90.0%
if 5e9 < x Initial program 100.0%
Taylor expanded in x around 0 67.5%
Taylor expanded in x around inf 67.5%
div-inv67.5%
metadata-eval67.5%
pow-plus67.5%
*-commutative67.5%
associate-*l*67.5%
pow-plus67.5%
metadata-eval67.5%
metadata-eval67.5%
metadata-eval67.5%
Applied egg-rr67.5%
add-cbrt-cube90.5%
pow390.5%
pow-pow90.5%
metadata-eval90.5%
Applied egg-rr90.5%
Final simplification90.1%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m) :precision binary64 (* x_s (if (<= x_m 2.5) (/ (* x_m 2.0) 2.0) (/ 1.0 (* 6.0 (pow x_m -3.0))))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 2.5) {
tmp = (x_m * 2.0) / 2.0;
} else {
tmp = 1.0 / (6.0 * pow(x_m, -3.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 <= 2.5d0) then
tmp = (x_m * 2.0d0) / 2.0d0
else
tmp = 1.0d0 / (6.0d0 * (x_m ** (-3.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 <= 2.5) {
tmp = (x_m * 2.0) / 2.0;
} else {
tmp = 1.0 / (6.0 * Math.pow(x_m, -3.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 <= 2.5: tmp = (x_m * 2.0) / 2.0 else: tmp = 1.0 / (6.0 * math.pow(x_m, -3.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 <= 2.5) tmp = Float64(Float64(x_m * 2.0) / 2.0); else tmp = Float64(1.0 / Float64(6.0 * (x_m ^ -3.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 <= 2.5) tmp = (x_m * 2.0) / 2.0; else tmp = 1.0 / (6.0 * (x_m ^ -3.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, 2.5], N[(N[(x$95$m * 2.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(1.0 / N[(6.0 * N[Power[x$95$m, -3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $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 2.5:\\
\;\;\;\;\frac{x\_m \cdot 2}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{6 \cdot {x\_m}^{-3}}\\
\end{array}
\end{array}
if x < 2.5Initial program 37.0%
Taylor expanded in x around 0 69.5%
if 2.5 < x Initial program 100.0%
Taylor expanded in x around 0 65.6%
Taylor expanded in x around inf 65.6%
pow165.6%
sqr-pow65.6%
pow-prod-down81.9%
Applied egg-rr81.9%
unpow1/281.9%
associate-*l*81.9%
metadata-eval81.9%
Simplified81.9%
sqrt-prod81.9%
sqrt-pow165.6%
metadata-eval65.6%
add-sqr-sqrt65.6%
metadata-eval65.6%
add-sqr-sqrt65.6%
metadata-eval65.6%
div-inv65.6%
clear-num65.6%
pow165.6%
pow165.6%
div-inv65.6%
pow-flip65.6%
metadata-eval65.6%
Applied egg-rr65.6%
Final simplification68.5%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m) :precision binary64 (* x_s (/ (+ (* 0.3333333333333333 (pow x_m 3.0)) (* x_m 2.0)) 2.0)))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
return x_s * (((0.3333333333333333 * pow(x_m, 3.0)) + (x_m * 2.0)) / 2.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 * (((0.3333333333333333d0 * (x_m ** 3.0d0)) + (x_m * 2.0d0)) / 2.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 * (((0.3333333333333333 * Math.pow(x_m, 3.0)) + (x_m * 2.0)) / 2.0);
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): return x_s * (((0.3333333333333333 * math.pow(x_m, 3.0)) + (x_m * 2.0)) / 2.0)
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) return Float64(x_s * Float64(Float64(Float64(0.3333333333333333 * (x_m ^ 3.0)) + Float64(x_m * 2.0)) / 2.0)) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m) tmp = x_s * (((0.3333333333333333 * (x_m ^ 3.0)) + (x_m * 2.0)) / 2.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 * N[(N[(N[(0.3333333333333333 * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision] + N[(x$95$m * 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \frac{0.3333333333333333 \cdot {x\_m}^{3} + x\_m \cdot 2}{2}
\end{array}
Initial program 52.5%
Taylor expanded in x around 0 84.6%
Final simplification84.6%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m) :precision binary64 (* x_s (if (<= x_m 2.5) (/ (* x_m 2.0) 2.0) (* (pow x_m 3.0) 0.16666666666666666))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 2.5) {
tmp = (x_m * 2.0) / 2.0;
} else {
tmp = pow(x_m, 3.0) * 0.16666666666666666;
}
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 <= 2.5d0) then
tmp = (x_m * 2.0d0) / 2.0d0
else
tmp = (x_m ** 3.0d0) * 0.16666666666666666d0
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 <= 2.5) {
tmp = (x_m * 2.0) / 2.0;
} else {
tmp = Math.pow(x_m, 3.0) * 0.16666666666666666;
}
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 <= 2.5: tmp = (x_m * 2.0) / 2.0 else: tmp = math.pow(x_m, 3.0) * 0.16666666666666666 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 <= 2.5) tmp = Float64(Float64(x_m * 2.0) / 2.0); else tmp = Float64((x_m ^ 3.0) * 0.16666666666666666); 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 <= 2.5) tmp = (x_m * 2.0) / 2.0; else tmp = (x_m ^ 3.0) * 0.16666666666666666; 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, 2.5], N[(N[(x$95$m * 2.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[Power[x$95$m, 3.0], $MachinePrecision] * 0.16666666666666666), $MachinePrecision]]), $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 2.5:\\
\;\;\;\;\frac{x\_m \cdot 2}{2}\\
\mathbf{else}:\\
\;\;\;\;{x\_m}^{3} \cdot 0.16666666666666666\\
\end{array}
\end{array}
if x < 2.5Initial program 37.0%
Taylor expanded in x around 0 69.5%
if 2.5 < x Initial program 100.0%
Taylor expanded in x around 0 65.6%
Taylor expanded in x around inf 65.6%
div-inv65.6%
metadata-eval65.6%
pow-plus65.6%
*-commutative65.6%
associate-*l*65.6%
pow-plus65.6%
metadata-eval65.6%
metadata-eval65.6%
metadata-eval65.6%
Applied egg-rr65.6%
Final simplification68.5%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m) :precision binary64 (* x_s (/ (* x_m 2.0) 2.0)))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
return x_s * ((x_m * 2.0) / 2.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 * ((x_m * 2.0d0) / 2.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 * ((x_m * 2.0) / 2.0);
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): return x_s * ((x_m * 2.0) / 2.0)
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) return Float64(x_s * Float64(Float64(x_m * 2.0) / 2.0)) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m) tmp = x_s * ((x_m * 2.0) / 2.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 * N[(N[(x$95$m * 2.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \frac{x\_m \cdot 2}{2}
\end{array}
Initial program 52.5%
Taylor expanded in x around 0 53.7%
Final simplification53.7%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m) :precision binary64 (* x_s 0.0))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
return x_s * 0.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 * 0.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 * 0.0;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): return x_s * 0.0
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) return Float64(x_s * 0.0) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m) tmp = x_s * 0.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 * 0.0), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot 0
\end{array}
Initial program 52.5%
Applied egg-rr3.5%
Final simplification3.5%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m) :precision binary64 (* x_s 0.25))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
return x_s * 0.25;
}
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.25d0
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.25;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): return x_s * 0.25
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) return Float64(x_s * 0.25) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m) tmp = x_s * 0.25; 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.25), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot 0.25
\end{array}
Initial program 52.5%
Applied egg-rr2.9%
Final simplification2.9%
herbie shell --seed 2024026
(FPCore (x)
:name "Hyperbolic sine"
:precision binary64
(/ (- (exp x) (exp (- x))) 2.0))