2atan (example 3.5)

Percentage Accurate: 8.5% → 99.9%
Time: 9.3s
Alternatives: 7
Speedup: 1.9×

Specification

?
\[N > 1 \land N < 10^{+100}\]
\[\begin{array}{l} \\ \tan^{-1} \left(N + 1\right) - \tan^{-1} N \end{array} \]
(FPCore (N) :precision binary64 (- (atan (+ N 1.0)) (atan N)))
double code(double N) {
	return atan((N + 1.0)) - atan(N);
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = atan((n + 1.0d0)) - atan(n)
end function
public static double code(double N) {
	return Math.atan((N + 1.0)) - Math.atan(N);
}
def code(N):
	return math.atan((N + 1.0)) - math.atan(N)
function code(N)
	return Float64(atan(Float64(N + 1.0)) - atan(N))
end
function tmp = code(N)
	tmp = atan((N + 1.0)) - atan(N);
end
code[N_] := N[(N[ArcTan[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[ArcTan[N], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\tan^{-1} \left(N + 1\right) - \tan^{-1} N
\end{array}

Sampling outcomes in binary64 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 7 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: 8.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \tan^{-1} \left(N + 1\right) - \tan^{-1} N \end{array} \]
(FPCore (N) :precision binary64 (- (atan (+ N 1.0)) (atan N)))
double code(double N) {
	return atan((N + 1.0)) - atan(N);
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = atan((n + 1.0d0)) - atan(n)
end function
public static double code(double N) {
	return Math.atan((N + 1.0)) - Math.atan(N);
}
def code(N):
	return math.atan((N + 1.0)) - math.atan(N)
function code(N)
	return Float64(atan(Float64(N + 1.0)) - atan(N))
end
function tmp = code(N)
	tmp = atan((N + 1.0)) - atan(N);
end
code[N_] := N[(N[ArcTan[N[(N + 1.0), $MachinePrecision]], $MachinePrecision] - N[ArcTan[N], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\tan^{-1} \left(N + 1\right) - \tan^{-1} N
\end{array}

Alternative 1: 99.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ {\left({\tan^{-1}_* \frac{1}{1 + \mathsf{fma}\left(N, N, N\right)}}^{-0.5}\right)}^{-2} \end{array} \]
(FPCore (N)
 :precision binary64
 (pow (pow (atan2 1.0 (+ 1.0 (fma N N N))) -0.5) -2.0))
double code(double N) {
	return pow(pow(atan2(1.0, (1.0 + fma(N, N, N))), -0.5), -2.0);
}
function code(N)
	return (atan(1.0, Float64(1.0 + fma(N, N, N))) ^ -0.5) ^ -2.0
end
code[N_] := N[Power[N[Power[N[ArcTan[1.0 / N[(1.0 + N[(N * N + N), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], -0.5], $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}

\\
{\left({\tan^{-1}_* \frac{1}{1 + \mathsf{fma}\left(N, N, N\right)}}^{-0.5}\right)}^{-2}
\end{array}
Derivation
  1. Initial program 10.1%

    \[\tan^{-1} \left(N + 1\right) - \tan^{-1} N \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \color{blue}{\tan^{-1} \left(N + 1\right) - \tan^{-1} N} \]
    2. flip--N/A

      \[\leadsto \color{blue}{\frac{\tan^{-1} \left(N + 1\right) \cdot \tan^{-1} \left(N + 1\right) - \tan^{-1} N \cdot \tan^{-1} N}{\tan^{-1} \left(N + 1\right) + \tan^{-1} N}} \]
    3. clear-numN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\tan^{-1} \left(N + 1\right) + \tan^{-1} N}{\tan^{-1} \left(N + 1\right) \cdot \tan^{-1} \left(N + 1\right) - \tan^{-1} N \cdot \tan^{-1} N}}} \]
    4. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\tan^{-1} \left(N + 1\right) + \tan^{-1} N}{\tan^{-1} \left(N + 1\right) \cdot \tan^{-1} \left(N + 1\right) - \tan^{-1} N \cdot \tan^{-1} N}}} \]
    5. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\tan^{-1} \left(N + 1\right) \cdot \tan^{-1} \left(N + 1\right) - \tan^{-1} N \cdot \tan^{-1} N}{\tan^{-1} \left(N + 1\right) + \tan^{-1} N}}}} \]
    6. flip--N/A

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\tan^{-1} \left(N + 1\right) - \tan^{-1} N}}} \]
    7. lift--.f64N/A

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\tan^{-1} \left(N + 1\right) - \tan^{-1} N}}} \]
    8. lower-/.f6410.1

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\tan^{-1} \left(N + 1\right) - \tan^{-1} N}}} \]
    9. lift--.f64N/A

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\tan^{-1} \left(N + 1\right) - \tan^{-1} N}}} \]
    10. lift-atan.f64N/A

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\tan^{-1} \left(N + 1\right)} - \tan^{-1} N}} \]
    11. lift-atan.f64N/A

      \[\leadsto \frac{1}{\frac{1}{\tan^{-1} \left(N + 1\right) - \color{blue}{\tan^{-1} N}}} \]
    12. diff-atanN/A

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\tan^{-1}_* \frac{\left(N + 1\right) - N}{1 + \left(N + 1\right) \cdot N}}}} \]
    13. lift-+.f64N/A

      \[\leadsto \frac{1}{\frac{1}{\tan^{-1}_* \frac{\color{blue}{\left(N + 1\right)} - N}{1 + \left(N + 1\right) \cdot N}}} \]
    14. +-commutativeN/A

      \[\leadsto \frac{1}{\frac{1}{\tan^{-1}_* \frac{\color{blue}{\left(1 + N\right)} - N}{1 + \left(N + 1\right) \cdot N}}} \]
    15. associate--l+N/A

      \[\leadsto \frac{1}{\frac{1}{\tan^{-1}_* \frac{\color{blue}{1 + \left(N - N\right)}}{1 + \left(N + 1\right) \cdot N}}} \]
    16. +-inversesN/A

      \[\leadsto \frac{1}{\frac{1}{\tan^{-1}_* \frac{1 + \color{blue}{0}}{1 + \left(N + 1\right) \cdot N}}} \]
    17. metadata-evalN/A

      \[\leadsto \frac{1}{\frac{1}{\tan^{-1}_* \frac{\color{blue}{1}}{1 + \left(N + 1\right) \cdot N}}} \]
    18. +-commutativeN/A

      \[\leadsto \frac{1}{\frac{1}{\tan^{-1}_* \frac{1}{\color{blue}{\left(N + 1\right) \cdot N + 1}}}} \]
  4. Applied rewrites99.6%

    \[\leadsto \color{blue}{\frac{1}{\frac{1}{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}}} \]
  5. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}}} \]
    2. inv-powN/A

      \[\leadsto \frac{1}{\color{blue}{{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}^{-1}}} \]
    3. sqr-powN/A

      \[\leadsto \frac{1}{\color{blue}{{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}^{\left(\frac{-1}{2}\right)} \cdot {\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}^{\left(\frac{-1}{2}\right)}}} \]
    4. pow2N/A

      \[\leadsto \frac{1}{\color{blue}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}^{\left(\frac{-1}{2}\right)}\right)}^{2}}} \]
    5. lower-pow.f64N/A

      \[\leadsto \frac{1}{\color{blue}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}^{\left(\frac{-1}{2}\right)}\right)}^{2}}} \]
    6. lower-pow.f64N/A

      \[\leadsto \frac{1}{{\color{blue}{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}^{\left(\frac{-1}{2}\right)}\right)}}^{2}} \]
    7. lift-+.f64N/A

      \[\leadsto \frac{1}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, \color{blue}{N + 1}\right)}}^{\left(\frac{-1}{2}\right)}\right)}^{2}} \]
    8. +-commutativeN/A

      \[\leadsto \frac{1}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, \color{blue}{1 + N}\right)}}^{\left(\frac{-1}{2}\right)}\right)}^{2}} \]
    9. lower-+.f64N/A

      \[\leadsto \frac{1}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, \color{blue}{1 + N}\right)}}^{\left(\frac{-1}{2}\right)}\right)}^{2}} \]
    10. metadata-eval99.6

      \[\leadsto \frac{1}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, 1 + N\right)}}^{\color{blue}{-0.5}}\right)}^{2}} \]
  6. Applied rewrites99.6%

    \[\leadsto \frac{1}{\color{blue}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, 1 + N\right)}}^{-0.5}\right)}^{2}}} \]
  7. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, 1 + N\right)}}^{\frac{-1}{2}}\right)}^{2}}} \]
    2. lift-pow.f64N/A

      \[\leadsto \frac{1}{\color{blue}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, 1 + N\right)}}^{\frac{-1}{2}}\right)}^{2}}} \]
    3. pow-flipN/A

      \[\leadsto \color{blue}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, 1 + N\right)}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)}} \]
    4. lower-pow.f64N/A

      \[\leadsto \color{blue}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, 1 + N\right)}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)}} \]
    5. lift-fma.f64N/A

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{\color{blue}{N \cdot N + \left(1 + N\right)}}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)} \]
    6. +-commutativeN/A

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{\color{blue}{\left(1 + N\right) + N \cdot N}}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)} \]
    7. lift-+.f64N/A

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{\color{blue}{\left(1 + N\right)} + N \cdot N}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)} \]
    8. associate-+r+N/A

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{\color{blue}{1 + \left(N + N \cdot N\right)}}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)} \]
    9. +-commutativeN/A

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{1 + \color{blue}{\left(N \cdot N + N\right)}}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)} \]
    10. lift-fma.f64N/A

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{1 + \color{blue}{\mathsf{fma}\left(N, N, N\right)}}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)} \]
    11. lower-+.f64N/A

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{\color{blue}{1 + \mathsf{fma}\left(N, N, N\right)}}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)} \]
    12. metadata-eval99.9

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{1 + \mathsf{fma}\left(N, N, N\right)}}^{-0.5}\right)}^{\color{blue}{-2}} \]
  8. Applied rewrites99.9%

    \[\leadsto \color{blue}{{\left({\tan^{-1}_* \frac{1}{1 + \mathsf{fma}\left(N, N, N\right)}}^{-0.5}\right)}^{-2}} \]
  9. Add Preprocessing

