Rust f32::atanh

Percentage Accurate: 99.8% → 99.8%
Time: 2.8s
Alternatives: 5
Speedup: 0.7×

Specification

?
\[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
(FPCore (x) :precision binary32 (* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))
float code(float x) {
	return 0.5f * log1pf(((2.0f * x) / (1.0f - x)));
}
function code(x)
	return Float32(Float32(0.5) * log1p(Float32(Float32(Float32(2.0) * x) / Float32(Float32(1.0) - x))))
end
0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right)

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: 99.8% accurate, 1.0× speedup?

\[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
(FPCore (x) :precision binary32 (* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))
float code(float x) {
	return 0.5f * log1pf(((2.0f * x) / (1.0f - x)));
}
function code(x)
	return Float32(Float32(0.5) * log1p(Float32(Float32(Float32(2.0) * x) / Float32(Float32(1.0) - x))))
end
0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right)

Alternative 1: 99.8% accurate, 0.7× speedup?

\[\mathsf{copysign}\left(1, x\right) \cdot \left(0.5 \cdot \mathsf{log1p}\left(\frac{\left|x\right| + \left|x\right|}{1 - \left|x\right|}\right)\right) \]
(FPCore (x)
 :precision binary32
 (*
  (copysign 1.0 x)
  (* 0.5 (log1p (/ (+ (fabs x) (fabs x)) (- 1.0 (fabs x)))))))
float code(float x) {
	return copysignf(1.0f, x) * (0.5f * log1pf(((fabsf(x) + fabsf(x)) / (1.0f - fabsf(x)))));
}
function code(x)
	return Float32(copysign(Float32(1.0), x) * Float32(Float32(0.5) * log1p(Float32(Float32(abs(x) + abs(x)) / Float32(Float32(1.0) - abs(x))))))
end
\mathsf{copysign}\left(1, x\right) \cdot \left(0.5 \cdot \mathsf{log1p}\left(\frac{\left|x\right| + \left|x\right|}{1 - \left|x\right|}\right)\right)
Derivation
  1. Initial program 99.8%

    \[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
  2. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto \frac{1}{2} \cdot \mathsf{log1p}\left(\frac{\color{blue}{2 \cdot x}}{1 - x}\right) \]
    2. count-2-revN/A

      \[\leadsto \frac{1}{2} \cdot \mathsf{log1p}\left(\frac{\color{blue}{x + x}}{1 - x}\right) \]
    3. lower-+.f3299.8%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\frac{\color{blue}{x + x}}{1 - x}\right) \]
  3. Applied rewrites99.8%

    \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\frac{\color{blue}{x + x}}{1 - x}\right) \]
  4. Add Preprocessing

Alternative 2: 99.3% accurate, 0.7× speedup?

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

