Rust f32::asinh

Percentage Accurate: 37.7% → 99.4%
Time: 11.1s
Alternatives: 12
Speedup: 2.0×

Specification

?
\[\begin{array}{l} \\ \sinh^{-1} x \end{array} \]
(FPCore (x) :precision binary32 (asinh x))
float code(float x) {
	return asinhf(x);
}
function code(x)
	return asinh(x)
end
function tmp = code(x)
	tmp = asinh(x);
end
\begin{array}{l}

\\
\sinh^{-1} x
\end{array}

Sampling outcomes in binary32 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 12 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: 37.7% 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 binary32
 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
	return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x)
	return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x)
end
function tmp = code(x)
	tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0))))));
end
\begin{array}{l}

\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}

Alternative 1: 99.4% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.05000000074505806:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\ \mathbf{elif}\;x \leq 0.03999999910593033:\\ \;\;\;\;\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 binary32
 (if (<= x -0.05000000074505806)
   (copysign (log (- (hypot 1.0 x) x)) x)
   (if (<= x 0.03999999910593033)
     (copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
     (copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
	float tmp;
	if (x <= -0.05000000074505806f) {
		tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
	} else if (x <= 0.03999999910593033f) {
		tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
	} else {
		tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-0.05000000074505806))
		tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x);
	elseif (x <= Float32(0.03999999910593033))
		tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x);
	else
		tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-0.05000000074505806))
		tmp = sign(x) * abs(log((hypot(single(1.0), x) - x)));
	elseif (x <= single(0.03999999910593033))
		tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666))));
	else
		tmp = sign(x) * abs(log((x + hypot(single(1.0), x))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\

\mathbf{elif}\;x \leq 0.03999999910593033:\\
\;\;\;\;\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 < -0.0500000007

    1. Initial program 57.8%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative57.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval57.7%

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right) - 1\right), x\right) \]
      7. associate--l+98.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) \]
      8. add-sqr-sqrt-0.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) \]
      9. fabs-sqr-0.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) \]
      10. add-sqr-sqrt15.6%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(1 + \left(\color{blue}{\left(-1 + \mathsf{hypot}\left(1, x\right)\right)} - x\right)\right), x\right) \]
      3. associate--l+98.5%

        \[\leadsto \mathsf{copysign}\left(\log \left(1 + \color{blue}{\left(-1 + \left(\mathsf{hypot}\left(1, x\right) - x\right)\right)}\right), x\right) \]
      4. associate-+r+98.5%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\mathsf{hypot}\left(1, x\right) - x\right)}, x\right) \]
    8. Simplified98.5%

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

    if -0.0500000007 < x < 0.0399999991

    1. Initial program 20.7%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative20.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval20.7%

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

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

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

        \[\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) \]
      9. fabs-sqr54.3%

        \[\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) \]
      10. add-sqr-sqrt97.2%

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

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

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

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

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

    if 0.0399999991 < x

    1. Initial program 51.7%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative51.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval51.7%

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right) - 1\right), x\right) \]
      7. associate--l+98.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) \]
      8. add-sqr-sqrt98.4%

        \[\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) \]
      9. fabs-sqr98.4%

        \[\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) \]
      10. add-sqr-sqrt98.5%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(x + \mathsf{hypot}\left(1, x\right)\right) - 1}\right), x\right) \]
      2. add-exp-log98.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.05000000074505806:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\ \mathbf{elif}\;x \leq 0.03999999910593033:\\ \;\;\;\;\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 2: 98.1% accurate, 0.6× 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 4:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left(\mathsf{hypot}\left(1, x\right) + -1\right) - x\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x) 4.0)
   (copysign (log1p (- (+ (hypot 1.0 x) -1.0) x)) x)
   (copysign (log (/ 0.5 x)) x)))
