Rust f64::asinh

Percentage Accurate: 28.9% → 99.3%
Time: 12.8s
Alternatives: 8
Speedup: 4.0×

Specification

?
\[\begin{array}{l} \\ \sinh^{-1} x \end{array} \]
(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:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 28.9% accurate, 1.0× speedup?

\[\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
 (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}

Alternative 1: 99.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \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(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x) -20.0)
   (copysign (log (+ (fabs x) (hypot 1.0 x))) x)
   (copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
double code(double x) {
	double tmp;
	if (copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x) <= -20.0) {
		tmp = copysign(log((fabs(x) + hypot(1.0, x))), x);
	} else {
		tmp = copysign(log1p((x + (hypot(1.0, x) + -1.0))), x);
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x) <= -20.0) {
		tmp = Math.copySign(Math.log((Math.abs(x) + Math.hypot(1.0, x))), x);
	} else {
		tmp = Math.copySign(Math.log1p((x + (Math.hypot(1.0, x) + -1.0))), x);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x) <= -20.0:
		tmp = math.copysign(math.log((math.fabs(x) + math.hypot(1.0, x))), x)
	else:
		tmp = math.copysign(math.log1p((x + (math.hypot(1.0, x) + -1.0))), x)
	return tmp
function code(x)
	tmp = 0.0
	if (copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x) <= -20.0)
		tmp = copysign(log(Float64(abs(x) + hypot(1.0, x))), x);
	else
		tmp = copysign(log1p(Float64(x + Float64(hypot(1.0, x) + -1.0))), x);
	end
	return tmp
end
code[x_] := If[LessEqual[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], -20.0], N[With[{TMP1 = Abs[N[Log[N[(N[Abs[x], $MachinePrecision] + N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[1 + N[(x + N[(N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}

\\
\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(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < -20

    1. Initial program 47.7%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Step-by-step derivation
      1. +-commutative47.7%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right) \]
      2. hypot-1-def100.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]

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

    1. Initial program 21.7%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Step-by-step derivation
      1. +-commutative21.7%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right) \]
      2. hypot-1-def37.8%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right) \]
    3. Simplified37.8%

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Step-by-step derivation
      1. log1p-expm1-u37.8%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)\right)}, x\right) \]
      2. expm1-udef37.8%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{e^{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)} - 1}\right), x\right) \]
      3. add-exp-log37.8%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)} - 1\right), x\right) \]
      4. associate--l+99.5%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left|x\right| + \left(\mathsf{hypot}\left(1, x\right) - 1\right)}\right), x\right) \]
      5. add-sqr-sqrt70.0%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + \left(\mathsf{hypot}\left(1, x\right) - 1\right)\right), x\right) \]
      6. fabs-sqr70.0%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} + \left(\mathsf{hypot}\left(1, x\right) - 1\right)\right), x\right) \]
      7. add-sqr-sqrt99.5%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{x} + \left(\mathsf{hypot}\left(1, x\right) - 1\right)\right), x\right) \]
    5. Applied egg-rr99.5%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) - 1\right)\right)}, x\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.6%

    \[\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(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right), x\right)\\ \end{array} \]

Alternative 2: 99.6% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.25:\\ \;\;\;\;\mathsf{copysign}\left(\log 0.5 + \log \left(\frac{-1}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 0.001:\\ \;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -1.25)
   (copysign (+ (log 0.5) (log (/ -1.0 x))) x)
   (if (<= x 0.001)
     (copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
     (copysign (log (+ x (hypot 1.0 x))) x))))
