Simplification of discriminant from scale-rotated-ellipse

Percentage Accurate: 24.4% → 90.7%
Time: 52.2s
Alternatives: 5
Speedup: 40.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 5 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 24.4% accurate, 1.0× speedup?

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

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

Alternative 1: 90.7% accurate, 35.9× speedup?

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

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

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

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

      \[\leadsto \color{blue}{\left(-4 \cdot {a}^{2}\right) \cdot \frac{{b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
    3. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
    13. lower-*.f64N/A

      \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
    14. lower-*.f64N/A

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

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

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

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

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

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

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

      Alternative 2: 79.1% accurate, 29.3× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 1.65 \cdot 10^{-152}:\\ \;\;\;\;\frac{\left(\left(a \cdot a\right) \cdot -4\right) \cdot \frac{b}{y-scale \cdot x-scale}}{y-scale \cdot x-scale} \cdot b\\ \mathbf{elif}\;b \leq 1.75 \cdot 10^{+155}:\\ \;\;\;\;\frac{b \cdot b}{y-scale \cdot x-scale} \cdot \left(\frac{a}{y-scale \cdot x-scale} \cdot \left(-4 \cdot a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(-4 \cdot a\right) \cdot b\right) \cdot a}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)} \cdot b\\ \end{array} \end{array} \]
      (FPCore (a b angle x-scale y-scale)
       :precision binary64
       (if (<= b 1.65e-152)
         (* (/ (* (* (* a a) -4.0) (/ b (* y-scale x-scale))) (* y-scale x-scale)) b)
         (if (<= b 1.75e+155)
           (*
            (/ (* b b) (* y-scale x-scale))
            (* (/ a (* y-scale x-scale)) (* -4.0 a)))
           (*
            (/ (* (* (* -4.0 a) b) a) (* (* y-scale x-scale) (* y-scale x-scale)))
            b))))
      double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
      	double tmp;
      	if (b <= 1.65e-152) {
      		tmp = ((((a * a) * -4.0) * (b / (y_45_scale * x_45_scale))) / (y_45_scale * x_45_scale)) * b;
      	} else if (b <= 1.75e+155) {
      		tmp = ((b * b) / (y_45_scale * x_45_scale)) * ((a / (y_45_scale * x_45_scale)) * (-4.0 * a));
      	} else {
      		tmp = ((((-4.0 * a) * b) * a) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * b;
      	}
      	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 <= 1.65d-152) then
              tmp = ((((a * a) * (-4.0d0)) * (b / (y_45scale * x_45scale))) / (y_45scale * x_45scale)) * b
          else if (b <= 1.75d+155) then
              tmp = ((b * b) / (y_45scale * x_45scale)) * ((a / (y_45scale * x_45scale)) * ((-4.0d0) * a))
          else
              tmp = (((((-4.0d0) * a) * b) * a) / ((y_45scale * x_45scale) * (y_45scale * x_45scale))) * b
          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 <= 1.65e-152) {
      		tmp = ((((a * a) * -4.0) * (b / (y_45_scale * x_45_scale))) / (y_45_scale * x_45_scale)) * b;
      	} else if (b <= 1.75e+155) {
      		tmp = ((b * b) / (y_45_scale * x_45_scale)) * ((a / (y_45_scale * x_45_scale)) * (-4.0 * a));
      	} else {
      		tmp = ((((-4.0 * a) * b) * a) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * b;
      	}
      	return tmp;
      }
      
      def code(a, b, angle, x_45_scale, y_45_scale):
      	tmp = 0
      	if b <= 1.65e-152:
      		tmp = ((((a * a) * -4.0) * (b / (y_45_scale * x_45_scale))) / (y_45_scale * x_45_scale)) * b
      	elif b <= 1.75e+155:
      		tmp = ((b * b) / (y_45_scale * x_45_scale)) * ((a / (y_45_scale * x_45_scale)) * (-4.0 * a))
      	else:
      		tmp = ((((-4.0 * a) * b) * a) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * b
      	return tmp
      
      function code(a, b, angle, x_45_scale, y_45_scale)
      	tmp = 0.0
      	if (b <= 1.65e-152)
      		tmp = Float64(Float64(Float64(Float64(Float64(a * a) * -4.0) * Float64(b / Float64(y_45_scale * x_45_scale))) / Float64(y_45_scale * x_45_scale)) * b);
      	elseif (b <= 1.75e+155)
      		tmp = Float64(Float64(Float64(b * b) / Float64(y_45_scale * x_45_scale)) * Float64(Float64(a / Float64(y_45_scale * x_45_scale)) * Float64(-4.0 * a)));
      	else
      		tmp = Float64(Float64(Float64(Float64(Float64(-4.0 * a) * b) * a) / Float64(Float64(y_45_scale * x_45_scale) * Float64(y_45_scale * x_45_scale))) * b);
      	end
      	return tmp
      end
      
      function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale)
      	tmp = 0.0;
      	if (b <= 1.65e-152)
      		tmp = ((((a * a) * -4.0) * (b / (y_45_scale * x_45_scale))) / (y_45_scale * x_45_scale)) * b;
      	elseif (b <= 1.75e+155)
      		tmp = ((b * b) / (y_45_scale * x_45_scale)) * ((a / (y_45_scale * x_45_scale)) * (-4.0 * a));
      	else
      		tmp = ((((-4.0 * a) * b) * a) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * b;
      	end
      	tmp_2 = tmp;
      end
      
      code[a_, b_, angle_, x$45$scale_, y$45$scale_] := If[LessEqual[b, 1.65e-152], N[(N[(N[(N[(N[(a * a), $MachinePrecision] * -4.0), $MachinePrecision] * N[(b / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], If[LessEqual[b, 1.75e+155], N[(N[(N[(b * b), $MachinePrecision] / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(a / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(-4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(-4.0 * a), $MachinePrecision] * b), $MachinePrecision] * a), $MachinePrecision] / N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;b \leq 1.65 \cdot 10^{-152}:\\
      \;\;\;\;\frac{\left(\left(a \cdot a\right) \cdot -4\right) \cdot \frac{b}{y-scale \cdot x-scale}}{y-scale \cdot x-scale} \cdot b\\
      
      \mathbf{elif}\;b \leq 1.75 \cdot 10^{+155}:\\
      \;\;\;\;\frac{b \cdot b}{y-scale \cdot x-scale} \cdot \left(\frac{a}{y-scale \cdot x-scale} \cdot \left(-4 \cdot a\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\left(\left(-4 \cdot a\right) \cdot b\right) \cdot a}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)} \cdot b\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if b < 1.64999999999999999e-152

        1. Initial program 30.3%

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

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

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

            \[\leadsto \color{blue}{\left(-4 \cdot {a}^{2}\right) \cdot \frac{{b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
          3. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
          13. lower-*.f64N/A

            \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
          14. lower-*.f64N/A

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

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

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

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

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

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

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

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

              if 1.64999999999999999e-152 < b < 1.74999999999999992e155

              1. Initial program 20.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. Add Preprocessing
              3. Taylor expanded in angle around 0

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

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

                  \[\leadsto \color{blue}{\left(-4 \cdot {a}^{2}\right) \cdot \frac{{b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
                3. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
                13. lower-*.f64N/A

                  \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
                14. lower-*.f64N/A

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

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

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

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

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

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

                  if 1.74999999999999992e155 < b

                  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. Add Preprocessing
                  3. Taylor expanded in angle around 0

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

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

                      \[\leadsto \color{blue}{\left(-4 \cdot {a}^{2}\right) \cdot \frac{{b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
                    3. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

                      \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
                    13. lower-*.f64N/A

                      \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
                    14. lower-*.f64N/A

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

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

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

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

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

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

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

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

                        \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.65 \cdot 10^{-152}:\\ \;\;\;\;\frac{\left(\left(a \cdot a\right) \cdot -4\right) \cdot \frac{b}{y-scale \cdot x-scale}}{y-scale \cdot x-scale} \cdot b\\ \mathbf{elif}\;b \leq 1.75 \cdot 10^{+155}:\\ \;\;\;\;\frac{b \cdot b}{y-scale \cdot x-scale} \cdot \left(\frac{a}{y-scale \cdot x-scale} \cdot \left(-4 \cdot a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(-4 \cdot a\right) \cdot b\right) \cdot a}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)} \cdot b\\ \end{array} \]
                      5. Add Preprocessing

                      Alternative 3: 79.0% accurate, 29.3× speedup?

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

                        1. Initial program 30.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. Add Preprocessing
                        3. Taylor expanded in angle around 0

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

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

                            \[\leadsto \color{blue}{\left(-4 \cdot {a}^{2}\right) \cdot \frac{{b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
                          3. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

                            \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
                          13. lower-*.f64N/A

                            \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
                          14. lower-*.f64N/A

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

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

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

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

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

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

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

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

                              if 3.55e-161 < a < 1.30000000000000009e156

                              1. Initial program 19.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. Add Preprocessing
                              3. Taylor expanded in angle around 0

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

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

                                  \[\leadsto \color{blue}{\left(-4 \cdot {a}^{2}\right) \cdot \frac{{b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
                                3. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

                                  \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
                                13. lower-*.f64N/A

                                  \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
                                14. lower-*.f64N/A

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

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

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

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

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

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

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

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

                                    if 1.30000000000000009e156 < a

                                    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. Add Preprocessing
                                    3. Taylor expanded in angle around 0

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

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

                                        \[\leadsto \color{blue}{\left(-4 \cdot {a}^{2}\right) \cdot \frac{{b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
                                      3. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

                                        \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
                                      13. lower-*.f64N/A

                                        \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
                                      14. lower-*.f64N/A

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

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

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

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

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

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

                                        \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq 3.55 \cdot 10^{-161}:\\ \;\;\;\;\frac{\left(\left(-4 \cdot a\right) \cdot b\right) \cdot a}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)} \cdot b\\ \mathbf{elif}\;a \leq 1.3 \cdot 10^{+156}:\\ \;\;\;\;\frac{\left(\left(a \cdot a\right) \cdot -4\right) \cdot \frac{b}{y-scale \cdot x-scale}}{y-scale \cdot x-scale} \cdot b\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\frac{b}{\left(\left(y-scale \cdot x-scale\right) \cdot y-scale\right) \cdot x-scale} \cdot b\right) \cdot \left(-4 \cdot a\right)\right) \cdot a\\ \end{array} \]
                                      5. Add Preprocessing

                                      Alternative 4: 76.1% accurate, 40.5× speedup?

                                      \[\begin{array}{l} \\ \frac{\left(\left(-4 \cdot a\right) \cdot b\right) \cdot a}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)} \cdot b \end{array} \]
                                      (FPCore (a b angle x-scale y-scale)
                                       :precision binary64
                                       (* (/ (* (* (* -4.0 a) b) a) (* (* y-scale x-scale) (* y-scale x-scale))) b))
                                      double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
                                      	return ((((-4.0 * a) * b) * a) / ((y_45_scale * x_45_scale) * (y_45_scale * x_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) * b) * a) / ((y_45scale * x_45scale) * (y_45scale * x_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) * b) * a) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * b;
                                      }
                                      
                                      def code(a, b, angle, x_45_scale, y_45_scale):
                                      	return ((((-4.0 * a) * b) * a) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * b
                                      
                                      function code(a, b, angle, x_45_scale, y_45_scale)
                                      	return Float64(Float64(Float64(Float64(Float64(-4.0 * a) * b) * a) / Float64(Float64(y_45_scale * x_45_scale) * Float64(y_45_scale * x_45_scale))) * b)
                                      end
                                      
                                      function tmp = code(a, b, angle, x_45_scale, y_45_scale)
                                      	tmp = ((((-4.0 * a) * b) * a) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * b;
                                      end
                                      
                                      code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(N[(N[(N[(N[(-4.0 * a), $MachinePrecision] * b), $MachinePrecision] * a), $MachinePrecision] / N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \frac{\left(\left(-4 \cdot a\right) \cdot b\right) \cdot a}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)} \cdot b
                                      \end{array}
                                      
                                      Derivation
                                      1. Initial program 23.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. Add Preprocessing
                                      3. Taylor expanded in angle around 0

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

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

                                          \[\leadsto \color{blue}{\left(-4 \cdot {a}^{2}\right) \cdot \frac{{b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
                                        3. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

                                          \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
                                        13. lower-*.f64N/A

                                          \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
                                        14. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

                                            Alternative 5: 69.4% accurate, 40.5× speedup?

                                            \[\begin{array}{l} \\ \frac{\left(\left(a \cdot a\right) \cdot -4\right) \cdot b}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)} \cdot b \end{array} \]
                                            (FPCore (a b angle x-scale y-scale)
                                             :precision binary64
                                             (* (/ (* (* (* a a) -4.0) b) (* (* y-scale x-scale) (* y-scale x-scale))) b))
                                            double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
                                            	return ((((a * a) * -4.0) * b) / ((y_45_scale * x_45_scale) * (y_45_scale * x_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 = ((((a * a) * (-4.0d0)) * b) / ((y_45scale * x_45scale) * (y_45scale * x_45scale))) * b
                                            end function
                                            
                                            public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
                                            	return ((((a * a) * -4.0) * b) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * b;
                                            }
                                            
                                            def code(a, b, angle, x_45_scale, y_45_scale):
                                            	return ((((a * a) * -4.0) * b) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * b
                                            
                                            function code(a, b, angle, x_45_scale, y_45_scale)
                                            	return Float64(Float64(Float64(Float64(Float64(a * a) * -4.0) * b) / Float64(Float64(y_45_scale * x_45_scale) * Float64(y_45_scale * x_45_scale))) * b)
                                            end
                                            
                                            function tmp = code(a, b, angle, x_45_scale, y_45_scale)
                                            	tmp = ((((a * a) * -4.0) * b) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * b;
                                            end
                                            
                                            code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(N[(N[(N[(N[(a * a), $MachinePrecision] * -4.0), $MachinePrecision] * b), $MachinePrecision] / N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]
                                            
                                            \begin{array}{l}
                                            
                                            \\
                                            \frac{\left(\left(a \cdot a\right) \cdot -4\right) \cdot b}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)} \cdot b
                                            \end{array}
                                            
                                            Derivation
                                            1. Initial program 23.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. Add Preprocessing
                                            3. Taylor expanded in angle around 0

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

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

                                                \[\leadsto \color{blue}{\left(-4 \cdot {a}^{2}\right) \cdot \frac{{b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}}} \]
                                              3. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

                                                \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
                                              13. lower-*.f64N/A

                                                \[\leadsto \left(-4 \cdot \left(a \cdot a\right)\right) \cdot \frac{b \cdot b}{\color{blue}{\left({y-scale}^{2} \cdot x-scale\right) \cdot x-scale}} \]
                                              14. lower-*.f64N/A

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

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

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

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

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

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

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

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

                                                Reproduce

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