_divideComplex, imaginary part

?

Percentage Accurate: 61.3% → 97.2%
Time: 19.3s
Precision: binary64
Cost: 26944

?

\[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
\[\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{x.re}{\mathsf{hypot}\left(y.im, y.re\right)} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (-
  (* (/ 1.0 (hypot y.re y.im)) (/ y.re (/ (hypot y.re y.im) x.im)))
  (* (/ y.im (hypot y.im y.re)) (/ x.re (hypot y.im y.re)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return ((1.0 / hypot(y_46_re, y_46_im)) * (y_46_re / (hypot(y_46_re, y_46_im) / x_46_im))) - ((y_46_im / hypot(y_46_im, y_46_re)) * (x_46_re / hypot(y_46_im, y_46_re)));
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return ((1.0 / Math.hypot(y_46_re, y_46_im)) * (y_46_re / (Math.hypot(y_46_re, y_46_im) / x_46_im))) - ((y_46_im / Math.hypot(y_46_im, y_46_re)) * (x_46_re / Math.hypot(y_46_im, y_46_re)));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	return ((1.0 / math.hypot(y_46_re, y_46_im)) * (y_46_re / (math.hypot(y_46_re, y_46_im) / x_46_im))) - ((y_46_im / math.hypot(y_46_im, y_46_re)) * (x_46_re / math.hypot(y_46_im, y_46_re)))
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im)))
end
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return Float64(Float64(Float64(1.0 / hypot(y_46_re, y_46_im)) * Float64(y_46_re / Float64(hypot(y_46_re, y_46_im) / x_46_im))) - Float64(Float64(y_46_im / hypot(y_46_im, y_46_re)) * Float64(x_46_re / hypot(y_46_im, y_46_re))))
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = ((1.0 / hypot(y_46_re, y_46_im)) * (y_46_re / (hypot(y_46_re, y_46_im) / x_46_im))) - ((y_46_im / hypot(y_46_im, y_46_re)) * (x_46_re / hypot(y_46_im, y_46_re)));
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(1.0 / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] * N[(y$46$re / N[(N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision] / x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(y$46$im / N[Sqrt[y$46$im ^ 2 + y$46$re ^ 2], $MachinePrecision]), $MachinePrecision] * N[(x$46$re / N[Sqrt[y$46$im ^ 2 + y$46$re ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{x.re}{\mathsf{hypot}\left(y.im, y.re\right)}

Local Percentage Accuracy?

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.

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 63.3%

    \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
  2. Applied egg-rr72.5%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right)} \]
    Step-by-step derivation

    [Start]63.3

    \[ \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]

    div-sub [=>]61.2

    \[ \color{blue}{\frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}} \]

    *-un-lft-identity [=>]61.2

    \[ \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re\right)}}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]

    add-sqr-sqrt [=>]61.2

    \[ \frac{1 \cdot \left(x.im \cdot y.re\right)}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]

    times-frac [=>]61.3

    \[ \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]

    fma-neg [=>]61.3

    \[ \color{blue}{\mathsf{fma}\left(\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}, \frac{x.im \cdot y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right)} \]

    hypot-def [=>]61.3

    \[ \mathsf{fma}\left(\frac{1}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}}, \frac{x.im \cdot y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right) \]

    hypot-def [=>]68.3

    \[ \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right) \]

    associate-/l* [=>]72.5

    \[ \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\color{blue}{\frac{x.re}{\frac{y.re \cdot y.re + y.im \cdot y.im}{y.im}}}\right) \]

    add-sqr-sqrt [=>]72.5

    \[ \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}}{y.im}}\right) \]

    pow2 [=>]72.5

    \[ \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{\color{blue}{{\left(\sqrt{y.re \cdot y.re + y.im \cdot y.im}\right)}^{2}}}{y.im}}\right) \]

    hypot-def [=>]72.5

    \[ \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{{\color{blue}{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}}^{2}}{y.im}}\right) \]
  3. Simplified76.9%

    \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{x.re}}} \]
    Step-by-step derivation

    [Start]72.5

    \[ \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right) \]

    fma-neg [<=]72.5

    \[ \color{blue}{\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}} \]

    *-commutative [<=]72.5

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{\color{blue}{y.re \cdot x.im}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}} \]

    associate-/l* [=>]81.8

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \color{blue}{\frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}}} - \frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}} \]

    associate-/l* [<=]76.4

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \color{blue}{\frac{x.re \cdot y.im}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}} \]

    *-commutative [=>]76.4

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{\color{blue}{y.im \cdot x.re}}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}} \]

    associate-/l* [=>]76.9

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \color{blue}{\frac{y.im}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{x.re}}} \]
  4. Applied egg-rr83.9%

    \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\color{blue}{\mathsf{hypot}\left(y.im, y.re\right) \cdot \frac{\mathsf{hypot}\left(y.im, y.re\right)}{x.re}}} \]
    Step-by-step derivation

    [Start]76.9

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{x.re}} \]

    unpow2 [=>]76.9

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\frac{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right) \cdot \mathsf{hypot}\left(y.re, y.im\right)}}{x.re}} \]

    *-un-lft-identity [=>]76.9

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right) \cdot \mathsf{hypot}\left(y.re, y.im\right)}{\color{blue}{1 \cdot x.re}}} \]

    times-frac [=>]83.9

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\color{blue}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{1} \cdot \frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.re}}} \]

    /-rgt-identity [=>]83.9

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.re}} \]

    hypot-udef [=>]76.9

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.re}} \]

    +-commutative [=>]76.9

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\sqrt{\color{blue}{y.im \cdot y.im + y.re \cdot y.re}} \cdot \frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.re}} \]

    hypot-def [=>]83.9

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\color{blue}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.re}} \]

    hypot-udef [=>]76.9

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right) \cdot \frac{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}{x.re}} \]

    +-commutative [=>]76.9

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right) \cdot \frac{\sqrt{\color{blue}{y.im \cdot y.im + y.re \cdot y.re}}}{x.re}} \]

    hypot-def [=>]83.9

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right) \cdot \frac{\color{blue}{\mathsf{hypot}\left(y.im, y.re\right)}}{x.re}} \]
  5. Applied egg-rr98.7%

    \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \color{blue}{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{x.re}{\mathsf{hypot}\left(y.im, y.re\right)}} \]
    Step-by-step derivation

    [Start]83.9

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right) \cdot \frac{\mathsf{hypot}\left(y.im, y.re\right)}{x.re}} \]

    associate-/r* [=>]98.1

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \color{blue}{\frac{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)}}{\frac{\mathsf{hypot}\left(y.im, y.re\right)}{x.re}}} \]

    div-inv [=>]98.1

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \color{blue}{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{1}{\frac{\mathsf{hypot}\left(y.im, y.re\right)}{x.re}}} \]

    clear-num [<=]98.7

    \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \color{blue}{\frac{x.re}{\mathsf{hypot}\left(y.im, y.re\right)}} \]
  6. Final simplification98.7%

    \[\leadsto \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{x.re}{\mathsf{hypot}\left(y.im, y.re\right)} \]

