Average Error: 23.6 → 16.3
Time: 37.7s
Precision: 64
Internal Precision: 2624
\[\sqrt{0.5 \cdot \left(1 + \frac{s}{\sqrt{p \cdot p + {s}^{2}}}\right)}\]
\[\begin{array}{l} \mathbf{if}\;\sqrt{0.5} + \frac{\sqrt{0.5}}{\frac{p}{s}} \cdot \left(\frac{1}{2} - \frac{\frac{1}{8}}{p} \cdot s\right) \le 0.6992373636850905:\\ \;\;\;\;\sqrt{0.5 + 0.5}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5} + \frac{\sqrt{0.5}}{\frac{p}{s}} \cdot \left(\frac{1}{2} - \frac{\frac{1}{8}}{p} \cdot s\right)\\ \end{array}\]

Error

Bits error versus s

Bits error versus p

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (+ (sqrt 0.5) (* (/ (sqrt 0.5) (/ p s)) (- 1/2 (* (/ 1/8 p) s)))) < 0.6992373636850905

    1. Initial program 42.6

      \[\sqrt{0.5 \cdot \left(1 + \frac{s}{\sqrt{p \cdot p + {s}^{2}}}\right)}\]
    2. Taylor expanded around 0 31.4

      \[\leadsto \sqrt{0.5 \cdot \left(1 + \frac{s}{\color{blue}{s}}\right)}\]
    3. Applied simplify31.4

      \[\leadsto \color{blue}{\sqrt{0.5 + 0.5}}\]

    if 0.6992373636850905 < (+ (sqrt 0.5) (* (/ (sqrt 0.5) (/ p s)) (- 1/2 (* (/ 1/8 p) s))))

    1. Initial program 4.0

      \[\sqrt{0.5 \cdot \left(1 + \frac{s}{\sqrt{p \cdot p + {s}^{2}}}\right)}\]
    2. Using strategy rm
    3. Applied add-log-exp4.0

      \[\leadsto \sqrt{0.5 \cdot \color{blue}{\log \left(e^{1 + \frac{s}{\sqrt{p \cdot p + {s}^{2}}}}\right)}}\]
    4. Taylor expanded around inf 8.4

      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \frac{\sqrt{0.5} \cdot s}{p} + \sqrt{0.5}\right) - \frac{1}{8} \cdot \frac{\sqrt{0.5} \cdot {s}^{2}}{{p}^{2}}}\]
    5. Applied simplify0.8

      \[\leadsto \color{blue}{\sqrt{0.5} + \frac{\sqrt{0.5}}{\frac{p}{s}} \cdot \left(\frac{1}{2} - \frac{\frac{1}{8}}{p} \cdot s\right)}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 37.7s)Debug log

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)' 
(FPCore (s p)
  :name "sqrt( 0.5*(1+s/sqrt(p*p + s^2)))"
  (sqrt (* 0.5 (+ 1 (/ s (sqrt (+ (* p p) (pow s 2))))))))