Average Error: 0.0 → 0.0
Time: 8.7s
Precision: 64
$\left(\left(a \cdot x + b \cdot x\right) + c \cdot x\right) + d \cdot x$
$x \cdot \left(\left(a + b\right) + \left(c + d\right)\right)$
\left(\left(a \cdot x + b \cdot x\right) + c \cdot x\right) + d \cdot x
x \cdot \left(\left(a + b\right) + \left(c + d\right)\right)
double f(double a, double x, double b, double c, double d) {
double r1036683 = a;
double r1036684 = x;
double r1036685 = r1036683 * r1036684;
double r1036686 = b;
double r1036687 = r1036686 * r1036684;
double r1036688 = r1036685 + r1036687;
double r1036689 = c;
double r1036690 = r1036689 * r1036684;
double r1036691 = r1036688 + r1036690;
double r1036692 = d;
double r1036693 = r1036692 * r1036684;
double r1036694 = r1036691 + r1036693;
return r1036694;
}


double f(double a, double x, double b, double c, double d) {
double r1036695 = x;
double r1036696 = a;
double r1036697 = b;
double r1036698 = r1036696 + r1036697;
double r1036699 = c;
double r1036700 = d;
double r1036701 = r1036699 + r1036700;
double r1036702 = r1036698 + r1036701;
double r1036703 = r1036695 * r1036702;
return r1036703;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 0.0

$\left(\left(a \cdot x + b \cdot x\right) + c \cdot x\right) + d \cdot x$
2. Simplified0.0

$\leadsto \color{blue}{x \cdot \left(\left(a + b\right) + \left(c + d\right)\right)}$
3. Final simplification0.0

$\leadsto x \cdot \left(\left(a + b\right) + \left(c + d\right)\right)$

# Reproduce

herbie shell --seed 1
(FPCore (a x b c d)
:name "a*x+b*x+c*x+d*x"
:precision binary64
(+ (+ (+ (* a x) (* b x)) (* c x)) (* d x)))