Rust f32::asinh

Percentage Accurate: 38.3% → 98.5%
Time: 8.9s
Alternatives: 8
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 8 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: 38.3% 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: 98.5% accurate, 1.3× speedup?

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

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

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

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


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

    1. Initial program 53.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -100 < x < 0.0399999991

    1. Initial program 25.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0399999991 < x

    1. Initial program 53.8%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\color{blue}{x} + \sqrt{1 + {x}^{2}}\right), x\right) \]
      4. metadata-eval53.8%

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

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

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

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

Alternative 2: 97.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq -5:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(3 \cdot \left(0.3333333333333333 \cdot \mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x) -5.0)
   (copysign (log (/ -0.5 x)) x)
   (copysign
    (* 3.0 (* 0.3333333333333333 (log1p (+ x (+ (hypot 1.0 x) -1.0)))))
    x)))
float code(float x) {
	float tmp;
	if (copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x) <= -5.0f) {
		tmp = copysignf(logf((-0.5f / x)), x);
	} else {
		tmp = copysignf((3.0f * (0.3333333333333333f * log1pf((x + (hypotf(1.0f, x) + -1.0f))))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) <= Float32(-5.0))
		tmp = copysign(log(Float32(Float32(-0.5) / x)), x);
	else
		tmp = copysign(Float32(Float32(3.0) * Float32(Float32(0.3333333333333333) * log1p(Float32(x + Float32(hypot(Float32(1.0), x) + Float32(-1.0)))))), x);
	end
	return tmp
end
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(3 \cdot \left(0.3333333333333333 \cdot \mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right)\right), x\right)\\


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

    1. Initial program 53.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 35.4%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{3 \cdot \log \left(\sqrt[3]{x + \mathsf{hypot}\left(1, x\right)}\right)}, x\right) \]
    5. Step-by-step derivation
      1. pow1/350.4%

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

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

      \[\leadsto \mathsf{copysign}\left(3 \cdot \color{blue}{\left(0.3333333333333333 \cdot \log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}, x\right) \]
    7. Step-by-step derivation
      1. log1p-expm1-u51.2%

        \[\leadsto \mathsf{copysign}\left(3 \cdot \left(0.3333333333333333 \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)\right)}\right), x\right) \]
      2. *-un-lft-identity51.2%

        \[\leadsto \mathsf{copysign}\left(3 \cdot \left(0.3333333333333333 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{1 \cdot \log \left(x + \mathsf{hypot}\left(1, x\right)\right)}\right)\right)\right), x\right) \]
      3. metadata-eval51.2%

        \[\leadsto \mathsf{copysign}\left(3 \cdot \left(0.3333333333333333 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\left(3 \cdot 0.3333333333333333\right)} \cdot \log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)\right)\right), x\right) \]
      4. associate-*r*51.2%

        \[\leadsto \mathsf{copysign}\left(3 \cdot \left(0.3333333333333333 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{3 \cdot \left(0.3333333333333333 \cdot \log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)}\right)\right)\right), x\right) \]
      5. expm1-undefine51.2%

        \[\leadsto \mathsf{copysign}\left(3 \cdot \left(0.3333333333333333 \cdot \mathsf{log1p}\left(\color{blue}{e^{3 \cdot \left(0.3333333333333333 \cdot \log \left(x + \mathsf{hypot}\left(1, x\right)\right)\right)} - 1}\right)\right), x\right) \]
      6. associate-*r*51.2%

        \[\leadsto \mathsf{copysign}\left(3 \cdot \left(0.3333333333333333 \cdot \mathsf{log1p}\left(e^{\color{blue}{\left(3 \cdot 0.3333333333333333\right) \cdot \log \left(x + \mathsf{hypot}\left(1, x\right)\right)}} - 1\right)\right), x\right) \]
      7. metadata-eval51.2%

        \[\leadsto \mathsf{copysign}\left(3 \cdot \left(0.3333333333333333 \cdot \mathsf{log1p}\left(e^{\color{blue}{1} \cdot \log \left(x + \mathsf{hypot}\left(1, x\right)\right)} - 1\right)\right), x\right) \]
      8. *-un-lft-identity51.2%

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

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

      \[\leadsto \mathsf{copysign}\left(3 \cdot \left(0.3333333333333333 \cdot \color{blue}{\mathsf{log1p}\left(\left(x + \mathsf{hypot}\left(1, x\right)\right) - 1\right)}\right), x\right) \]
    9. Step-by-step derivation
      1. associate--l+96.2%

        \[\leadsto \mathsf{copysign}\left(3 \cdot \left(0.3333333333333333 \cdot \mathsf{log1p}\left(\color{blue}{x + \left(\mathsf{hypot}\left(1, x\right) - 1\right)}\right)\right), x\right) \]
    10. Simplified96.2%

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

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

