Rust f32::asinh

Percentage Accurate: 37.6% → 98.7%
Time: 10.9s
Alternatives: 13
Speedup: 4.0×

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 37.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \end{array} \]
(FPCore (x)
 :precision binary32
 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
	return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x)
	return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x)
end
function tmp = code(x)
	tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0))))));
end
\begin{array}{l}

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

Alternative 1: 98.7% accurate, 1.3× speedup?

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

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

    1. Initial program 48.3%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \left(-\frac{\color{blue}{0.5}}{x}\right)\right), x\right) \]
      6. distribute-neg-frac99.9%

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

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

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

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

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

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

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

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

    if -10 < x < 0.0500000007

    1. Initial program 19.3%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Applied egg-rr19.6%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + \left(\color{blue}{x \cdot x} - x \cdot \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
      8. distribute-lft-out--97.3%

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + x \cdot \left(x - \mathsf{hypot}\left(1, x\right)\right)\right)}, x\right) \]
    6. Taylor expanded in x around 0 99.3%

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

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

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

    if 0.0500000007 < x

    1. Initial program 61.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.1% accurate, 0.5× 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 -2:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x) -2.0)
   (copysign (log (+ (fabs x) (hypot 1.0 x))) x)
   (copysign (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) <= -2.0f) {
		tmp = copysignf(logf((fabsf(x) + hypotf(1.0f, x))), x);
	} else {
		tmp = copysignf(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(-2.0))
		tmp = copysign(log(Float32(abs(x) + hypot(Float32(1.0), x))), x);
	else
		tmp = copysign(log1p(Float32(x + Float32(hypot(Float32(1.0), x) + Float32(-1.0)))), x);
	end
	return tmp
end
\begin{array}{l}

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

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


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

    1. Initial program 48.3%

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

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

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

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

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

    1. Initial program 33.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(\color{blue}{x} + \mathsf{hypot}\left(1, x\right)\right) \cdot \log \left(e^{1}\right)\right), x\right) \]
    4. Applied egg-rr44.9%

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(x + \mathsf{hypot}\left(1, x\right)\right) \cdot \log \left(e^{1}\right)\right)}, x\right) \]
    5. Step-by-step derivation
      1. log1p-expm1-u44.9%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(x + \mathsf{hypot}\left(1, x\right)\right) \cdot 1} - 1\right), x\right) \]
      5. *-rgt-identity45.3%

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

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

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

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

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

Alternative 3: 98.1% accurate, 1.3× speedup?

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

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

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


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

    1. Initial program 48.3%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \left(-\frac{\color{blue}{0.5}}{x}\right)\right), x\right) \]
      6. distribute-neg-frac99.9%

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

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

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

    if -10 < x

    1. Initial program 33.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(\color{blue}{x} + \mathsf{hypot}\left(1, x\right)\right) \cdot \log \left(e^{1}\right)\right), x\right) \]
    4. Applied egg-rr44.9%

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(x + \mathsf{hypot}\left(1, x\right)\right) \cdot \log \left(e^{1}\right)\right)}, x\right) \]
    5. Step-by-step derivation
      1. log1p-expm1-u44.9%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(x + \mathsf{hypot}\left(1, x\right)\right) \cdot 1} - 1\right), x\right) \]
      5. *-rgt-identity45.3%

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

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

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

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

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

Alternative 4: 98.1% accurate, 1.3× speedup?

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

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

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


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

    1. Initial program 48.3%

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

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

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

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

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

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

    if -10 < x

    1. Initial program 33.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(\color{blue}{x} + \mathsf{hypot}\left(1, x\right)\right) \cdot \log \left(e^{1}\right)\right), x\right) \]
    4. Applied egg-rr44.9%

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(x + \mathsf{hypot}\left(1, x\right)\right) \cdot \log \left(e^{1}\right)\right)}, x\right) \]
    5. Step-by-step derivation
      1. log1p-expm1-u44.9%

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(x + \mathsf{hypot}\left(1, x\right)\right) \cdot 1} - 1\right), x\right) \]
      5. *-rgt-identity45.3%

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

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

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

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

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

