Average Error: 29.6 → 0.2
Time: 1.6m
Precision: 64
Internal Precision: 4224
\[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re - im \cdot im} + re\right)}\]
\[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re + im} \cdot \sqrt{re - im} + re\right)}\]

Error

Bits error versus re

Bits error versus im

Derivation

  1. Initial program 29.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-squares29.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.2

    \[\leadsto 0.5 \cdot \sqrt{2.0 \cdot \left(\color{blue}{\sqrt{re + im} \cdot \sqrt{re - im}} + re\right)}\]
  5. Removed slow pow expressions.

Runtime

Time bar (total: 1.6m)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(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)))))