Rust f32::asinh

Percentage Accurate: 37.8% → 98.5%
Time: 9.9s
Alternatives: 8
Speedup: 3.7×

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 37.8% accurate, 1.0× speedup?

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

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

Alternative 1: 98.5% accurate, 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.019999999552965164:\\ \;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(\left(\log 2 + \frac{0.25}{{x}^{2}}\right) + \log x, 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.019999999552965164)
       (copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
       (copysign (+ (+ (log 2.0) (/ 0.25 (pow x 2.0))) (log 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.019999999552965164f) {
		tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
	} else {
		tmp = copysignf(((logf(2.0f) + (0.25f / powf(x, 2.0f))) + logf(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.019999999552965164))
		tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x);
	else
		tmp = copysign(Float32(Float32(log(Float32(2.0)) + Float32(Float32(0.25) / (x ^ Float32(2.0)))) + log(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.019999999552965164))
		tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666)))));
	else
		tmp = sign(x) * abs(((log(single(2.0)) + (single(0.25) / (x ^ single(2.0)))) + log(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.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\left(\log 2 + \frac{0.25}{{x}^{2}}\right) + \log x, 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 49.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 17.5%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{x + 1}, \color{blue}{\mathsf{log1p}\left(\left|x\right|\right)}\right), x\right) \]
      8. rem-square-sqrt53.0%

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{x + 1}, \mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)\right), x\right) \]
      10. rem-square-sqrt99.9%

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{fma}\left(0.5, \frac{{x}^{2}}{x + 1}, \mathsf{log1p}\left(x\right)\right)}, x\right) \]
    6. 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) \]
    7. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

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

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

    1. Initial program 55.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log 2 + \left(0.25 \cdot \frac{1}{{x}^{2}} + \left(-\color{blue}{\left(-\log x\right)}\right)\right), x\right) \]
      4. remove-double-neg99.1%

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

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

        \[\leadsto \mathsf{copysign}\left(\left(\log 2 + \color{blue}{\frac{0.25 \cdot 1}{{x}^{2}}}\right) + \log x, x\right) \]
      7. metadata-eval99.2%

        \[\leadsto \mathsf{copysign}\left(\left(\log 2 + \frac{\color{blue}{0.25}}{{x}^{2}}\right) + \log x, x\right) \]
    8. Simplified99.2%

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

Alternative 2: 99.4% 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.009999999776482582:\\ \;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\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.009999999776482582)
       (copysign (* x (+ 1.0 (* (* x x) -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.009999999776482582f) {
		tmp = copysignf((x * (1.0f + ((x * x) * -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.009999999776482582))
		tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * 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.009999999776482582))
		tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * 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.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\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 49.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 16.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{x + 1}, \mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)\right), x\right) \]
      10. rem-square-sqrt100.0%

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{fma}\left(0.5, \frac{{x}^{2}}{x + 1}, \mathsf{log1p}\left(x\right)\right)}, x\right) \]
    6. 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) \]
    7. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

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

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

    1. Initial program 55.9%

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

        \[\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
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 99.4% 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.009999999776482582:\\ \;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \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 -0.20000000298023224)
   (copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
   (if (<= x 0.009999999776482582)
     (copysign (* x (+ 1.0 (* (* x x) -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.009999999776482582f) {
		tmp = copysignf((x * (1.0f + ((x * x) * -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.009999999776482582))
		tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * 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.009999999776482582))
		tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * 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.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \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 < -0.200000003

    1. Initial program 49.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 16.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{x + 1}, \mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)\right), x\right) \]
      10. rem-square-sqrt100.0%

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\mathsf{fma}\left(0.5, \frac{{x}^{2}}{x + 1}, \mathsf{log1p}\left(x\right)\right)}, x\right) \]
    6. 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) \]
    7. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

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

    if 0.00999999978 < x

    1. Initial program 55.9%

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

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

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

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

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

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

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

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

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

Alternative 4: 83.7% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-e}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 0.009999999776482582:\\ \;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \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 -5.0)
   (copysign (log (/ (- E) x)) x)
   (if (<= x 0.009999999776482582)
     (copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
     (copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
	float tmp;
	if (x <= -5.0f) {
		tmp = copysignf(logf((-((float) M_E) / x)), x);
	} else if (x <= 0.009999999776482582f) {
		tmp = copysignf((x * (1.0f + ((x * x) * -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(-5.0))
		tmp = copysign(log(Float32(Float32(-Float32(exp(1))) / x)), x);
	elseif (x <= Float32(0.009999999776482582))
		tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * 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(-5.0))
		tmp = sign(x) * abs(log((-single(2.71828182845904523536) / x)));
	elseif (x <= single(0.009999999776482582))
		tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-e}{x}\right), x\right)\\

\mathbf{elif}\;x \leq 0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \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 < -5

    1. Initial program 48.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{-1}{x}\right) + \color{blue}{\log \left(e^{\frac{\left|x\right|}{x}}\right)}, x\right) \]
      9. sum-log48.3%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{-1}{x} \cdot e^{\frac{\color{blue}{x}}{x}}\right), x\right) \]
      15. *-inverses40.4%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{-1}{x} \cdot e^{\color{blue}{1}}\right), x\right) \]
    7. Applied egg-rr40.4%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\frac{-1}{x} \cdot e\right)}, x\right) \]
    8. Step-by-step derivation
      1. associate-*l/40.4%

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{\color{blue}{-e}}{x}\right), x\right) \]
    9. Simplified40.4%

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

    if -5 < x < 0.00999999978

    1. Initial program 17.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{x + 1}, \mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)\right), x\right) \]
      10. rem-square-sqrt99.6%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(x \cdot \left(1 + \color{blue}{\left(x \cdot x\right)} \cdot -0.16666666666666666\right), x\right) \]
    10. Applied egg-rr99.7%

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

    if 0.00999999978 < x

    1. Initial program 55.9%

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

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

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

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

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

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

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

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

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

