
(FPCore (x) :precision binary64 (asinh x))
double code(double x) {
return asinh(x);
}
def code(x): return math.asinh(x)
function code(x) return asinh(x) end
function tmp = code(x) tmp = asinh(x); end
code[x_] := N[ArcSinh[x], $MachinePrecision]
\begin{array}{l}
\\
\sinh^{-1} x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
double code(double x) {
return copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x);
}
public static double code(double x) {
return Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x);
}
def code(x): return math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x)
function code(x) return copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + 1.0))))); end
code[x_] := N[With[{TMP1 = Abs[N[Log[N[(N[Abs[x], $MachinePrecision] + N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= t_0 0.0001)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x x)) x)))))
double code(double x) {
double t_0 = copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x);
double tmp;
if (t_0 <= -5.0) {
tmp = copysign(log((-0.5 / x)), x);
} else if (t_0 <= 0.0001) {
tmp = copysign((x + (-0.16666666666666666 * pow(x, 3.0))), x);
} else {
tmp = copysign(log((x + x)), x);
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x);
double tmp;
if (t_0 <= -5.0) {
tmp = Math.copySign(Math.log((-0.5 / x)), x);
} else if (t_0 <= 0.0001) {
tmp = Math.copySign((x + (-0.16666666666666666 * Math.pow(x, 3.0))), x);
} else {
tmp = Math.copySign(Math.log((x + x)), x);
}
return tmp;
}
def code(x): t_0 = math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x) tmp = 0 if t_0 <= -5.0: tmp = math.copysign(math.log((-0.5 / x)), x) elif t_0 <= 0.0001: tmp = math.copysign((x + (-0.16666666666666666 * math.pow(x, 3.0))), x) else: tmp = math.copysign(math.log((x + x)), x) return tmp
function code(x) t_0 = copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x) tmp = 0.0 if (t_0 <= -5.0) tmp = copysign(log(Float64(-0.5 / x)), x); elseif (t_0 <= 0.0001) tmp = copysign(Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))), x); else tmp = copysign(log(Float64(x + x)), x); end return tmp end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + 1.0))))); tmp = 0.0; if (t_0 <= -5.0) tmp = sign(x) * abs(log((-0.5 / x))); elseif (t_0 <= 0.0001) tmp = sign(x) * abs((x + (-0.16666666666666666 * (x ^ 3.0)))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[With[{TMP1 = Abs[N[Log[N[(N[Abs[x], $MachinePrecision] + N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]}, If[LessEqual[t$95$0, -5.0], N[With[{TMP1 = Abs[N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[t$95$0, 0.0001], N[With[{TMP1 = Abs[N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x + x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t_0 \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.0001:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < -5Initial program 54.5%
+-commutative54.5%
hypot-1-def98.5%
Simplified98.5%
Taylor expanded in x around -inf 98.5%
associate--l+98.5%
unpow198.5%
sqr-pow0.0%
fabs-sqr0.0%
sqr-pow4.9%
unpow14.9%
associate-+r-98.9%
mul-1-neg98.9%
sub-neg98.9%
+-inverses98.9%
neg-sub098.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
if -5 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < 1.00000000000000005e-4Initial program 6.7%
+-commutative6.7%
hypot-1-def6.7%
Simplified6.7%
*-un-lft-identity6.7%
log-prod6.7%
metadata-eval6.7%
*-un-lft-identity6.7%
*-un-lft-identity6.7%
add-sqr-sqrt3.9%
fabs-sqr3.9%
add-sqr-sqrt6.7%
Applied egg-rr6.7%
+-lft-identity6.7%
Simplified6.7%
Taylor expanded in x around 0 100.0%
if 1.00000000000000005e-4 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) Initial program 53.9%
+-commutative53.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
unpow1100.0%
sqr-pow100.0%
fabs-sqr100.0%
sqr-pow100.0%
unpow1100.0%
Simplified100.0%
Final simplification99.7%
(FPCore (x)
:precision binary64
(if (<= x -1.65)
(copysign (log (- x)) x)
(if (<= x 1.1)
(copysign (* (* x (+ x 2.0)) (+ 0.5 (* x -0.25))) x)
(copysign (log (+ x x)) x))))
double code(double x) {
double tmp;
if (x <= -1.65) {
tmp = copysign(log(-x), x);
} else if (x <= 1.1) {
tmp = copysign(((x * (x + 2.0)) * (0.5 + (x * -0.25))), x);
} else {
tmp = copysign(log((x + x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.65) {
tmp = Math.copySign(Math.log(-x), x);
} else if (x <= 1.1) {
tmp = Math.copySign(((x * (x + 2.0)) * (0.5 + (x * -0.25))), x);
} else {
tmp = Math.copySign(Math.log((x + x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.65: tmp = math.copysign(math.log(-x), x) elif x <= 1.1: tmp = math.copysign(((x * (x + 2.0)) * (0.5 + (x * -0.25))), x) else: tmp = math.copysign(math.log((x + x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.65) tmp = copysign(log(Float64(-x)), x); elseif (x <= 1.1) tmp = copysign(Float64(Float64(x * Float64(x + 2.0)) * Float64(0.5 + Float64(x * -0.25))), x); else tmp = copysign(log(Float64(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.65) tmp = sign(x) * abs(log(-x)); elseif (x <= 1.1) tmp = sign(x) * abs(((x * (x + 2.0)) * (0.5 + (x * -0.25)))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.65], N[With[{TMP1 = Abs[N[Log[(-x)], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 1.1], N[With[{TMP1 = Abs[N[(N[(x * N[(x + 2.0), $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(x * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x + x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.65:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 1.1:\\
\;\;\;\;\mathsf{copysign}\left(\left(x \cdot \left(x + 2\right)\right) \cdot \left(0.5 + x \cdot -0.25\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -1.6499999999999999Initial program 54.5%
+-commutative54.5%
hypot-1-def98.5%
Simplified98.5%
Taylor expanded in x around -inf 31.2%
mul-1-neg31.2%
Simplified31.2%
if -1.6499999999999999 < x < 1.1000000000000001Initial program 6.7%
+-commutative6.7%
hypot-1-def6.7%
Simplified6.7%
expm1-log1p-u6.7%
expm1-udef6.6%
log1p-udef6.6%
add-exp-log6.6%
*-un-lft-identity6.6%
*-un-lft-identity6.6%
add-sqr-sqrt3.9%
fabs-sqr3.9%
add-sqr-sqrt6.7%
Applied egg-rr6.7%
Taylor expanded in x around 0 6.5%
flip--6.5%
div-inv6.5%
metadata-eval6.5%
difference-of-sqr-16.5%
+-commutative6.5%
associate-+l+6.5%
metadata-eval6.5%
add-exp-log6.5%
log1p-udef6.5%
expm1-udef99.6%
expm1-log1p-u99.6%
+-commutative99.6%
associate-+l+99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in x around 0 99.7%
*-commutative99.7%
Simplified99.7%
if 1.1000000000000001 < x Initial program 53.9%
+-commutative53.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
unpow1100.0%
sqr-pow100.0%
fabs-sqr100.0%
sqr-pow100.0%
unpow1100.0%
Simplified100.0%
Final simplification82.1%
(FPCore (x)
:precision binary64
(if (<= x -1.05)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.1)
(copysign (* (* x (+ x 2.0)) (+ 0.5 (* x -0.25))) x)
(copysign (log (+ x x)) x))))
double code(double x) {
double tmp;
if (x <= -1.05) {
tmp = copysign(log((-0.5 / x)), x);
} else if (x <= 1.1) {
tmp = copysign(((x * (x + 2.0)) * (0.5 + (x * -0.25))), x);
} else {
tmp = copysign(log((x + x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.05) {
tmp = Math.copySign(Math.log((-0.5 / x)), x);
} else if (x <= 1.1) {
tmp = Math.copySign(((x * (x + 2.0)) * (0.5 + (x * -0.25))), x);
} else {
tmp = Math.copySign(Math.log((x + x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.05: tmp = math.copysign(math.log((-0.5 / x)), x) elif x <= 1.1: tmp = math.copysign(((x * (x + 2.0)) * (0.5 + (x * -0.25))), x) else: tmp = math.copysign(math.log((x + x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.05) tmp = copysign(log(Float64(-0.5 / x)), x); elseif (x <= 1.1) tmp = copysign(Float64(Float64(x * Float64(x + 2.0)) * Float64(0.5 + Float64(x * -0.25))), x); else tmp = copysign(log(Float64(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.05) tmp = sign(x) * abs(log((-0.5 / x))); elseif (x <= 1.1) tmp = sign(x) * abs(((x * (x + 2.0)) * (0.5 + (x * -0.25)))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.05], N[With[{TMP1 = Abs[N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 1.1], N[With[{TMP1 = Abs[N[(N[(x * N[(x + 2.0), $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(x * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x + x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1.1:\\
\;\;\;\;\mathsf{copysign}\left(\left(x \cdot \left(x + 2\right)\right) \cdot \left(0.5 + x \cdot -0.25\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -1.05000000000000004Initial program 54.5%
+-commutative54.5%
hypot-1-def98.5%
Simplified98.5%
Taylor expanded in x around -inf 98.5%
associate--l+98.5%
unpow198.5%
sqr-pow0.0%
fabs-sqr0.0%
sqr-pow4.9%
unpow14.9%
associate-+r-98.9%
mul-1-neg98.9%
sub-neg98.9%
+-inverses98.9%
neg-sub098.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
if -1.05000000000000004 < x < 1.1000000000000001Initial program 6.7%
+-commutative6.7%
hypot-1-def6.7%
Simplified6.7%
expm1-log1p-u6.7%
expm1-udef6.6%
log1p-udef6.6%
add-exp-log6.6%
*-un-lft-identity6.6%
*-un-lft-identity6.6%
add-sqr-sqrt3.9%
fabs-sqr3.9%
add-sqr-sqrt6.7%
Applied egg-rr6.7%
Taylor expanded in x around 0 6.5%
flip--6.5%
div-inv6.5%
metadata-eval6.5%
difference-of-sqr-16.5%
+-commutative6.5%
associate-+l+6.5%
metadata-eval6.5%
add-exp-log6.5%
log1p-udef6.5%
expm1-udef99.6%
expm1-log1p-u99.6%
+-commutative99.6%
associate-+l+99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in x around 0 99.7%
*-commutative99.7%
Simplified99.7%
if 1.1000000000000001 < x Initial program 53.9%
+-commutative53.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
unpow1100.0%
sqr-pow100.0%
fabs-sqr100.0%
sqr-pow100.0%
unpow1100.0%
Simplified100.0%
Final simplification99.5%
(FPCore (x) :precision binary64 (if (<= x -1.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = copysign(log(-x), x);
} else {
tmp = copysign(log1p(x), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = Math.copySign(Math.log(-x), x);
} else {
tmp = Math.copySign(Math.log1p(x), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = math.copysign(math.log(-x), x) else: tmp = math.copysign(math.log1p(x), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = copysign(log(Float64(-x)), x); else tmp = copysign(log1p(x), x); end return tmp end
code[x_] := If[LessEqual[x, -1.0], N[With[{TMP1 = Abs[N[Log[(-x)], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[1 + x], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 54.5%
+-commutative54.5%
hypot-1-def98.5%
Simplified98.5%
Taylor expanded in x around -inf 31.2%
mul-1-neg31.2%
Simplified31.2%
if -1 < x Initial program 22.3%
+-commutative22.3%
hypot-1-def37.6%
Simplified37.6%
Taylor expanded in x around 0 14.6%
log1p-def76.6%
unpow176.6%
sqr-pow45.4%
fabs-sqr45.4%
sqr-pow76.6%
unpow176.6%
Simplified76.6%
Final simplification64.9%
(FPCore (x) :precision binary64 (if (<= x -1e-7) (copysign (/ (* x 2.0) (- 2.0 x)) x) (copysign (log1p x) x)))
double code(double x) {
double tmp;
if (x <= -1e-7) {
tmp = copysign(((x * 2.0) / (2.0 - x)), x);
} else {
tmp = copysign(log1p(x), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1e-7) {
tmp = Math.copySign(((x * 2.0) / (2.0 - x)), x);
} else {
tmp = Math.copySign(Math.log1p(x), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1e-7: tmp = math.copysign(((x * 2.0) / (2.0 - x)), x) else: tmp = math.copysign(math.log1p(x), x) return tmp
function code(x) tmp = 0.0 if (x <= -1e-7) tmp = copysign(Float64(Float64(x * 2.0) / Float64(2.0 - x)), x); else tmp = copysign(log1p(x), x); end return tmp end
code[x_] := If[LessEqual[x, -1e-7], N[With[{TMP1 = Abs[N[(N[(x * 2.0), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[1 + x], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{copysign}\left(\frac{x \cdot 2}{2 - x}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -9.9999999999999995e-8Initial program 54.5%
+-commutative54.5%
hypot-1-def98.5%
Simplified98.5%
expm1-log1p-u96.9%
expm1-udef96.9%
log1p-udef96.9%
add-exp-log98.5%
*-un-lft-identity98.5%
*-un-lft-identity98.5%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt5.2%
Applied egg-rr5.2%
Taylor expanded in x around 0 5.6%
associate--l+5.6%
flip-+5.3%
metadata-eval5.3%
sub-neg5.3%
metadata-eval5.3%
sub-neg5.3%
metadata-eval5.3%
sub-neg5.3%
metadata-eval5.3%
Applied egg-rr5.3%
sub-neg5.3%
+-commutative5.3%
distribute-rgt-in5.3%
neg-mul-15.3%
distribute-neg-in5.3%
remove-double-neg5.3%
associate-+r+5.3%
+-commutative5.3%
associate-+l+5.3%
metadata-eval5.3%
+-rgt-identity5.3%
distribute-rgt-neg-in5.3%
+-commutative5.3%
distribute-neg-in5.3%
metadata-eval5.3%
sub-neg5.3%
+-commutative5.3%
associate--r+5.3%
metadata-eval5.3%
Simplified5.3%
Taylor expanded in x around 0 14.3%
*-commutative14.3%
Simplified14.3%
if -9.9999999999999995e-8 < x Initial program 22.3%
+-commutative22.3%
hypot-1-def37.6%
Simplified37.6%
Taylor expanded in x around 0 14.6%
log1p-def76.6%
unpow176.6%
sqr-pow45.4%
fabs-sqr45.4%
sqr-pow76.6%
unpow176.6%
Simplified76.6%
Final simplification60.5%
(FPCore (x) :precision binary64 (copysign (/ (* x 2.0) (- 2.0 x)) x))
double code(double x) {
return copysign(((x * 2.0) / (2.0 - x)), x);
}
public static double code(double x) {
return Math.copySign(((x * 2.0) / (2.0 - x)), x);
}
def code(x): return math.copysign(((x * 2.0) / (2.0 - x)), x)
function code(x) return copysign(Float64(Float64(x * 2.0) / Float64(2.0 - x)), x) end
function tmp = code(x) tmp = sign(x) * abs(((x * 2.0) / (2.0 - x))); end
code[x_] := N[With[{TMP1 = Abs[N[(N[(x * 2.0), $MachinePrecision] / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(\frac{x \cdot 2}{2 - x}, x\right)
\end{array}
Initial program 30.6%
+-commutative30.6%
hypot-1-def53.3%
Simplified53.3%
expm1-log1p-u52.5%
expm1-udef52.4%
log1p-udef52.5%
add-exp-log53.3%
*-un-lft-identity53.3%
*-un-lft-identity53.3%
add-sqr-sqrt26.5%
fabs-sqr26.5%
add-sqr-sqrt29.2%
Applied egg-rr29.2%
Taylor expanded in x around 0 6.0%
associate--l+6.0%
flip-+5.8%
metadata-eval5.8%
sub-neg5.8%
metadata-eval5.8%
sub-neg5.8%
metadata-eval5.8%
sub-neg5.8%
metadata-eval5.8%
Applied egg-rr5.8%
sub-neg5.8%
+-commutative5.8%
distribute-rgt-in5.8%
neg-mul-15.8%
distribute-neg-in5.8%
remove-double-neg5.8%
associate-+r+12.4%
+-commutative12.4%
associate-+l+52.0%
metadata-eval52.0%
+-rgt-identity52.0%
distribute-rgt-neg-in52.0%
+-commutative52.0%
distribute-neg-in52.0%
metadata-eval52.0%
sub-neg52.0%
+-commutative52.0%
associate--r+52.0%
metadata-eval52.0%
Simplified52.0%
Taylor expanded in x around 0 56.3%
*-commutative56.3%
Simplified56.3%
Final simplification56.3%
(FPCore (x) :precision binary64 (copysign x x))
double code(double x) {
return copysign(x, x);
}
public static double code(double x) {
return Math.copySign(x, x);
}
def code(x): return math.copysign(x, x)
function code(x) return copysign(x, x) end
function tmp = code(x) tmp = sign(x) * abs(x); end
code[x_] := N[With[{TMP1 = Abs[x], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(x, x\right)
\end{array}
Initial program 30.6%
+-commutative30.6%
hypot-1-def53.3%
Simplified53.3%
*-un-lft-identity53.3%
log-prod53.3%
metadata-eval53.3%
*-un-lft-identity53.3%
*-un-lft-identity53.3%
add-sqr-sqrt26.6%
fabs-sqr26.6%
add-sqr-sqrt29.3%
Applied egg-rr29.3%
+-lft-identity29.3%
Simplified29.3%
Taylor expanded in x around 0 52.2%
Final simplification52.2%
(FPCore (x) :precision binary64 (let* ((t_0 (/ 1.0 (fabs x)))) (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 t_0) t_0)))) x)))
double code(double x) {
double t_0 = 1.0 / fabs(x);
return copysign(log1p((fabs(x) + (fabs(x) / (hypot(1.0, t_0) + t_0)))), x);
}
public static double code(double x) {
double t_0 = 1.0 / Math.abs(x);
return Math.copySign(Math.log1p((Math.abs(x) + (Math.abs(x) / (Math.hypot(1.0, t_0) + t_0)))), x);
}
def code(x): t_0 = 1.0 / math.fabs(x) return math.copysign(math.log1p((math.fabs(x) + (math.fabs(x) / (math.hypot(1.0, t_0) + t_0)))), x)
function code(x) t_0 = Float64(1.0 / abs(x)) return copysign(log1p(Float64(abs(x) + Float64(abs(x) / Float64(hypot(1.0, t_0) + t_0)))), x) end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[With[{TMP1 = Abs[N[Log[1 + N[(N[Abs[x], $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] / N[(N[Sqrt[1.0 ^ 2 + t$95$0 ^ 2], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right| + \frac{\left|x\right|}{\mathsf{hypot}\left(1, t_0\right) + t_0}\right), x\right)
\end{array}
\end{array}
herbie shell --seed 2023201
(FPCore (x)
:name "Rust f64::asinh"
:precision binary64
:herbie-target
(copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 (/ 1.0 (fabs x))) (/ 1.0 (fabs x)))))) x)
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))