Rust f32::asinh

Percentage Accurate: 37.7% → 99.6%
Time: 29.7s
Alternatives: 12
Speedup: 4.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.6% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\ \mathbf{if}\;t\_0 \leq -0.10000000149011612:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\ \mathbf{elif}\;t\_0 \leq 0.10000000149011612:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left({x}^{2}, {x}^{2} \cdot \left(\frac{-0.125}{x + 1} + \frac{-0.125}{{\left(x + 1\right)}^{2}}\right) + \frac{0.5}{x + 1}, \mathsf{log1p}\left(x\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
   (if (<= t_0 -0.10000000149011612)
     (copysign (- (log (- (hypot 1.0 x) x))) x)
     (if (<= t_0 0.10000000149011612)
       (copysign
        (fma
         (pow x 2.0)
         (+
          (*
           (pow x 2.0)
           (+ (/ -0.125 (+ x 1.0)) (/ -0.125 (pow (+ x 1.0) 2.0))))
          (/ 0.5 (+ x 1.0)))
         (log1p x))
        x)
       (copysign (log (+ (fabs x) (hypot 1.0 x))) x)))))
float code(float x) {
	float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
	float tmp;
	if (t_0 <= -0.10000000149011612f) {
		tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
	} else if (t_0 <= 0.10000000149011612f) {
		tmp = copysignf(fmaf(powf(x, 2.0f), ((powf(x, 2.0f) * ((-0.125f / (x + 1.0f)) + (-0.125f / powf((x + 1.0f), 2.0f)))) + (0.5f / (x + 1.0f))), log1pf(x)), x);
	} else {
		tmp = copysignf(logf((fabsf(x) + hypotf(1.0f, x))), x);
	}
	return tmp;
}
function code(x)
	t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x)
	tmp = Float32(0.0)
	if (t_0 <= Float32(-0.10000000149011612))
		tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x);
	elseif (t_0 <= Float32(0.10000000149011612))
		tmp = copysign(fma((x ^ Float32(2.0)), Float32(Float32((x ^ Float32(2.0)) * Float32(Float32(Float32(-0.125) / Float32(x + Float32(1.0))) + Float32(Float32(-0.125) / (Float32(x + Float32(1.0)) ^ Float32(2.0))))) + Float32(Float32(0.5) / Float32(x + Float32(1.0)))), log1p(x)), x);
	else
		tmp = copysign(log(Float32(abs(x) + hypot(Float32(1.0), x))), x);
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\

