Complex division, imag part

Percentage Accurate: 61.0% → 89.1%
Time: 8.6s
Alternatives: 9
Speedup: 5.0×

Specification

?
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]

Your Program's Arguments

Results

Enter valid numbers for all inputs

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Alternative 1: 89.1% accurate, 0.1× speedup?

\[\begin{array}{l} t_0 := b \cdot c - a \cdot d\\ \mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+297}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \frac{a}{d}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2e297

    1. Initial program 80.6%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. *-un-lft-identity80.6%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt80.6%

        \[\leadsto \frac{1 \cdot \left(b \cdot c - a \cdot d\right)}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. times-frac80.6%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}} \]
      4. hypot-def80.6%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
      5. hypot-def96.6%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
    3. Applied egg-rr96.6%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}} \]

    if 2e297 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 9.1%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub2.2%

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. *-un-lft-identity2.2%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c\right)}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt2.2%

        \[\leadsto \frac{1 \cdot \left(b \cdot c\right)}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac2.2%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg2.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\sqrt{c \cdot c + d \cdot d}}, \frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      6. hypot-def2.2%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      7. hypot-def7.0%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. associate-/l*13.2%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{\frac{a}{\frac{c \cdot c + d \cdot d}{d}}}\right) \]
      9. add-sqr-sqrt13.2%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}{d}}\right) \]
      10. pow213.2%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{\color{blue}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}}{d}}\right) \]
      11. hypot-def13.2%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{{\color{blue}{\left(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}{d}}\right) \]
    3. Applied egg-rr13.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    4. Step-by-step derivation
      1. fma-neg13.2%

        \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)} - \frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}} \]
      2. associate-/l*58.7%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}} - \frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}} \]
      3. associate-/r/58.7%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \color{blue}{\frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot d} \]
      4. *-commutative58.7%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \color{blue}{d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
    5. Simplified58.7%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
    6. Taylor expanded in d around inf 64.7%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \color{blue}{\frac{a}{d}} \]
    7. Step-by-step derivation
      1. sub-neg64.7%

        \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} + \left(-\frac{a}{d}\right)} \]
      2. associate-*l/64.8%

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}}{\mathsf{hypot}\left(c, d\right)}} + \left(-\frac{a}{d}\right) \]
      3. *-un-lft-identity64.8%

        \[\leadsto \frac{\color{blue}{\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}}}{\mathsf{hypot}\left(c, d\right)} + \left(-\frac{a}{d}\right) \]
      4. associate-/r/64.7%

        \[\leadsto \frac{\color{blue}{\frac{b}{\mathsf{hypot}\left(c, d\right)} \cdot c}}{\mathsf{hypot}\left(c, d\right)} + \left(-\frac{a}{d}\right) \]
    8. Applied egg-rr64.7%

      \[\leadsto \color{blue}{\frac{\frac{b}{\mathsf{hypot}\left(c, d\right)} \cdot c}{\mathsf{hypot}\left(c, d\right)} + \left(-\frac{a}{d}\right)} \]
    9. Step-by-step derivation
      1. sub-neg64.7%

        \[\leadsto \color{blue}{\frac{\frac{b}{\mathsf{hypot}\left(c, d\right)} \cdot c}{\mathsf{hypot}\left(c, d\right)} - \frac{a}{d}} \]
      2. associate-/l*64.8%

        \[\leadsto \color{blue}{\frac{\frac{b}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}} - \frac{a}{d} \]
    10. Simplified64.8%

      \[\leadsto \color{blue}{\frac{\frac{b}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \frac{a}{d}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+297}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \frac{a}{d}\\ \end{array} \]

Alternative 2: 82.8% accurate, 0.6× speedup?

\[\begin{array}{l} t_0 := \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{if}\;c \leq -1.05 \cdot 10^{+81}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq -1.45 \cdot 10^{-97}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 2.2 \cdot 10^{-80}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{+69}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \end{array} \]
Derivation
  1. Split input into 4 regimes
  2. if c < -1.0499999999999999e81

    1. Initial program 41.9%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Taylor expanded in c around inf 69.8%

      \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{c}^{2}} + \frac{b}{c}} \]
    3. Step-by-step derivation
      1. +-commutative69.8%

        \[\leadsto \color{blue}{\frac{b}{c} + -1 \cdot \frac{a \cdot d}{{c}^{2}}} \]
      2. mul-1-neg69.8%

        \[\leadsto \frac{b}{c} + \color{blue}{\left(-\frac{a \cdot d}{{c}^{2}}\right)} \]
      3. unsub-neg69.8%

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow269.8%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac84.8%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{c} \cdot \frac{d}{c}} \]
    4. Simplified84.8%

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}} \]
    5. Step-by-step derivation
      1. associate-*l/84.8%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
    6. Applied egg-rr84.8%

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
    7. Step-by-step derivation
      1. sub-div84.8%

        \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]
    8. Applied egg-rr84.8%

      \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]

    if -1.0499999999999999e81 < c < -1.45e-97 or 2.2000000000000001e-80 < c < 6.79999999999999973e69

    1. Initial program 86.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]

    if -1.45e-97 < c < 2.2000000000000001e-80

    1. Initial program 70.2%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. *-un-lft-identity70.2%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt70.2%

        \[\leadsto \frac{1 \cdot \left(b \cdot c - a \cdot d\right)}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. times-frac70.1%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}} \]
      4. hypot-def70.1%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
      5. hypot-def86.6%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
    3. Applied egg-rr86.6%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}} \]
    4. Taylor expanded in c around 0 62.9%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c \cdot b}{d} + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. neg-mul-162.9%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{c \cdot b}{d} + \color{blue}{\left(-a\right)}\right) \]
      2. unsub-neg62.9%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c \cdot b}{d} - a\right)} \]
      3. associate-/l*61.7%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\color{blue}{\frac{c}{\frac{d}{b}}} - a\right) \]
    6. Simplified61.7%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c}{\frac{d}{b}} - a\right)} \]
    7. Taylor expanded in c around 0 90.4%

      \[\leadsto \color{blue}{\frac{1}{d}} \cdot \left(\frac{c}{\frac{d}{b}} - a\right) \]

    if 6.79999999999999973e69 < c

    1. Initial program 42.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Taylor expanded in c around inf 77.1%

      \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{c}^{2}} + \frac{b}{c}} \]
    3. Step-by-step derivation
      1. +-commutative77.1%

        \[\leadsto \color{blue}{\frac{b}{c} + -1 \cdot \frac{a \cdot d}{{c}^{2}}} \]
      2. mul-1-neg77.1%

        \[\leadsto \frac{b}{c} + \color{blue}{\left(-\frac{a \cdot d}{{c}^{2}}\right)} \]
      3. unsub-neg77.1%

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow277.1%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac84.1%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{c} \cdot \frac{d}{c}} \]
    4. Simplified84.1%

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification87.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.05 \cdot 10^{+81}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq -1.45 \cdot 10^{-97}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.2 \cdot 10^{-80}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{+69}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \end{array} \]

