Rust f32::atanh

Percentage Accurate: 99.8% → 99.8%
Time: 10.2s
Alternatives: 10
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 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?

\[\begin{array}{l} \\ 0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \end{array} \]
(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
\begin{array}{l}

\\
0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right)
\end{array}

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \end{array} \]
(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
\begin{array}{l}

\\
0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right)
\end{array}
Derivation
  1. Initial program 99.8%

    \[0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right) \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 99.7% accurate, 1.0× speedup?

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

\\
0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{x + -1}\right)
\end{array}
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. associate-*l/99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2}{1 - x} \cdot x}\right) \]
    2. *-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{x \cdot \frac{2}{1 - x}}\right) \]
    3. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{1 + \left(-x\right)}}\right) \]
    4. +-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(-x\right) + 1}}\right) \]
    5. neg-sub099.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(0 - x\right)} + 1}\right) \]
    6. associate-+l-99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{0 - \left(x - 1\right)}}\right) \]
    7. sub0-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{-\left(x - 1\right)}}\right) \]
    8. distribute-frac-neg299.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\left(-\frac{2}{x - 1}\right)}\right) \]
    9. distribute-neg-frac99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\frac{-2}{x - 1}}\right) \]
    10. metadata-eval99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{\color{blue}{-2}}{x - 1}\right) \]
    11. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{\color{blue}{x + \left(-1\right)}}\right) \]
    12. metadata-eval99.7%

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

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

Alternative 3: 99.2% accurate, 4.0× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \left(x \cdot \left(2 + \left(-1 + \left(1 + x \cdot \left(x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + x \cdot \left(x \cdot 0.2857142857142857\right)\right)\right)\right)\right)\right)\right)\right)\right) \end{array} \]
(FPCore (x)
 :precision binary32
 (*
  0.5
  (*
   x
   (+
    2.0
    (+
     -1.0
     (+
      1.0
      (*
       x
       (*
        x
        (+
         0.6666666666666666
         (* x (* x (+ 0.4 (* x (* x 0.2857142857142857))))))))))))))
float code(float x) {
	return 0.5f * (x * (2.0f + (-1.0f + (1.0f + (x * (x * (0.6666666666666666f + (x * (x * (0.4f + (x * (x * 0.2857142857142857f))))))))))));
}
real(4) function code(x)
    real(4), intent (in) :: x
    code = 0.5e0 * (x * (2.0e0 + ((-1.0e0) + (1.0e0 + (x * (x * (0.6666666666666666e0 + (x * (x * (0.4e0 + (x * (x * 0.2857142857142857e0))))))))))))
end function
function code(x)
	return Float32(Float32(0.5) * Float32(x * Float32(Float32(2.0) + Float32(Float32(-1.0) + Float32(Float32(1.0) + Float32(x * Float32(x * Float32(Float32(0.6666666666666666) + Float32(x * Float32(x * Float32(Float32(0.4) + Float32(x * Float32(x * Float32(0.2857142857142857))))))))))))))
end
function tmp = code(x)
	tmp = single(0.5) * (x * (single(2.0) + (single(-1.0) + (single(1.0) + (x * (x * (single(0.6666666666666666) + (x * (x * (single(0.4) + (x * (x * single(0.2857142857142857)))))))))))));
end
\begin{array}{l}

