Sample trimmed logistic on [-pi, pi]

Percentage Accurate: 99.0% → 99.0%
Time: 14.8s
Alternatives: 9
Speedup: 1.0×

Specification

?
\[\left(2.328306437 \cdot 10^{-10} \leq u \land u \leq 1\right) \land \left(0 \leq s \land s \leq 1.0651631\right)\]
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\\ \left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - t\_0\right) + t\_0} - 1\right) \end{array} \end{array} \]
(FPCore (u s)
 :precision binary32
 (let* ((t_0 (/ 1.0 (+ 1.0 (exp (/ (PI) s))))))
   (*
    (- s)
    (log
     (-
      (/ 1.0 (+ (* u (- (/ 1.0 (+ 1.0 (exp (/ (- (PI)) s)))) t_0)) t_0))
      1.0)))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\\
\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - t\_0\right) + t\_0} - 1\right)
\end{array}
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 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.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\\ \left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - t\_0\right) + t\_0} - 1\right) \end{array} \end{array} \]
(FPCore (u s)
 :precision binary32
 (let* ((t_0 (/ 1.0 (+ 1.0 (exp (/ (PI) s))))))
   (*
    (- s)
    (log
     (-
      (/ 1.0 (+ (* u (- (/ 1.0 (+ 1.0 (exp (/ (- (PI)) s)))) t_0)) t_0))
      1.0)))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\\
\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - t\_0\right) + t\_0} - 1\right)
\end{array}
\end{array}

Alternative 1: 99.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\\ \left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - t\_0\right) + t\_0} - 1\right) \end{array} \end{array} \]
(FPCore (u s)
 :precision binary32
 (let* ((t_0 (/ 1.0 (+ 1.0 (exp (/ (PI) s))))))
   (*
    (- s)
    (log
     (-
      (/ 1.0 (+ (* u (- (/ 1.0 (+ 1.0 (exp (/ (- (PI)) s)))) t_0)) t_0))
      1.0)))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\\
\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - t\_0\right) + t\_0} - 1\right)
\end{array}
\end{array}
Derivation
  1. Initial program 99.0%

    \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\right) + \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}} - 1\right) \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 28.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\\ \mathbf{if}\;\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - t\_0\right) + t\_0} - 1\right) \leq -3.499999942646603 \cdot 10^{-11}:\\ \;\;\;\;\left(-s\right) \cdot \log \left(\left(\left(\frac{4}{s} \cdot 0.25\right) \cdot \mathsf{PI}\left(\right) + \left(\frac{4}{s} \cdot -0.5\right) \cdot \left(\mathsf{PI}\left(\right) \cdot u\right)\right) + 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-s\right) \cdot \log \left(\mathsf{fma}\left(\mathsf{fma}\left({\mathsf{PI}\left(\right)}^{1}, u \cdot -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right), \frac{4}{s}, 1\right)\right)\\ \end{array} \end{array} \]
(FPCore (u s)
 :precision binary32
 (let* ((t_0 (/ 1.0 (+ 1.0 (exp (/ (PI) s))))))
   (if (<=
        (*
         (- s)
         (log
          (-
           (/ 1.0 (+ (* u (- (/ 1.0 (+ 1.0 (exp (/ (- (PI)) s)))) t_0)) t_0))
           1.0)))
        -3.499999942646603e-11)
     (*
      (- s)
      (log
       (+
        (+ (* (* (/ 4.0 s) 0.25) (PI)) (* (* (/ 4.0 s) -0.5) (* (PI) u)))
        1.0)))
     (*
      (- s)
      (log
       (fma (fma (pow (PI) 1.0) (* u -0.5) (* 0.25 (PI))) (/ 4.0 s) 1.0))))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\\
\mathbf{if}\;\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - t\_0\right) + t\_0} - 1\right) \leq -3.499999942646603 \cdot 10^{-11}:\\
\;\;\;\;\left(-s\right) \cdot \log \left(\left(\left(\frac{4}{s} \cdot 0.25\right) \cdot \mathsf{PI}\left(\right) + \left(\frac{4}{s} \cdot -0.5\right) \cdot \left(\mathsf{PI}\left(\right) \cdot u\right)\right) + 1\right)\\

