\[\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: 12.7 s
Input Error: 26.5
Output Error: 7.0
Log:
Profile: 🕒
\(\begin{cases} \frac{b}{d} & \text{when } d \le -4.038116738229486 \cdot 10^{+128} \\ \frac{a \cdot c + b \cdot d}{{c}^2 + {d}^2} & \text{when } d \le -9.422774984820907 \cdot 10^{-149} \\ \frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c} & \text{when } d \le 1.2564695712199143 \cdot 10^{-66} \\ \frac{a \cdot c + b \cdot d}{{c}^2 + {d}^2} & \text{when } d \le 2.8628520537620805 \cdot 10^{+105} \\ \frac{b}{d} & \text{otherwise} \end{cases}\)

    if d < -4.038116738229486e+128 or 2.8628520537620805e+105 < d

    1. Started with
      \[\frac{a \cdot c + b \cdot d}{{c}^2 + {d}^2}\]
      40.5
    2. Using strategy rm
      40.5
    3. Applied add-exp-log to get
      \[\color{red}{\frac{a \cdot c + b \cdot d}{{c}^2 + {d}^2}} \leadsto \color{blue}{e^{\log \left(\frac{a \cdot c + b \cdot d}{{c}^2 + {d}^2}\right)}}\]
      43.1
    4. Applied taylor to get
      \[e^{\log \left(\frac{a \cdot c + b \cdot d}{{c}^2 + {d}^2}\right)} \leadsto e^{\log b - \log d}\]
      47.1
    5. Taylor expanded around 0 to get
      \[e^{\color{red}{\log b - \log d}} \leadsto e^{\color{blue}{\log b - \log d}}\]
      47.1
    6. Applied simplify to get
      \[e^{\log b - \log d} \leadsto \frac{b}{d}\]
      0

    7. Applied final simplification

    if -4.038116738229486e+128 < d < -9.422774984820907e-149 or 1.2564695712199143e-66 < d < 2.8628520537620805e+105

    1. Started with
      \[\frac{a \cdot c + b \cdot d}{{c}^2 + {d}^2}\]
      16.3

    if -9.422774984820907e-149 < d < 1.2564695712199143e-66

    1. Started with
      \[\frac{a \cdot c + b \cdot d}{{c}^2 + {d}^2}\]
      24.2
    2. Using strategy rm
      24.2
    3. Applied add-cbrt-cube 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}{\sqrt[3]{{\left({c}^2 + {d}^2\right)}^3}}}\]
      41.0
    4. Applied taylor to get
      \[\frac{a \cdot c + b \cdot d}{\sqrt[3]{{\left({c}^2 + {d}^2\right)}^3}} \leadsto \frac{a}{c} + \frac{b \cdot d}{{c}^2}\]
      7.9
    5. Taylor expanded around inf to get
      \[\color{red}{\frac{a}{c} + \frac{b \cdot d}{{c}^2}} \leadsto \color{blue}{\frac{a}{c} + \frac{b \cdot d}{{c}^2}}\]
      7.9
    6. Applied simplify to get
      \[\frac{a}{c} + \frac{b \cdot d}{{c}^2} \leadsto \frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\]
      2.5

    7. Applied final simplification

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