Simplification of discriminant from scale-rotated-ellipse

Percentage Accurate: 25.5% → 90.5%
Time: 18.5s
Alternatives: 7
Speedup: 40.5×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\ 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)))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
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 7 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: 25.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\ 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)))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
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.5% accurate, 13.7× speedup?

\[\begin{array}{l} x-scale_m = \left|x-scale\right| \\ \begin{array}{l} \mathbf{if}\;x-scale\_m \leq 8.5 \cdot 10^{+157}:\\ \;\;\;\;\frac{a \cdot b}{y-scale} \cdot \frac{\frac{-4 \cdot \frac{a \cdot b}{x-scale\_m}}{y-scale}}{x-scale\_m}\\ \mathbf{else}:\\ \;\;\;\;\left(\left({\left(\frac{b}{y-scale \cdot x-scale\_m}\right)}^{2} \cdot -4\right) \cdot a\right) \cdot a\\ \end{array} \end{array} \]
x-scale_m = (fabs.f64 x-scale)
(FPCore (a b angle x-scale_m y-scale)
 :precision binary64
 (if (<= x-scale_m 8.5e+157)
   (*
    (/ (* a b) y-scale)
    (/ (/ (* -4.0 (/ (* a b) x-scale_m)) y-scale) x-scale_m))
   (* (* (* (pow (/ b (* y-scale x-scale_m)) 2.0) -4.0) a) a)))
x-scale_m = fabs(x_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
	double tmp;
	if (x_45_scale_m <= 8.5e+157) {
		tmp = ((a * b) / y_45_scale) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / x_45_scale_m);
	} else {
		tmp = ((pow((b / (y_45_scale * x_45_scale_m)), 2.0) * -4.0) * a) * a;
	}
	return tmp;
}
x-scale_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, angle, x_45scale_m, y_45scale)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: angle
    real(8), intent (in) :: x_45scale_m
    real(8), intent (in) :: y_45scale
    real(8) :: tmp
    if (x_45scale_m <= 8.5d+157) then
        tmp = ((a * b) / y_45scale) * ((((-4.0d0) * ((a * b) / x_45scale_m)) / y_45scale) / x_45scale_m)
    else
        tmp = ((((b / (y_45scale * x_45scale_m)) ** 2.0d0) * (-4.0d0)) * a) * a
    end if
    code = tmp
end function
x-scale_m = Math.abs(x_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
	double tmp;
	if (x_45_scale_m <= 8.5e+157) {
		tmp = ((a * b) / y_45_scale) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / x_45_scale_m);
	} else {
		tmp = ((Math.pow((b / (y_45_scale * x_45_scale_m)), 2.0) * -4.0) * a) * a;
	}
	return tmp;
}
x-scale_m = math.fabs(x_45_scale)
def code(a, b, angle, x_45_scale_m, y_45_scale):
	tmp = 0
	if x_45_scale_m <= 8.5e+157:
		tmp = ((a * b) / y_45_scale) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / x_45_scale_m)
	else:
		tmp = ((math.pow((b / (y_45_scale * x_45_scale_m)), 2.0) * -4.0) * a) * a
	return tmp
x-scale_m = abs(x_45_scale)
function code(a, b, angle, x_45_scale_m, y_45_scale)
	tmp = 0.0
	if (x_45_scale_m <= 8.5e+157)
		tmp = Float64(Float64(Float64(a * b) / y_45_scale) * Float64(Float64(Float64(-4.0 * Float64(Float64(a * b) / x_45_scale_m)) / y_45_scale) / x_45_scale_m));
	else
		tmp = Float64(Float64(Float64((Float64(b / Float64(y_45_scale * x_45_scale_m)) ^ 2.0) * -4.0) * a) * a);
	end
	return tmp
end
x-scale_m = abs(x_45_scale);
function tmp_2 = code(a, b, angle, x_45_scale_m, y_45_scale)
	tmp = 0.0;
	if (x_45_scale_m <= 8.5e+157)
		tmp = ((a * b) / y_45_scale) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / x_45_scale_m);
	else
		tmp = ((((b / (y_45_scale * x_45_scale_m)) ^ 2.0) * -4.0) * a) * a;
	end
	tmp_2 = tmp;