float code(float x) {
	float tmp;
	if (copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x) <= 4.0f) {
		tmp = copysignf(log1pf(((hypotf(1.0f, x) + -1.0f) - x)), x);
	} else {
		tmp = copysignf(logf((0.5f / x)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) <= Float32(4.0))
		tmp = copysign(log1p(Float32(Float32(hypot(Float32(1.0), x) + Float32(-1.0)) - x)), x);
	else
		tmp = copysign(log(Float32(Float32(0.5) / x)), x);
	end
	return tmp
end
\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 4:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left(\mathsf{hypot}\left(1, x\right) + -1\right) - x\right), x\right)\\

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


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

    1. Initial program 36.2%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval36.1%

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

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

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

        \[\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) \]
      9. fabs-sqr36.6%

        \[\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) \]
      10. add-sqr-sqrt68.6%

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

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

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

    if 4 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x)

    1. Initial program 47.0%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval47.0%

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

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

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

        \[\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) \]
      9. fabs-sqr98.4%

        \[\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) \]
      10. add-sqr-sqrt98.4%

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

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

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

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{0.5 \cdot \frac{1}{x} - 1}\right), x\right) \]
    6. Step-by-step derivation
      1. associate-*r/13.5%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\frac{0.5 \cdot 1}{x}} - 1\right), x\right) \]
      2. metadata-eval13.5%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\frac{\color{blue}{0.5}}{x} - 1\right), x\right) \]
      3. sub-neg13.5%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\frac{0.5}{x} + \left(-1\right)}\right), x\right) \]
      4. metadata-eval13.5%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\frac{0.5}{x} + \color{blue}{-1}\right), x\right) \]
      5. +-commutative13.5%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{-1 + \frac{0.5}{x}}\right), x\right) \]
    7. Simplified13.5%

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{-1 + \frac{0.5}{x}}\right), x\right) \]
    8. Taylor expanded in x around 0 99.0%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log 0.5 + -1 \cdot \log x}, x\right) \]
    9. Step-by-step derivation
      1. mul-1-neg99.0%

        \[\leadsto \mathsf{copysign}\left(\log 0.5 + \color{blue}{\left(-\log x\right)}, x\right) \]
      2. log-rec99.0%

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(0.5 \cdot \frac{1}{x}\right)}, x\right) \]
      4. associate-*r/99.6%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\frac{0.5 \cdot 1}{x}\right)}, x\right) \]
      5. metadata-eval99.6%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{\color{blue}{0.5}}{x}\right), x\right) \]
    10. Simplified99.6%

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

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