\\
0.5 \cdot \left(x \cdot \left(2 + \left(-1 + \left(1 + x \cdot \left(x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + x \cdot \left(x \cdot 0.2857142857142857\right)\right)\right)\right)\right)\right)\right)\right)\right)
\end{array}
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. associate-*l/99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2}{1 - x} \cdot x}\right) \]
    2. *-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{x \cdot \frac{2}{1 - x}}\right) \]
    3. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{1 + \left(-x\right)}}\right) \]
    4. +-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(-x\right) + 1}}\right) \]
    5. neg-sub099.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(0 - x\right)} + 1}\right) \]
    6. associate-+l-99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{0 - \left(x - 1\right)}}\right) \]
    7. sub0-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{-\left(x - 1\right)}}\right) \]
    8. distribute-frac-neg299.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\left(-\frac{2}{x - 1}\right)}\right) \]
    9. distribute-neg-frac99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\frac{-2}{x - 1}}\right) \]
    10. metadata-eval99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{\color{blue}{-2}}{x - 1}\right) \]
    11. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{\color{blue}{x + \left(-1\right)}}\right) \]
    12. metadata-eval99.7%

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

    \[\leadsto \color{blue}{0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{x + -1}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 99.5%

    \[\leadsto 0.5 \cdot \color{blue}{\left(x \cdot \left(2 + {x}^{2} \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.4 + 0.2857142857142857 \cdot {x}^{2}\right)\right)\right)\right)} \]
  6. Step-by-step derivation
    1. unpow299.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{\left(x \cdot x\right)} \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.4 + 0.2857142857142857 \cdot {x}^{2}\right)\right)\right)\right) \]
    2. associate-*l*99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{x \cdot \left(x \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.4 + 0.2857142857142857 \cdot {x}^{2}\right)\right)\right)}\right)\right) \]
    3. unpow299.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + \color{blue}{\left(x \cdot x\right)} \cdot \left(0.4 + 0.2857142857142857 \cdot {x}^{2}\right)\right)\right)\right)\right) \]
    4. *-commutative99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + \color{blue}{{x}^{2} \cdot 0.2857142857142857}\right)\right)\right)\right)\right) \]
    5. unpow299.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + \color{blue}{\left(x \cdot x\right)} \cdot 0.2857142857142857\right)\right)\right)\right)\right) \]
  7. Simplified99.5%

    \[\leadsto 0.5 \cdot \color{blue}{\left(x \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)\right)\right)\right)} \]
  8. Step-by-step derivation
    1. expm1-log1p-u99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)\right)\right)\right)}\right)\right) \]
    2. expm1-undefine99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{\left(e^{\mathsf{log1p}\left(x \cdot \left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)\right)\right)} - 1\right)}\right)\right) \]
    3. associate-*l*99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \left(e^{\mathsf{log1p}\left(x \cdot \left(x \cdot \left(0.6666666666666666 + \color{blue}{x \cdot \left(x \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)}\right)\right)\right)} - 1\right)\right)\right) \]
  9. Applied egg-rr99.5%

    \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{\left(e^{\mathsf{log1p}\left(x \cdot \left(x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)\right)\right)\right)} - 1\right)}\right)\right) \]
  10. Step-by-step derivation
    1. sub-neg99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{\left(e^{\mathsf{log1p}\left(x \cdot \left(x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)\right)\right)\right)} + \left(-1\right)\right)}\right)\right) \]
    2. log1p-undefine99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \left(e^{\color{blue}{\log \left(1 + x \cdot \left(x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)\right)\right)\right)}} + \left(-1\right)\right)\right)\right) \]
    3. rem-exp-log99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \left(\color{blue}{\left(1 + x \cdot \left(x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)\right)\right)\right)} + \left(-1\right)\right)\right)\right) \]
    4. associate-*r*99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \left(\left(1 + x \cdot \left(x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + \color{blue}{x \cdot \left(x \cdot 0.2857142857142857\right)}\right)\right)\right)\right)\right) + \left(-1\right)\right)\right)\right) \]
    5. metadata-eval99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \left(\left(1 + x \cdot \left(x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + x \cdot \left(x \cdot 0.2857142857142857\right)\right)\right)\right)\right)\right) + \color{blue}{-1}\right)\right)\right) \]
  11. Simplified99.5%

    \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{\left(\left(1 + x \cdot \left(x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + x \cdot \left(x \cdot 0.2857142857142857\right)\right)\right)\right)\right)\right) + -1\right)}\right)\right) \]
  12. Final simplification99.5%

    \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \left(-1 + \left(1 + x \cdot \left(x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + x \cdot \left(x \cdot 0.2857142857142857\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
  13. Add Preprocessing

Alternative 4: 99.2% accurate, 4.0× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(-1 + \left(1 + x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + x \cdot \left(x \cdot 0.2857142857142857\right)\right)\right)\right)\right)\right)\right)\right) \end{array} \]
(FPCore (x)
 :precision binary32
 (*
  0.5
  (*
   x
   (+
    2.0
    (*
     x
     (+
      -1.0
      (+
       1.0
       (*
        x
        (+
         0.6666666666666666
         (* x (* x (+ 0.4 (* x (* x 0.2857142857142857))))))))))))))
float code(float x) {
	return 0.5f * (x * (2.0f + (x * (-1.0f + (1.0f + (x * (0.6666666666666666f + (x * (x * (0.4f + (x * (x * 0.2857142857142857f))))))))))));
}
real(4) function code(x)
    real(4), intent (in) :: x
    code = 0.5e0 * (x * (2.0e0 + (x * ((-1.0e0) + (1.0e0 + (x * (0.6666666666666666e0 + (x * (x * (0.4e0 + (x * (x * 0.2857142857142857e0))))))))))))
