Average Error: 53.1 → 0.1
Time: 18.6s
Precision: binary64
Cost: 20932
\[\log \left(x + \sqrt{x \cdot x + 1}\right) \]
\[\begin{array}{l} \mathbf{if}\;x \leq -1.02:\\ \;\;\;\;\log \left(\left(-0.125 \cdot \frac{\frac{-1}{x \cdot x}}{x} + \left(0.0390625 \cdot {x}^{-7} + -0.0625 \cdot {x}^{-5}\right)\right) - 0.5 \cdot \frac{1}{x}\right)\\ \mathbf{elif}\;x \leq 0.0076:\\ \;\;\;\;\left(\left(-0.16666666666666666 \cdot x\right) \cdot x\right) \cdot x + \left(0.075 \cdot {x}^{5} + x\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(x + \mathsf{hypot}\left(x, 1\right)\right)\\ \end{array} \]
(FPCore (x) :precision binary64 (log (+ x (sqrt (+ (* x x) 1.0)))))
(FPCore (x)
 :precision binary64
 (if (<= x -1.02)
   (log
    (-
     (+
      (* -0.125 (/ (/ -1.0 (* x x)) x))
      (+ (* 0.0390625 (pow x -7.0)) (* -0.0625 (pow x -5.0))))
     (* 0.5 (/ 1.0 x))))
   (if (<= x 0.0076)
     (+ (* (* (* -0.16666666666666666 x) x) x) (+ (* 0.075 (pow x 5.0)) x))
     (log (+ x (hypot x 1.0))))))
double code(double x) {
	return log((x + sqrt(((x * x) + 1.0))));
}
double code(double x) {
	double tmp;
	if (x <= -1.02) {
		tmp = log((((-0.125 * ((-1.0 / (x * x)) / x)) + ((0.0390625 * pow(x, -7.0)) + (-0.0625 * pow(x, -5.0)))) - (0.5 * (1.0 / x))));
	} else if (x <= 0.0076) {
		tmp = (((-0.16666666666666666 * x) * x) * x) + ((0.075 * pow(x, 5.0)) + x);
	} else {
		tmp = log((x + hypot(x, 1.0)));
	}
	return tmp;
}
public static double code(double x) {
	return Math.log((x + Math.sqrt(((x * x) + 1.0))));
}
public static double code(double x) {
	double tmp;
	if (x <= -1.02) {
		tmp = Math.log((((-0.125 * ((-1.0 / (x * x)) / x)) + ((0.0390625 * Math.pow(x, -7.0)) + (-0.0625 * Math.pow(x, -5.0)))) - (0.5 * (1.0 / x))));
	} else if (x <= 0.0076) {
		tmp = (((-0.16666666666666666 * x) * x) * x) + ((0.075 * Math.pow(x, 5.0)) + x);
	} else {
		tmp = Math.log((x + Math.hypot(x, 1.0)));
	}
	return tmp;
}
def code(x):
	return math.log((x + math.sqrt(((x * x) + 1.0))))
def code(x):
	tmp = 0
	if x <= -1.02:
		tmp = math.log((((-0.125 * ((-1.0 / (x * x)) / x)) + ((0.0390625 * math.pow(x, -7.0)) + (-0.0625 * math.pow(x, -5.0)))) - (0.5 * (1.0 / x))))
	elif x <= 0.0076:
		tmp = (((-0.16666666666666666 * x) * x) * x) + ((0.075 * math.pow(x, 5.0)) + x)
	else:
		tmp = math.log((x + math.hypot(x, 1.0)))
	return tmp
function code(x)
	return log(Float64(x + sqrt(Float64(Float64(x * x) + 1.0))))
end
function code(x)
	tmp = 0.0
	if (x <= -1.02)
		tmp = log(Float64(Float64(Float64(-0.125 * Float64(Float64(-1.0 / Float64(x * x)) / x)) + Float64(Float64(0.0390625 * (x ^ -7.0)) + Float64(-0.0625 * (x ^ -5.0)))) - Float64(0.5 * Float64(1.0 / x))));
	elseif (x <= 0.0076)
		tmp = Float64(Float64(Float64(Float64(-0.16666666666666666 * x) * x) * x) + Float64(Float64(0.075 * (x ^ 5.0)) + x));
	else
		tmp = log(Float64(x + hypot(x, 1.0)));
	end
	return tmp
end
function tmp = code(x)
	tmp = log((x + sqrt(((x * x) + 1.0))));
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -1.02)
		tmp = log((((-0.125 * ((-1.0 / (x * x)) / x)) + ((0.0390625 * (x ^ -7.0)) + (-0.0625 * (x ^ -5.0)))) - (0.5 * (1.0 / x))));
	elseif (x <= 0.0076)
		tmp = (((-0.16666666666666666 * x) * x) * x) + ((0.075 * (x ^ 5.0)) + x);
	else
		tmp = log((x + hypot(x, 1.0)));
	end
	tmp_2 = tmp;
