\[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: 3.6 s
Input Error: 37.3
Output Error: 13.4
Log:
Profile: 🕒
\(0.5 \cdot \sqrt{(\left(\sqrt{re^2 + im^2}^*\right) * 2.0 + \left(2.0 \cdot re\right))_*}\)
  1. Started with
    \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\]
    37.3
  2. Applied simplify to get
    \[\color{red}{0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}} \leadsto \color{blue}{0.5 \cdot \sqrt{(\left(\sqrt{re^2 + im^2}^*\right) * 2.0 + \left(2.0 \cdot re\right))_*}}\]
    13.4

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