Alternative 3: 98.5% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -40:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left(-1 - x\right) - \frac{0.5}{x}\right) - x\right), x\right)\\ \mathbf{elif}\;x \leq 0.03999999910593033:\\ \;\;\;\;\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 binary32
 (if (<= x -40.0)
   (copysign (log1p (- (- (- -1.0 x) (/ 0.5 x)) x)) x)
   (if (<= x 0.03999999910593033)
     (copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
     (copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
	float tmp;
	if (x <= -40.0f) {
		tmp = copysignf(log1pf((((-1.0f - x) - (0.5f / x)) - x)), x);
	} else if (x <= 0.03999999910593033f) {
		tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
	} else {
		tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-40.0))
		tmp = copysign(log1p(Float32(Float32(Float32(Float32(-1.0) - x) - Float32(Float32(0.5) / x)) - x)), x);
	elseif (x <= Float32(0.03999999910593033))
		tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x);
	else
		tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x);
	end
	return tmp
end
\begin{array}{l}

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

\mathbf{elif}\;x \leq 0.03999999910593033:\\
\;\;\;\;\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 < -40

    1. Initial program 56.7%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative56.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval56.7%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left|x\right| + \left(\mathsf{hypot}\left(1, x\right) - 1\right)}\right), x\right) \]
      8. add-sqr-sqrt-0.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) \]
      9. fabs-sqr-0.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) \]
      10. add-sqr-sqrt13.2%

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

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

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

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(-1 \cdot x - \left(1 + 0.5 \cdot \frac{1}{x}\right)\right)} - x\right), x\right) \]
    6. Step-by-step derivation
      1. associate--r+98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left(-1 \cdot x - 1\right) - 0.5 \cdot \frac{1}{x}\right)} - x\right), x\right) \]
      2. mul-1-neg98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left(\color{blue}{\left(-x\right)} - 1\right) - 0.5 \cdot \frac{1}{x}\right) - x\right), x\right) \]
      3. sub-neg98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\color{blue}{\left(\left(-x\right) + \left(-1\right)\right)} - 0.5 \cdot \frac{1}{x}\right) - x\right), x\right) \]
      4. metadata-eval98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left(\left(-x\right) + \color{blue}{-1}\right) - 0.5 \cdot \frac{1}{x}\right) - x\right), x\right) \]
      5. +-commutative98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\color{blue}{\left(-1 + \left(-x\right)\right)} - 0.5 \cdot \frac{1}{x}\right) - x\right), x\right) \]
      6. sub-neg98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\color{blue}{\left(-1 - x\right)} - 0.5 \cdot \frac{1}{x}\right) - x\right), x\right) \]
      7. associate-*r/98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left(-1 - x\right) - \color{blue}{\frac{0.5 \cdot 1}{x}}\right) - x\right), x\right) \]
      8. metadata-eval98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left(-1 - x\right) - \frac{\color{blue}{0.5}}{x}\right) - x\right), x\right) \]
    7. Simplified98.6%

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

    if -40 < x < 0.0399999991

    1. Initial program 21.9%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative21.9%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval21.9%

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

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

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

        \[\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) \]
      9. fabs-sqr53.5%

        \[\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) \]
      10. add-sqr-sqrt97.2%

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

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

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

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

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

    if 0.0399999991 < x

    1. Initial program 51.7%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative51.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval51.7%

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right) - 1\right), x\right) \]
      7. associate--l+98.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) \]
      8. add-sqr-sqrt98.4%

        \[\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) \]
      9. fabs-sqr98.4%

        \[\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) \]
      10. add-sqr-sqrt98.5%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(x + \mathsf{hypot}\left(1, x\right)\right) - 1}\right), x\right) \]
      2. add-exp-log98.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -40:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left(-1 - x\right) - \frac{0.5}{x}\right) - x\right), x\right)\\ \mathbf{elif}\;x \leq 0.03999999910593033:\\ \;\;\;\;\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 4: 98.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.4000000059604645:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - 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 binary32
 (if (<= x -0.4000000059604645)
   (copysign (log (- (hypot 1.0 x) x)) x)
   (copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
float code(float x) {
	float tmp;
	if (x <= -0.4000000059604645f) {
		tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
	} else {
		tmp = copysignf(log1pf((x + (hypotf(1.0f, x) + -1.0f))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-0.4000000059604645))
		tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x);
	else
		tmp = copysign(log1p(Float32(x + Float32(hypot(Float32(1.0), x) + Float32(-1.0)))), x);
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - 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 < -0.400000006

    1. Initial program 57.3%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative57.3%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval57.3%

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right) - 1\right), x\right) \]
      7. associate--l+98.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) \]
      8. add-sqr-sqrt-0.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) \]
      9. fabs-sqr-0.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) \]
      10. add-sqr-sqrt14.4%

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

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

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\mathsf{hypot}\left(1, x\right) + -1\right) - x}\right), x\right) \]
    5. Step-by-step derivation
      1. log1p-udef98.6%

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

        \[\leadsto \mathsf{copysign}\left(\log \left(1 + \left(\color{blue}{\left(-1 + \mathsf{hypot}\left(1, x\right)\right)} - x\right)\right), x\right) \]
      3. associate--l+98.6%

        \[\leadsto \mathsf{copysign}\left(\log \left(1 + \color{blue}{\left(-1 + \left(\mathsf{hypot}\left(1, x\right) - x\right)\right)}\right), x\right) \]
      4. associate-+r+98.6%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\mathsf{hypot}\left(1, x\right) - x\right)}, x\right) \]
    8. Simplified98.6%

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

    if -0.400000006 < x

    1. Initial program 32.0%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval32.0%

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

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

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

        \[\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) \]
      9. fabs-sqr69.5%

        \[\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) \]
      10. add-sqr-sqrt97.7%

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

      \[\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 simplification97.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.4000000059604645:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - 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 5: 98.1% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -40:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -40.0)
   (copysign (log (/ -0.5 x)) x)
   (if (<= x 0.5)
     (copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
     (copysign (log (+ (* x 2.0) (* 0.5 (/ 1.0 x)))) x))))