\mathbf{else}:\\
\;\;\;\;\log \left(\mathsf{fma}\left(\frac{-2}{\left|x\right| - 1}, \left|x\right|, 1\right)\right) \cdot 0.5\\


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

    1. Initial program 99.8%

      \[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{x} \]
    3. Step-by-step derivation
      1. Applied rewrites97.0%

        \[\leadsto \color{blue}{x} \]

      if 0.00400000019 < x

      1. Initial program 99.8%

        \[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
      2. Step-by-step derivation
        1. lift-*.f32N/A

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

          \[\leadsto \color{blue}{\mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \cdot \frac{1}{2}} \]
        3. lower-*.f3299.8%

          \[\leadsto \color{blue}{\mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \cdot 0.5} \]
        4. lift-log1p.f32N/A

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

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

          \[\leadsto \log \color{blue}{\left(\frac{2 \cdot x}{1 - x} + 1\right)} \cdot \frac{1}{2} \]
        7. metadata-evalN/A

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

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

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

          \[\leadsto \log \left(\frac{\color{blue}{x \cdot 2}}{1 - x} + \left(1 + 0\right)\right) \cdot \frac{1}{2} \]
        11. associate-/l*N/A

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

          \[\leadsto \log \left(\color{blue}{\frac{2}{1 - x} \cdot x} + \left(1 + 0\right)\right) \cdot \frac{1}{2} \]
        13. metadata-evalN/A

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

          \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(\frac{2}{1 - x}, x, 1\right)\right)} \cdot \frac{1}{2} \]
        15. frac-2negN/A

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

          \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{\frac{\mathsf{neg}\left(2\right)}{\mathsf{neg}\left(\left(1 - x\right)\right)}}, x, 1\right)\right) \cdot \frac{1}{2} \]
        17. metadata-evalN/A

          \[\leadsto \log \left(\mathsf{fma}\left(\frac{\color{blue}{-2}}{\mathsf{neg}\left(\left(1 - x\right)\right)}, x, 1\right)\right) \cdot \frac{1}{2} \]
        18. lift--.f32N/A

          \[\leadsto \log \left(\mathsf{fma}\left(\frac{-2}{\mathsf{neg}\left(\color{blue}{\left(1 - x\right)}\right)}, x, 1\right)\right) \cdot \frac{1}{2} \]
        19. sub-negate-revN/A

          \[\leadsto \log \left(\mathsf{fma}\left(\frac{-2}{\color{blue}{x - 1}}, x, 1\right)\right) \cdot \frac{1}{2} \]
        20. lower--.f3223.6%

          \[\leadsto \log \left(\mathsf{fma}\left(\frac{-2}{\color{blue}{x - 1}}, x, 1\right)\right) \cdot 0.5 \]
      3. Applied rewrites23.6%

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

    Alternative 3: 99.3% accurate, 0.7× speedup?

    \[\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 0.004000000189989805:\\ \;\;\;\;\left|x\right|\\ \mathbf{else}:\\ \;\;\;\;\log \left(\mathsf{fma}\left(-2, \frac{\left|x\right|}{\left|x\right| - 1}, 1\right)\right) \cdot 0.5\\ \end{array} \]
    (FPCore (x)
     :precision binary32
     (*
      (copysign 1.0 x)
      (if (<= (fabs x) 0.004000000189989805)
        (fabs x)
        (* (log (fma -2.0 (/ (fabs x) (- (fabs x) 1.0)) 1.0)) 0.5))))
    float code(float x) {
    	float tmp;
    	if (fabsf(x) <= 0.004000000189989805f) {
    		tmp = fabsf(x);
    	} else {
    		tmp = logf(fmaf(-2.0f, (fabsf(x) / (fabsf(x) - 1.0f)), 1.0f)) * 0.5f;
    	}
    	return copysignf(1.0f, x) * tmp;
    }
    
    function code(x)
    	tmp = Float32(0.0)
    	if (abs(x) <= Float32(0.004000000189989805))
    		tmp = abs(x);
    	else
    		tmp = Float32(log(fma(Float32(-2.0), Float32(abs(x) / Float32(abs(x) - Float32(1.0))), Float32(1.0))) * Float32(0.5));
    	end
    	return Float32(copysign(Float32(1.0), x) * tmp)
    end
    
    \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
    \mathbf{if}\;\left|x\right| \leq 0.004000000189989805:\\
    \;\;\;\;\left|x\right|\\
    
    \mathbf{else}:\\
    \;\;\;\;\log \left(\mathsf{fma}\left(-2, \frac{\left|x\right|}{\left|x\right| - 1}, 1\right)\right) \cdot 0.5\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 0.00400000019

      1. Initial program 99.8%

        \[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
      2. Taylor expanded in x around 0

        \[\leadsto \color{blue}{x} \]
      3. Step-by-step derivation
        1. Applied rewrites97.0%

          \[\leadsto \color{blue}{x} \]

        if 0.00400000019 < x

        1. Initial program 99.8%

          \[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
        2. Step-by-step derivation
          1. lift-*.f32N/A

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

            \[\leadsto \color{blue}{\mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \cdot \frac{1}{2}} \]
          3. lower-*.f3299.8%

            \[\leadsto \color{blue}{\mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \cdot 0.5} \]
          4. lift-log1p.f32N/A

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

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

            \[\leadsto \log \color{blue}{\left(\frac{2 \cdot x}{1 - x} + 1\right)} \cdot \frac{1}{2} \]
          7. metadata-evalN/A

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

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

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

            \[\leadsto \log \left(\frac{\color{blue}{x \cdot 2}}{1 - x} + \left(1 + 0\right)\right) \cdot \frac{1}{2} \]
          11. associate-/l*N/A

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

            \[\leadsto \log \left(\color{blue}{\frac{2}{1 - x} \cdot x} + \left(1 + 0\right)\right) \cdot \frac{1}{2} \]
          13. metadata-evalN/A

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

            \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(\frac{2}{1 - x}, x, 1\right)\right)} \cdot \frac{1}{2} \]
          15. frac-2negN/A

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

            \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{\frac{\mathsf{neg}\left(2\right)}{\mathsf{neg}\left(\left(1 - x\right)\right)}}, x, 1\right)\right) \cdot \frac{1}{2} \]
          17. metadata-evalN/A

            \[\leadsto \log \left(\mathsf{fma}\left(\frac{\color{blue}{-2}}{\mathsf{neg}\left(\left(1 - x\right)\right)}, x, 1\right)\right) \cdot \frac{1}{2} \]
          18. lift--.f32N/A

            \[\leadsto \log \left(\mathsf{fma}\left(\frac{-2}{\mathsf{neg}\left(\color{blue}{\left(1 - x\right)}\right)}, x, 1\right)\right) \cdot \frac{1}{2} \]
          19. sub-negate-revN/A

            \[\leadsto \log \left(\mathsf{fma}\left(\frac{-2}{\color{blue}{x - 1}}, x, 1\right)\right) \cdot \frac{1}{2} \]
          20. lower--.f3223.6%

            \[\leadsto \log \left(\mathsf{fma}\left(\frac{-2}{\color{blue}{x - 1}}, x, 1\right)\right) \cdot 0.5 \]
        3. Applied rewrites23.6%

          \[\leadsto \color{blue}{\log \left(\mathsf{fma}\left(\frac{-2}{x - 1}, x, 1\right)\right) \cdot 0.5} \]
        4. Step-by-step derivation
          1. lift-fma.f32N/A

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

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

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

            \[\leadsto \log \left(\frac{-2}{\color{blue}{x - 1}} \cdot x + 1\right) \cdot \frac{1}{2} \]
          5. associate-*l/N/A

            \[\leadsto \log \left(\color{blue}{\frac{-2 \cdot x}{x - 1}} + 1\right) \cdot \frac{1}{2} \]
          6. associate-/l*N/A

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

            \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(-2, \frac{x}{x - 1}, 1\right)\right)} \cdot \frac{1}{2} \]
          8. lower-/.f3223.6%

            \[\leadsto \log \left(\mathsf{fma}\left(-2, \color{blue}{\frac{x}{x - 1}}, 1\right)\right) \cdot 0.5 \]
        5. Applied rewrites23.6%

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

      Alternative 4: 99.2% accurate, 0.7× speedup?

      \[\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 0.004999999888241291:\\ \;\;\;\;\left|x\right|\\ \mathbf{else}:\\ \;\;\;\;\log \left(\sqrt{\mathsf{fma}\left(\frac{-2}{\left|x\right| - 1}, \left|x\right|, 1\right)}\right)\\ \end{array} \]
      (FPCore (x)
       :precision binary32
       (*
        (copysign 1.0 x)
        (if (<= (fabs x) 0.004999999888241291)
          (fabs x)
          (log (sqrt (fma (/ -2.0 (- (fabs x) 1.0)) (fabs x) 1.0))))))
      float code(float x) {
      	float tmp;
      	if (fabsf(x) <= 0.004999999888241291f) {
      		tmp = fabsf(x);
      	} else {
      		tmp = logf(sqrtf(fmaf((-2.0f / (fabsf(x) - 1.0f)), fabsf(x), 1.0f)));
      	}
      	return copysignf(1.0f, x) * tmp;
      }
      
      function code(x)
      	tmp = Float32(0.0)
      	if (abs(x) <= Float32(0.004999999888241291))
      		tmp = abs(x);
      	else
      		tmp = log(sqrt(fma(Float32(Float32(-2.0) / Float32(abs(x) - Float32(1.0))), abs(x), Float32(1.0))));
      	end
      	return Float32(copysign(Float32(1.0), x) * tmp)
      end
      
      \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
      \mathbf{if}\;\left|x\right| \leq 0.004999999888241291:\\
      \;\;\;\;\left|x\right|\\
      
      \mathbf{else}:\\
      \;\;\;\;\log \left(\sqrt{\mathsf{fma}\left(\frac{-2}{\left|x\right| - 1}, \left|x\right|, 1\right)}\right)\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < 0.00499999989

        1. Initial program 99.8%

          \[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
        2. Taylor expanded in x around 0

          \[\leadsto \color{blue}{x} \]
        3. Step-by-step derivation
          1. Applied rewrites97.0%

            \[\leadsto \color{blue}{x} \]

          if 0.00499999989 < x

          1. Initial program 99.8%

            \[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
          2. Step-by-step derivation
            1. lift-*.f32N/A

              \[\leadsto \color{blue}{\frac{1}{2} \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right)} \]
            2. lift-log1p.f32N/A

              \[\leadsto \frac{1}{2} \cdot \color{blue}{\log \left(1 + \frac{2 \cdot x}{1 - x}\right)} \]
            3. log-pow-revN/A

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

              \[\leadsto \color{blue}{\log \left({\left(1 + \frac{2 \cdot x}{1 - x}\right)}^{\frac{1}{2}}\right)} \]
            5. unpow1/2N/A

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

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

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

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

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

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

              \[\leadsto \log \left(\sqrt{\frac{\color{blue}{x \cdot 2}}{1 - x} + \left(1 + 0\right)}\right) \]
            12. associate-/l*N/A

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

              \[\leadsto \log \left(\sqrt{\color{blue}{\frac{2}{1 - x} \cdot x} + \left(1 + 0\right)}\right) \]
            14. metadata-evalN/A

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

              \[\leadsto \log \left(\sqrt{\color{blue}{\mathsf{fma}\left(\frac{2}{1 - x}, x, 1\right)}}\right) \]
            16. frac-2negN/A

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

              \[\leadsto \log \left(\sqrt{\mathsf{fma}\left(\color{blue}{\frac{\mathsf{neg}\left(2\right)}{\mathsf{neg}\left(\left(1 - x\right)\right)}}, x, 1\right)}\right) \]
            18. metadata-evalN/A

              \[\leadsto \log \left(\sqrt{\mathsf{fma}\left(\frac{\color{blue}{-2}}{\mathsf{neg}\left(\left(1 - x\right)\right)}, x, 1\right)}\right) \]
            19. lift--.f32N/A

              \[\leadsto \log \left(\sqrt{\mathsf{fma}\left(\frac{-2}{\mathsf{neg}\left(\color{blue}{\left(1 - x\right)}\right)}, x, 1\right)}\right) \]
            20. sub-negate-revN/A

              \[\leadsto \log \left(\sqrt{\mathsf{fma}\left(\frac{-2}{\color{blue}{x - 1}}, x, 1\right)}\right) \]
            21. lower--.f3222.8%

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

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

        Alternative 5: 97.0% accurate, 23.2× speedup?

        \[x \]
        (FPCore (x) :precision binary32 x)
        float code(float x) {
        	return x;
        }
        
        module fmin_fmax_functions
            implicit none
            private
            public fmax
            public fmin
        
            interface fmax
                module procedure fmax88
                module procedure fmax44
                module procedure fmax84
                module procedure fmax48
            end interface
            interface fmin
                module procedure fmin88
                module procedure fmin44
                module procedure fmin84
                module procedure fmin48
            end interface
        contains
            real(8) function fmax88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(4) function fmax44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(8) function fmax84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmax48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
            end function
            real(8) function fmin88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(4) function fmin44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(8) function fmin84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmin48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
            end function
        end module
        
        real(4) function code(x)
        use fmin_fmax_functions
            real(4), intent (in) :: x
            code = x
        end function
        
        function code(x)
        	return x
        end
        
        function tmp = code(x)
        	tmp = x;
        end
        
        x
        
        Derivation
        1. Initial program 99.8%

          \[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
        2. Taylor expanded in x around 0

          \[\leadsto \color{blue}{x} \]
        3. Step-by-step derivation
          1. Applied rewrites97.0%

            \[\leadsto \color{blue}{x} \]
          2. Add Preprocessing

          Reproduce

          ?
          herbie shell --seed 2025183 
          (FPCore (x)
            :name "Rust f32::atanh"
            :precision binary32
            (* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))