x1/sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2)

Percentage Accurate: 66.1% → 99.8%
Time: 3.5s
Alternatives: 11
Speedup: 0.8×

Specification

?
\[\left(\left(\left(-1000 \leq x1 \land x1 \leq 1000\right) \land \left(-1000 \leq y1 \land y1 \leq 1000\right)\right) \land \left(-1000 \leq x2 \land x2 \leq 1000\right)\right) \land \left(-1000 \leq y2 \land y2 \leq 1000\right)\]
\[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
(FPCore (x1 y1 x2 y2)
  :precision binary64
  (*
 (/ x1 (sqrt (+ (* x1 x1) (* y1 y1))))
 (sqrt (+ (* x2 x2) (* y2 y2)))))
double code(double x1, double y1, double x2, double y2) {
	return (x1 / sqrt(((x1 * x1) + (y1 * y1)))) * sqrt(((x2 * x2) + (y2 * y2)));
}
real(8) function code(x1, y1, x2, y2)
    real(8), intent (in) :: x1
    real(8), intent (in) :: y1
    real(8), intent (in) :: x2
    real(8), intent (in) :: y2
    code = (x1 / sqrt(((x1 * x1) + (y1 * y1)))) * sqrt(((x2 * x2) + (y2 * y2)))
end function
public static double code(double x1, double y1, double x2, double y2) {
	return (x1 / Math.sqrt(((x1 * x1) + (y1 * y1)))) * Math.sqrt(((x2 * x2) + (y2 * y2)));
}
def code(x1, y1, x2, y2):
	return (x1 / math.sqrt(((x1 * x1) + (y1 * y1)))) * math.sqrt(((x2 * x2) + (y2 * y2)))
function code(x1, y1, x2, y2)
	return Float64(Float64(x1 / sqrt(Float64(Float64(x1 * x1) + Float64(y1 * y1)))) * sqrt(Float64(Float64(x2 * x2) + Float64(y2 * y2))))
end
function tmp = code(x1, y1, x2, y2)
	tmp = (x1 / sqrt(((x1 * x1) + (y1 * y1)))) * sqrt(((x2 * x2) + (y2 * y2)));
end
code[x1_, y1_, x2_, y2_] := N[(N[(x1 / N[Sqrt[N[(N[(x1 * x1), $MachinePrecision] + N[(y1 * y1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(x2 * x2), $MachinePrecision] + N[(y2 * y2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}

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 11 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.

Initial Program: 66.1% accurate, 1.0× speedup?

\[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
(FPCore (x1 y1 x2 y2)
  :precision binary64
  (*
 (/ x1 (sqrt (+ (* x1 x1) (* y1 y1))))
 (sqrt (+ (* x2 x2) (* y2 y2)))))
double code(double x1, double y1, double x2, double y2) {
	return (x1 / sqrt(((x1 * x1) + (y1 * y1)))) * sqrt(((x2 * x2) + (y2 * y2)));
}
real(8) function code(x1, y1, x2, y2)
    real(8), intent (in) :: x1
    real(8), intent (in) :: y1
    real(8), intent (in) :: x2
    real(8), intent (in) :: y2
    code = (x1 / sqrt(((x1 * x1) + (y1 * y1)))) * sqrt(((x2 * x2) + (y2 * y2)))
end function
public static double code(double x1, double y1, double x2, double y2) {
	return (x1 / Math.sqrt(((x1 * x1) + (y1 * y1)))) * Math.sqrt(((x2 * x2) + (y2 * y2)));
}
def code(x1, y1, x2, y2):
	return (x1 / math.sqrt(((x1 * x1) + (y1 * y1)))) * math.sqrt(((x2 * x2) + (y2 * y2)))
function code(x1, y1, x2, y2)
	return Float64(Float64(x1 / sqrt(Float64(Float64(x1 * x1) + Float64(y1 * y1)))) * sqrt(Float64(Float64(x2 * x2) + Float64(y2 * y2))))
end
function tmp = code(x1, y1, x2, y2)
	tmp = (x1 / sqrt(((x1 * x1) + (y1 * y1)))) * sqrt(((x2 * x2) + (y2 * y2)));
end
code[x1_, y1_, x2_, y2_] := N[(N[(x1 / N[Sqrt[N[(N[(x1 * x1), $MachinePrecision] + N[(y1 * y1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(x2 * x2), $MachinePrecision] + N[(y2 * y2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}

Alternative 1: 99.8% accurate, 0.8× speedup?

\[\frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \mathsf{hypot}\left(y2, x2\right) \]
(FPCore (x1 y1 x2 y2)
  :precision binary64
  (* (/ x1 (hypot y1 x1)) (hypot y2 x2)))
double code(double x1, double y1, double x2, double y2) {
	return (x1 / hypot(y1, x1)) * hypot(y2, x2);
}
public static double code(double x1, double y1, double x2, double y2) {
	return (x1 / Math.hypot(y1, x1)) * Math.hypot(y2, x2);
}
def code(x1, y1, x2, y2):
	return (x1 / math.hypot(y1, x1)) * math.hypot(y2, x2)
function code(x1, y1, x2, y2)
	return Float64(Float64(x1 / hypot(y1, x1)) * hypot(y2, x2))
end
function tmp = code(x1, y1, x2, y2)
	tmp = (x1 / hypot(y1, x1)) * hypot(y2, x2);
end
code[x1_, y1_, x2_, y2_] := N[(N[(x1 / N[Sqrt[y1 ^ 2 + x1 ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sqrt[y2 ^ 2 + x2 ^ 2], $MachinePrecision]), $MachinePrecision]
\frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \mathsf{hypot}\left(y2, x2\right)
Derivation
  1. Initial program 66.1%

    \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
  2. Step-by-step derivation
    1. lift-sqrt.f64N/A

      \[\leadsto \frac{x1}{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    2. sqrt-fabs-revN/A

      \[\leadsto \frac{x1}{\color{blue}{\left|\sqrt{x1 \cdot x1 + y1 \cdot y1}\right|}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    3. lift-sqrt.f64N/A

      \[\leadsto \frac{x1}{\left|\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}\right|} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    4. rem-sqrt-square-revN/A

      \[\leadsto \frac{x1}{\color{blue}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    5. lift-sqrt.f64N/A

      \[\leadsto \frac{x1}{\sqrt{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    6. lift-sqrt.f64N/A

      \[\leadsto \frac{x1}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    7. rem-square-sqrtN/A

      \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    8. lift-+.f64N/A

      \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    9. +-commutativeN/A

      \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1 + x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    10. lift-*.f64N/A

      \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1} + x1 \cdot x1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    11. lift-*.f64N/A

      \[\leadsto \frac{x1}{\sqrt{y1 \cdot y1 + \color{blue}{x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    12. lower-hypot.f6483.4%

      \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
  3. Applied rewrites83.4%

    \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
  4. Step-by-step derivation
    1. lift-sqrt.f64N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}} \]
    2. pow1/2N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{{\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}} \]
    3. lift-+.f64N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}} \]
    4. +-commutativeN/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}} \]
    6. lift-fma.f64N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}} \]
    7. pow1/2N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \]
    8. sqrt-fabs-revN/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\left|\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right|} \]
    9. pow1/2N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}^{\frac{1}{2}}}\right| \]
    10. lift-fma.f64N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right| \]
    11. lift-*.f64N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right| \]
    12. +-commutativeN/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
    13. lift-+.f64N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
    14. pow1/2N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
    15. lift-sqrt.f64N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
    16. rem-sqrt-square-revN/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}}} \]
    17. pow2N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}^{2}}} \]
    18. lift-sqrt.f64N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}}^{2}} \]
    19. pow1/2N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left({\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}\right)}}^{2}} \]
    20. lift-+.f64N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
    21. +-commutativeN/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
    22. lift-*.f64N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right)}^{2}} \]
    23. lift-fma.f64N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}}\right)}^{2}} \]
    24. pow1/2N/A

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right)}}^{2}} \]
  5. Applied rewrites99.8%

    \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\mathsf{hypot}\left(y2, x2\right)} \]
  6. Add Preprocessing

Alternative 2: 96.8% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \frac{\left|x1\right|}{\sqrt{\left|x1\right| \cdot \left|x1\right| + y1 \cdot y1}}\\ t_1 := t\_0 \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}\\ \mathsf{copysign}\left(1, x1\right) \cdot \begin{array}{l} \mathbf{if}\;t\_1 \leq 5 \cdot 10^{-162}:\\ \;\;\;\;t\_0 \cdot \mathsf{hypot}\left(y2, x2\right)\\ \mathbf{elif}\;t\_1 \leq \infty:\\ \;\;\;\;\frac{\left|x1\right|}{\mathsf{hypot}\left(y1, \left|x1\right|\right)} \cdot \sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \mathsf{hypot}\left(y2, x2\right)\\ \end{array} \end{array} \]
(FPCore (x1 y1 x2 y2)
  :precision binary64
  (let* ((t_0
        (/ (fabs x1) (sqrt (+ (* (fabs x1) (fabs x1)) (* y1 y1)))))
       (t_1 (* t_0 (sqrt (+ (* x2 x2) (* y2 y2))))))
  (*
   (copysign 1.0 x1)
   (if (<= t_1 5e-162)
     (* t_0 (hypot y2 x2))
     (if (<= t_1 INFINITY)
       (*
        (/ (fabs x1) (hypot y1 (fabs x1)))
        (sqrt (fma y2 y2 (* x2 x2))))
       (* 1.0 (hypot y2 x2)))))))
double code(double x1, double y1, double x2, double y2) {
	double t_0 = fabs(x1) / sqrt(((fabs(x1) * fabs(x1)) + (y1 * y1)));
	double t_1 = t_0 * sqrt(((x2 * x2) + (y2 * y2)));
	double tmp;
	if (t_1 <= 5e-162) {
		tmp = t_0 * hypot(y2, x2);
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = (fabs(x1) / hypot(y1, fabs(x1))) * sqrt(fma(y2, y2, (x2 * x2)));
	} else {
		tmp = 1.0 * hypot(y2, x2);
	}
	return copysign(1.0, x1) * tmp;
}
function code(x1, y1, x2, y2)
	t_0 = Float64(abs(x1) / sqrt(Float64(Float64(abs(x1) * abs(x1)) + Float64(y1 * y1))))
	t_1 = Float64(t_0 * sqrt(Float64(Float64(x2 * x2) + Float64(y2 * y2))))
	tmp = 0.0
	if (t_1 <= 5e-162)
		tmp = Float64(t_0 * hypot(y2, x2));
	elseif (t_1 <= Inf)
		tmp = Float64(Float64(abs(x1) / hypot(y1, abs(x1))) * sqrt(fma(y2, y2, Float64(x2 * x2))));
	else
		tmp = Float64(1.0 * hypot(y2, x2));
	end
	return Float64(copysign(1.0, x1) * tmp)