float code(float x) {
	float tmp;
	if (x <= -40.0f) {
		tmp = copysignf(logf((-0.5f / x)), x);
	} else if (x <= 0.5f) {
		tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
	} else {
		tmp = copysignf(logf(((x * 2.0f) + (0.5f * (1.0f / x)))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-40.0))
		tmp = copysign(log(Float32(Float32(-0.5) / x)), x);
	elseif (x <= Float32(0.5))
		tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x);
	else
		tmp = copysign(log(Float32(Float32(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(Float32(1.0) / x)))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-40.0))
		tmp = sign(x) * abs(log((single(-0.5) / x)));
	elseif (x <= single(0.5))
		tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666))));
	else
		tmp = sign(x) * abs(log(((x * single(2.0)) + (single(0.5) * (single(1.0) / x)))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

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

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

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


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

    1. Initial program 56.7%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative56.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval56.7%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left|x\right| + \left(\mathsf{hypot}\left(1, x\right) - 1\right)}\right), x\right) \]
      8. add-sqr-sqrt-0.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) \]
      9. fabs-sqr-0.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) \]
      10. add-sqr-sqrt13.2%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(x + \mathsf{hypot}\left(1, x\right)\right) - 1}\right), x\right) \]
      2. add-exp-log13.5%

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

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

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

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

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

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

    if -40 < x < 0.5

    1. Initial program 23.1%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval23.1%

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

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

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

        \[\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) \]
      9. fabs-sqr54.2%

        \[\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) \]
      10. add-sqr-sqrt97.2%

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

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

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

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

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

    if 0.5 < x

    1. Initial program 50.3%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative50.3%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval50.3%

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right) - 1\right), x\right) \]
      7. associate--l+98.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) \]
      8. add-sqr-sqrt98.4%

        \[\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) \]
      9. fabs-sqr98.4%

        \[\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) \]
      10. add-sqr-sqrt98.5%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(x + \mathsf{hypot}\left(1, x\right)\right) - 1}\right), x\right) \]
      2. add-exp-log98.5%

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

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

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

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

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

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

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

Alternative 6: 97.9% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -40:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left(-1 - x\right) - \frac{0.5}{x}\right) - x\right), x\right)\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -40.0)
   (copysign (log1p (- (- (- -1.0 x) (/ 0.5 x)) x)) x)
   (if (<= x 0.5)
     (copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
     (copysign (log (+ (* x 2.0) (* 0.5 (/ 1.0 x)))) x))))
