2atan (example 3.5)

Percentage Accurate: 8.4% → 99.7%
Time: 2.5s
Alternatives: 8
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);
}
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(8) function code(n)
use fmin_fmax_functions
    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 8 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.4% 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);
}
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(8) function code(n)
use fmin_fmax_functions
    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.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \tan^{-1}_* \frac{1}{\left(N - -1\right) + \frac{1}{{N}^{-2}}} \end{array} \]
(FPCore (N)
 :precision binary64
 (atan2 1.0 (+ (- N -1.0) (/ 1.0 (pow N -2.0)))))
double code(double N) {
	return atan2(1.0, ((N - -1.0) + (1.0 / pow(N, -2.0))));
}
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(8) function code(n)
use fmin_fmax_functions
    real(8), intent (in) :: n
    code = atan2(1.0d0, ((n - (-1.0d0)) + (1.0d0 / (n ** (-2.0d0)))))
end function
public static double code(double N) {
	return Math.atan2(1.0, ((N - -1.0) + (1.0 / Math.pow(N, -2.0))));
}
def code(N):
	return math.atan2(1.0, ((N - -1.0) + (1.0 / math.pow(N, -2.0))))
function code(N)
	return atan(1.0, Float64(Float64(N - -1.0) + Float64(1.0 / (N ^ -2.0))))
end
function tmp = code(N)
	tmp = atan2(1.0, ((N - -1.0) + (1.0 / (N ^ -2.0))));
