Simplification of discriminant from scale-rotated-ellipse

Percentage Accurate: 24.5% → 95.7%
Time: 1.4min
Alternatives: 8
Speedup: 2485.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 95.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 62.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. Taylor expanded in angle around 0 70.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.0000000000000001e182 < (-.f64 (*.f64 (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 2 (-.f64 (pow.f64 b 2) (pow.f64 a 2))) (sin.f64 (*.f64 (/.f64 angle 180) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle 180) (PI.f64)))) x-scale) y-scale) (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 2 (-.f64 (pow.f64 b 2) (pow.f64 a 2))) (sin.f64 (*.f64 (/.f64 angle 180) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle 180) (PI.f64)))) x-scale) y-scale)) (*.f64 (*.f64 4 (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle 180) (PI.f64)))) 2) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle 180) (PI.f64)))) 2)) x-scale) x-scale)) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle 180) (PI.f64)))) 2) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle 180) (PI.f64)))) 2)) y-scale) y-scale)))

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 78.7% accurate, 117.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 3 \cdot 10^{-166} \lor \neg \left(b \leq 2.05 \cdot 10^{+101}\right):\\ \;\;\;\;-4 \cdot \left(\left(\frac{b}{x-scale} \cdot \frac{b}{x-scale}\right) \cdot \left(\frac{a}{y-scale} \cdot \frac{a}{y-scale}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(\frac{b \cdot b}{x-scale \cdot y-scale} \cdot \frac{a \cdot a}{x-scale \cdot y-scale}\right)\\ \end{array} \end{array} \]
(FPCore (a b angle x-scale y-scale)
 :precision binary64
 (if (or (<= b 3e-166) (not (<= b 2.05e+101)))
   (* -4.0 (* (* (/ b x-scale) (/ b x-scale)) (* (/ a y-scale) (/ a y-scale))))
   (*
    -4.0
    (* (/ (* b b) (* x-scale y-scale)) (/ (* a a) (* x-scale y-scale))))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double tmp;
	if ((b <= 3e-166) || !(b <= 2.05e+101)) {
		tmp = -4.0 * (((b / x_45_scale) * (b / x_45_scale)) * ((a / y_45_scale) * (a / y_45_scale)));
	} else {
		tmp = -4.0 * (((b * b) / (x_45_scale * y_45_scale)) * ((a * a) / (x_45_scale * y_45_scale)));
	}
	return tmp;
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
    real(8), intent (in) :: a
    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 ((b <= 3d-166) .or. (.not. (b <= 2.05d+101))) then
        tmp = (-4.0d0) * (((b / x_45scale) * (b / x_45scale)) * ((a / y_45scale) * (a / y_45scale)))
    else
        tmp = (-4.0d0) * (((b * b) / (x_45scale * y_45scale)) * ((a * a) / (x_45scale * y_45scale)))
    end if
    code = tmp
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double tmp;
	if ((b <= 3e-166) || !(b <= 2.05e+101)) {
		tmp = -4.0 * (((b / x_45_scale) * (b / x_45_scale)) * ((a / y_45_scale) * (a / y_45_scale)));
	} else {
		tmp = -4.0 * (((b * b) / (x_45_scale * y_45_scale)) * ((a * a) / (x_45_scale * y_45_scale)));
	}
	return tmp;
}
def code(a, b, angle, x_45_scale, y_45_scale):
	tmp = 0
	if (b <= 3e-166) or not (b <= 2.05e+101):
		tmp = -4.0 * (((b / x_45_scale) * (b / x_45_scale)) * ((a / y_45_scale) * (a / y_45_scale)))
	else:
		tmp = -4.0 * (((b * b) / (x_45_scale * y_45_scale)) * ((a * a) / (x_45_scale * y_45_scale)))
	return tmp
function code(a, b, angle, x_45_scale, y_45_scale)
	tmp = 0.0
	if ((b <= 3e-166) || !(b <= 2.05e+101))
		tmp = Float64(-4.0 * Float64(Float64(Float64(b / x_45_scale) * Float64(b / x_45_scale)) * Float64(Float64(a / y_45_scale) * Float64(a / y_45_scale))));
	else
		tmp = Float64(-4.0 * Float64(Float64(Float64(b * b) / Float64(x_45_scale * y_45_scale)) * Float64(Float64(a * a) / Float64(x_45_scale * y_45_scale))));
	end
	return tmp
end
function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale)
	tmp = 0.0;
	if ((b <= 3e-166) || ~((b <= 2.05e+101)))
		tmp = -4.0 * (((b / x_45_scale) * (b / x_45_scale)) * ((a / y_45_scale) * (a / y_45_scale)));
	else
		tmp = -4.0 * (((b * b) / (x_45_scale * y_45_scale)) * ((a * a) / (x_45_scale * y_45_scale)));
	end
	tmp_2 = tmp;
end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := If[Or[LessEqual[b, 3e-166], N[Not[LessEqual[b, 2.05e+101]], $MachinePrecision]], N[(-4.0 * N[(N[(N[(b / x$45$scale), $MachinePrecision] * N[(b / x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(a / y$45$scale), $MachinePrecision] * N[(a / y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(N[(N[(b * b), $MachinePrecision] / N[(x$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] / N[(x$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 3 \cdot 10^{-166} \lor \neg \left(b \leq 2.05 \cdot 10^{+101}\right):\\
\;\;\;\;-4 \cdot \left(\left(\frac{b}{x-scale} \cdot \frac{b}{x-scale}\right) \cdot \left(\frac{a}{y-scale} \cdot \frac{a}{y-scale}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 3.0000000000000003e-166 or 2.05e101 < b

    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. Taylor expanded in angle around 0 44.9%

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

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

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

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

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

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

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

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

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

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

    if 3.0000000000000003e-166 < b < 2.05e101

    1. Initial program 27.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. Taylor expanded in angle around 0 53.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 3 \cdot 10^{-166} \lor \neg \left(b \leq 2.05 \cdot 10^{+101}\right):\\ \;\;\;\;-4 \cdot \left(\left(\frac{b}{x-scale} \cdot \frac{b}{x-scale}\right) \cdot \left(\frac{a}{y-scale} \cdot \frac{a}{y-scale}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(\frac{b \cdot b}{x-scale \cdot y-scale} \cdot \frac{a \cdot a}{x-scale \cdot y-scale}\right)\\ \end{array} \]

Alternative 3: 81.4% accurate, 117.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 8.6 \cdot 10^{-181} \lor \neg \left(b \leq 1.34 \cdot 10^{+154}\right):\\ \;\;\;\;-4 \cdot \left(\left(\frac{b}{x-scale} \cdot \frac{b}{x-scale}\right) \cdot \left(\frac{a}{y-scale} \cdot \frac{a}{y-scale}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(\frac{\frac{a}{y-scale}}{x-scale} \cdot \frac{\frac{a}{y-scale} \cdot \left(b \cdot b\right)}{x-scale}\right)\\ \end{array} \end{array} \]
(FPCore (a b angle x-scale y-scale)
 :precision binary64
 (if (or (<= b 8.6e-181) (not (<= b 1.34e+154)))
   (* -4.0 (* (* (/ b x-scale) (/ b x-scale)) (* (/ a y-scale) (/ a y-scale))))
   (*
    -4.0
    (* (/ (/ a y-scale) x-scale) (/ (* (/ a y-scale) (* b b)) x-scale)))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double tmp;
	if ((b <= 8.6e-181) || !(b <= 1.34e+154)) {
		tmp = -4.0 * (((b / x_45_scale) * (b / x_45_scale)) * ((a / y_45_scale) * (a / y_45_scale)));
	} else {
		tmp = -4.0 * (((a / y_45_scale) / x_45_scale) * (((a / y_45_scale) * (b * b)) / x_45_scale));
	}
	return tmp;
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
    real(8), intent (in) :: a
    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 ((b <= 8.6d-181) .or. (.not. (b <= 1.34d+154))) then
        tmp = (-4.0d0) * (((b / x_45scale) * (b / x_45scale)) * ((a / y_45scale) * (a / y_45scale)))
    else
        tmp = (-4.0d0) * (((a / y_45scale) / x_45scale) * (((a / y_45scale) * (b * b)) / x_45scale))
    end if
    code = tmp
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double tmp;
	if ((b <= 8.6e-181) || !(b <= 1.34e+154)) {
		tmp = -4.0 * (((b / x_45_scale) * (b / x_45_scale)) * ((a / y_45_scale) * (a / y_45_scale)));
	} else {
		tmp = -4.0 * (((a / y_45_scale) / x_45_scale) * (((a / y_45_scale) * (b * b)) / x_45_scale));
	}
	return tmp;
}
def code(a, b, angle, x_45_scale, y_45_scale):
	tmp = 0
	if (b <= 8.6e-181) or not (b <= 1.34e+154):
		tmp = -4.0 * (((b / x_45_scale) * (b / x_45_scale)) * ((a / y_45_scale) * (a / y_45_scale)))
	else:
		tmp = -4.0 * (((a / y_45_scale) / x_45_scale) * (((a / y_45_scale) * (b * b)) / x_45_scale))
	return tmp
function code(a, b, angle, x_45_scale, y_45_scale)
	tmp = 0.0
	if ((b <= 8.6e-181) || !(b <= 1.34e+154))
		tmp = Float64(-4.0 * Float64(Float64(Float64(b / x_45_scale) * Float64(b / x_45_scale)) * Float64(Float64(a / y_45_scale) * Float64(a / y_45_scale))));
	else
		tmp = Float64(-4.0 * Float64(Float64(Float64(a / y_45_scale) / x_45_scale) * Float64(Float64(Float64(a / y_45_scale) * Float64(b * b)) / x_45_scale)));
	end
	return tmp
end
function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale)
	tmp = 0.0;
	if ((b <= 8.6e-181) || ~((b <= 1.34e+154)))
		tmp = -4.0 * (((b / x_45_scale) * (b / x_45_scale)) * ((a / y_45_scale) * (a / y_45_scale)));
	else
		tmp = -4.0 * (((a / y_45_scale) / x_45_scale) * (((a / y_45_scale) * (b * b)) / x_45_scale));
	end
	tmp_2 = tmp;
end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := If[Or[LessEqual[b, 8.6e-181], N[Not[LessEqual[b, 1.34e+154]], $MachinePrecision]], N[(-4.0 * N[(N[(N[(b / x$45$scale), $MachinePrecision] * N[(b / x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(a / y$45$scale), $MachinePrecision] * N[(a / y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(N[(N[(a / y$45$scale), $MachinePrecision] / x$45$scale), $MachinePrecision] * N[(N[(N[(a / y$45$scale), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision] / x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 8.6 \cdot 10^{-181} \lor \neg \left(b \leq 1.34 \cdot 10^{+154}\right):\\
\;\;\;\;-4 \cdot \left(\left(\frac{b}{x-scale} \cdot \frac{b}{x-scale}\right) \cdot \left(\frac{a}{y-scale} \cdot \frac{a}{y-scale}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 8.6e-181 or 1.34000000000000001e154 < b

    1. Initial program 24.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. Taylor expanded in angle around 0 44.5%

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

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

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

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

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

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

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

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

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

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

    if 8.6e-181 < b < 1.34000000000000001e154

    1. Initial program 22.4%

      \[\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. Taylor expanded in angle around 0 52.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 8.6 \cdot 10^{-181} \lor \neg \left(b \leq 1.34 \cdot 10^{+154}\right):\\ \;\;\;\;-4 \cdot \left(\left(\frac{b}{x-scale} \cdot \frac{b}{x-scale}\right) \cdot \left(\frac{a}{y-scale} \cdot \frac{a}{y-scale}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(\frac{\frac{a}{y-scale}}{x-scale} \cdot \frac{\frac{a}{y-scale} \cdot \left(b \cdot b\right)}{x-scale}\right)\\ \end{array} \]

Alternative 4: 61.9% accurate, 130.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x-scale \leq 1.3 \cdot 10^{+142}:\\ \;\;\;\;-4 \cdot \left(\left(\frac{a}{y-scale} \cdot \frac{a}{y-scale}\right) \cdot \frac{b \cdot b}{x-scale \cdot x-scale}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (a b angle x-scale y-scale)
 :precision binary64
 (if (<= x-scale 1.3e+142)
   (* -4.0 (* (* (/ a y-scale) (/ a y-scale)) (/ (* b b) (* x-scale x-scale))))
   0.0))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double tmp;
	if (x_45_scale <= 1.3e+142) {
		tmp = -4.0 * (((a / y_45_scale) * (a / y_45_scale)) * ((b * b) / (x_45_scale * x_45_scale)));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
    real(8), intent (in) :: a
    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.3d+142) then
        tmp = (-4.0d0) * (((a / y_45scale) * (a / y_45scale)) * ((b * b) / (x_45scale * x_45scale)))
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double tmp;
	if (x_45_scale <= 1.3e+142) {
		tmp = -4.0 * (((a / y_45_scale) * (a / y_45_scale)) * ((b * b) / (x_45_scale * x_45_scale)));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(a, b, angle, x_45_scale, y_45_scale):
	tmp = 0
	if x_45_scale <= 1.3e+142:
		tmp = -4.0 * (((a / y_45_scale) * (a / y_45_scale)) * ((b * b) / (x_45_scale * x_45_scale)))
	else:
		tmp = 0.0
	return tmp
function code(a, b, angle, x_45_scale, y_45_scale)
	tmp = 0.0
	if (x_45_scale <= 1.3e+142)
		tmp = Float64(-4.0 * Float64(Float64(Float64(a / y_45_scale) * Float64(a / y_45_scale)) * Float64(Float64(b * b) / Float64(x_45_scale * x_45_scale))));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale)
	tmp = 0.0;
	if (x_45_scale <= 1.3e+142)
		tmp = -4.0 * (((a / y_45_scale) * (a / y_45_scale)) * ((b * b) / (x_45_scale * x_45_scale)));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := If[LessEqual[x$45$scale, 1.3e+142], N[(-4.0 * N[(N[(N[(a / y$45$scale), $MachinePrecision] * N[(a / y$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] / N[(x$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x-scale \leq 1.3 \cdot 10^{+142}:\\
\;\;\;\;-4 \cdot \left(\left(\frac{a}{y-scale} \cdot \frac{a}{y-scale}\right) \cdot \frac{b \cdot b}{x-scale \cdot x-scale}\right)\\

\mathbf{else}:\\
\;\;\;\;0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x-scale < 1.30000000000000011e142

    1. Initial program 21.1%

      \[\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. Taylor expanded in angle around 0 47.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.30000000000000011e142 < x-scale

    1. Initial program 37.4%

      \[\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. Step-by-step derivation
      1. fma-neg37.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\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}, \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}\right)} \]
    3. Simplified34.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification61.7%

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

Alternative 5: 78.4% accurate, 146.2× speedup?

\[\begin{array}{l} \\ -4 \cdot \left(\left(\frac{b}{x-scale} \cdot \frac{b}{x-scale}\right) \cdot \left(\frac{a}{y-scale} \cdot \frac{a}{y-scale}\right)\right) \end{array} \]
(FPCore (a b angle x-scale y-scale)
 :precision binary64
 (* -4.0 (* (* (/ b x-scale) (/ b x-scale)) (* (/ a y-scale) (/ a y-scale)))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	return -4.0 * (((b / x_45_scale) * (b / x_45_scale)) * ((a / y_45_scale) * (a / y_45_scale)));
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
    real(8), intent (in) :: a
    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) * (((b / x_45scale) * (b / x_45scale)) * ((a / y_45scale) * (a / y_45scale)))
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	return -4.0 * (((b / x_45_scale) * (b / x_45_scale)) * ((a / y_45_scale) * (a / y_45_scale)));
}
def code(a, b, angle, x_45_scale, y_45_scale):
	return -4.0 * (((b / x_45_scale) * (b / x_45_scale)) * ((a / y_45_scale) * (a / y_45_scale)))
function code(a, b, angle, x_45_scale, y_45_scale)
	return Float64(-4.0 * Float64(Float64(Float64(b / x_45_scale) * Float64(b / x_45_scale)) * Float64(Float64(a / y_45_scale) * Float64(a / y_45_scale))))
end
function tmp = code(a, b, angle, x_45_scale, y_45_scale)
	tmp = -4.0 * (((b / x_45_scale) * (b / x_45_scale)) * ((a / y_45_scale) * (a / y_45_scale)));
end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(-4.0 * N[(N[(N[(b / x$45$scale), $MachinePrecision] * N[(b / x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(a / y$45$scale), $MachinePrecision] * N[(a / y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
-4 \cdot \left(\left(\frac{b}{x-scale} \cdot \frac{b}{x-scale}\right) \cdot \left(\frac{a}{y-scale} \cdot \frac{a}{y-scale}\right)\right)
\end{array}
Derivation
  1. Initial program 23.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. Taylor expanded in angle around 0 46.6%

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 89.6% accurate, 146.2× speedup?

\[\begin{array}{l} \\ -4 \cdot \frac{a}{\frac{x-scale \cdot y-scale}{b \cdot a} \cdot \frac{x-scale \cdot y-scale}{b}} \end{array} \]
(FPCore (a b angle x-scale y-scale)
 :precision binary64
 (* -4.0 (/ a (* (/ (* x-scale y-scale) (* b a)) (/ (* x-scale y-scale) b)))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	return -4.0 * (a / (((x_45_scale * y_45_scale) / (b * a)) * ((x_45_scale * y_45_scale) / b)));
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
    real(8), intent (in) :: a
    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 / (((x_45scale * y_45scale) / (b * a)) * ((x_45scale * y_45scale) / b)))
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	return -4.0 * (a / (((x_45_scale * y_45_scale) / (b * a)) * ((x_45_scale * y_45_scale) / b)));
}
def code(a, b, angle, x_45_scale, y_45_scale):
	return -4.0 * (a / (((x_45_scale * y_45_scale) / (b * a)) * ((x_45_scale * y_45_scale) / b)))
function code(a, b, angle, x_45_scale, y_45_scale)
	return Float64(-4.0 * Float64(a / Float64(Float64(Float64(x_45_scale * y_45_scale) / Float64(b * a)) * Float64(Float64(x_45_scale * y_45_scale) / b))))
end
function tmp = code(a, b, angle, x_45_scale, y_45_scale)
	tmp = -4.0 * (a / (((x_45_scale * y_45_scale) / (b * a)) * ((x_45_scale * y_45_scale) / b)));
end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(-4.0 * N[(a / N[(N[(N[(x$45$scale * y$45$scale), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision] * N[(N[(x$45$scale * y$45$scale), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
-4 \cdot \frac{a}{\frac{x-scale \cdot y-scale}{b \cdot a} \cdot \frac{x-scale \cdot y-scale}{b}}
\end{array}
Derivation
  1. Initial program 23.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. Taylor expanded in angle around 0 46.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -4 \cdot \frac{\color{blue}{a}}{\frac{y-scale \cdot x-scale}{a \cdot b} \cdot \frac{y-scale \cdot x-scale}{b}} \]
  10. Applied egg-rr92.7%

    \[\leadsto -4 \cdot \color{blue}{\frac{a}{\frac{y-scale \cdot x-scale}{a \cdot b} \cdot \frac{y-scale \cdot x-scale}{b}}} \]
  11. Final simplification92.7%

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

Alternative 7: 93.8% accurate, 146.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{a}{y-scale} \cdot \frac{b}{x-scale}\\ t_0 \cdot \left(-4 \cdot t_0\right) \end{array} \end{array} \]
(FPCore (a b angle x-scale y-scale)
 :precision binary64
 (let* ((t_0 (* (/ a y-scale) (/ b x-scale)))) (* t_0 (* -4.0 t_0))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double t_0 = (a / y_45_scale) * (b / x_45_scale);
	return t_0 * (-4.0 * t_0);
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
    real(8), intent (in) :: a
    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
    t_0 = (a / y_45scale) * (b / x_45scale)
    code = t_0 * ((-4.0d0) * t_0)
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double t_0 = (a / y_45_scale) * (b / x_45_scale);
	return t_0 * (-4.0 * t_0);
}
def code(a, b, angle, x_45_scale, y_45_scale):
	t_0 = (a / y_45_scale) * (b / x_45_scale)
	return t_0 * (-4.0 * t_0)
function code(a, b, angle, x_45_scale, y_45_scale)
	t_0 = Float64(Float64(a / y_45_scale) * Float64(b / x_45_scale))
	return Float64(t_0 * Float64(-4.0 * t_0))
end
function tmp = code(a, b, angle, x_45_scale, y_45_scale)
	t_0 = (a / y_45_scale) * (b / x_45_scale);
	tmp = t_0 * (-4.0 * t_0);
end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(a / y$45$scale), $MachinePrecision] * N[(b / x$45$scale), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * N[(-4.0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{a}{y-scale} \cdot \frac{b}{x-scale}\\
t_0 \cdot \left(-4 \cdot t_0\right)
\end{array}
\end{array}
Derivation
  1. Initial program 23.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. Taylor expanded in angle around 0 46.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 34.5% accurate, 2485.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (a b angle x-scale y-scale) :precision binary64 0.0)
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	return 0.0;
}
real(8) function code(a, b, angle, x_45scale, y_45scale)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: angle
    real(8), intent (in) :: x_45scale
    real(8), intent (in) :: y_45scale
    code = 0.0d0
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	return 0.0;
}
def code(a, b, angle, x_45_scale, y_45_scale):
	return 0.0
function code(a, b, angle, x_45_scale, y_45_scale)
	return 0.0
end
function tmp = code(a, b, angle, x_45_scale, y_45_scale)
	tmp = 0.0;
end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 23.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. Step-by-step derivation
    1. fma-neg25.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\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}, \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}\right)} \]
  3. Simplified22.6%

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

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

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

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

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

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

    \[\leadsto \color{blue}{0} \]
  7. Final simplification37.2%

    \[\leadsto 0 \]

Reproduce

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