end function
function code(x)
	return Float32(Float32(0.5) * Float32(x * Float32(Float32(2.0) + Float32(x * Float32(Float32(-1.0) + Float32(Float32(1.0) + Float32(x * Float32(Float32(0.6666666666666666) + Float32(x * Float32(x * Float32(Float32(0.4) + Float32(x * Float32(x * Float32(0.2857142857142857))))))))))))))
end
function tmp = code(x)
	tmp = single(0.5) * (x * (single(2.0) + (x * (single(-1.0) + (single(1.0) + (x * (single(0.6666666666666666) + (x * (x * (single(0.4) + (x * (x * single(0.2857142857142857)))))))))))));
end
\begin{array}{l}

\\
0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(-1 + \left(1 + x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + x \cdot \left(x \cdot 0.2857142857142857\right)\right)\right)\right)\right)\right)\right)\right)
\end{array}
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. associate-*l/99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2}{1 - x} \cdot x}\right) \]
    2. *-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{x \cdot \frac{2}{1 - x}}\right) \]
    3. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{1 + \left(-x\right)}}\right) \]
    4. +-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(-x\right) + 1}}\right) \]
    5. neg-sub099.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(0 - x\right)} + 1}\right) \]
    6. associate-+l-99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{0 - \left(x - 1\right)}}\right) \]
    7. sub0-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{-\left(x - 1\right)}}\right) \]
    8. distribute-frac-neg299.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\left(-\frac{2}{x - 1}\right)}\right) \]
    9. distribute-neg-frac99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\frac{-2}{x - 1}}\right) \]
    10. metadata-eval99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{\color{blue}{-2}}{x - 1}\right) \]
    11. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{\color{blue}{x + \left(-1\right)}}\right) \]
    12. metadata-eval99.7%

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

    \[\leadsto \color{blue}{0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{x + -1}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 99.5%

    \[\leadsto 0.5 \cdot \color{blue}{\left(x \cdot \left(2 + {x}^{2} \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.4 + 0.2857142857142857 \cdot {x}^{2}\right)\right)\right)\right)} \]
  6. Step-by-step derivation
    1. unpow299.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{\left(x \cdot x\right)} \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.4 + 0.2857142857142857 \cdot {x}^{2}\right)\right)\right)\right) \]
    2. associate-*l*99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{x \cdot \left(x \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.4 + 0.2857142857142857 \cdot {x}^{2}\right)\right)\right)}\right)\right) \]
    3. unpow299.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + \color{blue}{\left(x \cdot x\right)} \cdot \left(0.4 + 0.2857142857142857 \cdot {x}^{2}\right)\right)\right)\right)\right) \]
    4. *-commutative99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + \color{blue}{{x}^{2} \cdot 0.2857142857142857}\right)\right)\right)\right)\right) \]
    5. unpow299.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + \color{blue}{\left(x \cdot x\right)} \cdot 0.2857142857142857\right)\right)\right)\right)\right) \]
  7. Simplified99.5%

    \[\leadsto 0.5 \cdot \color{blue}{\left(x \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)\right)\right)\right)} \]
  8. Step-by-step derivation
    1. expm1-log1p-u99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)\right)\right)}\right)\right) \]
    2. expm1-undefine99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)\right)} - 1\right)}\right)\right) \]
    3. associate-*l*99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(e^{\mathsf{log1p}\left(x \cdot \left(0.6666666666666666 + \color{blue}{x \cdot \left(x \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)}\right)\right)} - 1\right)\right)\right) \]
  9. Applied egg-rr99.5%

    \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)\right)\right)} - 1\right)}\right)\right) \]
  10. Step-by-step derivation
    1. sub-neg99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)\right)\right)} + \left(-1\right)\right)}\right)\right) \]
    2. log1p-undefine99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(e^{\color{blue}{\log \left(1 + x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)\right)\right)}} + \left(-1\right)\right)\right)\right) \]
    3. rem-exp-log99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(\color{blue}{\left(1 + x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)\right)\right)} + \left(-1\right)\right)\right)\right) \]
    4. associate-*r*99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(\left(1 + x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + \color{blue}{x \cdot \left(x \cdot 0.2857142857142857\right)}\right)\right)\right)\right) + \left(-1\right)\right)\right)\right) \]
    5. metadata-eval99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(\left(1 + x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + x \cdot \left(x \cdot 0.2857142857142857\right)\right)\right)\right)\right) + \color{blue}{-1}\right)\right)\right) \]
  11. Simplified99.5%

    \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \color{blue}{\left(\left(1 + x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + x \cdot \left(x \cdot 0.2857142857142857\right)\right)\right)\right)\right) + -1\right)}\right)\right) \]
  12. Final simplification99.5%

    \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(-1 + \left(1 + x \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot \left(0.4 + x \cdot \left(x \cdot 0.2857142857142857\right)\right)\right)\right)\right)\right)\right)\right) \]
  13. Add Preprocessing