end
code[N_] := N[ArcTan[1.0 / N[(N[(N - -1.0), $MachinePrecision] + N[(1.0 / N[Power[N, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

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

    \[\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. lift-+.f64N/A

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

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

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

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

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

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

      \[\leadsto \tan^{-1}_* \frac{\left(N + \color{blue}{1 \cdot 1}\right) - N}{1 + \left(N + 1\right) \cdot N} \]
    9. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

      \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N + \color{blue}{1 \cdot 1}, N, 1\right)} \]
    16. fp-cancel-sign-sub-invN/A

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

      \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1} \cdot 1, N, 1\right)} \]
    18. metadata-evalN/A

      \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1}, N, 1\right)} \]
    19. lower--.f6415.8

      \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(\color{blue}{N - -1}, N, 1\right)} \]
  4. Applied rewrites15.8%

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{1}{\left(N - -1\right) \cdot N + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)} \cdot -1} \]
      5. fp-cancel-sub-signN/A

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

        \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{N \cdot \left(N - -1\right)} - 1 \cdot -1} \]
      7. distribute-rgt-out--N/A

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

        \[\leadsto \tan^{-1}_* \frac{1}{\left(\color{blue}{{N}^{2}} - -1 \cdot N\right) - 1 \cdot -1} \]
      9. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 2: 99.6% accurate, 1.8× speedup?

    \[\begin{array}{l} \\ \tan^{-1}_* \frac{1}{\left(N - -1\right) + N \cdot N} \end{array} \]
    (FPCore (N) :precision binary64 (atan2 1.0 (+ (- N -1.0) (* N N))))
    double code(double N) {
    	return atan2(1.0, ((N - -1.0) + (N * N)));
    }
    
    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(8) function code(n)
    use fmin_fmax_functions
        real(8), intent (in) :: n
        code = atan2(1.0d0, ((n - (-1.0d0)) + (n * n)))
    end function
    
    public static double code(double N) {
    	return Math.atan2(1.0, ((N - -1.0) + (N * N)));
    }
    
    def code(N):
    	return math.atan2(1.0, ((N - -1.0) + (N * N)))
    
    function code(N)
    	return atan(1.0, Float64(Float64(N - -1.0) + Float64(N * N)))
    end
    
    function tmp = code(N)
    	tmp = atan2(1.0, ((N - -1.0) + (N * N)));
    end
    
    code[N_] := N[ArcTan[1.0 / N[(N[(N - -1.0), $MachinePrecision] + N[(N * N), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \tan^{-1}_* \frac{1}{\left(N - -1\right) + N \cdot N}
    \end{array}
    
    Derivation
    1. Initial program 6.9%

      \[\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. lift-+.f64N/A

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(N + \color{blue}{1 \cdot 1}\right) - N}{1 + \left(N + 1\right) \cdot N} \]
      9. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N + \color{blue}{1 \cdot 1}, N, 1\right)} \]
      16. fp-cancel-sign-sub-invN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1} \cdot 1, N, 1\right)} \]
      18. metadata-evalN/A

        \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1}, N, 1\right)} \]
      19. lower--.f6415.8

        \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(\color{blue}{N - -1}, N, 1\right)} \]
    4. Applied rewrites15.8%

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

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

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

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

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

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

          \[\leadsto \tan^{-1}_* \frac{1}{\left(N - -1\right) \cdot N + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)} \cdot -1} \]
        5. fp-cancel-sub-signN/A

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

          \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{N \cdot \left(N - -1\right)} - 1 \cdot -1} \]
        7. distribute-rgt-out--N/A

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

          \[\leadsto \tan^{-1}_* \frac{1}{\left(\color{blue}{{N}^{2}} - -1 \cdot N\right) - 1 \cdot -1} \]
        9. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

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

      Alternative 3: 99.6% accurate, 1.9× speedup?

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

        \[\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. lift-+.f64N/A

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

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

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

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

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

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

          \[\leadsto \tan^{-1}_* \frac{\left(N + \color{blue}{1 \cdot 1}\right) - N}{1 + \left(N + 1\right) \cdot N} \]
        9. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

          \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N + \color{blue}{1 \cdot 1}, N, 1\right)} \]
        16. fp-cancel-sign-sub-invN/A

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

          \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1} \cdot 1, N, 1\right)} \]
        18. metadata-evalN/A

          \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1}, N, 1\right)} \]
        19. lower--.f6415.8

          \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(\color{blue}{N - -1}, N, 1\right)} \]
      4. Applied rewrites15.8%

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

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

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

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

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

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

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

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

            \[\leadsto \tan^{-1}_* \frac{1}{1 + \left(\color{blue}{{N}^{2}} - -1 \cdot N\right)} \]
          7. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

            \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{\left(N \cdot N + 1\right) + N}} \]
          14. lift-fma.f6499.6

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

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

        Alternative 4: 96.7% accurate, 1.9× speedup?

        \[\begin{array}{l} \\ \tan^{-1}_* \frac{1}{N + N \cdot N} \end{array} \]
        (FPCore (N) :precision binary64 (atan2 1.0 (+ N (* N N))))
        double code(double N) {
        	return atan2(1.0, (N + (N * N)));
        }
        
        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(8) function code(n)
        use fmin_fmax_functions
            real(8), intent (in) :: n
            code = atan2(1.0d0, (n + (n * n)))
        end function
        
        public static double code(double N) {
        	return Math.atan2(1.0, (N + (N * N)));
        }
        
        def code(N):
        	return math.atan2(1.0, (N + (N * N)))
        
        function code(N)
        	return atan(1.0, Float64(N + Float64(N * N)))
        end
        
        function tmp = code(N)
        	tmp = atan2(1.0, (N + (N * N)));
        end
        
        code[N_] := N[ArcTan[1.0 / N[(N + N[(N * N), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \tan^{-1}_* \frac{1}{N + N \cdot N}
        \end{array}
        
        Derivation
        1. Initial program 6.9%

          \[\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. lift-+.f64N/A

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

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

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

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

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

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

            \[\leadsto \tan^{-1}_* \frac{\left(N + \color{blue}{1 \cdot 1}\right) - N}{1 + \left(N + 1\right) \cdot N} \]
          9. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

            \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N + \color{blue}{1 \cdot 1}, N, 1\right)} \]
          16. fp-cancel-sign-sub-invN/A

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

            \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1} \cdot 1, N, 1\right)} \]
          18. metadata-evalN/A

            \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1}, N, 1\right)} \]
          19. lower--.f6415.8

            \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(\color{blue}{N - -1}, N, 1\right)} \]
        4. Applied rewrites15.8%

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

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

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

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

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

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

              \[\leadsto \tan^{-1}_* \frac{1}{\left(N - -1\right) \cdot N + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)} \cdot -1} \]
            5. fp-cancel-sub-signN/A

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

              \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{N \cdot \left(N - -1\right)} - 1 \cdot -1} \]
            7. distribute-rgt-out--N/A

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

              \[\leadsto \tan^{-1}_* \frac{1}{\left(\color{blue}{{N}^{2}} - -1 \cdot N\right) - 1 \cdot -1} \]
            9. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{\left(N - -1\right) + N \cdot N}} \]
          4. Taylor expanded in N around inf

            \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{N} + N \cdot N} \]
          5. Applied rewrites97.8%

            \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{N} + N \cdot N} \]
          6. Add Preprocessing

          Alternative 5: 96.7% accurate, 1.9× speedup?

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

            \[\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. lift-+.f64N/A

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

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

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

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

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

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

              \[\leadsto \tan^{-1}_* \frac{\left(N + \color{blue}{1 \cdot 1}\right) - N}{1 + \left(N + 1\right) \cdot N} \]
            9. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

              \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N + \color{blue}{1 \cdot 1}, N, 1\right)} \]
            16. fp-cancel-sign-sub-invN/A

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

              \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1} \cdot 1, N, 1\right)} \]
            18. metadata-evalN/A

              \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1}, N, 1\right)} \]
            19. lower--.f6415.8

              \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(\color{blue}{N - -1}, N, 1\right)} \]
          4. Applied rewrites15.8%

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

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

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

              \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{{N}^{2} \cdot \left(1 + \frac{1}{N}\right)}} \]
            3. Step-by-step derivation
              1. distribute-rgt-inN/A

                \[\leadsto \tan^{-1}_* \frac{1}{1 \cdot {N}^{2} + \color{blue}{\frac{1}{N} \cdot {N}^{2}}} \]
              2. inv-powN/A

                \[\leadsto \tan^{-1}_* \frac{1}{1 \cdot {N}^{2} + {N}^{-1} \cdot {\color{blue}{N}}^{2}} \]
              3. pow-prod-upN/A

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

                \[\leadsto \tan^{-1}_* \frac{1}{1 \cdot {N}^{2} + {N}^{1}} \]
              5. unpow1N/A

                \[\leadsto \tan^{-1}_* \frac{1}{1 \cdot {N}^{2} + N} \]
              6. *-lft-identityN/A

                \[\leadsto \tan^{-1}_* \frac{1}{{N}^{2} + N} \]
              7. pow2N/A

                \[\leadsto \tan^{-1}_* \frac{1}{N \cdot N + N} \]
              8. lower-fma.f6497.8

                \[\leadsto \tan^{-1}_* \frac{1}{\mathsf{fma}\left(N, \color{blue}{N}, N\right)} \]
            4. Applied rewrites97.8%

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

            Alternative 6: 93.6% accurate, 1.9× speedup?

            \[\begin{array}{l} \\ \tan^{-1}_* \frac{1}{N \cdot N} \end{array} \]
            (FPCore (N) :precision binary64 (atan2 1.0 (* N N)))
            double code(double N) {
            	return atan2(1.0, (N * N));
            }
            
            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(8) function code(n)
            use fmin_fmax_functions
                real(8), intent (in) :: n
                code = atan2(1.0d0, (n * n))
            end function
            
            public static double code(double N) {
            	return Math.atan2(1.0, (N * N));
            }
            
            def code(N):
            	return math.atan2(1.0, (N * N))
            
            function code(N)
            	return atan(1.0, Float64(N * N))
            end
            
            function tmp = code(N)
            	tmp = atan2(1.0, (N * N));
            end
            
            code[N_] := N[ArcTan[1.0 / N[(N * N), $MachinePrecision]], $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \tan^{-1}_* \frac{1}{N \cdot N}
            \end{array}
            
            Derivation
            1. Initial program 6.9%

              \[\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. lift-+.f64N/A

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

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

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

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

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

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

                \[\leadsto \tan^{-1}_* \frac{\left(N + \color{blue}{1 \cdot 1}\right) - N}{1 + \left(N + 1\right) \cdot N} \]
              9. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

                \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N + \color{blue}{1 \cdot 1}, N, 1\right)} \]
              16. fp-cancel-sign-sub-invN/A

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

                \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1} \cdot 1, N, 1\right)} \]
              18. metadata-evalN/A

                \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1}, N, 1\right)} \]
              19. lower--.f6415.8

                \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(\color{blue}{N - -1}, N, 1\right)} \]
            4. Applied rewrites15.8%

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

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

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

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

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

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

                  \[\leadsto \tan^{-1}_* \frac{1}{\left(N - -1\right) \cdot N + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)} \cdot -1} \]
                5. fp-cancel-sub-signN/A

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

                  \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{N \cdot \left(N - -1\right)} - 1 \cdot -1} \]
                7. distribute-rgt-out--N/A

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

                  \[\leadsto \tan^{-1}_* \frac{1}{\left(\color{blue}{{N}^{2}} - -1 \cdot N\right) - 1 \cdot -1} \]
                9. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{\left(N - -1\right) + N \cdot N}} \]
              4. Taylor expanded in N around inf

                \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{{N}^{2}}} \]
              5. Step-by-step derivation
                1. pow2N/A

                  \[\leadsto \tan^{-1}_* \frac{1}{{N}^{2}} \]
                2. +-commutativeN/A

                  \[\leadsto \tan^{-1}_* \frac{1}{{\color{blue}{N}}^{2}} \]
                3. metadata-evalN/A

                  \[\leadsto \tan^{-1}_* \frac{1}{{N}^{2}} \]
                4. fp-cancel-sub-signN/A

                  \[\leadsto \tan^{-1}_* \frac{1}{{N}^{2}} \]
                5. metadata-evalN/A

                  \[\leadsto \tan^{-1}_* \frac{1}{{N}^{2}} \]
                6. metadata-evalN/A

                  \[\leadsto \tan^{-1}_* \frac{1}{{N}^{2}} \]
                7. +-commutativeN/A

                  \[\leadsto \tan^{-1}_* \frac{1}{{N}^{2}} \]
                8. associate-+l+N/A

                  \[\leadsto \tan^{-1}_* \frac{1}{{\color{blue}{N}}^{2}} \]
                9. pow2N/A

                  \[\leadsto \tan^{-1}_* \frac{1}{{N}^{2}} \]
                10. pow2N/A

                  \[\leadsto \tan^{-1}_* \frac{1}{N \cdot \color{blue}{N}} \]
                11. lift-*.f6495.3

                  \[\leadsto \tan^{-1}_* \frac{1}{N \cdot \color{blue}{N}} \]
              6. Applied rewrites95.3%

                \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{N \cdot N}} \]
              7. Add Preprocessing

              Alternative 7: 7.9% accurate, 2.0× speedup?

              \[\begin{array}{l} \\ \tan^{-1}_* \frac{1}{N - -1} \end{array} \]
              (FPCore (N) :precision binary64 (atan2 1.0 (- N -1.0)))
              double code(double N) {
              	return atan2(1.0, (N - -1.0));
              }
              
              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(8) function code(n)
              use fmin_fmax_functions
                  real(8), intent (in) :: n
                  code = atan2(1.0d0, (n - (-1.0d0)))
              end function
              
              public static double code(double N) {
              	return Math.atan2(1.0, (N - -1.0));
              }
              
              def code(N):
              	return math.atan2(1.0, (N - -1.0))
              
              function code(N)
              	return atan(1.0, Float64(N - -1.0))
              end
              
              function tmp = code(N)
              	tmp = atan2(1.0, (N - -1.0));
              end
              
              code[N_] := N[ArcTan[1.0 / N[(N - -1.0), $MachinePrecision]], $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              \tan^{-1}_* \frac{1}{N - -1}
              \end{array}
              
              Derivation
              1. Initial program 6.9%

                \[\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. lift-+.f64N/A

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

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

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

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

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

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

                  \[\leadsto \tan^{-1}_* \frac{\left(N + \color{blue}{1 \cdot 1}\right) - N}{1 + \left(N + 1\right) \cdot N} \]
                9. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

                  \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N + \color{blue}{1 \cdot 1}, N, 1\right)} \]
                16. fp-cancel-sign-sub-invN/A

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

                  \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1} \cdot 1, N, 1\right)} \]
                18. metadata-evalN/A

                  \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1}, N, 1\right)} \]
                19. lower--.f6415.8

                  \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(\color{blue}{N - -1}, N, 1\right)} \]
              4. Applied rewrites15.8%

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

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

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

                  \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{1 + N}} \]
                3. Step-by-step derivation
                  1. +-commutativeN/A

                    \[\leadsto \tan^{-1}_* \frac{1}{N + \color{blue}{1}} \]
                  2. metadata-evalN/A

                    \[\leadsto \tan^{-1}_* \frac{1}{N + 1 \cdot \color{blue}{1}} \]
                  3. metadata-evalN/A

                    \[\leadsto \tan^{-1}_* \frac{1}{N + \left(\mathsf{neg}\left(-1\right)\right) \cdot 1} \]
                  4. fp-cancel-sub-signN/A

                    \[\leadsto \tan^{-1}_* \frac{1}{N - \color{blue}{-1 \cdot 1}} \]
                  5. metadata-evalN/A

                    \[\leadsto \tan^{-1}_* \frac{1}{N - -1} \]
                  6. lift--.f647.7

                    \[\leadsto \tan^{-1}_* \frac{1}{N - \color{blue}{-1}} \]
                4. Applied rewrites7.7%

                  \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{N - -1}} \]
                5. Add Preprocessing

                Alternative 8: 7.9% accurate, 2.0× speedup?

                \[\begin{array}{l} \\ \tan^{-1}_* \frac{1}{N} \end{array} \]
                (FPCore (N) :precision binary64 (atan2 1.0 N))
                double code(double N) {
                	return atan2(1.0, N);
                }
                
                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(8) function code(n)
                use fmin_fmax_functions
                    real(8), intent (in) :: n
                    code = atan2(1.0d0, n)
                end function
                
                public static double code(double N) {
                	return Math.atan2(1.0, N);
                }
                
                def code(N):
                	return math.atan2(1.0, N)
                
                function code(N)
                	return atan(1.0, N)
                end
                
                function tmp = code(N)
                	tmp = atan2(1.0, N);
                end
                
                code[N_] := N[ArcTan[1.0 / N], $MachinePrecision]
                
                \begin{array}{l}
                
                \\
                \tan^{-1}_* \frac{1}{N}
                \end{array}
                
                Derivation
                1. Initial program 6.9%

                  \[\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. lift-+.f64N/A

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

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

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

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

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

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

                    \[\leadsto \tan^{-1}_* \frac{\left(N + \color{blue}{1 \cdot 1}\right) - N}{1 + \left(N + 1\right) \cdot N} \]
                  9. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

                    \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N + \color{blue}{1 \cdot 1}, N, 1\right)} \]
                  16. fp-cancel-sign-sub-invN/A

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

                    \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1} \cdot 1, N, 1\right)} \]
                  18. metadata-evalN/A

                    \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(N - \color{blue}{-1}, N, 1\right)} \]
                  19. lower--.f6415.8

                    \[\leadsto \tan^{-1}_* \frac{\left(N - -1\right) - N}{\mathsf{fma}\left(\color{blue}{N - -1}, N, 1\right)} \]
                4. Applied rewrites15.8%

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

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

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

                    \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{1 + N}} \]
                  3. Step-by-step derivation
                    1. +-commutativeN/A

                      \[\leadsto \tan^{-1}_* \frac{1}{N + \color{blue}{1}} \]
                    2. metadata-evalN/A

                      \[\leadsto \tan^{-1}_* \frac{1}{N + 1 \cdot \color{blue}{1}} \]
                    3. metadata-evalN/A

                      \[\leadsto \tan^{-1}_* \frac{1}{N + \left(\mathsf{neg}\left(-1\right)\right) \cdot 1} \]
                    4. fp-cancel-sub-signN/A

                      \[\leadsto \tan^{-1}_* \frac{1}{N - \color{blue}{-1 \cdot 1}} \]
                    5. metadata-evalN/A

                      \[\leadsto \tan^{-1}_* \frac{1}{N - -1} \]
                    6. lift--.f647.7

                      \[\leadsto \tan^{-1}_* \frac{1}{N - \color{blue}{-1}} \]
                  4. Applied rewrites7.7%

                    \[\leadsto \tan^{-1}_* \frac{1}{\color{blue}{N - -1}} \]
                  5. Taylor expanded in N around inf

                    \[\leadsto \tan^{-1}_* \frac{1}{N} \]
                  6. Applied rewrites7.7%

                    \[\leadsto \tan^{-1}_* \frac{1}{N} \]
                  7. Add Preprocessing

                  Developer Target 1: 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 2025080 
                  (FPCore (N)
                    :name "2atan (example 3.5)"
                    :precision binary64
                    :pre (and (> N 1.0) (< N 1e+100))
                  
                    :alt
                    (! :herbie-platform default (atan2 1 (fma N (+ 1 N) 1)))
                  
                    (- (atan (+ N 1.0)) (atan N)))