Average Error: 45.1 → 0.7
Time: 4.5s
Precision: binary64
Cost: 79048
\[\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)\\ \mathbf{if}\;t_0 \leq -20:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;t_0 \leq 0.001:\\ \;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(0.075 \cdot {x}^{5} + \left(x + -0.16666666666666666 \cdot {x}^{6}\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \left(x + \frac{0.5}{x}\right)\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)))
   (if (<= t_0 -20.0)
     (copysign (log (/ -0.5 x)) x)
     (if (<= t_0 0.001)
       (copysign
        (+
         (* -0.16666666666666666 (pow x 3.0))
         (+ (* 0.075 (pow x 5.0)) (+ x (* -0.16666666666666666 (pow x 6.0)))))
        x)
       (copysign (log (+ x (+ x (/ 0.5 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 tmp;
	if (t_0 <= -20.0) {
		tmp = copysign(log((-0.5 / x)), x);
	} else if (t_0 <= 0.001) {
		tmp = copysign(((-0.16666666666666666 * pow(x, 3.0)) + ((0.075 * pow(x, 5.0)) + (x + (-0.16666666666666666 * pow(x, 6.0))))), x);
	} else {
		tmp = copysign(log((x + (x + (0.5 / 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 tmp;
	if (t_0 <= -20.0) {
		tmp = Math.copySign(Math.log((-0.5 / x)), x);
	} else if (t_0 <= 0.001) {
		tmp = Math.copySign(((-0.16666666666666666 * Math.pow(x, 3.0)) + ((0.075 * Math.pow(x, 5.0)) + (x + (-0.16666666666666666 * Math.pow(x, 6.0))))), x);
	} else {
		tmp = Math.copySign(Math.log((x + (x + (0.5 / 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)
	tmp = 0
	if t_0 <= -20.0:
		tmp = math.copysign(math.log((-0.5 / x)), x)
	elif t_0 <= 0.001:
		tmp = math.copysign(((-0.16666666666666666 * math.pow(x, 3.0)) + ((0.075 * math.pow(x, 5.0)) + (x + (-0.16666666666666666 * math.pow(x, 6.0))))), x)
	else:
		tmp = math.copysign(math.log((x + (x + (0.5 / 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)
	tmp = 0.0
	if (t_0 <= -20.0)
		tmp = copysign(log(Float64(-0.5 / x)), x);
	elseif (t_0 <= 0.001)
		tmp = copysign(Float64(Float64(-0.16666666666666666 * (x ^ 3.0)) + Float64(Float64(0.075 * (x ^ 5.0)) + Float64(x + Float64(-0.16666666666666666 * (x ^ 6.0))))), x);
	else
		tmp = copysign(log(Float64(x + Float64(x + Float64(0.5 / 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)))));
	tmp = 0.0;
	if (t_0 <= -20.0)
		tmp = sign(x) * abs(log((-0.5 / x)));
	elseif (t_0 <= 0.001)
		tmp = sign(x) * abs(((-0.16666666666666666 * (x ^ 3.0)) + ((0.075 * (x ^ 5.0)) + (x + (-0.16666666666666666 * (x ^ 6.0))))));
	else
		tmp = sign(x) * abs(log((x + (x + (0.5 / 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]}, If[LessEqual[t$95$0, -20.0], N[With[{TMP1 = Abs[N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[t$95$0, 0.001], N[With[{TMP1 = Abs[N[(N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.075 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] + N[(x + N[(-0.16666666666666666 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(x + N[(x + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $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)\\
\mathbf{if}\;t_0 \leq -20:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\

\mathbf{elif}\;t_0 \leq 0.001:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(0.075 \cdot {x}^{5} + \left(x + -0.16666666666666666 \cdot {x}^{6}\right)\right), x\right)\\

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


\end{array}

Error

Target

Original45.1
Target0.0
Herbie0.7
\[\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) < -20

    1. Initial program 32.5

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Simplified0

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
      Proof
      (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (hypot.f64 1 x))) x): 0 points increase in error, 0 points decrease in error
      (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (Rewrite<= hypot-1-def_binary64 (sqrt.f64 (+.f64 1 (*.f64 x x)))))) x): 60 points increase in error, 0 points decrease in error
      (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 x x) 1))))) x): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in x around -inf 0

      \[\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) \]
    4. Simplified0.0

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\frac{-0.5}{x}\right)}, x\right) \]
      Proof
      (/.f64 -1/2 x): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= metadata-eval (neg.f64 1/2)) x): 0 points increase in error, 0 points decrease in error
      (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 1/2 x))): 0 points increase in error, 0 points decrease in error
      (neg.f64 (/.f64 (Rewrite<= metadata-eval (*.f64 1/2 1)) x)): 0 points increase in error, 0 points decrease in error
      (neg.f64 (Rewrite<= associate-*r/_binary64 (*.f64 1/2 (/.f64 1 x)))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> neg-sub0_binary64 (-.f64 0 (*.f64 1/2 (/.f64 1 x)))): 0 points increase in error, 0 points decrease in error
      (-.f64 (Rewrite<= +-inverses_binary64 (-.f64 x x)) (*.f64 1/2 (/.f64 1 x))): 0 points increase in error, 0 points decrease in error
      (-.f64 (Rewrite<= unsub-neg_binary64 (+.f64 x (neg.f64 x))) (*.f64 1/2 (/.f64 1 x))): 0 points increase in error, 0 points decrease in error
      (-.f64 (+.f64 x (Rewrite<= mul-1-neg_binary64 (*.f64 -1 x))) (*.f64 1/2 (/.f64 1 x))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate--l+_binary64 (+.f64 x (-.f64 (*.f64 -1 x) (*.f64 1/2 (/.f64 1 x))))): 1 points increase in error, 114 points decrease in error
      (+.f64 (Rewrite<= rem-square-sqrt_binary64 (*.f64 (sqrt.f64 x) (sqrt.f64 x))) (-.f64 (*.f64 -1 x) (*.f64 1/2 (/.f64 1 x)))): 141 points increase in error, 18 points decrease in error
      (+.f64 (Rewrite<= fabs-sqr_binary64 (fabs.f64 (*.f64 (sqrt.f64 x) (sqrt.f64 x)))) (-.f64 (*.f64 -1 x) (*.f64 1/2 (/.f64 1 x)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (fabs.f64 (Rewrite=> rem-square-sqrt_binary64 x)) (-.f64 (*.f64 -1 x) (*.f64 1/2 (/.f64 1 x)))): 18 points increase in error, 141 points decrease in error
      (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (fabs.f64 x) (*.f64 -1 x)) (*.f64 1/2 (/.f64 1 x)))): 55 points increase in error, 1 points decrease in error

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

    1. Initial program 58.0

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Simplified58.0

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
      Proof
      (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (hypot.f64 1 x))) x): 0 points increase in error, 0 points decrease in error
      (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (Rewrite<= hypot-1-def_binary64 (sqrt.f64 (+.f64 1 (*.f64 x x)))))) x): 60 points increase in error, 0 points decrease in error
      (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 x x) 1))))) x): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in x around 0 58.1

      \[\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.5 \cdot \frac{{x}^{2}}{1 + \left|x\right|} + \log \left(1 + \left|x\right|\right)\right)}, x\right) \]
    4. Simplified1.0

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{fma}\left(\frac{-0.125}{1 + x} + \frac{-0.125}{{\left(1 + x\right)}^{2}}, {x}^{4}, \mathsf{fma}\left(0.5, \frac{x \cdot x}{1 + x}, \mathsf{log1p}\left(x\right)\right)\right)}, x\right) \]
      Proof
      (fma.f64 (+.f64 (/.f64 -1/8 (+.f64 1 x)) (/.f64 -1/8 (pow.f64 (+.f64 1 x) 2))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (+.f64 (/.f64 (Rewrite<= metadata-eval (*.f64 3 -1/24)) (+.f64 1 x)) (/.f64 -1/8 (pow.f64 (+.f64 1 x) 2))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (+.f64 (/.f64 (*.f64 3 -1/24) (+.f64 1 (Rewrite<= rem-square-sqrt_binary64 (*.f64 (sqrt.f64 x) (sqrt.f64 x))))) (/.f64 -1/8 (pow.f64 (+.f64 1 x) 2))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 69 points increase in error, 6 points decrease in error
      (fma.f64 (+.f64 (/.f64 (*.f64 3 -1/24) (+.f64 1 (Rewrite<= fabs-sqr_binary64 (fabs.f64 (*.f64 (sqrt.f64 x) (sqrt.f64 x)))))) (/.f64 -1/8 (pow.f64 (+.f64 1 x) 2))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (+.f64 (/.f64 (*.f64 3 -1/24) (+.f64 1 (fabs.f64 (Rewrite=> rem-square-sqrt_binary64 x)))) (/.f64 -1/8 (pow.f64 (+.f64 1 x) 2))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 6 points increase in error, 69 points decrease in error
      (fma.f64 (+.f64 (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 3 (+.f64 1 (fabs.f64 x))) -1/24)) (/.f64 -1/8 (pow.f64 (+.f64 1 x) 2))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 0 points increase in error, 2 points decrease in error
      (fma.f64 (+.f64 (*.f64 (/.f64 (Rewrite<= metadata-eval (*.f64 3 1)) (+.f64 1 (fabs.f64 x))) -1/24) (/.f64 -1/8 (pow.f64 (+.f64 1 x) 2))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (+.f64 (*.f64 (Rewrite<= associate-*r/_binary64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x))))) -1/24) (/.f64 -1/8 (pow.f64 (+.f64 1 x) 2))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 2 points increase in error, 4 points decrease in error
      (fma.f64 (+.f64 (*.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) -1/24) (/.f64 (Rewrite<= metadata-eval (*.f64 3 -1/24)) (pow.f64 (+.f64 1 x) 2))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (+.f64 (*.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) -1/24) (/.f64 (*.f64 3 -1/24) (pow.f64 (+.f64 1 (Rewrite<= rem-square-sqrt_binary64 (*.f64 (sqrt.f64 x) (sqrt.f64 x)))) 2))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 65 points increase in error, 0 points decrease in error
      (fma.f64 (+.f64 (*.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) -1/24) (/.f64 (*.f64 3 -1/24) (pow.f64 (+.f64 1 (Rewrite<= fabs-sqr_binary64 (fabs.f64 (*.f64 (sqrt.f64 x) (sqrt.f64 x))))) 2))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (+.f64 (*.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) -1/24) (/.f64 (*.f64 3 -1/24) (pow.f64 (+.f64 1 (fabs.f64 (Rewrite=> rem-square-sqrt_binary64 x))) 2))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 0 points increase in error, 65 points decrease in error
      (fma.f64 (+.f64 (*.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) -1/24) (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 3 (pow.f64 (+.f64 1 (fabs.f64 x)) 2)) -1/24))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (+.f64 (*.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) -1/24) (*.f64 (/.f64 (Rewrite<= metadata-eval (*.f64 3 1)) (pow.f64 (+.f64 1 (fabs.f64 x)) 2)) -1/24)) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (+.f64 (*.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) -1/24) (*.f64 (Rewrite<= associate-*r/_binary64 (*.f64 3 (/.f64 1 (pow.f64 (+.f64 1 (fabs.f64 x)) 2)))) -1/24)) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (Rewrite<= distribute-rgt-in_binary64 (*.f64 -1/24 (+.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) (*.f64 3 (/.f64 1 (pow.f64 (+.f64 1 (fabs.f64 x)) 2)))))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (*.f64 x x) (+.f64 1 x)) (log1p.f64 x))): 1 points increase in error, 0 points decrease in error
      (fma.f64 (*.f64 -1/24 (+.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) (*.f64 3 (/.f64 1 (pow.f64 (+.f64 1 (fabs.f64 x)) 2))))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (Rewrite<= unpow2_binary64 (pow.f64 x 2)) (+.f64 1 x)) (log1p.f64 x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (*.f64 -1/24 (+.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) (*.f64 3 (/.f64 1 (pow.f64 (+.f64 1 (fabs.f64 x)) 2))))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (pow.f64 x 2) (+.f64 1 (Rewrite<= rem-square-sqrt_binary64 (*.f64 (sqrt.f64 x) (sqrt.f64 x))))) (log1p.f64 x))): 65 points increase in error, 0 points decrease in error
      (fma.f64 (*.f64 -1/24 (+.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) (*.f64 3 (/.f64 1 (pow.f64 (+.f64 1 (fabs.f64 x)) 2))))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (pow.f64 x 2) (+.f64 1 (Rewrite<= fabs-sqr_binary64 (fabs.f64 (*.f64 (sqrt.f64 x) (sqrt.f64 x)))))) (log1p.f64 x))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (*.f64 -1/24 (+.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) (*.f64 3 (/.f64 1 (pow.f64 (+.f64 1 (fabs.f64 x)) 2))))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (pow.f64 x 2) (+.f64 1 (fabs.f64 (Rewrite=> rem-square-sqrt_binary64 x)))) (log1p.f64 x))): 0 points increase in error, 65 points decrease in error
      (fma.f64 (*.f64 -1/24 (+.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) (*.f64 3 (/.f64 1 (pow.f64 (+.f64 1 (fabs.f64 x)) 2))))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (pow.f64 x 2) (+.f64 1 (fabs.f64 x))) (log1p.f64 (Rewrite<= rem-square-sqrt_binary64 (*.f64 (sqrt.f64 x) (sqrt.f64 x)))))): 110 points increase in error, 0 points decrease in error
      (fma.f64 (*.f64 -1/24 (+.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) (*.f64 3 (/.f64 1 (pow.f64 (+.f64 1 (fabs.f64 x)) 2))))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (pow.f64 x 2) (+.f64 1 (fabs.f64 x))) (log1p.f64 (Rewrite<= fabs-sqr_binary64 (fabs.f64 (*.f64 (sqrt.f64 x) (sqrt.f64 x))))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (*.f64 -1/24 (+.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) (*.f64 3 (/.f64 1 (pow.f64 (+.f64 1 (fabs.f64 x)) 2))))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (pow.f64 x 2) (+.f64 1 (fabs.f64 x))) (log1p.f64 (fabs.f64 (Rewrite=> rem-square-sqrt_binary64 x))))): 0 points increase in error, 123 points decrease in error
      (fma.f64 (*.f64 -1/24 (+.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) (*.f64 3 (/.f64 1 (pow.f64 (+.f64 1 (fabs.f64 x)) 2))))) (pow.f64 x 4) (fma.f64 1/2 (/.f64 (pow.f64 x 2) (+.f64 1 (fabs.f64 x))) (Rewrite<= log1p-def_binary64 (log.f64 (+.f64 1 (fabs.f64 x)))))): 77 points increase in error, 64 points decrease in error
      (fma.f64 (*.f64 -1/24 (+.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) (*.f64 3 (/.f64 1 (pow.f64 (+.f64 1 (fabs.f64 x)) 2))))) (pow.f64 x 4) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 1/2 (/.f64 (pow.f64 x 2) (+.f64 1 (fabs.f64 x)))) (log.f64 (+.f64 1 (fabs.f64 x)))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (*.f64 -1/24 (+.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) (*.f64 3 (/.f64 1 (pow.f64 (+.f64 1 (fabs.f64 x)) 2))))) (pow.f64 x 4)) (+.f64 (*.f64 1/2 (/.f64 (pow.f64 x 2) (+.f64 1 (fabs.f64 x)))) (log.f64 (+.f64 1 (fabs.f64 x)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite<= associate-*r*_binary64 (*.f64 -1/24 (*.f64 (+.f64 (*.f64 3 (/.f64 1 (+.f64 1 (fabs.f64 x)))) (*.f64 3 (/.f64 1 (pow.f64 (+.f64 1 (fabs.f64 x)) 2)))) (pow.f64 x 4)))) (+.f64 (*.f64 1/2 (/.f64 (pow.f64 x 2) (+.f64 1 (fabs.f64 x)))) (log.f64 (+.f64 1 (fabs.f64 x))))): 2 points increase in error, 6 points decrease in error
    5. Taylor expanded in x around 0 0.9

      \[\leadsto \mathsf{copysign}\left(\color{blue}{-0.16666666666666666 \cdot {x}^{3} + \left(0.075 \cdot {x}^{5} + \left(-0.16666666666666666 \cdot {x}^{6} + x\right)\right)}, x\right) \]

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

    1. Initial program 30.9

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Simplified0.2

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
      Proof
      (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (hypot.f64 1 x))) x): 0 points increase in error, 0 points decrease in error
      (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (Rewrite<= hypot-1-def_binary64 (sqrt.f64 (+.f64 1 (*.f64 x x)))))) x): 60 points increase in error, 0 points decrease in error
      (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 x x) 1))))) x): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in x around inf 1.0

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

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(x + \left(x + \frac{0.5}{x}\right)\right)}, x\right) \]
      Proof
      (+.f64 x (+.f64 x (/.f64 1/2 x))): 0 points increase in error, 0 points decrease in error
      (+.f64 x (+.f64 (Rewrite<= rem-square-sqrt_binary64 (*.f64 (sqrt.f64 x) (sqrt.f64 x))) (/.f64 1/2 x))): 137 points increase in error, 8 points decrease in error
      (+.f64 x (+.f64 (Rewrite<= fabs-sqr_binary64 (fabs.f64 (*.f64 (sqrt.f64 x) (sqrt.f64 x)))) (/.f64 1/2 x))): 0 points increase in error, 0 points decrease in error
      (+.f64 x (+.f64 (fabs.f64 (Rewrite=> rem-square-sqrt_binary64 x)) (/.f64 1/2 x))): 8 points increase in error, 137 points decrease in error
      (+.f64 x (+.f64 (fabs.f64 x) (/.f64 (Rewrite<= metadata-eval (*.f64 1/2 1)) x))): 0 points increase in error, 0 points decrease in error
      (+.f64 x (+.f64 (fabs.f64 x) (Rewrite<= associate-*r/_binary64 (*.f64 1/2 (/.f64 1 x))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 x (fabs.f64 x)) (*.f64 1/2 (/.f64 1 x)))): 1 points increase in error, 61 points decrease in error
      (+.f64 (Rewrite<= +-commutative_binary64 (+.f64 (fabs.f64 x) x)) (*.f64 1/2 (/.f64 1 x))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 1/2 (/.f64 1 x)) (+.f64 (fabs.f64 x) x))): 0 points increase in error, 0 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification0.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq -20:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq 0.001:\\ \;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(0.075 \cdot {x}^{5} + \left(x + -0.16666666666666666 \cdot {x}^{6}\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \left(x + \frac{0.5}{x}\right)\right), x\right)\\ \end{array} \]

