Simplification of discriminant from scale-rotated-ellipse

Percentage Accurate: 24.6% → 94.1%
Time: 1.9min
Alternatives: 5
Speedup: 99.6×

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 5 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.6% 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: 94.1% accurate, 14.7× speedup?

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

\\
\begin{array}{l}
t_0 := b \cdot \frac{a_m}{x-scale}\\
\mathbf{if}\;a_m \leq 2.25 \cdot 10^{-189}:\\
\;\;\;\;-4 \cdot \frac{t_0}{y-scale \cdot \frac{y-scale}{t_0}}\\

\mathbf{else}:\\
\;\;\;\;-4 \cdot {\left(a_m \cdot \frac{\frac{b}{x-scale}}{y-scale}\right)}^{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 2.2499999999999998e-189

    1. Initial program 32.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. Simplified28.9%

      \[\leadsto \color{blue}{\frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} \cdot \frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} - 4 \cdot \left(\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}^{2}} \cdot \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}^{2}}\right)} \]
    3. Taylor expanded in angle around 0 49.6%

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

        \[\leadsto -4 \cdot \frac{\color{blue}{{b}^{2} \cdot {a}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      2. associate-/l*51.0%

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

      \[\leadsto \color{blue}{-4 \cdot \frac{{b}^{2}}{\frac{{x-scale}^{2} \cdot {y-scale}^{2}}{{a}^{2}}}} \]
    6. Step-by-step derivation
      1. associate-/l*49.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -4 \cdot \color{blue}{\left(\frac{b \cdot a}{x-scale \cdot y-scale} \cdot \frac{b \cdot a}{x-scale \cdot y-scale}\right)} \]
    12. Step-by-step derivation
      1. clear-num92.4%

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

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

        \[\leadsto -4 \cdot \color{blue}{\frac{1 \cdot \frac{b \cdot a}{x-scale}}{\frac{x-scale \cdot y-scale}{b \cdot a} \cdot y-scale}} \]
      4. *-un-lft-identity91.3%

        \[\leadsto -4 \cdot \frac{\color{blue}{\frac{b \cdot a}{x-scale}}}{\frac{x-scale \cdot y-scale}{b \cdot a} \cdot y-scale} \]
      5. *-un-lft-identity91.3%

        \[\leadsto -4 \cdot \frac{\frac{b \cdot a}{\color{blue}{1 \cdot x-scale}}}{\frac{x-scale \cdot y-scale}{b \cdot a} \cdot y-scale} \]
      6. times-frac88.8%

        \[\leadsto -4 \cdot \frac{\color{blue}{\frac{b}{1} \cdot \frac{a}{x-scale}}}{\frac{x-scale \cdot y-scale}{b \cdot a} \cdot y-scale} \]
      7. /-rgt-identity88.8%

        \[\leadsto -4 \cdot \frac{\color{blue}{b} \cdot \frac{a}{x-scale}}{\frac{x-scale \cdot y-scale}{b \cdot a} \cdot y-scale} \]
      8. *-commutative88.8%

        \[\leadsto -4 \cdot \frac{b \cdot \frac{a}{x-scale}}{\frac{\color{blue}{y-scale \cdot x-scale}}{b \cdot a} \cdot y-scale} \]
      9. associate-/l*91.4%

        \[\leadsto -4 \cdot \frac{b \cdot \frac{a}{x-scale}}{\color{blue}{\frac{y-scale}{\frac{b \cdot a}{x-scale}}} \cdot y-scale} \]
      10. *-un-lft-identity91.4%

        \[\leadsto -4 \cdot \frac{b \cdot \frac{a}{x-scale}}{\frac{y-scale}{\frac{b \cdot a}{\color{blue}{1 \cdot x-scale}}} \cdot y-scale} \]
      11. times-frac95.9%

        \[\leadsto -4 \cdot \frac{b \cdot \frac{a}{x-scale}}{\frac{y-scale}{\color{blue}{\frac{b}{1} \cdot \frac{a}{x-scale}}} \cdot y-scale} \]
      12. /-rgt-identity95.9%

        \[\leadsto -4 \cdot \frac{b \cdot \frac{a}{x-scale}}{\frac{y-scale}{\color{blue}{b} \cdot \frac{a}{x-scale}} \cdot y-scale} \]
    13. Applied egg-rr95.9%

      \[\leadsto -4 \cdot \color{blue}{\frac{b \cdot \frac{a}{x-scale}}{\frac{y-scale}{b \cdot \frac{a}{x-scale}} \cdot y-scale}} \]

    if 2.2499999999999998e-189 < a

    1. Initial program 18.8%

      \[\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. Simplified16.9%

      \[\leadsto \color{blue}{\frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} \cdot \frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} - 4 \cdot \left(\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}^{2}} \cdot \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}^{2}}\right)} \]
    3. Taylor expanded in angle around 0 44.1%

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

        \[\leadsto -4 \cdot \frac{\color{blue}{{b}^{2} \cdot {a}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      2. associate-/l*46.8%

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

      \[\leadsto \color{blue}{-4 \cdot \frac{{b}^{2}}{\frac{{x-scale}^{2} \cdot {y-scale}^{2}}{{a}^{2}}}} \]
    6. Step-by-step derivation
      1. associate-/l*44.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -4 \cdot \color{blue}{\left(\frac{b \cdot a}{x-scale \cdot y-scale} \cdot \frac{b \cdot a}{x-scale \cdot y-scale}\right)} \]
    12. Step-by-step derivation
      1. frac-times76.6%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \frac{1}{\frac{\color{blue}{\frac{{x-scale}^{2}}{a} \cdot \frac{{y-scale}^{2}}{a}}}{{b}^{2}}} \]
      10. *-commutative51.3%

        \[\leadsto -4 \cdot \frac{1}{\frac{\color{blue}{\frac{{y-scale}^{2}}{a} \cdot \frac{{x-scale}^{2}}{a}}}{{b}^{2}}} \]
      11. clear-num51.3%

        \[\leadsto -4 \cdot \frac{1}{\color{blue}{\frac{1}{\frac{{b}^{2}}{\frac{{y-scale}^{2}}{a} \cdot \frac{{x-scale}^{2}}{a}}}}} \]
      12. frac-times46.8%

        \[\leadsto -4 \cdot \frac{1}{\frac{1}{\frac{{b}^{2}}{\color{blue}{\frac{{y-scale}^{2} \cdot {x-scale}^{2}}{a \cdot a}}}}} \]
      13. *-commutative46.8%

        \[\leadsto -4 \cdot \frac{1}{\frac{1}{\frac{{b}^{2}}{\frac{\color{blue}{{x-scale}^{2} \cdot {y-scale}^{2}}}{a \cdot a}}}} \]
      14. unpow-prod-down57.8%

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

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

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

      \[\leadsto -4 \cdot \color{blue}{\frac{1}{\frac{1}{{\left(b \cdot \frac{a}{x-scale \cdot y-scale}\right)}^{2}}}} \]
    14. Step-by-step derivation
      1. remove-double-div95.6%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq 2.25 \cdot 10^{-189}:\\ \;\;\;\;-4 \cdot \frac{b \cdot \frac{a}{x-scale}}{y-scale \cdot \frac{y-scale}{b \cdot \frac{a}{x-scale}}}\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot {\left(a \cdot \frac{\frac{b}{x-scale}}{y-scale}\right)}^{2}\\ \end{array} \]

