
(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 12 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.25)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.001)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = copysign(log((-0.5 / x)), x);
} else if (x <= 0.001) {
tmp = copysign((x + (pow(x, 3.0) * -0.16666666666666666)), x);
} else {
tmp = copysign(log((x + hypot(1.0, x))), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = Math.copySign(Math.log((-0.5 / x)), x);
} else if (x <= 0.001) {
tmp = Math.copySign((x + (Math.pow(x, 3.0) * -0.16666666666666666)), x);
} else {
tmp = Math.copySign(Math.log((x + Math.hypot(1.0, x))), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.25: tmp = math.copysign(math.log((-0.5 / x)), x) elif x <= 0.001: tmp = math.copysign((x + (math.pow(x, 3.0) * -0.16666666666666666)), x) else: tmp = math.copysign(math.log((x + math.hypot(1.0, x))), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.25) tmp = copysign(log(Float64(-0.5 / x)), x); elseif (x <= 0.001) tmp = copysign(Float64(x + Float64((x ^ 3.0) * -0.16666666666666666)), 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 <= -1.25) tmp = sign(x) * abs(log((-0.5 / x))); elseif (x <= 0.001) tmp = sign(x) * abs((x + ((x ^ 3.0) * -0.16666666666666666))); else tmp = sign(x) * abs(log((x + hypot(1.0, x)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.25], 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, 0.001], N[With[{TMP1 = Abs[N[(x + N[(N[Power[x, 3.0], $MachinePrecision] * -0.16666666666666666), $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 -1.25:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.001:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, 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 < -1.25Initial program 58.7%
Taylor expanded in x around -inf 99.4%
sub-neg99.4%
neg-mul-199.4%
unsub-neg99.4%
associate-*r/99.4%
metadata-eval99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 98.4%
if -1.25 < x < 1e-3Initial program 9.2%
log1p-expm1-u9.2%
expm1-undefine9.2%
add-exp-log9.2%
add-sqr-sqrt4.5%
fabs-sqr4.5%
add-sqr-sqrt9.2%
+-commutative9.2%
hypot-1-def9.2%
Applied egg-rr9.2%
associate--l+98.7%
Simplified98.7%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
Simplified99.8%
if 1e-3 < x Initial program 38.9%
*-un-lft-identity38.9%
*-commutative38.9%
log-prod38.9%
add-sqr-sqrt38.9%
fabs-sqr38.9%
add-sqr-sqrt38.9%
+-commutative38.9%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification99.5%
(FPCore (x) :precision binary64 (if (<= (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x) -4e-6) (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) <= -4e-6) {
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) <= -4e-6) {
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) <= -4e-6: 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) <= -4e-6) 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], -4e-6], 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 -4 \cdot 10^{-6}:\\
\;\;\;\;\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) < -3.99999999999999982e-6Initial program 59.5%
add-log-exp7.7%
*-un-lft-identity7.7%
log-prod7.7%
metadata-eval7.7%
add-log-exp59.5%
+-commutative59.5%
hypot-1-def99.2%
Applied egg-rr99.2%
+-lft-identity99.2%
Simplified99.2%
if -3.99999999999999982e-6 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) Initial program 18.5%
log1p-expm1-u18.5%
expm1-undefine18.5%
add-exp-log18.5%
add-sqr-sqrt16.7%
fabs-sqr16.7%
add-sqr-sqrt18.5%
+-commutative18.5%
hypot-1-def40.0%
Applied egg-rr40.0%
associate--l+99.5%
Simplified99.5%
Final simplification99.4%
(FPCore (x) :precision binary64 (if (<= x -300.0) (copysign (log (+ (- (fabs x) x) (/ -0.5 x))) x) (copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
double code(double x) {
double tmp;
if (x <= -300.0) {
tmp = copysign(log(((fabs(x) - x) + (-0.5 / 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 <= -300.0) {
tmp = Math.copySign(Math.log(((Math.abs(x) - x) + (-0.5 / 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 <= -300.0: tmp = math.copysign(math.log(((math.fabs(x) - x) + (-0.5 / 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 <= -300.0) tmp = copysign(log(Float64(Float64(abs(x) - x) + Float64(-0.5 / 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, -300.0], N[With[{TMP1 = Abs[N[Log[N[(N[(N[Abs[x], $MachinePrecision] - x), $MachinePrecision] + N[(-0.5 / 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 -300:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \frac{-0.5}{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 x < -300Initial program 58.1%
Taylor expanded in x around -inf 100.0%
sub-neg100.0%
neg-mul-1100.0%
unsub-neg100.0%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
if -300 < x Initial program 19.9%
log1p-expm1-u19.9%
expm1-undefine19.9%
add-exp-log19.9%
add-sqr-sqrt16.3%
fabs-sqr16.3%
add-sqr-sqrt19.8%
+-commutative19.8%
hypot-1-def40.9%
Applied egg-rr40.9%
associate--l+99.1%
Simplified99.1%
Final simplification99.3%
(FPCore (x) :precision binary64 (if (<= x -9000.0) (copysign (log (/ -0.5 x)) x) (copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
double code(double x) {
double tmp;
if (x <= -9000.0) {
tmp = copysign(log((-0.5 / 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 <= -9000.0) {
tmp = Math.copySign(Math.log((-0.5 / 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 <= -9000.0: tmp = math.copysign(math.log((-0.5 / 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 <= -9000.0) tmp = copysign(log(Float64(-0.5 / 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, -9000.0], N[With[{TMP1 = Abs[N[Log[N[(-0.5 / 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}\;x \leq -9000:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{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 x < -9e3Initial program 57.4%
Taylor expanded in x around -inf 100.0%
sub-neg100.0%
neg-mul-1100.0%
unsub-neg100.0%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 99.8%
if -9e3 < x Initial program 20.3%
log1p-expm1-u20.3%
expm1-undefine20.3%
add-exp-log20.3%
add-sqr-sqrt16.2%
fabs-sqr16.2%
add-sqr-sqrt20.1%
+-commutative20.1%
hypot-1-def41.0%
Applied egg-rr41.0%
associate--l+98.9%
Simplified98.9%
Final simplification99.2%
(FPCore (x)
:precision binary64
(if (<= x -1.25)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.95)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log1p (+ (/ 0.5 x) (+ -1.0 (* x 2.0)))) x))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = copysign(log((-0.5 / x)), x);
} else if (x <= 0.95) {
tmp = copysign((x + (pow(x, 3.0) * -0.16666666666666666)), x);
} else {
tmp = copysign(log1p(((0.5 / x) + (-1.0 + (x * 2.0)))), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = Math.copySign(Math.log((-0.5 / x)), x);
} else if (x <= 0.95) {
tmp = Math.copySign((x + (Math.pow(x, 3.0) * -0.16666666666666666)), x);
} else {
tmp = Math.copySign(Math.log1p(((0.5 / x) + (-1.0 + (x * 2.0)))), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.25: tmp = math.copysign(math.log((-0.5 / x)), x) elif x <= 0.95: tmp = math.copysign((x + (math.pow(x, 3.0) * -0.16666666666666666)), x) else: tmp = math.copysign(math.log1p(((0.5 / x) + (-1.0 + (x * 2.0)))), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.25) tmp = copysign(log(Float64(-0.5 / x)), x); elseif (x <= 0.95) tmp = copysign(Float64(x + Float64((x ^ 3.0) * -0.16666666666666666)), x); else tmp = copysign(log1p(Float64(Float64(0.5 / x) + Float64(-1.0 + Float64(x * 2.0)))), x); end return tmp end
code[x_] := If[LessEqual[x, -1.25], 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, 0.95], N[With[{TMP1 = Abs[N[(x + N[(N[Power[x, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[1 + N[(N[(0.5 / x), $MachinePrecision] + N[(-1.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.95:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\frac{0.5}{x} + \left(-1 + x \cdot 2\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 58.7%
Taylor expanded in x around -inf 99.4%
sub-neg99.4%
neg-mul-199.4%
unsub-neg99.4%
associate-*r/99.4%
metadata-eval99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 98.4%
if -1.25 < x < 0.94999999999999996Initial program 9.9%
log1p-expm1-u9.9%
expm1-undefine9.9%
add-exp-log9.9%
add-sqr-sqrt5.3%
fabs-sqr5.3%
add-sqr-sqrt9.9%
+-commutative9.9%
hypot-1-def9.9%
Applied egg-rr9.9%
associate--l+98.7%
Simplified98.7%
Taylor expanded in x around 0 99.3%
*-commutative99.3%
Simplified99.3%
if 0.94999999999999996 < x Initial program 38.0%
log1p-expm1-u38.0%
expm1-undefine38.0%
add-exp-log38.0%
add-sqr-sqrt38.0%
fabs-sqr38.0%
add-sqr-sqrt38.0%
+-commutative38.0%
hypot-1-def100.0%
Applied egg-rr100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate--l+100.0%
associate-*r/100.0%
metadata-eval100.0%
sub-neg100.0%
*-commutative100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification99.2%
(FPCore (x)
:precision binary64
(if (<= x -1.25)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.3)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log1p (+ (* x 2.0) -1.0)) x))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = copysign(log((-0.5 / x)), x);
} else if (x <= 1.3) {
tmp = copysign((x + (pow(x, 3.0) * -0.16666666666666666)), x);
} else {
tmp = copysign(log1p(((x * 2.0) + -1.0)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = Math.copySign(Math.log((-0.5 / x)), x);
} else if (x <= 1.3) {
tmp = Math.copySign((x + (Math.pow(x, 3.0) * -0.16666666666666666)), x);
} else {
tmp = Math.copySign(Math.log1p(((x * 2.0) + -1.0)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.25: tmp = math.copysign(math.log((-0.5 / x)), x) elif x <= 1.3: tmp = math.copysign((x + (math.pow(x, 3.0) * -0.16666666666666666)), x) else: tmp = math.copysign(math.log1p(((x * 2.0) + -1.0)), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.25) tmp = copysign(log(Float64(-0.5 / x)), x); elseif (x <= 1.3) tmp = copysign(Float64(x + Float64((x ^ 3.0) * -0.16666666666666666)), x); else tmp = copysign(log1p(Float64(Float64(x * 2.0) + -1.0)), x); end return tmp end
code[x_] := If[LessEqual[x, -1.25], 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.3], N[With[{TMP1 = Abs[N[(x + N[(N[Power[x, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[1 + N[(N[(x * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1.3:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x \cdot 2 + -1\right), x\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 58.7%
Taylor expanded in x around -inf 99.4%
sub-neg99.4%
neg-mul-199.4%
unsub-neg99.4%
associate-*r/99.4%
metadata-eval99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 98.4%
if -1.25 < x < 1.30000000000000004Initial program 9.9%
log1p-expm1-u9.9%
expm1-undefine9.9%
add-exp-log9.9%
add-sqr-sqrt5.3%
fabs-sqr5.3%
add-sqr-sqrt9.9%
+-commutative9.9%
hypot-1-def9.9%
Applied egg-rr9.9%
associate--l+98.7%
Simplified98.7%
Taylor expanded in x around 0 99.3%
*-commutative99.3%
Simplified99.3%
if 1.30000000000000004 < x Initial program 38.0%
log1p-expm1-u38.0%
expm1-undefine38.0%
add-exp-log38.0%
add-sqr-sqrt38.0%
fabs-sqr38.0%
add-sqr-sqrt38.0%
+-commutative38.0%
hypot-1-def100.0%
Applied egg-rr100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around inf 99.3%
Final simplification99.1%
(FPCore (x)
:precision binary64
(if (<= x -0.72)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (log1p x) x)
(copysign (log1p (+ (* x 2.0) -1.0)) x))))
double code(double x) {
double tmp;
if (x <= -0.72) {
tmp = copysign(log((-0.5 / x)), x);
} else if (x <= 1.0) {
tmp = copysign(log1p(x), x);
} else {
tmp = copysign(log1p(((x * 2.0) + -1.0)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.72) {
tmp = Math.copySign(Math.log((-0.5 / x)), x);
} else if (x <= 1.0) {
tmp = Math.copySign(Math.log1p(x), x);
} else {
tmp = Math.copySign(Math.log1p(((x * 2.0) + -1.0)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.72: tmp = math.copysign(math.log((-0.5 / x)), x) elif x <= 1.0: tmp = math.copysign(math.log1p(x), x) else: tmp = math.copysign(math.log1p(((x * 2.0) + -1.0)), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.72) tmp = copysign(log(Float64(-0.5 / x)), x); elseif (x <= 1.0) tmp = copysign(log1p(x), x); else tmp = copysign(log1p(Float64(Float64(x * 2.0) + -1.0)), x); end return tmp end
code[x_] := If[LessEqual[x, -0.72], 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.0], 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 + N[(N[(x * 2.0), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.72:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x \cdot 2 + -1\right), x\right)\\
\end{array}
\end{array}
if x < -0.71999999999999997Initial program 58.7%
Taylor expanded in x around -inf 99.4%
sub-neg99.4%
neg-mul-199.4%
unsub-neg99.4%
associate-*r/99.4%
metadata-eval99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 98.4%
if -0.71999999999999997 < x < 1Initial program 9.9%
Taylor expanded in x around 0 8.0%
*-un-lft-identity8.0%
log-prod8.0%
metadata-eval8.0%
+-commutative8.0%
log1p-define96.7%
add-sqr-sqrt54.5%
fabs-sqr54.5%
add-sqr-sqrt96.7%
Applied egg-rr96.7%
+-lft-identity96.7%
Simplified96.7%
if 1 < x Initial program 38.0%
log1p-expm1-u38.0%
expm1-undefine38.0%
add-exp-log38.0%
add-sqr-sqrt38.0%
fabs-sqr38.0%
add-sqr-sqrt38.0%
+-commutative38.0%
hypot-1-def100.0%
Applied egg-rr100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around inf 99.3%
Final simplification97.8%
(FPCore (x) :precision binary64 (if (<= x -0.72) (copysign (log (/ -0.5 x)) x) (if (<= x 0.95) (copysign (log1p x) x) (copysign (log1p (+ x x)) x))))
double code(double x) {
double tmp;
if (x <= -0.72) {
tmp = copysign(log((-0.5 / x)), x);
} else if (x <= 0.95) {
tmp = copysign(log1p(x), x);
} else {
tmp = copysign(log1p((x + x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.72) {
tmp = Math.copySign(Math.log((-0.5 / x)), x);
} else if (x <= 0.95) {
tmp = Math.copySign(Math.log1p(x), x);
} else {
tmp = Math.copySign(Math.log1p((x + x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.72: tmp = math.copysign(math.log((-0.5 / x)), x) elif x <= 0.95: tmp = math.copysign(math.log1p(x), x) else: tmp = math.copysign(math.log1p((x + x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.72) tmp = copysign(log(Float64(-0.5 / x)), x); elseif (x <= 0.95) tmp = copysign(log1p(x), x); else tmp = copysign(log1p(Float64(x + x)), x); end return tmp end
code[x_] := If[LessEqual[x, -0.72], 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, 0.95], 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 + 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 -0.72:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.95:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -0.71999999999999997Initial program 58.7%
Taylor expanded in x around -inf 99.4%
sub-neg99.4%
neg-mul-199.4%
unsub-neg99.4%
associate-*r/99.4%
metadata-eval99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 98.4%
if -0.71999999999999997 < x < 0.94999999999999996Initial program 9.9%
Taylor expanded in x around 0 8.0%
*-un-lft-identity8.0%
log-prod8.0%
metadata-eval8.0%
+-commutative8.0%
log1p-define96.7%
add-sqr-sqrt54.5%
fabs-sqr54.5%
add-sqr-sqrt96.7%
Applied egg-rr96.7%
+-lft-identity96.7%
Simplified96.7%
if 0.94999999999999996 < x Initial program 38.0%
log1p-expm1-u38.0%
expm1-undefine38.0%
add-exp-log38.0%
add-sqr-sqrt38.0%
fabs-sqr38.0%
add-sqr-sqrt38.0%
+-commutative38.0%
hypot-1-def100.0%
Applied egg-rr100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around inf 98.4%
Final simplification97.6%
(FPCore (x) :precision binary64 (if (<= x -0.72) (copysign (log (/ -0.5 x)) x) (copysign (log1p x) x)))
double code(double x) {
double tmp;
if (x <= -0.72) {
tmp = copysign(log((-0.5 / x)), x);
} else {
tmp = copysign(log1p(x), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.72) {
tmp = Math.copySign(Math.log((-0.5 / x)), x);
} else {
tmp = Math.copySign(Math.log1p(x), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.72: tmp = math.copysign(math.log((-0.5 / x)), x) else: tmp = math.copysign(math.log1p(x), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.72) tmp = copysign(log(Float64(-0.5 / x)), x); else tmp = copysign(log1p(x), x); end return tmp end
code[x_] := If[LessEqual[x, -0.72], N[With[{TMP1 = Abs[N[Log[N[(-0.5 / 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 -0.72:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -0.71999999999999997Initial program 58.7%
Taylor expanded in x around -inf 99.4%
sub-neg99.4%
neg-mul-199.4%
unsub-neg99.4%
associate-*r/99.4%
metadata-eval99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 98.4%
if -0.71999999999999997 < x Initial program 19.4%
Taylor expanded in x around 0 16.0%
*-un-lft-identity16.0%
log-prod16.0%
metadata-eval16.0%
+-commutative16.0%
log1p-define74.5%
add-sqr-sqrt46.7%
fabs-sqr46.7%
add-sqr-sqrt74.5%
Applied egg-rr74.5%
+-lft-identity74.5%
Simplified74.5%
Final simplification80.9%
(FPCore (x) :precision binary64 (if (<= x -0.5) (copysign (log (- x)) x) (copysign (log1p x) x)))
double code(double x) {
double tmp;
if (x <= -0.5) {
tmp = copysign(log(-x), x);
} else {
tmp = copysign(log1p(x), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.5) {
tmp = Math.copySign(Math.log(-x), x);
} else {
tmp = Math.copySign(Math.log1p(x), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.5: 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 <= -0.5) tmp = copysign(log(Float64(-x)), x); else tmp = copysign(log1p(x), x); end return tmp end
code[x_] := If[LessEqual[x, -0.5], 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 -0.5:\\
\;\;\;\;\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 < -0.5Initial program 58.7%
Taylor expanded in x around -inf 99.4%
sub-neg99.4%
neg-mul-199.4%
unsub-neg99.4%
associate-*r/99.4%
metadata-eval99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around inf 31.0%
neg-mul-131.0%
Simplified31.0%
if -0.5 < x Initial program 19.4%
Taylor expanded in x around 0 16.0%
*-un-lft-identity16.0%
log-prod16.0%
metadata-eval16.0%
+-commutative16.0%
log1p-define74.5%
add-sqr-sqrt46.7%
fabs-sqr46.7%
add-sqr-sqrt74.5%
Applied egg-rr74.5%
+-lft-identity74.5%
Simplified74.5%
Final simplification63.0%
(FPCore (x) :precision binary64 (copysign (log x) x))
double code(double x) {
return copysign(log(x), x);
}
public static double code(double x) {
return Math.copySign(Math.log(x), x);
}
def code(x): return math.copysign(math.log(x), x)
function code(x) return copysign(log(x), x) end
function tmp = code(x) tmp = sign(x) * abs(log(x)); end
code[x_] := N[With[{TMP1 = Abs[N[Log[x], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(\log x, x\right)
\end{array}
Initial program 29.9%
Taylor expanded in x around inf 9.4%
mul-1-neg9.4%
log-rec9.4%
remove-double-neg9.4%
Simplified9.4%
Final simplification9.4%
(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.9%
Taylor expanded in x around 0 20.0%
*-un-lft-identity20.0%
log-prod20.0%
metadata-eval20.0%
+-commutative20.0%
log1p-define63.0%
add-sqr-sqrt34.3%
fabs-sqr34.3%
add-sqr-sqrt54.7%
Applied egg-rr54.7%
+-lft-identity54.7%
Simplified54.7%
Final simplification54.7%
(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 2024048
(FPCore (x)
:name "Rust f64::asinh"
:precision binary64
:alt
(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))