
(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 11 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.4)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.0005)
(copysign
(+ x (+ (* -0.16666666666666666 (pow x 3.0)) (* 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 <= -0.4) {
tmp = copysign(-log((hypot(1.0, x) - x)), x);
} else if (t_0 <= 0.0005) {
tmp = copysign((x + ((-0.16666666666666666 * pow(x, 3.0)) + (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 <= -0.4) {
tmp = Math.copySign(-Math.log((Math.hypot(1.0, x) - x)), x);
} else if (t_0 <= 0.0005) {
tmp = Math.copySign((x + ((-0.16666666666666666 * Math.pow(x, 3.0)) + (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 <= -0.4: tmp = math.copysign(-math.log((math.hypot(1.0, x) - x)), x) elif t_0 <= 0.0005: tmp = math.copysign((x + ((-0.16666666666666666 * math.pow(x, 3.0)) + (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 <= -0.4) tmp = copysign(Float64(-log(Float64(hypot(1.0, x) - x))), x); elseif (t_0 <= 0.0005) tmp = copysign(Float64(x + Float64(Float64(-0.16666666666666666 * (x ^ 3.0)) + 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 <= -0.4) tmp = sign(x) * abs(-log((hypot(1.0, x) - x))); elseif (t_0 <= 0.0005) tmp = sign(x) * abs((x + ((-0.16666666666666666 * (x ^ 3.0)) + (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, -0.4], 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, 0.0005], N[With[{TMP1 = Abs[N[(x + N[(N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + 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 -0.4:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.0005:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(-0.16666666666666666 \cdot {x}^{3} + 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) < -0.40000000000000002Initial program 58.7%
+-commutative58.7%
hypot-1-def100.0%
Simplified100.0%
flip-+3.3%
frac-2neg3.3%
log-div3.3%
Applied egg-rr6.5%
fma-udef6.5%
unpow26.5%
associate--r+57.4%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
if -0.40000000000000002 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < 5.0000000000000001e-4Initial program 7.6%
+-commutative7.6%
hypot-1-def7.6%
Simplified7.6%
*-un-lft-identity7.6%
*-commutative7.6%
log-prod7.6%
*-un-lft-identity7.6%
*-un-lft-identity7.6%
add-sqr-sqrt4.8%
fabs-sqr4.8%
add-sqr-sqrt7.6%
metadata-eval7.6%
Applied egg-rr7.6%
+-rgt-identity7.6%
Simplified7.6%
Taylor expanded in x around 0 100.0%
if 5.0000000000000001e-4 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) Initial program 53.7%
+-commutative53.7%
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 (/ -0.5 x)) x)
(if (<= x 0.00095)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) 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.00095) {
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 tmp;
if (x <= -1.25) {
tmp = Math.copySign(Math.log((-0.5 / x)), x);
} else if (x <= 0.00095) {
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): tmp = 0 if x <= -1.25: tmp = math.copysign(math.log((-0.5 / x)), x) elif x <= 0.00095: 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) tmp = 0.0 if (x <= -1.25) tmp = copysign(log(Float64(-0.5 / x)), x); elseif (x <= 0.00095) 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) tmp = 0.0; if (x <= -1.25) tmp = sign(x) * abs(log((-0.5 / x))); elseif (x <= 0.00095) 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_] := 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.00095], 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}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.00095:\\
\;\;\;\;\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 x < -1.25Initial program 58.0%
+-commutative58.0%
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-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt4.6%
metadata-eval4.6%
Applied egg-rr4.6%
+-rgt-identity4.6%
Simplified4.6%
Taylor expanded in x around -inf 99.5%
if -1.25 < x < 9.49999999999999998e-4Initial program 8.3%
+-commutative8.3%
hypot-1-def8.3%
Simplified8.3%
*-un-lft-identity8.3%
*-commutative8.3%
log-prod8.3%
*-un-lft-identity8.3%
*-un-lft-identity8.3%
add-sqr-sqrt4.8%
fabs-sqr4.8%
add-sqr-sqrt8.3%
metadata-eval8.3%
Applied egg-rr8.3%
+-rgt-identity8.3%
Simplified8.3%
Taylor expanded in x around 0 99.4%
if 9.49999999999999998e-4 < x Initial program 53.7%
+-commutative53.7%
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 simplification99.6%
(FPCore (x)
:precision binary64
(if (<= x -0.00077)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.00095)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
double code(double x) {
double tmp;
if (x <= -0.00077) {
tmp = copysign(-log((hypot(1.0, x) - x)), x);
} else if (x <= 0.00095) {
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 tmp;
if (x <= -0.00077) {
tmp = Math.copySign(-Math.log((Math.hypot(1.0, x) - x)), x);
} else if (x <= 0.00095) {
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): tmp = 0 if x <= -0.00077: tmp = math.copysign(-math.log((math.hypot(1.0, x) - x)), x) elif x <= 0.00095: 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) tmp = 0.0 if (x <= -0.00077) tmp = copysign(Float64(-log(Float64(hypot(1.0, x) - x))), x); elseif (x <= 0.00095) 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) tmp = 0.0; if (x <= -0.00077) tmp = sign(x) * abs(-log((hypot(1.0, x) - x))); elseif (x <= 0.00095) 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_] := If[LessEqual[x, -0.00077], 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[x, 0.00095], 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}
\mathbf{if}\;x \leq -0.00077:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.00095:\\
\;\;\;\;\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 x < -7.6999999999999996e-4Initial program 58.7%
+-commutative58.7%
hypot-1-def100.0%
Simplified100.0%
flip-+3.3%
frac-2neg3.3%
log-div3.3%
Applied egg-rr6.5%
fma-udef6.5%
unpow26.5%
associate--r+57.4%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
if -7.6999999999999996e-4 < x < 9.49999999999999998e-4Initial program 7.6%
+-commutative7.6%
hypot-1-def7.6%
Simplified7.6%
*-un-lft-identity7.6%
*-commutative7.6%
log-prod7.6%
*-un-lft-identity7.6%
*-un-lft-identity7.6%
add-sqr-sqrt4.8%
fabs-sqr4.8%
add-sqr-sqrt7.6%
metadata-eval7.6%
Applied egg-rr7.6%
+-rgt-identity7.6%
Simplified7.6%
Taylor expanded in x around 0 99.9%
if 9.49999999999999998e-4 < x Initial program 53.7%
+-commutative53.7%
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 (/ -0.5 x)) x)
(if (<= x 0.96)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ (+ x x) (/ 0.5 x))) x))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = copysign(log((-0.5 / x)), x);
} else if (x <= 0.96) {
tmp = copysign((x + (-0.16666666666666666 * pow(x, 3.0))), x);
} else {
tmp = copysign(log(((x + x) + (0.5 / 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.96) {
tmp = Math.copySign((x + (-0.16666666666666666 * Math.pow(x, 3.0))), x);
} else {
tmp = Math.copySign(Math.log(((x + x) + (0.5 / 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.96: tmp = math.copysign((x + (-0.16666666666666666 * math.pow(x, 3.0))), x) else: tmp = math.copysign(math.log(((x + x) + (0.5 / 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.96) tmp = copysign(Float64(x + Float64(-0.16666666666666666 * (x ^ 3.0))), x); else tmp = copysign(log(Float64(Float64(x + x) + 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((-0.5 / x))); elseif (x <= 0.96) tmp = sign(x) * abs((x + (-0.16666666666666666 * (x ^ 3.0)))); else tmp = sign(x) * abs(log(((x + x) + (0.5 / 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.96], 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[(N[(x + x), $MachinePrecision] + N[(0.5 / x), $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.96:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(x + x\right) + \frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 58.0%
+-commutative58.0%
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-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt4.6%
metadata-eval4.6%
Applied egg-rr4.6%
+-rgt-identity4.6%
Simplified4.6%
Taylor expanded in x around -inf 99.5%
if -1.25 < x < 0.95999999999999996Initial program 8.3%
+-commutative8.3%
hypot-1-def8.3%
Simplified8.3%
*-un-lft-identity8.3%
*-commutative8.3%
log-prod8.3%
*-un-lft-identity8.3%
*-un-lft-identity8.3%
add-sqr-sqrt4.8%
fabs-sqr4.8%
add-sqr-sqrt8.3%
metadata-eval8.3%
Applied egg-rr8.3%
+-rgt-identity8.3%
Simplified8.3%
Taylor expanded in x around 0 99.4%
if 0.95999999999999996 < x Initial program 53.7%
+-commutative53.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 99.2%
rem-square-sqrt99.2%
fabs-sqr99.2%
rem-square-sqrt99.2%
associate-+r+99.2%
associate-*r/99.2%
metadata-eval99.2%
Simplified99.2%
Final simplification99.4%
(FPCore (x)
:precision binary64
(if (<= x -1.25)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.3)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x x)) 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 + (-0.16666666666666666 * pow(x, 3.0))), x);
} else {
tmp = copysign(log((x + 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 <= 1.3) {
tmp = Math.copySign((x + (-0.16666666666666666 * Math.pow(x, 3.0))), x);
} else {
tmp = Math.copySign(Math.log((x + x)), 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 + (-0.16666666666666666 * math.pow(x, 3.0))), x) else: tmp = math.copysign(math.log((x + x)), 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(-0.16666666666666666 * (x ^ 3.0))), x); else tmp = copysign(log(Float64(x + 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 <= 1.3) tmp = sign(x) * abs((x + (-0.16666666666666666 * (x ^ 3.0)))); else tmp = sign(x) * abs(log((x + 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, 1.3], 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 + 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(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1.3:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 58.0%
+-commutative58.0%
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-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt4.6%
metadata-eval4.6%
Applied egg-rr4.6%
+-rgt-identity4.6%
Simplified4.6%
Taylor expanded in x around -inf 99.5%
if -1.25 < x < 1.30000000000000004Initial program 8.3%
+-commutative8.3%
hypot-1-def8.3%
Simplified8.3%
*-un-lft-identity8.3%
*-commutative8.3%
log-prod8.3%
*-un-lft-identity8.3%
*-un-lft-identity8.3%
add-sqr-sqrt4.8%
fabs-sqr4.8%
add-sqr-sqrt8.3%
metadata-eval8.3%
Applied egg-rr8.3%
+-rgt-identity8.3%
Simplified8.3%
Taylor expanded in x around 0 99.4%
if 1.30000000000000004 < x Initial program 53.7%
+-commutative53.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.7%
rem-square-sqrt98.7%
fabs-sqr98.7%
rem-square-sqrt98.7%
Simplified98.7%
Final simplification99.2%
(FPCore (x) :precision binary64 (if (<= x -3.2) (copysign (log (- x)) x) (if (<= x 1.3) (copysign x x) (copysign (log (+ x x)) x))))
double code(double x) {
double tmp;
if (x <= -3.2) {
tmp = copysign(log(-x), x);
} else if (x <= 1.3) {
tmp = copysign(x, x);
} else {
tmp = copysign(log((x + x)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -3.2) {
tmp = Math.copySign(Math.log(-x), x);
} else if (x <= 1.3) {
tmp = Math.copySign(x, x);
} else {
tmp = Math.copySign(Math.log((x + x)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -3.2: tmp = math.copysign(math.log(-x), x) elif x <= 1.3: tmp = math.copysign(x, x) else: tmp = math.copysign(math.log((x + x)), x) return tmp
function code(x) tmp = 0.0 if (x <= -3.2) tmp = copysign(log(Float64(-x)), x); elseif (x <= 1.3) tmp = copysign(x, x); else tmp = copysign(log(Float64(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -3.2) tmp = sign(x) * abs(log(-x)); elseif (x <= 1.3) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -3.2], N[With[{TMP1 = Abs[N[Log[(-x)], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 1.3], N[With[{TMP1 = Abs[x], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[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 -3.2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 1.3:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -3.2000000000000002Initial program 58.0%
+-commutative58.0%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 30.9%
mul-1-neg30.9%
Simplified30.9%
if -3.2000000000000002 < x < 1.30000000000000004Initial program 8.3%
+-commutative8.3%
hypot-1-def8.3%
Simplified8.3%
*-un-lft-identity8.3%
*-commutative8.3%
log-prod8.3%
*-un-lft-identity8.3%
*-un-lft-identity8.3%
add-sqr-sqrt4.8%
fabs-sqr4.8%
add-sqr-sqrt8.3%
metadata-eval8.3%
Applied egg-rr8.3%
+-rgt-identity8.3%
Simplified8.3%
Taylor expanded in x around 0 99.1%
if 1.30000000000000004 < x Initial program 53.7%
+-commutative53.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.7%
rem-square-sqrt98.7%
fabs-sqr98.7%
rem-square-sqrt98.7%
Simplified98.7%
Final simplification83.0%
(FPCore (x) :precision binary64 (if (<= x -1.25) (copysign (log (/ -0.5 x)) x) (if (<= x 1.3) (copysign x x) (copysign (log (+ x x)) 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, x);
} else {
tmp = copysign(log((x + 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 <= 1.3) {
tmp = Math.copySign(x, x);
} else {
tmp = Math.copySign(Math.log((x + x)), 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, x) else: tmp = math.copysign(math.log((x + x)), 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(x, x); else tmp = copysign(log(Float64(x + 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 <= 1.3) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + 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, 1.3], N[With[{TMP1 = Abs[x], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[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 -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\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 58.0%
+-commutative58.0%
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-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt4.6%
metadata-eval4.6%
Applied egg-rr4.6%
+-rgt-identity4.6%
Simplified4.6%
Taylor expanded in x around -inf 99.5%
if -1.25 < x < 1.30000000000000004Initial program 8.3%
+-commutative8.3%
hypot-1-def8.3%
Simplified8.3%
*-un-lft-identity8.3%
*-commutative8.3%
log-prod8.3%
*-un-lft-identity8.3%
*-un-lft-identity8.3%
add-sqr-sqrt4.8%
fabs-sqr4.8%
add-sqr-sqrt8.3%
metadata-eval8.3%
Applied egg-rr8.3%
+-rgt-identity8.3%
Simplified8.3%
Taylor expanded in x around 0 99.1%
if 1.30000000000000004 < x Initial program 53.7%
+-commutative53.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.7%
rem-square-sqrt98.7%
fabs-sqr98.7%
rem-square-sqrt98.7%
Simplified98.7%
Final simplification99.1%
(FPCore (x) :precision binary64 (if (<= x -1.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = copysign(log(-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(-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(-x), x) else: tmp = math.copysign(math.log1p(x), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = copysign(log(Float64(-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[(-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 -1:\\
\;\;\;\;\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 < -1Initial program 58.0%
+-commutative58.0%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 30.9%
mul-1-neg30.9%
Simplified30.9%
if -1 < x Initial program 23.9%
+-commutative23.9%
hypot-1-def39.7%
Simplified39.7%
Taylor expanded in x around 0 15.6%
log1p-def75.4%
rem-square-sqrt43.4%
fabs-sqr43.4%
rem-square-sqrt75.4%
Simplified75.4%
Final simplification64.9%
(FPCore (x) :precision binary64 (if (<= x -0.95) (copysign 0.2345679012345679 x) (copysign (log1p x) x)))
double code(double x) {
double tmp;
if (x <= -0.95) {
tmp = copysign(0.2345679012345679, x);
} else {
tmp = copysign(log1p(x), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -0.95) {
tmp = Math.copySign(0.2345679012345679, x);
} else {
tmp = Math.copySign(Math.log1p(x), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.95: tmp = math.copysign(0.2345679012345679, x) else: tmp = math.copysign(math.log1p(x), x) return tmp
function code(x) tmp = 0.0 if (x <= -0.95) tmp = copysign(0.2345679012345679, x); else tmp = copysign(log1p(x), x); end return tmp end
code[x_] := If[LessEqual[x, -0.95], N[With[{TMP1 = Abs[0.2345679012345679], 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.95:\\
\;\;\;\;\mathsf{copysign}\left(0.2345679012345679, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -0.94999999999999996Initial program 58.0%
+-commutative58.0%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 30.9%
add-cbrt-cube30.9%
pow1/330.9%
pow330.9%
log1p-def30.9%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
Applied egg-rr0.0%
Taylor expanded in x around inf 0.0%
Simplified13.6%
if -0.94999999999999996 < x Initial program 23.9%
+-commutative23.9%
hypot-1-def39.7%
Simplified39.7%
Taylor expanded in x around 0 15.6%
log1p-def75.4%
rem-square-sqrt43.4%
fabs-sqr43.4%
rem-square-sqrt75.4%
Simplified75.4%
Final simplification60.9%
(FPCore (x) :precision binary64 (if (or (<= x -118.0) (not (<= x 120.0))) (copysign 0.2345679012345679 x) (copysign x x)))
double code(double x) {
double tmp;
if ((x <= -118.0) || !(x <= 120.0)) {
tmp = copysign(0.2345679012345679, x);
} else {
tmp = copysign(x, x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -118.0) || !(x <= 120.0)) {
tmp = Math.copySign(0.2345679012345679, x);
} else {
tmp = Math.copySign(x, x);
}
return tmp;
}
def code(x): tmp = 0 if (x <= -118.0) or not (x <= 120.0): tmp = math.copysign(0.2345679012345679, x) else: tmp = math.copysign(x, x) return tmp
function code(x) tmp = 0.0 if ((x <= -118.0) || !(x <= 120.0)) tmp = copysign(0.2345679012345679, x); else tmp = copysign(x, x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -118.0) || ~((x <= 120.0))) tmp = sign(x) * abs(0.2345679012345679); else tmp = sign(x) * abs(x); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -118.0], N[Not[LessEqual[x, 120.0]], $MachinePrecision]], N[With[{TMP1 = Abs[0.2345679012345679], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[x], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -118 \lor \neg \left(x \leq 120\right):\\
\;\;\;\;\mathsf{copysign}\left(0.2345679012345679, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\end{array}
\end{array}
if x < -118 or 120 < x Initial program 55.4%
+-commutative55.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 31.2%
add-cbrt-cube31.2%
pow1/331.2%
pow331.2%
log1p-def31.2%
add-sqr-sqrt16.5%
fabs-sqr16.5%
add-sqr-sqrt16.5%
Applied egg-rr16.5%
Taylor expanded in x around inf 16.5%
Simplified13.6%
if -118 < x < 120Initial program 9.0%
+-commutative9.0%
hypot-1-def9.0%
Simplified9.0%
*-un-lft-identity9.0%
*-commutative9.0%
log-prod9.0%
*-un-lft-identity9.0%
*-un-lft-identity9.0%
add-sqr-sqrt5.5%
fabs-sqr5.5%
add-sqr-sqrt9.0%
metadata-eval9.0%
Applied egg-rr9.0%
+-rgt-identity9.0%
Simplified9.0%
Taylor expanded in x around 0 98.5%
Final simplification56.7%
(FPCore (x) :precision binary64 (copysign 0.2345679012345679 x))
double code(double x) {
return copysign(0.2345679012345679, x);
}
public static double code(double x) {
return Math.copySign(0.2345679012345679, x);
}
def code(x): return math.copysign(0.2345679012345679, x)
function code(x) return copysign(0.2345679012345679, x) end
function tmp = code(x) tmp = sign(x) * abs(0.2345679012345679); end
code[x_] := N[With[{TMP1 = Abs[0.2345679012345679], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{copysign}\left(0.2345679012345679, x\right)
\end{array}
Initial program 31.9%
+-commutative31.9%
hypot-1-def53.8%
Simplified53.8%
Taylor expanded in x around 0 19.2%
add-cbrt-cube19.2%
pow1/319.2%
pow319.2%
log1p-def32.2%
add-sqr-sqrt17.4%
fabs-sqr17.4%
add-sqr-sqrt18.5%
Applied egg-rr18.5%
Taylor expanded in x around inf 8.2%
Simplified9.4%
Final simplification9.4%
(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 2024024
(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))