Average Error: 6.5 → 3.5
Time: 15.0s
Precision: 64
$\left(\left(s \cdot \left(s - a\right)\right) \cdot \left(s - b\right)\right) \cdot \left(s - c\right)$
$\begin{array}{l} \mathbf{if}\;b \le -1.785477458830186796358063194334265971034 \cdot 10^{67} \lor \neg \left(b \le 6.406456317984153368872861150293274157264 \cdot 10^{-9}\right):\\ \;\;\;\;s \cdot \left(\left(s \cdot \left(s - a\right)\right) \cdot \left(s - b\right)\right) + \left(a \cdot \left(b \cdot s\right) - \left(s \cdot s\right) \cdot \left(a + b\right)\right) \cdot \left(-c\right)\\ \mathbf{else}:\\ \;\;\;\;\left(s \cdot \left(s - a\right)\right) \cdot \left(\left(s - b\right) \cdot \left(s - c\right)\right)\\ \end{array}$
\left(\left(s \cdot \left(s - a\right)\right) \cdot \left(s - b\right)\right) \cdot \left(s - c\right)
\begin{array}{l}
\mathbf{if}\;b \le -1.785477458830186796358063194334265971034 \cdot 10^{67} \lor \neg \left(b \le 6.406456317984153368872861150293274157264 \cdot 10^{-9}\right):\\
\;\;\;\;s \cdot \left(\left(s \cdot \left(s - a\right)\right) \cdot \left(s - b\right)\right) + \left(a \cdot \left(b \cdot s\right) - \left(s \cdot s\right) \cdot \left(a + b\right)\right) \cdot \left(-c\right)\\

\mathbf{else}:\\
\;\;\;\;\left(s \cdot \left(s - a\right)\right) \cdot \left(\left(s - b\right) \cdot \left(s - c\right)\right)\\

\end{array}
double f(double s, double a, double b, double c) {
double r1606103 = s;
double r1606104 = a;
double r1606105 = r1606103 - r1606104;
double r1606106 = r1606103 * r1606105;
double r1606107 = b;
double r1606108 = r1606103 - r1606107;
double r1606109 = r1606106 * r1606108;
double r1606110 = c;
double r1606111 = r1606103 - r1606110;
double r1606112 = r1606109 * r1606111;
return r1606112;
}


double f(double s, double a, double b, double c) {
double r1606113 = b;
double r1606114 = -1.7854774588301868e+67;
bool r1606115 = r1606113 <= r1606114;
double r1606116 = 6.406456317984153e-09;
bool r1606117 = r1606113 <= r1606116;
double r1606118 = !r1606117;
bool r1606119 = r1606115 || r1606118;
double r1606120 = s;
double r1606121 = a;
double r1606122 = r1606120 - r1606121;
double r1606123 = r1606120 * r1606122;
double r1606124 = r1606120 - r1606113;
double r1606125 = r1606123 * r1606124;
double r1606126 = r1606120 * r1606125;
double r1606127 = r1606113 * r1606120;
double r1606128 = r1606121 * r1606127;
double r1606129 = r1606120 * r1606120;
double r1606130 = r1606121 + r1606113;
double r1606131 = r1606129 * r1606130;
double r1606132 = r1606128 - r1606131;
double r1606133 = c;
double r1606134 = -r1606133;
double r1606135 = r1606132 * r1606134;
double r1606136 = r1606126 + r1606135;
double r1606137 = r1606120 - r1606133;
double r1606138 = r1606124 * r1606137;
double r1606139 = r1606123 * r1606138;
double r1606140 = r1606119 ? r1606136 : r1606139;
return r1606140;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if b < -1.7854774588301868e+67 or 6.406456317984153e-09 < b

1. Initial program 9.3

$\left(\left(s \cdot \left(s - a\right)\right) \cdot \left(s - b\right)\right) \cdot \left(s - c\right)$
2. Using strategy rm
3. Applied sub-neg9.3

$\leadsto \left(\left(s \cdot \left(s - a\right)\right) \cdot \left(s - b\right)\right) \cdot \color{blue}{\left(s + \left(-c\right)\right)}$
4. Applied distribute-rgt-in9.3

$\leadsto \color{blue}{s \cdot \left(\left(s \cdot \left(s - a\right)\right) \cdot \left(s - b\right)\right) + \left(-c\right) \cdot \left(\left(s \cdot \left(s - a\right)\right) \cdot \left(s - b\right)\right)}$
5. Simplified9.3

$\leadsto s \cdot \left(\left(s \cdot \left(s - a\right)\right) \cdot \left(s - b\right)\right) + \color{blue}{\left(\left(s \cdot \left(s - a\right)\right) \cdot \left(s - b\right)\right) \cdot \left(-c\right)}$
6. Taylor expanded around inf 5.3

$\leadsto s \cdot \left(\left(s \cdot \left(s - a\right)\right) \cdot \left(s - b\right)\right) + \color{blue}{\left(a \cdot \left(b \cdot s\right) - \left(a \cdot {s}^{2} + b \cdot {s}^{2}\right)\right)} \cdot \left(-c\right)$
7. Simplified5.3

$\leadsto s \cdot \left(\left(s \cdot \left(s - a\right)\right) \cdot \left(s - b\right)\right) + \color{blue}{\left(a \cdot \left(b \cdot s\right) - \left(s \cdot s\right) \cdot \left(a + b\right)\right)} \cdot \left(-c\right)$

## if -1.7854774588301868e+67 < b < 6.406456317984153e-09

1. Initial program 4.7

$\left(\left(s \cdot \left(s - a\right)\right) \cdot \left(s - b\right)\right) \cdot \left(s - c\right)$
2. Using strategy rm
3. Applied associate-*l*2.2

$\leadsto \color{blue}{\left(s \cdot \left(s - a\right)\right) \cdot \left(\left(s - b\right) \cdot \left(s - c\right)\right)}$
3. Recombined 2 regimes into one program.
4. Final simplification3.5

$\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.785477458830186796358063194334265971034 \cdot 10^{67} \lor \neg \left(b \le 6.406456317984153368872861150293274157264 \cdot 10^{-9}\right):\\ \;\;\;\;s \cdot \left(\left(s \cdot \left(s - a\right)\right) \cdot \left(s - b\right)\right) + \left(a \cdot \left(b \cdot s\right) - \left(s \cdot s\right) \cdot \left(a + b\right)\right) \cdot \left(-c\right)\\ \mathbf{else}:\\ \;\;\;\;\left(s \cdot \left(s - a\right)\right) \cdot \left(\left(s - b\right) \cdot \left(s - c\right)\right)\\ \end{array}$

# Reproduce

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