Alternative 3: 78.4% accurate, 1.0× speedup?

\[\begin{array}{l} \mathbf{if}\;d \leq -1.75 \cdot 10^{+23} \lor \neg \left(d \leq 50000000000\right):\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if d < -1.7500000000000001e23 or 5e10 < d

    1. Initial program 52.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. *-un-lft-identity52.7%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt52.7%

        \[\leadsto \frac{1 \cdot \left(b \cdot c - a \cdot d\right)}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. times-frac52.7%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}} \]
      4. hypot-def52.7%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
      5. hypot-def65.5%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
    3. Applied egg-rr65.5%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}} \]
    4. Taylor expanded in c around 0 52.1%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c \cdot b}{d} + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. neg-mul-152.1%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{c \cdot b}{d} + \color{blue}{\left(-a\right)}\right) \]
      2. unsub-neg52.1%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c \cdot b}{d} - a\right)} \]
      3. associate-/l*54.1%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\color{blue}{\frac{c}{\frac{d}{b}}} - a\right) \]
    6. Simplified54.1%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c}{\frac{d}{b}} - a\right)} \]
    7. Taylor expanded in c around 0 76.6%

      \[\leadsto \color{blue}{\frac{1}{d}} \cdot \left(\frac{c}{\frac{d}{b}} - a\right) \]

    if -1.7500000000000001e23 < d < 5e10

    1. Initial program 73.1%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Taylor expanded in c around inf 70.9%

      \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{c}^{2}} + \frac{b}{c}} \]
    3. Step-by-step derivation
      1. +-commutative70.9%

        \[\leadsto \color{blue}{\frac{b}{c} + -1 \cdot \frac{a \cdot d}{{c}^{2}}} \]
      2. mul-1-neg70.9%

        \[\leadsto \frac{b}{c} + \color{blue}{\left(-\frac{a \cdot d}{{c}^{2}}\right)} \]
      3. unsub-neg70.9%

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow270.9%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac76.0%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{c} \cdot \frac{d}{c}} \]
    4. Simplified76.0%

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}} \]
    5. Step-by-step derivation
      1. associate-*l/77.4%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
    6. Applied egg-rr77.4%

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
    7. Step-by-step derivation
      1. sub-div79.7%

        \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]
    8. Applied egg-rr79.7%

      \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification78.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.75 \cdot 10^{+23} \lor \neg \left(d \leq 50000000000\right):\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]

