Average Error: 32.6 → 19.6
Time: 16.0s
Precision: 64
Internal Precision: 320
\[\sqrt{\left(vect0 \cdot vect0 + vect1 \cdot vect1\right) + vect2 \cdot vec2}\]
\[\begin{array}{l} \mathbf{if}\;vect0 \le -1.1966703258969599 \cdot 10^{+141}:\\ \;\;\;\;\left(-vect0\right) + \left(-\frac{1}{2}\right) \cdot \frac{vect2 \cdot vec2}{vect0}\\ \mathbf{elif}\;vect0 \le 6.423566321171272 \cdot 10^{+131}:\\ \;\;\;\;\sqrt{vect2 \cdot vec2 + \left(vect0 \cdot vect0 + vect1 \cdot vect1\right)}\\ \mathbf{else}:\\ \;\;\;\;vect0 + \frac{vect2 \cdot vec2}{vect0} \cdot \frac{1}{2}\\ \end{array}\]

Error

Bits error versus vect0

Bits error versus vect1

Bits error versus vect2

Bits error versus vec2

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if vect0 < -1.1966703258969599e+141

    1. Initial program 55.8

      \[\sqrt{\left(vect0 \cdot vect0 + vect1 \cdot vect1\right) + vect2 \cdot vec2}\]
    2. Taylor expanded around -inf 13.8

      \[\leadsto \color{blue}{-\left(\frac{1}{2} \cdot \frac{vect2 \cdot vec2}{vect0} + vect0\right)}\]

    if -1.1966703258969599e+141 < vect0 < 6.423566321171272e+131

    1. Initial program 22.0

      \[\sqrt{\left(vect0 \cdot vect0 + vect1 \cdot vect1\right) + vect2 \cdot vec2}\]

    if 6.423566321171272e+131 < vect0

    1. Initial program 53.8

      \[\sqrt{\left(vect0 \cdot vect0 + vect1 \cdot vect1\right) + vect2 \cdot vec2}\]
    2. Taylor expanded around inf 15.1

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{vect2 \cdot vec2}{vect0} + vect0}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification19.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;vect0 \le -1.1966703258969599 \cdot 10^{+141}:\\ \;\;\;\;\left(-vect0\right) + \left(-\frac{1}{2}\right) \cdot \frac{vect2 \cdot vec2}{vect0}\\ \mathbf{elif}\;vect0 \le 6.423566321171272 \cdot 10^{+131}:\\ \;\;\;\;\sqrt{vect2 \cdot vec2 + \left(vect0 \cdot vect0 + vect1 \cdot vect1\right)}\\ \mathbf{else}:\\ \;\;\;\;vect0 + \frac{vect2 \cdot vec2}{vect0} \cdot \frac{1}{2}\\ \end{array}\]

Runtime

Time bar (total: 16.0s)Debug log

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)' 
(FPCore (vect0 vect1 vect2 vec2)
  :name "sqrt( vect0 * vect0 + vect1 * vect1 + vect2 * vec2)"
  (sqrt (+ (+ (* vect0 vect0) (* vect1 vect1)) (* vect2 vec2))))