Rust f32::asinh

Percentage Accurate: 37.9% → 99.6%
Time: 7.0s
Alternatives: 14
Speedup: 3.6×

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 14 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.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \end{array} \]
(FPCore (x)
 :precision 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.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.10000000149011612:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\ \mathbf{elif}\;t\_0 \leq 0.019999999552965164:\\ \;\;\;\;\mathsf{copysign}\left(x + \left(-0.16666666666666666 \cdot {x}^{3} + 0.075 \cdot {x}^{5}\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.019999999552965164)
       (copysign
        (+ x (+ (* -0.16666666666666666 (pow x 3.0)) (* 0.075 (pow x 5.0))))
        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.019999999552965164f) {
		tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + (0.075f * powf(x, 5.0f)))), 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.019999999552965164))
		tmp = copysign(Float32(x + Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(Float32(0.075) * (x ^ Float32(5.0))))), 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.10000000149011612))
		tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x)));
	elseif (t_0 <= single(0.019999999552965164))
		tmp = sign(x) * abs((x + ((single(-0.16666666666666666) * (x ^ single(3.0))) + (single(0.075) * (x ^ single(5.0))))));
	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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\

\mathbf{elif}\;t\_0 \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(-0.16666666666666666 \cdot {x}^{3} + 0.075 \cdot {x}^{5}\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) 1)))) x) < -0.100000001

    1. Initial program 56.0%

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

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

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

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+11.8%

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

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

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

      \[\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) \]
    7. Step-by-step derivation
      1. sub-neg17.0%

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

        \[\leadsto \mathsf{copysign}\left(\log \left(-\color{blue}{\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) \]
      3. fma-undefine16.6%

        \[\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) \]
      4. unpow216.6%

        \[\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) \]
      5. associate--r+53.0%

        \[\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) \]
      6. +-inverses99.8%

        \[\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) \]
      7. metadata-eval99.8%

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

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

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

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

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

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

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

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

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

      \[\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) 1)))) x) < 0.0199999996

    1. Initial program 23.4%

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

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

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

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+23.1%

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{\color{blue}{{\left(\left|x\right|\right)}^{2}}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      4. add-sqr-sqrt10.7%

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{{\color{blue}{x}}^{2}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      7. add-sqr-sqrt10.7%

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{{x}^{2}}{\color{blue}{\sqrt{x} \cdot \sqrt{x}} - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      9. add-sqr-sqrt21.9%

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

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\frac{{x}^{2}}{x - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{fma}\left(x, x, 1\right)}{x - \mathsf{hypot}\left(1, x\right)}\right)}, x\right) \]
    7. Step-by-step derivation
      1. div-sub23.4%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{\color{blue}{\frac{1}{-1}}}{x - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      8. associate-/r*23.6%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\frac{1}{-1 \cdot \left(x - \mathsf{hypot}\left(1, x\right)\right)}\right)}, x\right) \]
      9. neg-mul-123.6%

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{1}{-\color{blue}{\left(\left(-\mathsf{hypot}\left(1, x\right)\right) + x\right)}}\right), x\right) \]
      12. distribute-neg-in23.6%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{1}{\color{blue}{\left(-\left(-\mathsf{hypot}\left(1, x\right)\right)\right) + \left(-x\right)}}\right), x\right) \]
      13. remove-double-neg23.6%

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

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

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

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

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

    1. Initial program 62.6%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right) + \log 1}, x\right) \]
      4. *-un-lft-identity98.6%

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

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

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

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

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

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

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

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

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

    \[\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.019999999552965164:\\ \;\;\;\;\mathsf{copysign}\left(x + \left(-0.16666666666666666 \cdot {x}^{3} + 0.075 \cdot {x}^{5}\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 2: 99.1% accurate, 1.3× speedup?

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

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

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


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

    1. Initial program 54.7%

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

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

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

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+9.0%

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

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

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

      \[\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) \]
    7. Step-by-step derivation
      1. sub-neg14.4%

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

        \[\leadsto \mathsf{copysign}\left(\log \left(-\color{blue}{\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) \]
      3. fma-undefine14.0%

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

        \[\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) \]
      5. associate--r+51.6%

        \[\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) \]
      6. +-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) \]
      7. 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) \]
      8. 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) \]
      9. metadata-eval99.9%

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

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

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

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

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

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

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

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

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

    if -1 < x < 0.0199999996

    1. Initial program 24.5%

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

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

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

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

      \[\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) \]
    6. Step-by-step derivation
      1. +-commutative24.3%

        \[\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-define24.3%

        \[\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-sqrt11.0%

        \[\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-sqr11.0%

        \[\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-sqrt23.2%

        \[\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-define96.8%

        \[\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-sqrt40.4%

        \[\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-sqr40.4%

        \[\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-sqrt98.1%

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

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

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

    if 0.0199999996 < x

    1. Initial program 62.6%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right) + \log 1}, x\right) \]
      4. *-un-lft-identity98.6%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.6% accurate, 1.3× speedup?

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

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

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


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

    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-def99.6%

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

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+15.4%

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

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

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

      \[\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) \]
    7. Step-by-step derivation
      1. sub-neg20.4%

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

        \[\leadsto \mathsf{copysign}\left(\log \left(-\color{blue}{\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) \]
      3. fma-undefine20.0%

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

        \[\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) \]
      5. associate--r+55.0%

        \[\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) \]
      6. +-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) \]
      7. 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) \]
      8. 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) \]
      9. metadata-eval99.6%

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

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

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

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

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

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

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

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

    if -0.0299999993 < x < 0.0199999996

    1. Initial program 21.7%

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

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

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

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

      \[\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) \]
    6. Step-by-step derivation
      1. +-commutative22.7%

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

        \[\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-sqrt11.4%

        \[\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-sqr11.4%

        \[\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-sqrt22.3%

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

        \[\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-sqrt42.0%

        \[\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-sqr42.0%

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

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

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

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

    if 0.0199999996 < x

    1. Initial program 62.6%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right) + \log 1}, x\right) \]
      4. *-un-lft-identity98.6%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 98.1% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.5:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, 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 -1.5)
   (copysign (- (log (* x -2.0))) x)
   (if (<= x 0.5)
     (copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
     (copysign (log (/ 0.5 x)) x))))
