
(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 8 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 -1.06)
(copysign (- (- (log (* x -2.0))) (/ 0.25 (* x x))) x)
(if (<= x 2.0)
(copysign (log1p (+ x (/ (* x x) (+ 2.0 (* (* x x) 0.5))))) x)
(copysign (log (/ 0.5 x)) x))))
double code(double x) {
double tmp;
if (x <= -1.06) {
tmp = copysign((-log((x * -2.0)) - (0.25 / (x * x))), x);
} else if (x <= 2.0) {
tmp = copysign(log1p((x + ((x * x) / (2.0 + ((x * x) * 0.5))))), x);
} else {
tmp = copysign(log((0.5 / x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.06) {
tmp = Math.copySign((-Math.log((x * -2.0)) - (0.25 / (x * x))), x);
} else if (x <= 2.0) {
tmp = Math.copySign(Math.log1p((x + ((x * x) / (2.0 + ((x * x) * 0.5))))), x);
} else {
tmp = Math.copySign(Math.log((0.5 / x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.06: tmp = math.copysign((-math.log((x * -2.0)) - (0.25 / (x * x))), x) elif x <= 2.0: tmp = math.copysign(math.log1p((x + ((x * x) / (2.0 + ((x * x) * 0.5))))), x) else: tmp = math.copysign(math.log((0.5 / x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.06) tmp = copysign(Float64(Float64(-log(Float64(x * -2.0))) - Float64(0.25 / Float64(x * x))), x); elseif (x <= 2.0) tmp = copysign(log1p(Float64(x + Float64(Float64(x * x) / Float64(2.0 + Float64(Float64(x * x) * 0.5))))), x); else tmp = copysign(log(Float64(0.5 / x)), x); end return tmp end
code[x_] := If[LessEqual[x, -1.06], N[With[{TMP1 = Abs[N[((-N[Log[N[(x * -2.0), $MachinePrecision]], $MachinePrecision]) - N[(0.25 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 2.0], N[With[{TMP1 = Abs[N[Log[1 + N[(x + N[(N[(x * x), $MachinePrecision] / N[(2.0 + N[(N[(x * x), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(0.5 / x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.06:\\
\;\;\;\;\mathsf{copysign}\left(\left(-\log \left(x \cdot -2\right)\right) - \frac{0.25}{x \cdot x}, x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \frac{x \cdot x}{2 + \left(x \cdot x\right) \cdot 0.5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1.0600000000000001Initial program 50.0%
+-commutative50.0%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
*-un-lft-identity100.0%
*-un-lft-identity100.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt5.4%
Applied egg-rr5.4%
+-lft-identity5.4%
Simplified5.4%
Taylor expanded in x around -inf 99.8%
unpow299.8%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
+-commutative99.8%
sum-log100.0%
frac-2neg100.0%
metadata-eval100.0%
div-inv100.0%
metadata-eval100.0%
frac-2neg100.0%
clear-num100.0%
log-div100.0%
metadata-eval100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
neg-sub0100.0%
Simplified100.0%
if -1.0600000000000001 < x < 2Initial program 8.1%
+-commutative8.1%
hypot-1-def8.1%
Simplified8.1%
log1p-expm1-u8.1%
expm1-udef8.1%
add-exp-log8.1%
add-sqr-sqrt3.6%
fabs-sqr3.6%
add-sqr-sqrt8.0%
Applied egg-rr8.0%
associate--l+98.9%
Simplified98.9%
flip--98.9%
div-inv98.9%
metadata-eval98.9%
sub-neg98.9%
hypot-udef98.9%
hypot-udef98.9%
add-sqr-sqrt98.9%
metadata-eval98.9%
metadata-eval98.9%
+-commutative98.9%
Applied egg-rr98.9%
associate-*r/98.9%
*-rgt-identity98.9%
+-commutative98.9%
unpow298.9%
associate-+r+100.0%
metadata-eval100.0%
+-lft-identity100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
unpow2100.0%
Simplified100.0%
if 2 < x Initial program 59.0%
+-commutative59.0%
hypot-1-def100.0%
Simplified100.0%
log1p-expm1-u100.0%
expm1-udef100.0%
add-exp-log100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around -inf 3.1%
+-commutative3.1%
associate--r+3.1%
sub-neg3.1%
sub-neg3.1%
metadata-eval3.1%
+-commutative3.1%
mul-1-neg3.1%
unsub-neg3.1%
associate-*r/3.1%
metadata-eval3.1%
distribute-neg-frac3.1%
metadata-eval3.1%
Simplified3.1%
expm1-log1p-u3.0%
expm1-udef3.0%
+-commutative3.0%
associate-+r-3.0%
Applied egg-rr3.0%
expm1-def3.0%
expm1-log1p3.1%
+-commutative3.1%
associate-+l-3.0%
metadata-eval3.0%
distribute-neg-frac3.0%
metadata-eval3.0%
associate-*r/3.0%
metadata-eval3.0%
distribute-neg-in3.0%
sub-neg3.0%
+-inverses3.0%
metadata-eval3.0%
+-rgt-identity3.0%
+-commutative3.0%
distribute-neg-in3.0%
metadata-eval3.0%
associate-*r/3.0%
metadata-eval3.0%
distribute-neg-frac3.0%
metadata-eval3.0%
Simplified3.0%
expm1-log1p-u0.0%
expm1-udef0.0%
log1p-udef0.0%
associate-+r+0.0%
metadata-eval0.0%
add-sqr-sqrt0.0%
sqrt-unprod0.0%
frac-times0.0%
metadata-eval0.0%
sqrt-div0.0%
metadata-eval0.0%
sqrt-prod0.0%
add-sqr-sqrt0.0%
Applied egg-rr0.0%
expm1-def0.0%
expm1-log1p100.0%
+-lft-identity100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (if (<= (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x) -0.0005) (copysign (log (+ (fabs x) (hypot 1.0 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) <= -0.0005) {
tmp = copysign(log((fabs(x) + hypot(1.0, 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) <= -0.0005) {
tmp = Math.copySign(Math.log((Math.abs(x) + Math.hypot(1.0, 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) <= -0.0005: tmp = math.copysign(math.log((math.fabs(x) + math.hypot(1.0, 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) <= -0.0005) tmp = copysign(log(Float64(abs(x) + hypot(1.0, 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], -0.0005], N[With[{TMP1 = Abs[N[Log[N[(N[Abs[x], $MachinePrecision] + N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $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 -0.0005:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\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) 1)))) x) < -5.0000000000000001e-4Initial program 50.7%
+-commutative50.7%
hypot-1-def99.9%
Simplified99.9%
if -5.0000000000000001e-4 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) Initial program 28.0%
+-commutative28.0%
hypot-1-def44.4%
Simplified44.4%
log1p-expm1-u44.4%
expm1-udef44.4%
add-exp-log44.4%
add-sqr-sqrt42.2%
fabs-sqr42.2%
add-sqr-sqrt44.4%
Applied egg-rr44.4%
associate--l+99.4%
Simplified99.4%
Final simplification99.5%
(FPCore (x) :precision binary64 (if (<= x -310.0) (copysign (- (- (log (* x -2.0))) (/ 0.25 (* x x))) x) (copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
double code(double x) {
double tmp;
if (x <= -310.0) {
tmp = copysign((-log((x * -2.0)) - (0.25 / (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 (x <= -310.0) {
tmp = Math.copySign((-Math.log((x * -2.0)) - (0.25 / (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 x <= -310.0: tmp = math.copysign((-math.log((x * -2.0)) - (0.25 / (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 (x <= -310.0) tmp = copysign(Float64(Float64(-log(Float64(x * -2.0))) - Float64(0.25 / Float64(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[x, -310.0], N[With[{TMP1 = Abs[N[((-N[Log[N[(x * -2.0), $MachinePrecision]], $MachinePrecision]) - N[(0.25 / N[(x * x), $MachinePrecision]), $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}\;x \leq -310:\\
\;\;\;\;\mathsf{copysign}\left(\left(-\log \left(x \cdot -2\right)\right) - \frac{0.25}{x \cdot x}, 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 x < -310Initial program 50.0%
+-commutative50.0%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
*-un-lft-identity100.0%
*-un-lft-identity100.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt5.4%
Applied egg-rr5.4%
+-lft-identity5.4%
Simplified5.4%
Taylor expanded in x around -inf 99.8%
unpow299.8%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
+-commutative99.8%
sum-log100.0%
frac-2neg100.0%
metadata-eval100.0%
div-inv100.0%
metadata-eval100.0%
frac-2neg100.0%
clear-num100.0%
log-div100.0%
metadata-eval100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
neg-sub0100.0%
Simplified100.0%
if -310 < x Initial program 28.3%
+-commutative28.3%
hypot-1-def44.6%
Simplified44.6%
log1p-expm1-u44.6%
expm1-udef44.6%
add-exp-log44.6%
add-sqr-sqrt41.9%
fabs-sqr41.9%
add-sqr-sqrt44.6%
Applied egg-rr44.6%
associate--l+99.3%
Simplified99.3%
Final simplification99.5%
(FPCore (x)
:precision binary64
(if (<= x -1.05)
(copysign (- (- (log (* x -2.0))) (/ 0.25 (* x x))) x)
(if (<= x 1.3)
(copysign (+ x (* -0.16666666666666666 (* x (* x x)))) x)
(copysign (log (/ 0.5 x)) x))))
double code(double x) {
double tmp;
if (x <= -1.05) {
tmp = copysign((-log((x * -2.0)) - (0.25 / (x * x))), x);
} else if (x <= 1.3) {
tmp = copysign((x + (-0.16666666666666666 * (x * (x * x)))), x);
} else {
tmp = copysign(log((0.5 / x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.05) {
tmp = Math.copySign((-Math.log((x * -2.0)) - (0.25 / (x * x))), x);
} else if (x <= 1.3) {
tmp = Math.copySign((x + (-0.16666666666666666 * (x * (x * x)))), x);
} else {
tmp = Math.copySign(Math.log((0.5 / x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.05: tmp = math.copysign((-math.log((x * -2.0)) - (0.25 / (x * x))), x) elif x <= 1.3: tmp = math.copysign((x + (-0.16666666666666666 * (x * (x * x)))), x) else: tmp = math.copysign(math.log((0.5 / x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.05) tmp = copysign(Float64(Float64(-log(Float64(x * -2.0))) - Float64(0.25 / Float64(x * x))), x); elseif (x <= 1.3) tmp = copysign(Float64(x + Float64(-0.16666666666666666 * Float64(x * Float64(x * x)))), x); else tmp = copysign(log(Float64(0.5 / x)), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.05) tmp = sign(x) * abs((-log((x * -2.0)) - (0.25 / (x * x)))); elseif (x <= 1.3) tmp = sign(x) * abs((x + (-0.16666666666666666 * (x * (x * x))))); else tmp = sign(x) * abs(log((0.5 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.05], N[With[{TMP1 = Abs[N[((-N[Log[N[(x * -2.0), $MachinePrecision]], $MachinePrecision]) - N[(0.25 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 1.3], N[With[{TMP1 = Abs[N[(x + N[(-0.16666666666666666 * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(0.5 / 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(\left(-\log \left(x \cdot -2\right)\right) - \frac{0.25}{x \cdot x}, x\right)\\
\mathbf{elif}\;x \leq 1.3:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1.05000000000000004Initial program 50.0%
+-commutative50.0%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
*-un-lft-identity100.0%
*-un-lft-identity100.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt5.4%
Applied egg-rr5.4%
+-lft-identity5.4%
Simplified5.4%
Taylor expanded in x around -inf 99.8%
unpow299.8%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
+-commutative99.8%
sum-log100.0%
frac-2neg100.0%
metadata-eval100.0%
div-inv100.0%
metadata-eval100.0%
frac-2neg100.0%
clear-num100.0%
log-div100.0%
metadata-eval100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
neg-sub0100.0%
Simplified100.0%
if -1.05000000000000004 < x < 1.30000000000000004Initial program 8.1%
+-commutative8.1%
hypot-1-def8.1%
Simplified8.1%
*-un-lft-identity8.1%
log-prod8.1%
metadata-eval8.1%
*-un-lft-identity8.1%
*-un-lft-identity8.1%
add-sqr-sqrt3.6%
fabs-sqr3.6%
add-sqr-sqrt8.0%
Applied egg-rr8.0%
+-lft-identity8.0%
Simplified8.0%
Taylor expanded in x around 0 99.9%
unpow399.9%
Applied egg-rr99.9%
if 1.30000000000000004 < x Initial program 59.0%
+-commutative59.0%
hypot-1-def100.0%
Simplified100.0%
log1p-expm1-u100.0%
expm1-udef100.0%
add-exp-log100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around -inf 3.1%
+-commutative3.1%
associate--r+3.1%
sub-neg3.1%
sub-neg3.1%
metadata-eval3.1%
+-commutative3.1%
mul-1-neg3.1%
unsub-neg3.1%
associate-*r/3.1%
metadata-eval3.1%
distribute-neg-frac3.1%
metadata-eval3.1%
Simplified3.1%
expm1-log1p-u3.0%
expm1-udef3.0%
+-commutative3.0%
associate-+r-3.0%
Applied egg-rr3.0%
expm1-def3.0%
expm1-log1p3.1%
+-commutative3.1%
associate-+l-3.0%
metadata-eval3.0%
distribute-neg-frac3.0%
metadata-eval3.0%
associate-*r/3.0%
metadata-eval3.0%
distribute-neg-in3.0%
sub-neg3.0%
+-inverses3.0%
metadata-eval3.0%
+-rgt-identity3.0%
+-commutative3.0%
distribute-neg-in3.0%
metadata-eval3.0%
associate-*r/3.0%
metadata-eval3.0%
distribute-neg-frac3.0%
metadata-eval3.0%
Simplified3.0%
expm1-log1p-u0.0%
expm1-udef0.0%
log1p-udef0.0%
associate-+r+0.0%
metadata-eval0.0%
add-sqr-sqrt0.0%
sqrt-unprod0.0%
frac-times0.0%
metadata-eval0.0%
sqrt-div0.0%
metadata-eval0.0%
sqrt-prod0.0%
add-sqr-sqrt0.0%
Applied egg-rr0.0%
expm1-def0.0%
expm1-log1p100.0%
+-lft-identity100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x)
:precision binary64
(if (<= x -2.0)
(copysign (- (log (/ -1.0 x))) x)
(if (<= x 1.3)
(copysign (+ x (* -0.16666666666666666 (* x (* x x)))) x)
(copysign (log (/ 0.5 x)) x))))
double code(double x) {
double tmp;
if (x <= -2.0) {
tmp = copysign(-log((-1.0 / x)), x);
} else if (x <= 1.3) {
tmp = copysign((x + (-0.16666666666666666 * (x * (x * x)))), x);
} else {
tmp = copysign(log((0.5 / x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -2.0) {
tmp = Math.copySign(-Math.log((-1.0 / x)), x);
} else if (x <= 1.3) {
tmp = Math.copySign((x + (-0.16666666666666666 * (x * (x * x)))), x);
} else {
tmp = Math.copySign(Math.log((0.5 / x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -2.0: tmp = math.copysign(-math.log((-1.0 / x)), x) elif x <= 1.3: tmp = math.copysign((x + (-0.16666666666666666 * (x * (x * x)))), x) else: tmp = math.copysign(math.log((0.5 / x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -2.0) tmp = copysign(Float64(-log(Float64(-1.0 / x))), x); elseif (x <= 1.3) tmp = copysign(Float64(x + Float64(-0.16666666666666666 * Float64(x * Float64(x * x)))), x); else tmp = copysign(log(Float64(0.5 / x)), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2.0) tmp = sign(x) * abs(-log((-1.0 / x))); elseif (x <= 1.3) tmp = sign(x) * abs((x + (-0.16666666666666666 * (x * (x * x))))); else tmp = sign(x) * abs(log((0.5 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -2.0], N[With[{TMP1 = Abs[(-N[Log[N[(-1.0 / x), $MachinePrecision]], $MachinePrecision])], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 1.3], N[With[{TMP1 = Abs[N[(x + N[(-0.16666666666666666 * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(0.5 / x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1.3:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 50.0%
+-commutative50.0%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 31.5%
mul-1-neg31.5%
Simplified31.5%
if -2 < x < 1.30000000000000004Initial program 8.1%
+-commutative8.1%
hypot-1-def8.1%
Simplified8.1%
*-un-lft-identity8.1%
log-prod8.1%
metadata-eval8.1%
*-un-lft-identity8.1%
*-un-lft-identity8.1%
add-sqr-sqrt3.6%
fabs-sqr3.6%
add-sqr-sqrt8.0%
Applied egg-rr8.0%
+-lft-identity8.0%
Simplified8.0%
Taylor expanded in x around 0 99.9%
unpow399.9%
Applied egg-rr99.9%
if 1.30000000000000004 < x Initial program 59.0%
+-commutative59.0%
hypot-1-def100.0%
Simplified100.0%
log1p-expm1-u100.0%
expm1-udef100.0%
add-exp-log100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around -inf 3.1%
+-commutative3.1%
associate--r+3.1%
sub-neg3.1%
sub-neg3.1%
metadata-eval3.1%
+-commutative3.1%
mul-1-neg3.1%
unsub-neg3.1%
associate-*r/3.1%
metadata-eval3.1%
distribute-neg-frac3.1%
metadata-eval3.1%
Simplified3.1%
expm1-log1p-u3.0%
expm1-udef3.0%
+-commutative3.0%
associate-+r-3.0%
Applied egg-rr3.0%
expm1-def3.0%
expm1-log1p3.1%
+-commutative3.1%
associate-+l-3.0%
metadata-eval3.0%
distribute-neg-frac3.0%
metadata-eval3.0%
associate-*r/3.0%
metadata-eval3.0%
distribute-neg-in3.0%
sub-neg3.0%
+-inverses3.0%
metadata-eval3.0%
+-rgt-identity3.0%
+-commutative3.0%
distribute-neg-in3.0%
metadata-eval3.0%
associate-*r/3.0%
metadata-eval3.0%
distribute-neg-frac3.0%
metadata-eval3.0%
Simplified3.0%
expm1-log1p-u0.0%
expm1-udef0.0%
log1p-udef0.0%
associate-+r+0.0%
metadata-eval0.0%
add-sqr-sqrt0.0%
sqrt-unprod0.0%
frac-times0.0%
metadata-eval0.0%
sqrt-div0.0%
metadata-eval0.0%
sqrt-prod0.0%
add-sqr-sqrt0.0%
Applied egg-rr0.0%
expm1-def0.0%
expm1-log1p100.0%
+-lft-identity100.0%
Simplified100.0%
Final simplification83.9%
(FPCore (x) :precision binary64 (if (<= x 1.3) (copysign x x) (copysign (log (/ 0.5 x)) x)))
double code(double x) {
double tmp;
if (x <= 1.3) {
tmp = copysign(x, x);
} else {
tmp = copysign(log((0.5 / x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.3) {
tmp = Math.copySign(x, x);
} else {
tmp = Math.copySign(Math.log((0.5 / x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.3: tmp = math.copysign(x, x) else: tmp = math.copysign(math.log((0.5 / x)), x) return tmp
function code(x) tmp = 0.0 if (x <= 1.3) tmp = copysign(x, x); else tmp = copysign(log(Float64(0.5 / x)), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.3) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((0.5 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.3], N[With[{TMP1 = Abs[x], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(0.5 / x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.3:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < 1.30000000000000004Initial program 22.2%
+-commutative22.2%
hypot-1-def39.1%
Simplified39.1%
Taylor expanded in x around 0 15.6%
expm1-log1p-u15.6%
expm1-udef15.6%
log1p-udef15.6%
add-exp-log15.6%
log1p-def15.6%
add-sqr-sqrt2.4%
fabs-sqr2.4%
add-sqr-sqrt5.0%
Applied egg-rr5.0%
associate--l+5.0%
+-commutative5.0%
sub-neg5.0%
metadata-eval5.0%
Applied egg-rr5.0%
Taylor expanded in x around 0 67.8%
if 1.30000000000000004 < x Initial program 59.0%
+-commutative59.0%
hypot-1-def100.0%
Simplified100.0%
log1p-expm1-u100.0%
expm1-udef100.0%
add-exp-log100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around -inf 3.1%
+-commutative3.1%
associate--r+3.1%
sub-neg3.1%
sub-neg3.1%
metadata-eval3.1%
+-commutative3.1%
mul-1-neg3.1%
unsub-neg3.1%
associate-*r/3.1%
metadata-eval3.1%
distribute-neg-frac3.1%
metadata-eval3.1%
Simplified3.1%
expm1-log1p-u3.0%
expm1-udef3.0%
+-commutative3.0%
associate-+r-3.0%
Applied egg-rr3.0%
expm1-def3.0%
expm1-log1p3.1%
+-commutative3.1%
associate-+l-3.0%
metadata-eval3.0%
distribute-neg-frac3.0%
metadata-eval3.0%
associate-*r/3.0%
metadata-eval3.0%
distribute-neg-in3.0%
sub-neg3.0%
+-inverses3.0%
metadata-eval3.0%
+-rgt-identity3.0%
+-commutative3.0%
distribute-neg-in3.0%
metadata-eval3.0%
associate-*r/3.0%
metadata-eval3.0%
distribute-neg-frac3.0%
metadata-eval3.0%
Simplified3.0%
expm1-log1p-u0.0%
expm1-udef0.0%
log1p-udef0.0%
associate-+r+0.0%
metadata-eval0.0%
add-sqr-sqrt0.0%
sqrt-unprod0.0%
frac-times0.0%
metadata-eval0.0%
sqrt-div0.0%
metadata-eval0.0%
sqrt-prod0.0%
add-sqr-sqrt0.0%
Applied egg-rr0.0%
expm1-def0.0%
expm1-log1p100.0%
+-lft-identity100.0%
Simplified100.0%
Final simplification77.6%
(FPCore (x) :precision binary64 (if (<= x 1.6) (copysign x x) (copysign (log1p x) x)))
double code(double x) {
double tmp;
if (x <= 1.6) {
tmp = copysign(x, x);
} else {
tmp = copysign(log1p(x), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.6) {
tmp = Math.copySign(x, x);
} else {
tmp = Math.copySign(Math.log1p(x), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.6: tmp = math.copysign(x, x) else: tmp = math.copysign(math.log1p(x), x) return tmp
function code(x) tmp = 0.0 if (x <= 1.6) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
code[x_] := If[LessEqual[x, 1.6], N[With[{TMP1 = Abs[x], 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.6:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 1.6000000000000001Initial program 22.2%
+-commutative22.2%
hypot-1-def39.1%
Simplified39.1%
Taylor expanded in x around 0 15.6%
expm1-log1p-u15.6%
expm1-udef15.6%
log1p-udef15.6%
add-exp-log15.6%
log1p-def15.6%
add-sqr-sqrt2.4%
fabs-sqr2.4%
add-sqr-sqrt5.0%
Applied egg-rr5.0%
associate--l+5.0%
+-commutative5.0%
sub-neg5.0%
metadata-eval5.0%
Applied egg-rr5.0%
Taylor expanded in x around 0 67.8%
if 1.6000000000000001 < x Initial program 59.0%
+-commutative59.0%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 31.6%
log1p-def31.6%
unpow131.6%
sqr-pow31.6%
fabs-sqr31.6%
sqr-pow31.6%
unpow131.6%
Simplified31.6%
Final simplification56.8%
(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 33.4%
+-commutative33.4%
hypot-1-def57.6%
Simplified57.6%
Taylor expanded in x around 0 20.4%
expm1-log1p-u20.4%
expm1-udef20.4%
log1p-udef20.4%
add-exp-log20.4%
log1p-def20.4%
add-sqr-sqrt11.3%
fabs-sqr11.3%
add-sqr-sqrt13.1%
Applied egg-rr13.1%
associate--l+13.1%
+-commutative13.1%
sub-neg13.1%
metadata-eval13.1%
Applied egg-rr13.1%
Taylor expanded in x around 0 48.8%
Final simplification48.8%
(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 2023199
(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))