
(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 -0.1)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 1e-5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (* x 2.0)) x)))))
double code(double x) {
double t_0 = copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x);
double tmp;
if (t_0 <= -0.1) {
tmp = copysign(-log((hypot(1.0, x) - x)), x);
} else if (t_0 <= 1e-5) {
tmp = copysign((x + (-0.16666666666666666 * pow(x, 3.0))), x);
} else {
tmp = copysign(log((x * 2.0)), 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 <= -0.1) {
tmp = Math.copySign(-Math.log((Math.hypot(1.0, x) - x)), x);
} else if (t_0 <= 1e-5) {
tmp = Math.copySign((x + (-0.16666666666666666 * Math.pow(x, 3.0))), x);
} else {
tmp = Math.copySign(Math.log((x * 2.0)), 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 <= -0.1: tmp = math.copysign(-math.log((math.hypot(1.0, x) - x)), x) elif t_0 <= 1e-5: tmp = math.copysign((x + (-0.16666666666666666 * math.pow(x, 3.0))), x) else: tmp = math.copysign(math.log((x * 2.0)), 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 <= -0.1) tmp = copysign(Float64(-log(Float64(hypot(1.0, x) - x))), x); elseif (t_0 <= 1e-5) tmp = copysign(Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))), x); else tmp = copysign(log(Float64(x * 2.0)), 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 <= -0.1) tmp = sign(x) * abs(-log((hypot(1.0, x) - x))); elseif (t_0 <= 1e-5) tmp = sign(x) * abs((x + (-0.16666666666666666 * (x ^ 3.0)))); else tmp = sign(x) * abs(log((x * 2.0))); 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, -0.1], N[With[{TMP1 = Abs[(-N[Log[N[(N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision])], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[t$95$0, 1e-5], 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 * 2.0), $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 -0.1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 10^{-5}:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) #s(literal 1 binary64))))) x) < -0.10000000000000001Initial program 59.4%
+-commutative59.4%
hypot-1-def100.0%
Simplified100.0%
flip-+2.6%
frac-2neg2.6%
log-div2.6%
Applied egg-rr4.9%
sub-neg4.9%
sub-neg4.9%
fma-undefine4.9%
unpow24.9%
associate--r+58.1%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
if -0.10000000000000001 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) #s(literal 1 binary64))))) x) < 1.00000000000000008e-5Initial program 7.9%
+-commutative7.9%
hypot-1-def7.9%
Simplified7.9%
*-un-lft-identity7.9%
*-commutative7.9%
log-prod7.9%
add-sqr-sqrt4.7%
fabs-sqr4.7%
add-sqr-sqrt7.9%
metadata-eval7.9%
Applied egg-rr7.9%
+-rgt-identity7.9%
Simplified7.9%
Taylor expanded in x around 0 100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-*l*100.0%
unpow2100.0%
unpow3100.0%
Simplified100.0%
if 1.00000000000000008e-5 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) #s(literal 1 binary64))))) x) Initial program 52.3%
+-commutative52.3%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
*-commutative100.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 (* x 2.0)) 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((x * 2.0)), 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((x * 2.0)), 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((x * 2.0)), 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(log(Float64(x * 2.0)), 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((x * 2.0))); 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[(x * 2.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(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(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 58.7%
+-commutative58.7%
hypot-1-def100.0%
Simplified100.0%
flip-+1.0%
frac-2neg1.0%
log-div1.0%
Applied egg-rr3.4%
sub-neg3.4%
sub-neg3.4%
fma-undefine3.4%
unpow23.4%
associate--r+57.4%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.5%
*-commutative99.5%
Simplified99.5%
if -1.25 < x < 1.25Initial program 8.6%
+-commutative8.6%
hypot-1-def8.6%
Simplified8.6%
*-un-lft-identity8.6%
*-commutative8.6%
log-prod8.6%
add-sqr-sqrt4.7%
fabs-sqr4.7%
add-sqr-sqrt8.6%
metadata-eval8.6%
Applied egg-rr8.6%
+-rgt-identity8.6%
Simplified8.6%
Taylor expanded in x around 0 99.5%
distribute-rgt-in99.5%
*-lft-identity99.5%
associate-*l*99.5%
unpow299.5%
unpow399.5%
Simplified99.5%
if 1.25 < x Initial program 52.3%
+-commutative52.3%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification99.7%
(FPCore (x) :precision binary64 (if (<= x -1.25) (copysign (log (/ -0.5 x)) x) (if (<= x 1.25) (copysign x x) (copysign (log (* x 2.0)) x))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = copysign(log((-0.5 / x)), x);
} else if (x <= 1.25) {
tmp = copysign(x, x);
} else {
tmp = copysign(log((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 <= 1.25) {
tmp = Math.copySign(x, x);
} else {
tmp = Math.copySign(Math.log((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 <= 1.25: tmp = math.copysign(x, x) else: tmp = math.copysign(math.log((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 <= 1.25) tmp = copysign(x, x); else tmp = copysign(log(Float64(x * 2.0)), 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 <= 1.25) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * 2.0))); 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, 1.25], N[With[{TMP1 = Abs[x], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x * 2.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.25:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 58.7%
+-commutative58.7%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt4.1%
metadata-eval4.1%
Applied egg-rr4.1%
+-rgt-identity4.1%
Simplified4.1%
Taylor expanded in x around -inf 99.5%
if -1.25 < x < 1.25Initial program 8.6%
+-commutative8.6%
hypot-1-def8.6%
Simplified8.6%
*-un-lft-identity8.6%
*-commutative8.6%
log-prod8.6%
add-sqr-sqrt4.7%
fabs-sqr4.7%
add-sqr-sqrt8.6%
metadata-eval8.6%
Applied egg-rr8.6%
+-rgt-identity8.6%
Simplified8.6%
Taylor expanded in x around 0 99.3%
if 1.25 < x Initial program 52.3%
+-commutative52.3%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification99.5%
(FPCore (x) :precision binary64 (if (<= x -1.25) (copysign (- (log (* x -2.0))) x) (if (<= x 1.25) (copysign x x) (copysign (log (* x 2.0)) 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((x * 2.0)), 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((x * 2.0)), 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((x * 2.0)), 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(log(Float64(x * 2.0)), 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((x * 2.0))); 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[(x * 2.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(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(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 58.7%
+-commutative58.7%
hypot-1-def100.0%
Simplified100.0%
flip-+1.0%
frac-2neg1.0%
log-div1.0%
Applied egg-rr3.4%
sub-neg3.4%
sub-neg3.4%
fma-undefine3.4%
unpow23.4%
associate--r+57.4%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.5%
*-commutative99.5%
Simplified99.5%
if -1.25 < x < 1.25Initial program 8.6%
+-commutative8.6%
hypot-1-def8.6%
Simplified8.6%
*-un-lft-identity8.6%
*-commutative8.6%
log-prod8.6%
add-sqr-sqrt4.7%
fabs-sqr4.7%
add-sqr-sqrt8.6%
metadata-eval8.6%
Applied egg-rr8.6%
+-rgt-identity8.6%
Simplified8.6%
Taylor expanded in x around 0 99.3%
if 1.25 < x Initial program 52.3%
+-commutative52.3%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification99.5%
(FPCore (x) :precision binary64 (if (<= x 1.25) (copysign x x) (copysign (log (* x 2.0)) x)))
double code(double x) {
double tmp;
if (x <= 1.25) {
tmp = copysign(x, x);
} else {
tmp = copysign(log((x * 2.0)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 1.25) {
tmp = Math.copySign(x, x);
} else {
tmp = Math.copySign(Math.log((x * 2.0)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.25: tmp = math.copysign(x, x) else: tmp = math.copysign(math.log((x * 2.0)), x) return tmp
function code(x) tmp = 0.0 if (x <= 1.25) tmp = copysign(x, x); else tmp = copysign(log(Float64(x * 2.0)), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.25) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * 2.0))); end tmp_2 = tmp; end
code[x_] := 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[(x * 2.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(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < 1.25Initial program 25.2%
+-commutative25.2%
hypot-1-def38.8%
Simplified38.8%
*-un-lft-identity38.8%
*-commutative38.8%
log-prod38.8%
add-sqr-sqrt3.1%
fabs-sqr3.1%
add-sqr-sqrt7.1%
metadata-eval7.1%
Applied egg-rr7.1%
+-rgt-identity7.1%
Simplified7.1%
Taylor expanded in x around 0 68.3%
if 1.25 < x Initial program 52.3%
+-commutative52.3%
hypot-1-def100.0%
Simplified100.0%
*-un-lft-identity100.0%
*-commutative100.0%
log-prod100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification77.1%
(FPCore (x) :precision binary64 (if (<= x 3.2) (copysign x x) (copysign (log x) x)))
double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = copysign(x, x);
} else {
tmp = copysign(log(x), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = Math.copySign(x, x);
} else {
tmp = Math.copySign(Math.log(x), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 3.2: tmp = math.copysign(x, x) else: tmp = math.copysign(math.log(x), x) return tmp
function code(x) tmp = 0.0 if (x <= 3.2) tmp = copysign(x, x); else tmp = copysign(log(x), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 3.2) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log(x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 3.2], N[With[{TMP1 = Abs[x], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[x], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 3.2000000000000002Initial program 25.2%
+-commutative25.2%
hypot-1-def38.8%
Simplified38.8%
*-un-lft-identity38.8%
*-commutative38.8%
log-prod38.8%
add-sqr-sqrt3.1%
fabs-sqr3.1%
add-sqr-sqrt7.1%
metadata-eval7.1%
Applied egg-rr7.1%
+-rgt-identity7.1%
Simplified7.1%
Taylor expanded in x around 0 68.3%
if 3.2000000000000002 < x Initial program 52.3%
+-commutative52.3%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 31.6%
mul-1-neg31.6%
log-rec31.6%
remove-double-neg31.6%
Simplified31.6%
Final simplification58.1%
(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 25.2%
+-commutative25.2%
hypot-1-def38.8%
Simplified38.8%
*-un-lft-identity38.8%
*-commutative38.8%
log-prod38.8%
add-sqr-sqrt3.1%
fabs-sqr3.1%
add-sqr-sqrt7.1%
metadata-eval7.1%
Applied egg-rr7.1%
+-rgt-identity7.1%
Simplified7.1%
Taylor expanded in x around 0 68.3%
if 1.55000000000000004 < x Initial program 52.3%
+-commutative52.3%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 31.6%
*-un-lft-identity31.6%
log-prod31.6%
metadata-eval31.6%
log1p-define31.6%
add-sqr-sqrt31.6%
fabs-sqr31.6%
add-sqr-sqrt31.6%
Applied egg-rr31.6%
+-lft-identity31.6%
Simplified31.6%
Final simplification58.1%
(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 32.7%
+-commutative32.7%
hypot-1-def55.7%
Simplified55.7%
*-un-lft-identity55.7%
*-commutative55.7%
log-prod55.7%
add-sqr-sqrt30.0%
fabs-sqr30.0%
add-sqr-sqrt32.9%
metadata-eval32.9%
Applied egg-rr32.9%
+-rgt-identity32.9%
Simplified32.9%
Taylor expanded in x around 0 50.8%
Final simplification50.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 2024100
(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))