Alternative 4: 78.4% accurate, 1.0× speedup?

\[\begin{array}{l} \mathbf{if}\;d \leq -9.6 \cdot 10^{+22}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq 880000:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\ \end{array} \]
Derivation
  1. Split input into 3 regimes
  2. if d < -9.6e22

    1. Initial program 45.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Taylor expanded in c around 0 61.8%

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{c \cdot b}{{d}^{2}}} \]
    3. Step-by-step derivation
      1. +-commutative61.8%

        \[\leadsto \color{blue}{\frac{c \cdot b}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-neg61.8%

        \[\leadsto \frac{c \cdot b}{{d}^{2}} + \color{blue}{\left(-\frac{a}{d}\right)} \]
      3. unsub-neg61.8%

        \[\leadsto \color{blue}{\frac{c \cdot b}{{d}^{2}} - \frac{a}{d}} \]
      4. unpow261.8%

        \[\leadsto \frac{c \cdot b}{\color{blue}{d \cdot d}} - \frac{a}{d} \]
      5. times-frac72.3%

        \[\leadsto \color{blue}{\frac{c}{d} \cdot \frac{b}{d}} - \frac{a}{d} \]
    4. Simplified72.3%

      \[\leadsto \color{blue}{\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}} \]

    if -9.6e22 < d < 8.8e5

    1. Initial program 73.1%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Taylor expanded in c around inf 70.9%

      \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{c}^{2}} + \frac{b}{c}} \]
    3. Step-by-step derivation
      1. +-commutative70.9%

        \[\leadsto \color{blue}{\frac{b}{c} + -1 \cdot \frac{a \cdot d}{{c}^{2}}} \]
      2. mul-1-neg70.9%

        \[\leadsto \frac{b}{c} + \color{blue}{\left(-\frac{a \cdot d}{{c}^{2}}\right)} \]
      3. unsub-neg70.9%

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow270.9%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac76.0%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{c} \cdot \frac{d}{c}} \]
    4. Simplified76.0%

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}} \]
    5. Step-by-step derivation
      1. associate-*l/77.4%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
    6. Applied egg-rr77.4%

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
    7. Step-by-step derivation
      1. sub-div79.7%

        \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]
    8. Applied egg-rr79.7%

      \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]

    if 8.8e5 < d

    1. Initial program 59.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. *-un-lft-identity59.4%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt59.4%

        \[\leadsto \frac{1 \cdot \left(b \cdot c - a \cdot d\right)}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. times-frac59.4%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}} \]
      4. hypot-def59.4%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
      5. hypot-def73.9%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
    3. Applied egg-rr73.9%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}} \]
    4. Taylor expanded in c around 0 78.8%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c \cdot b}{d} + -1 \cdot a\right)} \]
    5. Step-by-step derivation
      1. neg-mul-178.8%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{c \cdot b}{d} + \color{blue}{\left(-a\right)}\right) \]
      2. unsub-neg78.8%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c \cdot b}{d} - a\right)} \]
      3. associate-/l*82.4%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\color{blue}{\frac{c}{\frac{d}{b}}} - a\right) \]
    6. Simplified82.4%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{c}{\frac{d}{b}} - a\right)} \]
    7. Taylor expanded in c around 0 80.6%

      \[\leadsto \color{blue}{\frac{1}{d}} \cdot \left(\frac{c}{\frac{d}{b}} - a\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification78.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9.6 \cdot 10^{+22}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq 880000:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\ \end{array} \]

Alternative 5: 73.9% accurate, 1.1× speedup?

\[\begin{array}{l} \mathbf{if}\;d \leq -2.55 \cdot 10^{+23} \lor \neg \left(d \leq 54000000\right):\\ \;\;\;\;\frac{a}{\left(-d\right) - \frac{c \cdot c}{d}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if d < -2.5500000000000001e23 or 5.4e7 < d

    1. Initial program 52.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Taylor expanded in b around 0 43.3%

      \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{d}^{2} + {c}^{2}}} \]
    3. Step-by-step derivation
      1. associate-*r/43.3%

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(a \cdot d\right)}{{d}^{2} + {c}^{2}}} \]
      2. mul-1-neg43.3%

        \[\leadsto \frac{\color{blue}{-a \cdot d}}{{d}^{2} + {c}^{2}} \]
      3. distribute-rgt-neg-out43.3%

        \[\leadsto \frac{\color{blue}{a \cdot \left(-d\right)}}{{d}^{2} + {c}^{2}} \]
      4. associate-/l*49.0%

        \[\leadsto \color{blue}{\frac{a}{\frac{{d}^{2} + {c}^{2}}{-d}}} \]
      5. unpow249.0%

        \[\leadsto \frac{a}{\frac{\color{blue}{d \cdot d} + {c}^{2}}{-d}} \]
      6. unpow249.0%

        \[\leadsto \frac{a}{\frac{d \cdot d + \color{blue}{c \cdot c}}{-d}} \]
      7. fma-udef49.0%

        \[\leadsto \frac{a}{\frac{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}{-d}} \]
    4. Simplified49.0%

      \[\leadsto \color{blue}{\frac{a}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{-d}}} \]
    5. Taylor expanded in d around 0 65.5%

      \[\leadsto \frac{a}{\color{blue}{-1 \cdot \frac{{c}^{2}}{d} + -1 \cdot d}} \]
    6. Step-by-step derivation
      1. neg-mul-165.5%

        \[\leadsto \frac{a}{-1 \cdot \frac{{c}^{2}}{d} + \color{blue}{\left(-d\right)}} \]
      2. +-commutative65.5%

        \[\leadsto \frac{a}{\color{blue}{\left(-d\right) + -1 \cdot \frac{{c}^{2}}{d}}} \]
      3. mul-1-neg65.5%

        \[\leadsto \frac{a}{\left(-d\right) + \color{blue}{\left(-\frac{{c}^{2}}{d}\right)}} \]
      4. unsub-neg65.5%

        \[\leadsto \frac{a}{\color{blue}{\left(-d\right) - \frac{{c}^{2}}{d}}} \]
      5. unpow265.5%

        \[\leadsto \frac{a}{\left(-d\right) - \frac{\color{blue}{c \cdot c}}{d}} \]
    7. Simplified65.5%

      \[\leadsto \frac{a}{\color{blue}{\left(-d\right) - \frac{c \cdot c}{d}}} \]

    if -2.5500000000000001e23 < d < 5.4e7

    1. Initial program 73.1%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Taylor expanded in c around inf 70.9%

      \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{c}^{2}} + \frac{b}{c}} \]
    3. Step-by-step derivation
      1. +-commutative70.9%

        \[\leadsto \color{blue}{\frac{b}{c} + -1 \cdot \frac{a \cdot d}{{c}^{2}}} \]
      2. mul-1-neg70.9%

        \[\leadsto \frac{b}{c} + \color{blue}{\left(-\frac{a \cdot d}{{c}^{2}}\right)} \]
      3. unsub-neg70.9%

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow270.9%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac76.0%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{c} \cdot \frac{d}{c}} \]
    4. Simplified76.0%

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}} \]
    5. Step-by-step derivation
      1. associate-*l/77.4%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
    6. Applied egg-rr77.4%

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
    7. Step-by-step derivation
      1. sub-div79.7%

        \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]
    8. Applied egg-rr79.7%

      \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification73.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.55 \cdot 10^{+23} \lor \neg \left(d \leq 54000000\right):\\ \;\;\;\;\frac{a}{\left(-d\right) - \frac{c \cdot c}{d}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]

