
(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 9 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
(if (<= x -0.0011)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= x 0.00084)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
double code(double x) {
double tmp;
if (x <= -0.0011) {
tmp = copysign(log((hypot(1.0, x) - x)), x);
} else if (x <= 0.00084) {
tmp = copysign((x + (-0.16666666666666666 * pow(x, 3.0))), x);
} else {
tmp = copysign(log((x + hypot(1.0, x))), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.0011) {
tmp = Math.copySign(Math.log((Math.hypot(1.0, x) - x)), x);
} else if (x <= 0.00084) {
tmp = Math.copySign((x + (-0.16666666666666666 * Math.pow(x, 3.0))), x);
} else {
tmp = Math.copySign(Math.log((x + Math.hypot(1.0, x))), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.0011: tmp = math.copysign(math.log((math.hypot(1.0, x) - x)), x) elif x <= 0.00084: tmp = math.copysign((x + (-0.16666666666666666 * math.pow(x, 3.0))), x) else: tmp = math.copysign(math.log((x + math.hypot(1.0, x))), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.0011) tmp = copysign(log(Float64(hypot(1.0, x) - x)), x); elseif (x <= 0.00084) tmp = copysign(Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))), x); else tmp = copysign(log(Float64(x + hypot(1.0, x))), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -0.0011) tmp = sign(x) * abs(log((hypot(1.0, x) - x))); elseif (x <= 0.00084) tmp = sign(x) * abs((x + (-0.16666666666666666 * (x ^ 3.0)))); else tmp = sign(x) * abs(log((x + hypot(1.0, x)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -0.0011], N[With[{TMP1 = Abs[N[Log[N[(N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 0.00084], 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 + N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0011:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.00084:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.00110000000000000007Initial program 46.3%
+-commutative46.3%
hypot-1-def99.9%
Simplified99.9%
flip-+2.3%
frac-2neg2.3%
log-div2.3%
Applied egg-rr3.9%
neg-sub03.9%
associate--r-3.9%
neg-sub03.9%
+-commutative3.9%
fma-undefine3.9%
unpow23.9%
+-commutative3.9%
associate-+l+44.5%
sub-neg44.5%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
sub-neg99.9%
distribute-neg-in99.9%
neg-mul-199.9%
remove-double-neg99.9%
+-commutative99.9%
neg-mul-199.9%
sub-neg99.9%
Simplified99.9%
*-un-lft-identity99.9%
add-sqr-sqrt0.0%
sqrt-unprod99.9%
sqr-neg99.9%
sqrt-unprod99.1%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
Simplified99.9%
if -0.00110000000000000007 < x < 8.4000000000000003e-4Initial program 6.7%
+-commutative6.7%
hypot-1-def6.7%
Simplified6.7%
Taylor expanded in x around 0 7.7%
+-commutative7.7%
fma-define7.7%
+-commutative7.7%
rem-square-sqrt4.6%
fabs-sqr4.6%
rem-square-sqrt7.7%
log1p-define100.0%
rem-square-sqrt54.5%
fabs-sqr54.5%
rem-square-sqrt100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
+-commutative100.0%
distribute-rgt-in100.0%
*-un-lft-identity100.0%
*-commutative100.0%
associate-*l*100.0%
unpow2100.0%
pow3100.0%
Applied egg-rr100.0%
if 8.4000000000000003e-4 < x Initial program 49.4%
+-commutative49.4%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around 0 49.4%
rem-square-sqrt49.4%
fabs-sqr49.4%
rem-square-sqrt49.4%
metadata-eval49.4%
unpow249.4%
hypot-undefine99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (x) :precision binary64 (if (<= (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x) -5.0) (copysign (log (- (hypot 1.0 x) x)) x) (copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
double code(double x) {
double tmp;
if (copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x) <= -5.0) {
tmp = copysign(log((hypot(1.0, x) - x)), x);
} else {
tmp = copysign(log1p((x + (hypot(1.0, x) + -1.0))), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x) <= -5.0) {
tmp = Math.copySign(Math.log((Math.hypot(1.0, x) - x)), x);
} else {
tmp = Math.copySign(Math.log1p((x + (Math.hypot(1.0, x) + -1.0))), x);
}
return tmp;
}
def code(x): tmp = 0 if math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x) <= -5.0: tmp = math.copysign(math.log((math.hypot(1.0, x) - x)), x) else: tmp = math.copysign(math.log1p((x + (math.hypot(1.0, x) + -1.0))), x) return tmp
function code(x) tmp = 0.0 if (copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x) <= -5.0) tmp = copysign(log(Float64(hypot(1.0, x) - x)), x); else tmp = copysign(log1p(Float64(x + Float64(hypot(1.0, x) + -1.0))), x); end return tmp end
code[x_] := If[LessEqual[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], -5.0], N[With[{TMP1 = Abs[N[Log[N[(N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[1 + N[(x + N[(N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right), x\right)\\
\end{array}
\end{array}
if (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) #s(literal 1 binary64))))) x) < -5Initial program 45.6%
+-commutative45.6%
hypot-1-def100.0%
Simplified100.0%
flip-+1.1%
frac-2neg1.1%
log-div1.1%
Applied egg-rr2.7%
neg-sub02.7%
associate--r-2.7%
neg-sub02.7%
+-commutative2.7%
fma-undefine2.7%
unpow22.7%
+-commutative2.7%
associate-+l+43.8%
sub-neg43.8%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
sub-neg100.0%
distribute-neg-in100.0%
neg-mul-1100.0%
remove-double-neg100.0%
+-commutative100.0%
neg-mul-1100.0%
sub-neg100.0%
Simplified100.0%
*-un-lft-identity100.0%
add-sqr-sqrt0.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod99.2%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
if -5 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) #s(literal 1 binary64))))) x) Initial program 23.3%
+-commutative23.3%
hypot-1-def42.3%
Simplified42.3%
Taylor expanded in x around 0 23.3%
rem-square-sqrt21.1%
fabs-sqr21.1%
rem-square-sqrt23.3%
metadata-eval23.3%
unpow223.3%
hypot-undefine42.3%
Simplified42.3%
log1p-expm1-u42.3%
expm1-undefine42.3%
add-exp-log42.3%
Applied egg-rr42.3%
associate--l+99.6%
Simplified99.6%
Final simplification99.7%
(FPCore (x) :precision binary64 (if (<= x 9.8e-9) (copysign (log1p (- x)) x) (copysign (log (+ x (hypot 1.0 x))) x)))
double code(double x) {
double tmp;
if (x <= 9.8e-9) {
tmp = copysign(log1p(-x), x);
} else {
tmp = copysign(log((x + hypot(1.0, x))), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 9.8e-9) {
tmp = Math.copySign(Math.log1p(-x), x);
} else {
tmp = Math.copySign(Math.log((x + Math.hypot(1.0, x))), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 9.8e-9: tmp = math.copysign(math.log1p(-x), x) else: tmp = math.copysign(math.log((x + math.hypot(1.0, x))), x) return tmp
function code(x) tmp = 0.0 if (x <= 9.8e-9) tmp = copysign(log1p(Float64(-x)), x); else tmp = copysign(log(Float64(x + hypot(1.0, x))), x); end return tmp end
code[x_] := If[LessEqual[x, 9.8e-9], N[With[{TMP1 = Abs[N[Log[1 + (-x)], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x + N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.8 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < 9.80000000000000007e-9Initial program 22.2%
+-commutative22.2%
hypot-1-def43.5%
Simplified43.5%
flip-+4.7%
frac-2neg4.7%
log-div4.7%
Applied egg-rr5.3%
neg-sub05.3%
associate--r-5.3%
neg-sub05.3%
+-commutative5.3%
fma-undefine5.3%
unpow25.3%
+-commutative5.3%
associate-+l+21.5%
sub-neg21.5%
+-inverses43.5%
metadata-eval43.5%
metadata-eval43.5%
neg-sub043.5%
sub-neg43.5%
distribute-neg-in43.5%
neg-mul-143.5%
remove-double-neg43.5%
+-commutative43.5%
neg-mul-143.5%
sub-neg43.5%
Simplified43.5%
Taylor expanded in x around 0 16.3%
neg-mul-116.3%
sub-neg16.3%
Simplified16.3%
*-un-lft-identity16.3%
add-sqr-sqrt3.6%
sqrt-unprod16.3%
sqr-neg16.3%
sqrt-unprod16.0%
add-sqr-sqrt16.3%
sub-neg16.3%
log1p-define72.6%
Applied egg-rr72.6%
*-lft-identity72.6%
Simplified72.6%
if 9.80000000000000007e-9 < x Initial program 49.6%
+-commutative49.6%
hypot-1-def99.4%
Simplified99.4%
Taylor expanded in x around 0 49.6%
rem-square-sqrt49.6%
fabs-sqr49.6%
rem-square-sqrt49.6%
metadata-eval49.6%
unpow249.6%
hypot-undefine99.4%
Simplified99.4%
(FPCore (x) :precision binary64 (if (<= x 0.7) (copysign (log1p (- x)) x) (copysign (log (* x 2.0)) x)))
double code(double x) {
double tmp;
if (x <= 0.7) {
tmp = copysign(log1p(-x), x);
} else {
tmp = copysign(log((x * 2.0)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 0.7) {
tmp = Math.copySign(Math.log1p(-x), x);
} else {
tmp = Math.copySign(Math.log((x * 2.0)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.7: tmp = math.copysign(math.log1p(-x), x) else: tmp = math.copysign(math.log((x * 2.0)), x) return tmp
function code(x) tmp = 0.0 if (x <= 0.7) tmp = copysign(log1p(Float64(-x)), x); else tmp = copysign(log(Float64(x * 2.0)), x); end return tmp end
code[x_] := If[LessEqual[x, 0.7], N[With[{TMP1 = Abs[N[Log[1 + (-x)], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.7:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < 0.69999999999999996Initial program 22.7%
+-commutative22.7%
hypot-1-def43.9%
Simplified43.9%
flip-+5.5%
frac-2neg5.5%
log-div5.5%
Applied egg-rr6.1%
neg-sub06.1%
associate--r-6.1%
neg-sub06.1%
+-commutative6.1%
fma-undefine6.1%
unpow26.1%
+-commutative6.1%
associate-+l+22.1%
sub-neg22.1%
+-inverses43.9%
metadata-eval43.9%
metadata-eval43.9%
neg-sub043.9%
sub-neg43.9%
distribute-neg-in43.9%
neg-mul-143.9%
remove-double-neg43.9%
+-commutative43.9%
neg-mul-143.9%
sub-neg43.9%
Simplified43.9%
Taylor expanded in x around 0 16.6%
neg-mul-116.6%
sub-neg16.6%
Simplified16.6%
*-un-lft-identity16.6%
add-sqr-sqrt4.0%
sqrt-unprod16.6%
sqr-neg16.6%
sqrt-unprod15.9%
add-sqr-sqrt16.6%
sub-neg16.6%
log1p-define72.3%
Applied egg-rr72.3%
*-lft-identity72.3%
Simplified72.3%
if 0.69999999999999996 < x Initial program 48.7%
+-commutative48.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 99.5%
+-commutative99.5%
rem-square-sqrt99.5%
fabs-sqr99.5%
rem-square-sqrt99.5%
*-inverses99.5%
metadata-eval99.5%
Simplified99.5%
(FPCore (x) :precision binary64 (if (<= x -0.02) (copysign (log1p (- x)) x) (copysign (log1p x) x)))
double code(double x) {
double tmp;
if (x <= -0.02) {
tmp = copysign(log1p(-x), x);
} else {
tmp = copysign(log1p(x), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.02) {
tmp = Math.copySign(Math.log1p(-x), x);
} else {
tmp = Math.copySign(Math.log1p(x), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.02: tmp = math.copysign(math.log1p(-x), x) else: tmp = math.copysign(math.log1p(x), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.02) tmp = copysign(log1p(Float64(-x)), x); else tmp = copysign(log1p(x), x); end return tmp end
code[x_] := If[LessEqual[x, -0.02], N[With[{TMP1 = Abs[N[Log[1 + (-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 -0.02:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -0.0200000000000000004Initial program 46.3%
+-commutative46.3%
hypot-1-def99.9%
Simplified99.9%
flip-+2.3%
frac-2neg2.3%
log-div2.3%
Applied egg-rr3.9%
neg-sub03.9%
associate--r-3.9%
neg-sub03.9%
+-commutative3.9%
fma-undefine3.9%
unpow23.9%
+-commutative3.9%
associate-+l+44.5%
sub-neg44.5%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
sub-neg99.9%
distribute-neg-in99.9%
neg-mul-199.9%
remove-double-neg99.9%
+-commutative99.9%
neg-mul-199.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 31.5%
neg-mul-131.5%
sub-neg31.5%
Simplified31.5%
*-un-lft-identity31.5%
add-sqr-sqrt0.0%
sqrt-unprod31.5%
sqr-neg31.5%
sqrt-unprod31.5%
add-sqr-sqrt31.5%
sub-neg31.5%
log1p-define31.5%
Applied egg-rr31.5%
*-lft-identity31.5%
Simplified31.5%
if -0.0200000000000000004 < x Initial program 22.9%
+-commutative22.9%
hypot-1-def42.1%
Simplified42.1%
flip-+5.3%
frac-2neg5.3%
log-div5.3%
Applied egg-rr5.2%
neg-sub05.2%
associate--r-5.2%
neg-sub05.2%
+-commutative5.2%
fma-undefine5.2%
unpow25.2%
+-commutative5.2%
associate-+l+5.8%
sub-neg5.8%
+-inverses6.4%
metadata-eval6.4%
metadata-eval6.4%
neg-sub06.4%
sub-neg6.4%
distribute-neg-in6.4%
neg-mul-16.4%
remove-double-neg6.4%
+-commutative6.4%
neg-mul-16.4%
sub-neg6.4%
Simplified6.4%
Taylor expanded in x around 0 4.3%
neg-mul-14.3%
sub-neg4.3%
Simplified4.3%
*-un-lft-identity4.3%
add-sqr-sqrt4.2%
sqrt-unprod4.3%
sqr-neg4.3%
sqrt-unprod3.6%
add-sqr-sqrt4.3%
sub-neg4.3%
log1p-define61.9%
Applied egg-rr61.9%
*-lft-identity61.9%
Simplified61.9%
*-un-lft-identity61.9%
neg-mul-161.9%
neg-mul-161.9%
add-sqr-sqrt27.8%
sqrt-unprod34.9%
sqr-neg34.9%
sqrt-unprod45.4%
add-sqr-sqrt73.7%
Applied egg-rr73.7%
*-lft-identity73.7%
Simplified73.7%
(FPCore (x) :precision binary64 (copysign (log1p x) x))
double code(double x) {
return copysign(log1p(x), x);
}
public static double code(double x) {
return Math.copySign(Math.log1p(x), x);
}
def code(x): return math.copysign(math.log1p(x), x)
function code(x) return copysign(log1p(x), x) end
code[x_] := N[With[{TMP1 = Abs[N[Log[1 + x], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)
\end{array}
Initial program 29.6%
+-commutative29.6%
hypot-1-def58.8%
Simplified58.8%
flip-+4.4%
frac-2neg4.4%
log-div4.4%
Applied egg-rr4.9%
neg-sub04.9%
associate--r-4.9%
neg-sub04.9%
+-commutative4.9%
fma-undefine4.9%
unpow24.9%
+-commutative4.9%
associate-+l+17.0%
sub-neg17.0%
+-inverses33.4%
metadata-eval33.4%
metadata-eval33.4%
neg-sub033.4%
sub-neg33.4%
distribute-neg-in33.4%
neg-mul-133.4%
remove-double-neg33.4%
+-commutative33.4%
neg-mul-133.4%
sub-neg33.4%
Simplified33.4%
Taylor expanded in x around 0 12.2%
neg-mul-112.2%
sub-neg12.2%
Simplified12.2%
*-un-lft-identity12.2%
add-sqr-sqrt3.0%
sqrt-unprod12.2%
sqr-neg12.2%
sqrt-unprod11.7%
add-sqr-sqrt12.2%
sub-neg12.2%
log1p-define53.1%
Applied egg-rr53.1%
*-lft-identity53.1%
Simplified53.1%
*-un-lft-identity53.1%
neg-mul-153.1%
neg-mul-153.1%
add-sqr-sqrt28.9%
sqrt-unprod29.1%
sqr-neg29.1%
sqrt-unprod32.3%
add-sqr-sqrt52.5%
Applied egg-rr52.5%
*-lft-identity52.5%
Simplified52.5%
(FPCore (x) :precision binary64 (copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x))
double code(double x) {
return copysign((x * (1.0 + ((x * x) * -0.16666666666666666))), x);
}
public static double code(double x) {
return Math.copySign((x * (1.0 + ((x * x) * -0.16666666666666666))), x);
}
def code(x): return math.copysign((x * (1.0 + ((x * x) * -0.16666666666666666))), x)
function code(x) return copysign(Float64(x * Float64(1.0 + Float64(Float64(x * x) * -0.16666666666666666))), x) end
function tmp = code(x) tmp = sign(x) * abs((x * (1.0 + ((x * x) * -0.16666666666666666)))); end
code[x_] := N[With[{TMP1 = Abs[N[(x * N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)
\end{array}
Initial program 29.6%
+-commutative29.6%
hypot-1-def58.8%
Simplified58.8%
Taylor expanded in x around 0 6.3%
+-commutative6.3%
fma-define6.3%
+-commutative6.3%
rem-square-sqrt3.4%
fabs-sqr3.4%
rem-square-sqrt6.3%
log1p-define47.0%
rem-square-sqrt25.5%
fabs-sqr25.5%
rem-square-sqrt45.7%
Simplified45.7%
Taylor expanded in x around 0 46.6%
*-commutative46.6%
Simplified46.6%
unpow246.6%
Applied egg-rr46.6%
(FPCore (x) :precision binary64 (copysign (* x (- 1.0 (* x 0.5))) x))
double code(double x) {
return copysign((x * (1.0 - (x * 0.5))), x);
}
public static double code(double x) {
return Math.copySign((x * (1.0 - (x * 0.5))), x);
}
def code(x): return math.copysign((x * (1.0 - (x * 0.5))), x)
function code(x) return copysign(Float64(x * Float64(1.0 - Float64(x * 0.5))), x) end
function tmp = code(x) tmp = sign(x) * abs((x * (1.0 - (x * 0.5)))); end
code[x_] := N[With[{TMP1 = Abs[N[(x * N[(1.0 - N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(x \cdot \left(1 - x \cdot 0.5\right), x\right)
\end{array}
Initial program 29.6%
+-commutative29.6%
hypot-1-def58.8%
Simplified58.8%
flip-+4.4%
frac-2neg4.4%
log-div4.4%
Applied egg-rr4.9%
neg-sub04.9%
associate--r-4.9%
neg-sub04.9%
+-commutative4.9%
fma-undefine4.9%
unpow24.9%
+-commutative4.9%
associate-+l+17.0%
sub-neg17.0%
+-inverses33.4%
metadata-eval33.4%
metadata-eval33.4%
neg-sub033.4%
sub-neg33.4%
distribute-neg-in33.4%
neg-mul-133.4%
remove-double-neg33.4%
+-commutative33.4%
neg-mul-133.4%
sub-neg33.4%
Simplified33.4%
Taylor expanded in x around 0 12.2%
neg-mul-112.2%
sub-neg12.2%
Simplified12.2%
Taylor expanded in x around 0 46.3%
*-commutative46.3%
Simplified46.3%
add-sqr-sqrt25.1%
sqrt-unprod46.3%
sqr-neg46.3%
sqrt-unprod21.2%
add-sqr-sqrt46.3%
cancel-sign-sub-inv46.3%
Applied egg-rr46.3%
(FPCore (x) :precision binary64 (copysign (* x (+ 1.0 (* x 0.5))) x))
double code(double x) {
return copysign((x * (1.0 + (x * 0.5))), x);
}
public static double code(double x) {
return Math.copySign((x * (1.0 + (x * 0.5))), x);
}
def code(x): return math.copysign((x * (1.0 + (x * 0.5))), x)
function code(x) return copysign(Float64(x * Float64(1.0 + Float64(x * 0.5))), x) end
function tmp = code(x) tmp = sign(x) * abs((x * (1.0 + (x * 0.5)))); end
code[x_] := N[With[{TMP1 = Abs[N[(x * N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(x \cdot \left(1 + x \cdot 0.5\right), x\right)
\end{array}
Initial program 29.6%
+-commutative29.6%
hypot-1-def58.8%
Simplified58.8%
flip-+4.4%
frac-2neg4.4%
log-div4.4%
Applied egg-rr4.9%
neg-sub04.9%
associate--r-4.9%
neg-sub04.9%
+-commutative4.9%
fma-undefine4.9%
unpow24.9%
+-commutative4.9%
associate-+l+17.0%
sub-neg17.0%
+-inverses33.4%
metadata-eval33.4%
metadata-eval33.4%
neg-sub033.4%
sub-neg33.4%
distribute-neg-in33.4%
neg-mul-133.4%
remove-double-neg33.4%
+-commutative33.4%
neg-mul-133.4%
sub-neg33.4%
Simplified33.4%
Taylor expanded in x around 0 12.2%
neg-mul-112.2%
sub-neg12.2%
Simplified12.2%
Taylor expanded in x around 0 46.3%
*-commutative46.3%
Simplified46.3%
(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 2024179
(FPCore (x)
:name "Rust f64::asinh"
:precision binary64
:alt
(! :herbie-platform default (let* ((ax (fabs x)) (ix (/ 1 ax))) (copysign (log1p (+ ax (/ ax (+ (hypot 1 ix) ix)))) x)))
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))