end
code[x1_, y1_, x2_, y2_] := Block[{t$95$0 = N[(N[Abs[x1], $MachinePrecision] / N[Sqrt[N[(N[(N[Abs[x1], $MachinePrecision] * N[Abs[x1], $MachinePrecision]), $MachinePrecision] + N[(y1 * y1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[Sqrt[N[(N[(x2 * x2), $MachinePrecision] + N[(y2 * y2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, 5e-162], N[(t$95$0 * N[Sqrt[y2 ^ 2 + x2 ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[Abs[x1], $MachinePrecision] / N[Sqrt[y1 ^ 2 + N[Abs[x1], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(y2 * y2 + N[(x2 * x2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 * N[Sqrt[y2 ^ 2 + x2 ^ 2], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \frac{\left|x1\right|}{\sqrt{\left|x1\right| \cdot \left|x1\right| + y1 \cdot y1}}\\
t_1 := t\_0 \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}\\
\mathsf{copysign}\left(1, x1\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{-162}:\\
\;\;\;\;t\_0 \cdot \mathsf{hypot}\left(y2, x2\right)\\

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\left|x1\right|}{\mathsf{hypot}\left(y1, \left|x1\right|\right)} \cdot \sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\\

\mathbf{else}:\\
\;\;\;\;1 \cdot \mathsf{hypot}\left(y2, x2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (/.f64 x1 (sqrt.f64 (+.f64 (*.f64 x1 x1) (*.f64 y1 y1)))) (sqrt.f64 (+.f64 (*.f64 x2 x2) (*.f64 y2 y2)))) < 5.0000000000000001e-162

    1. Initial program 66.1%

      \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    2. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}} \]
      2. sqrt-fabs-revN/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \color{blue}{\left|\sqrt{x2 \cdot x2 + y2 \cdot y2}\right|} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
      4. rem-sqrt-square-revN/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \color{blue}{\sqrt{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}} \]
      6. lift-sqrt.f64N/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}} \]
      7. rem-square-sqrtN/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{\color{blue}{x2 \cdot x2 + y2 \cdot y2}} \]
      8. lift-+.f64N/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{\color{blue}{x2 \cdot x2 + y2 \cdot y2}} \]
      9. +-commutativeN/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{\color{blue}{y2 \cdot y2 + x2 \cdot x2}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{y2 \cdot y2 + \color{blue}{x2 \cdot x2}} \]
      11. sqr-abs-revN/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{y2 \cdot y2 + \color{blue}{\left|x2\right| \cdot \left|x2\right|}} \]
      12. sqr-neg-revN/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{y2 \cdot y2 + \color{blue}{\left(\mathsf{neg}\left(\left|x2\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|x2\right|\right)\right)}} \]
      13. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{\color{blue}{y2 \cdot y2 - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|x2\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|x2\right|\right)\right)}} \]
      14. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{\color{blue}{y2 \cdot y2 + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|x2\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|x2\right|\right)\right)}} \]
      15. lift-*.f64N/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{\color{blue}{y2 \cdot y2} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|x2\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|x2\right|\right)\right)} \]
      16. distribute-lft-neg-inN/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{y2 \cdot y2 + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|x2\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|x2\right|\right)\right)\right)\right)}} \]
      17. distribute-rgt-neg-outN/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{y2 \cdot y2 + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|x2\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|x2\right|\right)\right)\right)\right)}} \]
      18. sqr-neg-revN/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{y2 \cdot y2 + \color{blue}{\left(\mathsf{neg}\left(\left|x2\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|x2\right|\right)\right)}} \]
      19. sqr-neg-revN/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{y2 \cdot y2 + \color{blue}{\left|x2\right| \cdot \left|x2\right|}} \]
      20. sqr-abs-revN/A

        \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{y2 \cdot y2 + \color{blue}{x2 \cdot x2}} \]
    3. Applied rewrites78.1%

      \[\leadsto \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \color{blue}{\mathsf{hypot}\left(y2, x2\right)} \]

    if 5.0000000000000001e-162 < (*.f64 (/.f64 x1 (sqrt.f64 (+.f64 (*.f64 x1 x1) (*.f64 y1 y1)))) (sqrt.f64 (+.f64 (*.f64 x2 x2) (*.f64 y2 y2)))) < +inf.0

    1. Initial program 66.1%

      \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    2. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \frac{x1}{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      2. sqrt-fabs-revN/A

        \[\leadsto \frac{x1}{\color{blue}{\left|\sqrt{x1 \cdot x1 + y1 \cdot y1}\right|}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \frac{x1}{\left|\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}\right|} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      4. rem-sqrt-square-revN/A

        \[\leadsto \frac{x1}{\color{blue}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{x1}{\sqrt{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      6. lift-sqrt.f64N/A

        \[\leadsto \frac{x1}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      7. rem-square-sqrtN/A

        \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      8. lift-+.f64N/A

        \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      9. +-commutativeN/A

        \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1 + x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1} + x1 \cdot x1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      11. lift-*.f64N/A

        \[\leadsto \frac{x1}{\sqrt{y1 \cdot y1 + \color{blue}{x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      12. lower-hypot.f6483.4%

        \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    3. Applied rewrites83.4%

      \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    4. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{x2 \cdot x2 + y2 \cdot y2}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{y2 \cdot y2 + x2 \cdot x2}} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{y2 \cdot y2} + x2 \cdot x2} \]
      4. lift-fma.f6483.4%

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \]
    5. Applied rewrites83.4%

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \]

    if +inf.0 < (*.f64 (/.f64 x1 (sqrt.f64 (+.f64 (*.f64 x1 x1) (*.f64 y1 y1)))) (sqrt.f64 (+.f64 (*.f64 x2 x2) (*.f64 y2 y2))))

    1. Initial program 66.1%

      \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    2. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \frac{x1}{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      2. sqrt-fabs-revN/A

        \[\leadsto \frac{x1}{\color{blue}{\left|\sqrt{x1 \cdot x1 + y1 \cdot y1}\right|}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \frac{x1}{\left|\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}\right|} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      4. rem-sqrt-square-revN/A

        \[\leadsto \frac{x1}{\color{blue}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{x1}{\sqrt{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      6. lift-sqrt.f64N/A

        \[\leadsto \frac{x1}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      7. rem-square-sqrtN/A

        \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      8. lift-+.f64N/A

        \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      9. +-commutativeN/A

        \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1 + x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1} + x1 \cdot x1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      11. lift-*.f64N/A

        \[\leadsto \frac{x1}{\sqrt{y1 \cdot y1 + \color{blue}{x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      12. lower-hypot.f6483.4%

        \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    3. Applied rewrites83.4%

      \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
    4. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}} \]
      2. pow1/2N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{{\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}} \]
      3. lift-+.f64N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}} \]
      4. +-commutativeN/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}} \]
      6. lift-fma.f64N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}} \]
      7. pow1/2N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \]
      8. sqrt-fabs-revN/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\left|\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right|} \]
      9. pow1/2N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}^{\frac{1}{2}}}\right| \]
      10. lift-fma.f64N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right| \]
      11. lift-*.f64N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right| \]
      12. +-commutativeN/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
      13. lift-+.f64N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
      14. pow1/2N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
      15. lift-sqrt.f64N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
      16. rem-sqrt-square-revN/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}}} \]
      17. pow2N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}^{2}}} \]
      18. lift-sqrt.f64N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}}^{2}} \]
      19. pow1/2N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left({\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}\right)}}^{2}} \]
      20. lift-+.f64N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
      21. +-commutativeN/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
      22. lift-*.f64N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right)}^{2}} \]
      23. lift-fma.f64N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}}\right)}^{2}} \]
      24. pow1/2N/A

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right)}}^{2}} \]
    5. Applied rewrites99.8%

      \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\mathsf{hypot}\left(y2, x2\right)} \]
    6. Taylor expanded in x1 around inf

      \[\leadsto \color{blue}{1} \cdot \mathsf{hypot}\left(y2, x2\right) \]
    7. Step-by-step derivation
      1. Applied rewrites28.2%

        \[\leadsto \color{blue}{1} \cdot \mathsf{hypot}\left(y2, x2\right) \]
    8. Recombined 3 regimes into one program.
    9. Add Preprocessing

    Alternative 3: 88.5% accurate, 0.5× speedup?

    \[\mathsf{copysign}\left(1, x1\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{\left|x1\right|}{\sqrt{\left|x1\right| \cdot \left|x1\right| + \left|y1\right| \cdot \left|y1\right|}} \leq 0.1:\\ \;\;\;\;\frac{\left|x1\right|}{\left|y1\right|} \cdot \mathsf{hypot}\left(y2, x2\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \mathsf{hypot}\left(y2, x2\right)\\ \end{array} \]
    (FPCore (x1 y1 x2 y2)
      :precision binary64
      (*
     (copysign 1.0 x1)
     (if (<=
          (/
           (fabs x1)
           (sqrt (+ (* (fabs x1) (fabs x1)) (* (fabs y1) (fabs y1)))))
          0.1)
       (* (/ (fabs x1) (fabs y1)) (hypot y2 x2))
       (* 1.0 (hypot y2 x2)))))
    double code(double x1, double y1, double x2, double y2) {
    	double tmp;
    	if ((fabs(x1) / sqrt(((fabs(x1) * fabs(x1)) + (fabs(y1) * fabs(y1))))) <= 0.1) {
    		tmp = (fabs(x1) / fabs(y1)) * hypot(y2, x2);
    	} else {
    		tmp = 1.0 * hypot(y2, x2);
    	}
    	return copysign(1.0, x1) * tmp;
    }
    
    public static double code(double x1, double y1, double x2, double y2) {
    	double tmp;
    	if ((Math.abs(x1) / Math.sqrt(((Math.abs(x1) * Math.abs(x1)) + (Math.abs(y1) * Math.abs(y1))))) <= 0.1) {
    		tmp = (Math.abs(x1) / Math.abs(y1)) * Math.hypot(y2, x2);
    	} else {
    		tmp = 1.0 * Math.hypot(y2, x2);
    	}
    	return Math.copySign(1.0, x1) * tmp;
    }
    
    def code(x1, y1, x2, y2):
    	tmp = 0
    	if (math.fabs(x1) / math.sqrt(((math.fabs(x1) * math.fabs(x1)) + (math.fabs(y1) * math.fabs(y1))))) <= 0.1:
    		tmp = (math.fabs(x1) / math.fabs(y1)) * math.hypot(y2, x2)
    	else:
    		tmp = 1.0 * math.hypot(y2, x2)
    	return math.copysign(1.0, x1) * tmp
    
    function code(x1, y1, x2, y2)
    	tmp = 0.0
    	if (Float64(abs(x1) / sqrt(Float64(Float64(abs(x1) * abs(x1)) + Float64(abs(y1) * abs(y1))))) <= 0.1)
    		tmp = Float64(Float64(abs(x1) / abs(y1)) * hypot(y2, x2));
    	else
    		tmp = Float64(1.0 * hypot(y2, x2));
    	end
    	return Float64(copysign(1.0, x1) * tmp)
    end
    
    function tmp_2 = code(x1, y1, x2, y2)
    	tmp = 0.0;
    	if ((abs(x1) / sqrt(((abs(x1) * abs(x1)) + (abs(y1) * abs(y1))))) <= 0.1)
    		tmp = (abs(x1) / abs(y1)) * hypot(y2, x2);
    	else
    		tmp = 1.0 * hypot(y2, x2);
    	end
    	tmp_2 = (sign(x1) * abs(1.0)) * tmp;
    end
    
    code[x1_, y1_, x2_, y2_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[Abs[x1], $MachinePrecision] / N[Sqrt[N[(N[(N[Abs[x1], $MachinePrecision] * N[Abs[x1], $MachinePrecision]), $MachinePrecision] + N[(N[Abs[y1], $MachinePrecision] * N[Abs[y1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.1], N[(N[(N[Abs[x1], $MachinePrecision] / N[Abs[y1], $MachinePrecision]), $MachinePrecision] * N[Sqrt[y2 ^ 2 + x2 ^ 2], $MachinePrecision]), $MachinePrecision], N[(1.0 * N[Sqrt[y2 ^ 2 + x2 ^ 2], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
    
    \mathsf{copysign}\left(1, x1\right) \cdot \begin{array}{l}
    \mathbf{if}\;\frac{\left|x1\right|}{\sqrt{\left|x1\right| \cdot \left|x1\right| + \left|y1\right| \cdot \left|y1\right|}} \leq 0.1:\\
    \;\;\;\;\frac{\left|x1\right|}{\left|y1\right|} \cdot \mathsf{hypot}\left(y2, x2\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;1 \cdot \mathsf{hypot}\left(y2, x2\right)\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (/.f64 x1 (sqrt.f64 (+.f64 (*.f64 x1 x1) (*.f64 y1 y1)))) < 0.10000000000000001

      1. Initial program 66.1%

        \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      2. Step-by-step derivation
        1. lift-sqrt.f64N/A

          \[\leadsto \frac{x1}{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        2. sqrt-fabs-revN/A

          \[\leadsto \frac{x1}{\color{blue}{\left|\sqrt{x1 \cdot x1 + y1 \cdot y1}\right|}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        3. lift-sqrt.f64N/A

          \[\leadsto \frac{x1}{\left|\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}\right|} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        4. rem-sqrt-square-revN/A

          \[\leadsto \frac{x1}{\color{blue}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        5. lift-sqrt.f64N/A

          \[\leadsto \frac{x1}{\sqrt{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        6. lift-sqrt.f64N/A

          \[\leadsto \frac{x1}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        7. rem-square-sqrtN/A

          \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        8. lift-+.f64N/A

          \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        9. +-commutativeN/A

          \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1 + x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        10. lift-*.f64N/A

          \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1} + x1 \cdot x1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        11. lift-*.f64N/A

          \[\leadsto \frac{x1}{\sqrt{y1 \cdot y1 + \color{blue}{x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        12. lower-hypot.f6483.4%

          \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      3. Applied rewrites83.4%

        \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      4. Step-by-step derivation
        1. lift-sqrt.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}} \]
        2. pow1/2N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{{\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}} \]
        3. lift-+.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}} \]
        4. +-commutativeN/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}} \]
        5. lift-*.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}} \]
        6. lift-fma.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}} \]
        7. pow1/2N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \]
        8. sqrt-fabs-revN/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\left|\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right|} \]
        9. pow1/2N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}^{\frac{1}{2}}}\right| \]
        10. lift-fma.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right| \]
        11. lift-*.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right| \]
        12. +-commutativeN/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
        13. lift-+.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
        14. pow1/2N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
        15. lift-sqrt.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
        16. rem-sqrt-square-revN/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}}} \]
        17. pow2N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}^{2}}} \]
        18. lift-sqrt.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}}^{2}} \]
        19. pow1/2N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left({\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}\right)}}^{2}} \]
        20. lift-+.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
        21. +-commutativeN/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
        22. lift-*.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right)}^{2}} \]
        23. lift-fma.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}}\right)}^{2}} \]
        24. pow1/2N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right)}}^{2}} \]
      5. Applied rewrites99.8%

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\mathsf{hypot}\left(y2, x2\right)} \]
      6. Taylor expanded in y1 around inf

        \[\leadsto \color{blue}{\frac{x1}{y1}} \cdot \mathsf{hypot}\left(y2, x2\right) \]
      7. Step-by-step derivation
        1. lower-/.f6431.4%

          \[\leadsto \frac{x1}{\color{blue}{y1}} \cdot \mathsf{hypot}\left(y2, x2\right) \]
      8. Applied rewrites31.4%

        \[\leadsto \color{blue}{\frac{x1}{y1}} \cdot \mathsf{hypot}\left(y2, x2\right) \]

      if 0.10000000000000001 < (/.f64 x1 (sqrt.f64 (+.f64 (*.f64 x1 x1) (*.f64 y1 y1))))

      1. Initial program 66.1%

        \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      2. Step-by-step derivation
        1. lift-sqrt.f64N/A

          \[\leadsto \frac{x1}{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        2. sqrt-fabs-revN/A

          \[\leadsto \frac{x1}{\color{blue}{\left|\sqrt{x1 \cdot x1 + y1 \cdot y1}\right|}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        3. lift-sqrt.f64N/A

          \[\leadsto \frac{x1}{\left|\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}\right|} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        4. rem-sqrt-square-revN/A

          \[\leadsto \frac{x1}{\color{blue}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        5. lift-sqrt.f64N/A

          \[\leadsto \frac{x1}{\sqrt{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        6. lift-sqrt.f64N/A

          \[\leadsto \frac{x1}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        7. rem-square-sqrtN/A

          \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        8. lift-+.f64N/A

          \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        9. +-commutativeN/A

          \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1 + x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        10. lift-*.f64N/A

          \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1} + x1 \cdot x1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        11. lift-*.f64N/A

          \[\leadsto \frac{x1}{\sqrt{y1 \cdot y1 + \color{blue}{x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        12. lower-hypot.f6483.4%

          \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      3. Applied rewrites83.4%

        \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
      4. Step-by-step derivation
        1. lift-sqrt.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}} \]
        2. pow1/2N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{{\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}} \]
        3. lift-+.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}} \]
        4. +-commutativeN/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}} \]
        5. lift-*.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}} \]
        6. lift-fma.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}} \]
        7. pow1/2N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \]
        8. sqrt-fabs-revN/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\left|\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right|} \]
        9. pow1/2N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}^{\frac{1}{2}}}\right| \]
        10. lift-fma.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right| \]
        11. lift-*.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right| \]
        12. +-commutativeN/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
        13. lift-+.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
        14. pow1/2N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
        15. lift-sqrt.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
        16. rem-sqrt-square-revN/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}}} \]
        17. pow2N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}^{2}}} \]
        18. lift-sqrt.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}}^{2}} \]
        19. pow1/2N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left({\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}\right)}}^{2}} \]
        20. lift-+.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
        21. +-commutativeN/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
        22. lift-*.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right)}^{2}} \]
        23. lift-fma.f64N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}}\right)}^{2}} \]
        24. pow1/2N/A

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right)}}^{2}} \]
      5. Applied rewrites99.8%

        \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\mathsf{hypot}\left(y2, x2\right)} \]
      6. Taylor expanded in x1 around inf

        \[\leadsto \color{blue}{1} \cdot \mathsf{hypot}\left(y2, x2\right) \]
      7. Step-by-step derivation
        1. Applied rewrites28.2%

          \[\leadsto \color{blue}{1} \cdot \mathsf{hypot}\left(y2, x2\right) \]
      8. Recombined 2 regimes into one program.
      9. Add Preprocessing

      Alternative 4: 84.8% accurate, 0.6× speedup?

      \[\mathsf{copysign}\left(1, x1\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{\left|x1\right|}{\sqrt{\left|x1\right| \cdot \left|x1\right| + \left|y1\right| \cdot \left|y1\right|}} \leq 0.1:\\ \;\;\;\;\frac{\left|x1\right|}{\left|y1\right|} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \mathsf{hypot}\left(y2, x2\right)\\ \end{array} \]
      (FPCore (x1 y1 x2 y2)
        :precision binary64
        (*
       (copysign 1.0 x1)
       (if (<=
            (/
             (fabs x1)
             (sqrt (+ (* (fabs x1) (fabs x1)) (* (fabs y1) (fabs y1)))))
            0.1)
         (* (/ (fabs x1) (fabs y1)) (sqrt (+ (* x2 x2) (* y2 y2))))
         (* 1.0 (hypot y2 x2)))))
      double code(double x1, double y1, double x2, double y2) {
      	double tmp;
      	if ((fabs(x1) / sqrt(((fabs(x1) * fabs(x1)) + (fabs(y1) * fabs(y1))))) <= 0.1) {
      		tmp = (fabs(x1) / fabs(y1)) * sqrt(((x2 * x2) + (y2 * y2)));
      	} else {
      		tmp = 1.0 * hypot(y2, x2);
      	}
      	return copysign(1.0, x1) * tmp;
      }
      
      public static double code(double x1, double y1, double x2, double y2) {
      	double tmp;
      	if ((Math.abs(x1) / Math.sqrt(((Math.abs(x1) * Math.abs(x1)) + (Math.abs(y1) * Math.abs(y1))))) <= 0.1) {
      		tmp = (Math.abs(x1) / Math.abs(y1)) * Math.sqrt(((x2 * x2) + (y2 * y2)));
      	} else {
      		tmp = 1.0 * Math.hypot(y2, x2);
      	}
      	return Math.copySign(1.0, x1) * tmp;
      }
      
      def code(x1, y1, x2, y2):
      	tmp = 0
      	if (math.fabs(x1) / math.sqrt(((math.fabs(x1) * math.fabs(x1)) + (math.fabs(y1) * math.fabs(y1))))) <= 0.1:
      		tmp = (math.fabs(x1) / math.fabs(y1)) * math.sqrt(((x2 * x2) + (y2 * y2)))
      	else:
      		tmp = 1.0 * math.hypot(y2, x2)
      	return math.copysign(1.0, x1) * tmp
      
      function code(x1, y1, x2, y2)
      	tmp = 0.0
      	if (Float64(abs(x1) / sqrt(Float64(Float64(abs(x1) * abs(x1)) + Float64(abs(y1) * abs(y1))))) <= 0.1)
      		tmp = Float64(Float64(abs(x1) / abs(y1)) * sqrt(Float64(Float64(x2 * x2) + Float64(y2 * y2))));
      	else
      		tmp = Float64(1.0 * hypot(y2, x2));
      	end
      	return Float64(copysign(1.0, x1) * tmp)
      end
      
      function tmp_2 = code(x1, y1, x2, y2)
      	tmp = 0.0;
      	if ((abs(x1) / sqrt(((abs(x1) * abs(x1)) + (abs(y1) * abs(y1))))) <= 0.1)
      		tmp = (abs(x1) / abs(y1)) * sqrt(((x2 * x2) + (y2 * y2)));
      	else
      		tmp = 1.0 * hypot(y2, x2);
      	end
      	tmp_2 = (sign(x1) * abs(1.0)) * tmp;
      end
      
      code[x1_, y1_, x2_, y2_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[Abs[x1], $MachinePrecision] / N[Sqrt[N[(N[(N[Abs[x1], $MachinePrecision] * N[Abs[x1], $MachinePrecision]), $MachinePrecision] + N[(N[Abs[y1], $MachinePrecision] * N[Abs[y1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.1], N[(N[(N[Abs[x1], $MachinePrecision] / N[Abs[y1], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(x2 * x2), $MachinePrecision] + N[(y2 * y2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 * N[Sqrt[y2 ^ 2 + x2 ^ 2], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
      
      \mathsf{copysign}\left(1, x1\right) \cdot \begin{array}{l}
      \mathbf{if}\;\frac{\left|x1\right|}{\sqrt{\left|x1\right| \cdot \left|x1\right| + \left|y1\right| \cdot \left|y1\right|}} \leq 0.1:\\
      \;\;\;\;\frac{\left|x1\right|}{\left|y1\right|} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}\\
      
      \mathbf{else}:\\
      \;\;\;\;1 \cdot \mathsf{hypot}\left(y2, x2\right)\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (/.f64 x1 (sqrt.f64 (+.f64 (*.f64 x1 x1) (*.f64 y1 y1)))) < 0.10000000000000001

        1. Initial program 66.1%

          \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        2. Taylor expanded in y1 around inf

          \[\leadsto \color{blue}{\frac{x1}{y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        3. Step-by-step derivation
          1. lower-/.f6428.7%

            \[\leadsto \frac{x1}{\color{blue}{y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        4. Applied rewrites28.7%

          \[\leadsto \color{blue}{\frac{x1}{y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]

        if 0.10000000000000001 < (/.f64 x1 (sqrt.f64 (+.f64 (*.f64 x1 x1) (*.f64 y1 y1))))

        1. Initial program 66.1%

          \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        2. Step-by-step derivation
          1. lift-sqrt.f64N/A

            \[\leadsto \frac{x1}{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          2. sqrt-fabs-revN/A

            \[\leadsto \frac{x1}{\color{blue}{\left|\sqrt{x1 \cdot x1 + y1 \cdot y1}\right|}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          3. lift-sqrt.f64N/A

            \[\leadsto \frac{x1}{\left|\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}\right|} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          4. rem-sqrt-square-revN/A

            \[\leadsto \frac{x1}{\color{blue}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          5. lift-sqrt.f64N/A

            \[\leadsto \frac{x1}{\sqrt{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          6. lift-sqrt.f64N/A

            \[\leadsto \frac{x1}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          7. rem-square-sqrtN/A

            \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          8. lift-+.f64N/A

            \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          9. +-commutativeN/A

            \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1 + x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          10. lift-*.f64N/A

            \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1} + x1 \cdot x1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          11. lift-*.f64N/A

            \[\leadsto \frac{x1}{\sqrt{y1 \cdot y1 + \color{blue}{x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          12. lower-hypot.f6483.4%

            \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        3. Applied rewrites83.4%

          \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
        4. Step-by-step derivation
          1. lift-sqrt.f64N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}} \]
          2. pow1/2N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{{\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}} \]
          3. lift-+.f64N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}} \]
          4. +-commutativeN/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}} \]
          5. lift-*.f64N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}} \]
          6. lift-fma.f64N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}} \]
          7. pow1/2N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \]
          8. sqrt-fabs-revN/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\left|\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right|} \]
          9. pow1/2N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}^{\frac{1}{2}}}\right| \]
          10. lift-fma.f64N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right| \]
          11. lift-*.f64N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right| \]
          12. +-commutativeN/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
          13. lift-+.f64N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
          14. pow1/2N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
          15. lift-sqrt.f64N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
          16. rem-sqrt-square-revN/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}}} \]
          17. pow2N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}^{2}}} \]
          18. lift-sqrt.f64N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}}^{2}} \]
          19. pow1/2N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left({\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}\right)}}^{2}} \]
          20. lift-+.f64N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
          21. +-commutativeN/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
          22. lift-*.f64N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right)}^{2}} \]
          23. lift-fma.f64N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}}\right)}^{2}} \]
          24. pow1/2N/A

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right)}}^{2}} \]
        5. Applied rewrites99.8%

          \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\mathsf{hypot}\left(y2, x2\right)} \]
        6. Taylor expanded in x1 around inf

          \[\leadsto \color{blue}{1} \cdot \mathsf{hypot}\left(y2, x2\right) \]
        7. Step-by-step derivation
          1. Applied rewrites28.2%

            \[\leadsto \color{blue}{1} \cdot \mathsf{hypot}\left(y2, x2\right) \]
        8. Recombined 2 regimes into one program.
        9. Add Preprocessing

        Alternative 5: 74.5% accurate, 0.6× speedup?

        \[\mathsf{copysign}\left(1, x1\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{\left|x1\right|}{\sqrt{\left|x1\right| \cdot \left|x1\right| + \left|y1\right| \cdot \left|y1\right|}} \leq 0.995:\\ \;\;\;\;\frac{\left|x1\right|}{\left|y1\right|} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)} \cdot 1\\ \end{array} \]
        (FPCore (x1 y1 x2 y2)
          :precision binary64
          (*
         (copysign 1.0 x1)
         (if (<=
              (/
               (fabs x1)
               (sqrt (+ (* (fabs x1) (fabs x1)) (* (fabs y1) (fabs y1)))))
              0.995)
           (* (/ (fabs x1) (fabs y1)) (sqrt (+ (* x2 x2) (* y2 y2))))
           (* (sqrt (fma y2 y2 (* x2 x2))) 1.0))))
        double code(double x1, double y1, double x2, double y2) {
        	double tmp;
        	if ((fabs(x1) / sqrt(((fabs(x1) * fabs(x1)) + (fabs(y1) * fabs(y1))))) <= 0.995) {
        		tmp = (fabs(x1) / fabs(y1)) * sqrt(((x2 * x2) + (y2 * y2)));
        	} else {
        		tmp = sqrt(fma(y2, y2, (x2 * x2))) * 1.0;
        	}
        	return copysign(1.0, x1) * tmp;
        }
        
        function code(x1, y1, x2, y2)
        	tmp = 0.0
        	if (Float64(abs(x1) / sqrt(Float64(Float64(abs(x1) * abs(x1)) + Float64(abs(y1) * abs(y1))))) <= 0.995)
        		tmp = Float64(Float64(abs(x1) / abs(y1)) * sqrt(Float64(Float64(x2 * x2) + Float64(y2 * y2))));
        	else
        		tmp = Float64(sqrt(fma(y2, y2, Float64(x2 * x2))) * 1.0);
        	end
        	return Float64(copysign(1.0, x1) * tmp)
        end
        
        code[x1_, y1_, x2_, y2_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[Abs[x1], $MachinePrecision] / N[Sqrt[N[(N[(N[Abs[x1], $MachinePrecision] * N[Abs[x1], $MachinePrecision]), $MachinePrecision] + N[(N[Abs[y1], $MachinePrecision] * N[Abs[y1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.995], N[(N[(N[Abs[x1], $MachinePrecision] / N[Abs[y1], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(x2 * x2), $MachinePrecision] + N[(y2 * y2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(y2 * y2 + N[(x2 * x2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]]), $MachinePrecision]
        
        \mathsf{copysign}\left(1, x1\right) \cdot \begin{array}{l}
        \mathbf{if}\;\frac{\left|x1\right|}{\sqrt{\left|x1\right| \cdot \left|x1\right| + \left|y1\right| \cdot \left|y1\right|}} \leq 0.995:\\
        \;\;\;\;\frac{\left|x1\right|}{\left|y1\right|} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}\\
        
        \mathbf{else}:\\
        \;\;\;\;\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)} \cdot 1\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (/.f64 x1 (sqrt.f64 (+.f64 (*.f64 x1 x1) (*.f64 y1 y1)))) < 0.995

          1. Initial program 66.1%

            \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          2. Taylor expanded in y1 around inf

            \[\leadsto \color{blue}{\frac{x1}{y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          3. Step-by-step derivation
            1. lower-/.f6428.7%

              \[\leadsto \frac{x1}{\color{blue}{y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          4. Applied rewrites28.7%

            \[\leadsto \color{blue}{\frac{x1}{y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]

          if 0.995 < (/.f64 x1 (sqrt.f64 (+.f64 (*.f64 x1 x1) (*.f64 y1 y1))))

          1. Initial program 66.1%

            \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          2. Step-by-step derivation
            1. lift-sqrt.f64N/A

              \[\leadsto \frac{x1}{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            2. sqrt-fabs-revN/A

              \[\leadsto \frac{x1}{\color{blue}{\left|\sqrt{x1 \cdot x1 + y1 \cdot y1}\right|}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            3. lift-sqrt.f64N/A

              \[\leadsto \frac{x1}{\left|\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}\right|} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            4. rem-sqrt-square-revN/A

              \[\leadsto \frac{x1}{\color{blue}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            5. lift-sqrt.f64N/A

              \[\leadsto \frac{x1}{\sqrt{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            6. lift-sqrt.f64N/A

              \[\leadsto \frac{x1}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            7. rem-square-sqrtN/A

              \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            8. lift-+.f64N/A

              \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            9. +-commutativeN/A

              \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1 + x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            10. lift-*.f64N/A

              \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1} + x1 \cdot x1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            11. lift-*.f64N/A

              \[\leadsto \frac{x1}{\sqrt{y1 \cdot y1 + \color{blue}{x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            12. lower-hypot.f6483.4%

              \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          3. Applied rewrites83.4%

            \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
          4. Step-by-step derivation
            1. lift-sqrt.f64N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}} \]
            2. pow1/2N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{{\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}} \]
            3. lift-+.f64N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}} \]
            4. +-commutativeN/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}} \]
            5. lift-*.f64N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}} \]
            6. lift-fma.f64N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}} \]
            7. pow1/2N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \]
            8. sqrt-fabs-revN/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\left|\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right|} \]
            9. pow1/2N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}^{\frac{1}{2}}}\right| \]
            10. lift-fma.f64N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right| \]
            11. lift-*.f64N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right| \]
            12. +-commutativeN/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
            13. lift-+.f64N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
            14. pow1/2N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
            15. lift-sqrt.f64N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
            16. rem-sqrt-square-revN/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}}} \]
            17. pow2N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}^{2}}} \]
            18. lift-sqrt.f64N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}}^{2}} \]
            19. pow1/2N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left({\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}\right)}}^{2}} \]
            20. lift-+.f64N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
            21. +-commutativeN/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
            22. lift-*.f64N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right)}^{2}} \]
            23. lift-fma.f64N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}}\right)}^{2}} \]
            24. pow1/2N/A

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right)}}^{2}} \]
          5. Applied rewrites99.8%

            \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\mathsf{hypot}\left(y2, x2\right)} \]
          6. Taylor expanded in x1 around inf

            \[\leadsto \color{blue}{1} \cdot \mathsf{hypot}\left(y2, x2\right) \]
          7. Step-by-step derivation
            1. Applied rewrites28.2%

              \[\leadsto \color{blue}{1} \cdot \mathsf{hypot}\left(y2, x2\right) \]
            2. Step-by-step derivation
              1. lift-*.f64N/A

                \[\leadsto \color{blue}{1 \cdot \mathsf{hypot}\left(y2, x2\right)} \]
              2. *-commutativeN/A

                \[\leadsto \color{blue}{\mathsf{hypot}\left(y2, x2\right) \cdot 1} \]
              3. lower-*.f6428.2%

                \[\leadsto \color{blue}{\mathsf{hypot}\left(y2, x2\right) \cdot 1} \]
              4. lift-hypot.f64N/A

                \[\leadsto \color{blue}{\sqrt{y2 \cdot y2 + x2 \cdot x2}} \cdot 1 \]
              5. lift-*.f64N/A

                \[\leadsto \sqrt{y2 \cdot y2 + \color{blue}{x2 \cdot x2}} \cdot 1 \]
              6. lift-fma.f64N/A

                \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \cdot 1 \]
              7. lift-sqrt.f6428.1%

                \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \cdot 1 \]
            3. Applied rewrites28.1%

              \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)} \cdot 1} \]
          8. Recombined 2 regimes into one program.
          9. Add Preprocessing

          Alternative 6: 74.5% accurate, 0.6× speedup?

          \[\begin{array}{l} t_0 := \sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\\ \mathsf{copysign}\left(1, x1\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{\left|x1\right|}{\sqrt{\left|x1\right| \cdot \left|x1\right| + \left|y1\right| \cdot \left|y1\right|}} \leq 0.995:\\ \;\;\;\;\frac{\left|x1\right|}{\left|y1\right|} \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot 1\\ \end{array} \end{array} \]
          (FPCore (x1 y1 x2 y2)
            :precision binary64
            (let* ((t_0 (sqrt (fma y2 y2 (* x2 x2)))))
            (*
             (copysign 1.0 x1)
             (if (<=
                  (/
                   (fabs x1)
                   (sqrt (+ (* (fabs x1) (fabs x1)) (* (fabs y1) (fabs y1)))))
                  0.995)
               (* (/ (fabs x1) (fabs y1)) t_0)
               (* t_0 1.0)))))
          double code(double x1, double y1, double x2, double y2) {
          	double t_0 = sqrt(fma(y2, y2, (x2 * x2)));
          	double tmp;
          	if ((fabs(x1) / sqrt(((fabs(x1) * fabs(x1)) + (fabs(y1) * fabs(y1))))) <= 0.995) {
          		tmp = (fabs(x1) / fabs(y1)) * t_0;
          	} else {
          		tmp = t_0 * 1.0;
          	}
          	return copysign(1.0, x1) * tmp;
          }
          
          function code(x1, y1, x2, y2)
          	t_0 = sqrt(fma(y2, y2, Float64(x2 * x2)))
          	tmp = 0.0
          	if (Float64(abs(x1) / sqrt(Float64(Float64(abs(x1) * abs(x1)) + Float64(abs(y1) * abs(y1))))) <= 0.995)
          		tmp = Float64(Float64(abs(x1) / abs(y1)) * t_0);
          	else
          		tmp = Float64(t_0 * 1.0);
          	end
          	return Float64(copysign(1.0, x1) * tmp)
          end
          
          code[x1_, y1_, x2_, y2_] := Block[{t$95$0 = N[Sqrt[N[(y2 * y2 + N[(x2 * x2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[Abs[x1], $MachinePrecision] / N[Sqrt[N[(N[(N[Abs[x1], $MachinePrecision] * N[Abs[x1], $MachinePrecision]), $MachinePrecision] + N[(N[Abs[y1], $MachinePrecision] * N[Abs[y1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.995], N[(N[(N[Abs[x1], $MachinePrecision] / N[Abs[y1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(t$95$0 * 1.0), $MachinePrecision]]), $MachinePrecision]]
          
          \begin{array}{l}
          t_0 := \sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\\
          \mathsf{copysign}\left(1, x1\right) \cdot \begin{array}{l}
          \mathbf{if}\;\frac{\left|x1\right|}{\sqrt{\left|x1\right| \cdot \left|x1\right| + \left|y1\right| \cdot \left|y1\right|}} \leq 0.995:\\
          \;\;\;\;\frac{\left|x1\right|}{\left|y1\right|} \cdot t\_0\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0 \cdot 1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (/.f64 x1 (sqrt.f64 (+.f64 (*.f64 x1 x1) (*.f64 y1 y1)))) < 0.995

            1. Initial program 66.1%

              \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            2. Step-by-step derivation
              1. lift-sqrt.f64N/A

                \[\leadsto \frac{x1}{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              2. sqrt-fabs-revN/A

                \[\leadsto \frac{x1}{\color{blue}{\left|\sqrt{x1 \cdot x1 + y1 \cdot y1}\right|}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              3. lift-sqrt.f64N/A

                \[\leadsto \frac{x1}{\left|\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}\right|} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              4. rem-sqrt-square-revN/A

                \[\leadsto \frac{x1}{\color{blue}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              5. lift-sqrt.f64N/A

                \[\leadsto \frac{x1}{\sqrt{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              6. lift-sqrt.f64N/A

                \[\leadsto \frac{x1}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              7. rem-square-sqrtN/A

                \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              8. lift-+.f64N/A

                \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              9. +-commutativeN/A

                \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1 + x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              10. lift-*.f64N/A

                \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1} + x1 \cdot x1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              11. lift-*.f64N/A

                \[\leadsto \frac{x1}{\sqrt{y1 \cdot y1 + \color{blue}{x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              12. lower-hypot.f6483.4%

                \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            3. Applied rewrites83.4%

              \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            4. Step-by-step derivation
              1. lift-+.f64N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{x2 \cdot x2 + y2 \cdot y2}} \]
              2. +-commutativeN/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{y2 \cdot y2 + x2 \cdot x2}} \]
              3. lift-*.f64N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{y2 \cdot y2} + x2 \cdot x2} \]
              4. lift-fma.f6483.4%

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \]
            5. Applied rewrites83.4%

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \]
            6. Taylor expanded in y1 around inf

              \[\leadsto \color{blue}{\frac{x1}{y1}} \cdot \sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)} \]
            7. Step-by-step derivation
              1. lower-/.f6428.7%

                \[\leadsto \frac{x1}{\color{blue}{y1}} \cdot \sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)} \]
            8. Applied rewrites28.7%

              \[\leadsto \color{blue}{\frac{x1}{y1}} \cdot \sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)} \]

            if 0.995 < (/.f64 x1 (sqrt.f64 (+.f64 (*.f64 x1 x1) (*.f64 y1 y1))))

            1. Initial program 66.1%

              \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            2. Step-by-step derivation
              1. lift-sqrt.f64N/A

                \[\leadsto \frac{x1}{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              2. sqrt-fabs-revN/A

                \[\leadsto \frac{x1}{\color{blue}{\left|\sqrt{x1 \cdot x1 + y1 \cdot y1}\right|}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              3. lift-sqrt.f64N/A

                \[\leadsto \frac{x1}{\left|\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}\right|} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              4. rem-sqrt-square-revN/A

                \[\leadsto \frac{x1}{\color{blue}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              5. lift-sqrt.f64N/A

                \[\leadsto \frac{x1}{\sqrt{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              6. lift-sqrt.f64N/A

                \[\leadsto \frac{x1}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              7. rem-square-sqrtN/A

                \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              8. lift-+.f64N/A

                \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              9. +-commutativeN/A

                \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1 + x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              10. lift-*.f64N/A

                \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1} + x1 \cdot x1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              11. lift-*.f64N/A

                \[\leadsto \frac{x1}{\sqrt{y1 \cdot y1 + \color{blue}{x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              12. lower-hypot.f6483.4%

                \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            3. Applied rewrites83.4%

              \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
            4. Step-by-step derivation
              1. lift-sqrt.f64N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}} \]
              2. pow1/2N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{{\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}} \]
              3. lift-+.f64N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}} \]
              4. +-commutativeN/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}} \]
              5. lift-*.f64N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}} \]
              6. lift-fma.f64N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}} \]
              7. pow1/2N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \]
              8. sqrt-fabs-revN/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\left|\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right|} \]
              9. pow1/2N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}^{\frac{1}{2}}}\right| \]
              10. lift-fma.f64N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right| \]
              11. lift-*.f64N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right| \]
              12. +-commutativeN/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
              13. lift-+.f64N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
              14. pow1/2N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
              15. lift-sqrt.f64N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
              16. rem-sqrt-square-revN/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}}} \]
              17. pow2N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}^{2}}} \]
              18. lift-sqrt.f64N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}}^{2}} \]
              19. pow1/2N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left({\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}\right)}}^{2}} \]
              20. lift-+.f64N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
              21. +-commutativeN/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
              22. lift-*.f64N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right)}^{2}} \]
              23. lift-fma.f64N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}}\right)}^{2}} \]
              24. pow1/2N/A

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right)}}^{2}} \]
            5. Applied rewrites99.8%

              \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\mathsf{hypot}\left(y2, x2\right)} \]
            6. Taylor expanded in x1 around inf

              \[\leadsto \color{blue}{1} \cdot \mathsf{hypot}\left(y2, x2\right) \]
            7. Step-by-step derivation
              1. Applied rewrites28.2%

                \[\leadsto \color{blue}{1} \cdot \mathsf{hypot}\left(y2, x2\right) \]
              2. Step-by-step derivation
                1. lift-*.f64N/A

                  \[\leadsto \color{blue}{1 \cdot \mathsf{hypot}\left(y2, x2\right)} \]
                2. *-commutativeN/A

                  \[\leadsto \color{blue}{\mathsf{hypot}\left(y2, x2\right) \cdot 1} \]
                3. lower-*.f6428.2%

                  \[\leadsto \color{blue}{\mathsf{hypot}\left(y2, x2\right) \cdot 1} \]
                4. lift-hypot.f64N/A

                  \[\leadsto \color{blue}{\sqrt{y2 \cdot y2 + x2 \cdot x2}} \cdot 1 \]
                5. lift-*.f64N/A

                  \[\leadsto \sqrt{y2 \cdot y2 + \color{blue}{x2 \cdot x2}} \cdot 1 \]
                6. lift-fma.f64N/A

                  \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \cdot 1 \]
                7. lift-sqrt.f6428.1%

                  \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \cdot 1 \]
              3. Applied rewrites28.1%

                \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)} \cdot 1} \]
            8. Recombined 2 regimes into one program.
            9. Add Preprocessing

            Alternative 7: 70.6% accurate, 0.5× speedup?

            \[\begin{array}{l} t_0 := \mathsf{min}\left(\left|x2\right|, \left|y2\right|\right)\\ t_1 := \mathsf{max}\left(\left|x2\right|, \left|y2\right|\right)\\ \mathsf{copysign}\left(1, x1\right) \cdot \begin{array}{l} \mathbf{if}\;\frac{\left|x1\right|}{\sqrt{\left|x1\right| \cdot \left|x1\right| + \left|y1\right| \cdot \left|y1\right|}} \leq 0.995:\\ \;\;\;\;\frac{-1}{\left|y1\right|} \cdot \left(\left(-1 \cdot t\_1\right) \cdot \left|x1\right|\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(t\_1, t\_1, t\_0 \cdot t\_0\right)} \cdot 1\\ \end{array} \end{array} \]
            (FPCore (x1 y1 x2 y2)
              :precision binary64
              (let* ((t_0 (fmin (fabs x2) (fabs y2)))
                   (t_1 (fmax (fabs x2) (fabs y2))))
              (*
               (copysign 1.0 x1)
               (if (<=
                    (/
                     (fabs x1)
                     (sqrt (+ (* (fabs x1) (fabs x1)) (* (fabs y1) (fabs y1)))))
                    0.995)
                 (* (/ -1.0 (fabs y1)) (* (* -1.0 t_1) (fabs x1)))
                 (* (sqrt (fma t_1 t_1 (* t_0 t_0))) 1.0)))))
            double code(double x1, double y1, double x2, double y2) {
            	double t_0 = fmin(fabs(x2), fabs(y2));
            	double t_1 = fmax(fabs(x2), fabs(y2));
            	double tmp;
            	if ((fabs(x1) / sqrt(((fabs(x1) * fabs(x1)) + (fabs(y1) * fabs(y1))))) <= 0.995) {
            		tmp = (-1.0 / fabs(y1)) * ((-1.0 * t_1) * fabs(x1));
            	} else {
            		tmp = sqrt(fma(t_1, t_1, (t_0 * t_0))) * 1.0;
            	}
            	return copysign(1.0, x1) * tmp;
            }
            
            function code(x1, y1, x2, y2)
            	t_0 = (abs(x2) != abs(x2)) ? abs(y2) : ((abs(y2) != abs(y2)) ? abs(x2) : min(abs(x2), abs(y2)))
            	t_1 = (abs(x2) != abs(x2)) ? abs(y2) : ((abs(y2) != abs(y2)) ? abs(x2) : max(abs(x2), abs(y2)))
            	tmp = 0.0
            	if (Float64(abs(x1) / sqrt(Float64(Float64(abs(x1) * abs(x1)) + Float64(abs(y1) * abs(y1))))) <= 0.995)
            		tmp = Float64(Float64(-1.0 / abs(y1)) * Float64(Float64(-1.0 * t_1) * abs(x1)));
            	else
            		tmp = Float64(sqrt(fma(t_1, t_1, Float64(t_0 * t_0))) * 1.0);
            	end
            	return Float64(copysign(1.0, x1) * tmp)
            end
            
            code[x1_, y1_, x2_, y2_] := Block[{t$95$0 = N[Min[N[Abs[x2], $MachinePrecision], N[Abs[y2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Abs[x2], $MachinePrecision], N[Abs[y2], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[Abs[x1], $MachinePrecision] / N[Sqrt[N[(N[(N[Abs[x1], $MachinePrecision] * N[Abs[x1], $MachinePrecision]), $MachinePrecision] + N[(N[Abs[y1], $MachinePrecision] * N[Abs[y1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.995], N[(N[(-1.0 / N[Abs[y1], $MachinePrecision]), $MachinePrecision] * N[(N[(-1.0 * t$95$1), $MachinePrecision] * N[Abs[x1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(t$95$1 * t$95$1 + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]]), $MachinePrecision]]]
            
            \begin{array}{l}
            t_0 := \mathsf{min}\left(\left|x2\right|, \left|y2\right|\right)\\
            t_1 := \mathsf{max}\left(\left|x2\right|, \left|y2\right|\right)\\
            \mathsf{copysign}\left(1, x1\right) \cdot \begin{array}{l}
            \mathbf{if}\;\frac{\left|x1\right|}{\sqrt{\left|x1\right| \cdot \left|x1\right| + \left|y1\right| \cdot \left|y1\right|}} \leq 0.995:\\
            \;\;\;\;\frac{-1}{\left|y1\right|} \cdot \left(\left(-1 \cdot t\_1\right) \cdot \left|x1\right|\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;\sqrt{\mathsf{fma}\left(t\_1, t\_1, t\_0 \cdot t\_0\right)} \cdot 1\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (/.f64 x1 (sqrt.f64 (+.f64 (*.f64 x1 x1) (*.f64 y1 y1)))) < 0.995

              1. Initial program 66.1%

                \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              2. Step-by-step derivation
                1. lift-*.f64N/A

                  \[\leadsto \color{blue}{\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}} \]
                2. *-commutativeN/A

                  \[\leadsto \color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}} \]
                3. lift-/.f64N/A

                  \[\leadsto \sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \color{blue}{\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}} \]
                4. frac-2negN/A

                  \[\leadsto \sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \color{blue}{\frac{\mathsf{neg}\left(x1\right)}{\mathsf{neg}\left(\sqrt{x1 \cdot x1 + y1 \cdot y1}\right)}} \]
                5. associate-*r/N/A

                  \[\leadsto \color{blue}{\frac{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \left(\mathsf{neg}\left(x1\right)\right)}{\mathsf{neg}\left(\sqrt{x1 \cdot x1 + y1 \cdot y1}\right)}} \]
                6. mult-flipN/A

                  \[\leadsto \color{blue}{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \left(\mathsf{neg}\left(x1\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{x1 \cdot x1 + y1 \cdot y1}\right)}} \]
                7. *-commutativeN/A

                  \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left(\sqrt{x1 \cdot x1 + y1 \cdot y1}\right)} \cdot \left(\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \left(\mathsf{neg}\left(x1\right)\right)\right)} \]
                8. lower-*.f64N/A

                  \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left(\sqrt{x1 \cdot x1 + y1 \cdot y1}\right)} \cdot \left(\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \left(\mathsf{neg}\left(x1\right)\right)\right)} \]
              3. Applied rewrites60.9%

                \[\leadsto \color{blue}{\frac{-1}{\sqrt{\mathsf{fma}\left(y1, y1, x1 \cdot x1\right)}} \cdot \left(\left(-\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right) \cdot x1\right)} \]
              4. Taylor expanded in y1 around inf

                \[\leadsto \color{blue}{\frac{-1}{y1}} \cdot \left(\left(-\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right) \cdot x1\right) \]
              5. Step-by-step derivation
                1. lower-/.f6424.1%

                  \[\leadsto \frac{-1}{\color{blue}{y1}} \cdot \left(\left(-\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right) \cdot x1\right) \]
              6. Applied rewrites24.1%

                \[\leadsto \color{blue}{\frac{-1}{y1}} \cdot \left(\left(-\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right) \cdot x1\right) \]
              7. Taylor expanded in y2 around inf

                \[\leadsto \frac{-1}{y1} \cdot \left(\color{blue}{\left(-1 \cdot y2\right)} \cdot x1\right) \]
              8. Step-by-step derivation
                1. lower-*.f6418.8%

                  \[\leadsto \frac{-1}{y1} \cdot \left(\left(-1 \cdot \color{blue}{y2}\right) \cdot x1\right) \]
              9. Applied rewrites18.8%

                \[\leadsto \frac{-1}{y1} \cdot \left(\color{blue}{\left(-1 \cdot y2\right)} \cdot x1\right) \]

              if 0.995 < (/.f64 x1 (sqrt.f64 (+.f64 (*.f64 x1 x1) (*.f64 y1 y1))))

              1. Initial program 66.1%

                \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              2. Step-by-step derivation
                1. lift-sqrt.f64N/A

                  \[\leadsto \frac{x1}{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
                2. sqrt-fabs-revN/A

                  \[\leadsto \frac{x1}{\color{blue}{\left|\sqrt{x1 \cdot x1 + y1 \cdot y1}\right|}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
                3. lift-sqrt.f64N/A

                  \[\leadsto \frac{x1}{\left|\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}\right|} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
                4. rem-sqrt-square-revN/A

                  \[\leadsto \frac{x1}{\color{blue}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
                5. lift-sqrt.f64N/A

                  \[\leadsto \frac{x1}{\sqrt{\color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
                6. lift-sqrt.f64N/A

                  \[\leadsto \frac{x1}{\sqrt{\sqrt{x1 \cdot x1 + y1 \cdot y1} \cdot \color{blue}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
                7. rem-square-sqrtN/A

                  \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
                8. lift-+.f64N/A

                  \[\leadsto \frac{x1}{\sqrt{\color{blue}{x1 \cdot x1 + y1 \cdot y1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
                9. +-commutativeN/A

                  \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1 + x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
                10. lift-*.f64N/A

                  \[\leadsto \frac{x1}{\sqrt{\color{blue}{y1 \cdot y1} + x1 \cdot x1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
                11. lift-*.f64N/A

                  \[\leadsto \frac{x1}{\sqrt{y1 \cdot y1 + \color{blue}{x1 \cdot x1}}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
                12. lower-hypot.f6483.4%

                  \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              3. Applied rewrites83.4%

                \[\leadsto \frac{x1}{\color{blue}{\mathsf{hypot}\left(y1, x1\right)}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              4. Step-by-step derivation
                1. lift-sqrt.f64N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}} \]
                2. pow1/2N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{{\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}} \]
                3. lift-+.f64N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}} \]
                4. +-commutativeN/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}} \]
                5. lift-*.f64N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}} \]
                6. lift-fma.f64N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot {\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}} \]
                7. pow1/2N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \]
                8. sqrt-fabs-revN/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\left|\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right|} \]
                9. pow1/2N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}^{\frac{1}{2}}}\right| \]
                10. lift-fma.f64N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right| \]
                11. lift-*.f64N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right| \]
                12. +-commutativeN/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
                13. lift-+.f64N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right| \]
                14. pow1/2N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
                15. lift-sqrt.f64N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \left|\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}}\right| \]
                16. rem-sqrt-square-revN/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\sqrt{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}}} \]
                17. pow2N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{\color{blue}{{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}^{2}}} \]
                18. lift-sqrt.f64N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2}\right)}}^{2}} \]
                19. pow1/2N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left({\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}\right)}}^{2}} \]
                20. lift-+.f64N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
                21. +-commutativeN/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}}\right)}^{2}} \]
                22. lift-*.f64N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}}\right)}^{2}} \]
                23. lift-fma.f64N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\left({\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}}\right)}^{2}} \]
                24. pow1/2N/A

                  \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \sqrt{{\color{blue}{\left(\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right)}}^{2}} \]
              5. Applied rewrites99.8%

                \[\leadsto \frac{x1}{\mathsf{hypot}\left(y1, x1\right)} \cdot \color{blue}{\mathsf{hypot}\left(y2, x2\right)} \]
              6. Taylor expanded in x1 around inf

                \[\leadsto \color{blue}{1} \cdot \mathsf{hypot}\left(y2, x2\right) \]
              7. Step-by-step derivation
                1. Applied rewrites28.2%

                  \[\leadsto \color{blue}{1} \cdot \mathsf{hypot}\left(y2, x2\right) \]
                2. Step-by-step derivation
                  1. lift-*.f64N/A

                    \[\leadsto \color{blue}{1 \cdot \mathsf{hypot}\left(y2, x2\right)} \]
                  2. *-commutativeN/A

                    \[\leadsto \color{blue}{\mathsf{hypot}\left(y2, x2\right) \cdot 1} \]
                  3. lower-*.f6428.2%

                    \[\leadsto \color{blue}{\mathsf{hypot}\left(y2, x2\right) \cdot 1} \]
                  4. lift-hypot.f64N/A

                    \[\leadsto \color{blue}{\sqrt{y2 \cdot y2 + x2 \cdot x2}} \cdot 1 \]
                  5. lift-*.f64N/A

                    \[\leadsto \sqrt{y2 \cdot y2 + \color{blue}{x2 \cdot x2}} \cdot 1 \]
                  6. lift-fma.f64N/A

                    \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \cdot 1 \]
                  7. lift-sqrt.f6428.1%

                    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \cdot 1 \]
                3. Applied rewrites28.1%

                  \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)} \cdot 1} \]
              8. Recombined 2 regimes into one program.
              9. Add Preprocessing

              Alternative 8: 38.1% accurate, 1.5× speedup?

              \[\frac{-1}{\left|y1\right|} \cdot \left(\left(-1 \cdot \mathsf{max}\left(\left|x2\right|, \left|y2\right|\right)\right) \cdot x1\right) \]
              (FPCore (x1 y1 x2 y2)
                :precision binary64
                (* (/ -1.0 (fabs y1)) (* (* -1.0 (fmax (fabs x2) (fabs y2))) x1)))
              double code(double x1, double y1, double x2, double y2) {
              	return (-1.0 / fabs(y1)) * ((-1.0 * fmax(fabs(x2), fabs(y2))) * x1);
              }
              
              real(8) function code(x1, y1, x2, y2)
                  real(8), intent (in) :: x1
                  real(8), intent (in) :: y1
                  real(8), intent (in) :: x2
                  real(8), intent (in) :: y2
                  code = ((-1.0d0) / abs(y1)) * (((-1.0d0) * merge(abs(y2), merge(abs(x2), max(abs(x2), abs(y2)), abs(y2) /= abs(y2)), abs(x2) /= abs(x2))) * x1)
              end function
              
              public static double code(double x1, double y1, double x2, double y2) {
              	return (-1.0 / Math.abs(y1)) * ((-1.0 * fmax(Math.abs(x2), Math.abs(y2))) * x1);
              }
              
              def code(x1, y1, x2, y2):
              	return (-1.0 / math.fabs(y1)) * ((-1.0 * fmax(math.fabs(x2), math.fabs(y2))) * x1)
              
              function code(x1, y1, x2, y2)
              	return Float64(Float64(-1.0 / abs(y1)) * Float64(Float64(-1.0 * ((abs(x2) != abs(x2)) ? abs(y2) : ((abs(y2) != abs(y2)) ? abs(x2) : max(abs(x2), abs(y2))))) * x1))
              end
              
              function tmp = code(x1, y1, x2, y2)
              	tmp = (-1.0 / abs(y1)) * ((-1.0 * max(abs(x2), abs(y2))) * x1);
              end
              
              code[x1_, y1_, x2_, y2_] := N[(N[(-1.0 / N[Abs[y1], $MachinePrecision]), $MachinePrecision] * N[(N[(-1.0 * N[Max[N[Abs[x2], $MachinePrecision], N[Abs[y2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * x1), $MachinePrecision]), $MachinePrecision]
              
              \frac{-1}{\left|y1\right|} \cdot \left(\left(-1 \cdot \mathsf{max}\left(\left|x2\right|, \left|y2\right|\right)\right) \cdot x1\right)
              
              Derivation
              1. Initial program 66.1%

                \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              2. Step-by-step derivation
                1. lift-*.f64N/A

                  \[\leadsto \color{blue}{\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}} \]
                2. *-commutativeN/A

                  \[\leadsto \color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}} \]
                3. lift-/.f64N/A

                  \[\leadsto \sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \color{blue}{\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}}} \]
                4. frac-2negN/A

                  \[\leadsto \sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \color{blue}{\frac{\mathsf{neg}\left(x1\right)}{\mathsf{neg}\left(\sqrt{x1 \cdot x1 + y1 \cdot y1}\right)}} \]
                5. associate-*r/N/A

                  \[\leadsto \color{blue}{\frac{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \left(\mathsf{neg}\left(x1\right)\right)}{\mathsf{neg}\left(\sqrt{x1 \cdot x1 + y1 \cdot y1}\right)}} \]
                6. mult-flipN/A

                  \[\leadsto \color{blue}{\left(\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \left(\mathsf{neg}\left(x1\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\sqrt{x1 \cdot x1 + y1 \cdot y1}\right)}} \]
                7. *-commutativeN/A

                  \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left(\sqrt{x1 \cdot x1 + y1 \cdot y1}\right)} \cdot \left(\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \left(\mathsf{neg}\left(x1\right)\right)\right)} \]
                8. lower-*.f64N/A

                  \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left(\sqrt{x1 \cdot x1 + y1 \cdot y1}\right)} \cdot \left(\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \left(\mathsf{neg}\left(x1\right)\right)\right)} \]
              3. Applied rewrites60.9%

                \[\leadsto \color{blue}{\frac{-1}{\sqrt{\mathsf{fma}\left(y1, y1, x1 \cdot x1\right)}} \cdot \left(\left(-\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right) \cdot x1\right)} \]
              4. Taylor expanded in y1 around inf

                \[\leadsto \color{blue}{\frac{-1}{y1}} \cdot \left(\left(-\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right) \cdot x1\right) \]
              5. Step-by-step derivation
                1. lower-/.f6424.1%

                  \[\leadsto \frac{-1}{\color{blue}{y1}} \cdot \left(\left(-\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right) \cdot x1\right) \]
              6. Applied rewrites24.1%

                \[\leadsto \color{blue}{\frac{-1}{y1}} \cdot \left(\left(-\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}\right) \cdot x1\right) \]
              7. Taylor expanded in y2 around inf

                \[\leadsto \frac{-1}{y1} \cdot \left(\color{blue}{\left(-1 \cdot y2\right)} \cdot x1\right) \]
              8. Step-by-step derivation
                1. lower-*.f6418.8%

                  \[\leadsto \frac{-1}{y1} \cdot \left(\left(-1 \cdot \color{blue}{y2}\right) \cdot x1\right) \]
              9. Applied rewrites18.8%

                \[\leadsto \frac{-1}{y1} \cdot \left(\color{blue}{\left(-1 \cdot y2\right)} \cdot x1\right) \]
              10. Add Preprocessing

              Alternative 9: 38.1% accurate, 1.6× speedup?

              \[\frac{-1 \cdot \left(x1 \cdot \mathsf{max}\left(\left|x2\right|, \left|y2\right|\right)\right)}{-\left|y1\right|} \]
              (FPCore (x1 y1 x2 y2)
                :precision binary64
                (/ (* -1.0 (* x1 (fmax (fabs x2) (fabs y2)))) (- (fabs y1))))
              double code(double x1, double y1, double x2, double y2) {
              	return (-1.0 * (x1 * fmax(fabs(x2), fabs(y2)))) / -fabs(y1);
              }
              
              real(8) function code(x1, y1, x2, y2)
                  real(8), intent (in) :: x1
                  real(8), intent (in) :: y1
                  real(8), intent (in) :: x2
                  real(8), intent (in) :: y2
                  code = ((-1.0d0) * (x1 * merge(abs(y2), merge(abs(x2), max(abs(x2), abs(y2)), abs(y2) /= abs(y2)), abs(x2) /= abs(x2)))) / -abs(y1)
              end function
              
              public static double code(double x1, double y1, double x2, double y2) {
              	return (-1.0 * (x1 * fmax(Math.abs(x2), Math.abs(y2)))) / -Math.abs(y1);
              }
              
              def code(x1, y1, x2, y2):
              	return (-1.0 * (x1 * fmax(math.fabs(x2), math.fabs(y2)))) / -math.fabs(y1)
              
              function code(x1, y1, x2, y2)
              	return Float64(Float64(-1.0 * Float64(x1 * ((abs(x2) != abs(x2)) ? abs(y2) : ((abs(y2) != abs(y2)) ? abs(x2) : max(abs(x2), abs(y2)))))) / Float64(-abs(y1)))
              end
              
              function tmp = code(x1, y1, x2, y2)
              	tmp = (-1.0 * (x1 * max(abs(x2), abs(y2)))) / -abs(y1);
              end
              
              code[x1_, y1_, x2_, y2_] := N[(N[(-1.0 * N[(x1 * N[Max[N[Abs[x2], $MachinePrecision], N[Abs[y2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-N[Abs[y1], $MachinePrecision])), $MachinePrecision]
              
              \frac{-1 \cdot \left(x1 \cdot \mathsf{max}\left(\left|x2\right|, \left|y2\right|\right)\right)}{-\left|y1\right|}
              
              Derivation
              1. Initial program 66.1%

                \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              2. Taylor expanded in y1 around -inf

                \[\leadsto \frac{x1}{\color{blue}{-1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              3. Step-by-step derivation
                1. lower-*.f6428.5%

                  \[\leadsto \frac{x1}{-1 \cdot \color{blue}{y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              4. Applied rewrites28.5%

                \[\leadsto \frac{x1}{\color{blue}{-1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              5. Step-by-step derivation
                1. lift-*.f64N/A

                  \[\leadsto \color{blue}{\frac{x1}{-1 \cdot y1} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}} \]
                2. *-commutativeN/A

                  \[\leadsto \color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \frac{x1}{-1 \cdot y1}} \]
                3. lift-/.f64N/A

                  \[\leadsto \sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \color{blue}{\frac{x1}{-1 \cdot y1}} \]
                4. associate-*r/N/A

                  \[\leadsto \color{blue}{\frac{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot x1}{-1 \cdot y1}} \]
                5. lift-sqrt.f64N/A

                  \[\leadsto \frac{\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}} \cdot x1}{-1 \cdot y1} \]
                6. pow1/2N/A

                  \[\leadsto \frac{\color{blue}{{\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}} \cdot x1}{-1 \cdot y1} \]
                7. lift-+.f64N/A

                  \[\leadsto \frac{{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}} \cdot x1}{-1 \cdot y1} \]
                8. +-commutativeN/A

                  \[\leadsto \frac{{\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}} \cdot x1}{-1 \cdot y1} \]
                9. lift-*.f64N/A

                  \[\leadsto \frac{{\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}} \cdot x1}{-1 \cdot y1} \]
                10. lift-fma.f64N/A

                  \[\leadsto \frac{{\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}} \cdot x1}{-1 \cdot y1} \]
                11. pow1/2N/A

                  \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \cdot x1}{-1 \cdot y1} \]
                12. lift-sqrt.f64N/A

                  \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \cdot x1}{-1 \cdot y1} \]
                13. lower-/.f64N/A

                  \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)} \cdot x1}{-1 \cdot y1}} \]
              6. Applied rewrites24.0%

                \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)} \cdot x1}{-y1}} \]
              7. Taylor expanded in x2 around inf

                \[\leadsto \frac{\color{blue}{x1 \cdot x2}}{-y1} \]
              8. Step-by-step derivation
                1. lower-*.f6418.0%

                  \[\leadsto \frac{x1 \cdot \color{blue}{x2}}{-y1} \]
              9. Applied rewrites18.0%

                \[\leadsto \frac{\color{blue}{x1 \cdot x2}}{-y1} \]
              10. Taylor expanded in y2 around -inf

                \[\leadsto \frac{\color{blue}{-1 \cdot \left(x1 \cdot y2\right)}}{-y1} \]
              11. Step-by-step derivation
                1. lower-*.f64N/A

                  \[\leadsto \frac{-1 \cdot \color{blue}{\left(x1 \cdot y2\right)}}{-y1} \]
                2. lower-*.f6418.8%

                  \[\leadsto \frac{-1 \cdot \left(x1 \cdot \color{blue}{y2}\right)}{-y1} \]
              12. Applied rewrites18.8%

                \[\leadsto \frac{\color{blue}{-1 \cdot \left(x1 \cdot y2\right)}}{-y1} \]
              13. Add Preprocessing

              Alternative 10: 25.1% accurate, 2.1× speedup?

              \[\frac{-1 \cdot \left(x1 \cdot \left|x2\right|\right)}{-\left|y1\right|} \]
              (FPCore (x1 y1 x2 y2)
                :precision binary64
                (/ (* -1.0 (* x1 (fabs x2))) (- (fabs y1))))
              double code(double x1, double y1, double x2, double y2) {
              	return (-1.0 * (x1 * fabs(x2))) / -fabs(y1);
              }
              
              real(8) function code(x1, y1, x2, y2)
                  real(8), intent (in) :: x1
                  real(8), intent (in) :: y1
                  real(8), intent (in) :: x2
                  real(8), intent (in) :: y2
                  code = ((-1.0d0) * (x1 * abs(x2))) / -abs(y1)
              end function
              
              public static double code(double x1, double y1, double x2, double y2) {
              	return (-1.0 * (x1 * Math.abs(x2))) / -Math.abs(y1);
              }
              
              def code(x1, y1, x2, y2):
              	return (-1.0 * (x1 * math.fabs(x2))) / -math.fabs(y1)
              
              function code(x1, y1, x2, y2)
              	return Float64(Float64(-1.0 * Float64(x1 * abs(x2))) / Float64(-abs(y1)))
              end
              
              function tmp = code(x1, y1, x2, y2)
              	tmp = (-1.0 * (x1 * abs(x2))) / -abs(y1);
              end
              
              code[x1_, y1_, x2_, y2_] := N[(N[(-1.0 * N[(x1 * N[Abs[x2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-N[Abs[y1], $MachinePrecision])), $MachinePrecision]
              
              \frac{-1 \cdot \left(x1 \cdot \left|x2\right|\right)}{-\left|y1\right|}
              
              Derivation
              1. Initial program 66.1%

                \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              2. Taylor expanded in y1 around -inf

                \[\leadsto \frac{x1}{\color{blue}{-1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              3. Step-by-step derivation
                1. lower-*.f6428.5%

                  \[\leadsto \frac{x1}{-1 \cdot \color{blue}{y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              4. Applied rewrites28.5%

                \[\leadsto \frac{x1}{\color{blue}{-1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              5. Step-by-step derivation
                1. lift-*.f64N/A

                  \[\leadsto \color{blue}{\frac{x1}{-1 \cdot y1} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}} \]
                2. *-commutativeN/A

                  \[\leadsto \color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \frac{x1}{-1 \cdot y1}} \]
                3. lift-/.f64N/A

                  \[\leadsto \sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \color{blue}{\frac{x1}{-1 \cdot y1}} \]
                4. associate-*r/N/A

                  \[\leadsto \color{blue}{\frac{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot x1}{-1 \cdot y1}} \]
                5. lift-sqrt.f64N/A

                  \[\leadsto \frac{\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}} \cdot x1}{-1 \cdot y1} \]
                6. pow1/2N/A

                  \[\leadsto \frac{\color{blue}{{\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}} \cdot x1}{-1 \cdot y1} \]
                7. lift-+.f64N/A

                  \[\leadsto \frac{{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}} \cdot x1}{-1 \cdot y1} \]
                8. +-commutativeN/A

                  \[\leadsto \frac{{\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}} \cdot x1}{-1 \cdot y1} \]
                9. lift-*.f64N/A

                  \[\leadsto \frac{{\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}} \cdot x1}{-1 \cdot y1} \]
                10. lift-fma.f64N/A

                  \[\leadsto \frac{{\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}} \cdot x1}{-1 \cdot y1} \]
                11. pow1/2N/A

                  \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \cdot x1}{-1 \cdot y1} \]
                12. lift-sqrt.f64N/A

                  \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \cdot x1}{-1 \cdot y1} \]
                13. lower-/.f64N/A

                  \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)} \cdot x1}{-1 \cdot y1}} \]
              6. Applied rewrites24.0%

                \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)} \cdot x1}{-y1}} \]
              7. Taylor expanded in x2 around inf

                \[\leadsto \frac{\color{blue}{x1 \cdot x2}}{-y1} \]
              8. Step-by-step derivation
                1. lower-*.f6418.0%

                  \[\leadsto \frac{x1 \cdot \color{blue}{x2}}{-y1} \]
              9. Applied rewrites18.0%

                \[\leadsto \frac{\color{blue}{x1 \cdot x2}}{-y1} \]
              10. Taylor expanded in x2 around -inf

                \[\leadsto \frac{\color{blue}{-1 \cdot \left(x1 \cdot x2\right)}}{-y1} \]
              11. Step-by-step derivation
                1. lower-*.f64N/A

                  \[\leadsto \frac{-1 \cdot \color{blue}{\left(x1 \cdot x2\right)}}{-y1} \]
                2. lower-*.f6418.4%

                  \[\leadsto \frac{-1 \cdot \left(x1 \cdot \color{blue}{x2}\right)}{-y1} \]
              12. Applied rewrites18.4%

                \[\leadsto \frac{\color{blue}{-1 \cdot \left(x1 \cdot x2\right)}}{-y1} \]
              13. Add Preprocessing

              Alternative 11: 18.0% accurate, 3.3× speedup?

              \[\frac{x1 \cdot x2}{-y1} \]
              (FPCore (x1 y1 x2 y2)
                :precision binary64
                (/ (* x1 x2) (- y1)))
              double code(double x1, double y1, double x2, double y2) {
              	return (x1 * x2) / -y1;
              }
              
              real(8) function code(x1, y1, x2, y2)
                  real(8), intent (in) :: x1
                  real(8), intent (in) :: y1
                  real(8), intent (in) :: x2
                  real(8), intent (in) :: y2
                  code = (x1 * x2) / -y1
              end function
              
              public static double code(double x1, double y1, double x2, double y2) {
              	return (x1 * x2) / -y1;
              }
              
              def code(x1, y1, x2, y2):
              	return (x1 * x2) / -y1
              
              function code(x1, y1, x2, y2)
              	return Float64(Float64(x1 * x2) / Float64(-y1))
              end
              
              function tmp = code(x1, y1, x2, y2)
              	tmp = (x1 * x2) / -y1;
              end
              
              code[x1_, y1_, x2_, y2_] := N[(N[(x1 * x2), $MachinePrecision] / (-y1)), $MachinePrecision]
              
              \frac{x1 \cdot x2}{-y1}
              
              Derivation
              1. Initial program 66.1%

                \[\frac{x1}{\sqrt{x1 \cdot x1 + y1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              2. Taylor expanded in y1 around -inf

                \[\leadsto \frac{x1}{\color{blue}{-1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              3. Step-by-step derivation
                1. lower-*.f6428.5%

                  \[\leadsto \frac{x1}{-1 \cdot \color{blue}{y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              4. Applied rewrites28.5%

                \[\leadsto \frac{x1}{\color{blue}{-1 \cdot y1}} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2} \]
              5. Step-by-step derivation
                1. lift-*.f64N/A

                  \[\leadsto \color{blue}{\frac{x1}{-1 \cdot y1} \cdot \sqrt{x2 \cdot x2 + y2 \cdot y2}} \]
                2. *-commutativeN/A

                  \[\leadsto \color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \frac{x1}{-1 \cdot y1}} \]
                3. lift-/.f64N/A

                  \[\leadsto \sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot \color{blue}{\frac{x1}{-1 \cdot y1}} \]
                4. associate-*r/N/A

                  \[\leadsto \color{blue}{\frac{\sqrt{x2 \cdot x2 + y2 \cdot y2} \cdot x1}{-1 \cdot y1}} \]
                5. lift-sqrt.f64N/A

                  \[\leadsto \frac{\color{blue}{\sqrt{x2 \cdot x2 + y2 \cdot y2}} \cdot x1}{-1 \cdot y1} \]
                6. pow1/2N/A

                  \[\leadsto \frac{\color{blue}{{\left(x2 \cdot x2 + y2 \cdot y2\right)}^{\frac{1}{2}}} \cdot x1}{-1 \cdot y1} \]
                7. lift-+.f64N/A

                  \[\leadsto \frac{{\color{blue}{\left(x2 \cdot x2 + y2 \cdot y2\right)}}^{\frac{1}{2}} \cdot x1}{-1 \cdot y1} \]
                8. +-commutativeN/A

                  \[\leadsto \frac{{\color{blue}{\left(y2 \cdot y2 + x2 \cdot x2\right)}}^{\frac{1}{2}} \cdot x1}{-1 \cdot y1} \]
                9. lift-*.f64N/A

                  \[\leadsto \frac{{\left(\color{blue}{y2 \cdot y2} + x2 \cdot x2\right)}^{\frac{1}{2}} \cdot x1}{-1 \cdot y1} \]
                10. lift-fma.f64N/A

                  \[\leadsto \frac{{\color{blue}{\left(\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)\right)}}^{\frac{1}{2}} \cdot x1}{-1 \cdot y1} \]
                11. pow1/2N/A

                  \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \cdot x1}{-1 \cdot y1} \]
                12. lift-sqrt.f64N/A

                  \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)}} \cdot x1}{-1 \cdot y1} \]
                13. lower-/.f64N/A

                  \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)} \cdot x1}{-1 \cdot y1}} \]
              6. Applied rewrites24.0%

                \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(y2, y2, x2 \cdot x2\right)} \cdot x1}{-y1}} \]
              7. Taylor expanded in x2 around inf

                \[\leadsto \frac{\color{blue}{x1 \cdot x2}}{-y1} \]
              8. Step-by-step derivation
                1. lower-*.f6418.0%

                  \[\leadsto \frac{x1 \cdot \color{blue}{x2}}{-y1} \]
              9. Applied rewrites18.0%

                \[\leadsto \frac{\color{blue}{x1 \cdot x2}}{-y1} \]
              10. Add Preprocessing

              Reproduce

              ?
              herbie shell --seed 1 
              (FPCore (x1 y1 x2 y2)
                :name "x1/sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2)"
                :precision binary64
                :pre (and (and (and (and (<= -1000.0 x1) (<= x1 1000.0)) (and (<= -1000.0 y1) (<= y1 1000.0))) (and (<= -1000.0 x2) (<= x2 1000.0))) (and (<= -1000.0 y2) (<= y2 1000.0)))
                (* (/ x1 (sqrt (+ (* x1 x1) (* y1 y1)))) (sqrt (+ (* x2 x2) (* y2 y2)))))