Alternative 5: 70.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5:\\ \;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-e}{x}\right), x\right)\\ \mathbf{elif}\;x \leq 0.019999999552965164:\\ \;\;\;\;\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{copysign}\left(1 + \log x, x\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary32
 (if (<= x -5.0)
   (copysign (log (/ (- E) x)) x)
   (if (<= x 0.019999999552965164)
     (copysign (* x (+ 1.0 (* (* x x) -0.16666666666666666))) x)
     (copysign (+ 1.0 (log x)) x))))
float code(float x) {
	float tmp;
	if (x <= -5.0f) {
		tmp = copysignf(logf((-((float) M_E) / x)), x);
	} else if (x <= 0.019999999552965164f) {
		tmp = copysignf((x * (1.0f + ((x * x) * -0.16666666666666666f))), x);
	} else {
		tmp = copysignf((1.0f + logf(x)), x);
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(-5.0))
		tmp = copysign(log(Float32(Float32(-Float32(exp(1))) / x)), x);
	elseif (x <= Float32(0.019999999552965164))
		tmp = copysign(Float32(x * Float32(Float32(1.0) + Float32(Float32(x * x) * Float32(-0.16666666666666666)))), x);
	else
		tmp = copysign(Float32(Float32(1.0) + log(x)), x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = single(0.0);
	if (x <= single(-5.0))
		tmp = sign(x) * abs(log((-single(2.71828182845904523536) / x)));
	elseif (x <= single(0.019999999552965164))
		tmp = sign(x) * abs((x * (single(1.0) + ((x * x) * single(-0.16666666666666666)))));
	else
		tmp = sign(x) * abs((single(1.0) + log(x)));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

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

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

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


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

    1. Initial program 48.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{-1}{x}\right) + \color{blue}{\log \left(e^{\frac{\left|x\right|}{x}}\right)}, x\right) \]
      9. sum-log48.3%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{-1}{x} \cdot e^{\frac{\color{blue}{x}}{x}}\right), x\right) \]
      15. *-inverses40.4%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{-1}{x} \cdot e^{\color{blue}{1}}\right), x\right) \]
    7. Applied egg-rr40.4%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\frac{-1}{x} \cdot e\right)}, x\right) \]
    8. Step-by-step derivation
      1. associate-*l/40.4%

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{\color{blue}{-e}}{x}\right), x\right) \]
    9. Simplified40.4%

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

    if -5 < x < 0.0199999996

    1. Initial program 18.1%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{x + 1}, \color{blue}{\mathsf{log1p}\left(\left|x\right|\right)}\right), x\right) \]
      8. rem-square-sqrt52.6%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(x \cdot \left(1 + \color{blue}{\left(x \cdot x\right)} \cdot -0.16666666666666666\right), x\right) \]
    10. Applied egg-rr99.7%

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

    if 0.0199999996 < x

    1. Initial program 55.3%

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 62.3% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 28.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{x + 1}, \mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)\right), x\right) \]
      10. rem-square-sqrt66.8%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(x \cdot \left(1 + \color{blue}{\left(x \cdot x\right)} \cdot -0.16666666666666666\right), x\right) \]
    10. Applied egg-rr69.6%

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

    if 0.0199999996 < x

    1. Initial program 55.3%

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 62.1% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 28.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(\mathsf{fma}\left(0.5, \frac{{x}^{2}}{x + 1}, \mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)\right), x\right) \]
      10. rem-square-sqrt66.8%

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

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

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

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

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

        \[\leadsto \mathsf{copysign}\left(x \cdot \left(1 + \color{blue}{\left(x \cdot x\right)} \cdot -0.16666666666666666\right), x\right) \]
    10. Applied egg-rr69.6%

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

    if 0.0199999996 < x

    1. Initial program 55.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\frac{x}{x} + \log x}, x\right) \]
    6. Step-by-step derivation
      1. add-log-exp46.9%

        \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(e^{\frac{x}{x} + \log x}\right)}, x\right) \]
      2. *-inverses46.9%

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

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

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(e^{\log x} \cdot e^{1}\right)}, x\right) \]
      5. add-exp-log46.9%

        \[\leadsto \mathsf{copysign}\left(\log \left(\color{blue}{x} \cdot e^{1}\right), x\right) \]
      6. exp-1-e46.9%

        \[\leadsto \mathsf{copysign}\left(\log \left(x \cdot \color{blue}{e}\right), x\right) \]
    7. Applied egg-rr46.9%

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

Alternative 8: 53.0% accurate, 3.7× speedup?

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

\\
\mathsf{copysign}\left(x \cdot \left(1 + \left(x \cdot x\right) \cdot -0.16666666666666666\right), 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. Add Preprocessing
  3. Taylor expanded in x around 0 14.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{copysign}\left(x \cdot \left(1 + \color{blue}{\left(x \cdot x\right)} \cdot -0.16666666666666666\right), x\right) \]
  10. Applied egg-rr53.4%

    \[\leadsto \mathsf{copysign}\left(x \cdot \left(1 + \color{blue}{\left(x \cdot x\right)} \cdot -0.16666666666666666\right), x\right) \]
  11. Add Preprocessing

Developer Target 1: 99.6% accurate, 0.6× speedup?

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

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

Reproduce

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

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

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