Rust f32::asinh

Percentage Accurate: 37.7% → 99.6%
Time: 2.3s
Alternatives: 5
Speedup: 3.2×

Specification

?
\[\sinh^{-1} x \]
(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
\sinh^{-1} x

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 5 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.7% accurate, 1.0× speedup?

\[\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \]
(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
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)

Alternative 1: 99.6% accurate, 1.5× speedup?

\[\mathsf{copysign}\left(\sinh^{-1} \left(\left|x\right|\right), x\right) \]
(FPCore (x)
  :precision binary32
  (copysign (asinh (fabs x)) x))
float code(float x) {
	return copysignf(asinhf(fabsf(x)), x);
}
function code(x)
	return copysign(asinh(abs(x)), x)
end
function tmp = code(x)
	tmp = sign(x) * abs(asinh(abs(x)));
end
\mathsf{copysign}\left(\sinh^{-1} \left(\left|x\right|\right), x\right)
Derivation
  1. Initial program 37.7%

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

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right)}, x\right) \]
    2. lift-+.f32N/A

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

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

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{x \cdot x + 1}}\right), x\right) \]
    5. lift-*.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{x \cdot x} + 1}\right), x\right) \]
    6. sqr-abs-revN/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{\left|x\right| \cdot \left|x\right|} + 1}\right), x\right) \]
    7. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{\left|x\right|} \cdot \left|x\right| + 1}\right), x\right) \]
    8. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\left|x\right| \cdot \color{blue}{\left|x\right|} + 1}\right), x\right) \]
    9. asinh-def-revN/A

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\sinh^{-1} \left(\left|x\right|\right)}, x\right) \]
    10. lower-asinh.f3299.6%

      \[\leadsto \mathsf{copysign}\left(\color{blue}{\sinh^{-1} \left(\left|x\right|\right)}, x\right) \]
  3. Applied rewrites99.6%

    \[\leadsto \mathsf{copysign}\left(\color{blue}{\sinh^{-1} \left(\left|x\right|\right)}, x\right) \]
  4. Add Preprocessing