double code(double x) {
	double tmp;
	if (x <= -1.25) {
		tmp = copysign((log(0.5) + log((-1.0 / x))), x);
	} else if (x <= 0.001) {
		tmp = copysign((x + (pow(x, 3.0) * -0.16666666666666666)), 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) + Math.log((-1.0 / x))), x);
	} else if (x <= 0.001) {
		tmp = Math.copySign((x + (Math.pow(x, 3.0) * -0.16666666666666666)), 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) + math.log((-1.0 / x))), x)
	elif x <= 0.001:
		tmp = math.copysign((x + (math.pow(x, 3.0) * -0.16666666666666666)), 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(Float64(log(0.5) + log(Float64(-1.0 / x))), x);
	elseif (x <= 0.001)
		tmp = copysign(Float64(x + Float64((x ^ 3.0) * -0.16666666666666666)), 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) + log((-1.0 / x))));
	elseif (x <= 0.001)
		tmp = sign(x) * abs((x + ((x ^ 3.0) * -0.16666666666666666)));
	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[(N[Log[0.5], $MachinePrecision] + N[Log[N[(-1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[x, 0.001], N[With[{TMP1 = Abs[N[(x + N[(N[Power[x, 3.0], $MachinePrecision] * -0.16666666666666666), $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 0.5 + \log \left(\frac{-1}{x}\right), x\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.25

    1. Initial program 48.5%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Step-by-step derivation
      1. +-commutative48.5%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right) \]
      2. hypot-1-def100.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Step-by-step derivation
      1. +-lft-identity100.0%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{0 + \log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)}, x\right) \]
      2. +-commutative100.0%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right) + 0}, x\right) \]
      3. add-sqr-sqrt0.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + \mathsf{hypot}\left(1, x\right)\right) + 0, x\right) \]
      4. fabs-sqr0.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} + \mathsf{hypot}\left(1, x\right)\right) + 0, x\right) \]
      5. add-sqr-sqrt4.6%

        \[\leadsto \mathsf{copysign}\left(\log \left(\color{blue}{x} + \mathsf{hypot}\left(1, x\right)\right) + 0, x\right) \]
    5. Applied egg-rr4.6%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(x + \mathsf{hypot}\left(1, x\right)\right) + 0}, x\right) \]
    6. Simplified4.6%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(x + \mathsf{hypot}\left(1, x\right)\right)}, x\right) \]
    7. Taylor expanded in x around -inf 98.4%

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

    if -1.25 < x < 1e-3

    1. Initial program 6.4%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Step-by-step derivation
      1. +-commutative6.4%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right) \]
      2. hypot-1-def6.4%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right) \]
    3. Simplified6.4%

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Step-by-step derivation
      1. expm1-log1p-u6.4%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)\right)}, x\right) \]
      2. expm1-udef6.4%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} - 1}, x\right) \]
      3. flip3--6.5%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\frac{{\left(e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - {1}^{3}}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 \cdot 1 + e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}}, x\right) \]
      4. add-sqr-sqrt3.1%

        \[\leadsto \mathsf{copysign}\left(\frac{{\left(e^{\mathsf{log1p}\left(\log \left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - {1}^{3}}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 \cdot 1 + e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
      5. fabs-sqr3.1%

        \[\leadsto \mathsf{copysign}\left(\frac{{\left(e^{\mathsf{log1p}\left(\log \left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - {1}^{3}}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 \cdot 1 + e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
      6. add-sqr-sqrt6.4%

        \[\leadsto \mathsf{copysign}\left(\frac{{\left(e^{\mathsf{log1p}\left(\log \left(\color{blue}{x} + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - {1}^{3}}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 \cdot 1 + e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
      7. metadata-eval6.4%

        \[\leadsto \mathsf{copysign}\left(\frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - \color{blue}{1}}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 \cdot 1 + e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
    5. Applied egg-rr6.5%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - 1}{e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}}, x\right) \]
    6. Step-by-step derivation
      1. *-un-lft-identity6.5%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{1 \cdot \frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - 1}{e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}}, x\right) \]
      2. sub-neg6.5%

        \[\leadsto \mathsf{copysign}\left(1 \cdot \frac{\color{blue}{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + \left(-1\right)}}{e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
      3. metadata-eval6.5%

        \[\leadsto \mathsf{copysign}\left(1 \cdot \frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + \color{blue}{-1}}{e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
      4. +-commutative6.5%

        \[\leadsto \mathsf{copysign}\left(1 \cdot \frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + -1}{\color{blue}{\left(1 + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right) + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}}}, x\right) \]
      5. *-rgt-identity6.5%

        \[\leadsto \mathsf{copysign}\left(1 \cdot \frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + -1}{\left(1 + \color{blue}{e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}}\right) + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}}, x\right) \]
    7. Applied egg-rr6.5%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{1 \cdot \frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + -1}{1 + \left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{2}\right)}}, x\right) \]
    8. Step-by-step derivation
      1. *-lft-identity6.5%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + -1}{1 + \left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{2}\right)}}, x\right) \]
      2. +-commutative6.5%

        \[\leadsto \mathsf{copysign}\left(\frac{\color{blue}{-1 + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3}}}{1 + \left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{2}\right)}, x\right) \]
    9. Simplified6.5%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\frac{-1 + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3}}{1 + \left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{2}\right)}}, x\right) \]
    10. Taylor expanded in x around 0 100.0%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{x + -0.16666666666666666 \cdot {x}^{3}}, x\right) \]
    11. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \mathsf{copysign}\left(x + \color{blue}{{x}^{3} \cdot -0.16666666666666666}, x\right) \]
    12. Simplified100.0%

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

    if 1e-3 < x

    1. Initial program 51.2%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Step-by-step derivation
      1. +-commutative51.2%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right) \]
      2. hypot-1-def99.6%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right) \]
    3. Simplified99.6%

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Step-by-step derivation
      1. +-lft-identity99.6%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{0 + \log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)}, x\right) \]
      2. +-commutative99.6%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right) + 0}, x\right) \]
      3. add-sqr-sqrt99.6%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + \mathsf{hypot}\left(1, x\right)\right) + 0, x\right) \]
      4. fabs-sqr99.6%

        \[\leadsto \mathsf{copysign}\left(\log \left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} + \mathsf{hypot}\left(1, x\right)\right) + 0, x\right) \]
      5. add-sqr-sqrt99.6%

        \[\leadsto \mathsf{copysign}\left(\log \left(\color{blue}{x} + \mathsf{hypot}\left(1, x\right)\right) + 0, x\right) \]
    5. Applied egg-rr99.6%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(x + \mathsf{hypot}\left(1, x\right)\right) + 0}, x\right) \]
    6. Simplified99.6%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(x + \mathsf{hypot}\left(1, x\right)\right)}, x\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.5%

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