Alternative 5: 98.0% accurate, 1.3× speedup?

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

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

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


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

    1. Initial program 46.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 100.0%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \left(-\frac{\color{blue}{0.5}}{x}\right)\right), x\right) \]
      6. distribute-neg-frac100.0%

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

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

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

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

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

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

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

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

    if -400 < x

    1. Initial program 33.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{log1p}\left(\color{blue}{\left(x + \mathsf{hypot}\left(1, x\right)\right) \cdot 1} - 1\right), x\right) \]
      5. *-rgt-identity45.7%

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

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

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

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

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

Alternative 6: 98.2% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -10:\\ \;\;\;\;\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(\mathsf{log1p}\left(x + \left(x + \left(\frac{0.5}{x} + -1\right)\right)\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -10.0)
   (copysign (log (/ -0.5 x)) x)
   (if (<= x 1.0)
     (copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
     (copysign (log1p (+ x (+ x (+ (/ 0.5 x) -1.0)))) x))))
float code(float x) {
	float tmp;
	if (x <= -10.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(log1pf((x + (x + ((0.5f / x) + -1.0f)))), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-10.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(log1p(Float32(x + Float32(x + Float32(Float32(Float32(0.5) / x) + Float32(-1.0))))), x);
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\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(\mathsf{log1p}\left(x + \left(x + \left(\frac{0.5}{x} + -1\right)\right)\right), x\right)\\


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

    1. Initial program 48.3%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \left(-\frac{\color{blue}{0.5}}{x}\right)\right), x\right) \]
      6. distribute-neg-frac99.9%

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

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

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

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

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

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

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

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

    if -10 < x < 1

    1. Initial program 21.6%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Applied egg-rr21.8%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + \left(\color{blue}{x \cdot x} - x \cdot \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
      8. distribute-lft-out--97.2%

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

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

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

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

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

    if 1 < x

    1. Initial program 59.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 97.9% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -10:\\ \;\;\;\;\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(x \cdot 2\right), x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -10.0)
   (copysign (log (/ -0.5 x)) x)
   (if (<= x 1.0)
     (copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
     (copysign (log (* x 2.0)) x))))
float code(float x) {
	float tmp;
	if (x <= -10.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((x * 2.0f)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-10.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(log(Float32(x * Float32(2.0))), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-10.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((x * single(2.0))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\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(x \cdot 2\right), x\right)\\


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

    1. Initial program 48.3%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \left(-\frac{\color{blue}{0.5}}{x}\right)\right), x\right) \]
      6. distribute-neg-frac99.9%

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

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

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

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

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

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

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

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

    if -10 < x < 1

    1. Initial program 21.6%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Applied egg-rr21.8%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + \left(\color{blue}{x \cdot x} - x \cdot \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
      8. distribute-lft-out--97.2%

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

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

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

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

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

    if 1 < x

    1. Initial program 59.6%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Applied egg-rr36.5%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + \left(\color{blue}{x \cdot x} - x \cdot \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
      8. distribute-lft-out--36.5%

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

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\left(\log 2 + -3 \cdot \log \left(\frac{1}{x}\right)\right) - -2 \cdot \log \left(\frac{1}{x}\right)}, x\right) \]
    7. Step-by-step derivation
      1. associate--l+95.0%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\left(-\color{blue}{\left(-\log x\right)}\right) + \log 2, x\right) \]
      8. remove-double-neg96.5%

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

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

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

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