Alternative 2: 97.3% accurate, 0.8× speedup?

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

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


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

    1. Initial program 37.7%

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

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

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

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{-1 \cdot x}\right), x\right) \]
    5. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + -1 \cdot \color{blue}{x}\right), x\right) \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \left(\mathsf{neg}\left(x\right)\right)\right), x\right) \]
      3. lower-neg.f3229.5%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \left(-x\right)\right), x\right) \]
    6. Applied rewrites29.5%

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \left(-x\right)\right), x\right) \]
    7. Step-by-step derivation
      1. lift-+.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left|x\right| + \left(-x\right)\right)}, x\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(-x\right) + \left|x\right|\right)}, x\right) \]
      3. add-flipN/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(-x\right) - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)}, x\right) \]
      4. lower--.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(-x\right) - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)}, x\right) \]
      5. rem-square-sqrtN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{-x} \cdot \color{blue}{\sqrt{-x}} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      6. sqrt-unprodN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{\left(-x\right) \cdot \left(-x\right)} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      7. lift-neg.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(-x\right)} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      8. lift-neg.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      9. sqr-neg-revN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{x \cdot x} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      10. rem-sqrt-square-revN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      11. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      12. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite<=}\left(mul-1-neg, \left(-1 \cdot \left|x\right|\right)\right)\right), x\right) \]
      13. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(lift-fabs.f32, \left(\left|x\right|\right)\right)\right), x\right) \]
      14. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(rem-sqrt-square-rev, \left(\sqrt{x \cdot x}\right)\right)\right), x\right) \]
      15. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \sqrt{\mathsf{Rewrite=>}\left(sqr-neg-rev, \left(\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)\right)\right)}\right), x\right) \]
      16. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \sqrt{\mathsf{Rewrite<=}\left(lift-neg.f32, \left(-x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)}\right), x\right) \]
      17. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \sqrt{\left(-x\right) \cdot \mathsf{Rewrite<=}\left(lift-neg.f32, \left(-x\right)\right)}\right), x\right) \]
      18. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite<=}\left(sqrt-unprod, \left(\sqrt{-x} \cdot \sqrt{-x}\right)\right)\right), x\right) \]
      19. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(rem-square-sqrt, \left(-x\right)\right)\right), x\right) \]
      20. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(lift-neg.f32, \left(\mathsf{neg}\left(x\right)\right)\right)\right), x\right) \]
      21. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite=>}\left(distribute-rgt-neg-out, \left(\mathsf{neg}\left(-1 \cdot x\right)\right)\right)\right), x\right) \]
      22. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite<=}\left(distribute-lft-neg-out, \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)\right)\right), x\right) \]
      23. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite=>}\left(metadata-eval, 1\right) \cdot x\right), x\right) \]
      24. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite=>}\left(*-lft-identity, x\right)\right), x\right) \]
    8. Applied rewrites29.5%

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left|x\right| - x\right)}, x\right) \]
    9. Taylor expanded in x around 0

      \[\leadsto \mathsf{copysign}\left(\color{blue}{-1 \cdot x}, x\right) \]
    10. Step-by-step derivation
      1. lower-*.f3254.5%

        \[\leadsto \mathsf{copysign}\left(-1 \cdot \color{blue}{x}, x\right) \]
    11. Applied rewrites54.5%

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

    if 1 < x

    1. Initial program 37.7%

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

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

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

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{-1 \cdot x}\right), x\right) \]
    5. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + -1 \cdot \color{blue}{x}\right), x\right) \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \left(\mathsf{neg}\left(x\right)\right)\right), x\right) \]
      3. lower-neg.f3229.5%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \left(-x\right)\right), x\right) \]
    6. Applied rewrites29.5%

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \left(-x\right)\right), x\right) \]
    7. Step-by-step derivation
      1. lift-+.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left|x\right| + \left(-x\right)\right)}, x\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(-x\right) + \left|x\right|\right)}, x\right) \]
      3. add-flipN/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(-x\right) - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)}, x\right) \]
      4. lower--.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(-x\right) - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)}, x\right) \]
      5. rem-square-sqrtN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{-x} \cdot \color{blue}{\sqrt{-x}} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      6. sqrt-unprodN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{\left(-x\right) \cdot \left(-x\right)} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      7. lift-neg.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(-x\right)} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      8. lift-neg.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      9. sqr-neg-revN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{x \cdot x} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      10. rem-sqrt-square-revN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      11. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      12. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite<=}\left(mul-1-neg, \left(-1 \cdot \left|x\right|\right)\right)\right), x\right) \]
      13. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(lift-fabs.f32, \left(\left|x\right|\right)\right)\right), x\right) \]
      14. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(rem-sqrt-square-rev, \left(\sqrt{x \cdot x}\right)\right)\right), x\right) \]
      15. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \sqrt{\mathsf{Rewrite=>}\left(sqr-neg-rev, \left(\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)\right)\right)}\right), x\right) \]
      16. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \sqrt{\mathsf{Rewrite<=}\left(lift-neg.f32, \left(-x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)}\right), x\right) \]
      17. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \sqrt{\left(-x\right) \cdot \mathsf{Rewrite<=}\left(lift-neg.f32, \left(-x\right)\right)}\right), x\right) \]
      18. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite<=}\left(sqrt-unprod, \left(\sqrt{-x} \cdot \sqrt{-x}\right)\right)\right), x\right) \]
      19. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(rem-square-sqrt, \left(-x\right)\right)\right), x\right) \]
      20. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(lift-neg.f32, \left(\mathsf{neg}\left(x\right)\right)\right)\right), x\right) \]
      21. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite=>}\left(distribute-rgt-neg-out, \left(\mathsf{neg}\left(-1 \cdot x\right)\right)\right)\right), x\right) \]
      22. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite<=}\left(distribute-lft-neg-out, \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)\right)\right), x\right) \]
      23. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite=>}\left(metadata-eval, 1\right) \cdot x\right), x\right) \]
      24. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite=>}\left(*-lft-identity, x\right)\right), x\right) \]
    8. Applied rewrites29.5%

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

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\frac{\frac{1}{2}}{x}\right)}, x\right) \]
    10. Step-by-step derivation
      1. lower-/.f3226.7%

        \[\leadsto \mathsf{copysign}\left(\log \left(\frac{0.5}{\color{blue}{x}}\right), x\right) \]
    11. Applied rewrites26.7%

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

