Average Error: 15.3 → 10.3
Time: 34.6s
Precision: 64
\[\left|pR\right| \le 100\]
\[\frac{a}{{pR}^{2}} \cdot \left(\cos \left(p0 + pR \cdot t\right) - \cos p0\right)\]
\[\begin{array}{l} \mathbf{if}\;pR \le 0.0:\\ \;\;\;\;\frac{a}{{pR}^{2}} \cdot \left(\left(\sin \left(\frac{\left(p0 + pR \cdot t\right) + p0}{2}\right) \cdot \sin \left(\frac{pR \cdot t}{2}\right)\right) \cdot -2\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
\frac{a}{{pR}^{2}} \cdot \left(\cos \left(p0 + pR \cdot t\right) - \cos p0\right)
\begin{array}{l}
\mathbf{if}\;pR \le 0.0:\\
\;\;\;\;\frac{a}{{pR}^{2}} \cdot \left(\left(\sin \left(\frac{\left(p0 + pR \cdot t\right) + p0}{2}\right) \cdot \sin \left(\frac{pR \cdot t}{2}\right)\right) \cdot -2\right)\\

\mathbf{else}:\\
\;\;\;\;0\\

\end{array}
double f(double a, double pR, double p0, double t) {
        double r1748033 = a;
        double r1748034 = pR;
        double r1748035 = 2.0;
        double r1748036 = pow(r1748034, r1748035);
        double r1748037 = r1748033 / r1748036;
        double r1748038 = p0;
        double r1748039 = t;
        double r1748040 = r1748034 * r1748039;
        double r1748041 = r1748038 + r1748040;
        double r1748042 = cos(r1748041);
        double r1748043 = cos(r1748038);
        double r1748044 = r1748042 - r1748043;
        double r1748045 = r1748037 * r1748044;
        return r1748045;
}

double f(double a, double pR, double p0, double t) {
        double r1748046 = pR;
        double r1748047 = 0.0;
        bool r1748048 = r1748046 <= r1748047;
        double r1748049 = a;
        double r1748050 = 2.0;
        double r1748051 = pow(r1748046, r1748050);
        double r1748052 = r1748049 / r1748051;
        double r1748053 = p0;
        double r1748054 = t;
        double r1748055 = r1748046 * r1748054;
        double r1748056 = r1748053 + r1748055;
        double r1748057 = r1748056 + r1748053;
        double r1748058 = 2.0;
        double r1748059 = r1748057 / r1748058;
        double r1748060 = sin(r1748059);
        double r1748061 = r1748055 / r1748058;
        double r1748062 = sin(r1748061);
        double r1748063 = r1748060 * r1748062;
        double r1748064 = -2.0;
        double r1748065 = r1748063 * r1748064;
        double r1748066 = r1748052 * r1748065;
        double r1748067 = 0.0;
        double r1748068 = r1748048 ? r1748066 : r1748067;
        return r1748068;
}

Error

Bits error versus a

Bits error versus pR

Bits error versus p0

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if pR < 0.0

    1. Initial program 15.4

      \[\frac{a}{{pR}^{2}} \cdot \left(\cos \left(p0 + pR \cdot t\right) - \cos p0\right)\]
    2. Using strategy rm
    3. Applied diff-cos15.0

      \[\leadsto \frac{a}{{pR}^{2}} \cdot \color{blue}{\left(-2 \cdot \left(\sin \left(\frac{\left(p0 + pR \cdot t\right) - p0}{2}\right) \cdot \sin \left(\frac{\left(p0 + pR \cdot t\right) + p0}{2}\right)\right)\right)}\]
    4. Simplified13.6

      \[\leadsto \frac{a}{{pR}^{2}} \cdot \left(-2 \cdot \color{blue}{\left(\sin \left(\frac{\left(p0 + pR \cdot t\right) + p0}{2}\right) \cdot \sin \left(\frac{pR \cdot t + 0}{2}\right)\right)}\right)\]

    if 0.0 < pR

    1. Initial program 15.2

      \[\frac{a}{{pR}^{2}} \cdot \left(\cos \left(p0 + pR \cdot t\right) - \cos p0\right)\]
    2. Taylor expanded around 0 7.0

      \[\leadsto \color{blue}{0}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification10.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;pR \le 0.0:\\ \;\;\;\;\frac{a}{{pR}^{2}} \cdot \left(\left(\sin \left(\frac{\left(p0 + pR \cdot t\right) + p0}{2}\right) \cdot \sin \left(\frac{pR \cdot t}{2}\right)\right) \cdot -2\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (a pR p0 t)
  :name "a / pR^2 * (cos(p0 + pR*t) - cos(p0))"
  :precision binary32
  :pre (<= (fabs pR) 100)
  (* (/ a (pow pR 2)) (- (cos (+ p0 (* pR t))) (cos p0))))