(FPCore (a b c d)
:precision binary64
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
↓
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ 1.0 (hypot c d))) (t_1 (/ (hypot c d) c)))
(if (<= d -1.65e+172)
(+ (/ b d) (/ c (/ d (/ a d))))
(if (<= d 1.72e+121)
(* t_0 (+ (/ (* d b) (hypot c d)) (/ a t_1)))
(* t_0 (+ b (/ a (pow (cbrt t_1) 3.0))))))))
double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
(*.f64 (/.f64 1 (hypot.f64 c d)) (+.f64 (/.f64 (*.f64 d b) (hypot.f64 c d)) (/.f64 a (/.f64 (hypot.f64 c d) c)))): 0 points increase in error, 0 points decrease in error
(*.f64 (/.f64 1 (hypot.f64 c d)) (+.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 b d)) (hypot.f64 c d)) (/.f64 a (/.f64 (hypot.f64 c d) c)))): 0 points increase in error, 0 points decrease in error
(*.f64 (/.f64 1 (hypot.f64 c d)) (+.f64 (/.f64 (*.f64 b d) (hypot.f64 c d)) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 a c) (hypot.f64 c d))))): 0 points increase in error, 0 points decrease in error
(*.f64 (/.f64 1 (hypot.f64 c d)) (Rewrite<= +-commutative_binary64 (+.f64 (/.f64 (*.f64 a c) (hypot.f64 c d)) (/.f64 (*.f64 b d) (hypot.f64 c d))))): 4 points increase in error, 0 points decrease in error
(*.f64 (/.f64 1 (hypot.f64 c d)) (+.f64 (/.f64 (*.f64 d b) (hypot.f64 c d)) (/.f64 a (/.f64 (hypot.f64 c d) c)))): 0 points increase in error, 0 points decrease in error
(*.f64 (/.f64 1 (hypot.f64 c d)) (+.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 b d)) (hypot.f64 c d)) (/.f64 a (/.f64 (hypot.f64 c d) c)))): 0 points increase in error, 0 points decrease in error
(*.f64 (/.f64 1 (hypot.f64 c d)) (+.f64 (/.f64 (*.f64 b d) (hypot.f64 c d)) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 a c) (hypot.f64 c d))))): 0 points increase in error, 0 points decrease in error
(*.f64 (/.f64 1 (hypot.f64 c d)) (Rewrite<= +-commutative_binary64 (+.f64 (/.f64 (*.f64 a c) (hypot.f64 c d)) (/.f64 (*.f64 b d) (hypot.f64 c d))))): 4 points increase in error, 0 points decrease in error
if 1.7200000000000001e121 < d
Initial program 40.8
\[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\]
(*.f64 (/.f64 1 (hypot.f64 c d)) (+.f64 (/.f64 (*.f64 d b) (hypot.f64 c d)) (/.f64 a (/.f64 (hypot.f64 c d) c)))): 0 points increase in error, 0 points decrease in error
(*.f64 (/.f64 1 (hypot.f64 c d)) (+.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 b d)) (hypot.f64 c d)) (/.f64 a (/.f64 (hypot.f64 c d) c)))): 0 points increase in error, 0 points decrease in error
(*.f64 (/.f64 1 (hypot.f64 c d)) (+.f64 (/.f64 (*.f64 b d) (hypot.f64 c d)) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 a c) (hypot.f64 c d))))): 0 points increase in error, 0 points decrease in error
(*.f64 (/.f64 1 (hypot.f64 c d)) (Rewrite<= +-commutative_binary64 (+.f64 (/.f64 (*.f64 a c) (hypot.f64 c d)) (/.f64 (*.f64 b d) (hypot.f64 c d))))): 4 points increase in error, 0 points decrease in error
herbie shell --seed 2022343
(FPCore (a b c d)
:name "Complex division, real part"
:precision binary64
:herbie-target
(if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d)))))
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))