
(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 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
double code(double x) {
return copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x);
}
public static double code(double x) {
return Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x);
}
def code(x): return math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x)
function code(x) return copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + 1.0))))); end
code[x_] := N[With[{TMP1 = Abs[N[Log[N[(N[Abs[x], $MachinePrecision] + N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -40.0)
(copysign (log (+ (fabs x) (hypot 1.0 x))) x)
(if (<= t_0 0.002)
(copysign
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 0.075 (pow x 5.0))))
x)
(copysign (log (+ x (hypot 1.0 x))) x)))))
double code(double x) {
double t_0 = copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x);
double tmp;
if (t_0 <= -40.0) {
tmp = copysign(log((fabs(x) + hypot(1.0, x))), x);
} else if (t_0 <= 0.002) {
tmp = copysign(((-0.16666666666666666 * pow(x, 3.0)) + (x + (0.075 * pow(x, 5.0)))), x);
} else {
tmp = copysign(log((x + hypot(1.0, x))), x);
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x);
double tmp;
if (t_0 <= -40.0) {
tmp = Math.copySign(Math.log((Math.abs(x) + Math.hypot(1.0, x))), x);
} else if (t_0 <= 0.002) {
tmp = Math.copySign(((-0.16666666666666666 * Math.pow(x, 3.0)) + (x + (0.075 * Math.pow(x, 5.0)))), x);
} else {
tmp = Math.copySign(Math.log((x + Math.hypot(1.0, x))), x);
}
return tmp;
}
def code(x): t_0 = math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x) tmp = 0 if t_0 <= -40.0: tmp = math.copysign(math.log((math.fabs(x) + math.hypot(1.0, x))), x) elif t_0 <= 0.002: tmp = math.copysign(((-0.16666666666666666 * math.pow(x, 3.0)) + (x + (0.075 * math.pow(x, 5.0)))), x) else: tmp = math.copysign(math.log((x + math.hypot(1.0, x))), x) return tmp
function code(x) t_0 = copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x) tmp = 0.0 if (t_0 <= -40.0) tmp = copysign(log(Float64(abs(x) + hypot(1.0, x))), x); elseif (t_0 <= 0.002) tmp = copysign(Float64(Float64(-0.16666666666666666 * (x ^ 3.0)) + Float64(x + Float64(0.075 * (x ^ 5.0)))), x); else tmp = copysign(log(Float64(x + hypot(1.0, x))), x); end return tmp end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + 1.0))))); tmp = 0.0; if (t_0 <= -40.0) tmp = sign(x) * abs(log((abs(x) + hypot(1.0, x)))); elseif (t_0 <= 0.002) tmp = sign(x) * abs(((-0.16666666666666666 * (x ^ 3.0)) + (x + (0.075 * (x ^ 5.0))))); else tmp = sign(x) * abs(log((x + hypot(1.0, x)))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[With[{TMP1 = Abs[N[Log[N[(N[Abs[x], $MachinePrecision] + N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]}, If[LessEqual[t$95$0, -40.0], 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], If[LessEqual[t$95$0, 0.002], N[With[{TMP1 = Abs[N[(N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(x + N[(0.075 * N[Power[x, 5.0], $MachinePrecision]), $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}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t_0 \leq -40:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.002:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(x + 0.075 \cdot {x}^{5}\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 (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < -40Initial program 41.9%
+-commutative41.9%
hypot-1-def100.0%
Simplified100.0%
if -40 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < 2e-3Initial program 7.7%
+-commutative7.7%
hypot-1-def7.7%
Simplified7.7%
*-un-lft-identity7.7%
log-prod7.7%
metadata-eval7.7%
*-un-lft-identity7.7%
*-un-lft-identity7.7%
add-sqr-sqrt4.2%
fabs-sqr4.2%
add-sqr-sqrt7.7%
Applied egg-rr7.7%
+-lft-identity7.7%
Simplified7.7%
Taylor expanded in x around 0 100.0%
if 2e-3 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) Initial program 61.2%
+-commutative61.2%
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-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(if (<= x -1.35)
(copysign (+ (log (/ -1.0 x)) (log 0.5)) x)
(if (<= x 0.0065)
(copysign
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 0.075 (pow x 5.0))))
x)
(copysign (log (+ x (hypot 1.0 x))) x))))
double code(double x) {
double tmp;
if (x <= -1.35) {
tmp = copysign((log((-1.0 / x)) + log(0.5)), x);
} else if (x <= 0.0065) {
tmp = copysign(((-0.16666666666666666 * pow(x, 3.0)) + (x + (0.075 * pow(x, 5.0)))), x);
} else {
tmp = copysign(log((x + hypot(1.0, x))), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.35) {
tmp = Math.copySign((Math.log((-1.0 / x)) + Math.log(0.5)), x);
} else if (x <= 0.0065) {
tmp = Math.copySign(((-0.16666666666666666 * Math.pow(x, 3.0)) + (x + (0.075 * Math.pow(x, 5.0)))), x);
} else {
tmp = Math.copySign(Math.log((x + Math.hypot(1.0, x))), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.35: tmp = math.copysign((math.log((-1.0 / x)) + math.log(0.5)), x) elif x <= 0.0065: tmp = math.copysign(((-0.16666666666666666 * math.pow(x, 3.0)) + (x + (0.075 * math.pow(x, 5.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 <= -1.35) tmp = copysign(Float64(log(Float64(-1.0 / x)) + log(0.5)), x); elseif (x <= 0.0065) tmp = copysign(Float64(Float64(-0.16666666666666666 * (x ^ 3.0)) + Float64(x + Float64(0.075 * (x ^ 5.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 <= -1.35) tmp = sign(x) * abs((log((-1.0 / x)) + log(0.5))); elseif (x <= 0.0065) tmp = sign(x) * abs(((-0.16666666666666666 * (x ^ 3.0)) + (x + (0.075 * (x ^ 5.0))))); else tmp = sign(x) * abs(log((x + hypot(1.0, x)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.35], N[With[{TMP1 = Abs[N[(N[Log[N[(-1.0 / x), $MachinePrecision]], $MachinePrecision] + N[Log[0.5], $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 0.0065], N[With[{TMP1 = Abs[N[(N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(x + N[(0.075 * N[Power[x, 5.0], $MachinePrecision]), $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 -1.35:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-1}{x}\right) + \log 0.5, x\right)\\
\mathbf{elif}\;x \leq 0.0065:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(x + 0.075 \cdot {x}^{5}\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 < -1.3500000000000001Initial program 41.9%
+-commutative41.9%
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-sqrt3.1%
Applied egg-rr3.1%
+-lft-identity3.1%
Simplified3.1%
Taylor expanded in x around -inf 99.7%
if -1.3500000000000001 < x < 0.0064999999999999997Initial program 7.7%
+-commutative7.7%
hypot-1-def7.7%
Simplified7.7%
*-un-lft-identity7.7%
log-prod7.7%
metadata-eval7.7%
*-un-lft-identity7.7%
*-un-lft-identity7.7%
add-sqr-sqrt4.2%
fabs-sqr4.2%
add-sqr-sqrt7.7%
Applied egg-rr7.7%
+-lft-identity7.7%
Simplified7.7%
Taylor expanded in x around 0 100.0%
if 0.0064999999999999997 < x Initial program 61.2%
+-commutative61.2%
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-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x)
:precision binary64
(if (<= x -1.25)
(copysign (+ (log (/ -1.0 x)) (log 0.5)) x)
(if (<= x 8.2e-6)
(copysign x x)
(copysign (+ -1.0 (+ 1.0 (log (+ x (hypot 1.0 x))))) x))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = copysign((log((-1.0 / x)) + log(0.5)), x);
} else if (x <= 8.2e-6) {
tmp = copysign(x, x);
} else {
tmp = copysign((-1.0 + (1.0 + 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((-1.0 / x)) + Math.log(0.5)), x);
} else if (x <= 8.2e-6) {
tmp = Math.copySign(x, x);
} else {
tmp = Math.copySign((-1.0 + (1.0 + 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((-1.0 / x)) + math.log(0.5)), x) elif x <= 8.2e-6: tmp = math.copysign(x, x) else: tmp = math.copysign((-1.0 + (1.0 + math.log((x + math.hypot(1.0, x))))), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.25) tmp = copysign(Float64(log(Float64(-1.0 / x)) + log(0.5)), x); elseif (x <= 8.2e-6) tmp = copysign(x, x); else tmp = copysign(Float64(-1.0 + Float64(1.0 + 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((-1.0 / x)) + log(0.5))); elseif (x <= 8.2e-6) tmp = sign(x) * abs(x); else tmp = sign(x) * abs((-1.0 + (1.0 + log((x + hypot(1.0, x)))))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.25], N[With[{TMP1 = Abs[N[(N[Log[N[(-1.0 / x), $MachinePrecision]], $MachinePrecision] + N[Log[0.5], $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 8.2e-6], N[With[{TMP1 = Abs[x], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[(-1.0 + N[(1.0 + N[Log[N[(x + N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $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{-1}{x}\right) + \log 0.5, x\right)\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-1 + \left(1 + \log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 41.9%
+-commutative41.9%
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-sqrt3.1%
Applied egg-rr3.1%
+-lft-identity3.1%
Simplified3.1%
Taylor expanded in x around -inf 99.7%
if -1.25 < x < 8.1999999999999994e-6Initial program 7.0%
+-commutative7.0%
hypot-1-def7.0%
Simplified7.0%
*-un-lft-identity7.0%
log-prod7.0%
metadata-eval7.0%
*-un-lft-identity7.0%
*-un-lft-identity7.0%
add-sqr-sqrt3.5%
fabs-sqr3.5%
add-sqr-sqrt7.0%
Applied egg-rr7.0%
+-lft-identity7.0%
Simplified7.0%
Taylor expanded in x around 0 100.0%
if 8.1999999999999994e-6 < x Initial program 61.6%
+-commutative61.6%
hypot-1-def99.8%
Simplified99.8%
expm1-log1p-u98.0%
expm1-udef98.0%
log1p-udef98.0%
add-exp-log99.8%
*-un-lft-identity99.8%
*-un-lft-identity99.8%
add-sqr-sqrt99.8%
fabs-sqr99.8%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
Final simplification99.9%
(FPCore (x) :precision binary64 (if (<= x -3.15) (copysign (- (log (/ -1.0 x))) x) (if (<= x 8.2e-6) (copysign x x) (copysign (log (+ x (hypot 1.0 x))) x))))
double code(double x) {
double tmp;
if (x <= -3.15) {
tmp = copysign(-log((-1.0 / x)), x);
} else if (x <= 8.2e-6) {
tmp = copysign(x, x);
} else {
tmp = copysign(log((x + hypot(1.0, x))), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -3.15) {
tmp = Math.copySign(-Math.log((-1.0 / x)), x);
} else if (x <= 8.2e-6) {
tmp = Math.copySign(x, x);
} else {
tmp = Math.copySign(Math.log((x + Math.hypot(1.0, x))), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -3.15: tmp = math.copysign(-math.log((-1.0 / x)), x) elif x <= 8.2e-6: tmp = math.copysign(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 <= -3.15) tmp = copysign(Float64(-log(Float64(-1.0 / x))), x); elseif (x <= 8.2e-6) tmp = copysign(x, 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 <= -3.15) tmp = sign(x) * abs(-log((-1.0 / x))); elseif (x <= 8.2e-6) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + hypot(1.0, x)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -3.15], 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, 8.2e-6], N[With[{TMP1 = Abs[x], 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 -3.15:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{copysign}\left(x, 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 < -3.14999999999999991Initial program 41.9%
+-commutative41.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 32.0%
mul-1-neg32.0%
Simplified32.0%
if -3.14999999999999991 < x < 8.1999999999999994e-6Initial program 7.0%
+-commutative7.0%
hypot-1-def7.0%
Simplified7.0%
*-un-lft-identity7.0%
log-prod7.0%
metadata-eval7.0%
*-un-lft-identity7.0%
*-un-lft-identity7.0%
add-sqr-sqrt3.5%
fabs-sqr3.5%
add-sqr-sqrt7.0%
Applied egg-rr7.0%
+-lft-identity7.0%
Simplified7.0%
Taylor expanded in x around 0 100.0%
if 8.1999999999999994e-6 < x Initial program 61.6%
+-commutative61.6%
hypot-1-def99.8%
Simplified99.8%
*-un-lft-identity99.8%
log-prod99.8%
metadata-eval99.8%
*-un-lft-identity99.8%
*-un-lft-identity99.8%
add-sqr-sqrt99.8%
fabs-sqr99.8%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
+-lft-identity99.8%
Simplified99.8%
Final simplification82.7%
(FPCore (x) :precision binary64 (if (<= x -1.25) (copysign (+ (log (/ -1.0 x)) (log 0.5)) x) (if (<= x 8.2e-6) (copysign x x) (copysign (log (+ x (hypot 1.0 x))) x))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = copysign((log((-1.0 / x)) + log(0.5)), x);
} else if (x <= 8.2e-6) {
tmp = copysign(x, 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((-1.0 / x)) + Math.log(0.5)), x);
} else if (x <= 8.2e-6) {
tmp = Math.copySign(x, 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((-1.0 / x)) + math.log(0.5)), x) elif x <= 8.2e-6: tmp = math.copysign(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 <= -1.25) tmp = copysign(Float64(log(Float64(-1.0 / x)) + log(0.5)), x); elseif (x <= 8.2e-6) tmp = copysign(x, 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((-1.0 / x)) + log(0.5))); elseif (x <= 8.2e-6) tmp = sign(x) * abs(x); 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[(N[Log[N[(-1.0 / x), $MachinePrecision]], $MachinePrecision] + N[Log[0.5], $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 8.2e-6], N[With[{TMP1 = Abs[x], 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{-1}{x}\right) + \log 0.5, x\right)\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{copysign}\left(x, 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 41.9%
+-commutative41.9%
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-sqrt3.1%
Applied egg-rr3.1%
+-lft-identity3.1%
Simplified3.1%
Taylor expanded in x around -inf 99.7%
if -1.25 < x < 8.1999999999999994e-6Initial program 7.0%
+-commutative7.0%
hypot-1-def7.0%
Simplified7.0%
*-un-lft-identity7.0%
log-prod7.0%
metadata-eval7.0%
*-un-lft-identity7.0%
*-un-lft-identity7.0%
add-sqr-sqrt3.5%
fabs-sqr3.5%
add-sqr-sqrt7.0%
Applied egg-rr7.0%
+-lft-identity7.0%
Simplified7.0%
Taylor expanded in x around 0 100.0%
if 8.1999999999999994e-6 < x Initial program 61.6%
+-commutative61.6%
hypot-1-def99.8%
Simplified99.8%
*-un-lft-identity99.8%
log-prod99.8%
metadata-eval99.8%
*-un-lft-identity99.8%
*-un-lft-identity99.8%
add-sqr-sqrt99.8%
fabs-sqr99.8%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
+-lft-identity99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (x)
:precision binary64
(if (<= x -1.96)
(copysign (- (log (/ -1.0 x))) x)
(if (<= x 1.25)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (+ (log 2.0) (log x)) x))))
double code(double x) {
double tmp;
if (x <= -1.96) {
tmp = copysign(-log((-1.0 / x)), x);
} else if (x <= 1.25) {
tmp = copysign((x + (-0.16666666666666666 * pow(x, 3.0))), x);
} else {
tmp = copysign((log(2.0) + log(x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.96) {
tmp = Math.copySign(-Math.log((-1.0 / x)), x);
} else if (x <= 1.25) {
tmp = Math.copySign((x + (-0.16666666666666666 * Math.pow(x, 3.0))), x);
} else {
tmp = Math.copySign((Math.log(2.0) + Math.log(x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.96: tmp = math.copysign(-math.log((-1.0 / x)), x) elif x <= 1.25: tmp = math.copysign((x + (-0.16666666666666666 * math.pow(x, 3.0))), x) else: tmp = math.copysign((math.log(2.0) + math.log(x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.96) tmp = copysign(Float64(-log(Float64(-1.0 / x))), x); elseif (x <= 1.25) tmp = copysign(Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))), x); else tmp = copysign(Float64(log(2.0) + log(x)), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.96) tmp = sign(x) * abs(-log((-1.0 / x))); elseif (x <= 1.25) tmp = sign(x) * abs((x + (-0.16666666666666666 * (x ^ 3.0)))); else tmp = sign(x) * abs((log(2.0) + log(x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.96], 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.25], 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[(N[Log[2.0], $MachinePrecision] + N[Log[x], $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.96:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log 2 + \log x, x\right)\\
\end{array}
\end{array}
if x < -1.96Initial program 41.9%
+-commutative41.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 32.0%
mul-1-neg32.0%
Simplified32.0%
if -1.96 < x < 1.25Initial program 8.4%
+-commutative8.4%
hypot-1-def8.4%
Simplified8.4%
*-un-lft-identity8.4%
log-prod8.4%
metadata-eval8.4%
*-un-lft-identity8.4%
*-un-lft-identity8.4%
add-sqr-sqrt5.0%
fabs-sqr5.0%
add-sqr-sqrt8.4%
Applied egg-rr8.4%
+-lft-identity8.4%
Simplified8.4%
Taylor expanded in x around 0 99.3%
if 1.25 < x Initial program 60.7%
+-commutative60.7%
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-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.5%
mul-1-neg98.5%
log-rec98.5%
remove-double-neg98.5%
Simplified98.5%
Final simplification82.0%
(FPCore (x) :precision binary64 (if (<= x -1.0) (copysign (- (log (/ -1.0 x))) x) (copysign (log1p x) x)))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = copysign(-log((-1.0 / x)), x);
} else {
tmp = copysign(log1p(x), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = Math.copySign(-Math.log((-1.0 / x)), x);
} else {
tmp = Math.copySign(Math.log1p(x), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = math.copysign(-math.log((-1.0 / x)), x) else: tmp = math.copysign(math.log1p(x), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = copysign(Float64(-log(Float64(-1.0 / x))), x); else tmp = copysign(log1p(x), x); end return tmp end
code[x_] := If[LessEqual[x, -1.0], N[With[{TMP1 = Abs[(-N[Log[N[(-1.0 / x), $MachinePrecision]], $MachinePrecision])], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[1 + x], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 41.9%
+-commutative41.9%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 32.0%
mul-1-neg32.0%
Simplified32.0%
if -1 < x Initial program 27.3%
+-commutative27.3%
hypot-1-def41.5%
Simplified41.5%
Taylor expanded in x around 0 15.9%
log1p-def73.9%
unpow173.9%
sqr-pow43.0%
fabs-sqr43.0%
sqr-pow73.9%
unpow173.9%
Simplified73.9%
Final simplification63.3%
(FPCore (x) :precision binary64 (if (<= x 0.65) (copysign x x) (copysign (+ 1.0 (log x)) x)))
double code(double x) {
double tmp;
if (x <= 0.65) {
tmp = copysign(x, x);
} else {
tmp = copysign((1.0 + log(x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 0.65) {
tmp = Math.copySign(x, x);
} else {
tmp = Math.copySign((1.0 + Math.log(x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.65: tmp = math.copysign(x, x) else: tmp = math.copysign((1.0 + math.log(x)), x) return tmp
function code(x) tmp = 0.0 if (x <= 0.65) tmp = copysign(x, x); else tmp = copysign(Float64(1.0 + log(x)), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.65) tmp = sign(x) * abs(x); else tmp = sign(x) * abs((1.0 + log(x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.65], N[With[{TMP1 = Abs[x], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[(1.0 + N[Log[x], $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.65:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(1 + \log x, x\right)\\
\end{array}
\end{array}
if x < 0.650000000000000022Initial program 20.0%
+-commutative20.0%
hypot-1-def40.2%
Simplified40.2%
*-un-lft-identity40.2%
log-prod40.2%
metadata-eval40.2%
*-un-lft-identity40.2%
*-un-lft-identity40.2%
add-sqr-sqrt3.2%
fabs-sqr3.2%
add-sqr-sqrt6.6%
Applied egg-rr6.6%
+-lft-identity6.6%
Simplified6.6%
Taylor expanded in x around 0 66.3%
if 0.650000000000000022 < x Initial program 60.7%
+-commutative60.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 32.9%
+-commutative32.9%
unpow132.9%
sqr-pow32.9%
fabs-sqr32.9%
sqr-pow32.9%
unpow132.9%
*-inverses32.9%
mul-1-neg32.9%
log-rec32.9%
remove-double-neg32.9%
Simplified32.9%
Final simplification57.3%
(FPCore (x) :precision binary64 (if (<= x 1.55) (copysign x x) (copysign (log1p x) x)))
double code(double x) {
double tmp;
if (x <= 1.55) {
tmp = copysign(x, x);
} else {
tmp = copysign(log1p(x), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.55) {
tmp = Math.copySign(x, x);
} else {
tmp = Math.copySign(Math.log1p(x), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.55: tmp = math.copysign(x, x) else: tmp = math.copysign(math.log1p(x), x) return tmp
function code(x) tmp = 0.0 if (x <= 1.55) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
code[x_] := If[LessEqual[x, 1.55], 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.55:\\
\;\;\;\;\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.55000000000000004Initial program 20.0%
+-commutative20.0%
hypot-1-def40.2%
Simplified40.2%
*-un-lft-identity40.2%
log-prod40.2%
metadata-eval40.2%
*-un-lft-identity40.2%
*-un-lft-identity40.2%
add-sqr-sqrt3.2%
fabs-sqr3.2%
add-sqr-sqrt6.6%
Applied egg-rr6.6%
+-lft-identity6.6%
Simplified6.6%
Taylor expanded in x around 0 66.3%
if 1.55000000000000004 < x Initial program 60.7%
+-commutative60.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 31.1%
log1p-def31.1%
unpow131.1%
sqr-pow31.1%
fabs-sqr31.1%
sqr-pow31.1%
unpow131.1%
Simplified31.1%
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 31.0%
+-commutative31.0%
hypot-1-def56.4%
Simplified56.4%
*-un-lft-identity56.4%
log-prod56.4%
metadata-eval56.4%
*-un-lft-identity56.4%
*-un-lft-identity56.4%
add-sqr-sqrt29.3%
fabs-sqr29.3%
add-sqr-sqrt31.8%
Applied egg-rr31.8%
+-lft-identity31.8%
Simplified31.8%
Taylor expanded in x around 0 50.0%
Final simplification50.0%
(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 2023172
(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))