Alternative 3: 97.1% accurate, 0.8× speedup?

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

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


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

    1. Initial program 37.7%

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

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

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

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{-1 \cdot x}\right), x\right) \]
    5. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + -1 \cdot \color{blue}{x}\right), x\right) \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \left(\mathsf{neg}\left(x\right)\right)\right), x\right) \]
      3. lower-neg.f3229.5%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \left(-x\right)\right), x\right) \]
    6. Applied rewrites29.5%

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \left(-x\right)\right), x\right) \]
    7. Step-by-step derivation
      1. lift-+.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left|x\right| + \left(-x\right)\right)}, x\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(-x\right) + \left|x\right|\right)}, x\right) \]
      3. add-flipN/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(-x\right) - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)}, x\right) \]
      4. lower--.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(-x\right) - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)}, x\right) \]
      5. rem-square-sqrtN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{-x} \cdot \color{blue}{\sqrt{-x}} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      6. sqrt-unprodN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{\left(-x\right) \cdot \left(-x\right)} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      7. lift-neg.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(-x\right)} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      8. lift-neg.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      9. sqr-neg-revN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{x \cdot x} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      10. rem-sqrt-square-revN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      11. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      12. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite<=}\left(mul-1-neg, \left(-1 \cdot \left|x\right|\right)\right)\right), x\right) \]
      13. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(lift-fabs.f32, \left(\left|x\right|\right)\right)\right), x\right) \]
      14. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(rem-sqrt-square-rev, \left(\sqrt{x \cdot x}\right)\right)\right), x\right) \]
      15. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \sqrt{\mathsf{Rewrite=>}\left(sqr-neg-rev, \left(\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)\right)\right)}\right), x\right) \]
      16. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \sqrt{\mathsf{Rewrite<=}\left(lift-neg.f32, \left(-x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)}\right), x\right) \]
      17. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \sqrt{\left(-x\right) \cdot \mathsf{Rewrite<=}\left(lift-neg.f32, \left(-x\right)\right)}\right), x\right) \]
      18. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite<=}\left(sqrt-unprod, \left(\sqrt{-x} \cdot \sqrt{-x}\right)\right)\right), x\right) \]
      19. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(rem-square-sqrt, \left(-x\right)\right)\right), x\right) \]
      20. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(lift-neg.f32, \left(\mathsf{neg}\left(x\right)\right)\right)\right), x\right) \]
      21. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite=>}\left(distribute-rgt-neg-out, \left(\mathsf{neg}\left(-1 \cdot x\right)\right)\right)\right), x\right) \]
      22. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite<=}\left(distribute-lft-neg-out, \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)\right)\right), x\right) \]
      23. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite=>}\left(metadata-eval, 1\right) \cdot x\right), x\right) \]
      24. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite=>}\left(*-lft-identity, x\right)\right), x\right) \]
    8. Applied rewrites29.5%

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left|x\right| - x\right)}, x\right) \]
    9. Taylor expanded in x around 0

      \[\leadsto \mathsf{copysign}\left(\color{blue}{-1 \cdot x}, x\right) \]
    10. Step-by-step derivation
      1. lower-*.f3254.5%

        \[\leadsto \mathsf{copysign}\left(-1 \cdot \color{blue}{x}, x\right) \]
    11. Applied rewrites54.5%

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

    if 1 < x

    1. Initial program 37.7%

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

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(x \cdot \left(1 + \frac{\left|x\right|}{x}\right)\right)}, x\right) \]
    3. Step-by-step derivation
      1. lower-*.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(x \cdot \color{blue}{\left(1 + \frac{\left|x\right|}{x}\right)}\right), x\right) \]
      2. lower-+.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(x \cdot \left(1 + \color{blue}{\frac{\left|x\right|}{x}}\right)\right), x\right) \]
      3. lower-/.f32N/A

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

        \[\leadsto \mathsf{copysign}\left(\log \left(x \cdot \left(1 + \frac{\left|x\right|}{x}\right)\right), x\right) \]
    4. Applied rewrites29.4%

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(x \cdot \left(1 + \frac{\left|x\right|}{x}\right)\right)}, x\right) \]
    5. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(x \cdot \color{blue}{\left(1 + \frac{\left|x\right|}{x}\right)}\right), x\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(1 + \frac{\left|x\right|}{x}\right) \cdot \color{blue}{x}\right), x\right) \]
      3. lift-+.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(1 + \frac{\left|x\right|}{x}\right) \cdot x\right), x\right) \]
      4. lift-/.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left(1 + \frac{\left|x\right|}{x}\right) \cdot x\right), x\right) \]
      5. sum-to-mult-revN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(x + \color{blue}{\left|x\right|}\right), x\right) \]
      6. +-commutativeN/A

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

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{x}\right), x\right) \]
    6. Applied rewrites29.4%

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