\mathbf{elif}\;t\_0 \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left({x}^{2}, {x}^{2} \cdot \left(\frac{-0.125}{x + 1} + \frac{-0.125}{{\left(x + 1\right)}^{2}}\right) + \frac{0.5}{x + 1}, \mathsf{log1p}\left(x\right)\right), x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -0.100000001

    1. Initial program 58.3%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(-\left(\left|x\right| \cdot \left|x\right| - \sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}\right)\right) - \log \left(-\left(\left|x\right| - \sqrt{x \cdot x + 1}\right)\right)}, x\right) \]
    4. Applied egg-rr13.8%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(-\left({x}^{2} - \mathsf{fma}\left(x, x, 1\right)\right)\right) - \log \left(-\left(x - \mathsf{hypot}\left(1, x\right)\right)\right)}, x\right) \]
    5. Step-by-step derivation
      1. fma-undefine13.8%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{1} - \log \left(-\left(x - \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
      7. metadata-eval99.9%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{0} - \log \left(-\left(x - \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
      8. neg-sub099.9%

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

        \[\leadsto \mathsf{copysign}\left(0 - \log \color{blue}{\left(\left(0 - x\right) + \mathsf{hypot}\left(1, x\right)\right)}, x\right) \]
      10. neg-sub099.9%

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

        \[\leadsto \mathsf{copysign}\left(0 - \log \color{blue}{\left(\mathsf{hypot}\left(1, x\right) + \left(-x\right)\right)}, x\right) \]
      12. sub-neg99.9%

        \[\leadsto \mathsf{copysign}\left(0 - \log \color{blue}{\left(\mathsf{hypot}\left(1, x\right) - x\right)}, x\right) \]
      13. neg-sub099.9%

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

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

    if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.100000001

    1. Initial program 20.9%

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(1 + \left|x\right|\right) + {x}^{2} \cdot \left(-0.041666666666666664 \cdot \left({x}^{2} \cdot \left(3 \cdot \frac{1}{1 + \left|x\right|} + 3 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{2}}\right)\right) + 0.5 \cdot \frac{1}{1 + \left|x\right|}\right)}, x\right) \]
    4. Step-by-step derivation
      1. +-commutative22.2%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{{x}^{2} \cdot \left(-0.041666666666666664 \cdot \left({x}^{2} \cdot \left(3 \cdot \frac{1}{1 + \left|x\right|} + 3 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{2}}\right)\right) + 0.5 \cdot \frac{1}{1 + \left|x\right|}\right) + \log \left(1 + \left|x\right|\right)}, x\right) \]
      2. fma-define22.2%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{fma}\left({x}^{2}, -0.041666666666666664 \cdot \left({x}^{2} \cdot \left(3 \cdot \frac{1}{1 + \left|x\right|} + 3 \cdot \frac{1}{{\left(1 + \left|x\right|\right)}^{2}}\right)\right) + 0.5 \cdot \frac{1}{1 + \left|x\right|}, \log \left(1 + \left|x\right|\right)\right)}, x\right) \]
    5. Simplified99.9%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{fma}\left({x}^{2}, {x}^{2} \cdot \left(\frac{-0.125}{1 + x} + \frac{-0.125}{{\left(1 + x\right)}^{2}}\right) + \frac{0.5}{1 + x}, \mathsf{log1p}\left(x\right)\right)}, x\right) \]

    if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x)

    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. +-commutative57.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq -0.10000000149011612:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\ \mathbf{elif}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq 0.10000000149011612:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left({x}^{2}, {x}^{2} \cdot \left(\frac{-0.125}{x + 1} + \frac{-0.125}{{\left(x + 1\right)}^{2}}\right) + \frac{0.5}{x + 1}, \mathsf{log1p}\left(x\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 99.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\ \mathbf{if}\;t\_0 \leq -0.10000000149011612:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\ \mathbf{elif}\;t\_0 \leq 0.009999999776482582:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{x + 1}, \mathsf{log1p}\left(x\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
   (if (<= t_0 -0.10000000149011612)
     (copysign (- (log (- (hypot 1.0 x) x))) x)
     (if (<= t_0 0.009999999776482582)
       (copysign (fma 0.5 (/ (pow x 2.0) (+ x 1.0)) (log1p x)) x)
       (copysign (log (+ x (hypot 1.0 x))) x)))))
float code(float x) {
	float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
	float tmp;
	if (t_0 <= -0.10000000149011612f) {
		tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
	} else if (t_0 <= 0.009999999776482582f) {
		tmp = copysignf(fmaf(0.5f, (powf(x, 2.0f) / (x + 1.0f)), log1pf(x)), x);
	} else {
		tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
	}
	return tmp;
}
function code(x)
	t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x)
	tmp = Float32(0.0)
	if (t_0 <= Float32(-0.10000000149011612))
		tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x);
	elseif (t_0 <= Float32(0.009999999776482582))
		tmp = copysign(fma(Float32(0.5), Float32((x ^ Float32(2.0)) / Float32(x + Float32(1.0))), log1p(x)), x);
	else
		tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x);
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\

