?

Average Error: 45.4 → 28.8
Time: 6.3s
Precision: binary64
Cost: 152200

?

\[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
\[\begin{array}{l} t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\ t_1 := 1 + \left|x\right|\\ t_2 := \frac{-1}{-1 - \left|x\right|} + \frac{1}{{t_1}^{2}}\\ \mathbf{if}\;t_0 \leq -2:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left(-x\right) + \left|x\right|\right) - 0.5 \cdot \frac{1}{x}\right), x\right)\\ \mathbf{elif}\;t_0 \leq 0.002:\\ \;\;\;\;\mathsf{copysign}\left(\log t_1 + \left({x}^{4} \cdot \left(t_2 \cdot -0.125\right) + \left(0.5 \cdot \frac{{x}^{2}}{t_1} + {x}^{6} \cdot \left(0.001388888888888889 \cdot \left(30 \cdot \frac{1}{{t_1}^{3}} + 45 \cdot t_2\right)\right)\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + x\right), x\right)\\ \end{array} \]
(FPCore (x)
 :precision binary64
 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
        (t_1 (+ 1.0 (fabs x)))
        (t_2 (+ (/ -1.0 (- -1.0 (fabs x))) (/ 1.0 (pow t_1 2.0)))))
   (if (<= t_0 -2.0)
     (copysign (log (- (+ (- x) (fabs x)) (* 0.5 (/ 1.0 x)))) x)
     (if (<= t_0 0.002)
       (copysign
        (+
         (log t_1)
         (+
          (* (pow x 4.0) (* t_2 -0.125))
          (+
           (* 0.5 (/ (pow x 2.0) t_1))
           (*
            (pow x 6.0)
            (*
             0.001388888888888889
             (+ (* 30.0 (/ 1.0 (pow t_1 3.0))) (* 45.0 t_2)))))))
        x)
       (copysign (log (+ (fabs x) x)) x)))))
double code(double x) {
	return copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x);
}
double code(double x) {
	double t_0 = copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x);
	double t_1 = 1.0 + fabs(x);
	double t_2 = (-1.0 / (-1.0 - fabs(x))) + (1.0 / pow(t_1, 2.0));
	double tmp;
	if (t_0 <= -2.0) {
		tmp = copysign(log(((-x + fabs(x)) - (0.5 * (1.0 / x)))), x);
	} else if (t_0 <= 0.002) {
		tmp = copysign((log(t_1) + ((pow(x, 4.0) * (t_2 * -0.125)) + ((0.5 * (pow(x, 2.0) / t_1)) + (pow(x, 6.0) * (0.001388888888888889 * ((30.0 * (1.0 / pow(t_1, 3.0))) + (45.0 * t_2))))))), x);
	} else {
		tmp = copysign(log((fabs(x) + x)), x);
	}
	return tmp;
}
public static double code(double x) {
	return Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x);
}
public static double code(double x) {
	double t_0 = Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x);
	double t_1 = 1.0 + Math.abs(x);
	double t_2 = (-1.0 / (-1.0 - Math.abs(x))) + (1.0 / Math.pow(t_1, 2.0));
	double tmp;
	if (t_0 <= -2.0) {
		tmp = Math.copySign(Math.log(((-x + Math.abs(x)) - (0.5 * (1.0 / x)))), x);
	} else if (t_0 <= 0.002) {
		tmp = Math.copySign((Math.log(t_1) + ((Math.pow(x, 4.0) * (t_2 * -0.125)) + ((0.5 * (Math.pow(x, 2.0) / t_1)) + (Math.pow(x, 6.0) * (0.001388888888888889 * ((30.0 * (1.0 / Math.pow(t_1, 3.0))) + (45.0 * t_2))))))), x);
	} else {
		tmp = Math.copySign(Math.log((Math.abs(x) + x)), x);
	}
	return tmp;
}
def code(x):
	return math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x)
def code(x):
	t_0 = math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x)
	t_1 = 1.0 + math.fabs(x)
	t_2 = (-1.0 / (-1.0 - math.fabs(x))) + (1.0 / math.pow(t_1, 2.0))
	tmp = 0
	if t_0 <= -2.0:
		tmp = math.copysign(math.log(((-x + math.fabs(x)) - (0.5 * (1.0 / x)))), x)
	elif t_0 <= 0.002:
		tmp = math.copysign((math.log(t_1) + ((math.pow(x, 4.0) * (t_2 * -0.125)) + ((0.5 * (math.pow(x, 2.0) / t_1)) + (math.pow(x, 6.0) * (0.001388888888888889 * ((30.0 * (1.0 / math.pow(t_1, 3.0))) + (45.0 * t_2))))))), x)
	else:
		tmp = math.copysign(math.log((math.fabs(x) + x)), x)
	return tmp
function code(x)
	return copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x)
