\[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re - im \cdot im} + re\right)}\]
Test:
math.sqrt on complex, imaginary part, im greater than 0 branch
Bits:
128 bits
Bits error versus re
Bits error versus im
Time: 13.4 s
Input Error: 13.8
Output Error: 0.5
Log:
Profile: 🕒
\(0.5 \cdot \sqrt{2.0 \cdot (\left(\sqrt{re + im}\right) * \left(\sqrt{re - im}\right) + re)_*}\)
  1. Started with
    \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re - im \cdot im} + re\right)}\]
    13.8
  2. Using strategy rm
    13.8
  3. Applied square-unmult to get
    \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re - \color{red}{im \cdot im}} + re\right)} \leadsto 0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re - \color{blue}{{im}^2}} + re\right)}\]
    13.8
  4. Applied square-unmult to get
    \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{\color{red}{re \cdot re} - {im}^2} + re\right)} \leadsto 0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{\color{blue}{{re}^2} - {im}^2} + re\right)}\]
    13.8
  5. Applied difference-of-squares to get
    \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{\color{red}{{re}^2 - {im}^2}} + re\right)} \leadsto 0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{\color{blue}{\left(re + im\right) \cdot \left(re - im\right)}} + re\right)}\]
    13.8
  6. Applied sqrt-prod to get
    \[0.5 \cdot \sqrt{2.0 \cdot \left(\color{red}{\sqrt{\left(re + im\right) \cdot \left(re - im\right)}} + re\right)} \leadsto 0.5 \cdot \sqrt{2.0 \cdot \left(\color{blue}{\sqrt{re + im} \cdot \sqrt{re - im}} + re\right)}\]
    0.5
  7. Applied fma-def to get
    \[0.5 \cdot \sqrt{2.0 \cdot \color{red}{\left(\sqrt{re + im} \cdot \sqrt{re - im} + re\right)}} \leadsto 0.5 \cdot \sqrt{2.0 \cdot \color{blue}{(\left(\sqrt{re + im}\right) * \left(\sqrt{re - im}\right) + re)_*}}\]
    0.5

  8. Removed slow pow expressions

Original test:


(lambda ((re default) (im default))
  #:name "math.sqrt on complex, imaginary part, im greater than 0 branch"
  (* 0.5 (sqrt (* 2.0 (+ (sqrt (- (* re re) (* im im))) re)))))