float code(float x) {
	float tmp;
	if (x <= -1.5f) {
		tmp = copysignf(-logf((x * -2.0f)), x);
	} else if (x <= 0.5f) {
		tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
	} else {
		tmp = copysignf(logf((0.5f / x)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-1.5))
		tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x);
	elseif (x <= Float32(0.5))
		tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), 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(-1.5))
		tmp = sign(x) * abs(-log((x * single(-2.0))));
	elseif (x <= single(0.5))
		tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0)))));
	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 -1.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\

\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, 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 < -1.5

    1. Initial program 53.2%

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

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

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

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+6.0%

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

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

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

      \[\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) \]
    7. Step-by-step derivation
      1. sub-neg11.6%

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

        \[\leadsto \mathsf{copysign}\left(\log \left(-\color{blue}{\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) \]
      3. fma-undefine11.1%

        \[\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) \]
      4. unpow211.1%

        \[\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) \]
      5. associate--r+49.9%

        \[\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) \]
      6. +-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) \]
      7. 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) \]
      8. 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) \]
      9. metadata-eval99.9%

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

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

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

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

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

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

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

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

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

    if -1.5 < x < 0.5

    1. Initial program 26.2%

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

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

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

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

      \[\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) \]
    6. Step-by-step derivation
      1. +-commutative24.6%

        \[\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-define24.6%

        \[\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-sqrt11.1%

        \[\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-sqr11.1%

        \[\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-sqrt23.4%

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

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

        \[\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-sqrt96.2%

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

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

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

    if 0.5 < x

    1. Initial program 62.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(x + x\right) + \frac{\color{blue}{0.5}}{x}\right), x\right) \]
    7. Simplified97.8%

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

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\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 -1.5:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 98.4% accurate, 1.9× speedup?

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

\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, 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 < -1

    1. Initial program 54.7%

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

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

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

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+9.0%

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

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

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

      \[\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) \]
    7. Step-by-step derivation
      1. sub-neg14.4%

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

        \[\leadsto \mathsf{copysign}\left(\log \left(-\color{blue}{\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) \]
      3. fma-undefine14.0%

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

        \[\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) \]
      5. associate--r+51.6%

        \[\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) \]
      6. +-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) \]
      7. 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) \]
      8. 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) \]
      9. metadata-eval99.9%

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

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

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

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

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

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

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

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

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

    if -1 < x < 0.5

    1. Initial program 25.1%

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

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

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

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

      \[\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) \]
    6. Step-by-step derivation
      1. +-commutative24.4%

        \[\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-define24.4%

        \[\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-sqrt11.3%

        \[\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-sqr11.3%

        \[\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-sqrt23.4%

        \[\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-define96.5%

        \[\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-sqrt40.5%

        \[\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-sqr40.5%

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

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

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

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

    if 0.5 < x

    1. Initial program 62.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(x + x\right) + \frac{\color{blue}{0.5}}{x}\right), x\right) \]
    7. Simplified97.8%

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

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

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

Alternative 6: 84.1% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\mathsf{copysign}\left(x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -5.0)
   (copysign (log (- x)) x)
   (if (<= x 0.5) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
	float tmp;
	if (x <= -5.0f) {
		tmp = copysignf(logf(-x), x);
	} else if (x <= 0.5f) {
		tmp = copysignf(x, x);
	} else {
		tmp = copysignf(logf((x + x)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-5.0))
		tmp = copysign(log(Float32(-x)), x);
	elseif (x <= Float32(0.5))
		tmp = copysign(x, x);
	else
		tmp = copysign(log(Float32(x + 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(-x));
	elseif (x <= single(0.5))
		tmp = sign(x) * abs(x);
	else
		tmp = sign(x) * abs(log((x + x)));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

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

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

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


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

    1. Initial program 52.4%

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

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

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

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

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

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

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

    if -5 < x < 0.5

    1. Initial program 26.7%

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

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

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

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

      \[\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) \]
    6. Step-by-step derivation
      1. +-commutative24.7%

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

        \[\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-sqrt11.0%

        \[\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-sqr11.0%

        \[\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-sqrt23.4%

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

        \[\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-sqrt39.6%

        \[\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-sqr39.6%

        \[\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-sqrt95.5%

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

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{x + -0.16666666666666666 \cdot {x}^{3}}, x\right) \]
    9. Taylor expanded in x around 0 95.1%

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

    if 0.5 < x

    1. Initial program 62.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\mathsf{copysign}\left(x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 97.4% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 53.2%

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

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

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

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+6.0%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\frac{\left|x\right| \cdot \left|x\right| - \mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right)}, x\right) \]
      2. div-sub5.9%

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{\color{blue}{{\left(\left|x\right|\right)}^{2}}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      4. add-sqr-sqrt-0.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{{\left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|\right)}^{2}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      5. fabs-sqr-0.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{{\color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)}}^{2}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      6. add-sqr-sqrt5.9%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{{\color{blue}{x}}^{2}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      7. add-sqr-sqrt-0.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{{x}^{2}}{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      8. fabs-sqr-0.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{{x}^{2}}{\color{blue}{\sqrt{x} \cdot \sqrt{x}} - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      9. add-sqr-sqrt2.3%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{{x}^{2}}{\color{blue}{x} - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
    6. Applied egg-rr8.6%

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\frac{{x}^{2}}{x - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{fma}\left(x, x, 1\right)}{x - \mathsf{hypot}\left(1, x\right)}\right)}, x\right) \]
    7. Step-by-step derivation
      1. div-sub11.6%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\frac{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}{x - \mathsf{hypot}\left(1, x\right)}\right)}, x\right) \]
      2. fma-undefine11.2%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\frac{1}{-1 \cdot \left(x - \mathsf{hypot}\left(1, x\right)\right)}\right)}, x\right) \]
      9. neg-mul-199.9%

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{1}{-\color{blue}{\left(\left(-\mathsf{hypot}\left(1, x\right)\right) + x\right)}}\right), x\right) \]
      12. distribute-neg-in99.9%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{1}{\color{blue}{\left(-\left(-\mathsf{hypot}\left(1, x\right)\right)\right) + \left(-x\right)}}\right), x\right) \]
      13. remove-double-neg99.9%

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

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

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

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

    if -1.5 < x < 0.5

    1. Initial program 26.2%

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

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

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

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

      \[\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) \]
    6. Step-by-step derivation
      1. +-commutative24.6%

        \[\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-define24.6%

        \[\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-sqrt11.1%

        \[\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-sqr11.1%

        \[\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-sqrt23.4%

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

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

        \[\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-sqrt96.2%

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

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{x + -0.16666666666666666 \cdot {x}^{3}}, x\right) \]
    9. Taylor expanded in x around 0 95.6%

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

    if 0.5 < x

    1. Initial program 62.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\mathsf{copysign}\left(x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 97.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.5:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\mathsf{copysign}\left(x, 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 -1.5)
   (copysign (log (/ -0.5 x)) x)
   (if (<= x 0.5) (copysign x x) (copysign (log (/ 0.5 x)) x))))
float code(float x) {
	float tmp;
	if (x <= -1.5f) {
		tmp = copysignf(logf((-0.5f / x)), x);
	} else if (x <= 0.5f) {
		tmp = copysignf(x, x);
	} else {
		tmp = copysignf(logf((0.5f / x)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-1.5))
		tmp = copysign(log(Float32(Float32(-0.5) / x)), x);
	elseif (x <= Float32(0.5))
		tmp = copysign(x, 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(-1.5))
		tmp = sign(x) * abs(log((single(-0.5) / x)));
	elseif (x <= single(0.5))
		tmp = sign(x) * abs(x);
	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 -1.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\

\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, 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 < -1.5

    1. Initial program 53.2%

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

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

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

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+6.0%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\frac{\left|x\right| \cdot \left|x\right| - \mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right)}, x\right) \]
      2. div-sub5.9%

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{\color{blue}{{\left(\left|x\right|\right)}^{2}}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      4. add-sqr-sqrt-0.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{{\left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|\right)}^{2}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      5. fabs-sqr-0.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{{\color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)}}^{2}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      6. add-sqr-sqrt5.9%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{{\color{blue}{x}}^{2}}{\left|x\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      7. add-sqr-sqrt-0.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{{x}^{2}}{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      8. fabs-sqr-0.0%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{{x}^{2}}{\color{blue}{\sqrt{x} \cdot \sqrt{x}} - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
      9. add-sqr-sqrt2.3%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{{x}^{2}}{\color{blue}{x} - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}\right), x\right) \]
    6. Applied egg-rr8.6%

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\frac{{x}^{2}}{x - \mathsf{hypot}\left(1, x\right)} - \frac{\mathsf{fma}\left(x, x, 1\right)}{x - \mathsf{hypot}\left(1, x\right)}\right)}, x\right) \]
    7. Step-by-step derivation
      1. div-sub11.6%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\frac{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}{x - \mathsf{hypot}\left(1, x\right)}\right)}, x\right) \]
      2. fma-undefine11.2%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\frac{1}{-1 \cdot \left(x - \mathsf{hypot}\left(1, x\right)\right)}\right)}, x\right) \]
      9. neg-mul-199.9%

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{1}{-\color{blue}{\left(\left(-\mathsf{hypot}\left(1, x\right)\right) + x\right)}}\right), x\right) \]
      12. distribute-neg-in99.9%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{1}{\color{blue}{\left(-\left(-\mathsf{hypot}\left(1, x\right)\right)\right) + \left(-x\right)}}\right), x\right) \]
      13. remove-double-neg99.9%

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

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

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

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

    if -1.5 < x < 0.5

    1. Initial program 26.2%

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

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

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

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

      \[\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) \]
    6. Step-by-step derivation
      1. +-commutative24.6%

        \[\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-define24.6%

        \[\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-sqrt11.1%

        \[\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-sqr11.1%

        \[\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-sqrt23.4%

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

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

        \[\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-sqrt96.2%

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

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{x + -0.16666666666666666 \cdot {x}^{3}}, x\right) \]
    9. Taylor expanded in x around 0 95.6%

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

    if 0.5 < x

    1. Initial program 62.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(x + x\right) + \frac{\color{blue}{0.5}}{x}\right), x\right) \]
    7. Simplified97.8%

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

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

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