Alternative 4: 70.8% accurate, 0.8× speedup?

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

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


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

    1. Initial program 37.7%

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

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

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

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{-1 \cdot x}\right), x\right) \]
    5. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + -1 \cdot \color{blue}{x}\right), x\right) \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \left(\mathsf{neg}\left(x\right)\right)\right), x\right) \]
      3. lower-neg.f3229.5%

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \left(-x\right)\right), x\right) \]
    6. Applied rewrites29.5%

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \left(-x\right)\right), x\right) \]
    7. Step-by-step derivation
      1. lift-+.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left|x\right| + \left(-x\right)\right)}, x\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(-x\right) + \left|x\right|\right)}, x\right) \]
      3. add-flipN/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(-x\right) - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)}, x\right) \]
      4. lower--.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(-x\right) - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)}, x\right) \]
      5. rem-square-sqrtN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{-x} \cdot \color{blue}{\sqrt{-x}} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      6. sqrt-unprodN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{\left(-x\right) \cdot \left(-x\right)} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      7. lift-neg.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(-x\right)} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      8. lift-neg.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      9. sqr-neg-revN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{x \cdot x} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      10. rem-sqrt-square-revN/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      11. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
      12. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite<=}\left(mul-1-neg, \left(-1 \cdot \left|x\right|\right)\right)\right), x\right) \]
      13. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(lift-fabs.f32, \left(\left|x\right|\right)\right)\right), x\right) \]
      14. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(rem-sqrt-square-rev, \left(\sqrt{x \cdot x}\right)\right)\right), x\right) \]
      15. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \sqrt{\mathsf{Rewrite=>}\left(sqr-neg-rev, \left(\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)\right)\right)}\right), x\right) \]
      16. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \sqrt{\mathsf{Rewrite<=}\left(lift-neg.f32, \left(-x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)}\right), x\right) \]
      17. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \sqrt{\left(-x\right) \cdot \mathsf{Rewrite<=}\left(lift-neg.f32, \left(-x\right)\right)}\right), x\right) \]
      18. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite<=}\left(sqrt-unprod, \left(\sqrt{-x} \cdot \sqrt{-x}\right)\right)\right), x\right) \]
      19. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(rem-square-sqrt, \left(-x\right)\right)\right), x\right) \]
      20. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(lift-neg.f32, \left(\mathsf{neg}\left(x\right)\right)\right)\right), x\right) \]
      21. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite=>}\left(distribute-rgt-neg-out, \left(\mathsf{neg}\left(-1 \cdot x\right)\right)\right)\right), x\right) \]
      22. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite<=}\left(distribute-lft-neg-out, \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)\right)\right), x\right) \]
      23. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite=>}\left(metadata-eval, 1\right) \cdot x\right), x\right) \]
      24. lift-fabs.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite=>}\left(*-lft-identity, x\right)\right), x\right) \]
    8. Applied rewrites29.5%

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left|x\right| - x\right)}, x\right) \]
    9. Taylor expanded in x around 0

      \[\leadsto \mathsf{copysign}\left(\color{blue}{-1 \cdot x}, x\right) \]
    10. Step-by-step derivation
      1. lower-*.f3254.5%

        \[\leadsto \mathsf{copysign}\left(-1 \cdot \color{blue}{x}, x\right) \]
    11. Applied rewrites54.5%

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

    if 1 < x

    1. Initial program 37.7%

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

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(1 + \left|x\right|\right)}, x\right) \]
    3. Step-by-step derivation
      1. lower-+.f32N/A

        \[\leadsto \mathsf{copysign}\left(\log \left(1 + \color{blue}{\left|x\right|}\right), x\right) \]
      2. lower-fabs.f3231.4%

        \[\leadsto \mathsf{copysign}\left(\log \left(1 + \left|x\right|\right), x\right) \]
    4. Applied rewrites31.4%

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

Alternative 5: 54.5% accurate, 3.2× speedup?