\mathbf{elif}\;t\_0 \leq 0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{x + 1}, \mathsf{log1p}\left(x\right)\right), x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -0.100000001

    1. Initial program 58.3%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(-\left(\left|x\right| \cdot \left|x\right| - \sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}\right)\right) - \log \left(-\left(\left|x\right| - \sqrt{x \cdot x + 1}\right)\right)}, x\right) \]
    4. Applied egg-rr13.8%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(-\left({x}^{2} - \mathsf{fma}\left(x, x, 1\right)\right)\right) - \log \left(-\left(x - \mathsf{hypot}\left(1, x\right)\right)\right)}, x\right) \]
    5. Step-by-step derivation
      1. fma-undefine13.8%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{1} - \log \left(-\left(x - \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
      7. metadata-eval99.9%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{0} - \log \left(-\left(x - \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
      8. neg-sub099.9%

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

        \[\leadsto \mathsf{copysign}\left(0 - \log \color{blue}{\left(\left(0 - x\right) + \mathsf{hypot}\left(1, x\right)\right)}, x\right) \]
      10. neg-sub099.9%

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

        \[\leadsto \mathsf{copysign}\left(0 - \log \color{blue}{\left(\mathsf{hypot}\left(1, x\right) + \left(-x\right)\right)}, x\right) \]
      12. sub-neg99.9%

        \[\leadsto \mathsf{copysign}\left(0 - \log \color{blue}{\left(\mathsf{hypot}\left(1, x\right) - x\right)}, x\right) \]
      13. neg-sub099.9%

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

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

    if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.00999999978

    1. Initial program 19.7%

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(1 + \left|x\right|\right) + 0.5 \cdot \frac{{x}^{2}}{1 + \left|x\right|}}, x\right) \]
    4. Step-by-step derivation
      1. +-commutative21.0%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{0.5 \cdot \frac{{x}^{2}}{1 + \left|x\right|} + \log \left(1 + \left|x\right|\right)}, x\right) \]
      2. fma-define21.0%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{fma}\left(0.5, \frac{{x}^{2}}{1 + \left|x\right|}, \log \left(1 + \left|x\right|\right)\right)}, x\right) \]
      3. rem-square-sqrt10.5%

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{1 + \left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}, \log \left(1 + \left|x\right|\right)\right), x\right) \]
      4. fabs-sqr10.5%

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{1 + \color{blue}{\sqrt{x} \cdot \sqrt{x}}}, \log \left(1 + \left|x\right|\right)\right), x\right) \]
      5. rem-square-sqrt20.9%

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{1 + \color{blue}{x}}, \log \left(1 + \left|x\right|\right)\right), x\right) \]
      6. log1p-define99.4%

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{1 + x}, \color{blue}{\mathsf{log1p}\left(\left|x\right|\right)}\right), x\right) \]
      7. rem-square-sqrt47.8%

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{1 + x}, \mathsf{log1p}\left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|\right)\right), x\right) \]
      8. fabs-sqr47.8%

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{1 + x}, \mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)\right), x\right) \]
      9. rem-square-sqrt99.9%

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{1 + x}, \mathsf{log1p}\left(\color{blue}{x}\right)\right), x\right) \]
    5. Simplified99.9%

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

    if 0.00999999978 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x)

    1. Initial program 58.8%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity58.8%

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right) + \log 1}, x\right) \]
      4. *-un-lft-identity58.8%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(1 \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)} + \log 1, x\right) \]
      5. *-un-lft-identity58.8%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} + \log 1, x\right) \]
      6. add-sqr-sqrt58.8%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq -0.10000000149011612:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\ \mathbf{elif}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq 0.009999999776482582:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{x + 1}, \mathsf{log1p}\left(x\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 99.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\ \mathbf{if}\;t\_0 \leq -0.009999999776482582:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\ \mathbf{elif}\;t\_0 \leq 0.0020000000949949026:\\ \;\;\;\;\mathsf{copysign}\left(x, 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
 (let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
   (if (<= t_0 -0.009999999776482582)
     (copysign (- (log (- (hypot 1.0 x) x))) x)
     (if (<= t_0 0.0020000000949949026)
       (copysign x x)
       (copysign (log (+ x (hypot 1.0 x))) x)))))
float code(float x) {
	float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
	float tmp;
	if (t_0 <= -0.009999999776482582f) {
		tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
	} else if (t_0 <= 0.0020000000949949026f) {
		tmp = copysignf(x, x);
	} else {
		tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
	}
	return tmp;
}
function code(x)
	t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x)
	tmp = Float32(0.0)
	if (t_0 <= Float32(-0.009999999776482582))
		tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x);
	elseif (t_0 <= Float32(0.0020000000949949026))
		tmp = copysign(x, x);
	else
		tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0))))));
	tmp = single(0.0);
	if (t_0 <= single(-0.009999999776482582))
		tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x)));
	elseif (t_0 <= single(0.0020000000949949026))
		tmp = sign(x) * abs(x);
	else
		tmp = sign(x) * abs(log((x + hypot(single(1.0), x))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\

\mathbf{elif}\;t\_0 \leq 0.0020000000949949026:\\
\;\;\;\;\mathsf{copysign}\left(x, 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 (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -0.00999999978

    1. Initial program 58.7%

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(-\left({x}^{2} - \mathsf{fma}\left(x, x, 1\right)\right)\right) - \log \left(-\left(x - \mathsf{hypot}\left(1, x\right)\right)\right)}, x\right) \]
    5. Step-by-step derivation
      1. fma-undefine14.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(0 - \log \color{blue}{\left(\mathsf{hypot}\left(1, x\right) - x\right)}, x\right) \]
      13. neg-sub099.6%

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

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

    if -0.00999999978 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < 0.00200000009

    1. Initial program 17.7%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(1 + \color{blue}{\sqrt{x} \cdot \sqrt{x}}\right), x\right) \]
      3. rem-square-sqrt17.9%

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

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

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

    if 0.00200000009 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x)

    1. Initial program 59.5%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity59.5%

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right) + \log 1}, x\right) \]
      4. *-un-lft-identity59.5%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(1 \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)} + \log 1, x\right) \]
      5. *-un-lft-identity59.5%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 98.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\ \mathbf{elif}\;x \leq 0.009999999776482582:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \left(x + {x}^{3} \cdot -0.16666666666666666\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -5.0)
   (copysign (log (- (fabs x) x)) x)
   (if (<= x 0.009999999776482582)
     (copysign
      (* 0.3333333333333333 (* 3.0 (+ x (* (pow x 3.0) -0.16666666666666666))))
      x)
     (copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
	float tmp;
	if (x <= -5.0f) {
		tmp = copysignf(logf((fabsf(x) - x)), x);
	} else if (x <= 0.009999999776482582f) {
		tmp = copysignf((0.3333333333333333f * (3.0f * (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(-5.0))
		tmp = copysign(log(Float32(abs(x) - x)), x);
	elseif (x <= Float32(0.009999999776482582))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(3.0) * 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(-5.0))
		tmp = sign(x) * abs(log((abs(x) - x)));
	elseif (x <= single(0.009999999776482582))
		tmp = sign(x) * abs((single(0.3333333333333333) * (single(3.0) * (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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\

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

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


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

    1. Initial program 57.1%

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

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{-1 \cdot x}\right), x\right) \]
    4. Step-by-step derivation
      1. neg-mul-197.9%

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

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

    if -5 < x < 0.00999999978

    1. Initial program 20.9%

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\sqrt[3]{\left(\left(\left|x\right| + \sqrt{x \cdot x + 1}\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}\right)}, x\right) \]
      2. pow1/320.9%

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

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

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \log \color{blue}{\left({\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}^{3}\right)}, x\right) \]
      5. log-pow20.9%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \color{blue}{\left(3 \cdot \log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}, x\right) \]
      6. *-un-lft-identity20.9%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \color{blue}{\left(1 \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}\right), x\right) \]
      7. *-un-lft-identity20.9%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}\right), x\right) \]
    4. Applied egg-rr21.7%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{0.3333333333333333 \cdot \left(3 \cdot \log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}, x\right) \]
    5. Taylor expanded in x around 0 98.4%

      \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \color{blue}{\left(x \cdot \left(1 + -0.16666666666666666 \cdot {x}^{2}\right)\right)}\right), x\right) \]
    6. Step-by-step derivation
      1. distribute-lft-in98.5%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \color{blue}{\left(x \cdot 1 + x \cdot \left(-0.16666666666666666 \cdot {x}^{2}\right)\right)}\right), x\right) \]
      2. *-rgt-identity98.5%

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

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \left(x + x \cdot \color{blue}{\left({x}^{2} \cdot -0.16666666666666666\right)}\right)\right), x\right) \]
      4. associate-*r*98.5%

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

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

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

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

    if 0.00999999978 < x

    1. Initial program 58.8%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity58.8%

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right) + \log 1}, x\right) \]
      4. *-un-lft-identity58.8%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(1 \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)} + \log 1, x\right) \]
      5. *-un-lft-identity58.8%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} + \log 1, x\right) \]
      6. add-sqr-sqrt58.8%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\ \mathbf{elif}\;x \leq 0.009999999776482582:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \left(x + {x}^{3} \cdot -0.16666666666666666\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 98.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(\frac{-0.5}{x}\right)\right), x\right)\\ \mathbf{elif}\;x \leq 0.009999999776482582:\\ \;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \left(x + {x}^{3} \cdot -0.16666666666666666\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -5.0)
   (copysign (* 0.3333333333333333 (* 3.0 (log (/ -0.5 x)))) x)
   (if (<= x 0.009999999776482582)
     (copysign
      (* 0.3333333333333333 (* 3.0 (+ x (* (pow x 3.0) -0.16666666666666666))))
      x)
     (copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
	float tmp;
	if (x <= -5.0f) {
		tmp = copysignf((0.3333333333333333f * (3.0f * logf((-0.5f / x)))), x);
	} else if (x <= 0.009999999776482582f) {
		tmp = copysignf((0.3333333333333333f * (3.0f * (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(-5.0))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(3.0) * log(Float32(Float32(-0.5) / x)))), x);
	elseif (x <= Float32(0.009999999776482582))
		tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(3.0) * 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(-5.0))
		tmp = sign(x) * abs((single(0.3333333333333333) * (single(3.0) * log((single(-0.5) / x)))));
	elseif (x <= single(0.009999999776482582))
		tmp = sign(x) * abs((single(0.3333333333333333) * (single(3.0) * (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 -5:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(\frac{-0.5}{x}\right)\right), x\right)\\

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

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


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

    1. Initial program 57.1%

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\sqrt[3]{\left(\left(\left|x\right| + \sqrt{x \cdot x + 1}\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}\right)}, x\right) \]
      2. pow1/339.6%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left({\left(\left(\left(\left|x\right| + \sqrt{x \cdot x + 1}\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}^{0.3333333333333333}\right)}, x\right) \]
      3. log-pow39.6%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{0.3333333333333333 \cdot \log \left(\left(\left(\left|x\right| + \sqrt{x \cdot x + 1}\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}, x\right) \]
      4. pow339.6%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \log \color{blue}{\left({\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}^{3}\right)}, x\right) \]
      5. log-pow56.3%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \color{blue}{\left(3 \cdot \log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}, x\right) \]
      6. *-un-lft-identity56.3%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \color{blue}{\left(1 \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}\right), x\right) \]
      7. *-un-lft-identity56.3%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}\right), x\right) \]
    4. Applied egg-rr12.2%

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

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

    if -5 < x < 0.00999999978

    1. Initial program 20.9%

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\sqrt[3]{\left(\left(\left|x\right| + \sqrt{x \cdot x + 1}\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}\right)}, x\right) \]
      2. pow1/320.9%

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

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

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \log \color{blue}{\left({\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}^{3}\right)}, x\right) \]
      5. log-pow20.9%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \color{blue}{\left(3 \cdot \log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}, x\right) \]
      6. *-un-lft-identity20.9%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \color{blue}{\left(1 \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}\right), x\right) \]
      7. *-un-lft-identity20.9%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}\right), x\right) \]
    4. Applied egg-rr21.7%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{0.3333333333333333 \cdot \left(3 \cdot \log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}, x\right) \]
    5. Taylor expanded in x around 0 98.4%

      \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \color{blue}{\left(x \cdot \left(1 + -0.16666666666666666 \cdot {x}^{2}\right)\right)}\right), x\right) \]
    6. Step-by-step derivation
      1. distribute-lft-in98.5%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \color{blue}{\left(x \cdot 1 + x \cdot \left(-0.16666666666666666 \cdot {x}^{2}\right)\right)}\right), x\right) \]
      2. *-rgt-identity98.5%

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

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \left(x + x \cdot \color{blue}{\left({x}^{2} \cdot -0.16666666666666666\right)}\right)\right), x\right) \]
      4. associate-*r*98.5%

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

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

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

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

    if 0.00999999978 < x

    1. Initial program 58.8%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity58.8%

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right) + \log 1}, x\right) \]
      4. *-un-lft-identity58.8%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(1 \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)} + \log 1, x\right) \]
      5. *-un-lft-identity58.8%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)} + \log 1, x\right) \]
      6. add-sqr-sqrt58.8%

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

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

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

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

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

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

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

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

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

