Average Error: 2.0 → 1.9
Time: 11.8s
Precision: 64
$9.999999974752427078783512115478515625 \cdot 10^{-7} \le \left|pR\right| \le 100 \land -10^{3} \le a \le 10^{3}$
$\frac{a}{{pR}^{2}} \cdot \left(\cos \left(p0 - pR \cdot t\right) - \cos p0\right)$
$\frac{a}{{pR}^{2}} \cdot \left(\left(\cos p0 \cdot \cos \left(pR \cdot t\right) - \sin p0 \cdot \sin \left(-pR \cdot t\right)\right) - \cos p0\right)$
\frac{a}{{pR}^{2}} \cdot \left(\cos \left(p0 - pR \cdot t\right) - \cos p0\right)
\frac{a}{{pR}^{2}} \cdot \left(\left(\cos p0 \cdot \cos \left(pR \cdot t\right) - \sin p0 \cdot \sin \left(-pR \cdot t\right)\right) - \cos p0\right)
double f(double a, double pR, double p0, double t) {
double r528592 = a;
double r528593 = pR;
double r528594 = 2.0;
double r528595 = pow(r528593, r528594);
double r528596 = r528592 / r528595;
double r528597 = p0;
double r528598 = t;
double r528599 = r528593 * r528598;
double r528600 = r528597 - r528599;
double r528601 = cos(r528600);
double r528602 = cos(r528597);
double r528603 = r528601 - r528602;
double r528604 = r528596 * r528603;
return r528604;
}


double f(double a, double pR, double p0, double t) {
double r528605 = a;
double r528606 = pR;
double r528607 = 2.0;
double r528608 = pow(r528606, r528607);
double r528609 = r528605 / r528608;
double r528610 = p0;
double r528611 = cos(r528610);
double r528612 = t;
double r528613 = r528606 * r528612;
double r528614 = cos(r528613);
double r528615 = r528611 * r528614;
double r528616 = sin(r528610);
double r528617 = -r528613;
double r528618 = sin(r528617);
double r528619 = r528616 * r528618;
double r528620 = r528615 - r528619;
double r528621 = r528620 - r528611;
double r528622 = r528609 * r528621;
return r528622;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 2.0

$\frac{a}{{pR}^{2}} \cdot \left(\cos \left(p0 - pR \cdot t\right) - \cos p0\right)$
2. Using strategy rm
3. Applied sub-neg2.0

$\leadsto \frac{a}{{pR}^{2}} \cdot \left(\cos \color{blue}{\left(p0 + \left(-pR \cdot t\right)\right)} - \cos p0\right)$
4. Applied cos-sum1.9

$\leadsto \frac{a}{{pR}^{2}} \cdot \left(\color{blue}{\left(\cos p0 \cdot \cos \left(-pR \cdot t\right) - \sin p0 \cdot \sin \left(-pR \cdot t\right)\right)} - \cos p0\right)$
5. Simplified1.9

$\leadsto \frac{a}{{pR}^{2}} \cdot \left(\left(\color{blue}{\cos p0 \cdot \cos \left(pR \cdot t\right)} - \sin p0 \cdot \sin \left(-pR \cdot t\right)\right) - \cos p0\right)$
6. Final simplification1.9

$\leadsto \frac{a}{{pR}^{2}} \cdot \left(\left(\cos p0 \cdot \cos \left(pR \cdot t\right) - \sin p0 \cdot \sin \left(-pR \cdot t\right)\right) - \cos p0\right)$

# Reproduce

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