\[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\]
Test:
math.sqrt on complex, real part
Bits:
128 bits
Bits error versus re
Bits error versus im
Time: 10.0 s
Input Error: 37.6
Output Error: 39.1
Log:
Profile: 🕒
\(0.5 \cdot e^{\log \left(\sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\right)}\)
  1. Started with
    \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\]
    37.6
  2. Using strategy rm
    37.6
  3. Applied add-exp-log to get
    \[0.5 \cdot \color{red}{\sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}} \leadsto 0.5 \cdot \color{blue}{e^{\log \left(\sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\right)}}\]
    39.1

Original test:


(lambda ((re default) (im default))
  #:name "math.sqrt on complex, real part"
  (* 0.5 (sqrt (* 2.0 (+ (sqrt (+ (* re re) (* im im))) re))))
  #:target
  (if (< re 0) (* 0.5 (* (sqrt 2) (sqrt (/ (sqr im) (- (sqrt (+ (sqr re) (sqr im))) re))))) (* 0.5 (sqrt (* 2.0 (+ (sqrt (+ (* re re) (* im im))) re))))))