Alternative 3: 99.4% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -9000:\\ \;\;\;\;\mathsf{copysign}\left(\log 0.5 + \log \left(\frac{-1}{x}\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -9000.0)
   (copysign (+ (log 0.5) (log (/ -1.0 x))) x)
   (copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
double code(double x) {
	double tmp;
	if (x <= -9000.0) {
		tmp = copysign((log(0.5) + log((-1.0 / x))), x);
	} else {
		tmp = copysign(log1p((x + (hypot(1.0, x) + -1.0))), x);
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (x <= -9000.0) {
		tmp = Math.copySign((Math.log(0.5) + Math.log((-1.0 / x))), x);
	} else {
		tmp = Math.copySign(Math.log1p((x + (Math.hypot(1.0, x) + -1.0))), x);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -9000.0:
		tmp = math.copysign((math.log(0.5) + math.log((-1.0 / x))), x)
	else:
		tmp = math.copysign(math.log1p((x + (math.hypot(1.0, x) + -1.0))), x)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -9000.0)
		tmp = copysign(Float64(log(0.5) + log(Float64(-1.0 / x))), x);
	else
		tmp = copysign(log1p(Float64(x + Float64(hypot(1.0, x) + -1.0))), x);
	end
	return tmp
end
code[x_] := If[LessEqual[x, -9000.0], N[With[{TMP1 = Abs[N[(N[Log[0.5], $MachinePrecision] + N[Log[N[(-1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[1 + N[(x + N[(N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -9000:\\
\;\;\;\;\mathsf{copysign}\left(\log 0.5 + \log \left(\frac{-1}{x}\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right), x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9e3

    1. Initial program 47.7%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Step-by-step derivation
      1. +-commutative47.7%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right) \]
      2. hypot-1-def100.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Step-by-step derivation
      1. +-lft-identity100.0%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{0 + \log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)}, x\right) \]
      2. +-commutative100.0%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right) + 0}, x\right) \]
      3. add-sqr-sqrt0.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + \mathsf{hypot}\left(1, x\right)\right) + 0, x\right) \]
      4. fabs-sqr0.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} + \mathsf{hypot}\left(1, x\right)\right) + 0, x\right) \]
      5. add-sqr-sqrt3.1%

        \[\leadsto \mathsf{copysign}\left(\log \left(\color{blue}{x} + \mathsf{hypot}\left(1, x\right)\right) + 0, x\right) \]
    5. Applied egg-rr3.1%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(x + \mathsf{hypot}\left(1, x\right)\right) + 0}, x\right) \]
    6. Simplified3.1%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(x + \mathsf{hypot}\left(1, x\right)\right)}, x\right) \]
    7. Taylor expanded in x around -inf 99.6%

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

    if -9e3 < x

    1. Initial program 21.7%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Step-by-step derivation
      1. +-commutative21.7%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right) \]
      2. hypot-1-def37.8%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right) \]
    3. Simplified37.8%

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Step-by-step derivation
      1. log1p-expm1-u37.8%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)\right)}, x\right) \]
      2. expm1-udef37.8%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{e^{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)} - 1}\right), x\right) \]
      3. add-exp-log37.8%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)} - 1\right), x\right) \]
      4. associate--l+99.5%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left|x\right| + \left(\mathsf{hypot}\left(1, x\right) - 1\right)}\right), x\right) \]
      5. add-sqr-sqrt70.0%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + \left(\mathsf{hypot}\left(1, x\right) - 1\right)\right), x\right) \]
      6. fabs-sqr70.0%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} + \left(\mathsf{hypot}\left(1, x\right) - 1\right)\right), x\right) \]
      7. add-sqr-sqrt99.5%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{x} + \left(\mathsf{hypot}\left(1, x\right) - 1\right)\right), x\right) \]
    5. Applied egg-rr99.5%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) - 1\right)\right)}, x\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9000:\\ \;\;\;\;\mathsf{copysign}\left(\log 0.5 + \log \left(\frac{-1}{x}\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right), x\right)\\ \end{array} \]

