\[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: 10.4 s
Input Error: 41.7
Output Error: 0.0
Log:
Profile: 🕒
\(\begin{cases} 0.5 \cdot \sqrt{2.0 \cdot \left(-1 \cdot re + re\right)} & \text{when } re \le 6.238827037309083 \cdot 10^{-295} \\ 0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re + im} \cdot \sqrt{re - im} + re\right)} & \text{otherwise} \end{cases}\)

    if re < 6.238827037309083e-295

    1. Started with
      \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re - im \cdot im} + re\right)}\]
      48.1
    2. Applied taylor to get
      \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re - im \cdot im} + re\right)} \leadsto 0.5 \cdot \sqrt{2.0 \cdot \left(-1 \cdot re + re\right)}\]
      0
    3. Taylor expanded around -inf to get
      \[0.5 \cdot \sqrt{2.0 \cdot \left(\color{red}{-1 \cdot re} + re\right)} \leadsto 0.5 \cdot \sqrt{2.0 \cdot \left(\color{blue}{-1 \cdot re} + re\right)}\]
      0

    if 6.238827037309083e-295 < re

    1. Started with
      \[0.5 \cdot \sqrt{2.0 \cdot \left(\sqrt{re \cdot re - im \cdot im} + re\right)}\]
      29.3
    2. Using strategy rm
      29.3
    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.3
    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.3
    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.3
    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

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