float code(float x) {
	float tmp;
	if (x <= -40.0f) {
		tmp = copysignf(log1pf((((-1.0f - x) - (0.5f / x)) - x)), x);
	} else if (x <= 0.5f) {
		tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
	} else {
		tmp = copysignf(logf(((x * 2.0f) + (0.5f * (1.0f / x)))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-40.0))
		tmp = copysign(log1p(Float32(Float32(Float32(Float32(-1.0) - x) - Float32(Float32(0.5) / x)) - x)), x);
	elseif (x <= Float32(0.5))
		tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x);
	else
		tmp = copysign(log(Float32(Float32(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(Float32(1.0) / x)))), x);
	end
	return tmp
end
\begin{array}{l}

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

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

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


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

    1. Initial program 56.7%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative56.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval56.7%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left|x\right| + \left(\mathsf{hypot}\left(1, x\right) - 1\right)}\right), x\right) \]
      8. add-sqr-sqrt-0.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) \]
      9. fabs-sqr-0.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) \]
      10. add-sqr-sqrt13.2%

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

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

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

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(-1 \cdot x - \left(1 + 0.5 \cdot \frac{1}{x}\right)\right)} - x\right), x\right) \]
    6. Step-by-step derivation
      1. associate--r+98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left(-1 \cdot x - 1\right) - 0.5 \cdot \frac{1}{x}\right)} - x\right), x\right) \]
      2. mul-1-neg98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left(\color{blue}{\left(-x\right)} - 1\right) - 0.5 \cdot \frac{1}{x}\right) - x\right), x\right) \]
      3. sub-neg98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\color{blue}{\left(\left(-x\right) + \left(-1\right)\right)} - 0.5 \cdot \frac{1}{x}\right) - x\right), x\right) \]
      4. metadata-eval98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left(\left(-x\right) + \color{blue}{-1}\right) - 0.5 \cdot \frac{1}{x}\right) - x\right), x\right) \]
      5. +-commutative98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\color{blue}{\left(-1 + \left(-x\right)\right)} - 0.5 \cdot \frac{1}{x}\right) - x\right), x\right) \]
      6. sub-neg98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\color{blue}{\left(-1 - x\right)} - 0.5 \cdot \frac{1}{x}\right) - x\right), x\right) \]
      7. associate-*r/98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left(-1 - x\right) - \color{blue}{\frac{0.5 \cdot 1}{x}}\right) - x\right), x\right) \]
      8. metadata-eval98.6%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left(-1 - x\right) - \frac{\color{blue}{0.5}}{x}\right) - x\right), x\right) \]
    7. Simplified98.6%

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

    if -40 < x < 0.5

    1. Initial program 23.1%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval23.1%

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

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

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

        \[\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) \]
      9. fabs-sqr54.2%

        \[\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) \]
      10. add-sqr-sqrt97.2%

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

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

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

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

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

    if 0.5 < x

    1. Initial program 50.3%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative50.3%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval50.3%

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right) - 1\right), x\right) \]
      7. associate--l+98.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) \]
      8. add-sqr-sqrt98.4%

        \[\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) \]
      9. fabs-sqr98.4%

        \[\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) \]
      10. add-sqr-sqrt98.5%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(x + \mathsf{hypot}\left(1, x\right)\right) - 1}\right), x\right) \]
      2. add-exp-log98.5%

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

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

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

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

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

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

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

Alternative 7: 97.9% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -40:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -40.0)
   (copysign (log (/ -0.5 x)) x)
   (if (<= x 0.5)
     (copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
     (copysign (log (/ 0.5 x)) x))))
float code(float x) {
	float tmp;
	if (x <= -40.0f) {
		tmp = copysignf(logf((-0.5f / x)), x);
	} else if (x <= 0.5f) {
		tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
	} else {
		tmp = copysignf(logf((0.5f / x)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-40.0))
		tmp = copysign(log(Float32(Float32(-0.5) / x)), x);
	elseif (x <= Float32(0.5))
		tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x);
	else
		tmp = copysign(log(Float32(Float32(0.5) / x)), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-40.0))
		tmp = sign(x) * abs(log((single(-0.5) / x)));
	elseif (x <= single(0.5))
		tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666))));
	else
		tmp = sign(x) * abs(log((single(0.5) / x)));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

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

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

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


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

    1. Initial program 56.7%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative56.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval56.7%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left|x\right| + \left(\mathsf{hypot}\left(1, x\right) - 1\right)}\right), x\right) \]
      8. add-sqr-sqrt-0.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) \]
      9. fabs-sqr-0.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) \]
      10. add-sqr-sqrt13.2%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(x + \mathsf{hypot}\left(1, x\right)\right) - 1}\right), x\right) \]
      2. add-exp-log13.5%

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

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

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

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

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

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

    if -40 < x < 0.5

    1. Initial program 23.1%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval23.1%

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

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

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

        \[\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) \]
      9. fabs-sqr54.2%

        \[\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) \]
      10. add-sqr-sqrt97.2%

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

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

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

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

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

    if 0.5 < x

    1. Initial program 50.3%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative50.3%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval50.3%

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right) - 1\right), x\right) \]
      7. associate--l+98.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) \]
      8. add-sqr-sqrt98.4%

        \[\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) \]
      9. fabs-sqr98.4%

        \[\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) \]
      10. add-sqr-sqrt98.5%

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

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

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

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{0.5 \cdot \frac{1}{x} - 1}\right), x\right) \]
    6. Step-by-step derivation
      1. associate-*r/15.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\frac{0.5 \cdot 1}{x}} - 1\right), x\right) \]
      2. metadata-eval15.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\frac{\color{blue}{0.5}}{x} - 1\right), x\right) \]
      3. sub-neg15.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\frac{0.5}{x} + \left(-1\right)}\right), x\right) \]
      4. metadata-eval15.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\frac{0.5}{x} + \color{blue}{-1}\right), x\right) \]
      5. +-commutative15.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{-1 + \frac{0.5}{x}}\right), x\right) \]
    7. Simplified15.7%

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{-1 + \frac{0.5}{x}}\right), x\right) \]
    8. Taylor expanded in x around 0 95.8%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log 0.5 + -1 \cdot \log x}, x\right) \]
    9. Step-by-step derivation
      1. mul-1-neg95.8%

        \[\leadsto \mathsf{copysign}\left(\log 0.5 + \color{blue}{\left(-\log x\right)}, x\right) \]
      2. log-rec95.8%

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(0.5 \cdot \frac{1}{x}\right)}, x\right) \]
      4. associate-*r/96.4%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\frac{0.5 \cdot 1}{x}\right)}, x\right) \]
      5. metadata-eval96.4%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{\color{blue}{0.5}}{x}\right), x\right) \]
    10. Simplified96.4%

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

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