Alternative 4: 81.7% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.25 \cdot 10^{-8}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 1.25e-8)
   (copysign (log1p (fabs x)) x)
   (copysign (log (+ x (hypot 1.0 x))) x)))
double code(double x) {
	double tmp;
	if (x <= 1.25e-8) {
		tmp = copysign(log1p(fabs(x)), x);
	} else {
		tmp = copysign(log((x + hypot(1.0, x))), x);
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (x <= 1.25e-8) {
		tmp = Math.copySign(Math.log1p(Math.abs(x)), x);
	} else {
		tmp = Math.copySign(Math.log((x + Math.hypot(1.0, x))), x);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 1.25e-8:
		tmp = math.copysign(math.log1p(math.fabs(x)), 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.25e-8)
		tmp = copysign(log1p(abs(x)), x);
	else
		tmp = copysign(log(Float64(x + hypot(1.0, x))), x);
	end
	return tmp
end
code[x_] := If[LessEqual[x, 1.25e-8], N[With[{TMP1 = Abs[N[Log[1 + N[Abs[x], $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 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.2499999999999999e-8

    1. Initial program 20.5%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Step-by-step derivation
      1. +-commutative20.5%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right) \]
      2. hypot-1-def37.6%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right) \]
    3. Simplified37.6%

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Taylor expanded in x around 0 14.8%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(1 + \left|x\right|\right)}, x\right) \]
    5. Simplified76.8%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{log1p}\left(\left|x\right|\right)}, x\right) \]

    if 1.2499999999999999e-8 < x

    1. Initial program 51.2%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Step-by-step derivation
      1. +-commutative51.2%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right) \]
      2. hypot-1-def99.6%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right) \]
    3. Simplified99.6%

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Step-by-step derivation
      1. +-lft-identity99.6%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{0 + \log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)}, x\right) \]
      2. +-commutative99.6%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right) + 0}, x\right) \]
      3. add-sqr-sqrt99.6%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + \mathsf{hypot}\left(1, x\right)\right) + 0, x\right) \]
      4. fabs-sqr99.6%

        \[\leadsto \mathsf{copysign}\left(\log \left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} + \mathsf{hypot}\left(1, x\right)\right) + 0, x\right) \]
      5. add-sqr-sqrt99.6%

        \[\leadsto \mathsf{copysign}\left(\log \left(\color{blue}{x} + \mathsf{hypot}\left(1, x\right)\right) + 0, x\right) \]
    5. Applied egg-rr99.6%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(x + \mathsf{hypot}\left(1, x\right)\right) + 0}, x\right) \]
    6. Simplified99.6%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(x + \mathsf{hypot}\left(1, x\right)\right)}, x\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification82.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.25 \cdot 10^{-8}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \]