Alternative 8: 83.8% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -10:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(-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 -10.0)
   (copysign (log (- x)) x)
   (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
	float tmp;
	if (x <= -10.0f) {
		tmp = copysignf(logf(-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(-10.0))
		tmp = copysign(log(Float32(-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(-10.0))
		tmp = sign(x) * abs(log(-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 -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-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 < -10

    1. Initial program 48.3%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \left(-\frac{\color{blue}{0.5}}{x}\right)\right), x\right) \]
      6. distribute-neg-frac99.9%

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

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

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

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

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

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

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

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

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

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

    if -10 < x < 1

    1. Initial program 21.6%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Applied egg-rr21.8%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + \left(\color{blue}{x \cdot x} - x \cdot \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
      8. distribute-lft-out--97.2%

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + x \cdot \left(x - \mathsf{hypot}\left(1, x\right)\right)\right)}, x\right) \]
    6. Taylor expanded in x around 0 96.6%

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

    if 1 < x

    1. Initial program 59.6%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Applied egg-rr36.5%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + \left(\color{blue}{x \cdot x} - x \cdot \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
      8. distribute-lft-out--36.5%

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

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\left(\log 2 + -3 \cdot \log \left(\frac{1}{x}\right)\right) - -2 \cdot \log \left(\frac{1}{x}\right)}, x\right) \]
    7. Step-by-step derivation
      1. associate--l+95.0%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\left(-\color{blue}{\left(-\log x\right)}\right) + \log 2, x\right) \]
      8. remove-double-neg96.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -10:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(-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} \]
  5. Add Preprocessing

Alternative 9: 97.1% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -10:\\ \;\;\;\;\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 -10.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 <= -10.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(-10.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(-10.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 -10:\\
\;\;\;\;\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 < -10

    1. Initial program 48.3%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \left(-\frac{\color{blue}{0.5}}{x}\right)\right), x\right) \]
      6. distribute-neg-frac99.9%

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

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

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

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

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

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

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

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

    if -10 < x < 1

    1. Initial program 21.6%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Applied egg-rr21.8%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + \left(\color{blue}{x \cdot x} - x \cdot \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
      8. distribute-lft-out--97.2%

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + x \cdot \left(x - \mathsf{hypot}\left(1, x\right)\right)\right)}, x\right) \]
    6. Taylor expanded in x around 0 96.6%

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

    if 1 < x

    1. Initial program 59.6%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Applied egg-rr36.5%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + \left(\color{blue}{x \cdot x} - x \cdot \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
      8. distribute-lft-out--36.5%

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

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\left(\log 2 + -3 \cdot \log \left(\frac{1}{x}\right)\right) - -2 \cdot \log \left(\frac{1}{x}\right)}, x\right) \]
    7. Step-by-step derivation
      1. associate--l+95.0%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\left(-\color{blue}{\left(-\log x\right)}\right) + \log 2, x\right) \]
      8. remove-double-neg96.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -10:\\ \;\;\;\;\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} \]
  5. Add Preprocessing

Alternative 10: 68.9% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 48.3%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \left(-\frac{\color{blue}{0.5}}{x}\right)\right), x\right) \]
      6. distribute-neg-frac99.9%

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

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

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

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

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

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

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

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

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

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

    if -10 < x

    1. Initial program 33.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 0 25.6%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{e^{\mathsf{log1p}\left(\mathsf{log1p}\left(\left|x\right|\right)\right)} - 1}, x\right) \]
      3. add-sqr-sqrt20.5%

        \[\leadsto \mathsf{copysign}\left(e^{\mathsf{log1p}\left(\mathsf{log1p}\left(\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|\right)\right)} - 1, x\right) \]
      4. fabs-sqr20.5%

        \[\leadsto \mathsf{copysign}\left(e^{\mathsf{log1p}\left(\mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)\right)} - 1, x\right) \]
      5. add-sqr-sqrt25.7%

        \[\leadsto \mathsf{copysign}\left(e^{\mathsf{log1p}\left(\mathsf{log1p}\left(\color{blue}{x}\right)\right)} - 1, x\right) \]
    7. Applied egg-rr25.7%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{e^{\mathsf{log1p}\left(\mathsf{log1p}\left(x\right)\right)} - 1}, x\right) \]
    8. Step-by-step derivation
      1. expm1-def78.4%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{log1p}\left(x\right)\right)\right)}, x\right) \]
      2. expm1-log1p78.4%

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

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

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