end
code[x_] := N[Log[N[(x + N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_] := If[LessEqual[x, -1.02], N[Log[N[(N[(N[(-0.125 * N[(N[(-1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + N[(N[(0.0390625 * N[Power[x, -7.0], $MachinePrecision]), $MachinePrecision] + N[(-0.0625 * N[Power[x, -5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 0.0076], N[(N[(N[(N[(-0.16666666666666666 * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] + N[(N[(0.075 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[Log[N[(x + N[Sqrt[x ^ 2 + 1.0 ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\log \left(x + \sqrt{x \cdot x + 1}\right)
\begin{array}{l}
\mathbf{if}\;x \leq -1.02:\\
\;\;\;\;\log \left(\left(-0.125 \cdot \frac{\frac{-1}{x \cdot x}}{x} + \left(0.0390625 \cdot {x}^{-7} + -0.0625 \cdot {x}^{-5}\right)\right) - 0.5 \cdot \frac{1}{x}\right)\\

\mathbf{elif}\;x \leq 0.0076:\\
\;\;\;\;\left(\left(-0.16666666666666666 \cdot x\right) \cdot x\right) \cdot x + \left(0.075 \cdot {x}^{5} + x\right)\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original53.1
Target45.3
Herbie0.1
\[\begin{array}{l} \mathbf{if}\;x < 0:\\ \;\;\;\;\log \left(\frac{-1}{x - \sqrt{x \cdot x + 1}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(x + \sqrt{x \cdot x + 1}\right)\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if x < -1.02

    1. Initial program 62.9

      \[\log \left(x + \sqrt{x \cdot x + 1}\right) \]
    2. Simplified62.9

      \[\leadsto \color{blue}{\log \left(x + \mathsf{hypot}\left(x, 1\right)\right)} \]
      Proof
    3. Taylor expanded in x around -inf 0.2

      \[\leadsto \log \color{blue}{\left(\left(-0.125 \cdot {\left(\frac{-1}{x}\right)}^{3} + \left(0.0625 \cdot {\left(\frac{-1}{x}\right)}^{5} + -0.0390625 \cdot {\left(\frac{-1}{x}\right)}^{7}\right)\right) - 0.5 \cdot \frac{1}{x}\right)} \]
    4. Applied egg-rr0.2

      \[\leadsto \log \left(\left(-0.125 \cdot \color{blue}{\frac{\frac{-1}{x \cdot x}}{x}} + \left(0.0625 \cdot {\left(\frac{-1}{x}\right)}^{5} + -0.0390625 \cdot {\left(\frac{-1}{x}\right)}^{7}\right)\right) - 0.5 \cdot \frac{1}{x}\right) \]
    5. Taylor expanded in x around 0 0.2

      \[\leadsto \log \left(\left(-0.125 \cdot \frac{\frac{-1}{x \cdot x}}{x} + \color{blue}{\left(0.0390625 \cdot {x}^{-7} + -0.0625 \cdot {x}^{-5}\right)}\right) - 0.5 \cdot \frac{1}{x}\right) \]

    if -1.02 < x < 0.00759999999999999998

    1. Initial program 58.7

      \[\log \left(x + \sqrt{x \cdot x + 1}\right) \]
    2. Simplified58.7

      \[\leadsto \color{blue}{\log \left(x + \mathsf{hypot}\left(x, 1\right)\right)} \]
      Proof
    3. Taylor expanded in x around 0 0.1

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot {x}^{3} + \left(0.075 \cdot {x}^{5} + x\right)} \]
    4. Applied egg-rr0.1

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

    if 0.00759999999999999998 < x

    1. Initial program 31.9

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

      \[\leadsto \color{blue}{\log \left(x + \mathsf{hypot}\left(x, 1\right)\right)} \]
      Proof
  3. Recombined 3 regimes into one program.

Alternatives

Alternative 1
Error0.1
Cost14276
\[\begin{array}{l} \mathbf{if}\;x \leq -1.05:\\ \;\;\;\;\log \left(\left(-0.125 \cdot \frac{\frac{-1}{x \cdot x}}{x} + 0.0625 \cdot \left(-{x}^{-5}\right)\right) - 0.5 \cdot \frac{1}{x}\right)\\ \mathbf{elif}\;x \leq 0.0076:\\ \;\;\;\;\left(\left(-0.16666666666666666 \cdot x\right) \cdot x\right) \cdot x + \left(0.075 \cdot {x}^{5} + x\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(x + \mathsf{hypot}\left(x, 1\right)\right)\\ \end{array} \]
Alternative 2
Error0.2
Cost13320
\[\begin{array}{l} \mathbf{if}\;x \leq -1.12:\\ \;\;\;\;\log \left(\frac{-0.5 + \frac{0.125}{x \cdot x}}{x}\right)\\ \mathbf{elif}\;x \leq 0.0076:\\ \;\;\;\;\left(\left(-0.16666666666666666 \cdot x\right) \cdot x\right) \cdot x + \left(0.075 \cdot {x}^{5} + x\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(x + \mathsf{hypot}\left(x, 1\right)\right)\\ \end{array} \]
Alternative 3
Error0.3
Cost7560
\[\begin{array}{l} \mathbf{if}\;x \leq -1.12:\\ \;\;\;\;\log \left(\frac{-0.5 + \frac{0.125}{x \cdot x}}{x}\right)\\ \mathbf{elif}\;x \leq 1.3:\\ \;\;\;\;\left(\left(-0.16666666666666666 \cdot x\right) \cdot x\right) \cdot x + \left(0.075 \cdot {x}^{5} + x\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(2 \cdot x\right)\\ \end{array} \]
Alternative 4
Error0.4
Cost7108
\[\begin{array}{l} \mathbf{if}\;x \leq -1.1:\\ \;\;\;\;\log \left(\frac{-0.5 + \frac{0.125}{x \cdot x}}{x}\right)\\ \mathbf{elif}\;x \leq 1.25:\\ \;\;\;\;\left(\left(-0.16666666666666666 \cdot x\right) \cdot x\right) \cdot x + x\\ \mathbf{else}:\\ \;\;\;\;\log \left(2 \cdot x\right)\\ \end{array} \]
Alternative 5
Error0.5
Cost6856
\[\begin{array}{l} \mathbf{if}\;x \leq -1.25:\\ \;\;\;\;\log \left(\frac{-0.5}{x}\right)\\ \mathbf{elif}\;x \leq 1.25:\\ \;\;\;\;\left(\left(-0.16666666666666666 \cdot x\right) \cdot x\right) \cdot x + x\\ \mathbf{else}:\\ \;\;\;\;\log \left(2 \cdot x\right)\\ \end{array} \]
Alternative 6
Error15.9
Cost6724
\[\begin{array}{l} \mathbf{if}\;x \leq 1.25:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\log \left(2 \cdot x\right)\\ \end{array} \]
Alternative 7
Error30.7
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (x)
  :name "Hyperbolic arcsine"
  :precision binary64

  :herbie-target
  (if (< x 0.0) (log (/ -1.0 (- x (sqrt (+ (* x x) 1.0))))) (log (+ x (sqrt (+ (* x x) 1.0)))))

  (log (+ x (sqrt (+ (* x x) 1.0)))))