Alternative 2: 92.4% accurate, 76.9× speedup?

\[\begin{array}{l} a_m = \left|a\right| \\ \begin{array}{l} \mathbf{if}\;x-scale \leq 1.2 \cdot 10^{-127}:\\ \;\;\;\;-4 \cdot \left(\frac{a_m \cdot b}{x-scale \cdot y-scale} \cdot \frac{b}{\frac{x-scale \cdot y-scale}{a_m}}\right)\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(\left(a_m \cdot \frac{\frac{b}{x-scale}}{y-scale}\right) \cdot \left(\frac{b}{x-scale} \cdot \frac{a_m}{y-scale}\right)\right)\\ \end{array} \end{array} \]
a_m = (fabs.f64 a)
(FPCore (a_m b angle x-scale y-scale)
 :precision binary64
 (if (<= x-scale 1.2e-127)
   (*
    -4.0
    (* (/ (* a_m b) (* x-scale y-scale)) (/ b (/ (* x-scale y-scale) a_m))))
   (*
    -4.0
    (* (* a_m (/ (/ b x-scale) y-scale)) (* (/ b x-scale) (/ a_m y-scale))))))
a_m = fabs(a);
double code(double a_m, double b, double angle, double x_45_scale, double y_45_scale) {
	double tmp;
	if (x_45_scale <= 1.2e-127) {
		tmp = -4.0 * (((a_m * b) / (x_45_scale * y_45_scale)) * (b / ((x_45_scale * y_45_scale) / a_m)));
	} else {
		tmp = -4.0 * ((a_m * ((b / x_45_scale) / y_45_scale)) * ((b / x_45_scale) * (a_m / y_45_scale)));
	}
	return tmp;
}
a_m = abs(a)
real(8) function code(a_m, b, angle, x_45scale, y_45scale)
    real(8), intent (in) :: a_m
    real(8), intent (in) :: b
    real(8), intent (in) :: angle
    real(8), intent (in) :: x_45scale
    real(8), intent (in) :: y_45scale
    real(8) :: tmp
    if (x_45scale <= 1.2d-127) then
        tmp = (-4.0d0) * (((a_m * b) / (x_45scale * y_45scale)) * (b / ((x_45scale * y_45scale) / a_m)))
    else
        tmp = (-4.0d0) * ((a_m * ((b / x_45scale) / y_45scale)) * ((b / x_45scale) * (a_m / y_45scale)))
    end if
    code = tmp
