Rust f32::asinh

Percentage Accurate: 36.6% → 99.6%
Time: 9.7s
Alternatives: 13
Speedup: 4.0×

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 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: 36.6% 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.20000000298023224:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\ \mathbf{elif}\;t\_0 \leq 0.20000000298023224:\\ \;\;\;\;\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.20000000298023224)
     (copysign (- (log (- (hypot 1.0 x) x))) x)
     (if (<= t_0 0.20000000298023224)
       (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.20000000298023224f) {
		tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
	} else if (t_0 <= 0.20000000298023224f) {
		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.20000000298023224))
		tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x);
	elseif (t_0 <= Float32(0.20000000298023224))
		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.20000000298023224))
		tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x)));
	elseif (t_0 <= single(0.20000000298023224))
		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.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\

\mathbf{elif}\;t\_0 \leq 0.20000000298023224:\\
\;\;\;\;\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.200000003

    1. Initial program 52.6%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(-\left(\left|x\right| \cdot \left|x\right| - \sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}\right)\right) - \log \left(-\left(\left|x\right| - \sqrt{x \cdot x + 1}\right)\right)}, x\right) \]
    4. Applied egg-rr14.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) \]
    5. Step-by-step derivation
      1. neg-sub014.0%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(0 - \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) \]
      2. associate--r-14.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 22.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(x + \mathsf{hypot}\left(1, x\right)\right)}, x\right) \]
    7. Taylor expanded in x around 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.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x)

    1. Initial program 52.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq -0.20000000298023224:\\ \;\;\;\;\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.20000000298023224:\\ \;\;\;\;\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.0% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 0.004999999888241291:\\ \;\;\;\;\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 x)))) x)
   (if (<= x 0.004999999888241291)
     (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 / x))), x);
	} else if (x <= 0.004999999888241291f) {
		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) / x)))), x);
	elseif (x <= Float32(0.004999999888241291))
		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) / x))));
	elseif (x <= single(0.004999999888241291))
		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 - \frac{0.5}{x}\right), x\right)\\

\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\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 51.9%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(0 - \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) \]
      2. associate--r-12.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(-\log \color{blue}{\left(-2 \cdot x - 0.5 \cdot \frac{1}{x}\right)}, x\right) \]
    8. Step-by-step derivation
      1. *-commutative97.7%

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

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

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

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

    if -1 < x < 0.00499999989

    1. Initial program 22.9%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{1 + x}, \color{blue}{\mathsf{log1p}\left(\left|x\right|\right)}\right), x\right) \]
      7. rem-square-sqrt47.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-sqr47.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-sqrt99.0%

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

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

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

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

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

    if 0.00499999989 < x

    1. Initial program 53.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.10000000149011612:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\ \mathbf{elif}\;x \leq 0.004999999888241291:\\ \;\;\;\;\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.10000000149011612)
   (copysign (- (log (- (hypot 1.0 x) x))) x)
   (if (<= x 0.004999999888241291)
     (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.10000000149011612f) {
		tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
	} else if (x <= 0.004999999888241291f) {
		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.10000000149011612))
		tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x);
	elseif (x <= Float32(0.004999999888241291))
		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.10000000149011612))
		tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x)));
	elseif (x <= single(0.004999999888241291))
		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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\

\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\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.100000001

    1. Initial program 53.1%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(-\left(\left|x\right| \cdot \left|x\right| - \sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}\right)\right) - \log \left(-\left(\left|x\right| - \sqrt{x \cdot x + 1}\right)\right)}, x\right) \]
    4. Applied egg-rr15.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) \]
    5. Step-by-step derivation
      1. neg-sub015.0%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(0 - \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) \]
      2. associate--r-15.0%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(1 + \color{blue}{0}\right) - \log \left(-\left(x - \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
      11. 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) \]
      12. metadata-eval99.8%

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

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

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

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

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

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

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

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

    if -0.100000001 < x < 0.00499999989

    1. Initial program 21.6%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 22.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) \]
    4. Step-by-step derivation
      1. +-commutative22.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-define22.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.6%

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

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

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

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

        \[\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.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) \]
    5. Simplified99.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) \]
    6. Taylor expanded in x around 0 100.0%

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

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

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

    if 0.00499999989 < x

    1. Initial program 53.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\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} + \left(x + x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -1.0)
   (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 x))) x))))
float code(float x) {
	float tmp;
	if (x <= -1.0f) {
		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 + x))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-1.0))
		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(Float32(0.5) / x) + Float32(x + 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))));
	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) + (x + 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\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} + \left(x + x\right)\right), x\right)\\


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

    1. Initial program 51.9%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(0 - \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) \]
      2. associate--r-12.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1 < x < 0.5

    1. Initial program 24.7%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 23.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) \]
    4. Step-by-step derivation
      1. +-commutative23.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-define23.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-sqrt12.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-sqr12.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-sqrt23.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-define97.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-sqrt47.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-sqr47.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-sqrt97.8%

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

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

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

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

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

    if 0.5 < x

    1. Initial program 51.1%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\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} + \left(x + x\right)\right), x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 98.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{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} + \left(x + x\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -1.0)
   (copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
   (if (<= x 0.5)
     (copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
     (copysign (log (+ (/ 0.5 x) (+ x x))) x))))