Alternative 5: 99.2% accurate, 4.7× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + 0.2857142857142857 \cdot \left(x \cdot x\right)\right)\right)\right)\right)\right) \end{array} \]
(FPCore (x)
 :precision binary32
 (*
  0.5
  (*
   x
   (+
    2.0
    (*
     x
     (*
      x
      (+
       0.6666666666666666
       (* (* x x) (+ 0.4 (* 0.2857142857142857 (* x x)))))))))))
float code(float x) {
	return 0.5f * (x * (2.0f + (x * (x * (0.6666666666666666f + ((x * x) * (0.4f + (0.2857142857142857f * (x * x)))))))));
}
real(4) function code(x)
    real(4), intent (in) :: x
    code = 0.5e0 * (x * (2.0e0 + (x * (x * (0.6666666666666666e0 + ((x * x) * (0.4e0 + (0.2857142857142857e0 * (x * x)))))))))
end function
function code(x)
	return Float32(Float32(0.5) * Float32(x * Float32(Float32(2.0) + Float32(x * Float32(x * Float32(Float32(0.6666666666666666) + Float32(Float32(x * x) * Float32(Float32(0.4) + Float32(Float32(0.2857142857142857) * Float32(x * x))))))))))
end
function tmp = code(x)
	tmp = single(0.5) * (x * (single(2.0) + (x * (x * (single(0.6666666666666666) + ((x * x) * (single(0.4) + (single(0.2857142857142857) * (x * x)))))))));
end
\begin{array}{l}

\\
0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + 0.2857142857142857 \cdot \left(x \cdot x\right)\right)\right)\right)\right)\right)
\end{array}
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. associate-*l/99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2}{1 - x} \cdot x}\right) \]
    2. *-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{x \cdot \frac{2}{1 - x}}\right) \]
    3. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{1 + \left(-x\right)}}\right) \]
    4. +-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(-x\right) + 1}}\right) \]
    5. neg-sub099.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(0 - x\right)} + 1}\right) \]
    6. associate-+l-99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{0 - \left(x - 1\right)}}\right) \]
    7. sub0-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{-\left(x - 1\right)}}\right) \]
    8. distribute-frac-neg299.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\left(-\frac{2}{x - 1}\right)}\right) \]
    9. distribute-neg-frac99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\frac{-2}{x - 1}}\right) \]
    10. metadata-eval99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{\color{blue}{-2}}{x - 1}\right) \]
    11. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{\color{blue}{x + \left(-1\right)}}\right) \]
    12. metadata-eval99.7%

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

    \[\leadsto \color{blue}{0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{x + -1}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 99.5%

    \[\leadsto 0.5 \cdot \color{blue}{\left(x \cdot \left(2 + {x}^{2} \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.4 + 0.2857142857142857 \cdot {x}^{2}\right)\right)\right)\right)} \]
  6. Step-by-step derivation
    1. unpow299.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{\left(x \cdot x\right)} \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.4 + 0.2857142857142857 \cdot {x}^{2}\right)\right)\right)\right) \]
    2. associate-*l*99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{x \cdot \left(x \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.4 + 0.2857142857142857 \cdot {x}^{2}\right)\right)\right)}\right)\right) \]
    3. unpow299.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + \color{blue}{\left(x \cdot x\right)} \cdot \left(0.4 + 0.2857142857142857 \cdot {x}^{2}\right)\right)\right)\right)\right) \]
    4. *-commutative99.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + \color{blue}{{x}^{2} \cdot 0.2857142857142857}\right)\right)\right)\right)\right) \]
    5. unpow299.5%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + \color{blue}{\left(x \cdot x\right)} \cdot 0.2857142857142857\right)\right)\right)\right)\right) \]
  7. Simplified99.5%

    \[\leadsto 0.5 \cdot \color{blue}{\left(x \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + \left(x \cdot x\right) \cdot 0.2857142857142857\right)\right)\right)\right)\right)} \]
  8. Final simplification99.5%

    \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + x \cdot \left(x \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot \left(0.4 + 0.2857142857142857 \cdot \left(x \cdot x\right)\right)\right)\right)\right)\right) \]
  9. Add Preprocessing