Alternatives

Alternative 1
Accuracy92.7%
Cost27344
\[\begin{array}{l} t_0 := \frac{\frac{y.re}{\mathsf{hypot}\left(y.im, y.re\right)}}{\frac{\mathsf{hypot}\left(y.im, y.re\right)}{x.im}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right) \cdot \frac{\mathsf{hypot}\left(y.im, y.re\right)}{x.re}}\\ t_1 := \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{x.re}{y.im}\\ \mathbf{if}\;y.im \leq -8.5 \cdot 10^{+114}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.im \leq -6 \cdot 10^{-110}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.im \leq 1.7 \cdot 10^{-176}:\\ \;\;\;\;\frac{x.im - \frac{x.re}{\frac{y.re}{y.im}}}{y.re}\\ \mathbf{elif}\;y.im \leq 7.4 \cdot 10^{+124}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Accuracy89.6%
Cost27080
\[\begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}\\ t_1 := t_0 \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}}\\ t_2 := t_1 - \frac{x.re}{y.im}\\ \mathbf{if}\;y.im \leq -9.5 \cdot 10^{+110}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y.im \leq -9.5 \cdot 10^{-106}:\\ \;\;\;\;t_1 - \frac{y.im}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{x.re}}\\ \mathbf{elif}\;y.im \leq 10^{-148}:\\ \;\;\;\;\frac{x.im - \frac{x.re}{\frac{y.re}{y.im}}}{y.re}\\ \mathbf{elif}\;y.im \leq 1.9 \cdot 10^{+96}:\\ \;\;\;\;t_0 \cdot \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Accuracy89.1%
Cost14788
\[\begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}\\ t_1 := y.re \cdot x.im - y.im \cdot x.re\\ \mathbf{if}\;\frac{t_1}{y.re \cdot y.re + y.im \cdot y.im} \leq 10^{+263}:\\ \;\;\;\;t_0 \cdot \frac{t_1}{\mathsf{hypot}\left(y.re, y.im\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{x.re}{y.im}\\ \end{array} \]
Alternative 4
Accuracy86.2%
Cost14288
\[\begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re \cdot x.im - y.im \cdot x.re}{\mathsf{hypot}\left(y.re, y.im\right)}\\ t_1 := \frac{x.im}{y.re} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{x.re}{\mathsf{hypot}\left(y.im, y.re\right)}\\ \mathbf{if}\;y.re \leq -10200:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.re \leq -8 \cdot 10^{-213}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq 8.8 \cdot 10^{-156}:\\ \;\;\;\;\frac{y.re}{y.im} \cdot \frac{x.im}{y.im} - \frac{x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 1.6 \cdot 10^{+148}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Accuracy84.5%
Cost14160
\[\begin{array}{l} t_0 := \frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ t_1 := \frac{x.im}{y.re} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{x.re}{\mathsf{hypot}\left(y.im, y.re\right)}\\ \mathbf{if}\;y.re \leq -7 \cdot 10^{+19}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.re \leq -5.7 \cdot 10^{-126}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq 3.8 \cdot 10^{-165}:\\ \;\;\;\;\frac{y.re}{y.im} \cdot \frac{x.im}{y.im} - \frac{x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 8.8 \cdot 10^{+24}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Accuracy83.0%
Cost1488
\[\begin{array}{l} t_0 := \frac{y.re \cdot x.im - y.im \cdot x.re}{y.re \cdot y.re + y.im \cdot y.im}\\ t_1 := \frac{y.re}{y.im} \cdot \frac{x.im}{y.im} - \frac{x.re}{y.im}\\ \mathbf{if}\;y.im \leq -3 \cdot 10^{+74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.im \leq -2.7 \cdot 10^{-110}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.im \leq 2.5 \cdot 10^{-50}:\\ \;\;\;\;\frac{x.im - \frac{x.re}{\frac{y.re}{y.im}}}{y.re}\\ \mathbf{elif}\;y.im \leq 5.6 \cdot 10^{+95}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Accuracy71.3%
Cost1106
\[\begin{array}{l} \mathbf{if}\;y.im \leq -4.2 \cdot 10^{+64} \lor \neg \left(y.im \leq 2.4 \cdot 10^{-31} \lor \neg \left(y.im \leq 9.5 \cdot 10^{+37}\right) \land y.im \leq 1.65 \cdot 10^{+75}\right):\\ \;\;\;\;\frac{-x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re}\\ \end{array} \]
Alternative 8
Accuracy72.0%
Cost1105
\[\begin{array}{l} t_0 := \frac{-x.re}{y.im}\\ \mathbf{if}\;y.im \leq -1 \cdot 10^{+61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.im \leq 4.4 \cdot 10^{-39}:\\ \;\;\;\;\frac{x.im - \frac{x.re}{\frac{y.re}{y.im}}}{y.re}\\ \mathbf{elif}\;y.im \leq 2.75 \cdot 10^{+38} \lor \neg \left(y.im \leq 5.8 \cdot 10^{+72}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - y.im \cdot \frac{x.re}{y.re}}{y.re}\\ \end{array} \]
Alternative 9
Accuracy78.0%
Cost969
\[\begin{array}{l} \mathbf{if}\;y.im \leq -3.1 \cdot 10^{+43} \lor \neg \left(y.im \leq 3.7 \cdot 10^{-32}\right):\\ \;\;\;\;\frac{y.re}{y.im} \cdot \frac{x.im}{y.im} - \frac{x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im - \frac{x.re}{\frac{y.re}{y.im}}}{y.re}\\ \end{array} \]
Alternative 10
Accuracy63.1%
Cost521
\[\begin{array}{l} \mathbf{if}\;y.im \leq -2.7 \cdot 10^{+60} \lor \neg \left(y.im \leq 1.35 \cdot 10^{-33}\right):\\ \;\;\;\;\frac{-x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \]
Alternative 11
Accuracy42.4%
Cost192
\[\frac{x.im}{y.re} \]

Error

Reproduce?

herbie shell --seed 2023159 
(FPCore (x.re x.im y.re y.im)
  :name "_divideComplex, imaginary part"
  :precision binary64
  (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))