Alternative 2: 99.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ {\left(\sqrt{\frac{1}{\tan^{-1}_* \frac{1}{1 + \mathsf{fma}\left(N, N, N\right)}}}\right)}^{-2} \end{array} \]
(FPCore (N)
 :precision binary64
 (pow (sqrt (/ 1.0 (atan2 1.0 (+ 1.0 (fma N N N))))) -2.0))
double code(double N) {
	return pow(sqrt((1.0 / atan2(1.0, (1.0 + fma(N, N, N))))), -2.0);
}
function code(N)
	return sqrt(Float64(1.0 / atan(1.0, Float64(1.0 + fma(N, N, N))))) ^ -2.0
end
code[N_] := N[Power[N[Sqrt[N[(1.0 / N[ArcTan[1.0 / N[(1.0 + N[(N * N + N), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}

\\
{\left(\sqrt{\frac{1}{\tan^{-1}_* \frac{1}{1 + \mathsf{fma}\left(N, N, N\right)}}}\right)}^{-2}
\end{array}
Derivation
  1. Initial program 8.5%

    \[\tan^{-1} \left(N + 1\right) - \tan^{-1} N \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \color{blue}{\tan^{-1} \left(N + 1\right) - \tan^{-1} N} \]
    2. flip--N/A

      \[\leadsto \color{blue}{\frac{\tan^{-1} \left(N + 1\right) \cdot \tan^{-1} \left(N + 1\right) - \tan^{-1} N \cdot \tan^{-1} N}{\tan^{-1} \left(N + 1\right) + \tan^{-1} N}} \]
    3. clear-numN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\tan^{-1} \left(N + 1\right) + \tan^{-1} N}{\tan^{-1} \left(N + 1\right) \cdot \tan^{-1} \left(N + 1\right) - \tan^{-1} N \cdot \tan^{-1} N}}} \]
    4. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\tan^{-1} \left(N + 1\right) + \tan^{-1} N}{\tan^{-1} \left(N + 1\right) \cdot \tan^{-1} \left(N + 1\right) - \tan^{-1} N \cdot \tan^{-1} N}}} \]
    5. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\tan^{-1} \left(N + 1\right) \cdot \tan^{-1} \left(N + 1\right) - \tan^{-1} N \cdot \tan^{-1} N}{\tan^{-1} \left(N + 1\right) + \tan^{-1} N}}}} \]
    6. flip--N/A

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\tan^{-1} \left(N + 1\right) - \tan^{-1} N}}} \]
    7. lift--.f64N/A

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\tan^{-1} \left(N + 1\right) - \tan^{-1} N}}} \]
    8. lower-/.f648.5

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\tan^{-1} \left(N + 1\right) - \tan^{-1} N}}} \]
    9. lift--.f64N/A

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\tan^{-1} \left(N + 1\right) - \tan^{-1} N}}} \]
    10. lift-atan.f64N/A

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\tan^{-1} \left(N + 1\right)} - \tan^{-1} N}} \]
    11. lift-atan.f64N/A

      \[\leadsto \frac{1}{\frac{1}{\tan^{-1} \left(N + 1\right) - \color{blue}{\tan^{-1} N}}} \]
    12. diff-atanN/A

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\tan^{-1}_* \frac{\left(N + 1\right) - N}{1 + \left(N + 1\right) \cdot N}}}} \]
    13. lift-+.f64N/A

      \[\leadsto \frac{1}{\frac{1}{\tan^{-1}_* \frac{\color{blue}{\left(N + 1\right)} - N}{1 + \left(N + 1\right) \cdot N}}} \]
    14. +-commutativeN/A

      \[\leadsto \frac{1}{\frac{1}{\tan^{-1}_* \frac{\color{blue}{\left(1 + N\right)} - N}{1 + \left(N + 1\right) \cdot N}}} \]
    15. associate--l+N/A

      \[\leadsto \frac{1}{\frac{1}{\tan^{-1}_* \frac{\color{blue}{1 + \left(N - N\right)}}{1 + \left(N + 1\right) \cdot N}}} \]
    16. +-inversesN/A

      \[\leadsto \frac{1}{\frac{1}{\tan^{-1}_* \frac{1 + \color{blue}{0}}{1 + \left(N + 1\right) \cdot N}}} \]
    17. metadata-evalN/A

      \[\leadsto \frac{1}{\frac{1}{\tan^{-1}_* \frac{\color{blue}{1}}{1 + \left(N + 1\right) \cdot N}}} \]
    18. +-commutativeN/A

      \[\leadsto \frac{1}{\frac{1}{\tan^{-1}_* \frac{1}{\color{blue}{\left(N + 1\right) \cdot N + 1}}}} \]
  4. Applied rewrites99.6%

    \[\leadsto \color{blue}{\frac{1}{\frac{1}{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}}} \]
  5. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}}} \]
    2. inv-powN/A

      \[\leadsto \frac{1}{\color{blue}{{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}^{-1}}} \]
    3. sqr-powN/A

      \[\leadsto \frac{1}{\color{blue}{{\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}^{\left(\frac{-1}{2}\right)} \cdot {\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}^{\left(\frac{-1}{2}\right)}}} \]
    4. pow2N/A

      \[\leadsto \frac{1}{\color{blue}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}^{\left(\frac{-1}{2}\right)}\right)}^{2}}} \]
    5. lower-pow.f64N/A

      \[\leadsto \frac{1}{\color{blue}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}^{\left(\frac{-1}{2}\right)}\right)}^{2}}} \]
    6. lower-pow.f64N/A

      \[\leadsto \frac{1}{{\color{blue}{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, N + 1\right)}}^{\left(\frac{-1}{2}\right)}\right)}}^{2}} \]
    7. lift-+.f64N/A

      \[\leadsto \frac{1}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, \color{blue}{N + 1}\right)}}^{\left(\frac{-1}{2}\right)}\right)}^{2}} \]
    8. +-commutativeN/A

      \[\leadsto \frac{1}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, \color{blue}{1 + N}\right)}}^{\left(\frac{-1}{2}\right)}\right)}^{2}} \]
    9. lower-+.f64N/A

      \[\leadsto \frac{1}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, \color{blue}{1 + N}\right)}}^{\left(\frac{-1}{2}\right)}\right)}^{2}} \]
    10. metadata-eval99.5

      \[\leadsto \frac{1}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, 1 + N\right)}}^{\color{blue}{-0.5}}\right)}^{2}} \]
  6. Applied rewrites99.5%

    \[\leadsto \frac{1}{\color{blue}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, 1 + N\right)}}^{-0.5}\right)}^{2}}} \]
  7. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, 1 + N\right)}}^{\frac{-1}{2}}\right)}^{2}}} \]
    2. lift-pow.f64N/A

      \[\leadsto \frac{1}{\color{blue}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, 1 + N\right)}}^{\frac{-1}{2}}\right)}^{2}}} \]
    3. pow-flipN/A

      \[\leadsto \color{blue}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, 1 + N\right)}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)}} \]
    4. lower-pow.f64N/A

      \[\leadsto \color{blue}{{\left({\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, N, 1 + N\right)}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)}} \]
    5. lift-fma.f64N/A

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{\color{blue}{N \cdot N + \left(1 + N\right)}}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)} \]
    6. +-commutativeN/A

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{\color{blue}{\left(1 + N\right) + N \cdot N}}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)} \]
    7. lift-+.f64N/A

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{\color{blue}{\left(1 + N\right)} + N \cdot N}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)} \]
    8. associate-+r+N/A

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{\color{blue}{1 + \left(N + N \cdot N\right)}}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)} \]
    9. +-commutativeN/A

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{1 + \color{blue}{\left(N \cdot N + N\right)}}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)} \]
    10. lift-fma.f64N/A

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{1 + \color{blue}{\mathsf{fma}\left(N, N, N\right)}}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)} \]
    11. lower-+.f64N/A

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{\color{blue}{1 + \mathsf{fma}\left(N, N, N\right)}}}^{\frac{-1}{2}}\right)}^{\left(\mathsf{neg}\left(2\right)\right)} \]
    12. metadata-eval99.9

      \[\leadsto {\left({\tan^{-1}_* \frac{1}{1 + \mathsf{fma}\left(N, N, N\right)}}^{-0.5}\right)}^{\color{blue}{-2}} \]
  8. Applied rewrites99.9%

    \[\leadsto \color{blue}{{\left({\tan^{-1}_* \frac{1}{1 + \mathsf{fma}\left(N, N, N\right)}}^{-0.5}\right)}^{-2}} \]
  9. Taylor expanded in N around 0

    \[\leadsto {\color{blue}{\left(\sqrt{\frac{1}{\tan^{-1}_* \frac{1}{1 + \left(N + {N}^{2}\right)}}}\right)}}^{-2} \]
  10. Step-by-step derivation
    1. lower-sqrt.f64N/A

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{1}{\tan^{-1}_* \frac{1}{1 + \left(N + {N}^{2}\right)}}}\right)}}^{-2} \]
    2. lower-/.f64N/A

      \[\leadsto {\left(\sqrt{\color{blue}{\frac{1}{\tan^{-1}_* \frac{1}{1 + \left(N + {N}^{2}\right)}}}}\right)}^{-2} \]
    3. lower-atan2.f64N/A

      \[\leadsto {\left(\sqrt{\frac{1}{\color{blue}{\tan^{-1}_* \frac{1}{1 + \left(N + {N}^{2}\right)}}}}\right)}^{-2} \]
    4. lower-+.f64N/A

      \[\leadsto {\left(\sqrt{\frac{1}{\tan^{-1}_* \frac{1}{\color{blue}{1 + \left(N + {N}^{2}\right)}}}}\right)}^{-2} \]
    5. +-commutativeN/A

      \[\leadsto {\left(\sqrt{\frac{1}{\tan^{-1}_* \frac{1}{1 + \color{blue}{\left({N}^{2} + N\right)}}}}\right)}^{-2} \]
    6. unpow2N/A

      \[\leadsto {\left(\sqrt{\frac{1}{\tan^{-1}_* \frac{1}{1 + \left(\color{blue}{N \cdot N} + N\right)}}}\right)}^{-2} \]
    7. lower-fma.f6499.8

      \[\leadsto {\left(\sqrt{\frac{1}{\tan^{-1}_* \frac{1}{1 + \color{blue}{\mathsf{fma}\left(N, N, N\right)}}}}\right)}^{-2} \]
  11. Applied rewrites99.8%

    \[\leadsto {\color{blue}{\left(\sqrt{\frac{1}{\tan^{-1}_* \frac{1}{1 + \mathsf{fma}\left(N, N, N\right)}}}\right)}}^{-2} \]
  12. Add Preprocessing

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