Alternative 6: 99.1% accurate, 5.7× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \left(x \cdot \left(\left(x \cdot x\right) \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot 0.4\right)\right)\right) + 2 \cdot x\right) \end{array} \]
(FPCore (x)
 :precision binary32
 (*
  0.5
  (+ (* x (* (* x x) (+ 0.6666666666666666 (* x (* x 0.4))))) (* 2.0 x))))
float code(float x) {
	return 0.5f * ((x * ((x * x) * (0.6666666666666666f + (x * (x * 0.4f))))) + (2.0f * x));
}
real(4) function code(x)
    real(4), intent (in) :: x
    code = 0.5e0 * ((x * ((x * x) * (0.6666666666666666e0 + (x * (x * 0.4e0))))) + (2.0e0 * x))
end function
function code(x)
	return Float32(Float32(0.5) * Float32(Float32(x * Float32(Float32(x * x) * Float32(Float32(0.6666666666666666) + Float32(x * Float32(x * Float32(0.4)))))) + Float32(Float32(2.0) * x)))
end
function tmp = code(x)
	tmp = single(0.5) * ((x * ((x * x) * (single(0.6666666666666666) + (x * (x * single(0.4)))))) + (single(2.0) * x));
end
\begin{array}{l}

\\
0.5 \cdot \left(x \cdot \left(\left(x \cdot x\right) \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot 0.4\right)\right)\right) + 2 \cdot x\right)
\end{array}
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. associate-*l/99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2}{1 - x} \cdot x}\right) \]
    2. *-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{x \cdot \frac{2}{1 - x}}\right) \]
    3. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{1 + \left(-x\right)}}\right) \]
    4. +-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(-x\right) + 1}}\right) \]
    5. neg-sub099.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(0 - x\right)} + 1}\right) \]
    6. associate-+l-99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{0 - \left(x - 1\right)}}\right) \]
    7. sub0-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{-\left(x - 1\right)}}\right) \]
    8. distribute-frac-neg299.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\left(-\frac{2}{x - 1}\right)}\right) \]
    9. distribute-neg-frac99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\frac{-2}{x - 1}}\right) \]
    10. metadata-eval99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{\color{blue}{-2}}{x - 1}\right) \]
    11. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{\color{blue}{x + \left(-1\right)}}\right) \]
    12. metadata-eval99.7%

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

    \[\leadsto \color{blue}{0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{x + -1}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 99.1%

    \[\leadsto 0.5 \cdot \color{blue}{\left(x \cdot \left(2 + {x}^{2} \cdot \left(0.6666666666666666 + 0.4 \cdot {x}^{2}\right)\right)\right)} \]
  6. Step-by-step derivation
    1. unpow299.1%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{\left(x \cdot x\right)} \cdot \left(0.6666666666666666 + 0.4 \cdot {x}^{2}\right)\right)\right) \]
    2. *-commutative99.1%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \left(x \cdot x\right) \cdot \left(0.6666666666666666 + \color{blue}{{x}^{2} \cdot 0.4}\right)\right)\right) \]
    3. unpow299.1%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \left(x \cdot x\right) \cdot \left(0.6666666666666666 + \color{blue}{\left(x \cdot x\right)} \cdot 0.4\right)\right)\right) \]
  7. Simplified99.1%

    \[\leadsto 0.5 \cdot \color{blue}{\left(x \cdot \left(2 + \left(x \cdot x\right) \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot 0.4\right)\right)\right)} \]
  8. Step-by-step derivation
    1. +-commutative99.1%

      \[\leadsto 0.5 \cdot \left(x \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot 0.4\right) + 2\right)}\right) \]
    2. distribute-rgt-in99.2%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\left(\left(x \cdot x\right) \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot 0.4\right)\right) \cdot x + 2 \cdot x\right)} \]
    3. associate-*l*99.2%

      \[\leadsto 0.5 \cdot \left(\left(\left(x \cdot x\right) \cdot \left(0.6666666666666666 + \color{blue}{x \cdot \left(x \cdot 0.4\right)}\right)\right) \cdot x + 2 \cdot x\right) \]
    4. *-commutative99.2%

      \[\leadsto 0.5 \cdot \left(\left(\left(x \cdot x\right) \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot 0.4\right)\right)\right) \cdot x + \color{blue}{x \cdot 2}\right) \]
  9. Applied egg-rr99.2%

    \[\leadsto 0.5 \cdot \color{blue}{\left(\left(\left(x \cdot x\right) \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot 0.4\right)\right)\right) \cdot x + x \cdot 2\right)} \]
  10. Final simplification99.2%

    \[\leadsto 0.5 \cdot \left(x \cdot \left(\left(x \cdot x\right) \cdot \left(0.6666666666666666 + x \cdot \left(x \cdot 0.4\right)\right)\right) + 2 \cdot x\right) \]
  11. Add Preprocessing