Alternative 8: 81.5% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -40:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 1.9999999949504854 \cdot 10^{-6}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-x\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + 1\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -40.0)
   (copysign (log (/ -0.5 x)) x)
   (if (<= x 1.9999999949504854e-6)
     (copysign (log1p (- x)) x)
     (copysign (log (+ x 1.0)) x))))
float code(float x) {
	float tmp;
	if (x <= -40.0f) {
		tmp = copysignf(logf((-0.5f / x)), x);
	} else if (x <= 1.9999999949504854e-6f) {
		tmp = copysignf(log1pf(-x), x);
	} else {
		tmp = copysignf(logf((x + 1.0f)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-40.0))
		tmp = copysign(log(Float32(Float32(-0.5) / x)), x);
	elseif (x <= Float32(1.9999999949504854e-6))
		tmp = copysign(log1p(Float32(-x)), x);
	else
		tmp = copysign(log(Float32(x + Float32(1.0))), x);
	end
	return tmp
end
\begin{array}{l}

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

\mathbf{elif}\;x \leq 1.9999999949504854 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-x\right), x\right)\\

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


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

    1. Initial program 56.7%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative56.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval56.7%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left|x\right| + \left(\mathsf{hypot}\left(1, x\right) - 1\right)}\right), x\right) \]
      8. add-sqr-sqrt-0.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) \]
      9. fabs-sqr-0.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) \]
      10. add-sqr-sqrt13.2%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(x + \mathsf{hypot}\left(1, x\right)\right) - 1}\right), x\right) \]
      2. add-exp-log13.5%

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

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

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

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

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

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

    if -40 < x < 1.99999999e-6

    1. Initial program 18.4%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval18.4%

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

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

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

        \[\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) \]
      9. fabs-sqr51.6%

        \[\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) \]
      10. add-sqr-sqrt98.0%

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

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

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\mathsf{hypot}\left(1, x\right) + -1\right) - x}\right), x\right) \]
    5. Taylor expanded in x around 0 96.3%

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{-1 \cdot x}\right), x\right) \]
    6. Step-by-step derivation
      1. mul-1-neg96.3%

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

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

    if 1.99999999e-6 < x

    1. Initial program 54.4%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval54.4%

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

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

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

        \[\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) \]
      9. fabs-sqr97.1%

        \[\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) \]
      10. add-sqr-sqrt97.1%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(x + \mathsf{hypot}\left(1, x\right)\right) - 1}\right), x\right) \]
      2. add-exp-log96.8%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -40:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 1.9999999949504854 \cdot 10^{-6}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-x\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + 1\right), x\right)\\ \end{array} \]

Alternative 9: 95.4% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -40:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-x\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -40.0)
   (copysign (log (/ -0.5 x)) x)
   (if (<= x 0.5) (copysign (log1p (- x)) x) (copysign (log (/ 0.5 x)) x))))