\[\begin{array}{l} \\ \tan^{-1} \left(\frac{1}{1 + N \cdot \left(N + 1\right)}\right) \end{array} \]
(FPCore (N) :precision binary64 (atan (/ 1.0 (+ 1.0 (* N (+ N 1.0))))))
double code(double N) {
	return atan((1.0 / (1.0 + (N * (N + 1.0)))));
}
real(8) function code(n)
    real(8), intent (in) :: n
    code = atan((1.0d0 / (1.0d0 + (n * (n + 1.0d0)))))
end function
public static double code(double N) {
	return Math.atan((1.0 / (1.0 + (N * (N + 1.0)))));
}
def code(N):
	return math.atan((1.0 / (1.0 + (N * (N + 1.0)))))
function code(N)
	return atan(Float64(1.0 / Float64(1.0 + Float64(N * Float64(N + 1.0)))))
end
function tmp = code(N)
	tmp = atan((1.0 / (1.0 + (N * (N + 1.0)))));
end
code[N_] := N[ArcTan[N[(1.0 / N[(1.0 + N[(N * N[(N + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\tan^{-1} \left(\frac{1}{1 + N \cdot \left(N + 1\right)}\right)
\end{array}

Developer Target 2: 99.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, 1 + N, 1\right)} \end{array} \]
(FPCore (N) :precision binary64 (atan2 1.0 (fma N (+ 1.0 N) 1.0)))
double code(double N) {
	return atan2(1.0, fma(N, (1.0 + N), 1.0));
}
function code(N)
	return atan(1.0, fma(N, Float64(1.0 + N), 1.0))
end
code[N_] := N[ArcTan[1.0 / N[(N * N[(1.0 + N), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, 1 + N, 1\right)}
\end{array}

Reproduce

?
herbie shell --seed 2024226 
(FPCore (N)
  :name "2atan (example 3.5)"
  :precision binary64
  :pre (and (> N 1.0) (< N 1e+100))

  :alt
  (! :herbie-platform default (atan (/ 1 (+ 1 (* N (+ N 1))))))

  :alt
  (! :herbie-platform default (atan2 1 (fma N (+ 1 N) 1)))

  (- (atan (+ N 1.0)) (atan N)))