Alternative 7: 99.0% accurate, 6.4× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \left(x \cdot \left(2 + \left(x \cdot x\right) \cdot \left(0.6666666666666666 + 0.4 \cdot \left(x \cdot x\right)\right)\right)\right) \end{array} \]
(FPCore (x)
 :precision binary32
 (* 0.5 (* x (+ 2.0 (* (* x x) (+ 0.6666666666666666 (* 0.4 (* x x))))))))
float code(float x) {
	return 0.5f * (x * (2.0f + ((x * x) * (0.6666666666666666f + (0.4f * (x * x))))));
}
real(4) function code(x)
    real(4), intent (in) :: x
    code = 0.5e0 * (x * (2.0e0 + ((x * x) * (0.6666666666666666e0 + (0.4e0 * (x * x))))))
end function
function code(x)
	return Float32(Float32(0.5) * Float32(x * Float32(Float32(2.0) + Float32(Float32(x * x) * Float32(Float32(0.6666666666666666) + Float32(Float32(0.4) * Float32(x * x)))))))
end
function tmp = code(x)
	tmp = single(0.5) * (x * (single(2.0) + ((x * x) * (single(0.6666666666666666) + (single(0.4) * (x * x))))));
end
\begin{array}{l}

\\
0.5 \cdot \left(x \cdot \left(2 + \left(x \cdot x\right) \cdot \left(0.6666666666666666 + 0.4 \cdot \left(x \cdot x\right)\right)\right)\right)
\end{array}
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. associate-*l/99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2}{1 - x} \cdot x}\right) \]
    2. *-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{x \cdot \frac{2}{1 - x}}\right) \]
    3. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{1 + \left(-x\right)}}\right) \]
    4. +-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(-x\right) + 1}}\right) \]
    5. neg-sub099.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(0 - x\right)} + 1}\right) \]
    6. associate-+l-99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{0 - \left(x - 1\right)}}\right) \]
    7. sub0-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{-\left(x - 1\right)}}\right) \]
    8. distribute-frac-neg299.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\left(-\frac{2}{x - 1}\right)}\right) \]
    9. distribute-neg-frac99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\frac{-2}{x - 1}}\right) \]
    10. metadata-eval99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{\color{blue}{-2}}{x - 1}\right) \]
    11. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{\color{blue}{x + \left(-1\right)}}\right) \]
    12. metadata-eval99.7%

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

    \[\leadsto \color{blue}{0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{x + -1}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 99.1%

    \[\leadsto 0.5 \cdot \color{blue}{\left(x \cdot \left(2 + {x}^{2} \cdot \left(0.6666666666666666 + 0.4 \cdot {x}^{2}\right)\right)\right)} \]
  6. Step-by-step derivation
    1. unpow299.1%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{\left(x \cdot x\right)} \cdot \left(0.6666666666666666 + 0.4 \cdot {x}^{2}\right)\right)\right) \]
    2. *-commutative99.1%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \left(x \cdot x\right) \cdot \left(0.6666666666666666 + \color{blue}{{x}^{2} \cdot 0.4}\right)\right)\right) \]
    3. unpow299.1%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \left(x \cdot x\right) \cdot \left(0.6666666666666666 + \color{blue}{\left(x \cdot x\right)} \cdot 0.4\right)\right)\right) \]
  7. Simplified99.1%

    \[\leadsto 0.5 \cdot \color{blue}{\left(x \cdot \left(2 + \left(x \cdot x\right) \cdot \left(0.6666666666666666 + \left(x \cdot x\right) \cdot 0.4\right)\right)\right)} \]
  8. Final simplification99.1%

    \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \left(x \cdot x\right) \cdot \left(0.6666666666666666 + 0.4 \cdot \left(x \cdot x\right)\right)\right)\right) \]
  9. Add Preprocessing