Alternative 3: 97.8% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 53.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -100 < x < 1

    1. Initial program 26.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 26.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1 < x

    1. Initial program 51.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. flip-+3.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. clear-num3.1%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\frac{\color{blue}{x \cdot 1}}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)} - \frac{\mathsf{hypot}\left(1, x\right)}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}\right), x\right) \]
      4. associate-/l*2.9%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\mathsf{fma}\left(x, -1, -\frac{\color{blue}{\mathsf{hypot}\left(1, x\right) \cdot 1}}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}\right)\right), x\right) \]
      13. associate-/l*2.9%

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\mathsf{fma}\left(x, -1, -\mathsf{hypot}\left(1, x\right) \cdot \frac{1}{\color{blue}{\left({x}^{2} - {x}^{2}\right) - 1}}\right)\right), x\right) \]
    6. Simplified8.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 99.9%

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

Alternative 4: 97.0% accurate, 1.9× speedup?

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

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

    1. Initial program 53.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -100 < x < 1

    1. Initial program 26.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. flip-+26.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\frac{\color{blue}{x \cdot 1}}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)} - \frac{\mathsf{hypot}\left(1, x\right)}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}\right), x\right) \]
      4. associate-/l*26.5%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\mathsf{fma}\left(x, -1, -\frac{\color{blue}{\mathsf{hypot}\left(1, x\right) \cdot 1}}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}\right)\right), x\right) \]
      13. associate-/l*26.5%

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

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

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

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

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

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

    if 1 < x

    1. Initial program 51.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. flip-+3.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. clear-num3.1%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\frac{\color{blue}{x \cdot 1}}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)} - \frac{\mathsf{hypot}\left(1, x\right)}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}\right), x\right) \]
      4. associate-/l*2.9%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\mathsf{fma}\left(x, -1, -\frac{\color{blue}{\mathsf{hypot}\left(1, x\right) \cdot 1}}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}\right)\right), x\right) \]
      13. associate-/l*2.9%

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\mathsf{fma}\left(x, -1, -\mathsf{hypot}\left(1, x\right) \cdot \frac{1}{\color{blue}{\left({x}^{2} - {x}^{2}\right) - 1}}\right)\right), x\right) \]
    6. Simplified8.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 99.9%

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

Alternative 5: 96.8% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 53.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -100 < x < 1

    1. Initial program 26.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. flip-+26.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\frac{\color{blue}{x \cdot 1}}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)} - \frac{\mathsf{hypot}\left(1, x\right)}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}\right), x\right) \]
      4. associate-/l*26.5%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\mathsf{fma}\left(x, -1, -\frac{\color{blue}{\mathsf{hypot}\left(1, x\right) \cdot 1}}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}\right)\right), x\right) \]
      13. associate-/l*26.5%

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

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

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

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

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

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

    if 1 < x

    1. Initial program 51.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 inf 98.5%

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

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

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

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

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

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

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

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

Alternative 6: 75.2% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 36.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. flip-+17.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\frac{\color{blue}{x \cdot 1}}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)} - \frac{\mathsf{hypot}\left(1, x\right)}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}\right), x\right) \]
      4. associate-/l*18.4%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\mathsf{fma}\left(x, -1, -\frac{\color{blue}{\mathsf{hypot}\left(1, x\right) \cdot 1}}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}\right)\right), x\right) \]
      13. associate-/l*18.4%

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\mathsf{fma}\left(x, -1, -\mathsf{hypot}\left(1, x\right) \cdot \frac{1}{\color{blue}{\left({x}^{2} - {x}^{2}\right) - 1}}\right)\right), x\right) \]
    6. Simplified53.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 0 65.1%

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

    if 1 < x

    1. Initial program 51.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 inf 98.5%

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

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

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

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

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

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

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

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

Alternative 7: 61.9% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 36.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. flip-+17.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\frac{\color{blue}{x \cdot 1}}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)} - \frac{\mathsf{hypot}\left(1, x\right)}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}\right), x\right) \]
      4. associate-/l*18.4%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\mathsf{fma}\left(x, -1, -\frac{\color{blue}{\mathsf{hypot}\left(1, x\right) \cdot 1}}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}\right)\right), x\right) \]
      13. associate-/l*18.4%

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(\mathsf{fma}\left(x, -1, -\mathsf{hypot}\left(1, x\right) \cdot \frac{1}{\color{blue}{\left({x}^{2} - {x}^{2}\right) - 1}}\right)\right), x\right) \]
    6. Simplified53.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 0 65.1%

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

    if 1 < x

    1. Initial program 51.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 44.5%

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

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

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

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

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

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

Alternative 8: 53.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 40.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(-\log \left(\frac{\color{blue}{x \cdot 1}}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)} - \frac{\mathsf{hypot}\left(1, x\right)}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}\right), x\right) \]
    4. associate-/l*14.5%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(-\log \left(\mathsf{fma}\left(x, -1, -\frac{\color{blue}{\mathsf{hypot}\left(1, x\right) \cdot 1}}{{x}^{2} - \mathsf{fma}\left(x, x, 1\right)}\right)\right), x\right) \]
    13. associate-/l*14.5%

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

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

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

      \[\leadsto \mathsf{copysign}\left(-\log \left(\mathsf{fma}\left(x, -1, -\mathsf{hypot}\left(1, x\right) \cdot \frac{1}{\color{blue}{\left({x}^{2} - {x}^{2}\right) - 1}}\right)\right), x\right) \]
  6. Simplified42.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 0 51.5%

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

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

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

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