end function
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle, double x_45_scale, double y_45_scale) {
	double tmp;
	if (x_45_scale <= 1.2e-127) {
		tmp = -4.0 * (((a_m * b) / (x_45_scale * y_45_scale)) * (b / ((x_45_scale * y_45_scale) / a_m)));
	} else {
		tmp = -4.0 * ((a_m * ((b / x_45_scale) / y_45_scale)) * ((b / x_45_scale) * (a_m / y_45_scale)));
	}
	return tmp;
}
a_m = math.fabs(a)
def code(a_m, b, angle, x_45_scale, y_45_scale):
	tmp = 0
	if x_45_scale <= 1.2e-127:
		tmp = -4.0 * (((a_m * b) / (x_45_scale * y_45_scale)) * (b / ((x_45_scale * y_45_scale) / a_m)))
	else:
		tmp = -4.0 * ((a_m * ((b / x_45_scale) / y_45_scale)) * ((b / x_45_scale) * (a_m / y_45_scale)))
	return tmp
a_m = abs(a)
function code(a_m, b, angle, x_45_scale, y_45_scale)
	tmp = 0.0
	if (x_45_scale <= 1.2e-127)
		tmp = Float64(-4.0 * Float64(Float64(Float64(a_m * b) / Float64(x_45_scale * y_45_scale)) * Float64(b / Float64(Float64(x_45_scale * y_45_scale) / a_m))));
	else
		tmp = Float64(-4.0 * Float64(Float64(a_m * Float64(Float64(b / x_45_scale) / y_45_scale)) * Float64(Float64(b / x_45_scale) * Float64(a_m / y_45_scale))));
	end
	return tmp
end
a_m = abs(a);
function tmp_2 = code(a_m, b, angle, x_45_scale, y_45_scale)
	tmp = 0.0;
	if (x_45_scale <= 1.2e-127)
		tmp = -4.0 * (((a_m * b) / (x_45_scale * y_45_scale)) * (b / ((x_45_scale * y_45_scale) / a_m)));
	else
		tmp = -4.0 * ((a_m * ((b / x_45_scale) / y_45_scale)) * ((b / x_45_scale) * (a_m / y_45_scale)));
	end
	tmp_2 = tmp;
