Rust f32::asinh

Percentage Accurate: 38.0% → 99.6%
Time: 7.0s
Alternatives: 14
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 14 alternatives:

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

Initial Program: 38.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.6% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_0 \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left({x}^{2} \cdot \left(0.075 + {x}^{2} \cdot -0.044642857142857144\right) - 0.16666666666666666\right)\right), x\right)\\

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


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

    1. Initial program 48.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 19.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 54.5%

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

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

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

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

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

Alternative 2: 99.6% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_0 \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + {x}^{2} \cdot \left({x}^{2} \cdot 0.075 - 0.16666666666666666\right)\right), x\right)\\

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


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

    1. Initial program 48.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 18.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 55.1%

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

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

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

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

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

Alternative 3: 99.6% accurate, 1.3× speedup?

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

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

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


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

    1. Initial program 48.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.200000003 < x < 0.100000001

    1. Initial program 18.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.100000001 < x

    1. Initial program 55.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 98.8% accurate, 1.3× speedup?

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

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

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


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

    1. Initial program 46.8%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right) + \log 1}, x\right) \]
      4. add-sqr-sqrt-0.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) \]
      5. fabs-sqr-0.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) \]
      6. add-sqr-sqrt15.4%

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

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

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

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

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

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

    if -4 < x < 0.0199999996

    1. Initial program 19.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0199999996 < x

    1. Initial program 55.6%

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

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

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

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

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

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

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

        \[\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) \]
      5. fabs-sqr98.5%

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

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

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

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

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

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

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

Alternative 5: 99.5% accurate, 1.3× speedup?

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

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

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

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


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

    1. Initial program 48.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(-1 \cdot x - \frac{\mathsf{hypot}\left(1, x\right)}{\color{blue}{-1}}\right), x\right) \]
      17. *-rgt-identity98.0%

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

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

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

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

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

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

    if -0.200000003 < x < 0.0199999996

    1. Initial program 18.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0199999996 < x

    1. Initial program 55.6%

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

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

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

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

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

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

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

        \[\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) \]
      5. fabs-sqr98.5%

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

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

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

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

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

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

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

Alternative 6: 99.5% accurate, 1.3× speedup?

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

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

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

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


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

    1. Initial program 48.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.200000003 < x < 0.0199999996

    1. Initial program 18.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0199999996 < x

    1. Initial program 55.6%

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

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

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

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

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

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

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

        \[\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) \]
      5. fabs-sqr98.5%

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

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

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

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

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

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

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

Alternative 7: 97.9% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 46.8%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right) + \log 1}, x\right) \]
      4. add-sqr-sqrt-0.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) \]
      5. fabs-sqr-0.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) \]
      6. add-sqr-sqrt15.4%

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

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

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

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

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

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

    if -4 < x < 0.200000003

    1. Initial program 20.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.200000003 < x

    1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(-1 \cdot x - \frac{\mathsf{hypot}\left(1, x\right)}{\color{blue}{-1}}\right), x\right) \]
      17. *-rgt-identity12.1%

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(-1 \cdot x - \mathsf{hypot}\left(1, x\right) \cdot \color{blue}{-1}\right), x\right) \]
      20. *-commutative12.1%

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

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

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

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

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

Alternative 8: 97.9% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 46.8%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right) + \log 1}, x\right) \]
      4. add-sqr-sqrt-0.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) \]
      5. fabs-sqr-0.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) \]
      6. add-sqr-sqrt15.4%

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

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

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

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

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

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

    if -4 < x < 0.200000003

    1. Initial program 20.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.200000003 < x

    1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(-1 \cdot x - \frac{\mathsf{hypot}\left(1, x\right)}{\color{blue}{-1}}\right), x\right) \]
      17. *-rgt-identity12.1%

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(-1 \cdot x - \mathsf{hypot}\left(1, x\right) \cdot \color{blue}{-1}\right), x\right) \]
      20. *-commutative12.1%

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

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

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

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

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

Alternative 9: 97.2% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 46.8%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right) + \log 1}, x\right) \]
      4. add-sqr-sqrt-0.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) \]
      5. fabs-sqr-0.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) \]
      6. add-sqr-sqrt15.4%

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

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

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

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

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

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

    if -4 < x < 0.200000003

    1. Initial program 20.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.200000003 < x

    1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(-1 \cdot x - \frac{\mathsf{hypot}\left(1, x\right)}{\color{blue}{-1}}\right), x\right) \]
      17. *-rgt-identity12.1%

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

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

        \[\leadsto \mathsf{copysign}\left(-\log \left(-1 \cdot x - \mathsf{hypot}\left(1, x\right) \cdot \color{blue}{-1}\right), x\right) \]
      20. *-commutative12.1%

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

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

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

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

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

Alternative 10: 83.7% accurate, 1.9× speedup?

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

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

    1. Initial program 46.8%

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

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

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

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

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

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

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

    if -4 < x < 0.200000003

    1. Initial program 20.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.200000003 < x

    1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\ \mathbf{elif}\;x \leq 0.20000000298023224:\\ \;\;\;\;\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 11: 97.0% accurate, 1.9× speedup?

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

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

    1. Initial program 46.8%

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right) + \log 1}, x\right) \]
      4. add-sqr-sqrt-0.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) \]
      5. fabs-sqr-0.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) \]
      6. add-sqr-sqrt15.4%

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

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

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

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

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

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

    if -4 < x < 0.200000003

    1. Initial program 20.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.200000003 < x

    1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 0.20000000298023224:\\ \;\;\;\;\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 12: 68.5% accurate, 2.0× speedup?

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

    1. Initial program 47.7%

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

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

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

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

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

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

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

    if -1 < x

    1. Initial program 32.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 27.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.200000003 < x

    1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 53.8% 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 35.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Developer target: 99.6% accurate, 0.6× speedup?

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

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

Reproduce

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

  :alt
  (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))