Alternative 5: 65.3% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right) \end{array} \]
(FPCore (x) :precision binary64 (copysign (log1p (fabs x)) x))
double code(double x) {
	return copysign(log1p(fabs(x)), x);
}
public static double code(double x) {
	return Math.copySign(Math.log1p(Math.abs(x)), x);
}
def code(x):
	return math.copysign(math.log1p(math.fabs(x)), x)
function code(x)
	return copysign(log1p(abs(x)), x)
end
code[x_] := N[With[{TMP1 = Abs[N[Log[1 + N[Abs[x], $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
\begin{array}{l}

\\
\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right)
\end{array}
Derivation
  1. Initial program 28.1%

    \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
  2. Step-by-step derivation
    1. +-commutative28.1%

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right) \]
    2. hypot-1-def53.1%

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right) \]
  3. Simplified53.1%

    \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
  4. Taylor expanded in x around 0 18.9%

    \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(1 + \left|x\right|\right)}, x\right) \]
  5. Simplified65.5%

    \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{log1p}\left(\left|x\right|\right)}, x\right) \]
  6. Final simplification65.5%

    \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right|\right), x\right) \]

Alternative 6: 65.3% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -1.0) (copysign (- (log (/ -1.0 x))) x) (copysign (log1p x) x)))
double code(double x) {
	double tmp;
	if (x <= -1.0) {
		tmp = copysign(-log((-1.0 / 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((-1.0 / 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((-1.0 / x)), x)
	else:
		tmp = math.copysign(math.log1p(x), x)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -1.0)
		tmp = copysign(Float64(-log(Float64(-1.0 / 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[N[(-1.0 / x), $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(-\log \left(\frac{-1}{x}\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1

    1. Initial program 48.5%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Step-by-step derivation
      1. +-commutative48.5%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right) \]
      2. hypot-1-def100.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Taylor expanded in x around -inf 31.5%

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

    if -1 < x

    1. Initial program 21.3%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Step-by-step derivation
      1. +-commutative21.3%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right) \]
      2. hypot-1-def37.5%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right) \]
    3. Simplified37.5%

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Taylor expanded in x around 0 14.7%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(1 + \left|x\right|\right)}, x\right) \]
    5. Step-by-step derivation
      1. log1p-def76.8%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{log1p}\left(\left|x\right|\right)}, x\right) \]
      2. add-sqr-sqrt47.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|\right), x\right) \]
      3. fabs-sqr47.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right), x\right) \]
      4. add-sqr-sqrt76.8%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{x}\right), x\right) \]
      5. *-un-lft-identity76.8%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{1 \cdot \mathsf{log1p}\left(x\right)}, x\right) \]
    6. Applied egg-rr76.8%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{1 \cdot \mathsf{log1p}\left(x\right)}, x\right) \]
    7. Step-by-step derivation
      1. *-lft-identity76.8%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{log1p}\left(x\right)}, x\right) \]
    8. Simplified76.8%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{log1p}\left(x\right)}, x\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification65.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\ \end{array} \]

