\[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: 29.9 s
Input Error: 37.6
Output Error: 39.2
Log:
Profile: 🕒
\(0.5 \cdot {e}^{\left(\log \left(\sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\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
  4. Using strategy rm
    39.1
  5. Applied pow1 to get
    \[0.5 \cdot e^{\log \color{red}{\left(\sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\right)}} \leadsto 0.5 \cdot e^{\log \color{blue}{\left({\left(\sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\right)}^{1}\right)}}\]
    39.1
  6. Applied log-pow to get
    \[0.5 \cdot e^{\color{red}{\log \left({\left(\sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\right)}^{1}\right)}} \leadsto 0.5 \cdot e^{\color{blue}{1 \cdot \log \left(\sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\right)}}\]
    39.1
  7. Applied exp-prod to get
    \[0.5 \cdot \color{red}{e^{1 \cdot \log \left(\sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\right)}} \leadsto 0.5 \cdot \color{blue}{{\left(e^{1}\right)}^{\left(\log \left(\sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\right)\right)}}\]
    39.2
  8. Applied simplify to get
    \[0.5 \cdot {\color{red}{\left(e^{1}\right)}}^{\left(\log \left(\sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\right)\right)} \leadsto 0.5 \cdot {\color{blue}{e}}^{\left(\log \left(\sqrt{2.0 \cdot \left(\sqrt{re \cdot re + im \cdot im} + re\right)}\right)\right)}\]
    39.2

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