Migdal et al, Equation (51)

Percentage Accurate: 99.4% → 99.5%
Time: 9.0s
Alternatives: 12
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ \frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \end{array} \]
(FPCore (k n)
 :precision binary64
 (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0))))
\begin{array}{l}

\\
\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
\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 12 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \end{array} \]
(FPCore (k n)
 :precision binary64
 (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0))))
\begin{array}{l}

\\
\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}

Alternative 1: 99.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\\ \sqrt{\frac{1}{k}} \cdot \left(\sqrt{t\_0} \cdot {t\_0}^{\left(-0.5 \cdot k\right)}\right) \end{array} \end{array} \]
(FPCore (k n)
 :precision binary64
 (let* ((t_0 (* (* (PI) n) 2.0)))
   (* (sqrt (/ 1.0 k)) (* (sqrt t_0) (pow t_0 (* -0.5 k))))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\\
\sqrt{\frac{1}{k}} \cdot \left(\sqrt{t\_0} \cdot {t\_0}^{\left(-0.5 \cdot k\right)}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in k around inf

    \[\leadsto \color{blue}{\sqrt{\frac{1}{k}} \cdot e^{\frac{1}{2} \cdot \left(\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \left(1 - k\right)\right)}} \]
  4. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \color{blue}{e^{\frac{1}{2} \cdot \left(\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \left(1 - k\right)\right)} \cdot \sqrt{\frac{1}{k}}} \]
    2. lower-*.f64N/A

      \[\leadsto \color{blue}{e^{\frac{1}{2} \cdot \left(\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \left(1 - k\right)\right)} \cdot \sqrt{\frac{1}{k}}} \]
    3. associate-*r*N/A

      \[\leadsto e^{\color{blue}{\left(\frac{1}{2} \cdot \log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \left(1 - k\right)}} \cdot \sqrt{\frac{1}{k}} \]
    4. exp-prodN/A

      \[\leadsto \color{blue}{{\left(e^{\frac{1}{2} \cdot \log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{\left(1 - k\right)}} \cdot \sqrt{\frac{1}{k}} \]
    5. lower-pow.f64N/A

      \[\leadsto \color{blue}{{\left(e^{\frac{1}{2} \cdot \log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{\left(1 - k\right)}} \cdot \sqrt{\frac{1}{k}} \]
    6. *-commutativeN/A

      \[\leadsto {\left(e^{\color{blue}{\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{2}}}\right)}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
    7. exp-to-powN/A

      \[\leadsto {\color{blue}{\left({\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}\right)}}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
    8. unpow1/2N/A

      \[\leadsto {\color{blue}{\left(\sqrt{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}\right)}}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
    9. lower-sqrt.f64N/A

      \[\leadsto {\color{blue}{\left(\sqrt{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}\right)}}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
    10. lower-*.f64N/A

      \[\leadsto {\left(\sqrt{\color{blue}{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}}\right)}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
    11. *-commutativeN/A

      \[\leadsto {\left(\sqrt{2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot n\right)}}\right)}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
    12. lower-*.f64N/A

      \[\leadsto {\left(\sqrt{2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot n\right)}}\right)}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
    13. lower-PI.f64N/A

      \[\leadsto {\left(\sqrt{2 \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot n\right)}\right)}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
    14. lower--.f64N/A

      \[\leadsto {\left(\sqrt{2 \cdot \left(\mathsf{PI}\left(\right) \cdot n\right)}\right)}^{\color{blue}{\left(1 - k\right)}} \cdot \sqrt{\frac{1}{k}} \]
    15. lower-sqrt.f64N/A

      \[\leadsto {\left(\sqrt{2 \cdot \left(\mathsf{PI}\left(\right) \cdot n\right)}\right)}^{\left(1 - k\right)} \cdot \color{blue}{\sqrt{\frac{1}{k}}} \]
    16. lower-/.f6499.6

      \[\leadsto {\left(\sqrt{2 \cdot \left(\mathsf{PI}\left(\right) \cdot n\right)}\right)}^{\left(1 - k\right)} \cdot \sqrt{\color{blue}{\frac{1}{k}}} \]
  5. Applied rewrites99.6%

    \[\leadsto \color{blue}{{\left(\sqrt{2 \cdot \left(\mathsf{PI}\left(\right) \cdot n\right)}\right)}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}}} \]
  6. Step-by-step derivation
    1. Applied rewrites99.7%

      \[\leadsto \left({\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\left(-0.5 \cdot k\right)} \cdot \sqrt{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \sqrt{\color{blue}{\frac{1}{k}}} \]
    2. Final simplification99.7%

      \[\leadsto \sqrt{\frac{1}{k}} \cdot \left(\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2} \cdot {\left(\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\right)}^{\left(-0.5 \cdot k\right)}\right) \]
    3. Add Preprocessing

    Alternative 2: 85.0% accurate, 0.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}}\\ \mathbf{if}\;t\_0 \leq 4 \cdot 10^{-100}:\\ \;\;\;\;\left(\sqrt{\frac{k}{\frac{k}{\mathsf{PI}\left(\right)} \cdot k}} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\ \mathbf{elif}\;t\_0 \leq 10^{+274}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(0 \cdot n\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}}\\ \end{array} \end{array} \]
    (FPCore (k n)
     :precision binary64
     (let* ((t_0 (* (pow (* (* (PI) 2.0) n) (/ (- 1.0 k) 2.0)) (/ 1.0 (sqrt k)))))
       (if (<= t_0 4e-100)
         (* (* (sqrt (/ k (* (/ k (PI)) k))) (sqrt n)) (sqrt 2.0))
         (if (<= t_0 1e+274)
           (/ (sqrt (* (* (PI) n) 2.0)) (sqrt k))
           (/ (pow (* 0.0 n) (fma k -0.5 0.5)) (sqrt k))))))
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := {\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}}\\
    \mathbf{if}\;t\_0 \leq 4 \cdot 10^{-100}:\\
    \;\;\;\;\left(\sqrt{\frac{k}{\frac{k}{\mathsf{PI}\left(\right)} \cdot k}} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\
    
    \mathbf{elif}\;t\_0 \leq 10^{+274}:\\
    \;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{{\left(0 \cdot n\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64)))) < 4.0000000000000001e-100

      1. Initial program 99.8%

        \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
      2. Add Preprocessing
      3. Taylor expanded in k around 0

        \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
        2. lower-*.f64N/A

          \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
        3. lower-sqrt.f64N/A

          \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
        4. lower-sqrt.f64N/A

          \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
        5. lower-/.f64N/A

          \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
        6. *-commutativeN/A

          \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
        7. lower-*.f64N/A

          \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
        8. lower-PI.f647.1

          \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
      5. Applied rewrites7.1%

        \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
      6. Step-by-step derivation
        1. Applied rewrites7.1%

          \[\leadsto \sqrt{2} \cdot \left(\sqrt{n} \cdot \color{blue}{\sqrt{\frac{\mathsf{PI}\left(\right)}{k}}}\right) \]
        2. Step-by-step derivation
          1. Applied rewrites48.9%

            \[\leadsto \sqrt{2} \cdot \left(\sqrt{n} \cdot \sqrt{\frac{\mathsf{fma}\left(0, \frac{k}{\mathsf{PI}\left(\right)}, k\right)}{k \cdot \frac{k}{\mathsf{PI}\left(\right)}}}\right) \]
          2. Step-by-step derivation
            1. Applied rewrites48.9%

              \[\leadsto \sqrt{2} \cdot \left(\sqrt{n} \cdot \sqrt{\frac{k}{\frac{k}{\mathsf{PI}\left(\right)} \cdot k}}\right) \]

            if 4.0000000000000001e-100 < (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64)))) < 9.99999999999999921e273

            1. Initial program 99.2%

              \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
            2. Add Preprocessing
            3. Taylor expanded in k around 0

              \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
              2. lower-*.f64N/A

                \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
              3. lower-sqrt.f64N/A

                \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
              4. lower-sqrt.f64N/A

                \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
              5. lower-/.f64N/A

                \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
              6. *-commutativeN/A

                \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
              7. lower-*.f64N/A

                \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
              8. lower-PI.f6478.0

                \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
            5. Applied rewrites78.0%

              \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
            6. Step-by-step derivation
              1. Applied rewrites97.6%

                \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}}{\color{blue}{\sqrt{k}}} \]

              if 9.99999999999999921e273 < (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64))))

              1. Initial program 100.0%

                \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
              2. Add Preprocessing
              3. Step-by-step derivation
                1. lift-*.f64N/A

                  \[\leadsto \color{blue}{\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}} \]
                2. *-commutativeN/A

                  \[\leadsto \color{blue}{{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}}} \]
                3. lift-/.f64N/A

                  \[\leadsto {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \color{blue}{\frac{1}{\sqrt{k}}} \]
                4. un-div-invN/A

                  \[\leadsto \color{blue}{\frac{{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}} \]
                5. lower-/.f64100.0

                  \[\leadsto \color{blue}{\frac{{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}} \]
              4. Applied rewrites100.0%

                \[\leadsto \color{blue}{\frac{{\left(0 \cdot n\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}}} \]
            7. Recombined 3 regimes into one program.
            8. Final simplification86.8%

              \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \leq 4 \cdot 10^{-100}:\\ \;\;\;\;\left(\sqrt{\frac{k}{\frac{k}{\mathsf{PI}\left(\right)} \cdot k}} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\ \mathbf{elif}\;{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \leq 10^{+274}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(0 \cdot n\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}}\\ \end{array} \]
            9. Add Preprocessing

            Alternative 3: 62.2% accurate, 0.7× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \leq 4 \cdot 10^{-100}:\\ \;\;\;\;\left(\sqrt{\frac{k}{\frac{k}{\mathsf{PI}\left(\right)} \cdot k}} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}\\ \end{array} \end{array} \]
            (FPCore (k n)
             :precision binary64
             (if (<=
                  (* (pow (* (* (PI) 2.0) n) (/ (- 1.0 k) 2.0)) (/ 1.0 (sqrt k)))
                  4e-100)
               (* (* (sqrt (/ k (* (/ k (PI)) k))) (sqrt n)) (sqrt 2.0))
               (/ (sqrt (* (* (PI) n) 2.0)) (sqrt k))))
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \leq 4 \cdot 10^{-100}:\\
            \;\;\;\;\left(\sqrt{\frac{k}{\frac{k}{\mathsf{PI}\left(\right)} \cdot k}} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64)))) < 4.0000000000000001e-100

              1. Initial program 99.8%

                \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
              2. Add Preprocessing
              3. Taylor expanded in k around 0

                \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
              4. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                2. lower-*.f64N/A

                  \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                3. lower-sqrt.f64N/A

                  \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
                4. lower-sqrt.f64N/A

                  \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                5. lower-/.f64N/A

                  \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                6. *-commutativeN/A

                  \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                7. lower-*.f64N/A

                  \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                8. lower-PI.f647.1

                  \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
              5. Applied rewrites7.1%

                \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
              6. Step-by-step derivation
                1. Applied rewrites7.1%

                  \[\leadsto \sqrt{2} \cdot \left(\sqrt{n} \cdot \color{blue}{\sqrt{\frac{\mathsf{PI}\left(\right)}{k}}}\right) \]
                2. Step-by-step derivation
                  1. Applied rewrites48.9%

                    \[\leadsto \sqrt{2} \cdot \left(\sqrt{n} \cdot \sqrt{\frac{\mathsf{fma}\left(0, \frac{k}{\mathsf{PI}\left(\right)}, k\right)}{k \cdot \frac{k}{\mathsf{PI}\left(\right)}}}\right) \]
                  2. Step-by-step derivation
                    1. Applied rewrites48.9%

                      \[\leadsto \sqrt{2} \cdot \left(\sqrt{n} \cdot \sqrt{\frac{k}{\frac{k}{\mathsf{PI}\left(\right)} \cdot k}}\right) \]

                    if 4.0000000000000001e-100 < (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64))))

                    1. Initial program 99.4%

                      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
                    2. Add Preprocessing
                    3. Taylor expanded in k around 0

                      \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
                    4. Step-by-step derivation
                      1. *-commutativeN/A

                        \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                      2. lower-*.f64N/A

                        \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                      3. lower-sqrt.f64N/A

                        \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
                      4. lower-sqrt.f64N/A

                        \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                      5. lower-/.f64N/A

                        \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                      6. *-commutativeN/A

                        \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                      7. lower-*.f64N/A

                        \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                      8. lower-PI.f6454.0

                        \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
                    5. Applied rewrites54.0%

                      \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
                    6. Step-by-step derivation
                      1. Applied rewrites67.5%

                        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}}{\color{blue}{\sqrt{k}}} \]
                    7. Recombined 2 regimes into one program.
                    8. Final simplification63.1%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \leq 4 \cdot 10^{-100}:\\ \;\;\;\;\left(\sqrt{\frac{k}{\frac{k}{\mathsf{PI}\left(\right)} \cdot k}} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}\\ \end{array} \]
                    9. Add Preprocessing

                    Alternative 4: 62.2% accurate, 0.7× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \leq 4 \cdot 10^{-100}:\\ \;\;\;\;\left(\sqrt{\frac{k}{k \cdot k} \cdot \mathsf{PI}\left(\right)} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}\\ \end{array} \end{array} \]
                    (FPCore (k n)
                     :precision binary64
                     (if (<=
                          (* (pow (* (* (PI) 2.0) n) (/ (- 1.0 k) 2.0)) (/ 1.0 (sqrt k)))
                          4e-100)
                       (* (* (sqrt (* (/ k (* k k)) (PI))) (sqrt n)) (sqrt 2.0))
                       (/ (sqrt (* (* (PI) n) 2.0)) (sqrt k))))
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \leq 4 \cdot 10^{-100}:\\
                    \;\;\;\;\left(\sqrt{\frac{k}{k \cdot k} \cdot \mathsf{PI}\left(\right)} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64)))) < 4.0000000000000001e-100

                      1. Initial program 99.8%

                        \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
                      2. Add Preprocessing
                      3. Taylor expanded in k around 0

                        \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
                      4. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                        2. lower-*.f64N/A

                          \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                        3. lower-sqrt.f64N/A

                          \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
                        4. lower-sqrt.f64N/A

                          \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                        5. lower-/.f64N/A

                          \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                        6. *-commutativeN/A

                          \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                        7. lower-*.f64N/A

                          \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                        8. lower-PI.f647.1

                          \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
                      5. Applied rewrites7.1%

                        \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
                      6. Step-by-step derivation
                        1. Applied rewrites7.1%

                          \[\leadsto \sqrt{2} \cdot \left(\sqrt{n} \cdot \color{blue}{\sqrt{\frac{\mathsf{PI}\left(\right)}{k}}}\right) \]
                        2. Step-by-step derivation
                          1. Applied rewrites48.9%

                            \[\leadsto \sqrt{2} \cdot \left(\sqrt{n} \cdot \sqrt{\frac{\mathsf{fma}\left(0, \frac{k}{\mathsf{PI}\left(\right)}, k\right)}{k \cdot \frac{k}{\mathsf{PI}\left(\right)}}}\right) \]
                          2. Step-by-step derivation
                            1. Applied rewrites48.9%

                              \[\leadsto \sqrt{2} \cdot \left(\sqrt{n} \cdot \sqrt{\frac{k}{k \cdot k} \cdot \mathsf{PI}\left(\right)}\right) \]

                            if 4.0000000000000001e-100 < (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64))))

                            1. Initial program 99.4%

                              \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
                            2. Add Preprocessing
                            3. Taylor expanded in k around 0

                              \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
                            4. Step-by-step derivation
                              1. *-commutativeN/A

                                \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                              2. lower-*.f64N/A

                                \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                              3. lower-sqrt.f64N/A

                                \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
                              4. lower-sqrt.f64N/A

                                \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                              5. lower-/.f64N/A

                                \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                              6. *-commutativeN/A

                                \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                              7. lower-*.f64N/A

                                \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                              8. lower-PI.f6454.0

                                \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
                            5. Applied rewrites54.0%

                              \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
                            6. Step-by-step derivation
                              1. Applied rewrites67.5%

                                \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}}{\color{blue}{\sqrt{k}}} \]
                            7. Recombined 2 regimes into one program.
                            8. Final simplification63.1%

                              \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \leq 4 \cdot 10^{-100}:\\ \;\;\;\;\left(\sqrt{\frac{k}{k \cdot k} \cdot \mathsf{PI}\left(\right)} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}\\ \end{array} \]
                            9. Add Preprocessing

                            Alternative 5: 52.8% accurate, 0.7× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{PI}\left(\right) \cdot n\\ \mathbf{if}\;{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \leq 0:\\ \;\;\;\;\sqrt{\frac{\mathsf{fma}\left(t\_0, k, t\_0 \cdot k\right)}{k \cdot k}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{t\_0 \cdot 2}}{\sqrt{k}}\\ \end{array} \end{array} \]
                            (FPCore (k n)
                             :precision binary64
                             (let* ((t_0 (* (PI) n)))
                               (if (<= (* (pow (* (* (PI) 2.0) n) (/ (- 1.0 k) 2.0)) (/ 1.0 (sqrt k))) 0.0)
                                 (sqrt (/ (fma t_0 k (* t_0 k)) (* k k)))
                                 (/ (sqrt (* t_0 2.0)) (sqrt k)))))
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            t_0 := \mathsf{PI}\left(\right) \cdot n\\
                            \mathbf{if}\;{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \leq 0:\\
                            \;\;\;\;\sqrt{\frac{\mathsf{fma}\left(t\_0, k, t\_0 \cdot k\right)}{k \cdot k}}\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\frac{\sqrt{t\_0 \cdot 2}}{\sqrt{k}}\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64)))) < 0.0

                              1. Initial program 100.0%

                                \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
                              2. Add Preprocessing
                              3. Taylor expanded in k around 0

                                \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
                              4. Step-by-step derivation
                                1. *-commutativeN/A

                                  \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                2. lower-*.f64N/A

                                  \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                3. lower-sqrt.f64N/A

                                  \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
                                4. lower-sqrt.f64N/A

                                  \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                5. lower-/.f64N/A

                                  \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                6. *-commutativeN/A

                                  \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                7. lower-*.f64N/A

                                  \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                8. lower-PI.f643.2

                                  \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
                              5. Applied rewrites3.2%

                                \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
                              6. Step-by-step derivation
                                1. Applied rewrites3.2%

                                  \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2}} \]
                                2. Step-by-step derivation
                                  1. Applied rewrites3.2%

                                    \[\leadsto \sqrt{\left(\mathsf{PI}\left(\right) \cdot \frac{n}{k}\right) \cdot 2} \]
                                  2. Step-by-step derivation
                                    1. Applied rewrites10.2%

                                      \[\leadsto \sqrt{\frac{\mathsf{fma}\left(n \cdot \mathsf{PI}\left(\right), k, k \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}{k \cdot k}} \]

                                    if 0.0 < (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64))))

                                    1. Initial program 99.4%

                                      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in k around 0

                                      \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
                                    4. Step-by-step derivation
                                      1. *-commutativeN/A

                                        \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                      2. lower-*.f64N/A

                                        \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                      3. lower-sqrt.f64N/A

                                        \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
                                      4. lower-sqrt.f64N/A

                                        \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                      5. lower-/.f64N/A

                                        \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                      6. *-commutativeN/A

                                        \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                      7. lower-*.f64N/A

                                        \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                      8. lower-PI.f6454.4

                                        \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
                                    5. Applied rewrites54.4%

                                      \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
                                    6. Step-by-step derivation
                                      1. Applied rewrites67.7%

                                        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}}{\color{blue}{\sqrt{k}}} \]
                                    7. Recombined 2 regimes into one program.
                                    8. Final simplification54.9%

                                      \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \leq 0:\\ \;\;\;\;\sqrt{\frac{\mathsf{fma}\left(\mathsf{PI}\left(\right) \cdot n, k, \left(\mathsf{PI}\left(\right) \cdot n\right) \cdot k\right)}{k \cdot k}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}\\ \end{array} \]
                                    9. Add Preprocessing

                                    Alternative 6: 99.4% accurate, 1.1× speedup?

                                    \[\begin{array}{l} \\ \frac{{\left(\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}} \end{array} \]
                                    (FPCore (k n)
                                     :precision binary64
                                     (/ (pow (* (* (PI) n) 2.0) (fma k -0.5 0.5)) (sqrt k)))
                                    \begin{array}{l}
                                    
                                    \\
                                    \frac{{\left(\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}}
                                    \end{array}
                                    
                                    Derivation
                                    1. Initial program 99.5%

                                      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in k around inf

                                      \[\leadsto \color{blue}{\sqrt{\frac{1}{k}} \cdot e^{\frac{1}{2} \cdot \left(\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \left(1 - k\right)\right)}} \]
                                    4. Step-by-step derivation
                                      1. *-commutativeN/A

                                        \[\leadsto \color{blue}{e^{\frac{1}{2} \cdot \left(\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \left(1 - k\right)\right)} \cdot \sqrt{\frac{1}{k}}} \]
                                      2. lower-*.f64N/A

                                        \[\leadsto \color{blue}{e^{\frac{1}{2} \cdot \left(\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \left(1 - k\right)\right)} \cdot \sqrt{\frac{1}{k}}} \]
                                      3. associate-*r*N/A

                                        \[\leadsto e^{\color{blue}{\left(\frac{1}{2} \cdot \log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \left(1 - k\right)}} \cdot \sqrt{\frac{1}{k}} \]
                                      4. exp-prodN/A

                                        \[\leadsto \color{blue}{{\left(e^{\frac{1}{2} \cdot \log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{\left(1 - k\right)}} \cdot \sqrt{\frac{1}{k}} \]
                                      5. lower-pow.f64N/A

                                        \[\leadsto \color{blue}{{\left(e^{\frac{1}{2} \cdot \log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{\left(1 - k\right)}} \cdot \sqrt{\frac{1}{k}} \]
                                      6. *-commutativeN/A

                                        \[\leadsto {\left(e^{\color{blue}{\log \left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \frac{1}{2}}}\right)}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
                                      7. exp-to-powN/A

                                        \[\leadsto {\color{blue}{\left({\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\frac{1}{2}}\right)}}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
                                      8. unpow1/2N/A

                                        \[\leadsto {\color{blue}{\left(\sqrt{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}\right)}}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
                                      9. lower-sqrt.f64N/A

                                        \[\leadsto {\color{blue}{\left(\sqrt{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}\right)}}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
                                      10. lower-*.f64N/A

                                        \[\leadsto {\left(\sqrt{\color{blue}{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}}\right)}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
                                      11. *-commutativeN/A

                                        \[\leadsto {\left(\sqrt{2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot n\right)}}\right)}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
                                      12. lower-*.f64N/A

                                        \[\leadsto {\left(\sqrt{2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot n\right)}}\right)}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
                                      13. lower-PI.f64N/A

                                        \[\leadsto {\left(\sqrt{2 \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot n\right)}\right)}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}} \]
                                      14. lower--.f64N/A

                                        \[\leadsto {\left(\sqrt{2 \cdot \left(\mathsf{PI}\left(\right) \cdot n\right)}\right)}^{\color{blue}{\left(1 - k\right)}} \cdot \sqrt{\frac{1}{k}} \]
                                      15. lower-sqrt.f64N/A

                                        \[\leadsto {\left(\sqrt{2 \cdot \left(\mathsf{PI}\left(\right) \cdot n\right)}\right)}^{\left(1 - k\right)} \cdot \color{blue}{\sqrt{\frac{1}{k}}} \]
                                      16. lower-/.f6499.6

                                        \[\leadsto {\left(\sqrt{2 \cdot \left(\mathsf{PI}\left(\right) \cdot n\right)}\right)}^{\left(1 - k\right)} \cdot \sqrt{\color{blue}{\frac{1}{k}}} \]
                                    5. Applied rewrites99.6%

                                      \[\leadsto \color{blue}{{\left(\sqrt{2 \cdot \left(\mathsf{PI}\left(\right) \cdot n\right)}\right)}^{\left(1 - k\right)} \cdot \sqrt{\frac{1}{k}}} \]
                                    6. Step-by-step derivation
                                      1. Applied rewrites99.7%

                                        \[\leadsto \left({\left(2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}^{\left(-0.5 \cdot k\right)} \cdot \sqrt{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \sqrt{\color{blue}{\frac{1}{k}}} \]
                                      2. Applied rewrites99.6%

                                        \[\leadsto \frac{{\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot n\right)\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\color{blue}{\sqrt{k}}} \]
                                      3. Final simplification99.6%

                                        \[\leadsto \frac{{\left(\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}} \]
                                      4. Add Preprocessing

                                      Alternative 7: 66.0% accurate, 1.7× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;k \leq 8.5 \cdot 10^{+104}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}\\ \mathbf{elif}\;k \leq 1.32 \cdot 10^{+154}:\\ \;\;\;\;\left(\sqrt{\frac{k \cdot k}{\left(\frac{k}{\mathsf{PI}\left(\right)} \cdot k\right) \cdot k}} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{k}{k \cdot k} \cdot \mathsf{PI}\left(\right)} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\ \end{array} \end{array} \]
                                      (FPCore (k n)
                                       :precision binary64
                                       (if (<= k 8.5e+104)
                                         (/ (sqrt (* (* (PI) n) 2.0)) (sqrt k))
                                         (if (<= k 1.32e+154)
                                           (* (* (sqrt (/ (* k k) (* (* (/ k (PI)) k) k))) (sqrt n)) (sqrt 2.0))
                                           (* (* (sqrt (* (/ k (* k k)) (PI))) (sqrt n)) (sqrt 2.0)))))
                                      \begin{array}{l}
                                      
                                      \\
                                      \begin{array}{l}
                                      \mathbf{if}\;k \leq 8.5 \cdot 10^{+104}:\\
                                      \;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}\\
                                      
                                      \mathbf{elif}\;k \leq 1.32 \cdot 10^{+154}:\\
                                      \;\;\;\;\left(\sqrt{\frac{k \cdot k}{\left(\frac{k}{\mathsf{PI}\left(\right)} \cdot k\right) \cdot k}} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;\left(\sqrt{\frac{k}{k \cdot k} \cdot \mathsf{PI}\left(\right)} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 3 regimes
                                      2. if k < 8.4999999999999999e104

                                        1. Initial program 99.3%

                                          \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in k around 0

                                          \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
                                        4. Step-by-step derivation
                                          1. *-commutativeN/A

                                            \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                          2. lower-*.f64N/A

                                            \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                          3. lower-sqrt.f64N/A

                                            \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
                                          4. lower-sqrt.f64N/A

                                            \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                          5. lower-/.f64N/A

                                            \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                          6. *-commutativeN/A

                                            \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                          7. lower-*.f64N/A

                                            \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                          8. lower-PI.f6457.9

                                            \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
                                        5. Applied rewrites57.9%

                                          \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
                                        6. Step-by-step derivation
                                          1. Applied rewrites72.0%

                                            \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}}{\color{blue}{\sqrt{k}}} \]

                                          if 8.4999999999999999e104 < k < 1.31999999999999998e154

                                          1. Initial program 100.0%

                                            \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
                                          2. Add Preprocessing
                                          3. Taylor expanded in k around 0

                                            \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
                                          4. Step-by-step derivation
                                            1. *-commutativeN/A

                                              \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                            2. lower-*.f64N/A

                                              \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                            3. lower-sqrt.f64N/A

                                              \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
                                            4. lower-sqrt.f64N/A

                                              \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                            5. lower-/.f64N/A

                                              \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                            6. *-commutativeN/A

                                              \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                            7. lower-*.f64N/A

                                              \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                            8. lower-PI.f642.9

                                              \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
                                          5. Applied rewrites2.9%

                                            \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
                                          6. Step-by-step derivation
                                            1. Applied rewrites2.9%

                                              \[\leadsto \sqrt{2} \cdot \left(\sqrt{n} \cdot \color{blue}{\sqrt{\frac{\mathsf{PI}\left(\right)}{k}}}\right) \]
                                            2. Step-by-step derivation
                                              1. Applied rewrites2.9%

                                                \[\leadsto \sqrt{2} \cdot \left(\sqrt{n} \cdot \sqrt{\frac{\mathsf{fma}\left(0, \frac{k}{\mathsf{PI}\left(\right)}, k\right)}{k \cdot \frac{k}{\mathsf{PI}\left(\right)}}}\right) \]
                                              2. Step-by-step derivation
                                                1. Applied rewrites64.2%

                                                  \[\leadsto \sqrt{2} \cdot \left(\sqrt{n} \cdot \sqrt{\frac{-k \cdot k}{\left(-k\right) \cdot \left(\frac{k}{\mathsf{PI}\left(\right)} \cdot k\right)}}\right) \]

                                                if 1.31999999999999998e154 < k

                                                1. Initial program 100.0%

                                                  \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in k around 0

                                                  \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
                                                4. Step-by-step derivation
                                                  1. *-commutativeN/A

                                                    \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                  2. lower-*.f64N/A

                                                    \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                  3. lower-sqrt.f64N/A

                                                    \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
                                                  4. lower-sqrt.f64N/A

                                                    \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                  5. lower-/.f64N/A

                                                    \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                  6. *-commutativeN/A

                                                    \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                                  7. lower-*.f64N/A

                                                    \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                                  8. lower-PI.f642.6

                                                    \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
                                                5. Applied rewrites2.6%

                                                  \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
                                                6. Step-by-step derivation
                                                  1. Applied rewrites2.7%

                                                    \[\leadsto \sqrt{2} \cdot \left(\sqrt{n} \cdot \color{blue}{\sqrt{\frac{\mathsf{PI}\left(\right)}{k}}}\right) \]
                                                  2. Step-by-step derivation
                                                    1. Applied rewrites45.7%

                                                      \[\leadsto \sqrt{2} \cdot \left(\sqrt{n} \cdot \sqrt{\frac{\mathsf{fma}\left(0, \frac{k}{\mathsf{PI}\left(\right)}, k\right)}{k \cdot \frac{k}{\mathsf{PI}\left(\right)}}}\right) \]
                                                    2. Step-by-step derivation
                                                      1. Applied rewrites45.7%

                                                        \[\leadsto \sqrt{2} \cdot \left(\sqrt{n} \cdot \sqrt{\frac{k}{k \cdot k} \cdot \mathsf{PI}\left(\right)}\right) \]
                                                    3. Recombined 3 regimes into one program.
                                                    4. Final simplification65.7%

                                                      \[\leadsto \begin{array}{l} \mathbf{if}\;k \leq 8.5 \cdot 10^{+104}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}\\ \mathbf{elif}\;k \leq 1.32 \cdot 10^{+154}:\\ \;\;\;\;\left(\sqrt{\frac{k \cdot k}{\left(\frac{k}{\mathsf{PI}\left(\right)} \cdot k\right) \cdot k}} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{k}{k \cdot k} \cdot \mathsf{PI}\left(\right)} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\ \end{array} \]
                                                    5. Add Preprocessing

                                                    Alternative 8: 49.9% accurate, 3.6× speedup?

                                                    \[\begin{array}{l} \\ \frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}} \end{array} \]
                                                    (FPCore (k n) :precision binary64 (/ (sqrt (* (* (PI) n) 2.0)) (sqrt k)))
                                                    \begin{array}{l}
                                                    
                                                    \\
                                                    \frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}
                                                    \end{array}
                                                    
                                                    Derivation
                                                    1. Initial program 99.5%

                                                      \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
                                                    2. Add Preprocessing
                                                    3. Taylor expanded in k around 0

                                                      \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
                                                    4. Step-by-step derivation
                                                      1. *-commutativeN/A

                                                        \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                      2. lower-*.f64N/A

                                                        \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                      3. lower-sqrt.f64N/A

                                                        \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
                                                      4. lower-sqrt.f64N/A

                                                        \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                      5. lower-/.f64N/A

                                                        \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                      6. *-commutativeN/A

                                                        \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                                      7. lower-*.f64N/A

                                                        \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                                      8. lower-PI.f6443.0

                                                        \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
                                                    5. Applied rewrites43.0%

                                                      \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
                                                    6. Step-by-step derivation
                                                      1. Applied rewrites53.3%

                                                        \[\leadsto \frac{\sqrt{2 \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)}}{\color{blue}{\sqrt{k}}} \]
                                                      2. Final simplification53.3%

                                                        \[\leadsto \frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}} \]
                                                      3. Add Preprocessing

                                                      Alternative 9: 49.9% accurate, 3.6× speedup?

                                                      \[\begin{array}{l} \\ \sqrt{\frac{2}{k}} \cdot \sqrt{\mathsf{PI}\left(\right) \cdot n} \end{array} \]
                                                      (FPCore (k n) :precision binary64 (* (sqrt (/ 2.0 k)) (sqrt (* (PI) n))))
                                                      \begin{array}{l}
                                                      
                                                      \\
                                                      \sqrt{\frac{2}{k}} \cdot \sqrt{\mathsf{PI}\left(\right) \cdot n}
                                                      \end{array}
                                                      
                                                      Derivation
                                                      1. Initial program 99.5%

                                                        \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
                                                      2. Add Preprocessing
                                                      3. Taylor expanded in k around 0

                                                        \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
                                                      4. Step-by-step derivation
                                                        1. *-commutativeN/A

                                                          \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                        2. lower-*.f64N/A

                                                          \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                        3. lower-sqrt.f64N/A

                                                          \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
                                                        4. lower-sqrt.f64N/A

                                                          \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                        5. lower-/.f64N/A

                                                          \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                        6. *-commutativeN/A

                                                          \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                                        7. lower-*.f64N/A

                                                          \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                                        8. lower-PI.f6443.0

                                                          \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
                                                      5. Applied rewrites43.0%

                                                        \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
                                                      6. Step-by-step derivation
                                                        1. Applied rewrites43.0%

                                                          \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2}} \]
                                                        2. Step-by-step derivation
                                                          1. Applied rewrites53.3%

                                                            \[\leadsto \sqrt{\mathsf{PI}\left(\right) \cdot n} \cdot \color{blue}{\sqrt{\frac{2}{k}}} \]
                                                          2. Final simplification53.3%

                                                            \[\leadsto \sqrt{\frac{2}{k}} \cdot \sqrt{\mathsf{PI}\left(\right) \cdot n} \]
                                                          3. Add Preprocessing

                                                          Alternative 10: 49.9% accurate, 3.6× speedup?

                                                          \[\begin{array}{l} \\ \sqrt{\frac{\mathsf{PI}\left(\right)}{k} \cdot 2} \cdot \sqrt{n} \end{array} \]
                                                          (FPCore (k n) :precision binary64 (* (sqrt (* (/ (PI) k) 2.0)) (sqrt n)))
                                                          \begin{array}{l}
                                                          
                                                          \\
                                                          \sqrt{\frac{\mathsf{PI}\left(\right)}{k} \cdot 2} \cdot \sqrt{n}
                                                          \end{array}
                                                          
                                                          Derivation
                                                          1. Initial program 99.5%

                                                            \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
                                                          2. Add Preprocessing
                                                          3. Taylor expanded in k around 0

                                                            \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
                                                          4. Step-by-step derivation
                                                            1. *-commutativeN/A

                                                              \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                            2. lower-*.f64N/A

                                                              \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                            3. lower-sqrt.f64N/A

                                                              \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
                                                            4. lower-sqrt.f64N/A

                                                              \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                            5. lower-/.f64N/A

                                                              \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                            6. *-commutativeN/A

                                                              \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                                            7. lower-*.f64N/A

                                                              \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                                            8. lower-PI.f6443.0

                                                              \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
                                                          5. Applied rewrites43.0%

                                                            \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
                                                          6. Step-by-step derivation
                                                            1. Applied rewrites43.0%

                                                              \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2}} \]
                                                            2. Step-by-step derivation
                                                              1. Applied rewrites53.2%

                                                                \[\leadsto \sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k}} \cdot \color{blue}{\sqrt{n}} \]
                                                              2. Final simplification53.2%

                                                                \[\leadsto \sqrt{\frac{\mathsf{PI}\left(\right)}{k} \cdot 2} \cdot \sqrt{n} \]
                                                              3. Add Preprocessing

                                                              Alternative 11: 38.1% accurate, 4.8× speedup?

                                                              \[\begin{array}{l} \\ \sqrt{\left(n \cdot 2\right) \cdot \frac{\mathsf{PI}\left(\right)}{k}} \end{array} \]
                                                              (FPCore (k n) :precision binary64 (sqrt (* (* n 2.0) (/ (PI) k))))
                                                              \begin{array}{l}
                                                              
                                                              \\
                                                              \sqrt{\left(n \cdot 2\right) \cdot \frac{\mathsf{PI}\left(\right)}{k}}
                                                              \end{array}
                                                              
                                                              Derivation
                                                              1. Initial program 99.5%

                                                                \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
                                                              2. Add Preprocessing
                                                              3. Taylor expanded in k around 0

                                                                \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
                                                              4. Step-by-step derivation
                                                                1. *-commutativeN/A

                                                                  \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                                2. lower-*.f64N/A

                                                                  \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                                3. lower-sqrt.f64N/A

                                                                  \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
                                                                4. lower-sqrt.f64N/A

                                                                  \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                                5. lower-/.f64N/A

                                                                  \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                                6. *-commutativeN/A

                                                                  \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                                                7. lower-*.f64N/A

                                                                  \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                                                8. lower-PI.f6443.0

                                                                  \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
                                                              5. Applied rewrites43.0%

                                                                \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
                                                              6. Step-by-step derivation
                                                                1. Applied rewrites43.0%

                                                                  \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2}} \]
                                                                2. Step-by-step derivation
                                                                  1. Applied rewrites43.1%

                                                                    \[\leadsto \sqrt{\frac{\mathsf{PI}\left(\right)}{k} \cdot \left(2 \cdot n\right)} \]
                                                                  2. Final simplification43.1%

                                                                    \[\leadsto \sqrt{\left(n \cdot 2\right) \cdot \frac{\mathsf{PI}\left(\right)}{k}} \]
                                                                  3. Add Preprocessing

                                                                  Alternative 12: 38.1% accurate, 4.8× speedup?

                                                                  \[\begin{array}{l} \\ \sqrt{\left(\frac{2}{k} \cdot \mathsf{PI}\left(\right)\right) \cdot n} \end{array} \]
                                                                  (FPCore (k n) :precision binary64 (sqrt (* (* (/ 2.0 k) (PI)) n)))
                                                                  \begin{array}{l}
                                                                  
                                                                  \\
                                                                  \sqrt{\left(\frac{2}{k} \cdot \mathsf{PI}\left(\right)\right) \cdot n}
                                                                  \end{array}
                                                                  
                                                                  Derivation
                                                                  1. Initial program 99.5%

                                                                    \[\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \]
                                                                  2. Add Preprocessing
                                                                  3. Taylor expanded in k around 0

                                                                    \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2}} \]
                                                                  4. Step-by-step derivation
                                                                    1. *-commutativeN/A

                                                                      \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                                    2. lower-*.f64N/A

                                                                      \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                                    3. lower-sqrt.f64N/A

                                                                      \[\leadsto \color{blue}{\sqrt{2}} \cdot \sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}} \]
                                                                    4. lower-sqrt.f64N/A

                                                                      \[\leadsto \sqrt{2} \cdot \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                                    5. lower-/.f64N/A

                                                                      \[\leadsto \sqrt{2} \cdot \sqrt{\color{blue}{\frac{n \cdot \mathsf{PI}\left(\right)}{k}}} \]
                                                                    6. *-commutativeN/A

                                                                      \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                                                    7. lower-*.f64N/A

                                                                      \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right) \cdot n}}{k}} \]
                                                                    8. lower-PI.f6443.0

                                                                      \[\leadsto \sqrt{2} \cdot \sqrt{\frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot n}{k}} \]
                                                                  5. Applied rewrites43.0%

                                                                    \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k}}} \]
                                                                  6. Step-by-step derivation
                                                                    1. Applied rewrites43.0%

                                                                      \[\leadsto \color{blue}{\sqrt{\frac{n \cdot \mathsf{PI}\left(\right)}{k} \cdot 2}} \]
                                                                    2. Step-by-step derivation
                                                                      1. Applied rewrites43.1%

                                                                        \[\leadsto \sqrt{\left(\mathsf{PI}\left(\right) \cdot \frac{n}{k}\right) \cdot 2} \]
                                                                      2. Step-by-step derivation
                                                                        1. Applied rewrites43.1%

                                                                          \[\leadsto \sqrt{n \cdot \left(\mathsf{PI}\left(\right) \cdot \frac{2}{k}\right)} \]
                                                                        2. Final simplification43.1%

                                                                          \[\leadsto \sqrt{\left(\frac{2}{k} \cdot \mathsf{PI}\left(\right)\right) \cdot n} \]
                                                                        3. Add Preprocessing

                                                                        Reproduce

                                                                        ?
                                                                        herbie shell --seed 2024312 
                                                                        (FPCore (k n)
                                                                          :name "Migdal et al, Equation (51)"
                                                                          :precision binary64
                                                                          (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0))))