float code(float x) {
	float tmp;
	if (x <= -40.0f) {
		tmp = copysignf(logf((-0.5f / x)), x);
	} else if (x <= 0.5f) {
		tmp = copysignf(log1pf(-x), x);
	} else {
		tmp = copysignf(logf((0.5f / x)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-40.0))
		tmp = copysign(log(Float32(Float32(-0.5) / x)), x);
	elseif (x <= Float32(0.5))
		tmp = copysign(log1p(Float32(-x)), x);
	else
		tmp = copysign(log(Float32(Float32(0.5) / x)), x);
	end
	return tmp
end
\begin{array}{l}

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

\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-x\right), x\right)\\

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


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

    1. Initial program 56.7%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative56.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval56.7%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left|x\right| + \left(\mathsf{hypot}\left(1, x\right) - 1\right)}\right), x\right) \]
      8. add-sqr-sqrt-0.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) \]
      9. fabs-sqr-0.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) \]
      10. add-sqr-sqrt13.2%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(x + \mathsf{hypot}\left(1, x\right)\right) - 1}\right), x\right) \]
      2. add-exp-log13.5%

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

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

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

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

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

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

    if -40 < x < 0.5

    1. Initial program 23.1%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval23.1%

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

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

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

        \[\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) \]
      9. fabs-sqr54.2%

        \[\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) \]
      10. add-sqr-sqrt97.2%

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

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

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\mathsf{hypot}\left(1, x\right) + -1\right) - x}\right), x\right) \]
    5. Taylor expanded in x around 0 93.1%

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{-1 \cdot x}\right), x\right) \]
    6. Step-by-step derivation
      1. mul-1-neg93.1%

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

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

    if 0.5 < x

    1. Initial program 50.3%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
      4. +-commutative50.3%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval50.3%

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \color{blue}{\mathsf{hypot}\left(1, x\right)}\right) - 1\right), x\right) \]
      7. associate--l+98.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) \]
      8. add-sqr-sqrt98.4%

        \[\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) \]
      9. fabs-sqr98.4%

        \[\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) \]
      10. add-sqr-sqrt98.5%

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

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

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

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{0.5 \cdot \frac{1}{x} - 1}\right), x\right) \]
    6. Step-by-step derivation
      1. associate-*r/15.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\frac{0.5 \cdot 1}{x}} - 1\right), x\right) \]
      2. metadata-eval15.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\frac{\color{blue}{0.5}}{x} - 1\right), x\right) \]
      3. sub-neg15.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\frac{0.5}{x} + \left(-1\right)}\right), x\right) \]
      4. metadata-eval15.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\frac{0.5}{x} + \color{blue}{-1}\right), x\right) \]
      5. +-commutative15.7%

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{-1 + \frac{0.5}{x}}\right), x\right) \]
    7. Simplified15.7%

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{-1 + \frac{0.5}{x}}\right), x\right) \]
    8. Taylor expanded in x around 0 95.8%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log 0.5 + -1 \cdot \log x}, x\right) \]
    9. Step-by-step derivation
      1. mul-1-neg95.8%

        \[\leadsto \mathsf{copysign}\left(\log 0.5 + \color{blue}{\left(-\log x\right)}, x\right) \]
      2. log-rec95.8%

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(0.5 \cdot \frac{1}{x}\right)}, x\right) \]
      4. associate-*r/96.4%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\frac{0.5 \cdot 1}{x}\right)}, x\right) \]
      5. metadata-eval96.4%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{\color{blue}{0.5}}{x}\right), x\right) \]
    10. Simplified96.4%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\frac{0.5}{x}\right)}, x\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification95.3%

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

Alternative 10: 68.6% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.9999999949504854 \cdot 10^{-6}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-x\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + 1\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x 1.9999999949504854e-6)
   (copysign (log1p (- x)) x)
   (copysign (log (+ x 1.0)) x)))