Alternative 9: 97.4% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.5:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\mathsf{copysign}\left(x, 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 -1.5)
   (copysign (- (log (* x -2.0))) x)
   (if (<= x 0.5) (copysign x x) (copysign (log (/ 0.5 x)) x))))
float code(float x) {
	float tmp;
	if (x <= -1.5f) {
		tmp = copysignf(-logf((x * -2.0f)), x);
	} else if (x <= 0.5f) {
		tmp = copysignf(x, x);
	} else {
		tmp = copysignf(logf((0.5f / x)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-1.5))
		tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x);
	elseif (x <= Float32(0.5))
		tmp = copysign(x, 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(-1.5))
		tmp = sign(x) * abs(-log((x * single(-2.0))));
	elseif (x <= single(0.5))
		tmp = sign(x) * abs(x);
	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 -1.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\

\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, 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 < -1.5

    1. Initial program 53.2%

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

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

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

      \[\leadsto \color{blue}{\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+6.0%

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

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

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

      \[\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) \]
    7. Step-by-step derivation
      1. sub-neg11.6%

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

        \[\leadsto \mathsf{copysign}\left(\log \left(-\color{blue}{\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) \]
      3. fma-undefine11.1%

        \[\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) \]
      4. unpow211.1%

        \[\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) \]
      5. associate--r+49.9%

        \[\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) \]
      6. +-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) \]
      7. 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) \]
      8. 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) \]
      9. metadata-eval99.9%

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

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

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

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

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

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

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

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

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

    if -1.5 < x < 0.5

    1. Initial program 26.2%

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

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

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

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

      \[\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) \]
    6. Step-by-step derivation
      1. +-commutative24.6%

        \[\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-define24.6%

        \[\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-sqrt11.1%

        \[\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-sqr11.1%

        \[\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-sqrt23.4%

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

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

        \[\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-sqrt96.2%

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

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{x + -0.16666666666666666 \cdot {x}^{3}}, x\right) \]
    9. Taylor expanded in x around 0 95.6%

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

    if 0.5 < x

    1. Initial program 62.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(x + x\right) + \frac{\color{blue}{0.5}}{x}\right), x\right) \]
    7. Simplified97.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\mathsf{copysign}\left(x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 68.7% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 55.4%

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

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

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

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

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

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

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

    if -0.5 < x

    1. Initial program 36.8%

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 64.4% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\mathsf{copysign}\left(14.333333333333334, 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 14.333333333333334 x) (copysign (log1p x) x)))
float code(float x) {
	float tmp;
	if (x <= -1.0f) {
		tmp = copysignf(14.333333333333334f, x);
	} else {
		tmp = copysignf(log1pf(x), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-1.0))
		tmp = copysign(Float32(14.333333333333334), 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(14.333333333333334, 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 54.7%

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(x + \left(\left|x\right| + 0.5 \cdot \frac{1}{x}\right)\right)}, x\right) \]
    6. Step-by-step derivation
      1. rem-square-sqrt-0.0%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(x + x\right) + \frac{\color{blue}{0.5}}{x}\right), x\right) \]
    7. Simplified-0.0%

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log 0.5 + \left(-8 \cdot {x}^{4} + \left(-1 \cdot \log x + \left(4 \cdot {x}^{2} + 21.333333333333332 \cdot {x}^{6}\right)\right)\right)}, x\right) \]
    9. Simplified26.5%

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

    if -1 < x

    1. Initial program 37.1%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\mathsf{copysign}\left(14.333333333333334, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 61.7% accurate, 3.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -200 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\mathsf{copysign}\left(14.333333333333334, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(x, x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (or (<= x -200.0) (not (<= x 4.0)))
   (copysign 14.333333333333334 x)
   (copysign x x)))
float code(float x) {
	float tmp;
	if ((x <= -200.0f) || !(x <= 4.0f)) {
		tmp = copysignf(14.333333333333334f, x);
	} else {
		tmp = copysignf(x, x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if ((x <= Float32(-200.0)) || !(x <= Float32(4.0)))
		tmp = copysign(Float32(14.333333333333334), x);
	else
		tmp = copysign(x, x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if ((x <= single(-200.0)) || ~((x <= single(4.0))))
		tmp = sign(x) * abs(single(14.333333333333334));
	else
		tmp = sign(x) * abs(x);
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -200 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;\mathsf{copysign}\left(14.333333333333334, x\right)\\

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


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

    1. Initial program 56.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log 0.5 + \left(-8 \cdot {x}^{4} + \left(-1 \cdot \log x + \left(4 \cdot {x}^{2} + 21.333333333333332 \cdot {x}^{6}\right)\right)\right)}, x\right) \]
    9. Simplified27.2%

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

    if -200 < x < 4

    1. Initial program 27.8%

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

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

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

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

      \[\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) \]
    6. Step-by-step derivation
      1. +-commutative24.8%

        \[\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-define24.8%

        \[\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-sqrt11.1%

        \[\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-sqr11.1%

        \[\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-sqrt23.6%

        \[\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-define94.1%

        \[\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-sqrt39.2%

        \[\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-sqr39.2%

        \[\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-sqrt94.4%

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

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{x + -0.16666666666666666 \cdot {x}^{3}}, x\right) \]
    9. Taylor expanded in x around 0 94.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -200 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\mathsf{copysign}\left(14.333333333333334, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(x, x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 17.7% accurate, 4.0× speedup?

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

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

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

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

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

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

    \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(x + \left(\left|x\right| + 0.5 \cdot \frac{1}{x}\right)\right)}, x\right) \]
  6. Step-by-step derivation
    1. rem-square-sqrt26.9%

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

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(\log \left(\left(x + x\right) + \frac{\color{blue}{0.5}}{x}\right), x\right) \]
  7. Simplified26.9%

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

    \[\leadsto \mathsf{copysign}\left(\color{blue}{\log 0.5 + \left(-8 \cdot {x}^{4} + \left(-1 \cdot \log x + 4 \cdot {x}^{2}\right)\right)}, x\right) \]
  9. Simplified17.7%

    \[\leadsto \mathsf{copysign}\left(\color{blue}{-7}, x\right) \]
  10. Final simplification17.7%

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

Alternative 14: 18.7% accurate, 4.0× speedup?

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

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

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

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

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

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

    \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(x + \left(\left|x\right| + 0.5 \cdot \frac{1}{x}\right)\right)}, x\right) \]
  6. Step-by-step derivation
    1. rem-square-sqrt26.9%

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

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(\log \left(\left(x + x\right) + \frac{\color{blue}{0.5}}{x}\right), x\right) \]
  7. Simplified26.9%

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

    \[\leadsto \mathsf{copysign}\left(\color{blue}{\log 0.5 + \left(-8 \cdot {x}^{4} + \left(-1 \cdot \log x + \left(4 \cdot {x}^{2} + 21.333333333333332 \cdot {x}^{6}\right)\right)\right)}, x\right) \]
  9. Simplified18.5%

    \[\leadsto \mathsf{copysign}\left(\color{blue}{14.333333333333334}, x\right) \]
  10. Final simplification18.5%

    \[\leadsto \mathsf{copysign}\left(14.333333333333334, x\right) \]
  11. Add Preprocessing

Developer target: 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 2024043 
(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))