float code(float x) {
	float tmp;
	if (x <= -1.0f) {
		tmp = copysignf(-logf(((x * -2.0f) - (0.5f / 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 + 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) / 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(Float32(0.5) / x) + Float32(x + 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) / 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) + (x + 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 - \frac{0.5}{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} + \left(x + x\right)\right), x\right)\\


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

    1. Initial program 51.9%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(0 - \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) \]
      2. associate--r-12.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(-\log \color{blue}{\left(-2 \cdot x - 0.5 \cdot \frac{1}{x}\right)}, x\right) \]
    8. Step-by-step derivation
      1. *-commutative97.7%

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

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

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

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

    if -1 < x < 0.5

    1. Initial program 24.7%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 23.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) \]
    4. Step-by-step derivation
      1. +-commutative23.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-define23.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-sqrt12.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-sqr12.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-sqrt23.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-define97.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-sqrt47.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-sqr47.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-sqrt97.8%

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

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

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

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

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

    if 0.5 < x

    1. Initial program 51.1%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{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} + \left(x + x\right)\right), x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 98.1% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\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.0)
   (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.0f) {
		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.0))
		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(Float32(-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))));
	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\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 51.9%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(0 - \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) \]
      2. associate--r-12.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1 < x < 0.5

    1. Initial program 24.7%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 23.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) \]
    4. Step-by-step derivation
      1. +-commutative23.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-define23.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-sqrt12.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-sqr12.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-sqrt23.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-define97.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-sqrt47.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-sqr47.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-sqrt97.8%

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

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

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

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

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

    if 0.5 < x

    1. Initial program 51.1%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(0 - \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) \]
      2. associate--r-7.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\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 7: 97.4% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\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.0)
   (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.0f) {
		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.0))
		tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x);
	elseif (x <= Float32(0.5))
		tmp = copysign(x, x);
	else
		tmp = copysign(Float32(-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))));
	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:\\
\;\;\;\;\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

    1. Initial program 51.9%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(0 - \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) \]
      2. associate--r-12.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1 < x < 0.5

    1. Initial program 24.7%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 23.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) \]
    4. Step-by-step derivation
      1. +-commutative23.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-define23.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-sqrt12.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-sqr12.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-sqrt23.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-define97.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-sqrt47.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-sqr47.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-sqrt97.8%

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

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

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

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

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

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

    if 0.5 < x

    1. Initial program 51.1%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(0 - \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) \]
      2. associate--r-7.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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:\\ \;\;\;\;\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 8: 97.5% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\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.0)
   (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.0f) {
		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.0))
		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.0))
		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:\\
\;\;\;\;\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

    1. Initial program 51.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(x + \left(\left(-\frac{\color{blue}{0.5}}{x}\right) - x\right)\right), x\right) \]
      11. distribute-neg-frac11.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(\frac{\color{blue}{-0.5}}{x} + \left(-x\right)\right) + x\right), x\right) \]
      5. distribute-neg-frac11.3%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(-0.5 \cdot \frac{1}{x}\right) + \color{blue}{0}\right), x\right) \]
      12. +-rgt-identity95.7%

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(-0.5 \cdot \frac{1}{x}\right)}, x\right) \]
      13. distribute-lft-neg-in95.7%

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

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

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

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

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

    if -1 < x < 0.5

    1. Initial program 24.7%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 23.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) \]
    4. Step-by-step derivation
      1. +-commutative23.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-define23.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-sqrt12.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-sqr12.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-sqrt23.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-define97.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-sqrt47.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-sqr47.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-sqrt97.8%

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

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

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

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

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

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

    if 0.5 < x

    1. Initial program 51.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\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 9: 97.3% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\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(x + x\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -1.0)
   (copysign (- (log (* x -2.0))) x)
   (if (<= x 0.5) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
	float tmp;
	if (x <= -1.0f) {
		tmp = copysignf(-logf((x * -2.0f)), 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.0))
		tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), 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.0))
		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((x + 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\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

    1. Initial program 51.9%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(0 - \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) \]
      2. associate--r-12.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1 < x < 0.5

    1. Initial program 24.7%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 23.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) \]
    4. Step-by-step derivation
      1. +-commutative23.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-define23.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-sqrt12.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-sqr12.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-sqrt23.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-define97.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-sqrt47.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-sqr47.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-sqrt97.8%

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

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

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

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

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

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

    if 0.5 < x

    1. Initial program 51.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\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(x + x\right), x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 63.0% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 34.4%

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

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

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

        \[\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-sqrt8.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-sqr8.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-sqrt19.1%

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

        \[\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-sqrt30.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-sqr30.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-sqrt62.6%

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

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

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

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

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

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

    if 0.5 < x

    1. Initial program 51.1%

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

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

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

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

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

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

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

Alternative 11: 76.4% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;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 0.5) (copysign x x) (copysign (log (+ x x)) x)))
float code(float x) {
	float tmp;
	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(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(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 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 2 regimes
  2. if x < 0.5

    1. Initial program 34.4%

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

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

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

        \[\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-sqrt8.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-sqr8.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-sqrt19.1%

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

        \[\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-sqrt30.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-sqr30.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-sqrt62.6%

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

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

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

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

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

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

    if 0.5 < x

    1. Initial program 51.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;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 12: 63.0% accurate, 2.0× speedup?

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

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


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

    1. Initial program 34.4%

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

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

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

        \[\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-sqrt8.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-sqr8.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-sqrt19.1%

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

        \[\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-sqrt30.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-sqr30.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-sqrt62.6%

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

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

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

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

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

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

    if 0.5 < x

    1. Initial program 51.1%

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

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

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

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

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

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

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

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

Alternative 13: 54.6% accurate, 4.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Developer target: 99.6% 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 2024044 
(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))