Rust f32::acosh

Percentage Accurate: 14.3% → 99.6%
Time: 1.8s
Alternatives: 4
Speedup: 4.3×

Specification

?
\[x \geq 1\]
\[\cosh^{-1} x \]
(FPCore (x)
  :precision binary32
  (acosh x))
float code(float x) {
	return acoshf(x);
}
function code(x)
	return acosh(x)
end
function tmp = code(x)
	tmp = acosh(x);
end
\cosh^{-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 4 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: 14.3% accurate, 1.0× speedup?

\[\log \left(x + \sqrt{x \cdot x - 1}\right) \]
(FPCore (x)
  :precision binary32
  (log (+ x (sqrt (- (* x x) 1.0)))))
float code(float x) {
	return logf((x + sqrtf(((x * x) - 1.0f))));
}
real(4) function code(x)
use fmin_fmax_functions
    real(4), intent (in) :: x
    code = log((x + sqrt(((x * x) - 1.0e0))))
end function
function code(x)
	return log(Float32(x + sqrt(Float32(Float32(x * x) - Float32(1.0)))))
end
function tmp = code(x)
	tmp = log((x + sqrt(((x * x) - single(1.0)))));
end
\log \left(x + \sqrt{x \cdot x - 1}\right)

Alternative 1: 99.6% accurate, 0.6× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq 0.5:\\ \;\;\;\;0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\log \left(\mathsf{fma}\left(\sqrt{\left|1 - x\right|}, \sqrt{\left|-1 - x\right|}, x\right)\right)\\ \end{array} \]
(FPCore (x)
  :precision binary32
  (if (<= x 0.5)
  (* 0.0 1.0)
  (log (fma (sqrt (fabs (- 1.0 x))) (sqrt (fabs (- -1.0 x))) x))))
float code(float x) {
	float tmp;
	if (x <= 0.5f) {
		tmp = 0.0f * 1.0f;
	} else {
		tmp = logf(fmaf(sqrtf(fabsf((1.0f - x))), sqrtf(fabsf((-1.0f - x))), x));
	}
	return tmp;
}
function code(x)
	tmp = Float32(0.0)
	if (x <= Float32(0.5))
		tmp = Float32(Float32(0.0) * Float32(1.0));
	else
		tmp = log(fma(sqrt(abs(Float32(Float32(1.0) - x))), sqrt(abs(Float32(Float32(-1.0) - x))), x));
	end
	return tmp
end
\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;0 \cdot 1\\

