Simplification of discriminant from scale-rotated-ellipse

Percentage Accurate: 24.4% → 95.8%
Time: 31.9s
Alternatives: 4
Speedup: 1693.0×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{angle}{180} \cdot \pi\\ t_1 := \sin t\_0\\ t_2 := \cos t\_0\\ t_3 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\\ t\_3 \cdot t\_3 - \left(4 \cdot \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale} \end{array} \end{array} \]
(FPCore (a b angle x-scale y-scale)
 :precision binary64
 (let* ((t_0 (* (/ angle 180.0) PI))
        (t_1 (sin t_0))
        (t_2 (cos t_0))
        (t_3
         (/
          (/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_2) x-scale)
          y-scale)))
   (-
    (* t_3 t_3)
    (*
     (*
      4.0
      (/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) x-scale) x-scale))
     (/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) y-scale) y-scale)))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double t_0 = (angle / 180.0) * ((double) M_PI);
	double t_1 = sin(t_0);
	double t_2 = cos(t_0);
	double t_3 = ((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale;
	return (t_3 * t_3) - ((4.0 * (((pow((a * t_1), 2.0) + pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((pow((a * t_2), 2.0) + pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale));
}
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double t_0 = (angle / 180.0) * Math.PI;
	double t_1 = Math.sin(t_0);
	double t_2 = Math.cos(t_0);
	double t_3 = ((((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale;
	return (t_3 * t_3) - ((4.0 * (((Math.pow((a * t_1), 2.0) + Math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((Math.pow((a * t_2), 2.0) + Math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale));
}
def code(a, b, angle, x_45_scale, y_45_scale):
	t_0 = (angle / 180.0) * math.pi
	t_1 = math.sin(t_0)
	t_2 = math.cos(t_0)
	t_3 = ((((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale
	return (t_3 * t_3) - ((4.0 * (((math.pow((a * t_1), 2.0) + math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((math.pow((a * t_2), 2.0) + math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale))
function code(a, b, angle, x_45_scale, y_45_scale)
	t_0 = Float64(Float64(angle / 180.0) * pi)
	t_1 = sin(t_0)
	t_2 = cos(t_0)
	t_3 = Float64(Float64(Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale)
	return Float64(Float64(t_3 * t_3) - Float64(Float64(4.0 * Float64(Float64(Float64((Float64(a * t_1) ^ 2.0) + (Float64(b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale)) * Float64(Float64(Float64((Float64(a * t_2) ^ 2.0) + (Float64(b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale)))
end
function tmp = code(a, b, angle, x_45_scale, y_45_scale)
	t_0 = (angle / 180.0) * pi;
	t_1 = sin(t_0);
	t_2 = cos(t_0);
	t_3 = ((((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale;
	tmp = (t_3 * t_3) - ((4.0 * (((((a * t_1) ^ 2.0) + ((b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale)) * (((((a * t_2) ^ 2.0) + ((b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale));
end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, Block[{t$95$1 = N[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision] / x$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]}, N[(N[(t$95$3 * t$95$3), $MachinePrecision] - N[(N[(4.0 * N[(N[(N[(N[Power[N[(a * t$95$1), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$2), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / x$45$scale), $MachinePrecision] / x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Power[N[(a * t$95$2), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
t_3 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\\
t\_3 \cdot t\_3 - \left(4 \cdot \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale}
\end{array}
\end{array}

Sampling outcomes in binary64 precision:

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 4 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: 24.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{angle}{180} \cdot \pi\\ t_1 := \sin t\_0\\ t_2 := \cos t\_0\\ t_3 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\\ t\_3 \cdot t\_3 - \left(4 \cdot \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale} \end{array} \end{array} \]
(FPCore (a b angle x-scale y-scale)
 :precision binary64
 (let* ((t_0 (* (/ angle 180.0) PI))
        (t_1 (sin t_0))
        (t_2 (cos t_0))
        (t_3
         (/
          (/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_2) x-scale)
          y-scale)))
   (-
    (* t_3 t_3)
    (*
     (*
      4.0
      (/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) x-scale) x-scale))
     (/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) y-scale) y-scale)))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double t_0 = (angle / 180.0) * ((double) M_PI);
	double t_1 = sin(t_0);
	double t_2 = cos(t_0);
	double t_3 = ((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale;
	return (t_3 * t_3) - ((4.0 * (((pow((a * t_1), 2.0) + pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((pow((a * t_2), 2.0) + pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale));
}
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double t_0 = (angle / 180.0) * Math.PI;
	double t_1 = Math.sin(t_0);
	double t_2 = Math.cos(t_0);
	double t_3 = ((((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale;
	return (t_3 * t_3) - ((4.0 * (((Math.pow((a * t_1), 2.0) + Math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((Math.pow((a * t_2), 2.0) + Math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale));
}
def code(a, b, angle, x_45_scale, y_45_scale):
	t_0 = (angle / 180.0) * math.pi
	t_1 = math.sin(t_0)
	t_2 = math.cos(t_0)
	t_3 = ((((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale
	return (t_3 * t_3) - ((4.0 * (((math.pow((a * t_1), 2.0) + math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((math.pow((a * t_2), 2.0) + math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale))
function code(a, b, angle, x_45_scale, y_45_scale)
	t_0 = Float64(Float64(angle / 180.0) * pi)
	t_1 = sin(t_0)
	t_2 = cos(t_0)
	t_3 = Float64(Float64(Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale)
	return Float64(Float64(t_3 * t_3) - Float64(Float64(4.0 * Float64(Float64(Float64((Float64(a * t_1) ^ 2.0) + (Float64(b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale)) * Float64(Float64(Float64((Float64(a * t_2) ^ 2.0) + (Float64(b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale)))
end
function tmp = code(a, b, angle, x_45_scale, y_45_scale)
	t_0 = (angle / 180.0) * pi;
	t_1 = sin(t_0);
	t_2 = cos(t_0);
	t_3 = ((((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale;
	tmp = (t_3 * t_3) - ((4.0 * (((((a * t_1) ^ 2.0) + ((b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale)) * (((((a * t_2) ^ 2.0) + ((b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale));
end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, Block[{t$95$1 = N[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision] / x$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]}, N[(N[(t$95$3 * t$95$3), $MachinePrecision] - N[(N[(4.0 * N[(N[(N[(N[Power[N[(a * t$95$1), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$2), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / x$45$scale), $MachinePrecision] / x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Power[N[(a * t$95$2), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
t_3 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\\
t\_3 \cdot t\_3 - \left(4 \cdot \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale}
\end{array}
\end{array}

Alternative 1: 95.8% accurate, 0.9× speedup?

\[\begin{array}{l} x-scale_m = \left|x-scale\right| \\ y-scale_m = \left|y-scale\right| \\ \begin{array}{l} t_0 := \frac{angle}{180} \cdot \pi\\ t_1 := \sin t\_0\\ t_2 := \frac{b \cdot a}{\sqrt{x-scale\_m \cdot y-scale\_m}}\\ t_3 := \cos t\_0\\ t_4 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_3}{x-scale\_m}}{y-scale\_m}\\ \mathbf{if}\;t\_4 \cdot t\_4 - \left(4 \cdot \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_3\right)}^{2}}{x-scale\_m}}{x-scale\_m}\right) \cdot \frac{\frac{{\left(a \cdot t\_3\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale\_m}}{y-scale\_m} \leq 2 \cdot 10^{+263}:\\ \;\;\;\;-4 \cdot {\left(\frac{a}{y-scale\_m} \cdot \frac{b}{x-scale\_m}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(t\_2 \cdot \frac{t\_2}{x-scale\_m \cdot y-scale\_m}\right)\\ \end{array} \end{array} \]
x-scale_m = (fabs.f64 x-scale)
y-scale_m = (fabs.f64 y-scale)
(FPCore (a b angle x-scale_m y-scale_m)
 :precision binary64
 (let* ((t_0 (* (/ angle 180.0) PI))
        (t_1 (sin t_0))
        (t_2 (/ (* b a) (sqrt (* x-scale_m y-scale_m))))
        (t_3 (cos t_0))
        (t_4
         (/
          (/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_3) x-scale_m)
          y-scale_m)))
   (if (<=
        (-
         (* t_4 t_4)
         (*
          (*
           4.0
           (/
            (/ (+ (pow (* a t_1) 2.0) (pow (* b t_3) 2.0)) x-scale_m)
            x-scale_m))
          (/
           (/ (+ (pow (* a t_3) 2.0) (pow (* b t_1) 2.0)) y-scale_m)
           y-scale_m)))
        2e+263)
     (* -4.0 (pow (* (/ a y-scale_m) (/ b x-scale_m)) 2.0))
     (* -4.0 (* t_2 (/ t_2 (* x-scale_m y-scale_m)))))))
x-scale_m = fabs(x_45_scale);
y-scale_m = fabs(y_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
	double t_0 = (angle / 180.0) * ((double) M_PI);
	double t_1 = sin(t_0);
	double t_2 = (b * a) / sqrt((x_45_scale_m * y_45_scale_m));
	double t_3 = cos(t_0);
	double t_4 = ((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * t_1) * t_3) / x_45_scale_m) / y_45_scale_m;
	double tmp;
	if (((t_4 * t_4) - ((4.0 * (((pow((a * t_1), 2.0) + pow((b * t_3), 2.0)) / x_45_scale_m) / x_45_scale_m)) * (((pow((a * t_3), 2.0) + pow((b * t_1), 2.0)) / y_45_scale_m) / y_45_scale_m))) <= 2e+263) {
		tmp = -4.0 * pow(((a / y_45_scale_m) * (b / x_45_scale_m)), 2.0);
	} else {
		tmp = -4.0 * (t_2 * (t_2 / (x_45_scale_m * y_45_scale_m)));
	}
	return tmp;
}
x-scale_m = Math.abs(x_45_scale);
y-scale_m = Math.abs(y_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
	double t_0 = (angle / 180.0) * Math.PI;
	double t_1 = Math.sin(t_0);
	double t_2 = (b * a) / Math.sqrt((x_45_scale_m * y_45_scale_m));
	double t_3 = Math.cos(t_0);
	double t_4 = ((((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * t_1) * t_3) / x_45_scale_m) / y_45_scale_m;
	double tmp;
	if (((t_4 * t_4) - ((4.0 * (((Math.pow((a * t_1), 2.0) + Math.pow((b * t_3), 2.0)) / x_45_scale_m) / x_45_scale_m)) * (((Math.pow((a * t_3), 2.0) + Math.pow((b * t_1), 2.0)) / y_45_scale_m) / y_45_scale_m))) <= 2e+263) {
		tmp = -4.0 * Math.pow(((a / y_45_scale_m) * (b / x_45_scale_m)), 2.0);
	} else {
		tmp = -4.0 * (t_2 * (t_2 / (x_45_scale_m * y_45_scale_m)));
	}
	return tmp;
}
x-scale_m = math.fabs(x_45_scale)
y-scale_m = math.fabs(y_45_scale)
def code(a, b, angle, x_45_scale_m, y_45_scale_m):
	t_0 = (angle / 180.0) * math.pi
	t_1 = math.sin(t_0)
	t_2 = (b * a) / math.sqrt((x_45_scale_m * y_45_scale_m))
	t_3 = math.cos(t_0)
	t_4 = ((((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * t_1) * t_3) / x_45_scale_m) / y_45_scale_m
	tmp = 0
	if ((t_4 * t_4) - ((4.0 * (((math.pow((a * t_1), 2.0) + math.pow((b * t_3), 2.0)) / x_45_scale_m) / x_45_scale_m)) * (((math.pow((a * t_3), 2.0) + math.pow((b * t_1), 2.0)) / y_45_scale_m) / y_45_scale_m))) <= 2e+263:
		tmp = -4.0 * math.pow(((a / y_45_scale_m) * (b / x_45_scale_m)), 2.0)
	else:
		tmp = -4.0 * (t_2 * (t_2 / (x_45_scale_m * y_45_scale_m)))
	return tmp
x-scale_m = abs(x_45_scale)
y-scale_m = abs(y_45_scale)
function code(a, b, angle, x_45_scale_m, y_45_scale_m)
	t_0 = Float64(Float64(angle / 180.0) * pi)
	t_1 = sin(t_0)
	t_2 = Float64(Float64(b * a) / sqrt(Float64(x_45_scale_m * y_45_scale_m)))
	t_3 = cos(t_0)
	t_4 = Float64(Float64(Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_3) / x_45_scale_m) / y_45_scale_m)
	tmp = 0.0
	if (Float64(Float64(t_4 * t_4) - Float64(Float64(4.0 * Float64(Float64(Float64((Float64(a * t_1) ^ 2.0) + (Float64(b * t_3) ^ 2.0)) / x_45_scale_m) / x_45_scale_m)) * Float64(Float64(Float64((Float64(a * t_3) ^ 2.0) + (Float64(b * t_1) ^ 2.0)) / y_45_scale_m) / y_45_scale_m))) <= 2e+263)
		tmp = Float64(-4.0 * (Float64(Float64(a / y_45_scale_m) * Float64(b / x_45_scale_m)) ^ 2.0));
	else
		tmp = Float64(-4.0 * Float64(t_2 * Float64(t_2 / Float64(x_45_scale_m * y_45_scale_m))));
	end
	return tmp
end
x-scale_m = abs(x_45_scale);
y-scale_m = abs(y_45_scale);
function tmp_2 = code(a, b, angle, x_45_scale_m, y_45_scale_m)
	t_0 = (angle / 180.0) * pi;
	t_1 = sin(t_0);
	t_2 = (b * a) / sqrt((x_45_scale_m * y_45_scale_m));
	t_3 = cos(t_0);
	t_4 = ((((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_3) / x_45_scale_m) / y_45_scale_m;
	tmp = 0.0;
	if (((t_4 * t_4) - ((4.0 * (((((a * t_1) ^ 2.0) + ((b * t_3) ^ 2.0)) / x_45_scale_m) / x_45_scale_m)) * (((((a * t_3) ^ 2.0) + ((b * t_1) ^ 2.0)) / y_45_scale_m) / y_45_scale_m))) <= 2e+263)
		tmp = -4.0 * (((a / y_45_scale_m) * (b / x_45_scale_m)) ^ 2.0);
	else
		tmp = -4.0 * (t_2 * (t_2 / (x_45_scale_m * y_45_scale_m)));
	end
	tmp_2 = tmp;
end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
y-scale_m = N[Abs[y$45$scale], $MachinePrecision]
code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale$95$m_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, Block[{t$95$1 = N[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(b * a), $MachinePrecision] / N[Sqrt[N[(x$45$scale$95$m * y$45$scale$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$3), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision] / y$45$scale$95$m), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$4 * t$95$4), $MachinePrecision] - N[(N[(4.0 * N[(N[(N[(N[Power[N[(a * t$95$1), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$3), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Power[N[(a * t$95$3), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / y$45$scale$95$m), $MachinePrecision] / y$45$scale$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+263], N[(-4.0 * N[Power[N[(N[(a / y$45$scale$95$m), $MachinePrecision] * N[(b / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(t$95$2 * N[(t$95$2 / N[(x$45$scale$95$m * y$45$scale$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
y-scale_m = \left|y-scale\right|

\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
t_1 := \sin t\_0\\
t_2 := \frac{b \cdot a}{\sqrt{x-scale\_m \cdot y-scale\_m}}\\
t_3 := \cos t\_0\\
t_4 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_3}{x-scale\_m}}{y-scale\_m}\\
\mathbf{if}\;t\_4 \cdot t\_4 - \left(4 \cdot \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_3\right)}^{2}}{x-scale\_m}}{x-scale\_m}\right) \cdot \frac{\frac{{\left(a \cdot t\_3\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale\_m}}{y-scale\_m} \leq 2 \cdot 10^{+263}:\\
\;\;\;\;-4 \cdot {\left(\frac{a}{y-scale\_m} \cdot \frac{b}{x-scale\_m}\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(t\_2 \cdot \frac{t\_2}{x-scale\_m \cdot y-scale\_m}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale) (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale)) (*.f64 (*.f64 #s(literal 4 binary64) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) x-scale) x-scale)) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) y-scale) y-scale))) < 2.00000000000000003e263

    1. Initial program 61.5%

      \[\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} \cdot \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{y-scale}}{y-scale} \]
    2. Simplified50.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{angle \cdot \pi}{180}\right) \cdot \frac{\left({b}^{2} - {a}^{2}\right) \cdot \left(2 \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}{x-scale \cdot y-scale}, \cos \left(\frac{angle \cdot \pi}{180}\right) \cdot \frac{\left({b}^{2} - {a}^{2}\right) \cdot \left(2 \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}{x-scale \cdot y-scale}, \frac{{\left(a \cdot \cos \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2}}{{y-scale}^{2}} \cdot \left(\frac{{\left(a \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2}}{{x-scale}^{2}} \cdot -4\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in angle around 0 61.7%

      \[\leadsto \color{blue}{-4 \cdot \frac{{a}^{2} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
    5. Step-by-step derivation
      1. *-commutative61.7%

        \[\leadsto -4 \cdot \frac{\color{blue}{{b}^{2} \cdot {a}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      2. unpow261.7%

        \[\leadsto -4 \cdot \frac{\color{blue}{\left(b \cdot b\right)} \cdot {a}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      3. unpow261.7%

        \[\leadsto -4 \cdot \frac{\left(b \cdot b\right) \cdot \color{blue}{\left(a \cdot a\right)}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      4. swap-sqr64.1%

        \[\leadsto -4 \cdot \frac{\color{blue}{\left(b \cdot a\right) \cdot \left(b \cdot a\right)}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      5. unpow264.1%

        \[\leadsto -4 \cdot \frac{\color{blue}{{\left(b \cdot a\right)}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      6. *-commutative64.1%

        \[\leadsto -4 \cdot \frac{{\color{blue}{\left(a \cdot b\right)}}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      7. unpow264.1%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\color{blue}{\left(x-scale \cdot x-scale\right)} \cdot {y-scale}^{2}} \]
      8. unpow264.1%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\left(x-scale \cdot x-scale\right) \cdot \color{blue}{\left(y-scale \cdot y-scale\right)}} \]
      9. swap-sqr73.1%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\color{blue}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}} \]
      10. unpow273.1%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\color{blue}{{\left(x-scale \cdot y-scale\right)}^{2}}} \]
    6. Simplified73.1%

      \[\leadsto \color{blue}{-4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}} \]
    7. Step-by-step derivation
      1. associate-*r/73.1%

        \[\leadsto \color{blue}{\frac{-4 \cdot {\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}} \]
    8. Applied egg-rr73.1%

      \[\leadsto \color{blue}{\frac{-4 \cdot {\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}} \]
    9. Step-by-step derivation
      1. *-commutative73.1%

        \[\leadsto \frac{-4 \cdot {\left(a \cdot b\right)}^{2}}{{\color{blue}{\left(y-scale \cdot x-scale\right)}}^{2}} \]
      2. unpow-prod-down64.1%

        \[\leadsto \frac{-4 \cdot {\left(a \cdot b\right)}^{2}}{\color{blue}{{y-scale}^{2} \cdot {x-scale}^{2}}} \]
    10. Applied egg-rr64.1%

      \[\leadsto \frac{-4 \cdot {\left(a \cdot b\right)}^{2}}{\color{blue}{{y-scale}^{2} \cdot {x-scale}^{2}}} \]
    11. Taylor expanded in a around 0 61.7%

      \[\leadsto \color{blue}{-4 \cdot \frac{{a}^{2} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
    12. Step-by-step derivation
      1. *-commutative61.7%

        \[\leadsto \color{blue}{\frac{{a}^{2} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -4} \]
      2. unpow261.7%

        \[\leadsto \frac{\color{blue}{\left(a \cdot a\right)} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -4 \]
      3. unpow261.7%

        \[\leadsto \frac{\left(a \cdot a\right) \cdot \color{blue}{\left(b \cdot b\right)}}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -4 \]
      4. swap-sqr64.1%

        \[\leadsto \frac{\color{blue}{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -4 \]
      5. unpow264.1%

        \[\leadsto \frac{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}{\color{blue}{\left(x-scale \cdot x-scale\right)} \cdot {y-scale}^{2}} \cdot -4 \]
      6. unpow264.1%

        \[\leadsto \frac{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}{\left(x-scale \cdot x-scale\right) \cdot \color{blue}{\left(y-scale \cdot y-scale\right)}} \cdot -4 \]
      7. swap-sqr73.1%

        \[\leadsto \frac{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}{\color{blue}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}} \cdot -4 \]
      8. times-frac91.3%

        \[\leadsto \color{blue}{\left(\frac{a \cdot b}{x-scale \cdot y-scale} \cdot \frac{a \cdot b}{x-scale \cdot y-scale}\right)} \cdot -4 \]
      9. rem-square-sqrt0.0%

        \[\leadsto \left(\frac{a \cdot b}{x-scale \cdot y-scale} \cdot \frac{a \cdot b}{x-scale \cdot y-scale}\right) \cdot \color{blue}{\left(\sqrt{-4} \cdot \sqrt{-4}\right)} \]
      10. swap-sqr0.0%

        \[\leadsto \color{blue}{\left(\frac{a \cdot b}{x-scale \cdot y-scale} \cdot \sqrt{-4}\right) \cdot \left(\frac{a \cdot b}{x-scale \cdot y-scale} \cdot \sqrt{-4}\right)} \]
      11. times-frac0.0%

        \[\leadsto \left(\color{blue}{\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)} \cdot \sqrt{-4}\right) \cdot \left(\frac{a \cdot b}{x-scale \cdot y-scale} \cdot \sqrt{-4}\right) \]
      12. times-frac0.0%

        \[\leadsto \left(\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right) \cdot \sqrt{-4}\right) \cdot \left(\color{blue}{\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)} \cdot \sqrt{-4}\right) \]
      13. swap-sqr0.0%

        \[\leadsto \color{blue}{\left(\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right) \cdot \left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)\right) \cdot \left(\sqrt{-4} \cdot \sqrt{-4}\right)} \]
      14. unpow20.0%

        \[\leadsto \color{blue}{{\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)}^{2}} \cdot \left(\sqrt{-4} \cdot \sqrt{-4}\right) \]
      15. rem-square-sqrt96.8%

        \[\leadsto {\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)}^{2} \cdot \color{blue}{-4} \]
      16. *-commutative96.8%

        \[\leadsto \color{blue}{-4 \cdot {\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)}^{2}} \]
    13. Simplified99.6%

      \[\leadsto \color{blue}{-4 \cdot {\left(\frac{a}{y-scale} \cdot \frac{b}{x-scale}\right)}^{2}} \]

    if 2.00000000000000003e263 < (-.f64 (*.f64 (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale) (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale)) (*.f64 (*.f64 #s(literal 4 binary64) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) x-scale) x-scale)) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) y-scale) y-scale)))

    1. Initial program 0.0%

      \[\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} \cdot \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{y-scale}}{y-scale} \]
    2. Simplified2.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{angle \cdot \pi}{180}\right) \cdot \frac{\left({b}^{2} - {a}^{2}\right) \cdot \left(2 \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}{x-scale \cdot y-scale}, \cos \left(\frac{angle \cdot \pi}{180}\right) \cdot \frac{\left({b}^{2} - {a}^{2}\right) \cdot \left(2 \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}{x-scale \cdot y-scale}, \frac{{\left(a \cdot \cos \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2}}{{y-scale}^{2}} \cdot \left(\frac{{\left(a \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2}}{{x-scale}^{2}} \cdot -4\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in angle around 0 38.7%

      \[\leadsto \color{blue}{-4 \cdot \frac{{a}^{2} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
    5. Step-by-step derivation
      1. *-commutative38.7%

        \[\leadsto -4 \cdot \frac{\color{blue}{{b}^{2} \cdot {a}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      2. unpow238.7%

        \[\leadsto -4 \cdot \frac{\color{blue}{\left(b \cdot b\right)} \cdot {a}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      3. unpow238.7%

        \[\leadsto -4 \cdot \frac{\left(b \cdot b\right) \cdot \color{blue}{\left(a \cdot a\right)}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      4. swap-sqr57.1%

        \[\leadsto -4 \cdot \frac{\color{blue}{\left(b \cdot a\right) \cdot \left(b \cdot a\right)}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      5. unpow257.1%

        \[\leadsto -4 \cdot \frac{\color{blue}{{\left(b \cdot a\right)}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      6. *-commutative57.1%

        \[\leadsto -4 \cdot \frac{{\color{blue}{\left(a \cdot b\right)}}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      7. unpow257.1%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\color{blue}{\left(x-scale \cdot x-scale\right)} \cdot {y-scale}^{2}} \]
      8. unpow257.1%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\left(x-scale \cdot x-scale\right) \cdot \color{blue}{\left(y-scale \cdot y-scale\right)}} \]
      9. swap-sqr78.6%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\color{blue}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}} \]
      10. unpow278.6%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\color{blue}{{\left(x-scale \cdot y-scale\right)}^{2}}} \]
    6. Simplified78.6%

      \[\leadsto \color{blue}{-4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}} \]
    7. Step-by-step derivation
      1. add-cbrt-cube67.9%

        \[\leadsto -4 \cdot \color{blue}{\sqrt[3]{\left(\frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}} \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}\right) \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}}} \]
      2. pow1/367.3%

        \[\leadsto -4 \cdot \color{blue}{{\left(\left(\frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}} \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}\right) \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}\right)}^{0.3333333333333333}} \]
      3. pow367.3%

        \[\leadsto -4 \cdot {\color{blue}{\left({\left(\frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}\right)}^{3}\right)}}^{0.3333333333333333} \]
      4. div-inv66.9%

        \[\leadsto -4 \cdot {\left({\color{blue}{\left({\left(a \cdot b\right)}^{2} \cdot \frac{1}{{\left(x-scale \cdot y-scale\right)}^{2}}\right)}}^{3}\right)}^{0.3333333333333333} \]
      5. pow-flip67.3%

        \[\leadsto -4 \cdot {\left({\left({\left(a \cdot b\right)}^{2} \cdot \color{blue}{{\left(x-scale \cdot y-scale\right)}^{\left(-2\right)}}\right)}^{3}\right)}^{0.3333333333333333} \]
      6. metadata-eval67.3%

        \[\leadsto -4 \cdot {\left({\left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{\color{blue}{-2}}\right)}^{3}\right)}^{0.3333333333333333} \]
    8. Applied egg-rr67.3%

      \[\leadsto -4 \cdot \color{blue}{{\left({\left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right)}^{3}\right)}^{0.3333333333333333}} \]
    9. Step-by-step derivation
      1. unpow1/367.9%

        \[\leadsto -4 \cdot \color{blue}{\sqrt[3]{{\left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right)}^{3}}} \]
      2. unpow367.9%

        \[\leadsto -4 \cdot \sqrt[3]{\color{blue}{\left(\left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right) \cdot \left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right)\right) \cdot \left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right)}} \]
      3. add-cbrt-cube78.2%

        \[\leadsto -4 \cdot \color{blue}{\left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right)} \]
      4. metadata-eval78.2%

        \[\leadsto -4 \cdot \left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{\color{blue}{\left(-2\right)}}\right) \]
      5. pow-flip77.8%

        \[\leadsto -4 \cdot \left({\left(a \cdot b\right)}^{2} \cdot \color{blue}{\frac{1}{{\left(x-scale \cdot y-scale\right)}^{2}}}\right) \]
      6. pow277.8%

        \[\leadsto -4 \cdot \left({\left(a \cdot b\right)}^{2} \cdot \frac{1}{\color{blue}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}}\right) \]
      7. div-inv78.6%

        \[\leadsto -4 \cdot \color{blue}{\frac{{\left(a \cdot b\right)}^{2}}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}} \]
      8. associate-/r*83.2%

        \[\leadsto -4 \cdot \color{blue}{\frac{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}}{x-scale \cdot y-scale}} \]
    10. Applied egg-rr83.2%

      \[\leadsto -4 \cdot \color{blue}{\frac{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}}{x-scale \cdot y-scale}} \]
    11. Step-by-step derivation
      1. add-sqr-sqrt48.9%

        \[\leadsto -4 \cdot \frac{\color{blue}{\sqrt{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}} \cdot \sqrt{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}}}}{x-scale \cdot y-scale} \]
      2. *-un-lft-identity48.9%

        \[\leadsto -4 \cdot \frac{\sqrt{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}} \cdot \sqrt{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}}}{\color{blue}{1 \cdot \left(x-scale \cdot y-scale\right)}} \]
      3. times-frac49.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{\sqrt{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}}}{1} \cdot \frac{\sqrt{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}}}{x-scale \cdot y-scale}\right)} \]
      4. sqrt-div44.9%

        \[\leadsto -4 \cdot \left(\frac{\color{blue}{\frac{\sqrt{{\left(a \cdot b\right)}^{2}}}{\sqrt{x-scale \cdot y-scale}}}}{1} \cdot \frac{\sqrt{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}}}{x-scale \cdot y-scale}\right) \]
      5. sqrt-pow121.6%

        \[\leadsto -4 \cdot \left(\frac{\frac{\color{blue}{{\left(a \cdot b\right)}^{\left(\frac{2}{2}\right)}}}{\sqrt{x-scale \cdot y-scale}}}{1} \cdot \frac{\sqrt{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}}}{x-scale \cdot y-scale}\right) \]
      6. metadata-eval21.6%

        \[\leadsto -4 \cdot \left(\frac{\frac{{\left(a \cdot b\right)}^{\color{blue}{1}}}{\sqrt{x-scale \cdot y-scale}}}{1} \cdot \frac{\sqrt{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}}}{x-scale \cdot y-scale}\right) \]
      7. pow121.6%

        \[\leadsto -4 \cdot \left(\frac{\frac{\color{blue}{a \cdot b}}{\sqrt{x-scale \cdot y-scale}}}{1} \cdot \frac{\sqrt{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}}}{x-scale \cdot y-scale}\right) \]
      8. sqrt-div23.5%

        \[\leadsto -4 \cdot \left(\frac{\frac{a \cdot b}{\sqrt{x-scale \cdot y-scale}}}{1} \cdot \frac{\color{blue}{\frac{\sqrt{{\left(a \cdot b\right)}^{2}}}{\sqrt{x-scale \cdot y-scale}}}}{x-scale \cdot y-scale}\right) \]
      9. sqrt-pow151.1%

        \[\leadsto -4 \cdot \left(\frac{\frac{a \cdot b}{\sqrt{x-scale \cdot y-scale}}}{1} \cdot \frac{\frac{\color{blue}{{\left(a \cdot b\right)}^{\left(\frac{2}{2}\right)}}}{\sqrt{x-scale \cdot y-scale}}}{x-scale \cdot y-scale}\right) \]
      10. metadata-eval51.1%

        \[\leadsto -4 \cdot \left(\frac{\frac{a \cdot b}{\sqrt{x-scale \cdot y-scale}}}{1} \cdot \frac{\frac{{\left(a \cdot b\right)}^{\color{blue}{1}}}{\sqrt{x-scale \cdot y-scale}}}{x-scale \cdot y-scale}\right) \]
      11. pow151.1%

        \[\leadsto -4 \cdot \left(\frac{\frac{a \cdot b}{\sqrt{x-scale \cdot y-scale}}}{1} \cdot \frac{\frac{\color{blue}{a \cdot b}}{\sqrt{x-scale \cdot y-scale}}}{x-scale \cdot y-scale}\right) \]
    12. Applied egg-rr51.1%

      \[\leadsto -4 \cdot \color{blue}{\left(\frac{\frac{a \cdot b}{\sqrt{x-scale \cdot y-scale}}}{1} \cdot \frac{\frac{a \cdot b}{\sqrt{x-scale \cdot y-scale}}}{x-scale \cdot y-scale}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification70.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} \cdot \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{y-scale}}{y-scale} \leq 2 \cdot 10^{+263}:\\ \;\;\;\;-4 \cdot {\left(\frac{a}{y-scale} \cdot \frac{b}{x-scale}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(\frac{b \cdot a}{\sqrt{x-scale \cdot y-scale}} \cdot \frac{\frac{b \cdot a}{\sqrt{x-scale \cdot y-scale}}}{x-scale \cdot y-scale}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 93.9% accurate, 14.7× speedup?

\[\begin{array}{l} x-scale_m = \left|x-scale\right| \\ y-scale_m = \left|y-scale\right| \\ \begin{array}{l} t_0 := \frac{a}{x-scale\_m} \cdot \frac{b}{y-scale\_m}\\ \mathbf{if}\;b \leq 1.9 \cdot 10^{-251}:\\ \;\;\;\;-4 \cdot {\left(\frac{a}{y-scale\_m} \cdot \frac{b}{x-scale\_m}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(t\_0 \cdot t\_0\right)\\ \end{array} \end{array} \]
x-scale_m = (fabs.f64 x-scale)
y-scale_m = (fabs.f64 y-scale)
(FPCore (a b angle x-scale_m y-scale_m)
 :precision binary64
 (let* ((t_0 (* (/ a x-scale_m) (/ b y-scale_m))))
   (if (<= b 1.9e-251)
     (* -4.0 (pow (* (/ a y-scale_m) (/ b x-scale_m)) 2.0))
     (* -4.0 (* t_0 t_0)))))
x-scale_m = fabs(x_45_scale);
y-scale_m = fabs(y_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
	double t_0 = (a / x_45_scale_m) * (b / y_45_scale_m);
	double tmp;
	if (b <= 1.9e-251) {
		tmp = -4.0 * pow(((a / y_45_scale_m) * (b / x_45_scale_m)), 2.0);
	} else {
		tmp = -4.0 * (t_0 * t_0);
	}
	return tmp;
}
x-scale_m = abs(x_45scale)
y-scale_m = abs(y_45scale)
real(8) function code(a, b, angle, x_45scale_m, y_45scale_m)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: angle
    real(8), intent (in) :: x_45scale_m
    real(8), intent (in) :: y_45scale_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (a / x_45scale_m) * (b / y_45scale_m)
    if (b <= 1.9d-251) then
        tmp = (-4.0d0) * (((a / y_45scale_m) * (b / x_45scale_m)) ** 2.0d0)
    else
        tmp = (-4.0d0) * (t_0 * t_0)
    end if
    code = tmp
end function
x-scale_m = Math.abs(x_45_scale);
y-scale_m = Math.abs(y_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
	double t_0 = (a / x_45_scale_m) * (b / y_45_scale_m);
	double tmp;
	if (b <= 1.9e-251) {
		tmp = -4.0 * Math.pow(((a / y_45_scale_m) * (b / x_45_scale_m)), 2.0);
	} else {
		tmp = -4.0 * (t_0 * t_0);
	}
	return tmp;
}
x-scale_m = math.fabs(x_45_scale)
y-scale_m = math.fabs(y_45_scale)
def code(a, b, angle, x_45_scale_m, y_45_scale_m):
	t_0 = (a / x_45_scale_m) * (b / y_45_scale_m)
	tmp = 0
	if b <= 1.9e-251:
		tmp = -4.0 * math.pow(((a / y_45_scale_m) * (b / x_45_scale_m)), 2.0)
	else:
		tmp = -4.0 * (t_0 * t_0)
	return tmp
x-scale_m = abs(x_45_scale)
y-scale_m = abs(y_45_scale)
function code(a, b, angle, x_45_scale_m, y_45_scale_m)
	t_0 = Float64(Float64(a / x_45_scale_m) * Float64(b / y_45_scale_m))
	tmp = 0.0
	if (b <= 1.9e-251)
		tmp = Float64(-4.0 * (Float64(Float64(a / y_45_scale_m) * Float64(b / x_45_scale_m)) ^ 2.0));
	else
		tmp = Float64(-4.0 * Float64(t_0 * t_0));
	end
	return tmp
end
x-scale_m = abs(x_45_scale);
y-scale_m = abs(y_45_scale);
function tmp_2 = code(a, b, angle, x_45_scale_m, y_45_scale_m)
	t_0 = (a / x_45_scale_m) * (b / y_45_scale_m);
	tmp = 0.0;
	if (b <= 1.9e-251)
		tmp = -4.0 * (((a / y_45_scale_m) * (b / x_45_scale_m)) ^ 2.0);
	else
		tmp = -4.0 * (t_0 * t_0);
	end
	tmp_2 = tmp;
end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
y-scale_m = N[Abs[y$45$scale], $MachinePrecision]
code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale$95$m_] := Block[{t$95$0 = N[(N[(a / x$45$scale$95$m), $MachinePrecision] * N[(b / y$45$scale$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 1.9e-251], N[(-4.0 * N[Power[N[(N[(a / y$45$scale$95$m), $MachinePrecision] * N[(b / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
y-scale_m = \left|y-scale\right|

\\
\begin{array}{l}
t_0 := \frac{a}{x-scale\_m} \cdot \frac{b}{y-scale\_m}\\
\mathbf{if}\;b \leq 1.9 \cdot 10^{-251}:\\
\;\;\;\;-4 \cdot {\left(\frac{a}{y-scale\_m} \cdot \frac{b}{x-scale\_m}\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(t\_0 \cdot t\_0\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 1.8999999999999999e-251

    1. Initial program 28.5%

      \[\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} \cdot \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{y-scale}}{y-scale} \]
    2. Simplified23.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{angle \cdot \pi}{180}\right) \cdot \frac{\left({b}^{2} - {a}^{2}\right) \cdot \left(2 \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}{x-scale \cdot y-scale}, \cos \left(\frac{angle \cdot \pi}{180}\right) \cdot \frac{\left({b}^{2} - {a}^{2}\right) \cdot \left(2 \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}{x-scale \cdot y-scale}, \frac{{\left(a \cdot \cos \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2}}{{y-scale}^{2}} \cdot \left(\frac{{\left(a \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2}}{{x-scale}^{2}} \cdot -4\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in angle around 0 43.9%

      \[\leadsto \color{blue}{-4 \cdot \frac{{a}^{2} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
    5. Step-by-step derivation
      1. *-commutative43.9%

        \[\leadsto -4 \cdot \frac{\color{blue}{{b}^{2} \cdot {a}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      2. unpow243.9%

        \[\leadsto -4 \cdot \frac{\color{blue}{\left(b \cdot b\right)} \cdot {a}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      3. unpow243.9%

        \[\leadsto -4 \cdot \frac{\left(b \cdot b\right) \cdot \color{blue}{\left(a \cdot a\right)}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      4. swap-sqr57.4%

        \[\leadsto -4 \cdot \frac{\color{blue}{\left(b \cdot a\right) \cdot \left(b \cdot a\right)}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      5. unpow257.4%

        \[\leadsto -4 \cdot \frac{\color{blue}{{\left(b \cdot a\right)}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      6. *-commutative57.4%

        \[\leadsto -4 \cdot \frac{{\color{blue}{\left(a \cdot b\right)}}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      7. unpow257.4%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\color{blue}{\left(x-scale \cdot x-scale\right)} \cdot {y-scale}^{2}} \]
      8. unpow257.4%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\left(x-scale \cdot x-scale\right) \cdot \color{blue}{\left(y-scale \cdot y-scale\right)}} \]
      9. swap-sqr73.3%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\color{blue}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}} \]
      10. unpow273.3%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\color{blue}{{\left(x-scale \cdot y-scale\right)}^{2}}} \]
    6. Simplified73.3%

      \[\leadsto \color{blue}{-4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}} \]
    7. Step-by-step derivation
      1. associate-*r/73.3%

        \[\leadsto \color{blue}{\frac{-4 \cdot {\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}} \]
    8. Applied egg-rr73.3%

      \[\leadsto \color{blue}{\frac{-4 \cdot {\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}} \]
    9. Step-by-step derivation
      1. *-commutative73.3%

        \[\leadsto \frac{-4 \cdot {\left(a \cdot b\right)}^{2}}{{\color{blue}{\left(y-scale \cdot x-scale\right)}}^{2}} \]
      2. unpow-prod-down57.4%

        \[\leadsto \frac{-4 \cdot {\left(a \cdot b\right)}^{2}}{\color{blue}{{y-scale}^{2} \cdot {x-scale}^{2}}} \]
    10. Applied egg-rr57.4%

      \[\leadsto \frac{-4 \cdot {\left(a \cdot b\right)}^{2}}{\color{blue}{{y-scale}^{2} \cdot {x-scale}^{2}}} \]
    11. Taylor expanded in a around 0 43.9%

      \[\leadsto \color{blue}{-4 \cdot \frac{{a}^{2} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
    12. Step-by-step derivation
      1. *-commutative43.9%

        \[\leadsto \color{blue}{\frac{{a}^{2} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -4} \]
      2. unpow243.9%

        \[\leadsto \frac{\color{blue}{\left(a \cdot a\right)} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -4 \]
      3. unpow243.9%

        \[\leadsto \frac{\left(a \cdot a\right) \cdot \color{blue}{\left(b \cdot b\right)}}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -4 \]
      4. swap-sqr57.4%

        \[\leadsto \frac{\color{blue}{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot -4 \]
      5. unpow257.4%

        \[\leadsto \frac{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}{\color{blue}{\left(x-scale \cdot x-scale\right)} \cdot {y-scale}^{2}} \cdot -4 \]
      6. unpow257.4%

        \[\leadsto \frac{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}{\left(x-scale \cdot x-scale\right) \cdot \color{blue}{\left(y-scale \cdot y-scale\right)}} \cdot -4 \]
      7. swap-sqr73.3%

        \[\leadsto \frac{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}{\color{blue}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}} \cdot -4 \]
      8. times-frac91.0%

        \[\leadsto \color{blue}{\left(\frac{a \cdot b}{x-scale \cdot y-scale} \cdot \frac{a \cdot b}{x-scale \cdot y-scale}\right)} \cdot -4 \]
      9. rem-square-sqrt0.0%

        \[\leadsto \left(\frac{a \cdot b}{x-scale \cdot y-scale} \cdot \frac{a \cdot b}{x-scale \cdot y-scale}\right) \cdot \color{blue}{\left(\sqrt{-4} \cdot \sqrt{-4}\right)} \]
      10. swap-sqr0.0%

        \[\leadsto \color{blue}{\left(\frac{a \cdot b}{x-scale \cdot y-scale} \cdot \sqrt{-4}\right) \cdot \left(\frac{a \cdot b}{x-scale \cdot y-scale} \cdot \sqrt{-4}\right)} \]
      11. times-frac0.0%

        \[\leadsto \left(\color{blue}{\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)} \cdot \sqrt{-4}\right) \cdot \left(\frac{a \cdot b}{x-scale \cdot y-scale} \cdot \sqrt{-4}\right) \]
      12. times-frac0.0%

        \[\leadsto \left(\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right) \cdot \sqrt{-4}\right) \cdot \left(\color{blue}{\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)} \cdot \sqrt{-4}\right) \]
      13. swap-sqr0.0%

        \[\leadsto \color{blue}{\left(\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right) \cdot \left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)\right) \cdot \left(\sqrt{-4} \cdot \sqrt{-4}\right)} \]
      14. unpow20.0%

        \[\leadsto \color{blue}{{\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)}^{2}} \cdot \left(\sqrt{-4} \cdot \sqrt{-4}\right) \]
      15. rem-square-sqrt93.1%

        \[\leadsto {\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)}^{2} \cdot \color{blue}{-4} \]
      16. *-commutative93.1%

        \[\leadsto \color{blue}{-4 \cdot {\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)}^{2}} \]
    13. Simplified95.5%

      \[\leadsto \color{blue}{-4 \cdot {\left(\frac{a}{y-scale} \cdot \frac{b}{x-scale}\right)}^{2}} \]

    if 1.8999999999999999e-251 < b

    1. Initial program 18.0%

      \[\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} \cdot \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{y-scale}}{y-scale} \]
    2. Simplified18.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{angle \cdot \pi}{180}\right) \cdot \frac{\left({b}^{2} - {a}^{2}\right) \cdot \left(2 \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}{x-scale \cdot y-scale}, \cos \left(\frac{angle \cdot \pi}{180}\right) \cdot \frac{\left({b}^{2} - {a}^{2}\right) \cdot \left(2 \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}{x-scale \cdot y-scale}, \frac{{\left(a \cdot \cos \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2}}{{y-scale}^{2}} \cdot \left(\frac{{\left(a \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2}}{{x-scale}^{2}} \cdot -4\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in angle around 0 53.0%

      \[\leadsto \color{blue}{-4 \cdot \frac{{a}^{2} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
    5. Step-by-step derivation
      1. *-commutative53.0%

        \[\leadsto -4 \cdot \frac{\color{blue}{{b}^{2} \cdot {a}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      2. unpow253.0%

        \[\leadsto -4 \cdot \frac{\color{blue}{\left(b \cdot b\right)} \cdot {a}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      3. unpow253.0%

        \[\leadsto -4 \cdot \frac{\left(b \cdot b\right) \cdot \color{blue}{\left(a \cdot a\right)}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      4. swap-sqr63.2%

        \[\leadsto -4 \cdot \frac{\color{blue}{\left(b \cdot a\right) \cdot \left(b \cdot a\right)}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      5. unpow263.2%

        \[\leadsto -4 \cdot \frac{\color{blue}{{\left(b \cdot a\right)}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      6. *-commutative63.2%

        \[\leadsto -4 \cdot \frac{{\color{blue}{\left(a \cdot b\right)}}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      7. unpow263.2%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\color{blue}{\left(x-scale \cdot x-scale\right)} \cdot {y-scale}^{2}} \]
      8. unpow263.2%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\left(x-scale \cdot x-scale\right) \cdot \color{blue}{\left(y-scale \cdot y-scale\right)}} \]
      9. swap-sqr80.8%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\color{blue}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}} \]
      10. unpow280.8%

        \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\color{blue}{{\left(x-scale \cdot y-scale\right)}^{2}}} \]
    6. Simplified80.8%

      \[\leadsto \color{blue}{-4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}} \]
    7. Step-by-step derivation
      1. add-cbrt-cube71.2%

        \[\leadsto -4 \cdot \color{blue}{\sqrt[3]{\left(\frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}} \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}\right) \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}}} \]
      2. pow1/370.9%

        \[\leadsto -4 \cdot \color{blue}{{\left(\left(\frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}} \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}\right) \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}\right)}^{0.3333333333333333}} \]
      3. pow370.9%

        \[\leadsto -4 \cdot {\color{blue}{\left({\left(\frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}\right)}^{3}\right)}}^{0.3333333333333333} \]
      4. div-inv70.9%

        \[\leadsto -4 \cdot {\left({\color{blue}{\left({\left(a \cdot b\right)}^{2} \cdot \frac{1}{{\left(x-scale \cdot y-scale\right)}^{2}}\right)}}^{3}\right)}^{0.3333333333333333} \]
      5. pow-flip71.4%

        \[\leadsto -4 \cdot {\left({\left({\left(a \cdot b\right)}^{2} \cdot \color{blue}{{\left(x-scale \cdot y-scale\right)}^{\left(-2\right)}}\right)}^{3}\right)}^{0.3333333333333333} \]
      6. metadata-eval71.4%

        \[\leadsto -4 \cdot {\left({\left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{\color{blue}{-2}}\right)}^{3}\right)}^{0.3333333333333333} \]
    8. Applied egg-rr71.4%

      \[\leadsto -4 \cdot \color{blue}{{\left({\left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right)}^{3}\right)}^{0.3333333333333333}} \]
    9. Step-by-step derivation
      1. unpow1/371.7%

        \[\leadsto -4 \cdot \color{blue}{\sqrt[3]{{\left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right)}^{3}}} \]
      2. unpow371.7%

        \[\leadsto -4 \cdot \sqrt[3]{\color{blue}{\left(\left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right) \cdot \left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right)\right) \cdot \left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right)}} \]
      3. add-cbrt-cube81.3%

        \[\leadsto -4 \cdot \color{blue}{\left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right)} \]
      4. metadata-eval81.3%

        \[\leadsto -4 \cdot \left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{\color{blue}{\left(-2\right)}}\right) \]
      5. pow-flip80.7%

        \[\leadsto -4 \cdot \left({\left(a \cdot b\right)}^{2} \cdot \color{blue}{\frac{1}{{\left(x-scale \cdot y-scale\right)}^{2}}}\right) \]
      6. pow280.7%

        \[\leadsto -4 \cdot \left({\left(a \cdot b\right)}^{2} \cdot \frac{1}{\color{blue}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}}\right) \]
      7. div-inv80.8%

        \[\leadsto -4 \cdot \color{blue}{\frac{{\left(a \cdot b\right)}^{2}}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}} \]
      8. associate-/r*86.3%

        \[\leadsto -4 \cdot \color{blue}{\frac{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}}{x-scale \cdot y-scale}} \]
    10. Applied egg-rr86.3%

      \[\leadsto -4 \cdot \color{blue}{\frac{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}}{x-scale \cdot y-scale}} \]
    11. Step-by-step derivation
      1. associate-/r*80.8%

        \[\leadsto -4 \cdot \color{blue}{\frac{{\left(a \cdot b\right)}^{2}}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}} \]
      2. pow280.8%

        \[\leadsto -4 \cdot \frac{\color{blue}{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)} \]
      3. times-frac97.4%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{a \cdot b}{x-scale \cdot y-scale} \cdot \frac{a \cdot b}{x-scale \cdot y-scale}\right)} \]
      4. times-frac93.6%

        \[\leadsto -4 \cdot \left(\color{blue}{\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)} \cdot \frac{a \cdot b}{x-scale \cdot y-scale}\right) \]
      5. times-frac95.6%

        \[\leadsto -4 \cdot \left(\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right) \cdot \color{blue}{\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)}\right) \]
    12. Applied egg-rr95.6%

      \[\leadsto -4 \cdot \color{blue}{\left(\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right) \cdot \left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 94.0% accurate, 99.6× speedup?

\[\begin{array}{l} x-scale_m = \left|x-scale\right| \\ y-scale_m = \left|y-scale\right| \\ \begin{array}{l} t_0 := \frac{a}{x-scale\_m} \cdot \frac{b}{y-scale\_m}\\ -4 \cdot \left(t\_0 \cdot t\_0\right) \end{array} \end{array} \]
x-scale_m = (fabs.f64 x-scale)
y-scale_m = (fabs.f64 y-scale)
(FPCore (a b angle x-scale_m y-scale_m)
 :precision binary64
 (let* ((t_0 (* (/ a x-scale_m) (/ b y-scale_m)))) (* -4.0 (* t_0 t_0))))
x-scale_m = fabs(x_45_scale);
y-scale_m = fabs(y_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
	double t_0 = (a / x_45_scale_m) * (b / y_45_scale_m);
	return -4.0 * (t_0 * t_0);
}
x-scale_m = abs(x_45scale)
y-scale_m = abs(y_45scale)
real(8) function code(a, b, angle, x_45scale_m, y_45scale_m)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: angle
    real(8), intent (in) :: x_45scale_m
    real(8), intent (in) :: y_45scale_m
    real(8) :: t_0
    t_0 = (a / x_45scale_m) * (b / y_45scale_m)
    code = (-4.0d0) * (t_0 * t_0)
end function
x-scale_m = Math.abs(x_45_scale);
y-scale_m = Math.abs(y_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
	double t_0 = (a / x_45_scale_m) * (b / y_45_scale_m);
	return -4.0 * (t_0 * t_0);
}
x-scale_m = math.fabs(x_45_scale)
y-scale_m = math.fabs(y_45_scale)
def code(a, b, angle, x_45_scale_m, y_45_scale_m):
	t_0 = (a / x_45_scale_m) * (b / y_45_scale_m)
	return -4.0 * (t_0 * t_0)
x-scale_m = abs(x_45_scale)
y-scale_m = abs(y_45_scale)
function code(a, b, angle, x_45_scale_m, y_45_scale_m)
	t_0 = Float64(Float64(a / x_45_scale_m) * Float64(b / y_45_scale_m))
	return Float64(-4.0 * Float64(t_0 * t_0))
end
x-scale_m = abs(x_45_scale);
y-scale_m = abs(y_45_scale);
function tmp = code(a, b, angle, x_45_scale_m, y_45_scale_m)
	t_0 = (a / x_45_scale_m) * (b / y_45_scale_m);
	tmp = -4.0 * (t_0 * t_0);
end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
y-scale_m = N[Abs[y$45$scale], $MachinePrecision]
code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale$95$m_] := Block[{t$95$0 = N[(N[(a / x$45$scale$95$m), $MachinePrecision] * N[(b / y$45$scale$95$m), $MachinePrecision]), $MachinePrecision]}, N[(-4.0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
y-scale_m = \left|y-scale\right|

\\
\begin{array}{l}
t_0 := \frac{a}{x-scale\_m} \cdot \frac{b}{y-scale\_m}\\
-4 \cdot \left(t\_0 \cdot t\_0\right)
\end{array}
\end{array}
Derivation
  1. Initial program 24.0%

    \[\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} \cdot \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{y-scale}}{y-scale} \]
  2. Simplified21.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{angle \cdot \pi}{180}\right) \cdot \frac{\left({b}^{2} - {a}^{2}\right) \cdot \left(2 \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}{x-scale \cdot y-scale}, \cos \left(\frac{angle \cdot \pi}{180}\right) \cdot \frac{\left({b}^{2} - {a}^{2}\right) \cdot \left(2 \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}{x-scale \cdot y-scale}, \frac{{\left(a \cdot \cos \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2}}{{y-scale}^{2}} \cdot \left(\frac{{\left(a \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2}}{{x-scale}^{2}} \cdot -4\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in angle around 0 47.7%

    \[\leadsto \color{blue}{-4 \cdot \frac{{a}^{2} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
  5. Step-by-step derivation
    1. *-commutative47.7%

      \[\leadsto -4 \cdot \frac{\color{blue}{{b}^{2} \cdot {a}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
    2. unpow247.7%

      \[\leadsto -4 \cdot \frac{\color{blue}{\left(b \cdot b\right)} \cdot {a}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
    3. unpow247.7%

      \[\leadsto -4 \cdot \frac{\left(b \cdot b\right) \cdot \color{blue}{\left(a \cdot a\right)}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
    4. swap-sqr59.9%

      \[\leadsto -4 \cdot \frac{\color{blue}{\left(b \cdot a\right) \cdot \left(b \cdot a\right)}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
    5. unpow259.9%

      \[\leadsto -4 \cdot \frac{\color{blue}{{\left(b \cdot a\right)}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
    6. *-commutative59.9%

      \[\leadsto -4 \cdot \frac{{\color{blue}{\left(a \cdot b\right)}}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
    7. unpow259.9%

      \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\color{blue}{\left(x-scale \cdot x-scale\right)} \cdot {y-scale}^{2}} \]
    8. unpow259.9%

      \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\left(x-scale \cdot x-scale\right) \cdot \color{blue}{\left(y-scale \cdot y-scale\right)}} \]
    9. swap-sqr76.4%

      \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\color{blue}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}} \]
    10. unpow276.4%

      \[\leadsto -4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{\color{blue}{{\left(x-scale \cdot y-scale\right)}^{2}}} \]
  6. Simplified76.4%

    \[\leadsto \color{blue}{-4 \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}} \]
  7. Step-by-step derivation
    1. add-cbrt-cube66.7%

      \[\leadsto -4 \cdot \color{blue}{\sqrt[3]{\left(\frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}} \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}\right) \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}}} \]
    2. pow1/366.2%

      \[\leadsto -4 \cdot \color{blue}{{\left(\left(\frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}} \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}\right) \cdot \frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}\right)}^{0.3333333333333333}} \]
    3. pow366.2%

      \[\leadsto -4 \cdot {\color{blue}{\left({\left(\frac{{\left(a \cdot b\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}}\right)}^{3}\right)}}^{0.3333333333333333} \]
    4. div-inv66.0%

      \[\leadsto -4 \cdot {\left({\color{blue}{\left({\left(a \cdot b\right)}^{2} \cdot \frac{1}{{\left(x-scale \cdot y-scale\right)}^{2}}\right)}}^{3}\right)}^{0.3333333333333333} \]
    5. pow-flip66.2%

      \[\leadsto -4 \cdot {\left({\left({\left(a \cdot b\right)}^{2} \cdot \color{blue}{{\left(x-scale \cdot y-scale\right)}^{\left(-2\right)}}\right)}^{3}\right)}^{0.3333333333333333} \]
    6. metadata-eval66.2%

      \[\leadsto -4 \cdot {\left({\left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{\color{blue}{-2}}\right)}^{3}\right)}^{0.3333333333333333} \]
  8. Applied egg-rr66.2%

    \[\leadsto -4 \cdot \color{blue}{{\left({\left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right)}^{3}\right)}^{0.3333333333333333}} \]
  9. Step-by-step derivation
    1. unpow1/366.6%

      \[\leadsto -4 \cdot \color{blue}{\sqrt[3]{{\left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right)}^{3}}} \]
    2. unpow366.6%

      \[\leadsto -4 \cdot \sqrt[3]{\color{blue}{\left(\left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right) \cdot \left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right)\right) \cdot \left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right)}} \]
    3. add-cbrt-cube76.2%

      \[\leadsto -4 \cdot \color{blue}{\left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{-2}\right)} \]
    4. metadata-eval76.2%

      \[\leadsto -4 \cdot \left({\left(a \cdot b\right)}^{2} \cdot {\left(x-scale \cdot y-scale\right)}^{\color{blue}{\left(-2\right)}}\right) \]
    5. pow-flip76.0%

      \[\leadsto -4 \cdot \left({\left(a \cdot b\right)}^{2} \cdot \color{blue}{\frac{1}{{\left(x-scale \cdot y-scale\right)}^{2}}}\right) \]
    6. pow276.0%

      \[\leadsto -4 \cdot \left({\left(a \cdot b\right)}^{2} \cdot \frac{1}{\color{blue}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}}\right) \]
    7. div-inv76.4%

      \[\leadsto -4 \cdot \color{blue}{\frac{{\left(a \cdot b\right)}^{2}}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}} \]
    8. associate-/r*82.0%

      \[\leadsto -4 \cdot \color{blue}{\frac{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}}{x-scale \cdot y-scale}} \]
  10. Applied egg-rr82.0%

    \[\leadsto -4 \cdot \color{blue}{\frac{\frac{{\left(a \cdot b\right)}^{2}}{x-scale \cdot y-scale}}{x-scale \cdot y-scale}} \]
  11. Step-by-step derivation
    1. associate-/r*76.4%

      \[\leadsto -4 \cdot \color{blue}{\frac{{\left(a \cdot b\right)}^{2}}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}} \]
    2. pow276.4%

      \[\leadsto -4 \cdot \frac{\color{blue}{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)} \]
    3. times-frac93.7%

      \[\leadsto -4 \cdot \color{blue}{\left(\frac{a \cdot b}{x-scale \cdot y-scale} \cdot \frac{a \cdot b}{x-scale \cdot y-scale}\right)} \]
    4. times-frac88.5%

      \[\leadsto -4 \cdot \left(\color{blue}{\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)} \cdot \frac{a \cdot b}{x-scale \cdot y-scale}\right) \]
    5. times-frac94.2%

      \[\leadsto -4 \cdot \left(\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right) \cdot \color{blue}{\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)}\right) \]
  12. Applied egg-rr94.2%

    \[\leadsto -4 \cdot \color{blue}{\left(\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right) \cdot \left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)\right)} \]
  13. Add Preprocessing

Alternative 4: 34.7% accurate, 1693.0× speedup?

\[\begin{array}{l} x-scale_m = \left|x-scale\right| \\ y-scale_m = \left|y-scale\right| \\ 0 \end{array} \]
x-scale_m = (fabs.f64 x-scale)
y-scale_m = (fabs.f64 y-scale)
(FPCore (a b angle x-scale_m y-scale_m) :precision binary64 0.0)
x-scale_m = fabs(x_45_scale);
y-scale_m = fabs(y_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
	return 0.0;
}
x-scale_m = abs(x_45scale)
y-scale_m = abs(y_45scale)
real(8) function code(a, b, angle, x_45scale_m, y_45scale_m)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: angle
    real(8), intent (in) :: x_45scale_m
    real(8), intent (in) :: y_45scale_m
    code = 0.0d0
end function
x-scale_m = Math.abs(x_45_scale);
y-scale_m = Math.abs(y_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
	return 0.0;
}
x-scale_m = math.fabs(x_45_scale)
y-scale_m = math.fabs(y_45_scale)
def code(a, b, angle, x_45_scale_m, y_45_scale_m):
	return 0.0
x-scale_m = abs(x_45_scale)
y-scale_m = abs(y_45_scale)
function code(a, b, angle, x_45_scale_m, y_45_scale_m)
	return 0.0
end
x-scale_m = abs(x_45_scale);
y-scale_m = abs(y_45_scale);
function tmp = code(a, b, angle, x_45_scale_m, y_45_scale_m)
	tmp = 0.0;
end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
y-scale_m = N[Abs[y$45$scale], $MachinePrecision]
code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale$95$m_] := 0.0
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
y-scale_m = \left|y-scale\right|

\\
0
\end{array}
Derivation
  1. Initial program 24.0%

    \[\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} \cdot \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{y-scale}}{y-scale} \]
  2. Simplified21.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\frac{angle \cdot \pi}{180}\right) \cdot \frac{\left({b}^{2} - {a}^{2}\right) \cdot \left(2 \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}{x-scale \cdot y-scale}, \cos \left(\frac{angle \cdot \pi}{180}\right) \cdot \frac{\left({b}^{2} - {a}^{2}\right) \cdot \left(2 \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}{x-scale \cdot y-scale}, \frac{{\left(a \cdot \cos \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2}}{{y-scale}^{2}} \cdot \left(\frac{{\left(a \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2}}{{x-scale}^{2}} \cdot -4\right)\right)} \]
  3. Add Preprocessing
  4. Taylor expanded in b around 0 22.4%

    \[\leadsto \color{blue}{-4 \cdot \frac{{a}^{4} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}\right)}{{x-scale}^{2} \cdot {y-scale}^{2}} + 4 \cdot \frac{{a}^{4} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}\right)}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
  5. Step-by-step derivation
    1. distribute-rgt-out22.4%

      \[\leadsto \color{blue}{\frac{{a}^{4} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}\right)}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot \left(-4 + 4\right)} \]
    2. metadata-eval22.4%

      \[\leadsto \frac{{a}^{4} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}\right)}{{x-scale}^{2} \cdot {y-scale}^{2}} \cdot \color{blue}{0} \]
    3. mul0-rgt33.4%

      \[\leadsto \color{blue}{0} \]
  6. Simplified33.4%

    \[\leadsto \color{blue}{0} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2024165 
(FPCore (a b angle x-scale y-scale)
  :name "Simplification of discriminant from scale-rotated-ellipse"
  :precision binary64
  (- (* (/ (/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* (/ angle 180.0) PI))) (cos (* (/ angle 180.0) PI))) x-scale) y-scale) (/ (/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* (/ angle 180.0) PI))) (cos (* (/ angle 180.0) PI))) x-scale) y-scale)) (* (* 4.0 (/ (/ (+ (pow (* a (sin (* (/ angle 180.0) PI))) 2.0) (pow (* b (cos (* (/ angle 180.0) PI))) 2.0)) x-scale) x-scale)) (/ (/ (+ (pow (* a (cos (* (/ angle 180.0) PI))) 2.0) (pow (* b (sin (* (/ angle 180.0) PI))) 2.0)) y-scale) y-scale))))