\[\frac{a \cdot c + b \cdot d}{{c}^2 + {d}^2}\]
Test:
Complex division, real part
Bits:
128 bits
Bits error versus a
Bits error versus b
Bits error versus c
Bits error versus d
Time: 8.2 s
Input Error: 12.5
Output Error: 5.4
Log:
Profile: 🕒
\(\begin{cases} \frac{c}{d} \cdot \frac{a}{d} + \frac{b}{d} & \text{when } d \le -9.1301655f+27 \\ \frac{b \cdot d}{{\left(\left|d\right|\right)}^2 + {\left(\left|c\right|\right)}^2} + \frac{c \cdot a}{{\left(\left|d\right|\right)}^2 + {\left(\left|c\right|\right)}^2} & \text{when } d \le 3.6376857f+23 \\ \frac{c}{d} \cdot \frac{a}{d} + \frac{b}{d} & \text{otherwise} \end{cases}\)

    if d < -9.1301655f+27 or 3.6376857f+23 < d

    1. Started with
      \[\frac{a \cdot c + b \cdot d}{{c}^2 + {d}^2}\]
      20.9
    2. Using strategy rm
      20.9
    3. Applied add-sqr-sqrt to get
      \[\frac{a \cdot c + b \cdot d}{\color{red}{{c}^2} + {d}^2} \leadsto \frac{a \cdot c + b \cdot d}{\color{blue}{{\left(\sqrt{{c}^2}\right)}^2} + {d}^2}\]
      20.9
    4. Applied simplify to get
      \[\frac{a \cdot c + b \cdot d}{{\color{red}{\left(\sqrt{{c}^2}\right)}}^2 + {d}^2} \leadsto \frac{a \cdot c + b \cdot d}{{\color{blue}{\left(\left|c\right|\right)}}^2 + {d}^2}\]
      20.9
    5. Applied taylor to get
      \[\frac{a \cdot c + b \cdot d}{{\left(\left|c\right|\right)}^2 + {d}^2} \leadsto \frac{c \cdot a}{{d}^2} + \frac{b}{d}\]
      5.8
    6. Taylor expanded around inf to get
      \[\color{red}{\frac{c \cdot a}{{d}^2} + \frac{b}{d}} \leadsto \color{blue}{\frac{c \cdot a}{{d}^2} + \frac{b}{d}}\]
      5.8
    7. Applied taylor to get
      \[\frac{c \cdot a}{{d}^2} + \frac{b}{d} \leadsto \frac{c \cdot a}{{d}^2} + \frac{b}{d}\]
      5.8
    8. Taylor expanded around 0 to get
      \[\frac{c \cdot a}{\color{red}{{d}^2}} + \frac{b}{d} \leadsto \frac{c \cdot a}{\color{blue}{{d}^2}} + \frac{b}{d}\]
      5.8
    9. Applied simplify to get
      \[\frac{c \cdot a}{{d}^2} + \frac{b}{d} \leadsto \frac{c}{d} \cdot \frac{a}{d} + \frac{b}{d}\]
      0.2

    10. Applied final simplification

    if -9.1301655f+27 < d < 3.6376857f+23

    1. Started with
      \[\frac{a \cdot c + b \cdot d}{{c}^2 + {d}^2}\]
      10.7
    2. Using strategy rm
      10.7
    3. Applied add-sqr-sqrt to get
      \[\frac{a \cdot c + b \cdot d}{\color{red}{{c}^2} + {d}^2} \leadsto \frac{a \cdot c + b \cdot d}{\color{blue}{{\left(\sqrt{{c}^2}\right)}^2} + {d}^2}\]
      10.7
    4. Applied simplify to get
      \[\frac{a \cdot c + b \cdot d}{{\color{red}{\left(\sqrt{{c}^2}\right)}}^2 + {d}^2} \leadsto \frac{a \cdot c + b \cdot d}{{\color{blue}{\left(\left|c\right|\right)}}^2 + {d}^2}\]
      8.2
    5. Using strategy rm
      8.2
    6. Applied add-sqr-sqrt to get
      \[\frac{a \cdot c + b \cdot d}{{\left(\left|c\right|\right)}^2 + \color{red}{{d}^2}} \leadsto \frac{a \cdot c + b \cdot d}{{\left(\left|c\right|\right)}^2 + \color{blue}{{\left(\sqrt{{d}^2}\right)}^2}}\]
      8.2
    7. Applied simplify to get
      \[\frac{a \cdot c + b \cdot d}{{\left(\left|c\right|\right)}^2 + {\color{red}{\left(\sqrt{{d}^2}\right)}}^2} \leadsto \frac{a \cdot c + b \cdot d}{{\left(\left|c\right|\right)}^2 + {\color{blue}{\left(\left|d\right|\right)}}^2}\]
      6.5
    8. Applied taylor to get
      \[\frac{a \cdot c + b \cdot d}{{\left(\left|c\right|\right)}^2 + {\left(\left|d\right|\right)}^2} \leadsto \frac{b \cdot d}{{\left(\left|d\right|\right)}^2 + {\left(\left|c\right|\right)}^2} + \frac{c \cdot a}{{\left(\left|d\right|\right)}^2 + {\left(\left|c\right|\right)}^2}\]
      6.5
    9. Taylor expanded around 0 to get
      \[\color{red}{\frac{b \cdot d}{{\left(\left|d\right|\right)}^2 + {\left(\left|c\right|\right)}^2} + \frac{c \cdot a}{{\left(\left|d\right|\right)}^2 + {\left(\left|c\right|\right)}^2}} \leadsto \color{blue}{\frac{b \cdot d}{{\left(\left|d\right|\right)}^2 + {\left(\left|c\right|\right)}^2} + \frac{c \cdot a}{{\left(\left|d\right|\right)}^2 + {\left(\left|c\right|\right)}^2}}\]
      6.5

  1. Removed slow pow expressions

Original test:


(lambda ((a default) (b default) (c default) (d default))
  #:name "Complex division, real part"
  (/ (+ (* a c) (* b d)) (+ (sqr c) (sqr d)))
  #:target
  (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))