\mathbf{else}:\\
\;\;\;\;\log \left(\mathsf{fma}\left(\sqrt{\left|1 - x\right|}, \sqrt{\left|-1 - x\right|}, x\right)\right)\\


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

    1. Initial program 14.3%

      \[\log \left(x + \sqrt{x \cdot x - 1}\right) \]
    2. Step-by-step derivation
      1. rem-square-sqrtN/A

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

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

        \[\leadsto \log \left(x + \sqrt{\sqrt{x \cdot x - 1} \cdot \color{blue}{\sqrt{x \cdot x - 1}}}\right) \]
      4. fabs-sqrN/A

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

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

        \[\leadsto \log \left(x + \sqrt{\left|\sqrt{x \cdot x - 1} \cdot \color{blue}{\sqrt{x \cdot x - 1}}\right|}\right) \]
      7. rem-square-sqrtN/A

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

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

        \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{x \cdot x} - 1\right|}\right) \]
      10. difference-of-sqr-1N/A

        \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{\left(x + 1\right) \cdot \left(x - 1\right)}\right|}\right) \]
      11. *-commutativeN/A

        \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{\left(x - 1\right) \cdot \left(x + 1\right)}\right|}\right) \]
      12. fabs-mulN/A

        \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|x - 1\right| \cdot \left|x + 1\right|}}\right) \]
      13. lower-*.f32N/A

        \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|x - 1\right| \cdot \left|x + 1\right|}}\right) \]
      14. fabs-subN/A

        \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|1 - x\right|} \cdot \left|x + 1\right|}\right) \]
      15. lower-fabs.f32N/A

        \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|1 - x\right|} \cdot \left|x + 1\right|}\right) \]
      16. lower--.f32N/A

        \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{1 - x}\right| \cdot \left|x + 1\right|}\right) \]
      17. add-flipN/A

        \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \left|\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right)}\right|}\right) \]
      18. fabs-subN/A

        \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \color{blue}{\left|\left(\mathsf{neg}\left(1\right)\right) - x\right|}}\right) \]
      19. lower-fabs.f32N/A

        \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \color{blue}{\left|\left(\mathsf{neg}\left(1\right)\right) - x\right|}}\right) \]
      20. lower--.f32N/A

        \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \left|\color{blue}{\left(\mathsf{neg}\left(1\right)\right) - x}\right|}\right) \]
      21. metadata-eval55.1%

        \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \left|\color{blue}{-1} - x\right|}\right) \]
    3. Applied rewrites55.1%

      \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|1 - x\right| \cdot \left|-1 - x\right|}}\right) \]
    4. Taylor expanded in x around 0

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot x\right)} \]
    5. Step-by-step derivation
      1. lower-*.f32N/A

        \[\leadsto x \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
      2. lower-+.f32N/A

        \[\leadsto x \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
      3. lower-*.f326.7%

        \[\leadsto x \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
    6. Applied rewrites6.7%

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot x\right)} \]
    7. Taylor expanded in x around 0

      \[\leadsto x \cdot 1 \]
    8. Step-by-step derivation
      1. Applied rewrites9.4%

        \[\leadsto x \cdot 1 \]
      2. Taylor expanded in undef-var around zero

        \[\leadsto 0 \cdot 1 \]
      3. Step-by-step derivation
        1. Applied rewrites76.1%

          \[\leadsto 0 \cdot 1 \]

        if 0.5 < x

        1. Initial program 14.3%

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

            \[\leadsto \log \color{blue}{\left(x + \sqrt{x \cdot x - 1}\right)} \]
          2. +-commutativeN/A

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

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

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

            \[\leadsto \log \left(\sqrt{\color{blue}{x \cdot x} - 1} + x\right) \]
          6. difference-of-sqr-1N/A

            \[\leadsto \log \left(\sqrt{\color{blue}{\left(x + 1\right) \cdot \left(x - 1\right)}} + x\right) \]
          7. sqrt-prodN/A

            \[\leadsto \log \left(\color{blue}{\sqrt{\left|x + 1\right|} \cdot \sqrt{\left|x - 1\right|}} + x\right) \]
          8. *-commutativeN/A

            \[\leadsto \log \left(\color{blue}{\sqrt{\left|x - 1\right|} \cdot \sqrt{\left|x + 1\right|}} + x\right) \]
          9. lower-fma.f32N/A

            \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(\sqrt{\left|x - 1\right|}, \sqrt{\left|x + 1\right|}, x\right)\right)} \]
          10. lower-sqrt.f32N/A

            \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{\sqrt{\left|x - 1\right|}}, \sqrt{\left|x + 1\right|}, x\right)\right) \]
          11. fabs-subN/A

            \[\leadsto \log \left(\mathsf{fma}\left(\sqrt{\color{blue}{\left|1 - x\right|}}, \sqrt{\left|x + 1\right|}, x\right)\right) \]
          12. lower-fabs.f32N/A

            \[\leadsto \log \left(\mathsf{fma}\left(\sqrt{\color{blue}{\left|1 - x\right|}}, \sqrt{\left|x + 1\right|}, x\right)\right) \]
          13. lower--.f32N/A

            \[\leadsto \log \left(\mathsf{fma}\left(\sqrt{\left|\color{blue}{1 - x}\right|}, \sqrt{\left|x + 1\right|}, x\right)\right) \]
          14. lower-sqrt.f32N/A

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

            \[\leadsto \log \left(\mathsf{fma}\left(\sqrt{\left|1 - x\right|}, \sqrt{\left|\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right)}\right|}, x\right)\right) \]
          16. fabs-subN/A

            \[\leadsto \log \left(\mathsf{fma}\left(\sqrt{\left|1 - x\right|}, \sqrt{\color{blue}{\left|\left(\mathsf{neg}\left(1\right)\right) - x\right|}}, x\right)\right) \]
          17. lower-fabs.f32N/A

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

            \[\leadsto \log \left(\mathsf{fma}\left(\sqrt{\left|1 - x\right|}, \sqrt{\left|\color{blue}{\left(\mathsf{neg}\left(1\right)\right) - x}\right|}, x\right)\right) \]
          19. metadata-eval67.1%

            \[\leadsto \log \left(\mathsf{fma}\left(\sqrt{\left|1 - x\right|}, \sqrt{\left|\color{blue}{-1} - x\right|}, x\right)\right) \]
        3. Applied rewrites67.1%

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

      Alternative 2: 99.6% accurate, 1.5× speedup?

      \[\begin{array}{l} \mathbf{if}\;x \leq 0.5:\\ \;\;\;\;0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\cosh^{-1} x\\ \end{array} \]
      (FPCore (x)
        :precision binary32
        (if (<= x 0.5) (* 0.0 1.0) (acosh x)))
      float code(float x) {
      	float tmp;
      	if (x <= 0.5f) {
      		tmp = 0.0f * 1.0f;
      	} else {
      		tmp = acoshf(x);
      	}
      	return tmp;
      }
      
      function code(x)
      	tmp = Float32(0.0)
      	if (x <= Float32(0.5))
      		tmp = Float32(Float32(0.0) * Float32(1.0));
      	else
      		tmp = acosh(x);
      	end
      	return tmp
      end
      
      function tmp_2 = code(x)
      	tmp = single(0.0);
      	if (x <= single(0.5))
      		tmp = single(0.0) * single(1.0);
      	else
      		tmp = acosh(x);
      	end
      	tmp_2 = tmp;
      end
      
      \begin{array}{l}
      \mathbf{if}\;x \leq 0.5:\\
      \;\;\;\;0 \cdot 1\\
      
      \mathbf{else}:\\
      \;\;\;\;\cosh^{-1} x\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < 0.5

        1. Initial program 14.3%

          \[\log \left(x + \sqrt{x \cdot x - 1}\right) \]
        2. Step-by-step derivation
          1. rem-square-sqrtN/A

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

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

            \[\leadsto \log \left(x + \sqrt{\sqrt{x \cdot x - 1} \cdot \color{blue}{\sqrt{x \cdot x - 1}}}\right) \]
          4. fabs-sqrN/A

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

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

            \[\leadsto \log \left(x + \sqrt{\left|\sqrt{x \cdot x - 1} \cdot \color{blue}{\sqrt{x \cdot x - 1}}\right|}\right) \]
          7. rem-square-sqrtN/A

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

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

            \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{x \cdot x} - 1\right|}\right) \]
          10. difference-of-sqr-1N/A

            \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{\left(x + 1\right) \cdot \left(x - 1\right)}\right|}\right) \]
          11. *-commutativeN/A

            \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{\left(x - 1\right) \cdot \left(x + 1\right)}\right|}\right) \]
          12. fabs-mulN/A

            \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|x - 1\right| \cdot \left|x + 1\right|}}\right) \]
          13. lower-*.f32N/A

            \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|x - 1\right| \cdot \left|x + 1\right|}}\right) \]
          14. fabs-subN/A

            \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|1 - x\right|} \cdot \left|x + 1\right|}\right) \]
          15. lower-fabs.f32N/A

            \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|1 - x\right|} \cdot \left|x + 1\right|}\right) \]
          16. lower--.f32N/A

            \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{1 - x}\right| \cdot \left|x + 1\right|}\right) \]
          17. add-flipN/A

            \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \left|\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right)}\right|}\right) \]
          18. fabs-subN/A

            \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \color{blue}{\left|\left(\mathsf{neg}\left(1\right)\right) - x\right|}}\right) \]
          19. lower-fabs.f32N/A

            \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \color{blue}{\left|\left(\mathsf{neg}\left(1\right)\right) - x\right|}}\right) \]
          20. lower--.f32N/A

            \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \left|\color{blue}{\left(\mathsf{neg}\left(1\right)\right) - x}\right|}\right) \]
          21. metadata-eval55.1%

            \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \left|\color{blue}{-1} - x\right|}\right) \]
        3. Applied rewrites55.1%

          \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|1 - x\right| \cdot \left|-1 - x\right|}}\right) \]
        4. Taylor expanded in x around 0

          \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot x\right)} \]
        5. Step-by-step derivation
          1. lower-*.f32N/A

            \[\leadsto x \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
          2. lower-+.f32N/A

            \[\leadsto x \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
          3. lower-*.f326.7%

            \[\leadsto x \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
        6. Applied rewrites6.7%

          \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot x\right)} \]
        7. Taylor expanded in x around 0

          \[\leadsto x \cdot 1 \]
        8. Step-by-step derivation
          1. Applied rewrites9.4%

            \[\leadsto x \cdot 1 \]
          2. Taylor expanded in undef-var around zero

            \[\leadsto 0 \cdot 1 \]
          3. Step-by-step derivation
            1. Applied rewrites76.1%

              \[\leadsto 0 \cdot 1 \]

            if 0.5 < x

            1. Initial program 14.3%

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

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

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

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

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

                \[\leadsto \log \left(x + \sqrt{\color{blue}{x \cdot x} - 1}\right) \]
              6. acosh-def-revN/A

                \[\leadsto \color{blue}{\cosh^{-1} x} \]
              7. lower-acosh.f3225.3%

                \[\leadsto \color{blue}{\cosh^{-1} x} \]
            3. Applied rewrites25.3%

              \[\leadsto \color{blue}{\cosh^{-1} x} \]
          4. Recombined 2 regimes into one program.
          5. Add Preprocessing

          Alternative 3: 76.1% accurate, 4.3× speedup?

          \[0 \cdot 1 \]
          (FPCore (x)
            :precision binary32
            (* 0.0 1.0))
          float code(float x) {
          	return 0.0f * 1.0f;
          }
          
          real(4) function code(x)
          use fmin_fmax_functions
              real(4), intent (in) :: x
              code = 0.0e0 * 1.0e0
          end function
          
          function code(x)
          	return Float32(Float32(0.0) * Float32(1.0))
          end
          
          function tmp = code(x)
          	tmp = single(0.0) * single(1.0);
          end
          
          0 \cdot 1
          
          Derivation
          1. Initial program 14.3%

            \[\log \left(x + \sqrt{x \cdot x - 1}\right) \]
          2. Step-by-step derivation
            1. rem-square-sqrtN/A

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

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

              \[\leadsto \log \left(x + \sqrt{\sqrt{x \cdot x - 1} \cdot \color{blue}{\sqrt{x \cdot x - 1}}}\right) \]
            4. fabs-sqrN/A

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

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

              \[\leadsto \log \left(x + \sqrt{\left|\sqrt{x \cdot x - 1} \cdot \color{blue}{\sqrt{x \cdot x - 1}}\right|}\right) \]
            7. rem-square-sqrtN/A

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

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

              \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{x \cdot x} - 1\right|}\right) \]
            10. difference-of-sqr-1N/A

              \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{\left(x + 1\right) \cdot \left(x - 1\right)}\right|}\right) \]
            11. *-commutativeN/A

              \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{\left(x - 1\right) \cdot \left(x + 1\right)}\right|}\right) \]
            12. fabs-mulN/A

              \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|x - 1\right| \cdot \left|x + 1\right|}}\right) \]
            13. lower-*.f32N/A

              \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|x - 1\right| \cdot \left|x + 1\right|}}\right) \]
            14. fabs-subN/A

              \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|1 - x\right|} \cdot \left|x + 1\right|}\right) \]
            15. lower-fabs.f32N/A

              \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|1 - x\right|} \cdot \left|x + 1\right|}\right) \]
            16. lower--.f32N/A

              \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{1 - x}\right| \cdot \left|x + 1\right|}\right) \]
            17. add-flipN/A

              \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \left|\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right)}\right|}\right) \]
            18. fabs-subN/A

              \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \color{blue}{\left|\left(\mathsf{neg}\left(1\right)\right) - x\right|}}\right) \]
            19. lower-fabs.f32N/A

              \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \color{blue}{\left|\left(\mathsf{neg}\left(1\right)\right) - x\right|}}\right) \]
            20. lower--.f32N/A

              \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \left|\color{blue}{\left(\mathsf{neg}\left(1\right)\right) - x}\right|}\right) \]
            21. metadata-eval55.1%

              \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \left|\color{blue}{-1} - x\right|}\right) \]
          3. Applied rewrites55.1%

            \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|1 - x\right| \cdot \left|-1 - x\right|}}\right) \]
          4. Taylor expanded in x around 0

            \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot x\right)} \]
          5. Step-by-step derivation
            1. lower-*.f32N/A

              \[\leadsto x \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
            2. lower-+.f32N/A

              \[\leadsto x \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
            3. lower-*.f326.7%

              \[\leadsto x \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
          6. Applied rewrites6.7%

            \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot x\right)} \]
          7. Taylor expanded in x around 0

            \[\leadsto x \cdot 1 \]
          8. Step-by-step derivation
            1. Applied rewrites9.4%

              \[\leadsto x \cdot 1 \]
            2. Taylor expanded in undef-var around zero

              \[\leadsto 0 \cdot 1 \]
            3. Step-by-step derivation
              1. Applied rewrites76.1%

                \[\leadsto 0 \cdot 1 \]
              2. Add Preprocessing

              Alternative 4: 9.4% accurate, 4.3× speedup?

              \[x \cdot 1 \]
              (FPCore (x)
                :precision binary32
                (* x 1.0))
              float code(float x) {
              	return x * 1.0f;
              }
              
              real(4) function code(x)
              use fmin_fmax_functions
                  real(4), intent (in) :: x
                  code = x * 1.0e0
              end function
              
              function code(x)
              	return Float32(x * Float32(1.0))
              end
              
              function tmp = code(x)
              	tmp = x * single(1.0);
              end
              
              x \cdot 1
              
              Derivation
              1. Initial program 14.3%

                \[\log \left(x + \sqrt{x \cdot x - 1}\right) \]
              2. Step-by-step derivation
                1. rem-square-sqrtN/A

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

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

                  \[\leadsto \log \left(x + \sqrt{\sqrt{x \cdot x - 1} \cdot \color{blue}{\sqrt{x \cdot x - 1}}}\right) \]
                4. fabs-sqrN/A

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

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

                  \[\leadsto \log \left(x + \sqrt{\left|\sqrt{x \cdot x - 1} \cdot \color{blue}{\sqrt{x \cdot x - 1}}\right|}\right) \]
                7. rem-square-sqrtN/A

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

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

                  \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{x \cdot x} - 1\right|}\right) \]
                10. difference-of-sqr-1N/A

                  \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{\left(x + 1\right) \cdot \left(x - 1\right)}\right|}\right) \]
                11. *-commutativeN/A

                  \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{\left(x - 1\right) \cdot \left(x + 1\right)}\right|}\right) \]
                12. fabs-mulN/A

                  \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|x - 1\right| \cdot \left|x + 1\right|}}\right) \]
                13. lower-*.f32N/A

                  \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|x - 1\right| \cdot \left|x + 1\right|}}\right) \]
                14. fabs-subN/A

                  \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|1 - x\right|} \cdot \left|x + 1\right|}\right) \]
                15. lower-fabs.f32N/A

                  \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|1 - x\right|} \cdot \left|x + 1\right|}\right) \]
                16. lower--.f32N/A

                  \[\leadsto \log \left(x + \sqrt{\left|\color{blue}{1 - x}\right| \cdot \left|x + 1\right|}\right) \]
                17. add-flipN/A

                  \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \left|\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right)}\right|}\right) \]
                18. fabs-subN/A

                  \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \color{blue}{\left|\left(\mathsf{neg}\left(1\right)\right) - x\right|}}\right) \]
                19. lower-fabs.f32N/A

                  \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \color{blue}{\left|\left(\mathsf{neg}\left(1\right)\right) - x\right|}}\right) \]
                20. lower--.f32N/A

                  \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \left|\color{blue}{\left(\mathsf{neg}\left(1\right)\right) - x}\right|}\right) \]
                21. metadata-eval55.1%

                  \[\leadsto \log \left(x + \sqrt{\left|1 - x\right| \cdot \left|\color{blue}{-1} - x\right|}\right) \]
              3. Applied rewrites55.1%

                \[\leadsto \log \left(x + \sqrt{\color{blue}{\left|1 - x\right| \cdot \left|-1 - x\right|}}\right) \]
              4. Taylor expanded in x around 0

                \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot x\right)} \]
              5. Step-by-step derivation
                1. lower-*.f32N/A

                  \[\leadsto x \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
                2. lower-+.f32N/A

                  \[\leadsto x \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
                3. lower-*.f326.7%

                  \[\leadsto x \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
              6. Applied rewrites6.7%

                \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot x\right)} \]
              7. Taylor expanded in x around 0

                \[\leadsto x \cdot 1 \]
              8. Step-by-step derivation
                1. Applied rewrites9.4%

                  \[\leadsto x \cdot 1 \]
                2. Add Preprocessing

                Developer Target 1: 25.2% accurate, 0.8× speedup?

                \[\log \left(x + \sqrt{x - 1} \cdot \sqrt{x + 1}\right) \]
                (FPCore (x)
                  :precision binary32
                  (log (+ x (* (sqrt (- x 1.0)) (sqrt (+ x 1.0))))))
                float code(float x) {
                	return logf((x + (sqrtf((x - 1.0f)) * sqrtf((x + 1.0f)))));
                }
                
                real(4) function code(x)
                use fmin_fmax_functions
                    real(4), intent (in) :: x
                    code = log((x + (sqrt((x - 1.0e0)) * sqrt((x + 1.0e0)))))
                end function
                
                function code(x)
                	return log(Float32(x + Float32(sqrt(Float32(x - Float32(1.0))) * sqrt(Float32(x + Float32(1.0))))))
                end
                
                function tmp = code(x)
                	tmp = log((x + (sqrt((x - single(1.0))) * sqrt((x + single(1.0))))));
                end
                
                \log \left(x + \sqrt{x - 1} \cdot \sqrt{x + 1}\right)
                

                Reproduce

                ?
                herbie shell --seed 2025313 -o setup:search
                (FPCore (x)
                  :name "Rust f32::acosh"
                  :precision binary32
                  :pre (>= x 1.0)
                
                  :alt
                  (! :herbie-platform c (log (+ x (* (sqrt (- x 1)) (sqrt (+ x 1))))))
                
                  (log (+ x (sqrt (- (* x x) 1.0)))))