Alternative 11: 62.8% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 31.0%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Applied egg-rr16.8%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + \left(\color{blue}{x \cdot x} - x \cdot \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
      8. distribute-lft-out--66.4%

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + x \cdot \left(x - \mathsf{hypot}\left(1, x\right)\right)\right)}, x\right) \]
    6. Taylor expanded in x around 0 67.3%

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

    if 3.20000005 < x

    1. Initial program 58.9%

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

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

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

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

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

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

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

Alternative 12: 62.8% 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 30.6%

      \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
    2. Add Preprocessing
    3. Applied egg-rr16.4%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + \left(\color{blue}{x \cdot x} - x \cdot \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
      8. distribute-lft-out--66.3%

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + x \cdot \left(x - \mathsf{hypot}\left(1, x\right)\right)\right)}, x\right) \]
    6. Taylor expanded in x around 0 67.5%

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

    if 1 < x

    1. Initial program 59.6%

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{log1p}\left(\left|x\right|\right)\right)\right)}, x\right) \]
      2. expm1-udef43.9%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{e^{\mathsf{log1p}\left(\mathsf{log1p}\left(\left|x\right|\right)\right)} - 1}, x\right) \]
      3. add-sqr-sqrt43.9%

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

        \[\leadsto \mathsf{copysign}\left(e^{\mathsf{log1p}\left(\mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)\right)} - 1, x\right) \]
      5. add-sqr-sqrt43.9%

        \[\leadsto \mathsf{copysign}\left(e^{\mathsf{log1p}\left(\mathsf{log1p}\left(\color{blue}{x}\right)\right)} - 1, x\right) \]
    7. Applied egg-rr43.9%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{e^{\mathsf{log1p}\left(\mathsf{log1p}\left(x\right)\right)} - 1}, x\right) \]
    8. Step-by-step derivation
      1. expm1-def43.9%

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

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

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

    \[\leadsto \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} \]
  5. Add Preprocessing

Alternative 13: 54.7% 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 37.2%

    \[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
  2. Add Preprocessing
  3. Applied egg-rr20.9%

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

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

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

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + \left(\color{blue}{x \cdot x} - x \cdot \mathsf{hypot}\left(1, x\right)\right)\right), x\right) \]
    8. distribute-lft-out--59.5%

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

    \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left({x}^{3} + {\left(\mathsf{hypot}\left(1, x\right)\right)}^{3}\right) - \mathsf{log1p}\left({x}^{2} + x \cdot \left(x - \mathsf{hypot}\left(1, x\right)\right)\right)}, x\right) \]
  6. Taylor expanded in x around 0 54.9%

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

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

Developer target: 99.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\left|x\right|}\\ \mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right| + \frac{\left|x\right|}{\mathsf{hypot}\left(1, t_0\right) + t_0}\right), x\right) \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (let* ((t_0 (/ 1.0 (fabs x))))
   (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 t_0) t_0)))) x)))
float code(float x) {
	float t_0 = 1.0f / fabsf(x);
	return copysignf(log1pf((fabsf(x) + (fabsf(x) / (hypotf(1.0f, t_0) + t_0)))), x);
}
function code(x)
	t_0 = Float32(Float32(1.0) / abs(x))
	return copysign(log1p(Float32(abs(x) + Float32(abs(x) / Float32(hypot(Float32(1.0), t_0) + t_0)))), x)
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right| + \frac{\left|x\right|}{\mathsf{hypot}\left(1, t_0\right) + t_0}\right), x\right)
\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024013 
(FPCore (x)
  :name "Rust f32::asinh"
  :precision binary32

  :herbie-target
  (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 (/ 1.0 (fabs x))) (/ 1.0 (fabs x)))))) x)

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