
(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
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -10.0)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= t_0 1e-10)
(copysign (+ x (* -0.16666666666666666 (pow x 3.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 <= -10.0) {
tmp = copysign(-log(((x * -2.0) - (0.5 / x))), x);
} else if (t_0 <= 1e-10) {
tmp = copysign((x + (-0.16666666666666666 * pow(x, 3.0))), x);
} else {
tmp = copysign(log((x + hypot(1.0, x))), x);
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x);
double tmp;
if (t_0 <= -10.0) {
tmp = Math.copySign(-Math.log(((x * -2.0) - (0.5 / x))), x);
} else if (t_0 <= 1e-10) {
tmp = Math.copySign((x + (-0.16666666666666666 * Math.pow(x, 3.0))), x);
} else {
tmp = Math.copySign(Math.log((x + Math.hypot(1.0, x))), x);
}
return tmp;
}
def code(x): t_0 = math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x) tmp = 0 if t_0 <= -10.0: tmp = math.copysign(-math.log(((x * -2.0) - (0.5 / x))), x) elif t_0 <= 1e-10: tmp = math.copysign((x + (-0.16666666666666666 * math.pow(x, 3.0))), x) else: tmp = math.copysign(math.log((x + math.hypot(1.0, x))), x) return tmp
function code(x) t_0 = copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x) tmp = 0.0 if (t_0 <= -10.0) tmp = copysign(Float64(-log(Float64(Float64(x * -2.0) - Float64(0.5 / x)))), x); elseif (t_0 <= 1e-10) tmp = copysign(Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))), x); else tmp = copysign(log(Float64(x + hypot(1.0, x))), x); end return tmp end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + 1.0))))); tmp = 0.0; if (t_0 <= -10.0) tmp = sign(x) * abs(-log(((x * -2.0) - (0.5 / x)))); elseif (t_0 <= 1e-10) tmp = sign(x) * abs((x + (-0.16666666666666666 * (x ^ 3.0)))); else tmp = sign(x) * abs(log((x + hypot(1.0, x)))); end tmp_2 = tmp; end
code[x_] := 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, -10.0], N[With[{TMP1 = Abs[(-N[Log[N[(N[(x * -2.0), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[t$95$0, 1e-10], N[With[{TMP1 = Abs[N[(x + N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x + N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 10^{-10}:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < -10Initial program 48.1%
+-commutative48.1%
hypot-1-def100.0%
Simplified100.0%
flip-+1.4%
frac-2neg1.4%
log-div1.4%
Applied egg-rr4.3%
neg-sub04.3%
associate--r-4.3%
neg-sub04.3%
+-commutative4.3%
sub-neg4.3%
fma-undefine4.3%
unpow24.3%
associate--r+46.4%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in x around -inf 100.0%
*-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
if -10 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < 1.00000000000000004e-10Initial program 7.4%
+-commutative7.4%
hypot-1-def7.4%
Simplified7.4%
*-un-lft-identity7.4%
*-commutative7.4%
log-prod7.4%
*-un-lft-identity7.4%
*-un-lft-identity7.4%
add-sqr-sqrt3.7%
fabs-sqr3.7%
add-sqr-sqrt7.5%
metadata-eval7.5%
Applied egg-rr7.5%
+-rgt-identity7.5%
Simplified7.5%
Taylor expanded in x around 0 100.0%
if 1.00000000000000004e-10 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) Initial program 56.6%
+-commutative56.6%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
*-un-lft-identity100.0%
*-un-lft-identity100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(if (<= x -1.25)
(copysign (- (log (* x -2.0))) x)
(if (<= x 1.25)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (- (log (/ 0.5 x))) x))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = copysign(-log((x * -2.0)), x);
} else if (x <= 1.25) {
tmp = copysign((x + (-0.16666666666666666 * pow(x, 3.0))), x);
} else {
tmp = copysign(-log((0.5 / x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = Math.copySign(-Math.log((x * -2.0)), x);
} else if (x <= 1.25) {
tmp = Math.copySign((x + (-0.16666666666666666 * Math.pow(x, 3.0))), x);
} else {
tmp = Math.copySign(-Math.log((0.5 / x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.25: tmp = math.copysign(-math.log((x * -2.0)), x) elif x <= 1.25: tmp = math.copysign((x + (-0.16666666666666666 * math.pow(x, 3.0))), x) else: tmp = math.copysign(-math.log((0.5 / x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.25) tmp = copysign(Float64(-log(Float64(x * -2.0))), x); elseif (x <= 1.25) tmp = copysign(Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))), x); else tmp = copysign(Float64(-log(Float64(0.5 / x))), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.25) tmp = sign(x) * abs(-log((x * -2.0))); elseif (x <= 1.25) tmp = sign(x) * abs((x + (-0.16666666666666666 * (x ^ 3.0)))); else tmp = sign(x) * abs(-log((0.5 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.25], N[With[{TMP1 = Abs[(-N[Log[N[(x * -2.0), $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[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.25:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\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 \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 48.1%
+-commutative48.1%
hypot-1-def100.0%
Simplified100.0%
flip-+1.4%
frac-2neg1.4%
log-div1.4%
Applied egg-rr4.3%
neg-sub04.3%
associate--r-4.3%
neg-sub04.3%
+-commutative4.3%
sub-neg4.3%
fma-undefine4.3%
unpow24.3%
associate--r+46.4%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.6%
*-commutative99.6%
Simplified99.6%
if -1.25 < x < 1.25Initial program 7.4%
+-commutative7.4%
hypot-1-def7.4%
Simplified7.4%
*-un-lft-identity7.4%
*-commutative7.4%
log-prod7.4%
*-un-lft-identity7.4%
*-un-lft-identity7.4%
add-sqr-sqrt3.7%
fabs-sqr3.7%
add-sqr-sqrt7.5%
metadata-eval7.5%
Applied egg-rr7.5%
+-rgt-identity7.5%
Simplified7.5%
Taylor expanded in x around 0 100.0%
if 1.25 < x Initial program 56.6%
+-commutative56.6%
hypot-1-def100.0%
Simplified100.0%
flip-+2.1%
frac-2neg2.1%
log-div2.1%
Applied egg-rr2.0%
neg-sub02.0%
associate--r-2.0%
neg-sub02.0%
+-commutative2.0%
sub-neg2.0%
fma-undefine2.0%
unpow22.0%
associate--r+3.6%
+-inverses5.0%
metadata-eval5.0%
metadata-eval5.0%
metadata-eval5.0%
neg-sub05.0%
Simplified5.0%
Taylor expanded in x around inf 98.9%
Final simplification99.6%
(FPCore (x)
:precision binary64
(if (<= x -0.96)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 1.25)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (- (log (/ 0.5 x))) x))))
double code(double x) {
double tmp;
if (x <= -0.96) {
tmp = copysign(-log(((x * -2.0) - (0.5 / x))), x);
} else if (x <= 1.25) {
tmp = copysign((x + (-0.16666666666666666 * pow(x, 3.0))), x);
} else {
tmp = copysign(-log((0.5 / x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.96) {
tmp = Math.copySign(-Math.log(((x * -2.0) - (0.5 / 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((0.5 / x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.96: tmp = math.copysign(-math.log(((x * -2.0) - (0.5 / x))), x) elif x <= 1.25: tmp = math.copysign((x + (-0.16666666666666666 * math.pow(x, 3.0))), x) else: tmp = math.copysign(-math.log((0.5 / x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.96) tmp = copysign(Float64(-log(Float64(Float64(x * -2.0) - Float64(0.5 / x)))), x); elseif (x <= 1.25) tmp = copysign(Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))), x); else tmp = copysign(Float64(-log(Float64(0.5 / x))), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -0.96) tmp = sign(x) * abs(-log(((x * -2.0) - (0.5 / x)))); elseif (x <= 1.25) tmp = sign(x) * abs((x + (-0.16666666666666666 * (x ^ 3.0)))); else tmp = sign(x) * abs(-log((0.5 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -0.96], N[With[{TMP1 = Abs[(-N[Log[N[(N[(x * -2.0), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $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[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 -0.96:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{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 \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -0.95999999999999996Initial program 48.1%
+-commutative48.1%
hypot-1-def100.0%
Simplified100.0%
flip-+1.4%
frac-2neg1.4%
log-div1.4%
Applied egg-rr4.3%
neg-sub04.3%
associate--r-4.3%
neg-sub04.3%
+-commutative4.3%
sub-neg4.3%
fma-undefine4.3%
unpow24.3%
associate--r+46.4%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in x around -inf 100.0%
*-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
if -0.95999999999999996 < x < 1.25Initial program 7.4%
+-commutative7.4%
hypot-1-def7.4%
Simplified7.4%
*-un-lft-identity7.4%
*-commutative7.4%
log-prod7.4%
*-un-lft-identity7.4%
*-un-lft-identity7.4%
add-sqr-sqrt3.7%
fabs-sqr3.7%
add-sqr-sqrt7.5%
metadata-eval7.5%
Applied egg-rr7.5%
+-rgt-identity7.5%
Simplified7.5%
Taylor expanded in x around 0 100.0%
if 1.25 < x Initial program 56.6%
+-commutative56.6%
hypot-1-def100.0%
Simplified100.0%
flip-+2.1%
frac-2neg2.1%
log-div2.1%
Applied egg-rr2.0%
neg-sub02.0%
associate--r-2.0%
neg-sub02.0%
+-commutative2.0%
sub-neg2.0%
fma-undefine2.0%
unpow22.0%
associate--r+3.6%
+-inverses5.0%
metadata-eval5.0%
metadata-eval5.0%
metadata-eval5.0%
neg-sub05.0%
Simplified5.0%
Taylor expanded in x around inf 98.9%
Final simplification99.7%
(FPCore (x) :precision binary64 (if (<= x -1.25) (copysign (- (log (* x -2.0))) x) (if (<= x 1.25) (copysign x x) (copysign (- (log (/ 0.5 x))) x))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = copysign(-log((x * -2.0)), x);
} else if (x <= 1.25) {
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.25) {
tmp = Math.copySign(-Math.log((x * -2.0)), x);
} else if (x <= 1.25) {
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.25: tmp = math.copysign(-math.log((x * -2.0)), x) elif x <= 1.25: 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.25) tmp = copysign(Float64(-log(Float64(x * -2.0))), x); elseif (x <= 1.25) tmp = copysign(x, x); else tmp = copysign(Float64(-log(Float64(0.5 / x))), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.25) tmp = sign(x) * abs(-log((x * -2.0))); elseif (x <= 1.25) 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.25], N[With[{TMP1 = Abs[(-N[Log[N[(x * -2.0), $MachinePrecision]], $MachinePrecision])], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 1.25], 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.25:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;\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.25Initial program 48.1%
+-commutative48.1%
hypot-1-def100.0%
Simplified100.0%
flip-+1.4%
frac-2neg1.4%
log-div1.4%
Applied egg-rr4.3%
neg-sub04.3%
associate--r-4.3%
neg-sub04.3%
+-commutative4.3%
sub-neg4.3%
fma-undefine4.3%
unpow24.3%
associate--r+46.4%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.6%
*-commutative99.6%
Simplified99.6%
if -1.25 < x < 1.25Initial program 7.4%
+-commutative7.4%
hypot-1-def7.4%
Simplified7.4%
*-un-lft-identity7.4%
*-commutative7.4%
log-prod7.4%
*-un-lft-identity7.4%
*-un-lft-identity7.4%
add-sqr-sqrt3.7%
fabs-sqr3.7%
add-sqr-sqrt7.5%
metadata-eval7.5%
Applied egg-rr7.5%
+-rgt-identity7.5%
Simplified7.5%
Taylor expanded in x around 0 99.8%
if 1.25 < x Initial program 56.6%
+-commutative56.6%
hypot-1-def100.0%
Simplified100.0%
flip-+2.1%
frac-2neg2.1%
log-div2.1%
Applied egg-rr2.0%
neg-sub02.0%
associate--r-2.0%
neg-sub02.0%
+-commutative2.0%
sub-neg2.0%
fma-undefine2.0%
unpow22.0%
associate--r+3.6%
+-inverses5.0%
metadata-eval5.0%
metadata-eval5.0%
metadata-eval5.0%
neg-sub05.0%
Simplified5.0%
Taylor expanded in x around inf 98.9%
Final simplification99.5%
(FPCore (x) :precision binary64 (if (<= x -0.72) (copysign (- (log (* x -2.0))) x) (copysign (log1p x) x)))
double code(double x) {
double tmp;
if (x <= -0.72) {
tmp = copysign(-log((x * -2.0)), 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((x * -2.0)), 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((x * -2.0)), x) else: tmp = math.copysign(math.log1p(x), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.72) tmp = copysign(Float64(-log(Float64(x * -2.0))), 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[(x * -2.0), $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(x \cdot -2\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -0.71999999999999997Initial program 48.1%
+-commutative48.1%
hypot-1-def100.0%
Simplified100.0%
flip-+1.4%
frac-2neg1.4%
log-div1.4%
Applied egg-rr4.3%
neg-sub04.3%
associate--r-4.3%
neg-sub04.3%
+-commutative4.3%
sub-neg4.3%
fma-undefine4.3%
unpow24.3%
associate--r+46.4%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.6%
*-commutative99.6%
Simplified99.6%
if -0.71999999999999997 < x Initial program 25.1%
+-commutative25.1%
hypot-1-def40.6%
Simplified40.6%
Taylor expanded in x around 0 15.7%
log1p-define74.5%
unpow174.5%
sqr-pow42.2%
fabs-sqr42.2%
sqr-pow74.5%
unpow174.5%
Simplified74.5%
Final simplification81.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 22.3%
+-commutative22.3%
hypot-1-def41.2%
Simplified41.2%
*-un-lft-identity41.2%
*-commutative41.2%
log-prod41.2%
*-un-lft-identity41.2%
*-un-lft-identity41.2%
add-sqr-sqrt2.3%
fabs-sqr2.3%
add-sqr-sqrt6.4%
metadata-eval6.4%
Applied egg-rr6.4%
+-rgt-identity6.4%
Simplified6.4%
Taylor expanded in x around 0 65.4%
if 0.650000000000000022 < x Initial program 56.6%
+-commutative56.6%
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 simplification56.9%
(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.3%
+-commutative22.3%
hypot-1-def41.2%
Simplified41.2%
*-un-lft-identity41.2%
*-commutative41.2%
log-prod41.2%
*-un-lft-identity41.2%
*-un-lft-identity41.2%
add-sqr-sqrt2.3%
fabs-sqr2.3%
add-sqr-sqrt6.4%
metadata-eval6.4%
Applied egg-rr6.4%
+-rgt-identity6.4%
Simplified6.4%
Taylor expanded in x around 0 65.4%
if 1.6000000000000001 < x Initial program 56.6%
+-commutative56.6%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 31.1%
log1p-define31.1%
unpow131.1%
sqr-pow31.1%
fabs-sqr31.1%
sqr-pow31.1%
unpow131.1%
Simplified31.1%
Final simplification56.4%
(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.3%
+-commutative31.3%
hypot-1-def56.6%
Simplified56.6%
*-un-lft-identity56.6%
*-commutative56.6%
log-prod56.6%
*-un-lft-identity56.6%
*-un-lft-identity56.6%
add-sqr-sqrt27.9%
fabs-sqr27.9%
add-sqr-sqrt30.9%
metadata-eval30.9%
Applied egg-rr30.9%
+-rgt-identity30.9%
Simplified30.9%
Taylor expanded in x around 0 49.8%
Final simplification49.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 2024044
(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))