Average Error: 9.5 → 1.3
Time: 25.1s
Precision: 64
$\left(\left(a \cdot a\right) \cdot d - \left(\left(a \cdot a\right) \cdot R\right) \cdot R\right) + b \cdot \left(b - \left(2 \cdot a\right) \cdot c\right)$
$\left(a \cdot \left(d \cdot a\right) - \left(a \cdot R\right) \cdot \left(a \cdot R\right)\right) + \left(b - \left(a \cdot 2\right) \cdot c\right) \cdot b$
\left(\left(a \cdot a\right) \cdot d - \left(\left(a \cdot a\right) \cdot R\right) \cdot R\right) + b \cdot \left(b - \left(2 \cdot a\right) \cdot c\right)
\left(a \cdot \left(d \cdot a\right) - \left(a \cdot R\right) \cdot \left(a \cdot R\right)\right) + \left(b - \left(a \cdot 2\right) \cdot c\right) \cdot b
double f(double a, double d, double R, double b, double c) {
double r7672850 = a;
double r7672851 = r7672850 * r7672850;
double r7672852 = d;
double r7672853 = r7672851 * r7672852;
double r7672854 = R;
double r7672855 = r7672851 * r7672854;
double r7672856 = r7672855 * r7672854;
double r7672857 = r7672853 - r7672856;
double r7672858 = b;
double r7672859 = 2.0;
double r7672860 = r7672859 * r7672850;
double r7672861 = c;
double r7672862 = r7672860 * r7672861;
double r7672863 = r7672858 - r7672862;
double r7672864 = r7672858 * r7672863;
double r7672865 = r7672857 + r7672864;
return r7672865;
}


double f(double a, double d, double R, double b, double c) {
double r7672866 = a;
double r7672867 = d;
double r7672868 = r7672867 * r7672866;
double r7672869 = r7672866 * r7672868;
double r7672870 = R;
double r7672871 = r7672866 * r7672870;
double r7672872 = r7672871 * r7672871;
double r7672873 = r7672869 - r7672872;
double r7672874 = b;
double r7672875 = 2.0;
double r7672876 = r7672866 * r7672875;
double r7672877 = c;
double r7672878 = r7672876 * r7672877;
double r7672879 = r7672874 - r7672878;
double r7672880 = r7672879 * r7672874;
double r7672881 = r7672873 + r7672880;
return r7672881;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 9.5

$\left(\left(a \cdot a\right) \cdot d - \left(\left(a \cdot a\right) \cdot R\right) \cdot R\right) + b \cdot \left(b - \left(2 \cdot a\right) \cdot c\right)$
2. Taylor expanded around inf 15.0

$\leadsto \left(\left(a \cdot a\right) \cdot d - \color{blue}{{a}^{2} \cdot {R}^{2}}\right) + b \cdot \left(b - \left(2 \cdot a\right) \cdot c\right)$
3. Simplified4.6

$\leadsto \left(\left(a \cdot a\right) \cdot d - \color{blue}{\left(a \cdot R\right) \cdot \left(a \cdot R\right)}\right) + b \cdot \left(b - \left(2 \cdot a\right) \cdot c\right)$
4. Using strategy rm
5. Applied associate-*l*1.3

$\leadsto \left(\color{blue}{a \cdot \left(a \cdot d\right)} - \left(a \cdot R\right) \cdot \left(a \cdot R\right)\right) + b \cdot \left(b - \left(2 \cdot a\right) \cdot c\right)$
6. Final simplification1.3

$\leadsto \left(a \cdot \left(d \cdot a\right) - \left(a \cdot R\right) \cdot \left(a \cdot R\right)\right) + \left(b - \left(a \cdot 2\right) \cdot c\right) \cdot b$

# Reproduce

herbie shell --seed 1
(FPCore (a d R b c)
:name " a * a * d - a * a * R * R+ b * (b - 2 * a * c)"
(+ (- (* (* a a) d) (* (* (* a a) R) R)) (* b (- b (* (* 2 a) c)))))