Alternative 7: 59.2% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.55:\\ \;\;\;\;\mathsf{copysign}\left(x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 1.55) (copysign x x) (copysign (log1p x) x)))
double code(double x) {
	double tmp;
	if (x <= 1.55) {
		tmp = copysign(x, x);
	} else {
		tmp = copysign(log1p(x), x);
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (x <= 1.55) {
		tmp = Math.copySign(x, x);
	} else {
		tmp = Math.copySign(Math.log1p(x), x);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 1.55:
		tmp = math.copysign(x, x)
	else:
		tmp = math.copysign(math.log1p(x), x)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 1.55)
		tmp = copysign(x, x);
	else
		tmp = copysign(log1p(x), x);
	end
	return tmp
end
code[x_] := If[LessEqual[x, 1.55], N[With[{TMP1 = Abs[x], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[1 + x], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.55:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.55000000000000004

    1. Initial program 22.0%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Step-by-step derivation
      1. +-commutative22.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right) \]
      2. hypot-1-def38.8%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right) \]
    3. Simplified38.8%

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Step-by-step derivation
      1. expm1-log1p-u38.2%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)\right)}, x\right) \]
      2. expm1-udef38.3%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} - 1}, x\right) \]
      3. flip3--38.3%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\frac{{\left(e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - {1}^{3}}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 \cdot 1 + e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}}, x\right) \]
      4. add-sqr-sqrt3.9%

        \[\leadsto \mathsf{copysign}\left(\frac{{\left(e^{\mathsf{log1p}\left(\log \left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - {1}^{3}}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 \cdot 1 + e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
      5. fabs-sqr3.9%

        \[\leadsto \mathsf{copysign}\left(\frac{{\left(e^{\mathsf{log1p}\left(\log \left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - {1}^{3}}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 \cdot 1 + e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
      6. add-sqr-sqrt6.1%

        \[\leadsto \mathsf{copysign}\left(\frac{{\left(e^{\mathsf{log1p}\left(\log \left(\color{blue}{x} + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - {1}^{3}}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 \cdot 1 + e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
      7. metadata-eval6.1%

        \[\leadsto \mathsf{copysign}\left(\frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - \color{blue}{1}}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 \cdot 1 + e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
    5. Applied egg-rr6.2%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - 1}{e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}}, x\right) \]
    6. Step-by-step derivation
      1. *-un-lft-identity6.2%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{1 \cdot \frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - 1}{e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}}, x\right) \]
      2. sub-neg6.2%

        \[\leadsto \mathsf{copysign}\left(1 \cdot \frac{\color{blue}{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + \left(-1\right)}}{e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
      3. metadata-eval6.2%

        \[\leadsto \mathsf{copysign}\left(1 \cdot \frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + \color{blue}{-1}}{e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
      4. +-commutative6.2%

        \[\leadsto \mathsf{copysign}\left(1 \cdot \frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + -1}{\color{blue}{\left(1 + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right) + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}}}, x\right) \]
      5. *-rgt-identity6.2%

        \[\leadsto \mathsf{copysign}\left(1 \cdot \frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + -1}{\left(1 + \color{blue}{e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}}\right) + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}}, x\right) \]
    7. Applied egg-rr6.2%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{1 \cdot \frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + -1}{1 + \left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{2}\right)}}, x\right) \]
    8. Step-by-step derivation
      1. *-lft-identity6.2%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + -1}{1 + \left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{2}\right)}}, x\right) \]
      2. +-commutative6.2%

        \[\leadsto \mathsf{copysign}\left(\frac{\color{blue}{-1 + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3}}}{1 + \left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{2}\right)}, x\right) \]
    9. Simplified6.2%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\frac{-1 + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3}}{1 + \left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{2}\right)}}, x\right) \]
    10. Taylor expanded in x around 0 67.8%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{x}, x\right) \]

    if 1.55000000000000004 < x

    1. Initial program 48.3%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Step-by-step derivation
      1. +-commutative48.3%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right) \]
      2. hypot-1-def100.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Taylor expanded in x around 0 31.7%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(1 + \left|x\right|\right)}, x\right) \]
    5. Step-by-step derivation
      1. log1p-def31.7%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{log1p}\left(\left|x\right|\right)}, x\right) \]
      2. add-sqr-sqrt31.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|\right), x\right) \]
      3. fabs-sqr31.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right), x\right) \]
      4. add-sqr-sqrt31.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{x}\right), x\right) \]
      5. *-un-lft-identity31.7%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{1 \cdot \mathsf{log1p}\left(x\right)}, x\right) \]
    6. Applied egg-rr31.7%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{1 \cdot \mathsf{log1p}\left(x\right)}, x\right) \]
    7. Step-by-step derivation
      1. *-lft-identity31.7%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{log1p}\left(x\right)}, x\right) \]
    8. Simplified31.7%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{log1p}\left(x\right)}, x\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.4%

    \[\leadsto \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 8: 53.0% accurate, 4.0× speedup?

\[\begin{array}{l} \\ \mathsf{copysign}\left(x, x\right) \end{array} \]
(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}
Derivation
  1. Initial program 28.1%

    \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
  2. Step-by-step derivation
    1. +-commutative28.1%

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right), x\right) \]
    2. hypot-1-def53.1%

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right), x\right) \]
  3. Simplified53.1%

    \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
  4. Step-by-step derivation
    1. expm1-log1p-u52.2%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)\right)}, x\right) \]
    2. expm1-udef52.2%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} - 1}, x\right) \]
    3. flip3--52.3%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\frac{{\left(e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - {1}^{3}}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 \cdot 1 + e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}}, x\right) \]
    4. add-sqr-sqrt26.0%

      \[\leadsto \mathsf{copysign}\left(\frac{{\left(e^{\mathsf{log1p}\left(\log \left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - {1}^{3}}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 \cdot 1 + e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
    5. fabs-sqr26.0%

      \[\leadsto \mathsf{copysign}\left(\frac{{\left(e^{\mathsf{log1p}\left(\log \left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - {1}^{3}}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 \cdot 1 + e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
    6. add-sqr-sqrt27.6%

      \[\leadsto \mathsf{copysign}\left(\frac{{\left(e^{\mathsf{log1p}\left(\log \left(\color{blue}{x} + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - {1}^{3}}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 \cdot 1 + e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
    7. metadata-eval27.6%

      \[\leadsto \mathsf{copysign}\left(\frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - \color{blue}{1}}{e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 \cdot 1 + e^{\mathsf{log1p}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
  5. Applied egg-rr27.7%

    \[\leadsto \mathsf{copysign}\left(\color{blue}{\frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - 1}{e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}}, x\right) \]
  6. Step-by-step derivation
    1. *-un-lft-identity27.7%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{1 \cdot \frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} - 1}{e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}}, x\right) \]
    2. sub-neg27.7%

      \[\leadsto \mathsf{copysign}\left(1 \cdot \frac{\color{blue}{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + \left(-1\right)}}{e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
    3. metadata-eval27.7%

      \[\leadsto \mathsf{copysign}\left(1 \cdot \frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + \color{blue}{-1}}{e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + \left(1 + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right)}, x\right) \]
    4. +-commutative27.7%

      \[\leadsto \mathsf{copysign}\left(1 \cdot \frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + -1}{\color{blue}{\left(1 + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot 1\right) + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}}}, x\right) \]
    5. *-rgt-identity27.7%

      \[\leadsto \mathsf{copysign}\left(1 \cdot \frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + -1}{\left(1 + \color{blue}{e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}}\right) + e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} \cdot e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}}, x\right) \]
  7. Applied egg-rr27.7%

    \[\leadsto \mathsf{copysign}\left(\color{blue}{1 \cdot \frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + -1}{1 + \left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{2}\right)}}, x\right) \]
  8. Step-by-step derivation
    1. *-lft-identity27.7%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\frac{{\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3} + -1}{1 + \left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{2}\right)}}, x\right) \]
    2. +-commutative27.7%

      \[\leadsto \mathsf{copysign}\left(\frac{\color{blue}{-1 + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3}}}{1 + \left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{2}\right)}, x\right) \]
  9. Simplified27.7%

    \[\leadsto \mathsf{copysign}\left(\color{blue}{\frac{-1 + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{3}}{1 + \left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} + {\left(e^{\mathsf{log1p}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)}^{2}\right)}}, x\right) \]
  10. Taylor expanded in x around 0 53.1%

    \[\leadsto \mathsf{copysign}\left(\color{blue}{x}, x\right) \]
  11. Final simplification53.1%

    \[\leadsto \mathsf{copysign}\left(x, x\right) \]

Developer target: 99.9% accurate, 0.6× speedup?

\[\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} \]
(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}

Reproduce

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