Average Error: 15.2 → 1.4
Time: 3.1m
Precision: 64
Internal Precision: 1408
\[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}\]
\[\begin{array}{l} \mathbf{if}\;\frac{K \cdot \left(m + n\right)}{2} - M \le -2.1780350068345573 \cdot 10^{+304}:\\ \;\;\;\;\frac{\cos \left(\frac{\frac{\frac{1}{2}}{m} + \frac{\frac{1}{2}}{n}}{K} - \frac{1}{M}\right)}{e^{\left(\ell - \left|m - n\right|\right) + \left(\frac{n + m}{2} - M\right) \cdot \left(\frac{n + m}{2} - M\right)}}\\ \mathbf{if}\;\frac{K \cdot \left(m + n\right)}{2} - M \le 3.0970790600414114 \cdot 10^{+299}:\\ \;\;\;\;\cos \left(\left(\sqrt[3]{\frac{K \cdot \left(m + n\right)}{2}} \cdot \sqrt[3]{\frac{K \cdot \left(m + n\right)}{2}}\right) \cdot \sqrt[3]{\frac{K \cdot \left(m + n\right)}{2}} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(\frac{\frac{\frac{1}{2}}{m} + \frac{\frac{1}{2}}{n}}{K} - \frac{1}{M}\right)}{e^{\left(\ell - \left|m - n\right|\right) + \left(\frac{n + m}{2} - M\right) \cdot \left(\frac{n + m}{2} - M\right)}}\\ \end{array}\]

Error

Bits error versus K

Bits error versus m

Bits error versus n

Bits error versus M

Bits error versus l

Derivation

  1. Split input into 2 regimes
  2. if (- (/ (* K (+ m n)) 2) M) < -2.1780350068345573e+304 or 3.0970790600414114e+299 < (- (/ (* K (+ m n)) 2) M)

    1. Initial program 58.6

      \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}\]
    2. Taylor expanded around inf 0.5

      \[\leadsto \color{blue}{\cos \left(\left(\frac{1}{2} \cdot \frac{1}{m \cdot K} + \frac{1}{2} \cdot \frac{1}{n \cdot K}\right) - \frac{1}{M}\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}\]
    3. Applied simplify0.6

      \[\leadsto \color{blue}{\frac{\cos \left(\frac{\frac{\frac{1}{2}}{m} + \frac{\frac{1}{2}}{n}}{K} - \frac{1}{M}\right)}{e^{\left(\ell - \left|m - n\right|\right) + \left(\frac{n + m}{2} - M\right) \cdot \left(\frac{n + m}{2} - M\right)}}}\]

    if -2.1780350068345573e+304 < (- (/ (* K (+ m n)) 2) M) < 3.0970790600414114e+299

    1. Initial program 1.7

      \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt1.6

      \[\leadsto \cos \left(\color{blue}{\left(\sqrt[3]{\frac{K \cdot \left(m + n\right)}{2}} \cdot \sqrt[3]{\frac{K \cdot \left(m + n\right)}{2}}\right) \cdot \sqrt[3]{\frac{K \cdot \left(m + n\right)}{2}}} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 3.1m)Debug logProfile

herbie shell --seed '#(1062930989 876886121 3990119081 3032829768 3060892583 1929069376)' 
(FPCore (K m n M l)
  :name "Maksimov and Kolovsky, Equation (32)"
  (* (cos (- (/ (* K (+ m n)) 2) M)) (exp (- (- (pow (- (/ (+ m n) 2) M) 2)) (- l (fabs (- m n)))))))