float code(float x) {
	float tmp;
	if (x <= 1.9999999949504854e-6f) {
		tmp = copysignf(log1pf(-x), x);
	} else {
		tmp = copysignf(logf((x + 1.0f)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(1.9999999949504854e-6))
		tmp = copysign(log1p(Float32(-x)), x);
	else
		tmp = copysign(log(Float32(x + Float32(1.0))), x);
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.9999999949504854 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-x\right), x\right)\\

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


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

    1. Initial program 32.4%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval32.4%

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

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

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

        \[\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) \]
      9. fabs-sqr32.7%

        \[\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) \]
      10. add-sqr-sqrt67.0%

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

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

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\mathsf{hypot}\left(1, x\right) + -1\right) - x}\right), x\right) \]
    5. Taylor expanded in x around 0 77.1%

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{-1 \cdot x}\right), x\right) \]
    6. Step-by-step derivation
      1. mul-1-neg77.1%

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

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

    if 1.99999999e-6 < x

    1. Initial program 54.4%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
      5. metadata-eval54.4%

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

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

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

        \[\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) \]
      9. fabs-sqr97.1%

        \[\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) \]
      10. add-sqr-sqrt97.1%

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(x + \mathsf{hypot}\left(1, x\right)\right) - 1}\right), x\right) \]
      2. add-exp-log96.8%

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

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

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

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

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

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

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

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

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

Alternative 11: 57.6% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \mathsf{copysign}\left(\mathsf{log1p}\left(-x\right), x\right) \end{array} \]
(FPCore (x) :precision binary32 (copysign (log1p (- x)) x))
float code(float x) {
	return copysignf(log1pf(-x), x);
}
function code(x)
	return copysign(log1p(Float32(-x)), x)
end
\begin{array}{l}

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
    4. +-commutative38.7%

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
    5. metadata-eval38.7%

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

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

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

      \[\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) \]
    9. fabs-sqr51.1%

      \[\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) \]
    10. add-sqr-sqrt75.6%

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

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

    \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\mathsf{hypot}\left(1, x\right) + -1\right) - x}\right), x\right) \]
  5. Taylor expanded in x around 0 56.9%

    \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{-1 \cdot x}\right), x\right) \]
  6. Step-by-step derivation
    1. mul-1-neg56.9%

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

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

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

Alternative 12: 8.4% accurate, 4.0× speedup?

\[\begin{array}{l} \\ \mathsf{copysign}\left(0, x\right) \end{array} \]
(FPCore (x) :precision binary32 (copysign 0.0 x))
float code(float x) {
	return copysignf(0.0f, x);
}
function code(x)
	return copysign(Float32(0.0), x)
end
function tmp = code(x)
	tmp = sign(x) * abs(single(0.0));
end
\begin{array}{l}

\\
\mathsf{copysign}\left(0, x\right)
\end{array}
Derivation
  1. Initial program 38.7%

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

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

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

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} - 1\right), x\right) \]
    4. +-commutative38.7%

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\left(\left|x\right| + \sqrt{\color{blue}{1 + x \cdot x}}\right) - 1\right), x\right) \]
    5. metadata-eval38.7%

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

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

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

      \[\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) \]
    9. fabs-sqr51.1%

      \[\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) \]
    10. add-sqr-sqrt75.6%

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

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

      \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(x + \mathsf{hypot}\left(1, x\right)\right) - 1}\right), x\right) \]
    2. add-exp-log39.5%

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

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

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

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

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

    \[\leadsto \mathsf{copysign}\left(\log \color{blue}{1}, x\right) \]
  7. Final simplification8.3%

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

Developer target: 99.5% 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 binary32
 (let* ((t_0 (/ 1.0 (fabs x))))
   (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 t_0) t_0)))) x)))
float code(float x) {
	float t_0 = 1.0f / fabsf(x);
	return copysignf(log1pf((fabsf(x) + (fabsf(x) / (hypotf(1.0f, t_0) + t_0)))), x);
}
function code(x)
	t_0 = Float32(Float32(1.0) / abs(x))
	return copysign(log1p(Float32(abs(x) + Float32(abs(x) / Float32(hypot(Float32(1.0), t_0) + t_0)))), x)
end
\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 2023305 
(FPCore (x)
  :name "Rust f32::asinh"
  :precision binary32

  :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))