Alternative 6: 97.2% accurate, 1.8× speedup?

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

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

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

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


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

    1. Initial program 57.1%

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\sqrt[3]{\left(\left(\left|x\right| + \sqrt{x \cdot x + 1}\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}\right)}, x\right) \]
      2. pow1/339.6%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left({\left(\left(\left(\left|x\right| + \sqrt{x \cdot x + 1}\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}^{0.3333333333333333}\right)}, x\right) \]
      3. log-pow39.6%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{0.3333333333333333 \cdot \log \left(\left(\left(\left|x\right| + \sqrt{x \cdot x + 1}\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}, x\right) \]
      4. pow339.6%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \log \color{blue}{\left({\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}^{3}\right)}, x\right) \]
      5. log-pow56.3%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \color{blue}{\left(3 \cdot \log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}, x\right) \]
      6. *-un-lft-identity56.3%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \color{blue}{\left(1 \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}\right), x\right) \]
      7. *-un-lft-identity56.3%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}\right), x\right) \]
    4. Applied egg-rr12.2%

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

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

    if -5 < x < 1

    1. Initial program 23.8%

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\sqrt[3]{\left(\left(\left|x\right| + \sqrt{x \cdot x + 1}\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}\right)}, x\right) \]
      2. pow1/323.8%

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

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

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \log \color{blue}{\left({\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}^{3}\right)}, x\right) \]
      5. log-pow23.8%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \color{blue}{\left(3 \cdot \log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}, x\right) \]
      6. *-un-lft-identity23.8%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \color{blue}{\left(1 \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}\right), x\right) \]
      7. *-un-lft-identity23.8%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}\right), x\right) \]
    4. Applied egg-rr24.6%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{0.3333333333333333 \cdot \left(3 \cdot \log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}, x\right) \]
    5. Taylor expanded in x around 0 97.4%

      \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \color{blue}{\left(x \cdot \left(1 + -0.16666666666666666 \cdot {x}^{2}\right)\right)}\right), x\right) \]
    6. Step-by-step derivation
      1. distribute-lft-in97.5%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \color{blue}{\left(x \cdot 1 + x \cdot \left(-0.16666666666666666 \cdot {x}^{2}\right)\right)}\right), x\right) \]
      2. *-rgt-identity97.5%

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

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \left(x + x \cdot \color{blue}{\left({x}^{2} \cdot -0.16666666666666666\right)}\right)\right), x\right) \]
      4. associate-*r*97.5%

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

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

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

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

    if 1 < x

    1. Initial program 56.0%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(0 + \log \left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + x\right), x\right) \]
      5. fabs-sqr97.3%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(2 \cdot x\right)}, x\right) \]
      3. *-commutative97.3%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(x \cdot 2\right)}, x\right) \]
    7. Simplified97.3%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(x \cdot 2\right)}, x\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 7: 96.9% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 57.1%

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\sqrt[3]{\left(\left(\left|x\right| + \sqrt{x \cdot x + 1}\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}\right)}, x\right) \]
      2. pow1/339.6%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left({\left(\left(\left(\left|x\right| + \sqrt{x \cdot x + 1}\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}^{0.3333333333333333}\right)}, x\right) \]
      3. log-pow39.6%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{0.3333333333333333 \cdot \log \left(\left(\left(\left|x\right| + \sqrt{x \cdot x + 1}\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right) \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}, x\right) \]
      4. pow339.6%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \log \color{blue}{\left({\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}^{3}\right)}, x\right) \]
      5. log-pow56.3%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \color{blue}{\left(3 \cdot \log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}, x\right) \]
      6. *-un-lft-identity56.3%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \color{blue}{\left(1 \cdot \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)\right)}\right), x\right) \]
      7. *-un-lft-identity56.3%

        \[\leadsto \mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \color{blue}{\left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}\right), x\right) \]
    4. Applied egg-rr12.2%

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

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

    if -5 < x < 1

    1. Initial program 23.8%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(1 + \color{blue}{\sqrt{x} \cdot \sqrt{x}}\right), x\right) \]
      3. rem-square-sqrt20.1%

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

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

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

    if 1 < x

    1. Initial program 56.0%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(0 + \log \left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + x\right), x\right) \]
      5. fabs-sqr97.3%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(2 \cdot x\right)}, x\right) \]
      3. *-commutative97.3%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(x \cdot 2\right)}, x\right) \]
    7. Simplified97.3%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(x \cdot 2\right)}, x\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 84.2% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 57.1%

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

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

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

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

    if -5 < x < 1

    1. Initial program 23.8%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(1 + \color{blue}{\sqrt{x} \cdot \sqrt{x}}\right), x\right) \]
      3. rem-square-sqrt20.1%

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

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

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

    if 1 < x

    1. Initial program 56.0%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(0 + \log \left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + x\right), x\right) \]
      5. fabs-sqr97.3%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(2 \cdot x\right)}, x\right) \]
      3. *-commutative97.3%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(x \cdot 2\right)}, x\right) \]
    7. Simplified97.3%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(x \cdot 2\right)}, x\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 9: 76.3% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\mathsf{copysign}\left(x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
	float tmp;
	if (x <= 1.0f) {
		tmp = copysignf(x, x);
	} else {
		tmp = copysignf(logf((x * 2.0f)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(1.0))
		tmp = copysign(x, x);
	else
		tmp = copysign(log(Float32(x * Float32(2.0))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(1.0))
		tmp = sign(x) * abs(x);
	else
		tmp = sign(x) * abs(log((x * single(2.0))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

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

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


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

    1. Initial program 34.5%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(1 + \color{blue}{\sqrt{x} \cdot \sqrt{x}}\right), x\right) \]
      3. rem-square-sqrt13.6%

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

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

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

    if 1 < x

    1. Initial program 56.0%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(0 + \log \left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| + x\right), x\right) \]
      5. fabs-sqr97.3%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(2 \cdot x\right)}, x\right) \]
      3. *-commutative97.3%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(x \cdot 2\right)}, x\right) \]
    7. Simplified97.3%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(x \cdot 2\right)}, x\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 63.1% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 34.5%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(1 + \color{blue}{\sqrt{x} \cdot \sqrt{x}}\right), x\right) \]
      3. rem-square-sqrt13.6%

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

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

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

    if 1 < x

    1. Initial program 56.0%

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{log1p}\left(\left|x\right|\right)}, x\right) \]
      2. rem-square-sqrt44.3%

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right), x\right) \]
      4. rem-square-sqrt44.3%

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

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

