\[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: 16.7 s
Input Error: 29.8
Output Error: 0.1
Log:
Profile: 🕒
\(0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re + im} \cdot \sqrt{re - im} + re\right)}\)
  1. Started with
    \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re - im \cdot im} + re\right)}\]
    29.8
  2. Using strategy rm
    29.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)}\]
    29.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)}\]
    29.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)}\]
    29.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.1

  7. 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)))))