\[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: 6.0 s
Input Error: 17.7
Output Error: 17.8
Log:
Profile: 🕒
\(0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{{\left(\sqrt[3]{{re}^2 + im \cdot im}\right)}^3} + re\right)}\)
  1. Started with
    \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\]
    17.7
  2. Using strategy rm
    17.7
  3. Applied add-cube-cbrt to get
    \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{\color{red}{re \cdot re + im \cdot im}} + re\right)} \leadsto 0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{\color{blue}{{\left(\sqrt[3]{re \cdot re + im \cdot im}\right)}^3}} + re\right)}\]
    17.8
  4. Applied simplify to get
    \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{{\color{red}{\left(\sqrt[3]{re \cdot re + im \cdot im}\right)}}^3} + re\right)} \leadsto 0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{{\color{blue}{\left(\sqrt[3]{{re}^2 + im \cdot im}\right)}}^3} + re\right)}\]
    17.8

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