Average Error: 14.1 → 13.6
Time: 13.2s
Precision: 64
$\frac{x}{\sqrt{\left(ax \cdot bx + ay \cdot by\right) + az \cdot bz}}$
$\begin{array}{l} \mathbf{if}\;\left(ax \cdot bx + ay \cdot by\right) + az \cdot bz \le 5.83879077299842085360192047398438969666 \cdot 10^{304}:\\ \;\;\;\;\frac{x}{\sqrt{\left(ax \cdot bx + ay \cdot by\right) + az \cdot bz}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}$
\frac{x}{\sqrt{\left(ax \cdot bx + ay \cdot by\right) + az \cdot bz}}
\begin{array}{l}
\mathbf{if}\;\left(ax \cdot bx + ay \cdot by\right) + az \cdot bz \le 5.83879077299842085360192047398438969666 \cdot 10^{304}:\\
\;\;\;\;\frac{x}{\sqrt{\left(ax \cdot bx + ay \cdot by\right) + az \cdot bz}}\\

\mathbf{else}:\\
\;\;\;\;0\\

\end{array}
double f(double x, double ax, double bx, double ay, double by, double az, double bz) {
double r2201143 = x;
double r2201144 = ax;
double r2201145 = bx;
double r2201146 = r2201144 * r2201145;
double r2201147 = ay;
double r2201148 = by;
double r2201149 = r2201147 * r2201148;
double r2201150 = r2201146 + r2201149;
double r2201151 = az;
double r2201152 = bz;
double r2201153 = r2201151 * r2201152;
double r2201154 = r2201150 + r2201153;
double r2201155 = sqrt(r2201154);
double r2201156 = r2201143 / r2201155;
return r2201156;
}


double f(double x, double ax, double bx, double ay, double by, double az, double bz) {
double r2201157 = ax;
double r2201158 = bx;
double r2201159 = r2201157 * r2201158;
double r2201160 = ay;
double r2201161 = by;
double r2201162 = r2201160 * r2201161;
double r2201163 = r2201159 + r2201162;
double r2201164 = az;
double r2201165 = bz;
double r2201166 = r2201164 * r2201165;
double r2201167 = r2201163 + r2201166;
double r2201168 = 5.838790772998421e+304;
bool r2201169 = r2201167 <= r2201168;
double r2201170 = x;
double r2201171 = sqrt(r2201167);
double r2201172 = r2201170 / r2201171;
double r2201173 = 0.0;
double r2201174 = r2201169 ? r2201172 : r2201173;
return r2201174;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if (+ (+ (* ax bx) (* ay by)) (* az bz)) < 5.838790772998421e+304

1. Initial program 0.3

$\frac{x}{\sqrt{\left(ax \cdot bx + ay \cdot by\right) + az \cdot bz}}$

## if 5.838790772998421e+304 < (+ (+ (* ax bx) (* ay by)) (* az bz))

1. Initial program 42.1

$\frac{x}{\sqrt{\left(ax \cdot bx + ay \cdot by\right) + az \cdot bz}}$
2. Taylor expanded around 0 40.6

$\leadsto \color{blue}{0}$
3. Recombined 2 regimes into one program.
4. Final simplification13.6

$\leadsto \begin{array}{l} \mathbf{if}\;\left(ax \cdot bx + ay \cdot by\right) + az \cdot bz \le 5.83879077299842085360192047398438969666 \cdot 10^{304}:\\ \;\;\;\;\frac{x}{\sqrt{\left(ax \cdot bx + ay \cdot by\right) + az \cdot bz}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (x ax bx ay by az bz)
:name "x / sqrt(ax * bx + ay * by + az * bz)"
:precision binary64
(/ x (sqrt (+ (+ (* ax bx) (* ay by)) (* az bz)))))