end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_, x$45$scale_, y$45$scale_] := If[LessEqual[x$45$scale, 1.2e-127], N[(-4.0 * N[(N[(N[(a$95$m * b), $MachinePrecision] / N[(x$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision] * N[(b / N[(N[(x$45$scale * y$45$scale), $MachinePrecision] / a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(N[(a$95$m * N[(N[(b / x$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(b / x$45$scale), $MachinePrecision] * N[(a$95$m / y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a_m = \left|a\right|

\\
\begin{array}{l}
\mathbf{if}\;x-scale \leq 1.2 \cdot 10^{-127}:\\
\;\;\;\;-4 \cdot \left(\frac{a_m \cdot b}{x-scale \cdot y-scale} \cdot \frac{b}{\frac{x-scale \cdot y-scale}{a_m}}\right)\\

\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(\left(a_m \cdot \frac{\frac{b}{x-scale}}{y-scale}\right) \cdot \left(\frac{b}{x-scale} \cdot \frac{a_m}{y-scale}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x-scale < 1.19999999999999991e-127

    1. Initial program 21.3%

      \[\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. Simplified16.6%

      \[\leadsto \color{blue}{\frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} \cdot \frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} - 4 \cdot \left(\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}^{2}} \cdot \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}^{2}}\right)} \]
    3. Taylor expanded in angle around 0 41.8%

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

        \[\leadsto -4 \cdot \frac{\color{blue}{{b}^{2} \cdot {a}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      2. associate-/l*43.1%

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

      \[\leadsto \color{blue}{-4 \cdot \frac{{b}^{2}}{\frac{{x-scale}^{2} \cdot {y-scale}^{2}}{{a}^{2}}}} \]
    6. Step-by-step derivation
      1. associate-/l*41.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -4 \cdot \color{blue}{\left(\frac{b \cdot a}{x-scale \cdot y-scale} \cdot \frac{b \cdot a}{x-scale \cdot y-scale}\right)} \]
    12. Step-by-step derivation
      1. associate-/l*93.2%

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

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

        \[\leadsto -4 \cdot \left(\frac{b \cdot a}{x-scale \cdot y-scale} \cdot \left(b \cdot \frac{1}{\frac{\color{blue}{y-scale \cdot x-scale}}{a}}\right)\right) \]
      4. *-un-lft-identity93.1%

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

        \[\leadsto -4 \cdot \left(\frac{b \cdot a}{x-scale \cdot y-scale} \cdot \left(b \cdot \frac{1}{\color{blue}{\frac{y-scale}{1} \cdot \frac{x-scale}{a}}}\right)\right) \]
      6. /-rgt-identity88.3%

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

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

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

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

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

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

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

    if 1.19999999999999991e-127 < x-scale

    1. Initial program 34.6%

      \[\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. Simplified34.6%

      \[\leadsto \color{blue}{\frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} \cdot \frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} - 4 \cdot \left(\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}^{2}} \cdot \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}^{2}}\right)} \]
    3. Taylor expanded in angle around 0 55.4%

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

        \[\leadsto -4 \cdot \frac{\color{blue}{{b}^{2} \cdot {a}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      2. associate-/l*58.3%

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

      \[\leadsto \color{blue}{-4 \cdot \frac{{b}^{2}}{\frac{{x-scale}^{2} \cdot {y-scale}^{2}}{{a}^{2}}}} \]
    6. Step-by-step derivation
      1. associate-/l*55.4%

        \[\leadsto -4 \cdot \color{blue}{\frac{{b}^{2} \cdot {a}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
      2. *-un-lft-identity55.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\left(\frac{b}{x-scale} \cdot \frac{a}{y-scale}\right) \cdot \color{blue}{\frac{b \cdot a}{x-scale \cdot y-scale}}\right) \]
      3. associate-*l/88.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x-scale \leq 1.2 \cdot 10^{-127}:\\ \;\;\;\;-4 \cdot \left(\frac{a \cdot b}{x-scale \cdot y-scale} \cdot \frac{b}{\frac{x-scale \cdot y-scale}{a}}\right)\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(\left(a \cdot \frac{\frac{b}{x-scale}}{y-scale}\right) \cdot \left(\frac{b}{x-scale} \cdot \frac{a}{y-scale}\right)\right)\\ \end{array} \]

Alternative 3: 93.5% accurate, 76.9× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{a_m \cdot b}{x-scale \cdot y-scale}\\
\mathbf{if}\;x-scale \leq 1.04 \cdot 10^{-13}:\\
\;\;\;\;-4 \cdot \left(t_0 \cdot t_0\right)\\

\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(\left(a_m \cdot \frac{\frac{b}{x-scale}}{y-scale}\right) \cdot \left(\frac{b}{x-scale} \cdot \frac{a_m}{y-scale}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x-scale < 1.03999999999999999e-13

    1. Initial program 22.7%

      \[\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}{\frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} \cdot \frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} - 4 \cdot \left(\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}^{2}} \cdot \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}^{2}}\right)} \]
    3. Taylor expanded in angle around 0 43.6%

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

        \[\leadsto -4 \cdot \frac{\color{blue}{{b}^{2} \cdot {a}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      2. associate-/l*45.2%

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

      \[\leadsto \color{blue}{-4 \cdot \frac{{b}^{2}}{\frac{{x-scale}^{2} \cdot {y-scale}^{2}}{{a}^{2}}}} \]
    6. Step-by-step derivation
      1. associate-/l*43.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.03999999999999999e-13 < x-scale

    1. Initial program 35.2%

      \[\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. Simplified36.4%

      \[\leadsto \color{blue}{\frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} \cdot \frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} - 4 \cdot \left(\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}^{2}} \cdot \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}^{2}}\right)} \]
    3. Taylor expanded in angle around 0 55.3%

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

        \[\leadsto -4 \cdot \frac{\color{blue}{{b}^{2} \cdot {a}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      2. associate-/l*57.8%

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

      \[\leadsto \color{blue}{-4 \cdot \frac{{b}^{2}}{\frac{{x-scale}^{2} \cdot {y-scale}^{2}}{{a}^{2}}}} \]
    6. Step-by-step derivation
      1. associate-/l*55.3%

        \[\leadsto -4 \cdot \color{blue}{\frac{{b}^{2} \cdot {a}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
      2. *-un-lft-identity55.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\left(\frac{b}{x-scale} \cdot \frac{a}{y-scale}\right) \cdot \color{blue}{\frac{b \cdot a}{x-scale \cdot y-scale}}\right) \]
      3. associate-*l/88.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x-scale \leq 1.04 \cdot 10^{-13}:\\ \;\;\;\;-4 \cdot \left(\frac{a \cdot b}{x-scale \cdot y-scale} \cdot \frac{a \cdot b}{x-scale \cdot y-scale}\right)\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(\left(a \cdot \frac{\frac{b}{x-scale}}{y-scale}\right) \cdot \left(\frac{b}{x-scale} \cdot \frac{a}{y-scale}\right)\right)\\ \end{array} \]

Alternative 4: 92.9% accurate, 76.9× speedup?

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

\\
\begin{array}{l}
t_0 := b \cdot \frac{a_m}{x-scale}\\
\mathbf{if}\;a_m \leq 2 \cdot 10^{-190}:\\
\;\;\;\;-4 \cdot \frac{t_0}{y-scale \cdot \frac{y-scale}{t_0}}\\

\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(\left(a_m \cdot \frac{\frac{b}{x-scale}}{y-scale}\right) \cdot \left(\frac{b}{x-scale} \cdot \frac{a_m}{y-scale}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 2e-190

    1. Initial program 32.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. Simplified28.9%

      \[\leadsto \color{blue}{\frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} \cdot \frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} - 4 \cdot \left(\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}^{2}} \cdot \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}^{2}}\right)} \]
    3. Taylor expanded in angle around 0 49.6%

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

        \[\leadsto -4 \cdot \frac{\color{blue}{{b}^{2} \cdot {a}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      2. associate-/l*51.0%

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

      \[\leadsto \color{blue}{-4 \cdot \frac{{b}^{2}}{\frac{{x-scale}^{2} \cdot {y-scale}^{2}}{{a}^{2}}}} \]
    6. Step-by-step derivation
      1. associate-/l*49.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -4 \cdot \color{blue}{\left(\frac{b \cdot a}{x-scale \cdot y-scale} \cdot \frac{b \cdot a}{x-scale \cdot y-scale}\right)} \]
    12. Step-by-step derivation
      1. clear-num92.4%

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

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

        \[\leadsto -4 \cdot \color{blue}{\frac{1 \cdot \frac{b \cdot a}{x-scale}}{\frac{x-scale \cdot y-scale}{b \cdot a} \cdot y-scale}} \]
      4. *-un-lft-identity91.3%

        \[\leadsto -4 \cdot \frac{\color{blue}{\frac{b \cdot a}{x-scale}}}{\frac{x-scale \cdot y-scale}{b \cdot a} \cdot y-scale} \]
      5. *-un-lft-identity91.3%

        \[\leadsto -4 \cdot \frac{\frac{b \cdot a}{\color{blue}{1 \cdot x-scale}}}{\frac{x-scale \cdot y-scale}{b \cdot a} \cdot y-scale} \]
      6. times-frac88.8%

        \[\leadsto -4 \cdot \frac{\color{blue}{\frac{b}{1} \cdot \frac{a}{x-scale}}}{\frac{x-scale \cdot y-scale}{b \cdot a} \cdot y-scale} \]
      7. /-rgt-identity88.8%

        \[\leadsto -4 \cdot \frac{\color{blue}{b} \cdot \frac{a}{x-scale}}{\frac{x-scale \cdot y-scale}{b \cdot a} \cdot y-scale} \]
      8. *-commutative88.8%

        \[\leadsto -4 \cdot \frac{b \cdot \frac{a}{x-scale}}{\frac{\color{blue}{y-scale \cdot x-scale}}{b \cdot a} \cdot y-scale} \]
      9. associate-/l*91.4%

        \[\leadsto -4 \cdot \frac{b \cdot \frac{a}{x-scale}}{\color{blue}{\frac{y-scale}{\frac{b \cdot a}{x-scale}}} \cdot y-scale} \]
      10. *-un-lft-identity91.4%

        \[\leadsto -4 \cdot \frac{b \cdot \frac{a}{x-scale}}{\frac{y-scale}{\frac{b \cdot a}{\color{blue}{1 \cdot x-scale}}} \cdot y-scale} \]
      11. times-frac95.9%

        \[\leadsto -4 \cdot \frac{b \cdot \frac{a}{x-scale}}{\frac{y-scale}{\color{blue}{\frac{b}{1} \cdot \frac{a}{x-scale}}} \cdot y-scale} \]
      12. /-rgt-identity95.9%

        \[\leadsto -4 \cdot \frac{b \cdot \frac{a}{x-scale}}{\frac{y-scale}{\color{blue}{b} \cdot \frac{a}{x-scale}} \cdot y-scale} \]
    13. Applied egg-rr95.9%

      \[\leadsto -4 \cdot \color{blue}{\frac{b \cdot \frac{a}{x-scale}}{\frac{y-scale}{b \cdot \frac{a}{x-scale}} \cdot y-scale}} \]

    if 2e-190 < a

    1. Initial program 18.8%

      \[\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. Simplified16.9%

      \[\leadsto \color{blue}{\frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} \cdot \frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} - 4 \cdot \left(\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}^{2}} \cdot \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}^{2}}\right)} \]
    3. Taylor expanded in angle around 0 44.1%

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

        \[\leadsto -4 \cdot \frac{\color{blue}{{b}^{2} \cdot {a}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
      2. associate-/l*46.8%

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

      \[\leadsto \color{blue}{-4 \cdot \frac{{b}^{2}}{\frac{{x-scale}^{2} \cdot {y-scale}^{2}}{{a}^{2}}}} \]
    6. Step-by-step derivation
      1. associate-/l*44.1%

        \[\leadsto -4 \cdot \color{blue}{\frac{{b}^{2} \cdot {a}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
      2. *-un-lft-identity44.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\left(\frac{b}{x-scale} \cdot \frac{a}{y-scale}\right) \cdot \color{blue}{\frac{b \cdot a}{x-scale \cdot y-scale}}\right) \]
      3. associate-*l/89.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq 2 \cdot 10^{-190}:\\ \;\;\;\;-4 \cdot \frac{b \cdot \frac{a}{x-scale}}{y-scale \cdot \frac{y-scale}{b \cdot \frac{a}{x-scale}}}\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(\left(a \cdot \frac{\frac{b}{x-scale}}{y-scale}\right) \cdot \left(\frac{b}{x-scale} \cdot \frac{a}{y-scale}\right)\right)\\ \end{array} \]

Alternative 5: 92.5% accurate, 99.6× speedup?

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

\\
-4 \cdot \left(\left(a_m \cdot \frac{\frac{b}{x-scale}}{y-scale}\right) \cdot \left(\frac{b}{x-scale} \cdot \frac{a_m}{y-scale}\right)\right)
\end{array}
Derivation
  1. Initial program 26.6%

    \[\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.7%

    \[\leadsto \color{blue}{\frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} \cdot \frac{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}{y-scale \cdot x-scale} - 4 \cdot \left(\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}^{2}} \cdot \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}^{2}}\right)} \]
  3. Taylor expanded in angle around 0 47.2%

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

      \[\leadsto -4 \cdot \frac{\color{blue}{{b}^{2} \cdot {a}^{2}}}{{x-scale}^{2} \cdot {y-scale}^{2}} \]
    2. associate-/l*49.2%

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

    \[\leadsto \color{blue}{-4 \cdot \frac{{b}^{2}}{\frac{{x-scale}^{2} \cdot {y-scale}^{2}}{{a}^{2}}}} \]
  6. Step-by-step derivation
    1. associate-/l*47.2%

      \[\leadsto -4 \cdot \color{blue}{\frac{{b}^{2} \cdot {a}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
    2. *-un-lft-identity47.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -4 \cdot \left(\left(\frac{b}{x-scale} \cdot \frac{a}{y-scale}\right) \cdot \color{blue}{\frac{b \cdot a}{x-scale \cdot y-scale}}\right) \]
    3. associate-*l/89.0%

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

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

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

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

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

Reproduce

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