end
function code(x)
	t_0 = copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x)
	t_1 = Float64(1.0 + abs(x))
	t_2 = Float64(Float64(-1.0 / Float64(-1.0 - abs(x))) + Float64(1.0 / (t_1 ^ 2.0)))
	tmp = 0.0
	if (t_0 <= -2.0)
		tmp = copysign(log(Float64(Float64(Float64(-x) + abs(x)) - Float64(0.5 * Float64(1.0 / x)))), x);
	elseif (t_0 <= 0.002)
		tmp = copysign(Float64(log(t_1) + Float64(Float64((x ^ 4.0) * Float64(t_2 * -0.125)) + Float64(Float64(0.5 * Float64((x ^ 2.0) / t_1)) + Float64((x ^ 6.0) * Float64(0.001388888888888889 * Float64(Float64(30.0 * Float64(1.0 / (t_1 ^ 3.0))) + Float64(45.0 * t_2))))))), x);
	else
		tmp = copysign(log(Float64(abs(x) + x)), x);
	end
	return tmp
end
function tmp = code(x)
	tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + 1.0)))));
end
function tmp_2 = code(x)
	t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + 1.0)))));
	t_1 = 1.0 + abs(x);
	t_2 = (-1.0 / (-1.0 - abs(x))) + (1.0 / (t_1 ^ 2.0));
	tmp = 0.0;
	if (t_0 <= -2.0)
		tmp = sign(x) * abs(log(((-x + abs(x)) - (0.5 * (1.0 / x)))));
	elseif (t_0 <= 0.002)
		tmp = sign(x) * abs((log(t_1) + (((x ^ 4.0) * (t_2 * -0.125)) + ((0.5 * ((x ^ 2.0) / t_1)) + ((x ^ 6.0) * (0.001388888888888889 * ((30.0 * (1.0 / (t_1 ^ 3.0))) + (45.0 * t_2))))))));
	else
		tmp = sign(x) * abs(log((abs(x) + x)));
	end
	tmp_2 = tmp;
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]
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]}, Block[{t$95$1 = N[(1.0 + N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(-1.0 / N[(-1.0 - N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2.0], N[With[{TMP1 = Abs[N[Log[N[(N[((-x) + N[Abs[x], $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[t$95$0, 0.002], N[With[{TMP1 = Abs[N[(N[Log[t$95$1], $MachinePrecision] + N[(N[(N[Power[x, 4.0], $MachinePrecision] * N[(t$95$2 * -0.125), $MachinePrecision]), $MachinePrecision] + N[(N[(0.5 * N[(N[Power[x, 2.0], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 6.0], $MachinePrecision] * N[(0.001388888888888889 * N[(N[(30.0 * N[(1.0 / N[Power[t$95$1, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(45.0 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(N[Abs[x], $MachinePrecision] + x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]]]]
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
t_1 := 1 + \left|x\right|\\
t_2 := \frac{-1}{-1 - \left|x\right|} + \frac{1}{{t_1}^{2}}\\
\mathbf{if}\;t_0 \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left(-x\right) + \left|x\right|\right) - 0.5 \cdot \frac{1}{x}\right), x\right)\\

\mathbf{elif}\;t_0 \leq 0.002:\\
\;\;\;\;\mathsf{copysign}\left(\log t_1 + \left({x}^{4} \cdot \left(t_2 \cdot -0.125\right) + \left(0.5 \cdot \frac{{x}^{2}}{t_1} + {x}^{6} \cdot \left(0.001388888888888889 \cdot \left(30 \cdot \frac{1}{{t_1}^{3}} + 45 \cdot t_2\right)\right)\right)\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + x\right), x\right)\\


\end{array}

Error?

Target

Original45.4
Target0.0
Herbie28.8
\[\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right| + \frac{\left|x\right|}{\mathsf{hypot}\left(1, \frac{1}{\left|x\right|}\right) + \frac{1}{\left|x\right|}}\right), x\right) \]

Derivation?

  1. Split input into 3 regimes
  2. if (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < -2

    1. Initial program 32.8

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Taylor expanded in x around -inf 0.1

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(\left|x\right| + -1 \cdot x\right) - 0.5 \cdot \frac{1}{x}\right)}, x\right) \]
    3. Simplified0.1

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(\left(-x\right) + \left|x\right|\right) - 0.5 \cdot \frac{1}{x}\right)}, x\right) \]
      Proof

      [Start]0.1

      \[ \mathsf{copysign}\left(\log \left(\left(\left|x\right| + -1 \cdot x\right) - 0.5 \cdot \frac{1}{x}\right), x\right) \]

      rational.json-simplify-1 [=>]0.1

      \[ \mathsf{copysign}\left(\log \left(\color{blue}{\left(-1 \cdot x + \left|x\right|\right)} - 0.5 \cdot \frac{1}{x}\right), x\right) \]

      rational.json-simplify-2 [=>]0.1

      \[ \mathsf{copysign}\left(\log \left(\left(\color{blue}{x \cdot -1} + \left|x\right|\right) - 0.5 \cdot \frac{1}{x}\right), x\right) \]

      rational.json-simplify-9 [=>]0.1

      \[ \mathsf{copysign}\left(\log \left(\left(\color{blue}{\left(-x\right)} + \left|x\right|\right) - 0.5 \cdot \frac{1}{x}\right), x\right) \]

    if -2 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < 2e-3

    1. Initial program 58.9

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Taylor expanded in x around 0 58.3

      \[\leadsto \mathsf{copysign}\left(\color{blue}{-0.041666666666666664 \cdot \left(\left(3 \cdot \frac{1}{1 + \left|x\right|} + 3 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{2}}\right) \cdot {x}^{4}\right) + \left(0.001388888888888889 \cdot \left(\left(45 \cdot \frac{1}{1 + \left|x\right|} + \left(30 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{3}} + 45 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{2}}\right)\right) \cdot {x}^{6}\right) + \left(0.5 \cdot \frac{{x}^{2}}{1 + \left|x\right|} + \log \left(1 + \left|x\right|\right)\right)\right)}, x\right) \]
    3. Simplified58.3

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(1 + \left|x\right|\right) + \left({x}^{4} \cdot \left(\left(\frac{-1}{-1 - \left|x\right|} + \frac{1}{{\left(1 + \left|x\right|\right)}^{2}}\right) \cdot -0.125\right) + \left(0.5 \cdot \frac{{x}^{2}}{1 + \left|x\right|} + {x}^{6} \cdot \left(0.001388888888888889 \cdot \left(30 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{3}} + 45 \cdot \left(\frac{-1}{-1 - \left|x\right|} + \frac{1}{{\left(1 + \left|x\right|\right)}^{2}}\right)\right)\right)\right)\right)}, x\right) \]
      Proof

      [Start]58.3

      \[ \mathsf{copysign}\left(-0.041666666666666664 \cdot \left(\left(3 \cdot \frac{1}{1 + \left|x\right|} + 3 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{2}}\right) \cdot {x}^{4}\right) + \left(0.001388888888888889 \cdot \left(\left(45 \cdot \frac{1}{1 + \left|x\right|} + \left(30 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{3}} + 45 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{2}}\right)\right) \cdot {x}^{6}\right) + \left(0.5 \cdot \frac{{x}^{2}}{1 + \left|x\right|} + \log \left(1 + \left|x\right|\right)\right)\right), x\right) \]

      rational.json-simplify-1 [=>]58.3

      \[ \mathsf{copysign}\left(-0.041666666666666664 \cdot \left(\left(3 \cdot \frac{1}{1 + \left|x\right|} + 3 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{2}}\right) \cdot {x}^{4}\right) + \left(0.001388888888888889 \cdot \left(\left(45 \cdot \frac{1}{1 + \left|x\right|} + \left(30 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{3}} + 45 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{2}}\right)\right) \cdot {x}^{6}\right) + \color{blue}{\left(\log \left(1 + \left|x\right|\right) + 0.5 \cdot \frac{{x}^{2}}{1 + \left|x\right|}\right)}\right), x\right) \]

      rational.json-simplify-41 [=>]58.3

      \[ \mathsf{copysign}\left(-0.041666666666666664 \cdot \left(\left(3 \cdot \frac{1}{1 + \left|x\right|} + 3 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{2}}\right) \cdot {x}^{4}\right) + \color{blue}{\left(\log \left(1 + \left|x\right|\right) + \left(0.5 \cdot \frac{{x}^{2}}{1 + \left|x\right|} + 0.001388888888888889 \cdot \left(\left(45 \cdot \frac{1}{1 + \left|x\right|} + \left(30 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{3}} + 45 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{2}}\right)\right) \cdot {x}^{6}\right)\right)\right)}, x\right) \]

    if 2e-3 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x)

    1. Initial program 32.0

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Taylor expanded in x around inf 0.6

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{x}\right), x\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification28.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq -2:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left(-x\right) + \left|x\right|\right) - 0.5 \cdot \frac{1}{x}\right), x\right)\\ \mathbf{elif}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq 0.002:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(1 + \left|x\right|\right) + \left({x}^{4} \cdot \left(\left(\frac{-1}{-1 - \left|x\right|} + \frac{1}{{\left(1 + \left|x\right|\right)}^{2}}\right) \cdot -0.125\right) + \left(0.5 \cdot \frac{{x}^{2}}{1 + \left|x\right|} + {x}^{6} \cdot \left(0.001388888888888889 \cdot \left(30 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{3}} + 45 \cdot \left(\frac{-1}{-1 - \left|x\right|} + \frac{1}{{\left(1 + \left|x\right|\right)}^{2}}\right)\right)\right)\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + x\right), x\right)\\ \end{array} \]

Alternatives

Alternative 1
Error28.8
Cost145544
\[\begin{array}{l} t_0 := 1 + \left|x\right|\\ t_1 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\ t_2 := \frac{1}{{t_0}^{2}}\\ \mathbf{if}\;t_1 \leq -2:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left(-x\right) + \left|x\right|\right) - 0.5 \cdot \frac{1}{x}\right), x\right)\\ \mathbf{elif}\;t_1 \leq 0.002:\\ \;\;\;\;\mathsf{copysign}\left(\frac{\left(t_2 \cdot 45 + 30 \cdot \frac{1}{{t_0}^{3}}\right) \cdot \left({x}^{6} \cdot 0.001388888888888889\right) + \left(\left(\log t_0 + 0.5 \cdot \frac{{x}^{2}}{t_0}\right) + {x}^{4} \cdot \left(\left(t_2 + \frac{1}{t_0}\right) \cdot -0.125\right)\right)}{1}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + x\right), x\right)\\ \end{array} \]
Alternative 2
Error28.8
Cost145416
\[\begin{array}{l} t_0 := \left|x\right| + 1\\ t_1 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\ t_2 := \frac{1}{{t_0}^{2}}\\ \mathbf{if}\;t_1 \leq -2:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left(-x\right) + \left|x\right|\right) - 0.5 \cdot \frac{1}{x}\right), x\right)\\ \mathbf{elif}\;t_1 \leq 0.002:\\ \;\;\;\;\mathsf{copysign}\left(\log t_0 + \left({x}^{4} \cdot \left(\left(\frac{1}{t_0} + t_2\right) \cdot -0.125\right) + \left(0.5 \cdot \frac{{x}^{2}}{t_0} + \left(t_2 \cdot 45 + 30 \cdot \frac{1}{{t_0}^{3}}\right) \cdot \left(0.001388888888888889 \cdot {x}^{6}\right)\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + x\right), x\right)\\ \end{array} \]
Alternative 3
Error28.9
Cost111944
\[\begin{array}{l} t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\ t_1 := 1 + \left|x\right|\\ \mathbf{if}\;t_0 \leq -2:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left(-x\right) + \left|x\right|\right) - 0.5 \cdot \frac{1}{x}\right), x\right)\\ \mathbf{elif}\;t_0 \leq 0.002:\\ \;\;\;\;\mathsf{copysign}\left(\left(\log t_1 + 0.5 \cdot \frac{{x}^{2}}{t_1}\right) + {x}^{4} \cdot \left(\left(\frac{-1}{-1 - \left|x\right|} + \frac{1}{{t_1}^{2}}\right) \cdot -0.125\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + x\right), x\right)\\ \end{array} \]
Alternative 4
Error28.9
Cost85192
\[\begin{array}{l} t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\ t_1 := 1 + \left|x\right|\\ \mathbf{if}\;t_0 \leq -2:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left(-x\right) + \left|x\right|\right) - 0.5 \cdot \frac{1}{x}\right), x\right)\\ \mathbf{elif}\;t_0 \leq 0.002:\\ \;\;\;\;\mathsf{copysign}\left(0.5 \cdot \frac{{x}^{2}}{t_1} + \log t_1, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + x\right), x\right)\\ \end{array} \]
Alternative 5
Error29.1
Cost78472
\[\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 -\infty:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left(-x\right) + \left|x\right|\right), x\right)\\ \mathbf{elif}\;t_0 \leq 0.002:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + x\right), x\right)\\ \end{array} \]
Alternative 6
Error30.0
Cost20036
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-308}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left(-x\right) + \left|x\right|\right) - 0.5 \cdot \frac{1}{x}\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + x\right), x\right)\\ \end{array} \]
Alternative 7
Error30.1
Cost19652
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-310}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left(-x\right) + \left|x\right|\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + x\right), x\right)\\ \end{array} \]
Alternative 8
Error40.2
Cost19588
\[\begin{array}{l} \mathbf{if}\;x \leq 0.34:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + 1\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + x\right), x\right)\\ \end{array} \]
Alternative 9
Error51.5
Cost19456
\[\mathsf{copysign}\left(\log \left(\left|x\right| + 1\right), x\right) \]
Alternative 10
Error55.0
Cost13252
\[\begin{array}{l} \mathbf{if}\;x \leq -0.37:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\frac{\left|x\right|}{x}, x\right)\\ \end{array} \]
Alternative 11
Error52.1
Cost13252
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-308}:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{1}{x}\right), x\right)\\ \end{array} \]
Alternative 12
Error57.8
Cost13056
\[\mathsf{copysign}\left(\frac{\left|x\right|}{x}, x\right) \]

Error

Reproduce?

herbie shell --seed 2023064 
(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))