Average Error: 24.7 → 5.0
Time: 16.5s
Precision: 64
${\left(\frac{s1}{n1} - \frac{s2}{n2}\right)}^{2} \cdot \left(n1 \cdot n2\right)$
$\left(n2 \cdot s1 - s2 \cdot n1\right) \cdot \left(\frac{s1}{n1} - \frac{s2}{n2}\right)$
{\left(\frac{s1}{n1} - \frac{s2}{n2}\right)}^{2} \cdot \left(n1 \cdot n2\right)
\left(n2 \cdot s1 - s2 \cdot n1\right) \cdot \left(\frac{s1}{n1} - \frac{s2}{n2}\right)
double f(double s1, double n1, double s2, double n2) {
double r18273884 = s1;
double r18273885 = n1;
double r18273886 = r18273884 / r18273885;
double r18273887 = s2;
double r18273888 = n2;
double r18273889 = r18273887 / r18273888;
double r18273890 = r18273886 - r18273889;
double r18273891 = 2.0;
double r18273892 = pow(r18273890, r18273891);
double r18273893 = r18273885 * r18273888;
double r18273894 = r18273892 * r18273893;
return r18273894;
}


double f(double s1, double n1, double s2, double n2) {
double r18273895 = n2;
double r18273896 = s1;
double r18273897 = r18273895 * r18273896;
double r18273898 = s2;
double r18273899 = n1;
double r18273900 = r18273898 * r18273899;
double r18273901 = r18273897 - r18273900;
double r18273902 = r18273896 / r18273899;
double r18273903 = r18273898 / r18273895;
double r18273904 = r18273902 - r18273903;
double r18273905 = r18273901 * r18273904;
return r18273905;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 24.7

${\left(\frac{s1}{n1} - \frac{s2}{n2}\right)}^{2} \cdot \left(n1 \cdot n2\right)$
2. Simplified24.7

$\leadsto \color{blue}{\left(n1 \cdot n2\right) \cdot \left(\left(\frac{s1}{n1} - \frac{s2}{n2}\right) \cdot \left(\frac{s1}{n1} - \frac{s2}{n2}\right)\right)}$
3. Using strategy rm
4. Applied associate-*r*15.5

$\leadsto \color{blue}{\left(\left(n1 \cdot n2\right) \cdot \left(\frac{s1}{n1} - \frac{s2}{n2}\right)\right) \cdot \left(\frac{s1}{n1} - \frac{s2}{n2}\right)}$
5. Taylor expanded around -inf 5.0

$\leadsto \color{blue}{\left(s1 \cdot n2 - s2 \cdot n1\right)} \cdot \left(\frac{s1}{n1} - \frac{s2}{n2}\right)$
6. Final simplification5.0

$\leadsto \left(n2 \cdot s1 - s2 \cdot n1\right) \cdot \left(\frac{s1}{n1} - \frac{s2}{n2}\right)$

# Reproduce

herbie shell --seed 1
(FPCore (s1 n1 s2 n2)
:name "pow(s1/n1-s2/n2,2) *(n1*n2)"
(* (pow (- (/ s1 n1) (/ s2 n2)) 2) (* n1 n2)))