?

Average Error: 26.0 → 15.5
Time: 24.7s
Precision: binary64
Cost: 7500

?

\[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
\[\begin{array}{l} t_0 := \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ t_1 := -\frac{x.re}{y.im}\\ \mathbf{if}\;y.im \leq -900000000000:\\ \;\;\;\;t_1 + x.im \cdot \frac{y.re}{{y.im}^{2}}\\ \mathbf{elif}\;y.im \leq -1.35 \cdot 10^{-139}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.im \leq 1.6 \cdot 10^{-149}:\\ \;\;\;\;\frac{x.im}{y.re} + x.re \cdot \left(-\frac{y.im}{{y.re}^{2}}\right)\\ \mathbf{elif}\;y.im \leq 3.8 \cdot 10^{+108}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(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
 (let* ((t_0
         (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))
        (t_1 (- (/ x.re y.im))))
   (if (<= y.im -900000000000.0)
     (+ t_1 (* x.im (/ y.re (pow y.im 2.0))))
     (if (<= y.im -1.35e-139)
       t_0
       (if (<= y.im 1.6e-149)
         (+ (/ x.im y.re) (* x.re (- (/ y.im (pow y.re 2.0)))))
         (if (<= y.im 3.8e+108) t_0 t_1))))))
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) {
	double t_0 = ((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 t_1 = -(x_46_re / y_46_im);
	double tmp;
	if (y_46_im <= -900000000000.0) {
		tmp = t_1 + (x_46_im * (y_46_re / pow(y_46_im, 2.0)));
	} else if (y_46_im <= -1.35e-139) {
		tmp = t_0;
	} else if (y_46_im <= 1.6e-149) {
		tmp = (x_46_im / y_46_re) + (x_46_re * -(y_46_im / pow(y_46_re, 2.0)));
	} else if (y_46_im <= 3.8e+108) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    code = ((x_46im * y_46re) - (x_46re * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
end function
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = ((x_46im * y_46re) - (x_46re * y_46im)) / ((y_46re * y_46re) + (y_46im * y_46im))
    t_1 = -(x_46re / y_46im)
    if (y_46im <= (-900000000000.0d0)) then
        tmp = t_1 + (x_46im * (y_46re / (y_46im ** 2.0d0)))
    else if (y_46im <= (-1.35d-139)) then
        tmp = t_0
    else if (y_46im <= 1.6d-149) then
        tmp = (x_46im / y_46re) + (x_46re * -(y_46im / (y_46re ** 2.0d0)))
    else if (y_46im <= 3.8d+108) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
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) {
	double t_0 = ((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 t_1 = -(x_46_re / y_46_im);
	double tmp;
	if (y_46_im <= -900000000000.0) {
		tmp = t_1 + (x_46_im * (y_46_re / Math.pow(y_46_im, 2.0)));
	} else if (y_46_im <= -1.35e-139) {
		tmp = t_0;
	} else if (y_46_im <= 1.6e-149) {
		tmp = (x_46_im / y_46_re) + (x_46_re * -(y_46_im / Math.pow(y_46_re, 2.0)));
	} else if (y_46_im <= 3.8e+108) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
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):
	t_0 = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
	t_1 = -(x_46_re / y_46_im)
	tmp = 0
	if y_46_im <= -900000000000.0:
		tmp = t_1 + (x_46_im * (y_46_re / math.pow(y_46_im, 2.0)))
	elif y_46_im <= -1.35e-139:
		tmp = t_0
	elif y_46_im <= 1.6e-149:
		tmp = (x_46_im / y_46_re) + (x_46_re * -(y_46_im / math.pow(y_46_re, 2.0)))
	elif y_46_im <= 3.8e+108:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
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)
	t_0 = 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)))
	t_1 = Float64(-Float64(x_46_re / y_46_im))
	tmp = 0.0
	if (y_46_im <= -900000000000.0)
		tmp = Float64(t_1 + Float64(x_46_im * Float64(y_46_re / (y_46_im ^ 2.0))));
	elseif (y_46_im <= -1.35e-139)
		tmp = t_0;
	elseif (y_46_im <= 1.6e-149)
		tmp = Float64(Float64(x_46_im / y_46_re) + Float64(x_46_re * Float64(-Float64(y_46_im / (y_46_re ^ 2.0)))));
	elseif (y_46_im <= 3.8e+108)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
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_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
	t_1 = -(x_46_re / y_46_im);
	tmp = 0.0;
	if (y_46_im <= -900000000000.0)
		tmp = t_1 + (x_46_im * (y_46_re / (y_46_im ^ 2.0)));
	elseif (y_46_im <= -1.35e-139)
		tmp = t_0;
	elseif (y_46_im <= 1.6e-149)
		tmp = (x_46_im / y_46_re) + (x_46_re * -(y_46_im / (y_46_re ^ 2.0)));
	elseif (y_46_im <= 3.8e+108)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
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_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = (-N[(x$46$re / y$46$im), $MachinePrecision])}, If[LessEqual[y$46$im, -900000000000.0], N[(t$95$1 + N[(x$46$im * N[(y$46$re / N[Power[y$46$im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, -1.35e-139], t$95$0, If[LessEqual[y$46$im, 1.6e-149], N[(N[(x$46$im / y$46$re), $MachinePrecision] + N[(x$46$re * (-N[(y$46$im / N[Power[y$46$re, 2.0], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$im, 3.8e+108], t$95$0, t$95$1]]]]]]
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\begin{array}{l}
t_0 := \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\
t_1 := -\frac{x.re}{y.im}\\
\mathbf{if}\;y.im \leq -900000000000:\\
\;\;\;\;t_1 + x.im \cdot \frac{y.re}{{y.im}^{2}}\\

\mathbf{elif}\;y.im \leq -1.35 \cdot 10^{-139}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y.im \leq 1.6 \cdot 10^{-149}:\\
\;\;\;\;\frac{x.im}{y.re} + x.re \cdot \left(-\frac{y.im}{{y.re}^{2}}\right)\\

\mathbf{elif}\;y.im \leq 3.8 \cdot 10^{+108}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 4 regimes
  2. if y.im < -9e11

    1. Initial program 32.1

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Taylor expanded in y.re around 0 18.5

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im} + \frac{y.re \cdot x.im}{{y.im}^{2}}} \]
    3. Simplified18.5

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

      [Start]18.5

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

      rational.json-simplify-2 [=>]18.5

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

      rational.json-simplify-9 [=>]18.5

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

      rational.json-simplify-49 [=>]18.5

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

    if -9e11 < y.im < -1.3499999999999999e-139 or 1.60000000000000001e-149 < y.im < 3.80000000000000008e108

    1. Initial program 15.6

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

    if -1.3499999999999999e-139 < y.im < 1.60000000000000001e-149

    1. Initial program 24.2

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Taylor expanded in y.re around inf 10.5

      \[\leadsto \color{blue}{\frac{x.im}{y.re} + -1 \cdot \frac{x.re \cdot y.im}{{y.re}^{2}}} \]
    3. Simplified11.3

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

      [Start]10.5

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

      rational.json-simplify-2 [=>]10.5

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

      rational.json-simplify-49 [=>]11.3

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

      rational.json-simplify-43 [=>]11.3

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

      rational.json-simplify-9 [=>]11.3

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

    if 3.80000000000000008e108 < y.im

    1. Initial program 39.9

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im} \]
    2. Taylor expanded in y.re around 0 17.1

      \[\leadsto \color{blue}{-1 \cdot \frac{x.re}{y.im}} \]
    3. Simplified17.1

      \[\leadsto \color{blue}{-\frac{x.re}{y.im}} \]
      Proof

      [Start]17.1

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

      rational.json-simplify-2 [=>]17.1

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

      rational.json-simplify-9 [=>]17.1

      \[ \color{blue}{-\frac{x.re}{y.im}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification15.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \leq -900000000000:\\ \;\;\;\;\left(-\frac{x.re}{y.im}\right) + x.im \cdot \frac{y.re}{{y.im}^{2}}\\ \mathbf{elif}\;y.im \leq -1.35 \cdot 10^{-139}:\\ \;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{elif}\;y.im \leq 1.6 \cdot 10^{-149}:\\ \;\;\;\;\frac{x.im}{y.re} + x.re \cdot \left(-\frac{y.im}{{y.re}^{2}}\right)\\ \mathbf{elif}\;y.im \leq 3.8 \cdot 10^{+108}:\\ \;\;\;\;\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;-\frac{x.re}{y.im}\\ \end{array} \]

Alternatives

Alternative 1
Error14.9
Cost7500
\[\begin{array}{l} t_0 := \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{if}\;y.re \leq -7.5 \cdot 10^{+98}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.re \leq -5.2 \cdot 10^{-109}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq 2.95 \cdot 10^{-139}:\\ \;\;\;\;\left(-\frac{x.re}{y.im}\right) + x.im \cdot \frac{y.re}{{y.im}^{2}}\\ \mathbf{elif}\;y.re \leq 10^{+99}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \]
Alternative 2
Error21.2
Cost1496
\[\begin{array}{l} t_0 := y.re \cdot y.re + y.im \cdot y.im\\ t_1 := \frac{x.im}{\frac{t_0}{y.re}}\\ \mathbf{if}\;y.re \leq -3.35 \cdot 10^{+152}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.re \leq -3.8 \cdot 10^{-7}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.re \leq -3.35 \cdot 10^{-19}:\\ \;\;\;\;\frac{-y.im}{t_0} \cdot x.re\\ \mathbf{elif}\;y.re \leq -2.9 \cdot 10^{-70}:\\ \;\;\;\;\frac{y.re}{t_0} \cdot x.im\\ \mathbf{elif}\;y.re \leq 6.1 \cdot 10^{-139}:\\ \;\;\;\;-\frac{x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 3.1 \cdot 10^{+121}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \]
Alternative 3
Error21.1
Cost1496
\[\begin{array}{l} t_0 := y.re \cdot y.re + y.im \cdot y.im\\ t_1 := \frac{x.im}{\frac{t_0}{y.re}}\\ \mathbf{if}\;y.re \leq -8 \cdot 10^{+150}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.re \leq -4.2 \cdot 10^{-6}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.re \leq -7 \cdot 10^{-21}:\\ \;\;\;\;\frac{x.re}{\frac{t_0}{-y.im}}\\ \mathbf{elif}\;y.re \leq -1.3 \cdot 10^{-68}:\\ \;\;\;\;\frac{y.re}{t_0} \cdot x.im\\ \mathbf{elif}\;y.re \leq 5.7 \cdot 10^{-139}:\\ \;\;\;\;-\frac{x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 1.65 \cdot 10^{+121}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \]
Alternative 4
Error16.7
Cost1488
\[\begin{array}{l} t_0 := -\frac{x.re}{y.im}\\ t_1 := \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\\ \mathbf{if}\;y.im \leq -2 \cdot 10^{+119}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.im \leq -5.4 \cdot 10^{-273}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.im \leq 4.2 \cdot 10^{-170}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.im \leq 5.9 \cdot 10^{+107}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error21.1
Cost1232
\[\begin{array}{l} t_0 := \frac{y.re}{y.re \cdot y.re + y.im \cdot y.im} \cdot x.im\\ \mathbf{if}\;y.re \leq -1.8 \cdot 10^{+122}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.re \leq -9.2 \cdot 10^{-69}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq 5.7 \cdot 10^{-139}:\\ \;\;\;\;-\frac{x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 1.45 \cdot 10^{+121}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \]
Alternative 6
Error21.1
Cost1232
\[\begin{array}{l} t_0 := \frac{x.im}{\frac{y.re \cdot y.re + y.im \cdot y.im}{y.re}}\\ \mathbf{if}\;y.re \leq -1 \cdot 10^{+152}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.re \leq -2.4 \cdot 10^{-71}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq 6.1 \cdot 10^{-139}:\\ \;\;\;\;-\frac{x.re}{y.im}\\ \mathbf{elif}\;y.re \leq 3.1 \cdot 10^{+121}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \]
Alternative 7
Error23.5
Cost968
\[\begin{array}{l} \mathbf{if}\;y.re \leq -4.5 \cdot 10^{+117}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.re \leq -4.1 \cdot 10^{-69}:\\ \;\;\;\;\frac{x.im}{y.re \cdot y.re + y.im \cdot y.im} \cdot y.re\\ \mathbf{elif}\;y.re \leq 1.25 \cdot 10^{-131}:\\ \;\;\;\;-\frac{x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \]
Alternative 8
Error24.4
Cost520
\[\begin{array}{l} \mathbf{if}\;y.re \leq -0.00062:\\ \;\;\;\;\frac{x.im}{y.re}\\ \mathbf{elif}\;y.re \leq 1.25 \cdot 10^{-131}:\\ \;\;\;\;-\frac{x.re}{y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{y.re}\\ \end{array} \]
Alternative 9
Error37.4
Cost192
\[\frac{x.im}{y.re} \]

Error

Reproduce?

herbie shell --seed 2023074 
(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))))