
(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 6 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 (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.1%
+-commutative29.1%
hypot-1-def55.2%
Simplified55.2%
Taylor expanded in x around 0 19.1%
log1p-def63.7%
rem-square-sqrt28.6%
fabs-sqr28.6%
rem-square-sqrt54.6%
Simplified54.6%
Final simplification54.6%
(FPCore (x) :precision binary64 (copysign (+ (+ 1.0 (log (+ x (hypot 1.0 x)))) -1.0) x))
double code(double x) {
return copysign(((1.0 + log((x + hypot(1.0, x)))) + -1.0), x);
}
public static double code(double x) {
return Math.copySign(((1.0 + Math.log((x + Math.hypot(1.0, x)))) + -1.0), x);
}
def code(x): return math.copysign(((1.0 + math.log((x + math.hypot(1.0, x)))) + -1.0), x)
function code(x) return copysign(Float64(Float64(1.0 + log(Float64(x + hypot(1.0, x)))) + -1.0), x) end
function tmp = code(x) tmp = sign(x) * abs(((1.0 + log((x + hypot(1.0, x)))) + -1.0)); end
code[x_] := N[With[{TMP1 = Abs[N[(N[(1.0 + N[Log[N[(x + N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(\left(1 + \log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right) + -1, x\right)
\end{array}
Initial program 29.1%
+-commutative29.1%
hypot-1-def55.2%
Simplified55.2%
expm1-log1p-u54.3%
expm1-udef54.3%
log1p-udef54.3%
rem-exp-log55.2%
*-un-lft-identity55.2%
*-un-lft-identity55.2%
add-sqr-sqrt24.6%
fabs-sqr24.6%
add-sqr-sqrt27.7%
Applied egg-rr27.7%
Final simplification27.7%
(FPCore (x) :precision binary64 (copysign (log (+ x (hypot 1.0 x))) x))
double code(double x) {
return copysign(log((x + hypot(1.0, x))), x);
}
public static double code(double x) {
return Math.copySign(Math.log((x + Math.hypot(1.0, x))), x);
}
def code(x): return math.copysign(math.log((x + math.hypot(1.0, x))), x)
function code(x) return copysign(log(Float64(x + hypot(1.0, x))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((x + hypot(1.0, x)))); end
code[x_] := 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}
\\
\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)
\end{array}
Initial program 29.1%
+-commutative29.1%
hypot-1-def55.2%
Simplified55.2%
*-un-lft-identity55.2%
*-commutative55.2%
log-prod55.2%
add-sqr-sqrt24.6%
fabs-sqr24.6%
add-sqr-sqrt27.7%
metadata-eval27.7%
Applied egg-rr27.7%
+-rgt-identity27.7%
Simplified27.7%
Final simplification27.7%
(FPCore (x) :precision binary64 (copysign (log (+ (+ x x) (/ 0.5 x))) x))
double code(double x) {
return copysign(log(((x + x) + (0.5 / x))), x);
}
public static double code(double x) {
return Math.copySign(Math.log(((x + x) + (0.5 / x))), x);
}
def code(x): return math.copysign(math.log(((x + x) + (0.5 / x))), x)
function code(x) return copysign(log(Float64(Float64(x + x) + Float64(0.5 / x))), x) end
function tmp = code(x) tmp = sign(x) * abs(log(((x + x) + (0.5 / x)))); end
code[x_] := N[With[{TMP1 = Abs[N[Log[N[(N[(x + x), $MachinePrecision] + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left(x + x\right) + \frac{0.5}{x}\right), x\right)
\end{array}
Initial program 29.1%
+-commutative29.1%
hypot-1-def55.2%
Simplified55.2%
Taylor expanded in x around inf 24.7%
rem-square-sqrt23.9%
fabs-sqr23.9%
rem-square-sqrt23.9%
associate-+r+23.9%
associate-*r/23.9%
metadata-eval23.9%
Simplified23.9%
Final simplification23.9%
(FPCore (x) :precision binary64 (copysign (log (+ x x)) x))
double code(double x) {
return copysign(log((x + x)), x);
}
public static double code(double x) {
return Math.copySign(Math.log((x + x)), x);
}
def code(x): return math.copysign(math.log((x + x)), x)
function code(x) return copysign(log(Float64(x + x)), x) end
function tmp = code(x) tmp = sign(x) * abs(log((x + x))); end
code[x_] := N[With[{TMP1 = Abs[N[Log[N[(x + x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(x + x\right), x\right)
\end{array}
Initial program 29.1%
+-commutative29.1%
hypot-1-def55.2%
Simplified55.2%
Taylor expanded in x around inf 25.2%
rem-square-sqrt23.7%
fabs-sqr23.7%
rem-square-sqrt23.7%
Simplified23.7%
Final simplification23.7%
(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.1%
+-commutative29.1%
hypot-1-def55.2%
Simplified55.2%
Taylor expanded in x around inf 8.5%
mul-1-neg8.5%
log-rec8.5%
remove-double-neg8.5%
Simplified8.5%
Final simplification8.5%
(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 2024033
(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))