\mathbf{else}:\\
\;\;\;\;\left(-s\right) \cdot \log \left(\mathsf{fma}\left(\mathsf{fma}\left({\mathsf{PI}\left(\right)}^{1}, u \cdot -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right), \frac{4}{s}, 1\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 (neg.f32 s) (log.f32 (-.f32 (/.f32 #s(literal 1 binary32) (+.f32 (*.f32 u (-.f32 (/.f32 #s(literal 1 binary32) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (PI.f32)) s)))) (/.f32 #s(literal 1 binary32) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (PI.f32) s)))))) (/.f32 #s(literal 1 binary32) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (PI.f32) s)))))) #s(literal 1 binary32)))) < -3.49999994e-11

    1. Initial program 99.1%

      \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\right) + \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}} - 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in s around -inf

      \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(1 + 4 \cdot \frac{u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}{s}\right)} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \left(-s\right) \cdot \log \left(1 + \color{blue}{\frac{4 \cdot \left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s}}\right) \]
      2. +-commutativeN/A

        \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\frac{4 \cdot \left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s} + 1\right)} \]
      3. *-commutativeN/A

        \[\leadsto \left(-s\right) \cdot \log \left(\frac{\color{blue}{\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) \cdot 4}}{s} + 1\right) \]
      4. associate-/l*N/A

        \[\leadsto \left(-s\right) \cdot \log \left(\color{blue}{\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{4}{s}} + 1\right) \]
      5. lower-fma.f32N/A

        \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right), \frac{4}{s}, 1\right)\right)} \]
    5. Applied rewrites6.9%

      \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right), \frac{4}{s}, 1\right)\right)} \]
    6. Step-by-step derivation
      1. Applied rewrites16.0%

        \[\leadsto \left(-s\right) \cdot \log \left(\frac{4}{s} \cdot \mathsf{fma}\left(-0.5, \mathsf{PI}\left(\right) \cdot u, 0.25 \cdot \mathsf{PI}\left(\right)\right) + \color{blue}{1}\right) \]
      2. Step-by-step derivation
        1. Applied rewrites29.9%

          \[\leadsto \left(-s\right) \cdot \log \left(\left(\left(\frac{4}{s} \cdot 0.25\right) \cdot \mathsf{PI}\left(\right) + \left(\frac{4}{s} \cdot -0.5\right) \cdot \left(\mathsf{PI}\left(\right) \cdot u\right)\right) + 1\right) \]

        if -3.49999994e-11 < (*.f32 (neg.f32 s) (log.f32 (-.f32 (/.f32 #s(literal 1 binary32) (+.f32 (*.f32 u (-.f32 (/.f32 #s(literal 1 binary32) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (PI.f32)) s)))) (/.f32 #s(literal 1 binary32) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (PI.f32) s)))))) (/.f32 #s(literal 1 binary32) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (PI.f32) s)))))) #s(literal 1 binary32))))

        1. Initial program 98.9%

          \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\right) + \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}} - 1\right) \]
        2. Add Preprocessing
        3. Taylor expanded in s around -inf

          \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(1 + 4 \cdot \frac{u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}{s}\right)} \]
        4. Step-by-step derivation
          1. associate-*r/N/A

            \[\leadsto \left(-s\right) \cdot \log \left(1 + \color{blue}{\frac{4 \cdot \left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s}}\right) \]
          2. +-commutativeN/A

            \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\frac{4 \cdot \left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s} + 1\right)} \]
          3. *-commutativeN/A

            \[\leadsto \left(-s\right) \cdot \log \left(\frac{\color{blue}{\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) \cdot 4}}{s} + 1\right) \]
          4. associate-/l*N/A

            \[\leadsto \left(-s\right) \cdot \log \left(\color{blue}{\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{4}{s}} + 1\right) \]
          5. lower-fma.f32N/A

            \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right), \frac{4}{s}, 1\right)\right)} \]
        5. Applied rewrites11.8%

          \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right), \frac{4}{s}, 1\right)\right)} \]
        6. Step-by-step derivation
          1. Applied rewrites11.8%

            \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{PI}\left(\right), u \cdot -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right), \frac{\color{blue}{4}}{s}, 1\right)\right) \]
          2. Step-by-step derivation
            1. Applied rewrites27.8%

              \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(\mathsf{fma}\left({\mathsf{PI}\left(\right)}^{1}, u \cdot -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right), \frac{4}{s}, 1\right)\right) \]
          3. Recombined 2 regimes into one program.
          4. Add Preprocessing

          Alternative 3: 97.7% accurate, 1.3× speedup?

          \[\begin{array}{l} \\ \left(-s\right) \cdot \log \left(\frac{1}{\left(\frac{1}{e^{\frac{-\mathsf{PI}\left(\right)}{s}} + 1} - \frac{1}{e^{\frac{\mathsf{PI}\left(\right)}{s}} + 1}\right) \cdot u} - 1\right) \end{array} \]
          (FPCore (u s)
           :precision binary32
           (*
            (- s)
            (log
             (-
              (/
               1.0
               (*
                (- (/ 1.0 (+ (exp (/ (- (PI)) s)) 1.0)) (/ 1.0 (+ (exp (/ (PI) s)) 1.0)))
                u))
              1.0))))
          \begin{array}{l}
          
          \\
          \left(-s\right) \cdot \log \left(\frac{1}{\left(\frac{1}{e^{\frac{-\mathsf{PI}\left(\right)}{s}} + 1} - \frac{1}{e^{\frac{\mathsf{PI}\left(\right)}{s}} + 1}\right) \cdot u} - 1\right)
          \end{array}
          
          Derivation
          1. Initial program 99.0%

            \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\right) + \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}} - 1\right) \]
          2. Add Preprocessing
          3. Taylor expanded in u around inf

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

              \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\color{blue}{\left(\frac{1}{1 + e^{-1 \cdot \frac{\mathsf{PI}\left(\right)}{s}}} - \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\right) \cdot u}} - 1\right) \]
            2. lower-*.f32N/A

              \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\color{blue}{\left(\frac{1}{1 + e^{-1 \cdot \frac{\mathsf{PI}\left(\right)}{s}}} - \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\right) \cdot u}} - 1\right) \]
          5. Applied rewrites98.0%

            \[\leadsto \left(-s\right) \cdot \log \left(\frac{1}{\color{blue}{\left(\frac{1}{e^{\frac{-\mathsf{PI}\left(\right)}{s}} + 1} - \frac{1}{e^{\frac{\mathsf{PI}\left(\right)}{s}} + 1}\right) \cdot u}} - 1\right) \]
          6. Add Preprocessing

          Alternative 4: 25.2% accurate, 1.4× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\mathsf{PI}\left(\right)}\\ \left(-s\right) \cdot \log \left(\mathsf{fma}\left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \left(t\_0 \cdot \log \left(e^{t\_0}\right)\right)\right), \frac{4}{s}, 1\right)\right) \end{array} \end{array} \]
          (FPCore (u s)
           :precision binary32
           (let* ((t_0 (sqrt (PI))))
             (*
              (- s)
              (log
               (fma
                (fma (* u (PI)) -0.5 (* 0.25 (* t_0 (log (exp t_0)))))
                (/ 4.0 s)
                1.0)))))
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
          \left(-s\right) \cdot \log \left(\mathsf{fma}\left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \left(t\_0 \cdot \log \left(e^{t\_0}\right)\right)\right), \frac{4}{s}, 1\right)\right)
          \end{array}
          \end{array}
          
          Derivation
          1. Initial program 99.0%

            \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\right) + \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}} - 1\right) \]
          2. Add Preprocessing
          3. Taylor expanded in s around -inf

            \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(1 + 4 \cdot \frac{u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}{s}\right)} \]
          4. Step-by-step derivation
            1. associate-*r/N/A

              \[\leadsto \left(-s\right) \cdot \log \left(1 + \color{blue}{\frac{4 \cdot \left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s}}\right) \]
            2. +-commutativeN/A

              \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\frac{4 \cdot \left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s} + 1\right)} \]
            3. *-commutativeN/A

              \[\leadsto \left(-s\right) \cdot \log \left(\frac{\color{blue}{\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) \cdot 4}}{s} + 1\right) \]
            4. associate-/l*N/A

              \[\leadsto \left(-s\right) \cdot \log \left(\color{blue}{\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{4}{s}} + 1\right) \]
            5. lower-fma.f32N/A

              \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right), \frac{4}{s}, 1\right)\right)} \]
          5. Applied rewrites10.3%

            \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right), \frac{4}{s}, 1\right)\right)} \]
          6. Step-by-step derivation
            1. Applied rewrites25.9%

              \[\leadsto \left(-s\right) \cdot \log \left(\mathsf{fma}\left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \left(\sqrt{\mathsf{PI}\left(\right)} \cdot \log \left(e^{\sqrt{\mathsf{PI}\left(\right)}}\right)\right)\right), \frac{4}{s}, 1\right)\right) \]
            2. Add Preprocessing

            Alternative 5: 25.2% accurate, 4.2× speedup?

            \[\begin{array}{l} \\ \left(-s\right) \cdot \log \left(\frac{\mathsf{PI}\left(\right)}{s} + 1\right) \end{array} \]
            (FPCore (u s) :precision binary32 (* (- s) (log (+ (/ (PI) s) 1.0))))
            \begin{array}{l}
            
            \\
            \left(-s\right) \cdot \log \left(\frac{\mathsf{PI}\left(\right)}{s} + 1\right)
            \end{array}
            
            Derivation
            1. Initial program 99.0%

              \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\right) + \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}} - 1\right) \]
            2. Add Preprocessing
            3. Taylor expanded in s around -inf

              \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(1 + 4 \cdot \frac{u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}{s}\right)} \]
            4. Step-by-step derivation
              1. associate-*r/N/A

                \[\leadsto \left(-s\right) \cdot \log \left(1 + \color{blue}{\frac{4 \cdot \left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s}}\right) \]
              2. +-commutativeN/A

                \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\frac{4 \cdot \left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s} + 1\right)} \]
              3. *-commutativeN/A

                \[\leadsto \left(-s\right) \cdot \log \left(\frac{\color{blue}{\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) \cdot 4}}{s} + 1\right) \]
              4. associate-/l*N/A

                \[\leadsto \left(-s\right) \cdot \log \left(\color{blue}{\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{4}{s}} + 1\right) \]
              5. lower-fma.f32N/A

                \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right), \frac{4}{s}, 1\right)\right)} \]
            5. Applied rewrites10.3%

              \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right), \frac{4}{s}, 1\right)\right)} \]
            6. Taylor expanded in u around 0

              \[\leadsto \left(-s\right) \cdot \log \left(1 + \color{blue}{\frac{\mathsf{PI}\left(\right)}{s}}\right) \]
            7. Step-by-step derivation
              1. Applied rewrites25.5%

                \[\leadsto \left(-s\right) \cdot \log \left(\frac{\mathsf{PI}\left(\right)}{s} + \color{blue}{1}\right) \]
              2. Add Preprocessing

              Alternative 6: 11.0% accurate, 7.4× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{-\mathsf{PI}\left(\right)}\\ \left(-s\right) \cdot \left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \left(t\_0 \cdot t\_0\right)\right) \cdot \frac{4}{s}\right) \end{array} \end{array} \]
              (FPCore (u s)
               :precision binary32
               (let* ((t_0 (sqrt (- (PI)))))
                 (* (- s) (* (fma (* u (PI)) -0.5 (* 0.25 (* t_0 t_0))) (/ 4.0 s)))))
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := \sqrt{-\mathsf{PI}\left(\right)}\\
              \left(-s\right) \cdot \left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \left(t\_0 \cdot t\_0\right)\right) \cdot \frac{4}{s}\right)
              \end{array}
              \end{array}
              
              Derivation
              1. Initial program 99.0%

                \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\right) + \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}} - 1\right) \]
              2. Add Preprocessing
              3. Taylor expanded in s around -inf

                \[\leadsto \left(-s\right) \cdot \color{blue}{\left(4 \cdot \frac{u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}{s}\right)} \]
              4. Step-by-step derivation
                1. associate-*r/N/A

                  \[\leadsto \left(-s\right) \cdot \color{blue}{\frac{4 \cdot \left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}{s}} \]
                2. *-commutativeN/A

                  \[\leadsto \left(-s\right) \cdot \frac{\color{blue}{\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) \cdot 4}}{s} \]
                3. associate-/l*N/A

                  \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{4}{s}\right)} \]
                4. lower-*.f32N/A

                  \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{4}{s}\right)} \]
                5. fp-cancel-sub-sign-invN/A

                  \[\leadsto \left(-s\right) \cdot \left(\color{blue}{\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) + \left(\mathsf{neg}\left(\frac{-1}{4}\right)\right) \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{4}{s}\right) \]
                6. distribute-rgt-out--N/A

                  \[\leadsto \left(-s\right) \cdot \left(\left(u \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(\frac{-1}{4} - \frac{1}{4}\right)\right)} + \left(\mathsf{neg}\left(\frac{-1}{4}\right)\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{4}{s}\right) \]
                7. metadata-evalN/A

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

                  \[\leadsto \left(-s\right) \cdot \left(\left(\color{blue}{\left(u \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{-1}{2}} + \left(\mathsf{neg}\left(\frac{-1}{4}\right)\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{4}{s}\right) \]
                9. metadata-evalN/A

                  \[\leadsto \left(-s\right) \cdot \left(\left(\left(u \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{-1}{2} + \color{blue}{\frac{1}{4}} \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{4}{s}\right) \]
                10. lower-fma.f32N/A

                  \[\leadsto \left(-s\right) \cdot \left(\color{blue}{\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), \frac{-1}{2}, \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)} \cdot \frac{4}{s}\right) \]
                11. lower-*.f32N/A

                  \[\leadsto \left(-s\right) \cdot \left(\mathsf{fma}\left(\color{blue}{u \cdot \mathsf{PI}\left(\right)}, \frac{-1}{2}, \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{4}{s}\right) \]
                12. lower-PI.f32N/A

                  \[\leadsto \left(-s\right) \cdot \left(\mathsf{fma}\left(u \cdot \color{blue}{\mathsf{PI}\left(\right)}, \frac{-1}{2}, \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{4}{s}\right) \]
                13. lower-*.f32N/A

                  \[\leadsto \left(-s\right) \cdot \left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), \frac{-1}{2}, \color{blue}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)}\right) \cdot \frac{4}{s}\right) \]
                14. lower-PI.f32N/A

                  \[\leadsto \left(-s\right) \cdot \left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), \frac{-1}{2}, \frac{1}{4} \cdot \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot \frac{4}{s}\right) \]
                15. lower-/.f3211.3

                  \[\leadsto \left(-s\right) \cdot \left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\frac{4}{s}}\right) \]
              5. Applied rewrites11.3%

                \[\leadsto \left(-s\right) \cdot \color{blue}{\left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{4}{s}\right)} \]
              6. Step-by-step derivation
                1. Applied rewrites12.4%

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

                Alternative 7: 11.5% accurate, 36.4× speedup?

                \[\begin{array}{l} \\ \left(\mathsf{PI}\left(\right) \cdot u\right) \cdot 2 - \mathsf{PI}\left(\right) \end{array} \]
                (FPCore (u s) :precision binary32 (- (* (* (PI) u) 2.0) (PI)))
                \begin{array}{l}
                
                \\
                \left(\mathsf{PI}\left(\right) \cdot u\right) \cdot 2 - \mathsf{PI}\left(\right)
                \end{array}
                
                Derivation
                1. Initial program 99.0%

                  \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\right) + \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}} - 1\right) \]
                2. Add Preprocessing
                3. Taylor expanded in s around -inf

                  \[\leadsto \color{blue}{-4 \cdot \left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) + \frac{-1}{2} \cdot \frac{-16 \cdot {\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} + -2 \cdot \left(-8 \cdot {\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} + -4 \cdot \left(\frac{-1}{8} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{8} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)}{s}} \]
                4. Applied rewrites7.6%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\mathsf{fma}\left({\left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}, -16, \mathsf{fma}\left(16, {\left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}, 0\right)\right)}{s}, -0.5, \mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right) \cdot -4\right)} \]
                5. Step-by-step derivation
                  1. Applied rewrites11.2%

                    \[\leadsto \mathsf{fma}\left(\frac{0}{-\left(-s\right)}, -0.5, \mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right) \cdot -4\right) \]
                  2. Step-by-step derivation
                    1. Applied rewrites5.0%

                      \[\leadsto \mathsf{fma}\left(\frac{0}{-\left(-s\right)}, -0.5, \mathsf{fma}\left(0.25, \mathsf{PI}\left(\right), \left(\mathsf{PI}\left(\right) \cdot u\right) \cdot -0.5\right) \cdot -4\right) \]
                    2. Step-by-step derivation
                      1. Applied rewrites11.5%

                        \[\leadsto \left(\mathsf{PI}\left(\right) \cdot u\right) \cdot 2 + \color{blue}{\left(-\mathsf{PI}\left(\right)\right)} \]
                      2. Final simplification11.5%

                        \[\leadsto \left(\mathsf{PI}\left(\right) \cdot u\right) \cdot 2 - \mathsf{PI}\left(\right) \]
                      3. Add Preprocessing

                      Alternative 8: 11.3% accurate, 170.0× speedup?

                      \[\begin{array}{l} \\ -\mathsf{PI}\left(\right) \end{array} \]
                      (FPCore (u s) :precision binary32 (- (PI)))
                      \begin{array}{l}
                      
                      \\
                      -\mathsf{PI}\left(\right)
                      \end{array}
                      
                      Derivation
                      1. Initial program 99.0%

                        \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\right) + \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}} - 1\right) \]
                      2. Add Preprocessing
                      3. Taylor expanded in u around 0

                        \[\leadsto \color{blue}{-1 \cdot \mathsf{PI}\left(\right)} \]
                      4. Step-by-step derivation
                        1. mul-1-negN/A

                          \[\leadsto \color{blue}{\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)} \]
                        2. lower-neg.f32N/A

                          \[\leadsto \color{blue}{-\mathsf{PI}\left(\right)} \]
                        3. lower-PI.f3211.3

                          \[\leadsto -\color{blue}{\mathsf{PI}\left(\right)} \]
                      5. Applied rewrites11.3%

                        \[\leadsto \color{blue}{-\mathsf{PI}\left(\right)} \]
                      6. Add Preprocessing

                      Alternative 9: 10.3% accurate, 510.0× speedup?

                      \[\begin{array}{l} \\ 0 \end{array} \]
                      (FPCore (u s) :precision binary32 0.0)
                      float code(float u, float s) {
                      	return 0.0f;
                      }
                      
                      real(4) function code(u, s)
                          real(4), intent (in) :: u
                          real(4), intent (in) :: s
                          code = 0.0e0
                      end function
                      
                      function code(u, s)
                      	return Float32(0.0)
                      end
                      
                      function tmp = code(u, s)
                      	tmp = single(0.0);
                      end
                      
                      \begin{array}{l}
                      
                      \\
                      0
                      \end{array}
                      
                      Derivation
                      1. Initial program 99.0%

                        \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\mathsf{PI}\left(\right)}{s}}} - \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}\right) + \frac{1}{1 + e^{\frac{\mathsf{PI}\left(\right)}{s}}}} - 1\right) \]
                      2. Add Preprocessing
                      3. Taylor expanded in s around -inf

                        \[\leadsto \color{blue}{-4 \cdot \left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right) + \frac{-1}{2} \cdot \frac{-16 \cdot {\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} + -2 \cdot \left(-8 \cdot {\left(u \cdot \left(\frac{-1}{4} \cdot \mathsf{PI}\left(\right) - \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} + -4 \cdot \left(\frac{-1}{8} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{8} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)}{s}} \]
                      4. Applied rewrites8.0%

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\mathsf{fma}\left({\left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}, -16, \mathsf{fma}\left(16, {\left(\mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}, 0\right)\right)}{s}, -0.5, \mathsf{fma}\left(u \cdot \mathsf{PI}\left(\right), -0.5, 0.25 \cdot \mathsf{PI}\left(\right)\right) \cdot -4\right)} \]
                      5. Taylor expanded in s around 0

                        \[\leadsto \frac{-1}{2} \cdot \color{blue}{\frac{-16 \cdot {\left(\frac{-1}{2} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2} + 16 \cdot {\left(\frac{-1}{2} \cdot \left(u \cdot \mathsf{PI}\left(\right)\right) + \frac{1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2}}{s}} \]
                      6. Step-by-step derivation
                        1. Applied rewrites10.3%

                          \[\leadsto 0 \]
                        2. Add Preprocessing

                        Reproduce

                        ?
                        herbie shell --seed 2024337 
                        (FPCore (u s)
                          :name "Sample trimmed logistic on [-pi, pi]"
                          :precision binary32
                          :pre (and (and (<= 2.328306437e-10 u) (<= u 1.0)) (and (<= 0.0 s) (<= s 1.0651631)))
                          (* (- s) (log (- (/ 1.0 (+ (* u (- (/ 1.0 (+ 1.0 (exp (/ (- (PI)) s)))) (/ 1.0 (+ 1.0 (exp (/ (PI) s)))))) (/ 1.0 (+ 1.0 (exp (/ (PI) s)))))) 1.0))))