Alternative 8: 98.6% accurate, 8.4× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \left(2 \cdot x + x \cdot \left(0.6666666666666666 \cdot \left(x \cdot x\right)\right)\right) \end{array} \]
(FPCore (x)
 :precision binary32
 (* 0.5 (+ (* 2.0 x) (* x (* 0.6666666666666666 (* x x))))))
float code(float x) {
	return 0.5f * ((2.0f * x) + (x * (0.6666666666666666f * (x * x))));
}
real(4) function code(x)
    real(4), intent (in) :: x
    code = 0.5e0 * ((2.0e0 * x) + (x * (0.6666666666666666e0 * (x * x))))
end function
function code(x)
	return Float32(Float32(0.5) * Float32(Float32(Float32(2.0) * x) + Float32(x * Float32(Float32(0.6666666666666666) * Float32(x * x)))))
end
function tmp = code(x)
	tmp = single(0.5) * ((single(2.0) * x) + (x * (single(0.6666666666666666) * (x * x))));
end
\begin{array}{l}

\\
0.5 \cdot \left(2 \cdot x + x \cdot \left(0.6666666666666666 \cdot \left(x \cdot x\right)\right)\right)
\end{array}
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. associate-*l/99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2}{1 - x} \cdot x}\right) \]
    2. *-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{x \cdot \frac{2}{1 - x}}\right) \]
    3. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{1 + \left(-x\right)}}\right) \]
    4. +-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(-x\right) + 1}}\right) \]
    5. neg-sub099.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(0 - x\right)} + 1}\right) \]
    6. associate-+l-99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{0 - \left(x - 1\right)}}\right) \]
    7. sub0-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{-\left(x - 1\right)}}\right) \]
    8. distribute-frac-neg299.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\left(-\frac{2}{x - 1}\right)}\right) \]
    9. distribute-neg-frac99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\frac{-2}{x - 1}}\right) \]
    10. metadata-eval99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{\color{blue}{-2}}{x - 1}\right) \]
    11. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{\color{blue}{x + \left(-1\right)}}\right) \]
    12. metadata-eval99.7%

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

    \[\leadsto \color{blue}{0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{x + -1}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 98.6%

    \[\leadsto 0.5 \cdot \color{blue}{\left(x \cdot \left(2 + 0.6666666666666666 \cdot {x}^{2}\right)\right)} \]
  6. Step-by-step derivation
    1. *-commutative98.6%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{{x}^{2} \cdot 0.6666666666666666}\right)\right) \]
    2. unpow298.6%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{\left(x \cdot x\right)} \cdot 0.6666666666666666\right)\right) \]
  7. Simplified98.6%

    \[\leadsto 0.5 \cdot \color{blue}{\left(x \cdot \left(2 + \left(x \cdot x\right) \cdot 0.6666666666666666\right)\right)} \]
  8. Step-by-step derivation
    1. +-commutative98.6%

      \[\leadsto 0.5 \cdot \left(x \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot 0.6666666666666666 + 2\right)}\right) \]
    2. distribute-rgt-in98.6%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\left(\left(x \cdot x\right) \cdot 0.6666666666666666\right) \cdot x + 2 \cdot x\right)} \]
    3. *-commutative98.6%

      \[\leadsto 0.5 \cdot \left(\left(\left(x \cdot x\right) \cdot 0.6666666666666666\right) \cdot x + \color{blue}{x \cdot 2}\right) \]
  9. Applied egg-rr98.6%

    \[\leadsto 0.5 \cdot \color{blue}{\left(\left(\left(x \cdot x\right) \cdot 0.6666666666666666\right) \cdot x + x \cdot 2\right)} \]
  10. Final simplification98.6%

    \[\leadsto 0.5 \cdot \left(2 \cdot x + x \cdot \left(0.6666666666666666 \cdot \left(x \cdot x\right)\right)\right) \]
  11. Add Preprocessing

Alternative 9: 98.5% accurate, 9.9× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \left(x \cdot \left(2 + 0.6666666666666666 \cdot \left(x \cdot x\right)\right)\right) \end{array} \]
(FPCore (x)
 :precision binary32
 (* 0.5 (* x (+ 2.0 (* 0.6666666666666666 (* x x))))))
float code(float x) {
	return 0.5f * (x * (2.0f + (0.6666666666666666f * (x * x))));
}
real(4) function code(x)
    real(4), intent (in) :: x
    code = 0.5e0 * (x * (2.0e0 + (0.6666666666666666e0 * (x * x))))
