
(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 -10.0)
(copysign (+ -1.0 (- 1.0 (log (* x -2.0)))) x)
(if (<= t_0 0.02)
(copysign
(*
x
(+
1.0
(*
(pow x 2.0)
(-
(* (pow x 2.0) (+ 0.075 (* (pow x 2.0) -0.044642857142857144)))
0.16666666666666666))))
x)
(copysign (+ -1.0 (- 1.0 (log (/ 0.5 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((-1.0 + (1.0 - log((x * -2.0)))), x);
} else if (t_0 <= 0.02) {
tmp = copysign((x * (1.0 + (pow(x, 2.0) * ((pow(x, 2.0) * (0.075 + (pow(x, 2.0) * -0.044642857142857144))) - 0.16666666666666666)))), x);
} else {
tmp = copysign((-1.0 + (1.0 - log((0.5 / 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((-1.0 + (1.0 - Math.log((x * -2.0)))), x);
} else if (t_0 <= 0.02) {
tmp = Math.copySign((x * (1.0 + (Math.pow(x, 2.0) * ((Math.pow(x, 2.0) * (0.075 + (Math.pow(x, 2.0) * -0.044642857142857144))) - 0.16666666666666666)))), x);
} else {
tmp = Math.copySign((-1.0 + (1.0 - Math.log((0.5 / 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((-1.0 + (1.0 - math.log((x * -2.0)))), x) elif t_0 <= 0.02: tmp = math.copysign((x * (1.0 + (math.pow(x, 2.0) * ((math.pow(x, 2.0) * (0.075 + (math.pow(x, 2.0) * -0.044642857142857144))) - 0.16666666666666666)))), x) else: tmp = math.copysign((-1.0 + (1.0 - math.log((0.5 / 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(-1.0 + Float64(1.0 - log(Float64(x * -2.0)))), x); elseif (t_0 <= 0.02) tmp = copysign(Float64(x * Float64(1.0 + Float64((x ^ 2.0) * Float64(Float64((x ^ 2.0) * Float64(0.075 + Float64((x ^ 2.0) * -0.044642857142857144))) - 0.16666666666666666)))), x); else tmp = copysign(Float64(-1.0 + Float64(1.0 - log(Float64(0.5 / 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((-1.0 + (1.0 - log((x * -2.0))))); elseif (t_0 <= 0.02) tmp = sign(x) * abs((x * (1.0 + ((x ^ 2.0) * (((x ^ 2.0) * (0.075 + ((x ^ 2.0) * -0.044642857142857144))) - 0.16666666666666666))))); else tmp = sign(x) * abs((-1.0 + (1.0 - log((0.5 / 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[(-1.0 + N[(1.0 - N[Log[N[(x * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[t$95$0, 0.02], N[With[{TMP1 = Abs[N[(x * N[(1.0 + N[(N[Power[x, 2.0], $MachinePrecision] * N[(N[(N[Power[x, 2.0], $MachinePrecision] * N[(0.075 + N[(N[Power[x, 2.0], $MachinePrecision] * -0.044642857142857144), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[(-1.0 + N[(1.0 - N[Log[N[(0.5 / x), $MachinePrecision]], $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(-1 + \left(1 - \log \left(x \cdot -2\right)\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.02:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left({x}^{2} \cdot \left(0.075 + {x}^{2} \cdot -0.044642857142857144\right) - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-1 + \left(1 - \log \left(\frac{0.5}{x}\right)\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) < -10Initial program 37.2%
+-commutative37.2%
hypot-1-def100.0%
Simplified100.0%
flip-+0.0%
div-sub0.0%
pow20.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
Applied egg-rr1.1%
div-sub1.1%
fma-undefine1.1%
unpow21.1%
associate--r+35.2%
sub-neg35.2%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
expm1-log1p-u0.0%
expm1-undefine0.0%
Applied egg-rr0.0%
sub-neg0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-undefine0.0%
rem-exp-log100.0%
metadata-eval100.0%
associate-/r*100.0%
*-commutative100.0%
log-rec100.0%
unsub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
hypot-undefine37.2%
metadata-eval37.2%
unpow237.2%
Simplified100.0%
Taylor expanded in x around -inf 100.0%
*-commutative100.0%
Simplified100.0%
if -10 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) #s(literal 1 binary64))))) x) < 0.0200000000000000004Initial program 8.8%
+-commutative8.8%
hypot-1-def8.8%
Simplified8.8%
flip-+8.7%
div-sub8.7%
pow28.7%
add-sqr-sqrt4.1%
fabs-sqr4.1%
add-sqr-sqrt8.7%
add-sqr-sqrt4.1%
fabs-sqr4.1%
add-sqr-sqrt8.3%
Applied egg-rr8.8%
div-sub8.8%
fma-undefine8.8%
unpow28.8%
associate--r+8.8%
sub-neg8.8%
+-inverses8.8%
metadata-eval8.8%
metadata-eval8.8%
Simplified8.8%
Taylor expanded in x around 0 100.0%
if 0.0200000000000000004 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) #s(literal 1 binary64))))) x) Initial program 51.6%
+-commutative51.6%
hypot-1-def98.5%
Simplified98.5%
flip-+1.5%
div-sub1.5%
pow21.5%
add-sqr-sqrt1.4%
fabs-sqr1.4%
add-sqr-sqrt1.5%
add-sqr-sqrt1.3%
fabs-sqr1.3%
add-sqr-sqrt1.5%
Applied egg-rr1.5%
div-sub1.5%
fma-undefine1.5%
unpow21.5%
associate--r+1.5%
sub-neg1.5%
+-inverses1.5%
metadata-eval1.5%
metadata-eval1.5%
Simplified1.5%
expm1-log1p-u1.5%
expm1-undefine1.5%
Applied egg-rr1.5%
sub-neg1.5%
metadata-eval1.5%
+-commutative1.5%
log1p-undefine1.5%
rem-exp-log1.5%
metadata-eval1.5%
associate-/r*1.5%
*-commutative1.5%
log-rec4.6%
unsub-neg4.6%
*-commutative4.6%
neg-mul-14.6%
sub-neg4.6%
distribute-neg-in4.6%
remove-double-neg4.6%
hypot-undefine4.6%
metadata-eval4.6%
unpow24.6%
Simplified4.6%
Taylor expanded in x around inf 98.9%
Final simplification99.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -10.0)
(copysign (+ -1.0 (- 1.0 (log (* x -2.0)))) x)
(if (<= t_0 0.02)
(copysign
(* x (+ 1.0 (* (pow x 2.0) (- (* (* x x) 0.075) 0.16666666666666666))))
x)
(copysign (+ -1.0 (- 1.0 (log (/ 0.5 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((-1.0 + (1.0 - log((x * -2.0)))), x);
} else if (t_0 <= 0.02) {
tmp = copysign((x * (1.0 + (pow(x, 2.0) * (((x * x) * 0.075) - 0.16666666666666666)))), x);
} else {
tmp = copysign((-1.0 + (1.0 - log((0.5 / 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((-1.0 + (1.0 - Math.log((x * -2.0)))), x);
} else if (t_0 <= 0.02) {
tmp = Math.copySign((x * (1.0 + (Math.pow(x, 2.0) * (((x * x) * 0.075) - 0.16666666666666666)))), x);
} else {
tmp = Math.copySign((-1.0 + (1.0 - Math.log((0.5 / 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((-1.0 + (1.0 - math.log((x * -2.0)))), x) elif t_0 <= 0.02: tmp = math.copysign((x * (1.0 + (math.pow(x, 2.0) * (((x * x) * 0.075) - 0.16666666666666666)))), x) else: tmp = math.copysign((-1.0 + (1.0 - math.log((0.5 / 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(-1.0 + Float64(1.0 - log(Float64(x * -2.0)))), x); elseif (t_0 <= 0.02) tmp = copysign(Float64(x * Float64(1.0 + Float64((x ^ 2.0) * Float64(Float64(Float64(x * x) * 0.075) - 0.16666666666666666)))), x); else tmp = copysign(Float64(-1.0 + Float64(1.0 - log(Float64(0.5 / 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((-1.0 + (1.0 - log((x * -2.0))))); elseif (t_0 <= 0.02) tmp = sign(x) * abs((x * (1.0 + ((x ^ 2.0) * (((x * x) * 0.075) - 0.16666666666666666))))); else tmp = sign(x) * abs((-1.0 + (1.0 - log((0.5 / 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[(-1.0 + N[(1.0 - N[Log[N[(x * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[t$95$0, 0.02], N[With[{TMP1 = Abs[N[(x * N[(1.0 + N[(N[Power[x, 2.0], $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * 0.075), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[(-1.0 + N[(1.0 - N[Log[N[(0.5 / x), $MachinePrecision]], $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(-1 + \left(1 - \log \left(x \cdot -2\right)\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.02:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left(\left(x \cdot x\right) \cdot 0.075 - 0.16666666666666666\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-1 + \left(1 - \log \left(\frac{0.5}{x}\right)\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) < -10Initial program 37.2%
+-commutative37.2%
hypot-1-def100.0%
Simplified100.0%
flip-+0.0%
div-sub0.0%
pow20.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
Applied egg-rr1.1%
div-sub1.1%
fma-undefine1.1%
unpow21.1%
associate--r+35.2%
sub-neg35.2%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
expm1-log1p-u0.0%
expm1-undefine0.0%
Applied egg-rr0.0%
sub-neg0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-undefine0.0%
rem-exp-log100.0%
metadata-eval100.0%
associate-/r*100.0%
*-commutative100.0%
log-rec100.0%
unsub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
hypot-undefine37.2%
metadata-eval37.2%
unpow237.2%
Simplified100.0%
Taylor expanded in x around -inf 100.0%
*-commutative100.0%
Simplified100.0%
if -10 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) #s(literal 1 binary64))))) x) < 0.0200000000000000004Initial program 8.8%
+-commutative8.8%
hypot-1-def8.8%
Simplified8.8%
flip-+8.7%
div-sub8.7%
pow28.7%
add-sqr-sqrt4.1%
fabs-sqr4.1%
add-sqr-sqrt8.7%
add-sqr-sqrt4.1%
fabs-sqr4.1%
add-sqr-sqrt8.3%
Applied egg-rr8.8%
div-sub8.8%
fma-undefine8.8%
unpow28.8%
associate--r+8.8%
sub-neg8.8%
+-inverses8.8%
metadata-eval8.8%
metadata-eval8.8%
Simplified8.8%
Taylor expanded in x around 0 99.8%
unpow299.8%
Applied egg-rr99.8%
if 0.0200000000000000004 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) #s(literal 1 binary64))))) x) Initial program 51.6%
+-commutative51.6%
hypot-1-def98.5%
Simplified98.5%
flip-+1.5%
div-sub1.5%
pow21.5%
add-sqr-sqrt1.4%
fabs-sqr1.4%
add-sqr-sqrt1.5%
add-sqr-sqrt1.3%
fabs-sqr1.3%
add-sqr-sqrt1.5%
Applied egg-rr1.5%
div-sub1.5%
fma-undefine1.5%
unpow21.5%
associate--r+1.5%
sub-neg1.5%
+-inverses1.5%
metadata-eval1.5%
metadata-eval1.5%
Simplified1.5%
expm1-log1p-u1.5%
expm1-undefine1.5%
Applied egg-rr1.5%
sub-neg1.5%
metadata-eval1.5%
+-commutative1.5%
log1p-undefine1.5%
rem-exp-log1.5%
metadata-eval1.5%
associate-/r*1.5%
*-commutative1.5%
log-rec4.6%
unsub-neg4.6%
*-commutative4.6%
neg-mul-14.6%
sub-neg4.6%
distribute-neg-in4.6%
remove-double-neg4.6%
hypot-undefine4.6%
metadata-eval4.6%
unpow24.6%
Simplified4.6%
Taylor expanded in x around inf 98.9%
Final simplification99.6%
(FPCore (x)
:precision binary64
(if (<= x -1.25)
(copysign (+ -1.0 (- 1.0 (log (* x -2.0)))) x)
(if (<= x 1.25)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (+ -1.0 (- 1.0 (log (/ 0.5 x)))) x))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = copysign((-1.0 + (1.0 - log((x * -2.0)))), x);
} else if (x <= 1.25) {
tmp = copysign((x + (-0.16666666666666666 * pow(x, 3.0))), x);
} else {
tmp = copysign((-1.0 + (1.0 - log((0.5 / x)))), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = Math.copySign((-1.0 + (1.0 - 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((-1.0 + (1.0 - Math.log((0.5 / x)))), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.25: tmp = math.copysign((-1.0 + (1.0 - 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((-1.0 + (1.0 - math.log((0.5 / x)))), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.25) tmp = copysign(Float64(-1.0 + Float64(1.0 - 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(-1.0 + Float64(1.0 - 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((-1.0 + (1.0 - log((x * -2.0))))); elseif (x <= 1.25) tmp = sign(x) * abs((x + (-0.16666666666666666 * (x ^ 3.0)))); else tmp = sign(x) * abs((-1.0 + (1.0 - log((0.5 / x))))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.25], N[With[{TMP1 = Abs[N[(-1.0 + N[(1.0 - N[Log[N[(x * -2.0), $MachinePrecision]], $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[(-1.0 + N[(1.0 - N[Log[N[(0.5 / x), $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(-1 + \left(1 - \log \left(x \cdot -2\right)\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(-1 + \left(1 - \log \left(\frac{0.5}{x}\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1.25Initial program 37.2%
+-commutative37.2%
hypot-1-def100.0%
Simplified100.0%
flip-+0.0%
div-sub0.0%
pow20.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
Applied egg-rr1.1%
div-sub1.1%
fma-undefine1.1%
unpow21.1%
associate--r+35.2%
sub-neg35.2%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
expm1-log1p-u0.0%
expm1-undefine0.0%
Applied egg-rr0.0%
sub-neg0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-undefine0.0%
rem-exp-log100.0%
metadata-eval100.0%
associate-/r*100.0%
*-commutative100.0%
log-rec100.0%
unsub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
hypot-undefine37.2%
metadata-eval37.2%
unpow237.2%
Simplified100.0%
Taylor expanded in x around -inf 100.0%
*-commutative100.0%
Simplified100.0%
if -1.25 < x < 1.25Initial program 8.8%
+-commutative8.8%
hypot-1-def8.8%
Simplified8.8%
flip-+8.7%
div-sub8.7%
pow28.7%
add-sqr-sqrt4.1%
fabs-sqr4.1%
add-sqr-sqrt8.7%
add-sqr-sqrt4.1%
fabs-sqr4.1%
add-sqr-sqrt8.3%
Applied egg-rr8.8%
div-sub8.8%
fma-undefine8.8%
unpow28.8%
associate--r+8.8%
sub-neg8.8%
+-inverses8.8%
metadata-eval8.8%
metadata-eval8.8%
Simplified8.8%
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 51.6%
+-commutative51.6%
hypot-1-def98.5%
Simplified98.5%
flip-+1.5%
div-sub1.5%
pow21.5%
add-sqr-sqrt1.4%
fabs-sqr1.4%
add-sqr-sqrt1.5%
add-sqr-sqrt1.3%
fabs-sqr1.3%
add-sqr-sqrt1.5%
Applied egg-rr1.5%
div-sub1.5%
fma-undefine1.5%
unpow21.5%
associate--r+1.5%
sub-neg1.5%
+-inverses1.5%
metadata-eval1.5%
metadata-eval1.5%
Simplified1.5%
expm1-log1p-u1.5%
expm1-undefine1.5%
Applied egg-rr1.5%
sub-neg1.5%
metadata-eval1.5%
+-commutative1.5%
log1p-undefine1.5%
rem-exp-log1.5%
metadata-eval1.5%
associate-/r*1.5%
*-commutative1.5%
log-rec4.6%
unsub-neg4.6%
*-commutative4.6%
neg-mul-14.6%
sub-neg4.6%
distribute-neg-in4.6%
remove-double-neg4.6%
hypot-undefine4.6%
metadata-eval4.6%
unpow24.6%
Simplified4.6%
Taylor expanded in x around inf 98.9%
(FPCore (x)
:precision binary64
(if (<= x -1.25)
(copysign (+ -1.0 (- 1.0 (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((-1.0 + (1.0 - 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((-1.0 + (1.0 - 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((-1.0 + (1.0 - 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(-1.0 + Float64(1.0 - 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((-1.0 + (1.0 - 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[(-1.0 + N[(1.0 - N[Log[N[(x * -2.0), $MachinePrecision]], $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[(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(-1 + \left(1 - \log \left(x \cdot -2\right)\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 37.2%
+-commutative37.2%
hypot-1-def100.0%
Simplified100.0%
flip-+0.0%
div-sub0.0%
pow20.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
Applied egg-rr1.1%
div-sub1.1%
fma-undefine1.1%
unpow21.1%
associate--r+35.2%
sub-neg35.2%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
expm1-log1p-u0.0%
expm1-undefine0.0%
Applied egg-rr0.0%
sub-neg0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-undefine0.0%
rem-exp-log100.0%
metadata-eval100.0%
associate-/r*100.0%
*-commutative100.0%
log-rec100.0%
unsub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
hypot-undefine37.2%
metadata-eval37.2%
unpow237.2%
Simplified100.0%
Taylor expanded in x around -inf 100.0%
*-commutative100.0%
Simplified100.0%
if -1.25 < x < 1.25Initial program 8.8%
+-commutative8.8%
hypot-1-def8.8%
Simplified8.8%
flip-+8.7%
div-sub8.7%
pow28.7%
add-sqr-sqrt4.1%
fabs-sqr4.1%
add-sqr-sqrt8.7%
add-sqr-sqrt4.1%
fabs-sqr4.1%
add-sqr-sqrt8.3%
Applied egg-rr8.8%
div-sub8.8%
fma-undefine8.8%
unpow28.8%
associate--r+8.8%
sub-neg8.8%
+-inverses8.8%
metadata-eval8.8%
metadata-eval8.8%
Simplified8.8%
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 51.6%
+-commutative51.6%
hypot-1-def98.5%
Simplified98.5%
Taylor expanded in x around inf 97.4%
rem-square-sqrt97.4%
fabs-sqr97.4%
rem-square-sqrt97.4%
*-inverses97.4%
metadata-eval97.4%
Simplified97.4%
(FPCore (x) :precision binary64 (if (<= x -3.15) (copysign (log (- x)) x) (if (<= x 1.25) (copysign x x) (copysign (log (* x 2.0)) x))))
double code(double x) {
double tmp;
if (x <= -3.15) {
tmp = copysign(log(-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 <= -3.15) {
tmp = Math.copySign(Math.log(-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 <= -3.15: tmp = math.copysign(math.log(-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 <= -3.15) tmp = copysign(log(Float64(-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 <= -3.15) tmp = sign(x) * abs(log(-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, -3.15], N[With[{TMP1 = Abs[N[Log[(-x)], $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 -3.15:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-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 < -3.14999999999999991Initial program 37.2%
+-commutative37.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 31.9%
mul-1-neg31.9%
Simplified31.9%
if -3.14999999999999991 < x < 1.25Initial program 8.8%
+-commutative8.8%
hypot-1-def8.8%
Simplified8.8%
flip-+8.7%
div-sub8.7%
pow28.7%
add-sqr-sqrt4.1%
fabs-sqr4.1%
add-sqr-sqrt8.7%
add-sqr-sqrt4.1%
fabs-sqr4.1%
add-sqr-sqrt8.3%
Applied egg-rr8.8%
div-sub8.8%
fma-undefine8.8%
unpow28.8%
associate--r+8.8%
sub-neg8.8%
+-inverses8.8%
metadata-eval8.8%
metadata-eval8.8%
Simplified8.8%
Taylor expanded in x around 0 99.2%
if 1.25 < x Initial program 51.6%
+-commutative51.6%
hypot-1-def98.5%
Simplified98.5%
Taylor expanded in x around inf 97.4%
rem-square-sqrt97.4%
fabs-sqr97.4%
rem-square-sqrt97.4%
*-inverses97.4%
metadata-eval97.4%
Simplified97.4%
(FPCore (x) :precision binary64 (if (<= x 0.72) (copysign (- (log1p (- x))) x) (copysign (log (* x 2.0)) x)))
double code(double x) {
double tmp;
if (x <= 0.72) {
tmp = copysign(-log1p(-x), x);
} else {
tmp = copysign(log((x * 2.0)), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 0.72) {
tmp = Math.copySign(-Math.log1p(-x), x);
} else {
tmp = Math.copySign(Math.log((x * 2.0)), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.72: tmp = math.copysign(-math.log1p(-x), x) else: tmp = math.copysign(math.log((x * 2.0)), x) return tmp
function code(x) tmp = 0.0 if (x <= 0.72) tmp = copysign(Float64(-log1p(Float64(-x))), x); else tmp = copysign(log(Float64(x * 2.0)), x); end return tmp end
code[x_] := If[LessEqual[x, 0.72], N[With[{TMP1 = Abs[(-N[Log[1 + (-x)], $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 0.72:\\
\;\;\;\;\mathsf{copysign}\left(-\mathsf{log1p}\left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < 0.71999999999999997Initial program 16.8%
+-commutative16.8%
hypot-1-def34.4%
Simplified34.4%
flip-+6.3%
div-sub6.3%
pow26.3%
add-sqr-sqrt3.0%
fabs-sqr3.0%
add-sqr-sqrt6.3%
add-sqr-sqrt3.0%
fabs-sqr3.0%
add-sqr-sqrt6.0%
Applied egg-rr6.6%
div-sub6.6%
fma-undefine6.6%
unpow26.6%
associate--r+16.2%
sub-neg16.2%
+-inverses34.4%
metadata-eval34.4%
metadata-eval34.4%
Simplified34.4%
Taylor expanded in x around 0 14.6%
Taylor expanded in x around -inf 14.6%
log-rec14.6%
neg-mul-114.6%
log1p-define79.2%
Simplified79.2%
if 0.71999999999999997 < x Initial program 51.6%
+-commutative51.6%
hypot-1-def98.5%
Simplified98.5%
Taylor expanded in x around inf 97.4%
rem-square-sqrt97.4%
fabs-sqr97.4%
rem-square-sqrt97.4%
*-inverses97.4%
metadata-eval97.4%
Simplified97.4%
(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 37.2%
+-commutative37.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 31.9%
mul-1-neg31.9%
Simplified31.9%
if -1 < x Initial program 22.3%
+-commutative22.3%
hypot-1-def37.2%
Simplified37.2%
Taylor expanded in x around 0 15.3%
log1p-define76.7%
rem-square-sqrt46.3%
fabs-sqr46.3%
rem-square-sqrt76.7%
Simplified76.7%
(FPCore (x) :precision binary64 (if (<= x -1.0) (copysign (+ -1.0 (/ 1.0 (+ x 1.0))) x) (copysign (log1p x) x)))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = copysign((-1.0 + (1.0 / (x + 1.0))), x);
} else {
tmp = copysign(log1p(x), x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = Math.copySign((-1.0 + (1.0 / (x + 1.0))), x);
} else {
tmp = Math.copySign(Math.log1p(x), x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = math.copysign((-1.0 + (1.0 / (x + 1.0))), x) else: tmp = math.copysign(math.log1p(x), x) return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = copysign(Float64(-1.0 + Float64(1.0 / Float64(x + 1.0))), x); else tmp = copysign(log1p(x), x); end return tmp end
code[x_] := If[LessEqual[x, -1.0], N[With[{TMP1 = Abs[N[(-1.0 + N[(1.0 / N[(x + 1.0), $MachinePrecision]), $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(-1 + \frac{1}{x + 1}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 37.2%
+-commutative37.2%
hypot-1-def100.0%
Simplified100.0%
flip-+0.0%
div-sub0.0%
pow20.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
Applied egg-rr1.1%
div-sub1.1%
fma-undefine1.1%
unpow21.1%
associate--r+35.2%
sub-neg35.2%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
expm1-log1p-u0.0%
expm1-undefine0.0%
Applied egg-rr0.0%
sub-neg0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-undefine0.0%
rem-exp-log100.0%
metadata-eval100.0%
associate-/r*100.0%
*-commutative100.0%
log-rec100.0%
unsub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
hypot-undefine37.2%
metadata-eval37.2%
unpow237.2%
Simplified100.0%
Taylor expanded in x around 0 4.9%
neg-mul-14.9%
Simplified4.9%
sub-neg4.9%
neg-sub04.9%
metadata-eval4.9%
associate-+r-4.9%
associate-+r-4.9%
metadata-eval4.9%
neg-sub04.9%
remove-double-neg4.9%
add-sqr-sqrt0.0%
sqrt-prod4.5%
sqr-neg4.5%
sqrt-unprod4.9%
add-sqr-sqrt4.9%
rem-exp-log4.9%
log1p-undefine4.9%
add-sqr-sqrt4.9%
sqrt-unprod4.9%
sqr-neg4.9%
sqrt-unprod0.0%
add-sqr-sqrt14.0%
exp-neg14.0%
log1p-undefine14.0%
Applied egg-rr14.0%
+-commutative14.0%
Simplified14.0%
if -1 < x Initial program 22.3%
+-commutative22.3%
hypot-1-def37.2%
Simplified37.2%
Taylor expanded in x around 0 15.3%
log1p-define76.7%
rem-square-sqrt46.3%
fabs-sqr46.3%
rem-square-sqrt76.7%
Simplified76.7%
(FPCore (x) :precision binary64 (if (or (<= x -2.0) (not (<= x 8.0))) (copysign (+ -1.0 (/ 1.0 (+ x 1.0))) x) (copysign x x)))
double code(double x) {
double tmp;
if ((x <= -2.0) || !(x <= 8.0)) {
tmp = copysign((-1.0 + (1.0 / (x + 1.0))), x);
} else {
tmp = copysign(x, x);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x <= -2.0) || !(x <= 8.0)) {
tmp = Math.copySign((-1.0 + (1.0 / (x + 1.0))), x);
} else {
tmp = Math.copySign(x, x);
}
return tmp;
}
def code(x): tmp = 0 if (x <= -2.0) or not (x <= 8.0): tmp = math.copysign((-1.0 + (1.0 / (x + 1.0))), x) else: tmp = math.copysign(x, x) return tmp
function code(x) tmp = 0.0 if ((x <= -2.0) || !(x <= 8.0)) tmp = copysign(Float64(-1.0 + Float64(1.0 / Float64(x + 1.0))), x); else tmp = copysign(x, x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -2.0) || ~((x <= 8.0))) tmp = sign(x) * abs((-1.0 + (1.0 / (x + 1.0)))); else tmp = sign(x) * abs(x); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -2.0], N[Not[LessEqual[x, 8.0]], $MachinePrecision]], N[With[{TMP1 = Abs[N[(-1.0 + N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], 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 -2 \lor \neg \left(x \leq 8\right):\\
\;\;\;\;\mathsf{copysign}\left(-1 + \frac{1}{x + 1}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\end{array}
\end{array}
if x < -2 or 8 < x Initial program 44.5%
+-commutative44.5%
hypot-1-def99.2%
Simplified99.2%
flip-+0.0%
div-sub0.0%
pow20.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.0%
Applied egg-rr0.5%
div-sub0.5%
fma-undefine0.5%
unpow20.5%
associate--r+16.2%
sub-neg16.2%
+-inverses46.2%
metadata-eval46.2%
metadata-eval46.2%
Simplified46.2%
expm1-log1p-u0.0%
expm1-undefine0.0%
Applied egg-rr0.0%
sub-neg0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-undefine0.0%
rem-exp-log46.2%
metadata-eval46.2%
associate-/r*46.2%
*-commutative46.2%
log-rec47.8%
unsub-neg47.8%
*-commutative47.8%
neg-mul-147.8%
sub-neg47.8%
distribute-neg-in47.8%
remove-double-neg47.8%
hypot-undefine18.9%
metadata-eval18.9%
unpow218.9%
Simplified47.8%
Taylor expanded in x around 0 5.2%
neg-mul-15.2%
Simplified5.2%
sub-neg5.2%
neg-sub05.2%
metadata-eval5.2%
associate-+r-5.2%
associate-+r-5.2%
metadata-eval5.2%
neg-sub05.2%
remove-double-neg5.2%
add-sqr-sqrt2.9%
sqrt-prod4.8%
sqr-neg4.8%
sqrt-unprod2.3%
add-sqr-sqrt5.2%
rem-exp-log2.3%
log1p-undefine2.3%
add-sqr-sqrt2.3%
sqrt-unprod2.3%
sqr-neg2.3%
sqrt-unprod0.0%
add-sqr-sqrt6.5%
exp-neg6.5%
log1p-undefine6.5%
Applied egg-rr14.0%
+-commutative14.0%
Simplified14.0%
if -2 < x < 8Initial program 9.4%
+-commutative9.4%
hypot-1-def9.4%
Simplified9.4%
flip-+9.4%
div-sub9.4%
pow29.4%
add-sqr-sqrt4.8%
fabs-sqr4.8%
add-sqr-sqrt9.4%
add-sqr-sqrt4.7%
fabs-sqr4.7%
add-sqr-sqrt9.0%
Applied egg-rr9.4%
div-sub9.4%
fma-undefine9.4%
unpow29.4%
associate--r+9.4%
sub-neg9.4%
+-inverses9.4%
metadata-eval9.4%
metadata-eval9.4%
Simplified9.4%
Taylor expanded in x around 0 98.6%
Final simplification60.0%
(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 25.5%
+-commutative25.5%
hypot-1-def50.4%
Simplified50.4%
flip-+5.1%
div-sub5.1%
pow25.1%
add-sqr-sqrt2.6%
fabs-sqr2.6%
add-sqr-sqrt5.1%
add-sqr-sqrt2.6%
fabs-sqr2.6%
add-sqr-sqrt4.9%
Applied egg-rr5.3%
div-sub5.3%
fma-undefine5.3%
unpow25.3%
associate--r+12.5%
sub-neg12.5%
+-inverses26.2%
metadata-eval26.2%
metadata-eval26.2%
Simplified26.2%
Taylor expanded in x around 0 55.9%
(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 2024132
(FPCore (x)
:name "Rust f64::asinh"
:precision binary64
:alt
(! :herbie-platform default (let* ((ax (fabs x)) (ix (/ 1 ax))) (copysign (log1p (+ ax (/ ax (+ (hypot 1 ix) ix)))) x)))
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))