Average Error: 42.7 → 0.0
Time: 56.0s
Precision: 64
Internal Precision: 4224
\[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re - im \cdot im} + re\right)}\]
\[\begin{array}{l} \mathbf{if}\;re \le 1.470483924151545 \cdot 10^{-276}:\\ \;\;\;\;0.5 \cdot \sqrt{2.0 \cdot \left(-1 \cdot re + re\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re + im} \cdot \sqrt{re - im} + re\right)}\\ \end{array}\]

Error

Bits error versus re

Bits error versus im

Derivation

  1. Split input into 2 regimes
  2. if re < 1.470483924151545e-276

    1. Initial program 48.6

      \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re - im \cdot im} + re\right)}\]
    2. Taylor expanded around -inf 0

      \[\leadsto 0.5 \cdot \sqrt{2.0 \cdot \left(\color{blue}{-1 \cdot re} + re\right)}\]

    if 1.470483924151545e-276 < re

    1. Initial program 30.6

      \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re - im \cdot im} + re\right)}\]
    2. Using strategy rm
    3. Applied difference-of-squares30.6

      \[\leadsto 0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{\color{blue}{\left(re + im\right) \cdot \left(re - im\right)}} + re\right)}\]
    4. Applied sqrt-prod0.1

      \[\leadsto 0.5 \cdot \sqrt{2.0 \cdot \left(\color{blue}{\sqrt{re + im} \cdot \sqrt{re - im}} + re\right)}\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 56.0s)Debug logProfile

herbie shell --seed '#(1062930989 876886121 3990119081 3032829768 3060892583 1929069376)' 
(FPCore (re im)
  :name "math.sqrt on complex, imaginary part, im greater than 0 branch"
  (* 0.5 (sqrt (* 2.0 (+ (sqrt (- (* re re) (* im im))) re)))))