end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := If[LessEqual[x$45$scale$95$m, 8.5e+157], N[(N[(N[(a * b), $MachinePrecision] / y$45$scale), $MachinePrecision] * N[(N[(N[(-4.0 * N[(N[(a * b), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Power[N[(b / N[(y$45$scale * x$45$scale$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -4.0), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
x-scale_m = \left|x-scale\right|

\\
\begin{array}{l}
\mathbf{if}\;x-scale\_m \leq 8.5 \cdot 10^{+157}:\\
\;\;\;\;\frac{a \cdot b}{y-scale} \cdot \frac{\frac{-4 \cdot \frac{a \cdot b}{x-scale\_m}}{y-scale}}{x-scale\_m}\\

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


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

    1. Initial program 19.3%

      \[\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\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 \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\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. Applied rewrites53.3%

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

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

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

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

            if 8.4999999999999998e157 < x-scale

            1. Initial program 46.9%

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

              \[\leadsto \color{blue}{{a}^{2} \cdot \left(-8 \cdot \frac{{b}^{2} \cdot \left({\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot {\sin \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}\right)}{{x-scale}^{2} \cdot {y-scale}^{2}} - 4 \cdot \left(\frac{{b}^{2} \cdot {\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}{{x-scale}^{2} \cdot {y-scale}^{2}} + \frac{{b}^{2} \cdot {\sin \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}{{x-scale}^{2} \cdot {y-scale}^{2}}\right)\right)} \]
            4. Applied rewrites56.5%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-8}{y-scale \cdot y-scale}, \left(\left(b \cdot b\right) \cdot \frac{{\cos \left(-0.005555555555555556 \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)}^{2}}{x-scale}\right) \cdot \frac{{\sin \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)}^{2}}{x-scale}, -4 \cdot \frac{\left(b \cdot b\right) \cdot \left({\cos \left(-0.005555555555555556 \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)}^{4} + {\sin \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)}^{4}\right)}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)}\right) \cdot \left(a \cdot a\right)} \]
            5. Taylor expanded in angle around 0

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

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

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

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

                Alternative 2: 91.4% accurate, 26.8× speedup?

                \[\begin{array}{l} x-scale_m = \left|x-scale\right| \\ \begin{array}{l} t_0 := \frac{a \cdot b}{x-scale\_m}\\ \mathbf{if}\;y-scale \leq 1.4 \cdot 10^{-228}:\\ \;\;\;\;\frac{\left(\frac{\frac{-4}{y-scale}}{x-scale\_m} \cdot \left(a \cdot b\right)\right) \cdot \left(a \cdot b\right)}{y-scale \cdot x-scale\_m}\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \frac{\frac{-4 \cdot t\_0}{y-scale}}{y-scale}\\ \end{array} \end{array} \]
                x-scale_m = (fabs.f64 x-scale)
                (FPCore (a b angle x-scale_m y-scale)
                 :precision binary64
                 (let* ((t_0 (/ (* a b) x-scale_m)))
                   (if (<= y-scale 1.4e-228)
                     (/
                      (* (* (/ (/ -4.0 y-scale) x-scale_m) (* a b)) (* a b))
                      (* y-scale x-scale_m))
                     (* t_0 (/ (/ (* -4.0 t_0) y-scale) y-scale)))))
                x-scale_m = fabs(x_45_scale);
                double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
                	double t_0 = (a * b) / x_45_scale_m;
                	double tmp;
                	if (y_45_scale <= 1.4e-228) {
                		tmp = ((((-4.0 / y_45_scale) / x_45_scale_m) * (a * b)) * (a * b)) / (y_45_scale * x_45_scale_m);
                	} else {
                		tmp = t_0 * (((-4.0 * t_0) / y_45_scale) / y_45_scale);
                	}
                	return tmp;
                }
                
                x-scale_m =     private
                module fmin_fmax_functions
                    implicit none
                    private
                    public fmax
                    public fmin
                
                    interface fmax
                        module procedure fmax88
                        module procedure fmax44
                        module procedure fmax84
                        module procedure fmax48
                    end interface
                    interface fmin
                        module procedure fmin88
                        module procedure fmin44
                        module procedure fmin84
                        module procedure fmin48
                    end interface
                contains
                    real(8) function fmax88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmax44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmax84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmax48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                    end function
                    real(8) function fmin88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmin44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmin84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmin48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                    end function
                end module
                
                real(8) function code(a, b, angle, x_45scale_m, y_45scale)
                use fmin_fmax_functions
                    real(8), intent (in) :: a
                    real(8), intent (in) :: b
                    real(8), intent (in) :: angle
                    real(8), intent (in) :: x_45scale_m
                    real(8), intent (in) :: y_45scale
                    real(8) :: t_0
                    real(8) :: tmp
                    t_0 = (a * b) / x_45scale_m
                    if (y_45scale <= 1.4d-228) then
                        tmp = (((((-4.0d0) / y_45scale) / x_45scale_m) * (a * b)) * (a * b)) / (y_45scale * x_45scale_m)
                    else
                        tmp = t_0 * ((((-4.0d0) * t_0) / y_45scale) / y_45scale)
                    end if
                    code = tmp
                end function
                
                x-scale_m = Math.abs(x_45_scale);
                public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
                	double t_0 = (a * b) / x_45_scale_m;
                	double tmp;
                	if (y_45_scale <= 1.4e-228) {
                		tmp = ((((-4.0 / y_45_scale) / x_45_scale_m) * (a * b)) * (a * b)) / (y_45_scale * x_45_scale_m);
                	} else {
                		tmp = t_0 * (((-4.0 * t_0) / y_45_scale) / y_45_scale);
                	}
                	return tmp;
                }
                
                x-scale_m = math.fabs(x_45_scale)
                def code(a, b, angle, x_45_scale_m, y_45_scale):
                	t_0 = (a * b) / x_45_scale_m
                	tmp = 0
                	if y_45_scale <= 1.4e-228:
                		tmp = ((((-4.0 / y_45_scale) / x_45_scale_m) * (a * b)) * (a * b)) / (y_45_scale * x_45_scale_m)
                	else:
                		tmp = t_0 * (((-4.0 * t_0) / y_45_scale) / y_45_scale)
                	return tmp
                
                x-scale_m = abs(x_45_scale)
                function code(a, b, angle, x_45_scale_m, y_45_scale)
                	t_0 = Float64(Float64(a * b) / x_45_scale_m)
                	tmp = 0.0
                	if (y_45_scale <= 1.4e-228)
                		tmp = Float64(Float64(Float64(Float64(Float64(-4.0 / y_45_scale) / x_45_scale_m) * Float64(a * b)) * Float64(a * b)) / Float64(y_45_scale * x_45_scale_m));
                	else
                		tmp = Float64(t_0 * Float64(Float64(Float64(-4.0 * t_0) / y_45_scale) / y_45_scale));
                	end
                	return tmp
                end
                
                x-scale_m = abs(x_45_scale);
                function tmp_2 = code(a, b, angle, x_45_scale_m, y_45_scale)
                	t_0 = (a * b) / x_45_scale_m;
                	tmp = 0.0;
                	if (y_45_scale <= 1.4e-228)
                		tmp = ((((-4.0 / y_45_scale) / x_45_scale_m) * (a * b)) * (a * b)) / (y_45_scale * x_45_scale_m);
                	else
                		tmp = t_0 * (((-4.0 * t_0) / y_45_scale) / y_45_scale);
                	end
                	tmp_2 = tmp;
                end
                
                x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
                code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := Block[{t$95$0 = N[(N[(a * b), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision]}, If[LessEqual[y$45$scale, 1.4e-228], N[(N[(N[(N[(N[(-4.0 / y$45$scale), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision] / N[(y$45$scale * x$45$scale$95$m), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(-4.0 * t$95$0), $MachinePrecision] / y$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]), $MachinePrecision]]]
                
                \begin{array}{l}
                x-scale_m = \left|x-scale\right|
                
                \\
                \begin{array}{l}
                t_0 := \frac{a \cdot b}{x-scale\_m}\\
                \mathbf{if}\;y-scale \leq 1.4 \cdot 10^{-228}:\\
                \;\;\;\;\frac{\left(\frac{\frac{-4}{y-scale}}{x-scale\_m} \cdot \left(a \cdot b\right)\right) \cdot \left(a \cdot b\right)}{y-scale \cdot x-scale\_m}\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_0 \cdot \frac{\frac{-4 \cdot t\_0}{y-scale}}{y-scale}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if y-scale < 1.4000000000000001e-228

                  1. Initial program 18.5%

                    \[\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\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 \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\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. Applied rewrites50.2%

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

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

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

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

                          if 1.4000000000000001e-228 < y-scale

                          1. Initial program 29.9%

                            \[\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\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 \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\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. Applied rewrites58.9%

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

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

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

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

                                Alternative 3: 89.7% accurate, 32.3× speedup?

                                \[\begin{array}{l} x-scale_m = \left|x-scale\right| \\ \left(a \cdot b\right) \cdot \frac{\frac{-4 \cdot \frac{a \cdot b}{x-scale\_m}}{y-scale}}{y-scale \cdot x-scale\_m} \end{array} \]
                                x-scale_m = (fabs.f64 x-scale)
                                (FPCore (a b angle x-scale_m y-scale)
                                 :precision binary64
                                 (*
                                  (* a b)
                                  (/ (/ (* -4.0 (/ (* a b) x-scale_m)) y-scale) (* y-scale x-scale_m))))
                                x-scale_m = fabs(x_45_scale);
                                double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
                                	return (a * b) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / (y_45_scale * x_45_scale_m));
                                }
                                
                                x-scale_m =     private
                                module fmin_fmax_functions
                                    implicit none
                                    private
                                    public fmax
                                    public fmin
                                
                                    interface fmax
                                        module procedure fmax88
                                        module procedure fmax44
                                        module procedure fmax84
                                        module procedure fmax48
                                    end interface
                                    interface fmin
                                        module procedure fmin88
                                        module procedure fmin44
                                        module procedure fmin84
                                        module procedure fmin48
                                    end interface
                                contains
                                    real(8) function fmax88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmax44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmax84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmax48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmin44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmin48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                    end function
                                end module
                                
                                real(8) function code(a, b, angle, x_45scale_m, y_45scale)
                                use fmin_fmax_functions
                                    real(8), intent (in) :: a
                                    real(8), intent (in) :: b
                                    real(8), intent (in) :: angle
                                    real(8), intent (in) :: x_45scale_m
                                    real(8), intent (in) :: y_45scale
                                    code = (a * b) * ((((-4.0d0) * ((a * b) / x_45scale_m)) / y_45scale) / (y_45scale * x_45scale_m))
                                end function
                                
                                x-scale_m = Math.abs(x_45_scale);
                                public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
                                	return (a * b) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / (y_45_scale * x_45_scale_m));
                                }
                                
                                x-scale_m = math.fabs(x_45_scale)
                                def code(a, b, angle, x_45_scale_m, y_45_scale):
                                	return (a * b) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / (y_45_scale * x_45_scale_m))
                                
                                x-scale_m = abs(x_45_scale)
                                function code(a, b, angle, x_45_scale_m, y_45_scale)
                                	return Float64(Float64(a * b) * Float64(Float64(Float64(-4.0 * Float64(Float64(a * b) / x_45_scale_m)) / y_45_scale) / Float64(y_45_scale * x_45_scale_m)))
                                end
                                
                                x-scale_m = abs(x_45_scale);
                                function tmp = code(a, b, angle, x_45_scale_m, y_45_scale)
                                	tmp = (a * b) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / (y_45_scale * x_45_scale_m));
                                end
                                
                                x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
                                code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := N[(N[(a * b), $MachinePrecision] * N[(N[(N[(-4.0 * N[(N[(a * b), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision] / N[(y$45$scale * x$45$scale$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                                
                                \begin{array}{l}
                                x-scale_m = \left|x-scale\right|
                                
                                \\
                                \left(a \cdot b\right) \cdot \frac{\frac{-4 \cdot \frac{a \cdot b}{x-scale\_m}}{y-scale}}{y-scale \cdot x-scale\_m}
                                \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 \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\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 \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\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. Applied rewrites54.2%

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

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

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

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

                                        Alternative 4: 83.4% accurate, 35.9× speedup?

                                        \[\begin{array}{l} x-scale_m = \left|x-scale\right| \\ \left(a \cdot b\right) \cdot \frac{-4 \cdot \frac{a \cdot b}{x-scale\_m}}{\left(y-scale \cdot x-scale\_m\right) \cdot y-scale} \end{array} \]
                                        x-scale_m = (fabs.f64 x-scale)
                                        (FPCore (a b angle x-scale_m y-scale)
                                         :precision binary64
                                         (*
                                          (* a b)
                                          (/ (* -4.0 (/ (* a b) x-scale_m)) (* (* y-scale x-scale_m) y-scale))))
                                        x-scale_m = fabs(x_45_scale);
                                        double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
                                        	return (a * b) * ((-4.0 * ((a * b) / x_45_scale_m)) / ((y_45_scale * x_45_scale_m) * y_45_scale));
                                        }
                                        
                                        x-scale_m =     private
                                        module fmin_fmax_functions
                                            implicit none
                                            private
                                            public fmax
                                            public fmin
                                        
                                            interface fmax
                                                module procedure fmax88
                                                module procedure fmax44
                                                module procedure fmax84
                                                module procedure fmax48
                                            end interface
                                            interface fmin
                                                module procedure fmin88
                                                module procedure fmin44
                                                module procedure fmin84
                                                module procedure fmin48
                                            end interface
                                        contains
                                            real(8) function fmax88(x, y) result (res)
                                                real(8), intent (in) :: x
                                                real(8), intent (in) :: y
                                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                            end function
                                            real(4) function fmax44(x, y) result (res)
                                                real(4), intent (in) :: x
                                                real(4), intent (in) :: y
                                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                            end function
                                            real(8) function fmax84(x, y) result(res)
                                                real(8), intent (in) :: x
                                                real(4), intent (in) :: y
                                                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                            end function
                                            real(8) function fmax48(x, y) result(res)
                                                real(4), intent (in) :: x
                                                real(8), intent (in) :: y
                                                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                            end function
                                            real(8) function fmin88(x, y) result (res)
                                                real(8), intent (in) :: x
                                                real(8), intent (in) :: y
                                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                            end function
                                            real(4) function fmin44(x, y) result (res)
                                                real(4), intent (in) :: x
                                                real(4), intent (in) :: y
                                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                            end function
                                            real(8) function fmin84(x, y) result(res)
                                                real(8), intent (in) :: x
                                                real(4), intent (in) :: y
                                                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                            end function
                                            real(8) function fmin48(x, y) result(res)
                                                real(4), intent (in) :: x
                                                real(8), intent (in) :: y
                                                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                            end function
                                        end module
                                        
                                        real(8) function code(a, b, angle, x_45scale_m, y_45scale)
                                        use fmin_fmax_functions
                                            real(8), intent (in) :: a
                                            real(8), intent (in) :: b
                                            real(8), intent (in) :: angle
                                            real(8), intent (in) :: x_45scale_m
                                            real(8), intent (in) :: y_45scale
                                            code = (a * b) * (((-4.0d0) * ((a * b) / x_45scale_m)) / ((y_45scale * x_45scale_m) * y_45scale))
                                        end function
                                        
                                        x-scale_m = Math.abs(x_45_scale);
                                        public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
                                        	return (a * b) * ((-4.0 * ((a * b) / x_45_scale_m)) / ((y_45_scale * x_45_scale_m) * y_45_scale));
                                        }
                                        
                                        x-scale_m = math.fabs(x_45_scale)
                                        def code(a, b, angle, x_45_scale_m, y_45_scale):
                                        	return (a * b) * ((-4.0 * ((a * b) / x_45_scale_m)) / ((y_45_scale * x_45_scale_m) * y_45_scale))
                                        
                                        x-scale_m = abs(x_45_scale)
                                        function code(a, b, angle, x_45_scale_m, y_45_scale)
                                        	return Float64(Float64(a * b) * Float64(Float64(-4.0 * Float64(Float64(a * b) / x_45_scale_m)) / Float64(Float64(y_45_scale * x_45_scale_m) * y_45_scale)))
                                        end
                                        
                                        x-scale_m = abs(x_45_scale);
                                        function tmp = code(a, b, angle, x_45_scale_m, y_45_scale)
                                        	tmp = (a * b) * ((-4.0 * ((a * b) / x_45_scale_m)) / ((y_45_scale * x_45_scale_m) * y_45_scale));
                                        end
                                        
                                        x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
                                        code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := N[(N[(a * b), $MachinePrecision] * N[(N[(-4.0 * N[(N[(a * b), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(y$45$scale * x$45$scale$95$m), $MachinePrecision] * y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                                        
                                        \begin{array}{l}
                                        x-scale_m = \left|x-scale\right|
                                        
                                        \\
                                        \left(a \cdot b\right) \cdot \frac{-4 \cdot \frac{a \cdot b}{x-scale\_m}}{\left(y-scale \cdot x-scale\_m\right) \cdot y-scale}
                                        \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 \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\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 \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\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. Applied rewrites54.2%

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

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

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

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

                                                Alternative 5: 75.3% accurate, 35.9× speedup?

                                                \[\begin{array}{l} x-scale_m = \left|x-scale\right| \\ \begin{array}{l} t_0 := \frac{b}{y-scale \cdot x-scale\_m}\\ \left(-4 \cdot \left(t\_0 \cdot t\_0\right)\right) \cdot \left(a \cdot a\right) \end{array} \end{array} \]
                                                x-scale_m = (fabs.f64 x-scale)
                                                (FPCore (a b angle x-scale_m y-scale)
                                                 :precision binary64
                                                 (let* ((t_0 (/ b (* y-scale x-scale_m)))) (* (* -4.0 (* t_0 t_0)) (* a a))))
                                                x-scale_m = fabs(x_45_scale);
                                                double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
                                                	double t_0 = b / (y_45_scale * x_45_scale_m);
                                                	return (-4.0 * (t_0 * t_0)) * (a * a);
                                                }
                                                
                                                x-scale_m =     private
                                                module fmin_fmax_functions
                                                    implicit none
                                                    private
                                                    public fmax
                                                    public fmin
                                                
                                                    interface fmax
                                                        module procedure fmax88
                                                        module procedure fmax44
                                                        module procedure fmax84
                                                        module procedure fmax48
                                                    end interface
                                                    interface fmin
                                                        module procedure fmin88
                                                        module procedure fmin44
                                                        module procedure fmin84
                                                        module procedure fmin48
                                                    end interface
                                                contains
                                                    real(8) function fmax88(x, y) result (res)
                                                        real(8), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                    end function
                                                    real(4) function fmax44(x, y) result (res)
                                                        real(4), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmax84(x, y) result(res)
                                                        real(8), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmax48(x, y) result(res)
                                                        real(4), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmin88(x, y) result (res)
                                                        real(8), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                    end function
                                                    real(4) function fmin44(x, y) result (res)
                                                        real(4), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmin84(x, y) result(res)
                                                        real(8), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmin48(x, y) result(res)
                                                        real(4), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                    end function
                                                end module
                                                
                                                real(8) function code(a, b, angle, x_45scale_m, y_45scale)
                                                use fmin_fmax_functions
                                                    real(8), intent (in) :: a
                                                    real(8), intent (in) :: b
                                                    real(8), intent (in) :: angle
                                                    real(8), intent (in) :: x_45scale_m
                                                    real(8), intent (in) :: y_45scale
                                                    real(8) :: t_0
                                                    t_0 = b / (y_45scale * x_45scale_m)
                                                    code = ((-4.0d0) * (t_0 * t_0)) * (a * a)
                                                end function
                                                
                                                x-scale_m = Math.abs(x_45_scale);
                                                public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
                                                	double t_0 = b / (y_45_scale * x_45_scale_m);
                                                	return (-4.0 * (t_0 * t_0)) * (a * a);
                                                }
                                                
                                                x-scale_m = math.fabs(x_45_scale)
                                                def code(a, b, angle, x_45_scale_m, y_45_scale):
                                                	t_0 = b / (y_45_scale * x_45_scale_m)
                                                	return (-4.0 * (t_0 * t_0)) * (a * a)
                                                
                                                x-scale_m = abs(x_45_scale)
                                                function code(a, b, angle, x_45_scale_m, y_45_scale)
                                                	t_0 = Float64(b / Float64(y_45_scale * x_45_scale_m))
                                                	return Float64(Float64(-4.0 * Float64(t_0 * t_0)) * Float64(a * a))
                                                end
                                                
                                                x-scale_m = abs(x_45_scale);
                                                function tmp = code(a, b, angle, x_45_scale_m, y_45_scale)
                                                	t_0 = b / (y_45_scale * x_45_scale_m);
                                                	tmp = (-4.0 * (t_0 * t_0)) * (a * a);
                                                end
                                                
                                                x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
                                                code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := Block[{t$95$0 = N[(b / N[(y$45$scale * x$45$scale$95$m), $MachinePrecision]), $MachinePrecision]}, N[(N[(-4.0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]]
                                                
                                                \begin{array}{l}
                                                x-scale_m = \left|x-scale\right|
                                                
                                                \\
                                                \begin{array}{l}
                                                t_0 := \frac{b}{y-scale \cdot x-scale\_m}\\
                                                \left(-4 \cdot \left(t\_0 \cdot t\_0\right)\right) \cdot \left(a \cdot a\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 \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\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 \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}}{y-scale}}{y-scale} \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in a around 0

                                                  \[\leadsto \color{blue}{{a}^{2} \cdot \left(-8 \cdot \frac{{b}^{2} \cdot \left({\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot {\sin \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}\right)}{{x-scale}^{2} \cdot {y-scale}^{2}} - 4 \cdot \left(\frac{{b}^{2} \cdot {\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}{{x-scale}^{2} \cdot {y-scale}^{2}} + \frac{{b}^{2} \cdot {\sin \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}{{x-scale}^{2} \cdot {y-scale}^{2}}\right)\right)} \]
                                                4. Applied rewrites47.4%

                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-8}{y-scale \cdot y-scale}, \left(\left(b \cdot b\right) \cdot \frac{{\cos \left(-0.005555555555555556 \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)}^{2}}{x-scale}\right) \cdot \frac{{\sin \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)}^{2}}{x-scale}, -4 \cdot \frac{\left(b \cdot b\right) \cdot \left({\cos \left(-0.005555555555555556 \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)}^{4} + {\sin \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)}^{4}\right)}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)}\right) \cdot \left(a \cdot a\right)} \]
                                                5. Taylor expanded in angle around 0

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

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

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

                                                    Alternative 6: 61.0% accurate, 40.5× speedup?

                                                    \[\begin{array}{l} x-scale_m = \left|x-scale\right| \\ \left(-4 \cdot \frac{b \cdot b}{\left(y-scale \cdot x-scale\_m\right) \cdot \left(y-scale \cdot x-scale\_m\right)}\right) \cdot \left(a \cdot a\right) \end{array} \]
                                                    x-scale_m = (fabs.f64 x-scale)
                                                    (FPCore (a b angle x-scale_m y-scale)
                                                     :precision binary64
                                                     (*
                                                      (* -4.0 (/ (* b b) (* (* y-scale x-scale_m) (* y-scale x-scale_m))))
                                                      (* a a)))
                                                    x-scale_m = fabs(x_45_scale);
                                                    double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
                                                    	return (-4.0 * ((b * b) / ((y_45_scale * x_45_scale_m) * (y_45_scale * x_45_scale_m)))) * (a * a);
                                                    }
                                                    
                                                    x-scale_m =     private
                                                    module fmin_fmax_functions
                                                        implicit none
                                                        private
                                                        public fmax
                                                        public fmin
                                                    
                                                        interface fmax
                                                            module procedure fmax88
                                                            module procedure fmax44
                                                            module procedure fmax84
                                                            module procedure fmax48
                                                        end interface
                                                        interface fmin
                                                            module procedure fmin88
                                                            module procedure fmin44
                                                            module procedure fmin84
                                                            module procedure fmin48
                                                        end interface
                                                    contains
                                                        real(8) function fmax88(x, y) result (res)
                                                            real(8), intent (in) :: x
                                                            real(8), intent (in) :: y
                                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                        end function
                                                        real(4) function fmax44(x, y) result (res)
                                                            real(4), intent (in) :: x
                                                            real(4), intent (in) :: y
                                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                        end function
                                                        real(8) function fmax84(x, y) result(res)
                                                            real(8), intent (in) :: x
                                                            real(4), intent (in) :: y
                                                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                        end function
                                                        real(8) function fmax48(x, y) result(res)
                                                            real(4), intent (in) :: x
                                                            real(8), intent (in) :: y
                                                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                        end function
                                                        real(8) function fmin88(x, y) result (res)
                                                            real(8), intent (in) :: x
                                                            real(8), intent (in) :: y
                                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                        end function
                                                        real(4) function fmin44(x, y) result (res)
                                                            real(4), intent (in) :: x
                                                            real(4), intent (in) :: y
                                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                        end function
                                                        real(8) function fmin84(x, y) result(res)
                                                            real(8), intent (in) :: x
                                                            real(4), intent (in) :: y
                                                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                        end function
                                                        real(8) function fmin48(x, y) result(res)
                                                            real(4), intent (in) :: x
                                                            real(8), intent (in) :: y
                                                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                        end function
                                                    end module
                                                    
                                                    real(8) function code(a, b, angle, x_45scale_m, y_45scale)
                                                    use fmin_fmax_functions
                                                        real(8), intent (in) :: a
                                                        real(8), intent (in) :: b
                                                        real(8), intent (in) :: angle
                                                        real(8), intent (in) :: x_45scale_m
                                                        real(8), intent (in) :: y_45scale
                                                        code = ((-4.0d0) * ((b * b) / ((y_45scale * x_45scale_m) * (y_45scale * x_45scale_m)))) * (a * a)
                                                    end function
                                                    
                                                    x-scale_m = Math.abs(x_45_scale);
                                                    public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
                                                    	return (-4.0 * ((b * b) / ((y_45_scale * x_45_scale_m) * (y_45_scale * x_45_scale_m)))) * (a * a);
                                                    }
                                                    
                                                    x-scale_m = math.fabs(x_45_scale)
                                                    def code(a, b, angle, x_45_scale_m, y_45_scale):
                                                    	return (-4.0 * ((b * b) / ((y_45_scale * x_45_scale_m) * (y_45_scale * x_45_scale_m)))) * (a * a)
                                                    
                                                    x-scale_m = abs(x_45_scale)
                                                    function code(a, b, angle, x_45_scale_m, y_45_scale)
                                                    	return Float64(Float64(-4.0 * Float64(Float64(b * b) / Float64(Float64(y_45_scale * x_45_scale_m) * Float64(y_45_scale * x_45_scale_m)))) * Float64(a * a))
                                                    end
                                                    
                                                    x-scale_m = abs(x_45_scale);
                                                    function tmp = code(a, b, angle, x_45_scale_m, y_45_scale)
                                                    	tmp = (-4.0 * ((b * b) / ((y_45_scale * x_45_scale_m) * (y_45_scale * x_45_scale_m)))) * (a * a);
                                                    end
                                                    
                                                    x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
                                                    code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := N[(N[(-4.0 * N[(N[(b * b), $MachinePrecision] / N[(N[(y$45$scale * x$45$scale$95$m), $MachinePrecision] * N[(y$45$scale * x$45$scale$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]
                                                    
                                                    \begin{array}{l}
                                                    x-scale_m = \left|x-scale\right|
                                                    
                                                    \\
                                                    \left(-4 \cdot \frac{b \cdot b}{\left(y-scale \cdot x-scale\_m\right) \cdot \left(y-scale \cdot x-scale\_m\right)}\right) \cdot \left(a \cdot a\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 \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\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 \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}}{y-scale}}{y-scale} \]
                                                    2. Add Preprocessing
                                                    3. Taylor expanded in a around 0

                                                      \[\leadsto \color{blue}{{a}^{2} \cdot \left(-8 \cdot \frac{{b}^{2} \cdot \left({\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot {\sin \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}\right)}{{x-scale}^{2} \cdot {y-scale}^{2}} - 4 \cdot \left(\frac{{b}^{2} \cdot {\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}{{x-scale}^{2} \cdot {y-scale}^{2}} + \frac{{b}^{2} \cdot {\sin \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}{{x-scale}^{2} \cdot {y-scale}^{2}}\right)\right)} \]
                                                    4. Applied rewrites47.4%

                                                      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-8}{y-scale \cdot y-scale}, \left(\left(b \cdot b\right) \cdot \frac{{\cos \left(-0.005555555555555556 \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)}^{2}}{x-scale}\right) \cdot \frac{{\sin \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)}^{2}}{x-scale}, -4 \cdot \frac{\left(b \cdot b\right) \cdot \left({\cos \left(-0.005555555555555556 \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)}^{4} + {\sin \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)}^{4}\right)}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)}\right) \cdot \left(a \cdot a\right)} \]
                                                    5. Taylor expanded in angle around 0

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

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

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

                                                        Alternative 7: 48.3% accurate, 40.5× speedup?

                                                        \[\begin{array}{l} x-scale_m = \left|x-scale\right| \\ \left(-4 \cdot \frac{b \cdot b}{\left(x-scale\_m \cdot x-scale\_m\right) \cdot \left(y-scale \cdot y-scale\right)}\right) \cdot \left(a \cdot a\right) \end{array} \]
                                                        x-scale_m = (fabs.f64 x-scale)
                                                        (FPCore (a b angle x-scale_m y-scale)
                                                         :precision binary64
                                                         (*
                                                          (* -4.0 (/ (* b b) (* (* x-scale_m x-scale_m) (* y-scale y-scale))))
                                                          (* a a)))
                                                        x-scale_m = fabs(x_45_scale);
                                                        double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
                                                        	return (-4.0 * ((b * b) / ((x_45_scale_m * x_45_scale_m) * (y_45_scale * y_45_scale)))) * (a * a);
                                                        }
                                                        
                                                        x-scale_m =     private
                                                        module fmin_fmax_functions
                                                            implicit none
                                                            private
                                                            public fmax
                                                            public fmin
                                                        
                                                            interface fmax
                                                                module procedure fmax88
                                                                module procedure fmax44
                                                                module procedure fmax84
                                                                module procedure fmax48
                                                            end interface
                                                            interface fmin
                                                                module procedure fmin88
                                                                module procedure fmin44
                                                                module procedure fmin84
                                                                module procedure fmin48
                                                            end interface
                                                        contains
                                                            real(8) function fmax88(x, y) result (res)
                                                                real(8), intent (in) :: x
                                                                real(8), intent (in) :: y
                                                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                            end function
                                                            real(4) function fmax44(x, y) result (res)
                                                                real(4), intent (in) :: x
                                                                real(4), intent (in) :: y
                                                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                            end function
                                                            real(8) function fmax84(x, y) result(res)
                                                                real(8), intent (in) :: x
                                                                real(4), intent (in) :: y
                                                                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                            end function
                                                            real(8) function fmax48(x, y) result(res)
                                                                real(4), intent (in) :: x
                                                                real(8), intent (in) :: y
                                                                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                            end function
                                                            real(8) function fmin88(x, y) result (res)
                                                                real(8), intent (in) :: x
                                                                real(8), intent (in) :: y
                                                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                            end function
                                                            real(4) function fmin44(x, y) result (res)
                                                                real(4), intent (in) :: x
                                                                real(4), intent (in) :: y
                                                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                            end function
                                                            real(8) function fmin84(x, y) result(res)
                                                                real(8), intent (in) :: x
                                                                real(4), intent (in) :: y
                                                                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                            end function
                                                            real(8) function fmin48(x, y) result(res)
                                                                real(4), intent (in) :: x
                                                                real(8), intent (in) :: y
                                                                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                            end function
                                                        end module
                                                        
                                                        real(8) function code(a, b, angle, x_45scale_m, y_45scale)
                                                        use fmin_fmax_functions
                                                            real(8), intent (in) :: a
                                                            real(8), intent (in) :: b
                                                            real(8), intent (in) :: angle
                                                            real(8), intent (in) :: x_45scale_m
                                                            real(8), intent (in) :: y_45scale
                                                            code = ((-4.0d0) * ((b * b) / ((x_45scale_m * x_45scale_m) * (y_45scale * y_45scale)))) * (a * a)
                                                        end function
                                                        
                                                        x-scale_m = Math.abs(x_45_scale);
                                                        public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
                                                        	return (-4.0 * ((b * b) / ((x_45_scale_m * x_45_scale_m) * (y_45_scale * y_45_scale)))) * (a * a);
                                                        }
                                                        
                                                        x-scale_m = math.fabs(x_45_scale)
                                                        def code(a, b, angle, x_45_scale_m, y_45_scale):
                                                        	return (-4.0 * ((b * b) / ((x_45_scale_m * x_45_scale_m) * (y_45_scale * y_45_scale)))) * (a * a)
                                                        
                                                        x-scale_m = abs(x_45_scale)
                                                        function code(a, b, angle, x_45_scale_m, y_45_scale)
                                                        	return Float64(Float64(-4.0 * Float64(Float64(b * b) / Float64(Float64(x_45_scale_m * x_45_scale_m) * Float64(y_45_scale * y_45_scale)))) * Float64(a * a))
                                                        end
                                                        
                                                        x-scale_m = abs(x_45_scale);
                                                        function tmp = code(a, b, angle, x_45_scale_m, y_45_scale)
                                                        	tmp = (-4.0 * ((b * b) / ((x_45_scale_m * x_45_scale_m) * (y_45_scale * y_45_scale)))) * (a * a);
                                                        end
                                                        
                                                        x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
                                                        code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := N[(N[(-4.0 * N[(N[(b * b), $MachinePrecision] / N[(N[(x$45$scale$95$m * x$45$scale$95$m), $MachinePrecision] * N[(y$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]
                                                        
                                                        \begin{array}{l}
                                                        x-scale_m = \left|x-scale\right|
                                                        
                                                        \\
                                                        \left(-4 \cdot \frac{b \cdot b}{\left(x-scale\_m \cdot x-scale\_m\right) \cdot \left(y-scale \cdot y-scale\right)}\right) \cdot \left(a \cdot a\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 \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\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 \mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}}{y-scale}}{y-scale} \]
                                                        2. Add Preprocessing
                                                        3. Taylor expanded in a around 0

                                                          \[\leadsto \color{blue}{{a}^{2} \cdot \left(-8 \cdot \frac{{b}^{2} \cdot \left({\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} \cdot {\sin \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2}\right)}{{x-scale}^{2} \cdot {y-scale}^{2}} - 4 \cdot \left(\frac{{b}^{2} \cdot {\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}{{x-scale}^{2} \cdot {y-scale}^{2}} + \frac{{b}^{2} \cdot {\sin \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}{{x-scale}^{2} \cdot {y-scale}^{2}}\right)\right)} \]
                                                        4. Applied rewrites47.4%

                                                          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-8}{y-scale \cdot y-scale}, \left(\left(b \cdot b\right) \cdot \frac{{\cos \left(-0.005555555555555556 \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)}^{2}}{x-scale}\right) \cdot \frac{{\sin \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)}^{2}}{x-scale}, -4 \cdot \frac{\left(b \cdot b\right) \cdot \left({\cos \left(-0.005555555555555556 \cdot \left(\mathsf{PI}\left(\right) \cdot angle\right)\right)}^{4} + {\sin \left(\left(\mathsf{PI}\left(\right) \cdot angle\right) \cdot 0.005555555555555556\right)}^{4}\right)}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)}\right) \cdot \left(a \cdot a\right)} \]
                                                        5. Taylor expanded in angle around 0

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

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

                                                          Reproduce

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