Alternative 6: 70.0% accurate, 1.1× speedup?

\[\begin{array}{l} \mathbf{if}\;c \leq -1.55 \cdot 10^{-94} \lor \neg \left(c \leq 1.05 \cdot 10^{-70}\right):\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if c < -1.5499999999999999e-94 or 1.0500000000000001e-70 < c

    1. Initial program 60.2%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Taylor expanded in c around inf 66.7%

      \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{c}^{2}} + \frac{b}{c}} \]
    3. Step-by-step derivation
      1. +-commutative66.7%

        \[\leadsto \color{blue}{\frac{b}{c} + -1 \cdot \frac{a \cdot d}{{c}^{2}}} \]
      2. mul-1-neg66.7%

        \[\leadsto \frac{b}{c} + \color{blue}{\left(-\frac{a \cdot d}{{c}^{2}}\right)} \]
      3. unsub-neg66.7%

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. unpow266.7%

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac73.1%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{c} \cdot \frac{d}{c}} \]
    4. Simplified73.1%

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}} \]
    5. Step-by-step derivation
      1. associate-*l/73.1%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
    6. Applied egg-rr73.1%

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot \frac{d}{c}}{c}} \]
    7. Step-by-step derivation
      1. sub-div73.1%

        \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]
    8. Applied egg-rr73.1%

      \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]

    if -1.5499999999999999e-94 < c < 1.0500000000000001e-70

    1. Initial program 70.5%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Taylor expanded in c around 0 69.4%

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    3. Step-by-step derivation
      1. associate-*r/69.4%

        \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
      2. neg-mul-169.4%

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    4. Simplified69.4%

      \[\leadsto \color{blue}{\frac{-a}{d}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification71.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.55 \cdot 10^{-94} \lor \neg \left(c \leq 1.05 \cdot 10^{-70}\right):\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]

Alternative 7: 63.9% accurate, 1.8× speedup?

\[\begin{array}{l} \mathbf{if}\;c \leq -65000000000:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 8.6 \cdot 10^{-20}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if c < -6.5e10 or 8.60000000000000022e-20 < c

    1. Initial program 53.6%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Taylor expanded in c around inf 66.7%

      \[\leadsto \color{blue}{\frac{b}{c}} \]

    if -6.5e10 < c < 8.60000000000000022e-20

    1. Initial program 74.2%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Taylor expanded in c around 0 60.5%

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    3. Step-by-step derivation
      1. associate-*r/60.5%

        \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
      2. neg-mul-160.5%

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    4. Simplified60.5%

      \[\leadsto \color{blue}{\frac{-a}{d}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification63.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -65000000000:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 8.6 \cdot 10^{-20}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]

Alternative 8: 46.5% accurate, 2.1× speedup?

\[\begin{array}{l} \mathbf{if}\;d \leq -1.25 \cdot 10^{+148} \lor \neg \left(d \leq 2.35 \cdot 10^{+126}\right):\\ \;\;\;\;\frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if d < -1.25000000000000006e148 or 2.3499999999999999e126 < d

    1. Initial program 42.0%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Taylor expanded in b around 0 36.9%

      \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{d}^{2} + {c}^{2}}} \]
    3. Step-by-step derivation
      1. associate-*r/36.9%

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(a \cdot d\right)}{{d}^{2} + {c}^{2}}} \]
      2. mul-1-neg36.9%

        \[\leadsto \frac{\color{blue}{-a \cdot d}}{{d}^{2} + {c}^{2}} \]
      3. distribute-rgt-neg-out36.9%

        \[\leadsto \frac{\color{blue}{a \cdot \left(-d\right)}}{{d}^{2} + {c}^{2}} \]
      4. associate-/l*38.2%

        \[\leadsto \color{blue}{\frac{a}{\frac{{d}^{2} + {c}^{2}}{-d}}} \]
      5. unpow238.2%

        \[\leadsto \frac{a}{\frac{\color{blue}{d \cdot d} + {c}^{2}}{-d}} \]
      6. unpow238.2%

        \[\leadsto \frac{a}{\frac{d \cdot d + \color{blue}{c \cdot c}}{-d}} \]
      7. fma-udef38.2%

        \[\leadsto \frac{a}{\frac{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}{-d}} \]
    4. Simplified38.2%

      \[\leadsto \color{blue}{\frac{a}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{-d}}} \]
    5. Taylor expanded in d around 0 67.1%

      \[\leadsto \frac{a}{\color{blue}{-1 \cdot \frac{{c}^{2}}{d} + -1 \cdot d}} \]
    6. Step-by-step derivation
      1. neg-mul-167.1%

        \[\leadsto \frac{a}{-1 \cdot \frac{{c}^{2}}{d} + \color{blue}{\left(-d\right)}} \]
      2. +-commutative67.1%

        \[\leadsto \frac{a}{\color{blue}{\left(-d\right) + -1 \cdot \frac{{c}^{2}}{d}}} \]
      3. mul-1-neg67.1%

        \[\leadsto \frac{a}{\left(-d\right) + \color{blue}{\left(-\frac{{c}^{2}}{d}\right)}} \]
      4. unsub-neg67.1%

        \[\leadsto \frac{a}{\color{blue}{\left(-d\right) - \frac{{c}^{2}}{d}}} \]
      5. unpow267.1%

        \[\leadsto \frac{a}{\left(-d\right) - \frac{\color{blue}{c \cdot c}}{d}} \]
    7. Simplified67.1%

      \[\leadsto \frac{a}{\color{blue}{\left(-d\right) - \frac{c \cdot c}{d}}} \]
    8. Step-by-step derivation
      1. sub-neg67.1%

        \[\leadsto \frac{a}{\color{blue}{\left(-d\right) + \left(-\frac{c \cdot c}{d}\right)}} \]
      2. add-sqr-sqrt34.1%

        \[\leadsto \frac{a}{\color{blue}{\sqrt{-d} \cdot \sqrt{-d}} + \left(-\frac{c \cdot c}{d}\right)} \]
      3. sqrt-unprod36.4%

        \[\leadsto \frac{a}{\color{blue}{\sqrt{\left(-d\right) \cdot \left(-d\right)}} + \left(-\frac{c \cdot c}{d}\right)} \]
      4. sqr-neg36.4%

        \[\leadsto \frac{a}{\sqrt{\color{blue}{d \cdot d}} + \left(-\frac{c \cdot c}{d}\right)} \]
      5. sqrt-prod13.8%

        \[\leadsto \frac{a}{\color{blue}{\sqrt{d} \cdot \sqrt{d}} + \left(-\frac{c \cdot c}{d}\right)} \]
      6. add-sqr-sqrt34.7%

        \[\leadsto \frac{a}{\color{blue}{d} + \left(-\frac{c \cdot c}{d}\right)} \]
      7. associate-/l*37.5%

        \[\leadsto \frac{a}{d + \left(-\color{blue}{\frac{c}{\frac{d}{c}}}\right)} \]
    9. Applied egg-rr37.5%

      \[\leadsto \frac{a}{\color{blue}{d + \left(-\frac{c}{\frac{d}{c}}\right)}} \]
    10. Taylor expanded in d around inf 33.3%

      \[\leadsto \color{blue}{\frac{a}{d}} \]

    if -1.25000000000000006e148 < d < 2.3499999999999999e126

    1. Initial program 71.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Taylor expanded in c around inf 53.3%

      \[\leadsto \color{blue}{\frac{b}{c}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification48.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.25 \cdot 10^{+148} \lor \neg \left(d \leq 2.35 \cdot 10^{+126}\right):\\ \;\;\;\;\frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]

Alternative 9: 10.9% accurate, 5.0× speedup?

\[\frac{a}{d} \]
Derivation
  1. Initial program 63.8%

    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
  2. Taylor expanded in b around 0 41.4%

    \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{d}^{2} + {c}^{2}}} \]
  3. Step-by-step derivation
    1. associate-*r/41.4%

      \[\leadsto \color{blue}{\frac{-1 \cdot \left(a \cdot d\right)}{{d}^{2} + {c}^{2}}} \]
    2. mul-1-neg41.4%

      \[\leadsto \frac{\color{blue}{-a \cdot d}}{{d}^{2} + {c}^{2}} \]
    3. distribute-rgt-neg-out41.4%

      \[\leadsto \frac{\color{blue}{a \cdot \left(-d\right)}}{{d}^{2} + {c}^{2}} \]
    4. associate-/l*44.1%

      \[\leadsto \color{blue}{\frac{a}{\frac{{d}^{2} + {c}^{2}}{-d}}} \]
    5. unpow244.1%

      \[\leadsto \frac{a}{\frac{\color{blue}{d \cdot d} + {c}^{2}}{-d}} \]
    6. unpow244.1%

      \[\leadsto \frac{a}{\frac{d \cdot d + \color{blue}{c \cdot c}}{-d}} \]
    7. fma-udef44.1%

      \[\leadsto \frac{a}{\frac{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}{-d}} \]
  4. Simplified44.1%

    \[\leadsto \color{blue}{\frac{a}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{-d}}} \]
  5. Taylor expanded in d around 0 52.7%

    \[\leadsto \frac{a}{\color{blue}{-1 \cdot \frac{{c}^{2}}{d} + -1 \cdot d}} \]
  6. Step-by-step derivation
    1. neg-mul-152.7%

      \[\leadsto \frac{a}{-1 \cdot \frac{{c}^{2}}{d} + \color{blue}{\left(-d\right)}} \]
    2. +-commutative52.7%

      \[\leadsto \frac{a}{\color{blue}{\left(-d\right) + -1 \cdot \frac{{c}^{2}}{d}}} \]
    3. mul-1-neg52.7%

      \[\leadsto \frac{a}{\left(-d\right) + \color{blue}{\left(-\frac{{c}^{2}}{d}\right)}} \]
    4. unsub-neg52.7%

      \[\leadsto \frac{a}{\color{blue}{\left(-d\right) - \frac{{c}^{2}}{d}}} \]
    5. unpow252.7%

      \[\leadsto \frac{a}{\left(-d\right) - \frac{\color{blue}{c \cdot c}}{d}} \]
  7. Simplified52.7%

    \[\leadsto \frac{a}{\color{blue}{\left(-d\right) - \frac{c \cdot c}{d}}} \]
  8. Step-by-step derivation
    1. sub-neg52.7%

      \[\leadsto \frac{a}{\color{blue}{\left(-d\right) + \left(-\frac{c \cdot c}{d}\right)}} \]
    2. add-sqr-sqrt23.1%

      \[\leadsto \frac{a}{\color{blue}{\sqrt{-d} \cdot \sqrt{-d}} + \left(-\frac{c \cdot c}{d}\right)} \]
    3. sqrt-unprod35.0%

      \[\leadsto \frac{a}{\color{blue}{\sqrt{\left(-d\right) \cdot \left(-d\right)}} + \left(-\frac{c \cdot c}{d}\right)} \]
    4. sqr-neg35.0%

      \[\leadsto \frac{a}{\sqrt{\color{blue}{d \cdot d}} + \left(-\frac{c \cdot c}{d}\right)} \]
    5. sqrt-prod14.0%

      \[\leadsto \frac{a}{\color{blue}{\sqrt{d} \cdot \sqrt{d}} + \left(-\frac{c \cdot c}{d}\right)} \]
    6. add-sqr-sqrt25.6%

      \[\leadsto \frac{a}{\color{blue}{d} + \left(-\frac{c \cdot c}{d}\right)} \]
    7. associate-/l*28.3%

      \[\leadsto \frac{a}{d + \left(-\color{blue}{\frac{c}{\frac{d}{c}}}\right)} \]
  9. Applied egg-rr28.3%

    \[\leadsto \frac{a}{\color{blue}{d + \left(-\frac{c}{\frac{d}{c}}\right)}} \]
  10. Taylor expanded in d around inf 10.8%

    \[\leadsto \color{blue}{\frac{a}{d}} \]
  11. Final simplification10.8%

    \[\leadsto \frac{a}{d} \]

Developer target: 99.4% accurate, 0.1× speedup?

\[\begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array} \]

Reproduce

?
herbie shell --seed 2023167 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :herbie-target
  (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))

  (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))