Average Error: 1.7 → 1.7
Time: 41.9s
Precision: 64
$\left(c - a \cdot b\right) \cdot \left(c - a \cdot b\right) - \left(4 \cdot \left(1 - a \cdot a\right)\right) \cdot \left(\left(d - b \cdot b\right) - R \cdot R\right)$
$\left(-4 - \left(a \cdot -4\right) \cdot a\right) \cdot \left(d - \left(b \cdot b + R \cdot R\right)\right) + \left(c - a \cdot b\right) \cdot \left(c - a \cdot b\right)$
\left(c - a \cdot b\right) \cdot \left(c - a \cdot b\right) - \left(4 \cdot \left(1 - a \cdot a\right)\right) \cdot \left(\left(d - b \cdot b\right) - R \cdot R\right)
\left(-4 - \left(a \cdot -4\right) \cdot a\right) \cdot \left(d - \left(b \cdot b + R \cdot R\right)\right) + \left(c - a \cdot b\right) \cdot \left(c - a \cdot b\right)
double f(double c, double a, double b, double d, double R) {
double r2131773 = c;
double r2131774 = a;
double r2131775 = b;
double r2131776 = r2131774 * r2131775;
double r2131777 = r2131773 - r2131776;
double r2131778 = r2131777 * r2131777;
double r2131779 = 4.0;
double r2131780 = 1.0;
double r2131781 = r2131774 * r2131774;
double r2131782 = r2131780 - r2131781;
double r2131783 = r2131779 * r2131782;
double r2131784 = d;
double r2131785 = r2131775 * r2131775;
double r2131786 = r2131784 - r2131785;
double r2131787 = R;
double r2131788 = r2131787 * r2131787;
double r2131789 = r2131786 - r2131788;
double r2131790 = r2131783 * r2131789;
double r2131791 = r2131778 - r2131790;
return r2131791;
}


double f(double c, double a, double b, double d, double R) {
double r2131792 = -4.0;
double r2131793 = a;
double r2131794 = r2131793 * r2131792;
double r2131795 = r2131794 * r2131793;
double r2131796 = r2131792 - r2131795;
double r2131797 = d;
double r2131798 = b;
double r2131799 = r2131798 * r2131798;
double r2131800 = R;
double r2131801 = r2131800 * r2131800;
double r2131802 = r2131799 + r2131801;
double r2131803 = r2131797 - r2131802;
double r2131804 = r2131796 * r2131803;
double r2131805 = c;
double r2131806 = r2131793 * r2131798;
double r2131807 = r2131805 - r2131806;
double r2131808 = r2131807 * r2131807;
double r2131809 = r2131804 + r2131808;
return r2131809;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 1.7

$\left(c - a \cdot b\right) \cdot \left(c - a \cdot b\right) - \left(4 \cdot \left(1 - a \cdot a\right)\right) \cdot \left(\left(d - b \cdot b\right) - R \cdot R\right)$
2. Simplified1.7

$\leadsto \color{blue}{\left(-4 - a \cdot \left(-4 \cdot a\right)\right) \cdot \left(d - \left(b \cdot b + R \cdot R\right)\right) + \left(c - b \cdot a\right) \cdot \left(c - b \cdot a\right)}$
3. Using strategy rm
4. Applied +-commutative1.7

$\leadsto \color{blue}{\left(c - b \cdot a\right) \cdot \left(c - b \cdot a\right) + \left(-4 - a \cdot \left(-4 \cdot a\right)\right) \cdot \left(d - \left(b \cdot b + R \cdot R\right)\right)}$
5. Final simplification1.7

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

# Reproduce

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