Alternative 11: 63.0% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\mathsf{copysign}\left(x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x 1.0) (copysign x x) (copysign (log x) x)))
float code(float x) {
	float tmp;
	if (x <= 1.0f) {
		tmp = copysignf(x, x);
	} else {
		tmp = copysignf(logf(x), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(1.0))
		tmp = copysign(x, x);
	else
		tmp = copysign(log(x), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(1.0))
		tmp = sign(x) * abs(x);
	else
		tmp = sign(x) * abs(log(x));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

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

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


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

    1. Initial program 34.5%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(1 + \color{blue}{\sqrt{x} \cdot \sqrt{x}}\right), x\right) \]
      3. rem-square-sqrt13.6%

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

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

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

    if 1 < x

    1. Initial program 56.0%

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{-1 \cdot \log \left(\frac{1}{x}\right)}, x\right) \]
    4. Step-by-step derivation
      1. mul-1-neg44.3%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{-\log \left(\frac{1}{x}\right)}, x\right) \]
      2. log-rec44.3%

        \[\leadsto \mathsf{copysign}\left(-\color{blue}{\left(-\log x\right)}, x\right) \]
      3. remove-double-neg44.3%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log x}, x\right) \]
    5. Simplified44.3%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log x}, x\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 54.9% accurate, 4.0× speedup?

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

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(\log \left(1 + \color{blue}{\sqrt{x} \cdot \sqrt{x}}\right), x\right) \]
    3. rem-square-sqrt21.5%

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

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

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

Developer Target 1: 99.7% 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 2024115 
(FPCore (x)
  :name "Rust f32::asinh"
  :precision binary32

  :alt
  (! :herbie-platform default (let* ((ax (fabs x)) (ix (/ 1 ax))) (copysign (log1p (+ ax (/ ax (+ (hypot 1 ix) ix)))) x)))

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