end function
function code(x)
	return Float32(Float32(0.5) * Float32(x * Float32(Float32(2.0) + Float32(Float32(0.6666666666666666) * Float32(x * x)))))
end
function tmp = code(x)
	tmp = single(0.5) * (x * (single(2.0) + (single(0.6666666666666666) * (x * x))));
end
\begin{array}{l}

\\
0.5 \cdot \left(x \cdot \left(2 + 0.6666666666666666 \cdot \left(x \cdot x\right)\right)\right)
\end{array}
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. associate-*l/99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2}{1 - x} \cdot x}\right) \]
    2. *-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{x \cdot \frac{2}{1 - x}}\right) \]
    3. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{1 + \left(-x\right)}}\right) \]
    4. +-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(-x\right) + 1}}\right) \]
    5. neg-sub099.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(0 - x\right)} + 1}\right) \]
    6. associate-+l-99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{0 - \left(x - 1\right)}}\right) \]
    7. sub0-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{-\left(x - 1\right)}}\right) \]
    8. distribute-frac-neg299.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\left(-\frac{2}{x - 1}\right)}\right) \]
    9. distribute-neg-frac99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\frac{-2}{x - 1}}\right) \]
    10. metadata-eval99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{\color{blue}{-2}}{x - 1}\right) \]
    11. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{\color{blue}{x + \left(-1\right)}}\right) \]
    12. metadata-eval99.7%

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

    \[\leadsto \color{blue}{0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{x + -1}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 98.6%

    \[\leadsto 0.5 \cdot \color{blue}{\left(x \cdot \left(2 + 0.6666666666666666 \cdot {x}^{2}\right)\right)} \]
  6. Step-by-step derivation
    1. *-commutative98.6%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{{x}^{2} \cdot 0.6666666666666666}\right)\right) \]
    2. unpow298.6%

      \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + \color{blue}{\left(x \cdot x\right)} \cdot 0.6666666666666666\right)\right) \]
  7. Simplified98.6%

    \[\leadsto 0.5 \cdot \color{blue}{\left(x \cdot \left(2 + \left(x \cdot x\right) \cdot 0.6666666666666666\right)\right)} \]
  8. Final simplification98.6%

    \[\leadsto 0.5 \cdot \left(x \cdot \left(2 + 0.6666666666666666 \cdot \left(x \cdot x\right)\right)\right) \]
  9. Add Preprocessing

Alternative 10: 96.9% accurate, 21.8× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \left(2 \cdot x\right) \end{array} \]
(FPCore (x) :precision binary32 (* 0.5 (* 2.0 x)))
float code(float x) {
	return 0.5f * (2.0f * x);
}
real(4) function code(x)
    real(4), intent (in) :: x
    code = 0.5e0 * (2.0e0 * x)
end function
function code(x)
	return Float32(Float32(0.5) * Float32(Float32(2.0) * x))
end
function tmp = code(x)
	tmp = single(0.5) * (single(2.0) * x);
end
\begin{array}{l}

\\
0.5 \cdot \left(2 \cdot x\right)
\end{array}
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. associate-*l/99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{\frac{2}{1 - x} \cdot x}\right) \]
    2. *-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(\color{blue}{x \cdot \frac{2}{1 - x}}\right) \]
    3. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{1 + \left(-x\right)}}\right) \]
    4. +-commutative99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(-x\right) + 1}}\right) \]
    5. neg-sub099.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{\left(0 - x\right)} + 1}\right) \]
    6. associate-+l-99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{0 - \left(x - 1\right)}}\right) \]
    7. sub0-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{\color{blue}{-\left(x - 1\right)}}\right) \]
    8. distribute-frac-neg299.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\left(-\frac{2}{x - 1}\right)}\right) \]
    9. distribute-neg-frac99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \color{blue}{\frac{-2}{x - 1}}\right) \]
    10. metadata-eval99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{\color{blue}{-2}}{x - 1}\right) \]
    11. sub-neg99.7%

      \[\leadsto 0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{\color{blue}{x + \left(-1\right)}}\right) \]
    12. metadata-eval99.7%

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

    \[\leadsto \color{blue}{0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{-2}{x + -1}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 97.4%

    \[\leadsto 0.5 \cdot \color{blue}{\left(2 \cdot x\right)} \]
  6. Add Preprocessing

Reproduce

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