a from scale-rotated-ellipse

Percentage Accurate: 2.5% → 16.7%
Time: 35.9s
Alternatives: 4
Speedup: 6.9×

Specification

?
\[\begin{array}{l} t_0 := \frac{angle}{180} \cdot \pi\\ t_1 := \sin t\_0\\ t_2 := \cos t\_0\\ t_3 := \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale}\\ t_4 := \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\\ t_5 := \left(b \cdot a\right) \cdot \left(b \cdot \left(-a\right)\right)\\ t_6 := \frac{4 \cdot t\_5}{{\left(x-scale \cdot y-scale\right)}^{2}}\\ \frac{-\sqrt{\left(\left(2 \cdot t\_6\right) \cdot t\_5\right) \cdot \left(\left(t\_4 + t\_3\right) + \sqrt{{\left(t\_4 - t\_3\right)}^{2} + {\left(\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\right)}^{2}}\right)}}{t\_6} \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
         (/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) y-scale) y-scale))
        (t_4
         (/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) x-scale) x-scale))
        (t_5 (* (* b a) (* b (- a))))
        (t_6 (/ (* 4.0 t_5) (pow (* x-scale y-scale) 2.0))))
   (/
    (-
     (sqrt
      (*
       (* (* 2.0 t_6) t_5)
       (+
        (+ t_4 t_3)
        (sqrt
         (+
          (pow (- t_4 t_3) 2.0)
          (pow
           (/
            (/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_2) x-scale)
            y-scale)
           2.0)))))))
    t_6)))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double t_0 = (angle / 180.0) * ((double) M_PI);
	double t_1 = sin(t_0);
	double t_2 = cos(t_0);
	double t_3 = ((pow((a * t_2), 2.0) + pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale;
	double t_4 = ((pow((a * t_1), 2.0) + pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale;
	double t_5 = (b * a) * (b * -a);
	double t_6 = (4.0 * t_5) / pow((x_45_scale * y_45_scale), 2.0);
	return -sqrt((((2.0 * t_6) * t_5) * ((t_4 + t_3) + sqrt((pow((t_4 - t_3), 2.0) + pow((((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale), 2.0)))))) / t_6;
}
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double t_0 = (angle / 180.0) * Math.PI;
	double t_1 = Math.sin(t_0);
	double t_2 = Math.cos(t_0);
	double t_3 = ((Math.pow((a * t_2), 2.0) + Math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale;
	double t_4 = ((Math.pow((a * t_1), 2.0) + Math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale;
	double t_5 = (b * a) * (b * -a);
	double t_6 = (4.0 * t_5) / Math.pow((x_45_scale * y_45_scale), 2.0);
	return -Math.sqrt((((2.0 * t_6) * t_5) * ((t_4 + t_3) + Math.sqrt((Math.pow((t_4 - t_3), 2.0) + Math.pow((((((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale), 2.0)))))) / t_6;
}
def code(a, b, angle, x_45_scale, y_45_scale):
	t_0 = (angle / 180.0) * math.pi
	t_1 = math.sin(t_0)
	t_2 = math.cos(t_0)
	t_3 = ((math.pow((a * t_2), 2.0) + math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale
	t_4 = ((math.pow((a * t_1), 2.0) + math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale
	t_5 = (b * a) * (b * -a)
	t_6 = (4.0 * t_5) / math.pow((x_45_scale * y_45_scale), 2.0)
	return -math.sqrt((((2.0 * t_6) * t_5) * ((t_4 + t_3) + math.sqrt((math.pow((t_4 - t_3), 2.0) + math.pow((((((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale), 2.0)))))) / t_6
function code(a, b, angle, x_45_scale, y_45_scale)
	t_0 = Float64(Float64(angle / 180.0) * pi)
	t_1 = sin(t_0)
	t_2 = cos(t_0)
	t_3 = Float64(Float64(Float64((Float64(a * t_2) ^ 2.0) + (Float64(b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale)
	t_4 = Float64(Float64(Float64((Float64(a * t_1) ^ 2.0) + (Float64(b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale)
	t_5 = Float64(Float64(b * a) * Float64(b * Float64(-a)))
	t_6 = Float64(Float64(4.0 * t_5) / (Float64(x_45_scale * y_45_scale) ^ 2.0))
	return Float64(Float64(-sqrt(Float64(Float64(Float64(2.0 * t_6) * t_5) * Float64(Float64(t_4 + t_3) + sqrt(Float64((Float64(t_4 - t_3) ^ 2.0) + (Float64(Float64(Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale) ^ 2.0))))))) / t_6)
end
function tmp = code(a, b, angle, x_45_scale, y_45_scale)
	t_0 = (angle / 180.0) * pi;
	t_1 = sin(t_0);
	t_2 = cos(t_0);
	t_3 = ((((a * t_2) ^ 2.0) + ((b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale;
	t_4 = ((((a * t_1) ^ 2.0) + ((b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale;
	t_5 = (b * a) * (b * -a);
	t_6 = (4.0 * t_5) / ((x_45_scale * y_45_scale) ^ 2.0);
	tmp = -sqrt((((2.0 * t_6) * t_5) * ((t_4 + t_3) + sqrt((((t_4 - t_3) ^ 2.0) + ((((((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale) ^ 2.0)))))) / t_6;
end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, Block[{t$95$1 = N[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[Power[N[(a * t$95$2), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[(N[Power[N[(a * t$95$1), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$2), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / x$45$scale), $MachinePrecision] / x$45$scale), $MachinePrecision]}, Block[{t$95$5 = N[(N[(b * a), $MachinePrecision] * N[(b * (-a)), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(N[(4.0 * t$95$5), $MachinePrecision] / N[Power[N[(x$45$scale * y$45$scale), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(N[(2.0 * t$95$6), $MachinePrecision] * t$95$5), $MachinePrecision] * N[(N[(t$95$4 + t$95$3), $MachinePrecision] + N[Sqrt[N[(N[Power[N[(t$95$4 - t$95$3), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(N[(N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision] / x$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$6), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
t_3 := \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale}\\
t_4 := \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\\
t_5 := \left(b \cdot a\right) \cdot \left(b \cdot \left(-a\right)\right)\\
t_6 := \frac{4 \cdot t\_5}{{\left(x-scale \cdot y-scale\right)}^{2}}\\
\frac{-\sqrt{\left(\left(2 \cdot t\_6\right) \cdot t\_5\right) \cdot \left(\left(t\_4 + t\_3\right) + \sqrt{{\left(t\_4 - t\_3\right)}^{2} + {\left(\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\right)}^{2}}\right)}}{t\_6}
\end{array}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 4 alternatives:

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

Initial Program: 2.5% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := \frac{angle}{180} \cdot \pi\\ t_1 := \sin t\_0\\ t_2 := \cos t\_0\\ t_3 := \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale}\\ t_4 := \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\\ t_5 := \left(b \cdot a\right) \cdot \left(b \cdot \left(-a\right)\right)\\ t_6 := \frac{4 \cdot t\_5}{{\left(x-scale \cdot y-scale\right)}^{2}}\\ \frac{-\sqrt{\left(\left(2 \cdot t\_6\right) \cdot t\_5\right) \cdot \left(\left(t\_4 + t\_3\right) + \sqrt{{\left(t\_4 - t\_3\right)}^{2} + {\left(\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\right)}^{2}}\right)}}{t\_6} \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
         (/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) y-scale) y-scale))
        (t_4
         (/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) x-scale) x-scale))
        (t_5 (* (* b a) (* b (- a))))
        (t_6 (/ (* 4.0 t_5) (pow (* x-scale y-scale) 2.0))))
   (/
    (-
     (sqrt
      (*
       (* (* 2.0 t_6) t_5)
       (+
        (+ t_4 t_3)
        (sqrt
         (+
          (pow (- t_4 t_3) 2.0)
          (pow
           (/
            (/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_2) x-scale)
            y-scale)
           2.0)))))))
    t_6)))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double t_0 = (angle / 180.0) * ((double) M_PI);
	double t_1 = sin(t_0);
	double t_2 = cos(t_0);
	double t_3 = ((pow((a * t_2), 2.0) + pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale;
	double t_4 = ((pow((a * t_1), 2.0) + pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale;
	double t_5 = (b * a) * (b * -a);
	double t_6 = (4.0 * t_5) / pow((x_45_scale * y_45_scale), 2.0);
	return -sqrt((((2.0 * t_6) * t_5) * ((t_4 + t_3) + sqrt((pow((t_4 - t_3), 2.0) + pow((((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale), 2.0)))))) / t_6;
}
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double t_0 = (angle / 180.0) * Math.PI;
	double t_1 = Math.sin(t_0);
	double t_2 = Math.cos(t_0);
	double t_3 = ((Math.pow((a * t_2), 2.0) + Math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale;
	double t_4 = ((Math.pow((a * t_1), 2.0) + Math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale;
	double t_5 = (b * a) * (b * -a);
	double t_6 = (4.0 * t_5) / Math.pow((x_45_scale * y_45_scale), 2.0);
	return -Math.sqrt((((2.0 * t_6) * t_5) * ((t_4 + t_3) + Math.sqrt((Math.pow((t_4 - t_3), 2.0) + Math.pow((((((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale), 2.0)))))) / t_6;
}
def code(a, b, angle, x_45_scale, y_45_scale):
	t_0 = (angle / 180.0) * math.pi
	t_1 = math.sin(t_0)
	t_2 = math.cos(t_0)
	t_3 = ((math.pow((a * t_2), 2.0) + math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale
	t_4 = ((math.pow((a * t_1), 2.0) + math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale
	t_5 = (b * a) * (b * -a)
	t_6 = (4.0 * t_5) / math.pow((x_45_scale * y_45_scale), 2.0)
	return -math.sqrt((((2.0 * t_6) * t_5) * ((t_4 + t_3) + math.sqrt((math.pow((t_4 - t_3), 2.0) + math.pow((((((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale), 2.0)))))) / t_6
function code(a, b, angle, x_45_scale, y_45_scale)
	t_0 = Float64(Float64(angle / 180.0) * pi)
	t_1 = sin(t_0)
	t_2 = cos(t_0)
	t_3 = Float64(Float64(Float64((Float64(a * t_2) ^ 2.0) + (Float64(b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale)
	t_4 = Float64(Float64(Float64((Float64(a * t_1) ^ 2.0) + (Float64(b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale)
	t_5 = Float64(Float64(b * a) * Float64(b * Float64(-a)))
	t_6 = Float64(Float64(4.0 * t_5) / (Float64(x_45_scale * y_45_scale) ^ 2.0))
	return Float64(Float64(-sqrt(Float64(Float64(Float64(2.0 * t_6) * t_5) * Float64(Float64(t_4 + t_3) + sqrt(Float64((Float64(t_4 - t_3) ^ 2.0) + (Float64(Float64(Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale) ^ 2.0))))))) / t_6)
end
function tmp = code(a, b, angle, x_45_scale, y_45_scale)
	t_0 = (angle / 180.0) * pi;
	t_1 = sin(t_0);
	t_2 = cos(t_0);
	t_3 = ((((a * t_2) ^ 2.0) + ((b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale;
	t_4 = ((((a * t_1) ^ 2.0) + ((b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale;
	t_5 = (b * a) * (b * -a);
	t_6 = (4.0 * t_5) / ((x_45_scale * y_45_scale) ^ 2.0);
	tmp = -sqrt((((2.0 * t_6) * t_5) * ((t_4 + t_3) + sqrt((((t_4 - t_3) ^ 2.0) + ((((((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale) ^ 2.0)))))) / t_6;
end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, Block[{t$95$1 = N[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[Power[N[(a * t$95$2), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[(N[Power[N[(a * t$95$1), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$2), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / x$45$scale), $MachinePrecision] / x$45$scale), $MachinePrecision]}, Block[{t$95$5 = N[(N[(b * a), $MachinePrecision] * N[(b * (-a)), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(N[(4.0 * t$95$5), $MachinePrecision] / N[Power[N[(x$45$scale * y$45$scale), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(N[(2.0 * t$95$6), $MachinePrecision] * t$95$5), $MachinePrecision] * N[(N[(t$95$4 + t$95$3), $MachinePrecision] + N[Sqrt[N[(N[Power[N[(t$95$4 - t$95$3), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(N[(N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision] / x$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$6), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
t_3 := \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale}\\
t_4 := \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\\
t_5 := \left(b \cdot a\right) \cdot \left(b \cdot \left(-a\right)\right)\\
t_6 := \frac{4 \cdot t\_5}{{\left(x-scale \cdot y-scale\right)}^{2}}\\
\frac{-\sqrt{\left(\left(2 \cdot t\_6\right) \cdot t\_5\right) \cdot \left(\left(t\_4 + t\_3\right) + \sqrt{{\left(t\_4 - t\_3\right)}^{2} + {\left(\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\right)}^{2}}\right)}}{t\_6}
\end{array}

Alternative 1: 16.7% accurate, 6.8× speedup?

\[\begin{array}{l} t_0 := \frac{a}{y-scale \cdot y-scale}\\ t_1 := \frac{b}{x-scale \cdot x-scale}\\ t_2 := \left(\left(-a\right) \cdot b\right) \cdot \left(a \cdot b\right)\\ \left(\frac{\frac{\frac{\sqrt{t\_2 \cdot \left(8 \cdot \left(\mathsf{fma}\left(t\_0, a, \mathsf{fma}\left(t\_1, b, \left|t\_1 \cdot b - t\_0 \cdot a\right|\right)\right) \cdot t\_2\right)\right)}}{\left|x-scale \cdot y-scale\right|}}{\left(b \cdot a\right) \cdot 4}}{b \cdot a} \cdot \left(y-scale \cdot x-scale\right)\right) \cdot \left(y-scale \cdot x-scale\right) \end{array} \]
(FPCore (a b angle x-scale y-scale)
 :precision binary64
 (let* ((t_0 (/ a (* y-scale y-scale)))
        (t_1 (/ b (* x-scale x-scale)))
        (t_2 (* (* (- a) b) (* a b))))
   (*
    (*
     (/
      (/
       (/
        (sqrt
         (*
          t_2
          (*
           8.0
           (* (fma t_0 a (fma t_1 b (fabs (- (* t_1 b) (* t_0 a))))) t_2))))
        (fabs (* x-scale y-scale)))
       (* (* b a) 4.0))
      (* b a))
     (* y-scale x-scale))
    (* y-scale x-scale))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double t_0 = a / (y_45_scale * y_45_scale);
	double t_1 = b / (x_45_scale * x_45_scale);
	double t_2 = (-a * b) * (a * b);
	return ((((sqrt((t_2 * (8.0 * (fma(t_0, a, fma(t_1, b, fabs(((t_1 * b) - (t_0 * a))))) * t_2)))) / fabs((x_45_scale * y_45_scale))) / ((b * a) * 4.0)) / (b * a)) * (y_45_scale * x_45_scale)) * (y_45_scale * x_45_scale);
}
function code(a, b, angle, x_45_scale, y_45_scale)
	t_0 = Float64(a / Float64(y_45_scale * y_45_scale))
	t_1 = Float64(b / Float64(x_45_scale * x_45_scale))
	t_2 = Float64(Float64(Float64(-a) * b) * Float64(a * b))
	return Float64(Float64(Float64(Float64(Float64(sqrt(Float64(t_2 * Float64(8.0 * Float64(fma(t_0, a, fma(t_1, b, abs(Float64(Float64(t_1 * b) - Float64(t_0 * a))))) * t_2)))) / abs(Float64(x_45_scale * y_45_scale))) / Float64(Float64(b * a) * 4.0)) / Float64(b * a)) * Float64(y_45_scale * x_45_scale)) * Float64(y_45_scale * x_45_scale))
end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(a / N[(y$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[(x$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[((-a) * b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[(N[Sqrt[N[(t$95$2 * N[(8.0 * N[(N[(t$95$0 * a + N[(t$95$1 * b + N[Abs[N[(N[(t$95$1 * b), $MachinePrecision] - N[(t$95$0 * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[N[(x$45$scale * y$45$scale), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(b * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \frac{a}{y-scale \cdot y-scale}\\
t_1 := \frac{b}{x-scale \cdot x-scale}\\
t_2 := \left(\left(-a\right) \cdot b\right) \cdot \left(a \cdot b\right)\\
\left(\frac{\frac{\frac{\sqrt{t\_2 \cdot \left(8 \cdot \left(\mathsf{fma}\left(t\_0, a, \mathsf{fma}\left(t\_1, b, \left|t\_1 \cdot b - t\_0 \cdot a\right|\right)\right) \cdot t\_2\right)\right)}}{\left|x-scale \cdot y-scale\right|}}{\left(b \cdot a\right) \cdot 4}}{b \cdot a} \cdot \left(y-scale \cdot x-scale\right)\right) \cdot \left(y-scale \cdot x-scale\right)
\end{array}
Derivation
  1. Initial program 2.5%

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

    \[\leadsto \color{blue}{\left(\frac{\frac{\sqrt{\left(8 \cdot \left(\left(\left(\left(-a\right) \cdot b\right) \cdot b\right) \cdot a\right)\right) \cdot \left(\left(\left(\left(\left(-a\right) \cdot b\right) \cdot b\right) \cdot a\right) \cdot \left(\left(\mathsf{hypot}\left(\frac{\left(\left(b + a\right) \cdot \left(b - a\right)\right) \cdot \sin \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)}{y-scale \cdot x-scale}, \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), a \cdot a, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(b \cdot b\right)\right)}{x-scale \cdot x-scale} - \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), b \cdot b, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(a \cdot a\right)\right)}{y-scale \cdot y-scale}\right) + \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), a \cdot a, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(b \cdot b\right)\right)}{x-scale \cdot x-scale}\right) + \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), b \cdot b, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(a \cdot a\right)\right)}{y-scale \cdot y-scale}\right)\right)}}{\left|y-scale \cdot x-scale\right|}}{\left(\left(a \cdot b\right) \cdot 4\right) \cdot \left(a \cdot b\right)} \cdot \left(y-scale \cdot x-scale\right)\right) \cdot \left(y-scale \cdot x-scale\right)} \]
  3. Applied rewrites12.1%

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

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

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

      \[\leadsto \left(\frac{\frac{\frac{\sqrt{\color{blue}{\left(\left(\left(-a\right) \cdot b\right) \cdot \left(a \cdot b\right)\right) \cdot \left(8 \cdot \left(\mathsf{fma}\left(\frac{a}{y-scale \cdot y-scale}, a, \mathsf{fma}\left(\frac{b}{x-scale \cdot x-scale}, b, \left|\frac{b}{x-scale \cdot x-scale} \cdot b - \frac{a}{y-scale \cdot y-scale} \cdot a\right|\right)\right) \cdot \left(\left(\left(-a\right) \cdot b\right) \cdot \left(a \cdot b\right)\right)\right)\right)}}}{\left|x-scale \cdot y-scale\right|}}{\left(b \cdot a\right) \cdot 4}}{b \cdot a} \cdot \left(y-scale \cdot x-scale\right)\right) \cdot \left(y-scale \cdot x-scale\right) \]
    3. Add Preprocessing

    Alternative 2: 12.6% accurate, 6.9× speedup?

    \[\begin{array}{l} t_0 := \frac{b}{x-scale \cdot x-scale}\\ t_1 := \frac{a}{y-scale \cdot y-scale}\\ \frac{\frac{\sqrt{\left(\mathsf{fma}\left(t\_1, a, \mathsf{fma}\left(t\_0, b, \left|t\_0 \cdot b - t\_1 \cdot a\right|\right)\right) \cdot \left(\left(\left(-a\right) \cdot b\right) \cdot \left(a \cdot b\right)\right)\right) \cdot \left(\left(\left(a \cdot b\right) \cdot b\right) \cdot \left(\left(-a\right) \cdot 8\right)\right)}}{\left|x-scale \cdot y-scale\right| \cdot \left(4 \cdot \left(a \cdot b\right)\right)} \cdot \left(x-scale \cdot y-scale\right)}{a \cdot b} \cdot \left(y-scale \cdot x-scale\right) \end{array} \]
    (FPCore (a b angle x-scale y-scale)
     :precision binary64
     (let* ((t_0 (/ b (* x-scale x-scale))) (t_1 (/ a (* y-scale y-scale))))
       (*
        (/
         (*
          (/
           (sqrt
            (*
             (*
              (fma t_1 a (fma t_0 b (fabs (- (* t_0 b) (* t_1 a)))))
              (* (* (- a) b) (* a b)))
             (* (* (* a b) b) (* (- a) 8.0))))
           (* (fabs (* x-scale y-scale)) (* 4.0 (* a b))))
          (* x-scale y-scale))
         (* a b))
        (* y-scale x-scale))))
    double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
    	double t_0 = b / (x_45_scale * x_45_scale);
    	double t_1 = a / (y_45_scale * y_45_scale);
    	return (((sqrt(((fma(t_1, a, fma(t_0, b, fabs(((t_0 * b) - (t_1 * a))))) * ((-a * b) * (a * b))) * (((a * b) * b) * (-a * 8.0)))) / (fabs((x_45_scale * y_45_scale)) * (4.0 * (a * b)))) * (x_45_scale * y_45_scale)) / (a * b)) * (y_45_scale * x_45_scale);
    }
    
    function code(a, b, angle, x_45_scale, y_45_scale)
    	t_0 = Float64(b / Float64(x_45_scale * x_45_scale))
    	t_1 = Float64(a / Float64(y_45_scale * y_45_scale))
    	return Float64(Float64(Float64(Float64(sqrt(Float64(Float64(fma(t_1, a, fma(t_0, b, abs(Float64(Float64(t_0 * b) - Float64(t_1 * a))))) * Float64(Float64(Float64(-a) * b) * Float64(a * b))) * Float64(Float64(Float64(a * b) * b) * Float64(Float64(-a) * 8.0)))) / Float64(abs(Float64(x_45_scale * y_45_scale)) * Float64(4.0 * Float64(a * b)))) * Float64(x_45_scale * y_45_scale)) / Float64(a * b)) * Float64(y_45_scale * x_45_scale))
    end
    
    code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(b / N[(x$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(a / N[(y$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[Sqrt[N[(N[(N[(t$95$1 * a + N[(t$95$0 * b + N[Abs[N[(N[(t$95$0 * b), $MachinePrecision] - N[(t$95$1 * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[((-a) * b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(a * b), $MachinePrecision] * b), $MachinePrecision] * N[((-a) * 8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[Abs[N[(x$45$scale * y$45$scale), $MachinePrecision]], $MachinePrecision] * N[(4.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    t_0 := \frac{b}{x-scale \cdot x-scale}\\
    t_1 := \frac{a}{y-scale \cdot y-scale}\\
    \frac{\frac{\sqrt{\left(\mathsf{fma}\left(t\_1, a, \mathsf{fma}\left(t\_0, b, \left|t\_0 \cdot b - t\_1 \cdot a\right|\right)\right) \cdot \left(\left(\left(-a\right) \cdot b\right) \cdot \left(a \cdot b\right)\right)\right) \cdot \left(\left(\left(a \cdot b\right) \cdot b\right) \cdot \left(\left(-a\right) \cdot 8\right)\right)}}{\left|x-scale \cdot y-scale\right| \cdot \left(4 \cdot \left(a \cdot b\right)\right)} \cdot \left(x-scale \cdot y-scale\right)}{a \cdot b} \cdot \left(y-scale \cdot x-scale\right)
    \end{array}
    
    Derivation
    1. Initial program 2.5%

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

      \[\leadsto \color{blue}{\left(\frac{\frac{\sqrt{\left(8 \cdot \left(\left(\left(\left(-a\right) \cdot b\right) \cdot b\right) \cdot a\right)\right) \cdot \left(\left(\left(\left(\left(-a\right) \cdot b\right) \cdot b\right) \cdot a\right) \cdot \left(\left(\mathsf{hypot}\left(\frac{\left(\left(b + a\right) \cdot \left(b - a\right)\right) \cdot \sin \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)}{y-scale \cdot x-scale}, \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), a \cdot a, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(b \cdot b\right)\right)}{x-scale \cdot x-scale} - \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), b \cdot b, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(a \cdot a\right)\right)}{y-scale \cdot y-scale}\right) + \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), a \cdot a, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(b \cdot b\right)\right)}{x-scale \cdot x-scale}\right) + \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), b \cdot b, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(a \cdot a\right)\right)}{y-scale \cdot y-scale}\right)\right)}}{\left|y-scale \cdot x-scale\right|}}{\left(\left(a \cdot b\right) \cdot 4\right) \cdot \left(a \cdot b\right)} \cdot \left(y-scale \cdot x-scale\right)\right) \cdot \left(y-scale \cdot x-scale\right)} \]
    3. Applied rewrites12.1%

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{\sqrt{\left(\mathsf{fma}\left(\frac{a}{y-scale \cdot y-scale}, a, \mathsf{fma}\left(\frac{b}{x-scale \cdot x-scale}, b, \left|\frac{b}{x-scale \cdot x-scale} \cdot b - \frac{a}{y-scale \cdot y-scale} \cdot a\right|\right)\right) \cdot \left(\left(\left(-a\right) \cdot b\right) \cdot \left(a \cdot b\right)\right)\right) \cdot \left(\left(\left(a \cdot b\right) \cdot b\right) \cdot \left(\left(-a\right) \cdot 8\right)\right)}}{\left|x-scale \cdot y-scale\right| \cdot \left(4 \cdot \left(a \cdot b\right)\right)} \cdot \left(x-scale \cdot y-scale\right)}{a \cdot b}} \cdot \left(y-scale \cdot x-scale\right) \]
      3. Add Preprocessing

      Alternative 3: 12.5% accurate, 6.9× speedup?

      \[\begin{array}{l} t_0 := \frac{b}{x-scale \cdot x-scale}\\ t_1 := \frac{a}{y-scale \cdot y-scale}\\ \left(\frac{\frac{\sqrt{\left(\mathsf{fma}\left(t\_1, a, \mathsf{fma}\left(t\_0, b, \left|t\_0 \cdot b - t\_1 \cdot a\right|\right)\right) \cdot \left(\left(\left(-a\right) \cdot b\right) \cdot \left(a \cdot b\right)\right)\right) \cdot \left(\left(\left(a \cdot b\right) \cdot b\right) \cdot \left(\left(-a\right) \cdot 8\right)\right)}}{\left|x-scale \cdot y-scale\right| \cdot \left(4 \cdot \left(a \cdot b\right)\right)}}{b \cdot a} \cdot \left(y-scale \cdot x-scale\right)\right) \cdot \left(y-scale \cdot x-scale\right) \end{array} \]
      (FPCore (a b angle x-scale y-scale)
       :precision binary64
       (let* ((t_0 (/ b (* x-scale x-scale))) (t_1 (/ a (* y-scale y-scale))))
         (*
          (*
           (/
            (/
             (sqrt
              (*
               (*
                (fma t_1 a (fma t_0 b (fabs (- (* t_0 b) (* t_1 a)))))
                (* (* (- a) b) (* a b)))
               (* (* (* a b) b) (* (- a) 8.0))))
             (* (fabs (* x-scale y-scale)) (* 4.0 (* a b))))
            (* b a))
           (* y-scale x-scale))
          (* y-scale x-scale))))
      double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
      	double t_0 = b / (x_45_scale * x_45_scale);
      	double t_1 = a / (y_45_scale * y_45_scale);
      	return (((sqrt(((fma(t_1, a, fma(t_0, b, fabs(((t_0 * b) - (t_1 * a))))) * ((-a * b) * (a * b))) * (((a * b) * b) * (-a * 8.0)))) / (fabs((x_45_scale * y_45_scale)) * (4.0 * (a * b)))) / (b * a)) * (y_45_scale * x_45_scale)) * (y_45_scale * x_45_scale);
      }
      
      function code(a, b, angle, x_45_scale, y_45_scale)
      	t_0 = Float64(b / Float64(x_45_scale * x_45_scale))
      	t_1 = Float64(a / Float64(y_45_scale * y_45_scale))
      	return Float64(Float64(Float64(Float64(sqrt(Float64(Float64(fma(t_1, a, fma(t_0, b, abs(Float64(Float64(t_0 * b) - Float64(t_1 * a))))) * Float64(Float64(Float64(-a) * b) * Float64(a * b))) * Float64(Float64(Float64(a * b) * b) * Float64(Float64(-a) * 8.0)))) / Float64(abs(Float64(x_45_scale * y_45_scale)) * Float64(4.0 * Float64(a * b)))) / Float64(b * a)) * Float64(y_45_scale * x_45_scale)) * Float64(y_45_scale * x_45_scale))
      end
      
      code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(b / N[(x$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(a / N[(y$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[Sqrt[N[(N[(N[(t$95$1 * a + N[(t$95$0 * b + N[Abs[N[(N[(t$95$0 * b), $MachinePrecision] - N[(t$95$1 * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[((-a) * b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(a * b), $MachinePrecision] * b), $MachinePrecision] * N[((-a) * 8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[Abs[N[(x$45$scale * y$45$scale), $MachinePrecision]], $MachinePrecision] * N[(4.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      t_0 := \frac{b}{x-scale \cdot x-scale}\\
      t_1 := \frac{a}{y-scale \cdot y-scale}\\
      \left(\frac{\frac{\sqrt{\left(\mathsf{fma}\left(t\_1, a, \mathsf{fma}\left(t\_0, b, \left|t\_0 \cdot b - t\_1 \cdot a\right|\right)\right) \cdot \left(\left(\left(-a\right) \cdot b\right) \cdot \left(a \cdot b\right)\right)\right) \cdot \left(\left(\left(a \cdot b\right) \cdot b\right) \cdot \left(\left(-a\right) \cdot 8\right)\right)}}{\left|x-scale \cdot y-scale\right| \cdot \left(4 \cdot \left(a \cdot b\right)\right)}}{b \cdot a} \cdot \left(y-scale \cdot x-scale\right)\right) \cdot \left(y-scale \cdot x-scale\right)
      \end{array}
      
      Derivation
      1. Initial program 2.5%

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

        \[\leadsto \color{blue}{\left(\frac{\frac{\sqrt{\left(8 \cdot \left(\left(\left(\left(-a\right) \cdot b\right) \cdot b\right) \cdot a\right)\right) \cdot \left(\left(\left(\left(\left(-a\right) \cdot b\right) \cdot b\right) \cdot a\right) \cdot \left(\left(\mathsf{hypot}\left(\frac{\left(\left(b + a\right) \cdot \left(b - a\right)\right) \cdot \sin \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)}{y-scale \cdot x-scale}, \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), a \cdot a, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(b \cdot b\right)\right)}{x-scale \cdot x-scale} - \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), b \cdot b, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(a \cdot a\right)\right)}{y-scale \cdot y-scale}\right) + \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), a \cdot a, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(b \cdot b\right)\right)}{x-scale \cdot x-scale}\right) + \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), b \cdot b, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(a \cdot a\right)\right)}{y-scale \cdot y-scale}\right)\right)}}{\left|y-scale \cdot x-scale\right|}}{\left(\left(a \cdot b\right) \cdot 4\right) \cdot \left(a \cdot b\right)} \cdot \left(y-scale \cdot x-scale\right)\right) \cdot \left(y-scale \cdot x-scale\right)} \]
      3. Applied rewrites12.1%

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

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

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

          \[\leadsto \left(\frac{\color{blue}{\frac{\sqrt{\left(\mathsf{fma}\left(\frac{a}{y-scale \cdot y-scale}, a, \mathsf{fma}\left(\frac{b}{x-scale \cdot x-scale}, b, \left|\frac{b}{x-scale \cdot x-scale} \cdot b - \frac{a}{y-scale \cdot y-scale} \cdot a\right|\right)\right) \cdot \left(\left(\left(-a\right) \cdot b\right) \cdot \left(a \cdot b\right)\right)\right) \cdot \left(\left(\left(a \cdot b\right) \cdot b\right) \cdot \left(\left(-a\right) \cdot 8\right)\right)}}{\left|x-scale \cdot y-scale\right| \cdot \left(4 \cdot \left(a \cdot b\right)\right)}}}{b \cdot a} \cdot \left(y-scale \cdot x-scale\right)\right) \cdot \left(y-scale \cdot x-scale\right) \]
        3. Add Preprocessing

        Alternative 4: 9.7% accurate, 6.9× speedup?

        \[\begin{array}{l} t_0 := \frac{b}{x-scale \cdot x-scale}\\ t_1 := \frac{a}{y-scale \cdot y-scale}\\ \left(\frac{\frac{\sqrt{\left(\mathsf{fma}\left(t\_1, a, \mathsf{fma}\left(t\_0, b, \left|t\_0 \cdot b - t\_1 \cdot a\right|\right)\right) \cdot \left(\left(\left(-a\right) \cdot b\right) \cdot \left(a \cdot b\right)\right)\right) \cdot \left(\left(\left(a \cdot b\right) \cdot b\right) \cdot \left(\left(-a\right) \cdot 8\right)\right)}}{\left|x-scale \cdot y-scale\right|}}{\left(4 \cdot \left(a \cdot b\right)\right) \cdot \left(a \cdot b\right)} \cdot \left(y-scale \cdot x-scale\right)\right) \cdot \left(y-scale \cdot x-scale\right) \end{array} \]
        (FPCore (a b angle x-scale y-scale)
         :precision binary64
         (let* ((t_0 (/ b (* x-scale x-scale))) (t_1 (/ a (* y-scale y-scale))))
           (*
            (*
             (/
              (/
               (sqrt
                (*
                 (*
                  (fma t_1 a (fma t_0 b (fabs (- (* t_0 b) (* t_1 a)))))
                  (* (* (- a) b) (* a b)))
                 (* (* (* a b) b) (* (- a) 8.0))))
               (fabs (* x-scale y-scale)))
              (* (* 4.0 (* a b)) (* a b)))
             (* y-scale x-scale))
            (* y-scale x-scale))))
        double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
        	double t_0 = b / (x_45_scale * x_45_scale);
        	double t_1 = a / (y_45_scale * y_45_scale);
        	return (((sqrt(((fma(t_1, a, fma(t_0, b, fabs(((t_0 * b) - (t_1 * a))))) * ((-a * b) * (a * b))) * (((a * b) * b) * (-a * 8.0)))) / fabs((x_45_scale * y_45_scale))) / ((4.0 * (a * b)) * (a * b))) * (y_45_scale * x_45_scale)) * (y_45_scale * x_45_scale);
        }
        
        function code(a, b, angle, x_45_scale, y_45_scale)
        	t_0 = Float64(b / Float64(x_45_scale * x_45_scale))
        	t_1 = Float64(a / Float64(y_45_scale * y_45_scale))
        	return Float64(Float64(Float64(Float64(sqrt(Float64(Float64(fma(t_1, a, fma(t_0, b, abs(Float64(Float64(t_0 * b) - Float64(t_1 * a))))) * Float64(Float64(Float64(-a) * b) * Float64(a * b))) * Float64(Float64(Float64(a * b) * b) * Float64(Float64(-a) * 8.0)))) / abs(Float64(x_45_scale * y_45_scale))) / Float64(Float64(4.0 * Float64(a * b)) * Float64(a * b))) * Float64(y_45_scale * x_45_scale)) * Float64(y_45_scale * x_45_scale))
        end
        
        code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(b / N[(x$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(a / N[(y$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[Sqrt[N[(N[(N[(t$95$1 * a + N[(t$95$0 * b + N[Abs[N[(N[(t$95$0 * b), $MachinePrecision] - N[(t$95$1 * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[((-a) * b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(a * b), $MachinePrecision] * b), $MachinePrecision] * N[((-a) * 8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[N[(x$45$scale * y$45$scale), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(4.0 * N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]]]
        
        \begin{array}{l}
        t_0 := \frac{b}{x-scale \cdot x-scale}\\
        t_1 := \frac{a}{y-scale \cdot y-scale}\\
        \left(\frac{\frac{\sqrt{\left(\mathsf{fma}\left(t\_1, a, \mathsf{fma}\left(t\_0, b, \left|t\_0 \cdot b - t\_1 \cdot a\right|\right)\right) \cdot \left(\left(\left(-a\right) \cdot b\right) \cdot \left(a \cdot b\right)\right)\right) \cdot \left(\left(\left(a \cdot b\right) \cdot b\right) \cdot \left(\left(-a\right) \cdot 8\right)\right)}}{\left|x-scale \cdot y-scale\right|}}{\left(4 \cdot \left(a \cdot b\right)\right) \cdot \left(a \cdot b\right)} \cdot \left(y-scale \cdot x-scale\right)\right) \cdot \left(y-scale \cdot x-scale\right)
        \end{array}
        
        Derivation
        1. Initial program 2.5%

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

          \[\leadsto \color{blue}{\left(\frac{\frac{\sqrt{\left(8 \cdot \left(\left(\left(\left(-a\right) \cdot b\right) \cdot b\right) \cdot a\right)\right) \cdot \left(\left(\left(\left(\left(-a\right) \cdot b\right) \cdot b\right) \cdot a\right) \cdot \left(\left(\mathsf{hypot}\left(\frac{\left(\left(b + a\right) \cdot \left(b - a\right)\right) \cdot \sin \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)}{y-scale \cdot x-scale}, \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), a \cdot a, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(b \cdot b\right)\right)}{x-scale \cdot x-scale} - \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), b \cdot b, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(a \cdot a\right)\right)}{y-scale \cdot y-scale}\right) + \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), a \cdot a, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(b \cdot b\right)\right)}{x-scale \cdot x-scale}\right) + \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right), b \cdot b, \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(a \cdot a\right)\right)}{y-scale \cdot y-scale}\right)\right)}}{\left|y-scale \cdot x-scale\right|}}{\left(\left(a \cdot b\right) \cdot 4\right) \cdot \left(a \cdot b\right)} \cdot \left(y-scale \cdot x-scale\right)\right) \cdot \left(y-scale \cdot x-scale\right)} \]
        3. Applied rewrites12.1%

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

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

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

            \[\leadsto \left(\color{blue}{\frac{\frac{\sqrt{\left(\mathsf{fma}\left(\frac{a}{y-scale \cdot y-scale}, a, \mathsf{fma}\left(\frac{b}{x-scale \cdot x-scale}, b, \left|\frac{b}{x-scale \cdot x-scale} \cdot b - \frac{a}{y-scale \cdot y-scale} \cdot a\right|\right)\right) \cdot \left(\left(\left(-a\right) \cdot b\right) \cdot \left(a \cdot b\right)\right)\right) \cdot \left(\left(\left(a \cdot b\right) \cdot b\right) \cdot \left(\left(-a\right) \cdot 8\right)\right)}}{\left|x-scale \cdot y-scale\right|}}{\left(4 \cdot \left(a \cdot b\right)\right) \cdot \left(a \cdot b\right)}} \cdot \left(y-scale \cdot x-scale\right)\right) \cdot \left(y-scale \cdot x-scale\right) \]
          3. Add Preprocessing

          Reproduce

          ?
          herbie shell --seed 2025189 
          (FPCore (a b angle x-scale y-scale)
            :name "a from scale-rotated-ellipse"
            :precision binary64
            (/ (- (sqrt (* (* (* 2.0 (/ (* 4.0 (* (* b a) (* b (- a)))) (pow (* x-scale y-scale) 2.0))) (* (* b a) (* b (- a)))) (+ (+ (/ (/ (+ (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)) (sqrt (+ (pow (- (/ (/ (+ (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)) 2.0) (pow (/ (/ (* (* (* 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))))))) (/ (* 4.0 (* (* b a) (* b (- a)))) (pow (* x-scale y-scale) 2.0))))