\[\mathsf{copysign}\left(-1 \cdot x, x\right) \]
(FPCore (x)
  :precision binary32
  (copysign (* -1.0 x) x))
float code(float x) {
	return copysignf((-1.0f * x), x);
}
function code(x)
	return copysign(Float32(Float32(-1.0) * x), x)
end
function tmp = code(x)
	tmp = sign(x) * abs((single(-1.0) * x));
end
\mathsf{copysign}\left(-1 \cdot x, x\right)
Derivation
  1. Initial program 37.7%

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

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

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

    \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{-1 \cdot x}\right), x\right) \]
  5. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + -1 \cdot \color{blue}{x}\right), x\right) \]
    2. mul-1-negN/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \left(\mathsf{neg}\left(x\right)\right)\right), x\right) \]
    3. lower-neg.f3229.5%

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \left(-x\right)\right), x\right) \]
  6. Applied rewrites29.5%

    \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| + \left(-x\right)\right), x\right) \]
  7. Step-by-step derivation
    1. lift-+.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left|x\right| + \left(-x\right)\right)}, x\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(-x\right) + \left|x\right|\right)}, x\right) \]
    3. add-flipN/A

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(-x\right) - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)}, x\right) \]
    4. lower--.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left(-x\right) - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)}, x\right) \]
    5. rem-square-sqrtN/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{-x} \cdot \color{blue}{\sqrt{-x}} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
    6. sqrt-unprodN/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{\left(-x\right) \cdot \left(-x\right)} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
    7. lift-neg.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(-x\right)} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
    8. lift-neg.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
    9. sqr-neg-revN/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\sqrt{x \cdot x} - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
    10. rem-sqrt-square-revN/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
    11. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right), x\right) \]
    12. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite<=}\left(mul-1-neg, \left(-1 \cdot \left|x\right|\right)\right)\right), x\right) \]
    13. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(lift-fabs.f32, \left(\left|x\right|\right)\right)\right), x\right) \]
    14. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(rem-sqrt-square-rev, \left(\sqrt{x \cdot x}\right)\right)\right), x\right) \]
    15. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \sqrt{\mathsf{Rewrite=>}\left(sqr-neg-rev, \left(\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)\right)\right)}\right), x\right) \]
    16. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \sqrt{\mathsf{Rewrite<=}\left(lift-neg.f32, \left(-x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)}\right), x\right) \]
    17. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \sqrt{\left(-x\right) \cdot \mathsf{Rewrite<=}\left(lift-neg.f32, \left(-x\right)\right)}\right), x\right) \]
    18. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite<=}\left(sqrt-unprod, \left(\sqrt{-x} \cdot \sqrt{-x}\right)\right)\right), x\right) \]
    19. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(rem-square-sqrt, \left(-x\right)\right)\right), x\right) \]
    20. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - -1 \cdot \mathsf{Rewrite=>}\left(lift-neg.f32, \left(\mathsf{neg}\left(x\right)\right)\right)\right), x\right) \]
    21. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite=>}\left(distribute-rgt-neg-out, \left(\mathsf{neg}\left(-1 \cdot x\right)\right)\right)\right), x\right) \]
    22. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite<=}\left(distribute-lft-neg-out, \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)\right)\right), x\right) \]
    23. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite=>}\left(metadata-eval, 1\right) \cdot x\right), x\right) \]
    24. lift-fabs.f32N/A

      \[\leadsto \mathsf{copysign}\left(\log \left(\left|x\right| - \mathsf{Rewrite=>}\left(*-lft-identity, x\right)\right), x\right) \]
  8. Applied rewrites29.5%

    \[\leadsto \mathsf{copysign}\left(\log \color{blue}{\left(\left|x\right| - x\right)}, x\right) \]
  9. Taylor expanded in x around 0

    \[\leadsto \mathsf{copysign}\left(\color{blue}{-1 \cdot x}, x\right) \]
  10. Step-by-step derivation
    1. lower-*.f3254.5%

      \[\leadsto \mathsf{copysign}\left(-1 \cdot \color{blue}{x}, x\right) \]
  11. Applied rewrites54.5%

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

Developer Target 1: 99.7% accurate, 0.4× speedup?

\[\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} \]
(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}
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}

Reproduce

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

  :alt
  (! :herbie-platform c (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))