Alternatives

Alternative 1
Error0.7
Cost72328
\[\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 -20:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;t_0 \leq 0.001:\\ \;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(x + 0.075 \cdot {x}^{5}\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \left(x + \frac{0.5}{x}\right)\right), x\right)\\ \end{array} \]
Alternative 2
Error0.2
Cost20040
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 0.00068:\\ \;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\left(1 + \log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right) + -1, x\right)\\ \end{array} \]
Alternative 3
Error0.2
Cost19784
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 0.00068:\\ \;\;\;\;\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} \]
Alternative 4
Error0.4
Cost13576
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 0.95:\\ \;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \left(x + \frac{0.5}{x}\right)\right), x\right)\\ \end{array} \]
Alternative 5
Error0.4
Cost13512
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 1.25:\\ \;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\ \end{array} \]
Alternative 6
Error11.5
Cost13320
\[\begin{array}{l} \mathbf{if}\;x \leq -3.2:\\ \;\;\;\;\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 + x\right), x\right)\\ \end{array} \]
Alternative 7
Error0.6
Cost13320
\[\begin{array}{l} \mathbf{if}\;x \leq -1.25:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 1.25:\\ \;\;\;\;\mathsf{copysign}\left(x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\ \end{array} \]
Alternative 8
Error22.5
Cost13124
\[\begin{array}{l} \mathbf{if}\;x \leq -0.5:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\ \end{array} \]
Alternative 9
Error26.3
Cost13060
\[\begin{array}{l} \mathbf{if}\;x \leq 1.55:\\ \;\;\;\;\mathsf{copysign}\left(x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\ \end{array} \]
Alternative 10
Error30.3
Cost6528
\[\mathsf{copysign}\left(x, x\right) \]

Error

Reproduce

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