b from scale-rotated-ellipse

Percentage Accurate: 0.1% → 25.4%
Time: 34.2s
Alternatives: 8
Speedup: 14.3×

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 8 alternatives:

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

Initial Program: 0.1% 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: 25.4% accurate, 4.4× speedup?

\[\begin{array}{l} t_0 := {\left(\left|x-scale\right|\right)}^{2}\\ t_1 := \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\\ t_2 := \left(b \cdot a\right) \cdot \left(b \cdot \left(-a\right)\right)\\ t_3 := \frac{4 \cdot t\_2}{{\left(\left|x-scale\right| \cdot y-scale\right)}^{2}}\\ t_4 := \sqrt{{t\_1}^{4}}\\ \mathbf{if}\;\left|x-scale\right| \leq 1.55 \cdot 10^{-162}:\\ \;\;\;\;0.25 \cdot \frac{a \cdot \left(t\_0 \cdot \sqrt{8 \cdot \left(\left(0.5 + 0.5 \cdot \cos \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right) - t\_4\right)}\right)}{\left|\left|x-scale\right|\right|}\\ \mathbf{elif}\;\left|x-scale\right| \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;0.25 \cdot \left(a \cdot \left(t\_0 \cdot \sqrt{8 \cdot \frac{{t\_1}^{2} - t\_4}{t\_0}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{\left(\left(2 \cdot t\_3\right) \cdot t\_2\right) \cdot \frac{{b}^{2} - \sqrt{{b}^{4}}}{t\_0}}}{t\_3}\\ \end{array} \]
(FPCore (a b angle x-scale y-scale)
 :precision binary64
 (let* ((t_0 (pow (fabs x-scale) 2.0))
        (t_1 (cos (* 0.005555555555555556 (* angle PI))))
        (t_2 (* (* b a) (* b (- a))))
        (t_3 (/ (* 4.0 t_2) (pow (* (fabs x-scale) y-scale) 2.0)))
        (t_4 (sqrt (pow t_1 4.0))))
   (if (<= (fabs x-scale) 1.55e-162)
     (*
      0.25
      (/
       (*
        a
        (*
         t_0
         (sqrt
          (*
           8.0
           (-
            (+ 0.5 (* 0.5 (cos (* 0.011111111111111112 (* angle PI)))))
            t_4)))))
       (fabs (fabs x-scale))))
     (if (<= (fabs x-scale) 1.35e+154)
       (* 0.25 (* a (* t_0 (sqrt (* 8.0 (/ (- (pow t_1 2.0) t_4) t_0))))))
       (/
        (-
         (sqrt
          (* (* (* 2.0 t_3) t_2) (/ (- (pow b 2.0) (sqrt (pow b 4.0))) t_0))))
        t_3)))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double t_0 = pow(fabs(x_45_scale), 2.0);
	double t_1 = cos((0.005555555555555556 * (angle * ((double) M_PI))));
	double t_2 = (b * a) * (b * -a);
	double t_3 = (4.0 * t_2) / pow((fabs(x_45_scale) * y_45_scale), 2.0);
	double t_4 = sqrt(pow(t_1, 4.0));
	double tmp;
	if (fabs(x_45_scale) <= 1.55e-162) {
		tmp = 0.25 * ((a * (t_0 * sqrt((8.0 * ((0.5 + (0.5 * cos((0.011111111111111112 * (angle * ((double) M_PI)))))) - t_4))))) / fabs(fabs(x_45_scale)));
	} else if (fabs(x_45_scale) <= 1.35e+154) {
		tmp = 0.25 * (a * (t_0 * sqrt((8.0 * ((pow(t_1, 2.0) - t_4) / t_0)))));
	} else {
		tmp = -sqrt((((2.0 * t_3) * t_2) * ((pow(b, 2.0) - sqrt(pow(b, 4.0))) / t_0))) / t_3;
	}
	return tmp;
}
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
	double t_0 = Math.pow(Math.abs(x_45_scale), 2.0);
	double t_1 = Math.cos((0.005555555555555556 * (angle * Math.PI)));
	double t_2 = (b * a) * (b * -a);
	double t_3 = (4.0 * t_2) / Math.pow((Math.abs(x_45_scale) * y_45_scale), 2.0);
	double t_4 = Math.sqrt(Math.pow(t_1, 4.0));
	double tmp;
	if (Math.abs(x_45_scale) <= 1.55e-162) {
		tmp = 0.25 * ((a * (t_0 * Math.sqrt((8.0 * ((0.5 + (0.5 * Math.cos((0.011111111111111112 * (angle * Math.PI))))) - t_4))))) / Math.abs(Math.abs(x_45_scale)));
	} else if (Math.abs(x_45_scale) <= 1.35e+154) {
		tmp = 0.25 * (a * (t_0 * Math.sqrt((8.0 * ((Math.pow(t_1, 2.0) - t_4) / t_0)))));
	} else {
		tmp = -Math.sqrt((((2.0 * t_3) * t_2) * ((Math.pow(b, 2.0) - Math.sqrt(Math.pow(b, 4.0))) / t_0))) / t_3;
	}
	return tmp;
}
def code(a, b, angle, x_45_scale, y_45_scale):
	t_0 = math.pow(math.fabs(x_45_scale), 2.0)
	t_1 = math.cos((0.005555555555555556 * (angle * math.pi)))
	t_2 = (b * a) * (b * -a)
	t_3 = (4.0 * t_2) / math.pow((math.fabs(x_45_scale) * y_45_scale), 2.0)
	t_4 = math.sqrt(math.pow(t_1, 4.0))
	tmp = 0
	if math.fabs(x_45_scale) <= 1.55e-162:
		tmp = 0.25 * ((a * (t_0 * math.sqrt((8.0 * ((0.5 + (0.5 * math.cos((0.011111111111111112 * (angle * math.pi))))) - t_4))))) / math.fabs(math.fabs(x_45_scale)))
	elif math.fabs(x_45_scale) <= 1.35e+154:
		tmp = 0.25 * (a * (t_0 * math.sqrt((8.0 * ((math.pow(t_1, 2.0) - t_4) / t_0)))))
	else:
		tmp = -math.sqrt((((2.0 * t_3) * t_2) * ((math.pow(b, 2.0) - math.sqrt(math.pow(b, 4.0))) / t_0))) / t_3
	return tmp
function code(a, b, angle, x_45_scale, y_45_scale)
	t_0 = abs(x_45_scale) ^ 2.0
	t_1 = cos(Float64(0.005555555555555556 * Float64(angle * pi)))
	t_2 = Float64(Float64(b * a) * Float64(b * Float64(-a)))
	t_3 = Float64(Float64(4.0 * t_2) / (Float64(abs(x_45_scale) * y_45_scale) ^ 2.0))
	t_4 = sqrt((t_1 ^ 4.0))
	tmp = 0.0
	if (abs(x_45_scale) <= 1.55e-162)
		tmp = Float64(0.25 * Float64(Float64(a * Float64(t_0 * sqrt(Float64(8.0 * Float64(Float64(0.5 + Float64(0.5 * cos(Float64(0.011111111111111112 * Float64(angle * pi))))) - t_4))))) / abs(abs(x_45_scale))));
	elseif (abs(x_45_scale) <= 1.35e+154)
		tmp = Float64(0.25 * Float64(a * Float64(t_0 * sqrt(Float64(8.0 * Float64(Float64((t_1 ^ 2.0) - t_4) / t_0))))));
	else
		tmp = Float64(Float64(-sqrt(Float64(Float64(Float64(2.0 * t_3) * t_2) * Float64(Float64((b ^ 2.0) - sqrt((b ^ 4.0))) / t_0)))) / t_3);
	end
	return tmp
end
function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale)
	t_0 = abs(x_45_scale) ^ 2.0;
	t_1 = cos((0.005555555555555556 * (angle * pi)));
	t_2 = (b * a) * (b * -a);
	t_3 = (4.0 * t_2) / ((abs(x_45_scale) * y_45_scale) ^ 2.0);
	t_4 = sqrt((t_1 ^ 4.0));
	tmp = 0.0;
	if (abs(x_45_scale) <= 1.55e-162)
		tmp = 0.25 * ((a * (t_0 * sqrt((8.0 * ((0.5 + (0.5 * cos((0.011111111111111112 * (angle * pi))))) - t_4))))) / abs(abs(x_45_scale)));
	elseif (abs(x_45_scale) <= 1.35e+154)
		tmp = 0.25 * (a * (t_0 * sqrt((8.0 * (((t_1 ^ 2.0) - t_4) / t_0)))));
	else
		tmp = -sqrt((((2.0 * t_3) * t_2) * (((b ^ 2.0) - sqrt((b ^ 4.0))) / t_0))) / t_3;
	end
	tmp_2 = tmp;
end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[Power[N[Abs[x$45$scale], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(b * a), $MachinePrecision] * N[(b * (-a)), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(4.0 * t$95$2), $MachinePrecision] / N[Power[N[(N[Abs[x$45$scale], $MachinePrecision] * y$45$scale), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[Power[t$95$1, 4.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Abs[x$45$scale], $MachinePrecision], 1.55e-162], N[(0.25 * N[(N[(a * N[(t$95$0 * N[Sqrt[N[(8.0 * N[(N[(0.5 + N[(0.5 * N[Cos[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Abs[N[Abs[x$45$scale], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[x$45$scale], $MachinePrecision], 1.35e+154], N[(0.25 * N[(a * N[(t$95$0 * N[Sqrt[N[(8.0 * N[(N[(N[Power[t$95$1, 2.0], $MachinePrecision] - t$95$4), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(N[(N[(2.0 * t$95$3), $MachinePrecision] * t$95$2), $MachinePrecision] * N[(N[(N[Power[b, 2.0], $MachinePrecision] - N[Sqrt[N[Power[b, 4.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$3), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := {\left(\left|x-scale\right|\right)}^{2}\\
t_1 := \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\\
t_2 := \left(b \cdot a\right) \cdot \left(b \cdot \left(-a\right)\right)\\
t_3 := \frac{4 \cdot t\_2}{{\left(\left|x-scale\right| \cdot y-scale\right)}^{2}}\\
t_4 := \sqrt{{t\_1}^{4}}\\
\mathbf{if}\;\left|x-scale\right| \leq 1.55 \cdot 10^{-162}:\\
\;\;\;\;0.25 \cdot \frac{a \cdot \left(t\_0 \cdot \sqrt{8 \cdot \left(\left(0.5 + 0.5 \cdot \cos \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right) - t\_4\right)}\right)}{\left|\left|x-scale\right|\right|}\\

\mathbf{elif}\;\left|x-scale\right| \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.25 \cdot \left(a \cdot \left(t\_0 \cdot \sqrt{8 \cdot \frac{{t\_1}^{2} - t\_4}{t\_0}}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{\left(\left(2 \cdot t\_3\right) \cdot t\_2\right) \cdot \frac{{b}^{2} - \sqrt{{b}^{4}}}{t\_0}}}{t\_3}\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x-scale < 1.5499999999999999e-162

    1. Initial program 0.1%

      \[\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. Taylor expanded in y-scale around 0

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

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

      \[\leadsto \frac{1}{4} \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{b}^{4} \cdot \left({\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}\right)}{{x-scale}^{2}}}\right)}{\color{blue}{{b}^{2}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

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

      \[\leadsto 0.25 \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{b}^{4} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} - \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}\right)}{{x-scale}^{2}}}\right)}{\color{blue}{{b}^{2}}} \]
    7. Applied rewrites17.3%

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

      \[\leadsto \frac{1}{4} \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)\right) - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}\right)}\right)}{\left|x-scale\right|} \]
    9. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{1}{4} \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)\right) - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}\right)}\right)}{\left|x-scale\right|} \]
    10. Applied rewrites21.7%

      \[\leadsto 0.25 \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \left(\left(0.5 + 0.5 \cdot \cos \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right) - \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}\right)}\right)}{\left|x-scale\right|} \]

    if 1.5499999999999999e-162 < x-scale < 1.35000000000000003e154

    1. Initial program 0.1%

      \[\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. Taylor expanded in y-scale around 0

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

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

      \[\leadsto \frac{1}{4} \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{b}^{4} \cdot \left({\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}\right)}{{x-scale}^{2}}}\right)}{\color{blue}{{b}^{2}}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

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

      \[\leadsto 0.25 \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{b}^{4} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} - \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}\right)}{{x-scale}^{2}}}\right)}{\color{blue}{{b}^{2}}} \]
    7. Taylor expanded in b around 0

      \[\leadsto \frac{1}{4} \cdot \left(a \cdot \left({x-scale}^{2} \cdot \color{blue}{\sqrt{8 \cdot \frac{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}}{{x-scale}^{2}}}}\right)\right) \]
    8. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{4} \cdot \left(a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}}{{x-scale}^{2}}}\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto \frac{1}{4} \cdot \left(a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}}{{x-scale}^{2}}}\right)\right) \]
      3. lower-pow.f64N/A

        \[\leadsto \frac{1}{4} \cdot \left(a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}}{{x-scale}^{2}}}\right)\right) \]
      4. lower-sqrt.f64N/A

        \[\leadsto \frac{1}{4} \cdot \left(a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}}{{x-scale}^{2}}}\right)\right) \]
    9. Applied rewrites13.1%

      \[\leadsto 0.25 \cdot \left(a \cdot \left({x-scale}^{2} \cdot \color{blue}{\sqrt{8 \cdot \frac{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} - \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}}{{x-scale}^{2}}}}\right)\right) \]

    if 1.35000000000000003e154 < x-scale

    1. Initial program 0.1%

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

      \[\leadsto \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 \color{blue}{\left(\left(\frac{{a}^{2}}{{y-scale}^{2}} + \frac{{b}^{2}}{{x-scale}^{2}}\right) - \sqrt{{\left(\frac{{b}^{2}}{{x-scale}^{2}} - \frac{{a}^{2}}{{y-scale}^{2}}\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}}} \]
    3. Step-by-step derivation
      1. Applied rewrites0.2%

        \[\leadsto \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 \color{blue}{\left(\left(\frac{{a}^{2}}{{y-scale}^{2}} + \frac{{b}^{2}}{{x-scale}^{2}}\right) - \sqrt{{\left(\frac{{b}^{2}}{{x-scale}^{2}} - \frac{{a}^{2}}{{y-scale}^{2}}\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. Taylor expanded in x-scale around 0

        \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{\color{blue}{{x-scale}^{2}}}}}{\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}}} \]
      3. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{{x-scale}^{\color{blue}{2}}}}}{\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. lower--.f64N/A

          \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{{x-scale}^{2}}}}{\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}}} \]
        3. lower-pow.f64N/A

          \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{{x-scale}^{2}}}}{\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}}} \]
        4. lower-sqrt.f64N/A

          \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{{x-scale}^{2}}}}{\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}}} \]
        5. lower-pow.f64N/A

          \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{{x-scale}^{2}}}}{\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}}} \]
        6. lower-pow.f642.2

          \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{{x-scale}^{2}}}}{\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}}} \]
      4. Applied rewrites2.2%

        \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{\color{blue}{{x-scale}^{2}}}}}{\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}}} \]
    4. Recombined 3 regimes into one program.
    5. Add Preprocessing

    Alternative 2: 24.0% accurate, 4.6× speedup?

    \[\begin{array}{l} t_0 := {\left(\left|x-scale\right|\right)}^{2}\\ t_1 := \left(b \cdot \left|a\right|\right) \cdot \left(b \cdot \left(-\left|a\right|\right)\right)\\ t_2 := \frac{4 \cdot t\_1}{{\left(\left|x-scale\right| \cdot y-scale\right)}^{2}}\\ \mathbf{if}\;\left|x-scale\right| \leq 6.4 \cdot 10^{+161}:\\ \;\;\;\;0.25 \cdot \frac{\left|a\right| \cdot \left(t\_0 \cdot \sqrt{8 \cdot \left(\left(0.5 + 0.5 \cdot \cos \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right) - \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}\right)}\right)}{\left|\left|x-scale\right|\right|}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{\left(\left(2 \cdot t\_2\right) \cdot t\_1\right) \cdot \frac{{b}^{2} - \sqrt{{b}^{4}}}{t\_0}}}{t\_2}\\ \end{array} \]
    (FPCore (a b angle x-scale y-scale)
     :precision binary64
     (let* ((t_0 (pow (fabs x-scale) 2.0))
            (t_1 (* (* b (fabs a)) (* b (- (fabs a)))))
            (t_2 (/ (* 4.0 t_1) (pow (* (fabs x-scale) y-scale) 2.0))))
       (if (<= (fabs x-scale) 6.4e+161)
         (*
          0.25
          (/
           (*
            (fabs a)
            (*
             t_0
             (sqrt
              (*
               8.0
               (-
                (+ 0.5 (* 0.5 (cos (* 0.011111111111111112 (* angle PI)))))
                (sqrt (pow (cos (* 0.005555555555555556 (* angle PI))) 4.0)))))))
           (fabs (fabs x-scale))))
         (/
          (-
           (sqrt
            (* (* (* 2.0 t_2) t_1) (/ (- (pow b 2.0) (sqrt (pow b 4.0))) t_0))))
          t_2))))
    double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
    	double t_0 = pow(fabs(x_45_scale), 2.0);
    	double t_1 = (b * fabs(a)) * (b * -fabs(a));
    	double t_2 = (4.0 * t_1) / pow((fabs(x_45_scale) * y_45_scale), 2.0);
    	double tmp;
    	if (fabs(x_45_scale) <= 6.4e+161) {
    		tmp = 0.25 * ((fabs(a) * (t_0 * sqrt((8.0 * ((0.5 + (0.5 * cos((0.011111111111111112 * (angle * ((double) M_PI)))))) - sqrt(pow(cos((0.005555555555555556 * (angle * ((double) M_PI)))), 4.0))))))) / fabs(fabs(x_45_scale)));
    	} else {
    		tmp = -sqrt((((2.0 * t_2) * t_1) * ((pow(b, 2.0) - sqrt(pow(b, 4.0))) / t_0))) / t_2;
    	}
    	return tmp;
    }
    
    public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
    	double t_0 = Math.pow(Math.abs(x_45_scale), 2.0);
    	double t_1 = (b * Math.abs(a)) * (b * -Math.abs(a));
    	double t_2 = (4.0 * t_1) / Math.pow((Math.abs(x_45_scale) * y_45_scale), 2.0);
    	double tmp;
    	if (Math.abs(x_45_scale) <= 6.4e+161) {
    		tmp = 0.25 * ((Math.abs(a) * (t_0 * Math.sqrt((8.0 * ((0.5 + (0.5 * Math.cos((0.011111111111111112 * (angle * Math.PI))))) - Math.sqrt(Math.pow(Math.cos((0.005555555555555556 * (angle * Math.PI))), 4.0))))))) / Math.abs(Math.abs(x_45_scale)));
    	} else {
    		tmp = -Math.sqrt((((2.0 * t_2) * t_1) * ((Math.pow(b, 2.0) - Math.sqrt(Math.pow(b, 4.0))) / t_0))) / t_2;
    	}
    	return tmp;
    }
    
    def code(a, b, angle, x_45_scale, y_45_scale):
    	t_0 = math.pow(math.fabs(x_45_scale), 2.0)
    	t_1 = (b * math.fabs(a)) * (b * -math.fabs(a))
    	t_2 = (4.0 * t_1) / math.pow((math.fabs(x_45_scale) * y_45_scale), 2.0)
    	tmp = 0
    	if math.fabs(x_45_scale) <= 6.4e+161:
    		tmp = 0.25 * ((math.fabs(a) * (t_0 * math.sqrt((8.0 * ((0.5 + (0.5 * math.cos((0.011111111111111112 * (angle * math.pi))))) - math.sqrt(math.pow(math.cos((0.005555555555555556 * (angle * math.pi))), 4.0))))))) / math.fabs(math.fabs(x_45_scale)))
    	else:
    		tmp = -math.sqrt((((2.0 * t_2) * t_1) * ((math.pow(b, 2.0) - math.sqrt(math.pow(b, 4.0))) / t_0))) / t_2
    	return tmp
    
    function code(a, b, angle, x_45_scale, y_45_scale)
    	t_0 = abs(x_45_scale) ^ 2.0
    	t_1 = Float64(Float64(b * abs(a)) * Float64(b * Float64(-abs(a))))
    	t_2 = Float64(Float64(4.0 * t_1) / (Float64(abs(x_45_scale) * y_45_scale) ^ 2.0))
    	tmp = 0.0
    	if (abs(x_45_scale) <= 6.4e+161)
    		tmp = Float64(0.25 * Float64(Float64(abs(a) * Float64(t_0 * sqrt(Float64(8.0 * Float64(Float64(0.5 + Float64(0.5 * cos(Float64(0.011111111111111112 * Float64(angle * pi))))) - sqrt((cos(Float64(0.005555555555555556 * Float64(angle * pi))) ^ 4.0))))))) / abs(abs(x_45_scale))));
    	else
    		tmp = Float64(Float64(-sqrt(Float64(Float64(Float64(2.0 * t_2) * t_1) * Float64(Float64((b ^ 2.0) - sqrt((b ^ 4.0))) / t_0)))) / t_2);
    	end
    	return tmp
    end
    
    function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale)
    	t_0 = abs(x_45_scale) ^ 2.0;
    	t_1 = (b * abs(a)) * (b * -abs(a));
    	t_2 = (4.0 * t_1) / ((abs(x_45_scale) * y_45_scale) ^ 2.0);
    	tmp = 0.0;
    	if (abs(x_45_scale) <= 6.4e+161)
    		tmp = 0.25 * ((abs(a) * (t_0 * sqrt((8.0 * ((0.5 + (0.5 * cos((0.011111111111111112 * (angle * pi))))) - sqrt((cos((0.005555555555555556 * (angle * pi))) ^ 4.0))))))) / abs(abs(x_45_scale)));
    	else
    		tmp = -sqrt((((2.0 * t_2) * t_1) * (((b ^ 2.0) - sqrt((b ^ 4.0))) / t_0))) / t_2;
    	end
    	tmp_2 = tmp;
    end
    
    code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[Power[N[Abs[x$45$scale], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[(b * N[Abs[a], $MachinePrecision]), $MachinePrecision] * N[(b * (-N[Abs[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(4.0 * t$95$1), $MachinePrecision] / N[Power[N[(N[Abs[x$45$scale], $MachinePrecision] * y$45$scale), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x$45$scale], $MachinePrecision], 6.4e+161], N[(0.25 * N[(N[(N[Abs[a], $MachinePrecision] * N[(t$95$0 * N[Sqrt[N[(8.0 * N[(N[(0.5 + N[(0.5 * N[Cos[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Sqrt[N[Power[N[Cos[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 4.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Abs[N[Abs[x$45$scale], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(N[(N[(2.0 * t$95$2), $MachinePrecision] * t$95$1), $MachinePrecision] * N[(N[(N[Power[b, 2.0], $MachinePrecision] - N[Sqrt[N[Power[b, 4.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision]]]]]
    
    \begin{array}{l}
    t_0 := {\left(\left|x-scale\right|\right)}^{2}\\
    t_1 := \left(b \cdot \left|a\right|\right) \cdot \left(b \cdot \left(-\left|a\right|\right)\right)\\
    t_2 := \frac{4 \cdot t\_1}{{\left(\left|x-scale\right| \cdot y-scale\right)}^{2}}\\
    \mathbf{if}\;\left|x-scale\right| \leq 6.4 \cdot 10^{+161}:\\
    \;\;\;\;0.25 \cdot \frac{\left|a\right| \cdot \left(t\_0 \cdot \sqrt{8 \cdot \left(\left(0.5 + 0.5 \cdot \cos \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right) - \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}\right)}\right)}{\left|\left|x-scale\right|\right|}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{-\sqrt{\left(\left(2 \cdot t\_2\right) \cdot t\_1\right) \cdot \frac{{b}^{2} - \sqrt{{b}^{4}}}{t\_0}}}{t\_2}\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x-scale < 6.40000000000000004e161

      1. Initial program 0.1%

        \[\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. Taylor expanded in y-scale around 0

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

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

        \[\leadsto \frac{1}{4} \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{b}^{4} \cdot \left({\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}\right)}{{x-scale}^{2}}}\right)}{\color{blue}{{b}^{2}}} \]
      5. Step-by-step derivation
        1. lower-/.f64N/A

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

        \[\leadsto 0.25 \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{b}^{4} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} - \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}\right)}{{x-scale}^{2}}}\right)}{\color{blue}{{b}^{2}}} \]
      7. Applied rewrites17.3%

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

        \[\leadsto \frac{1}{4} \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)\right) - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}\right)}\right)}{\left|x-scale\right|} \]
      9. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{1}{4} \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)\right) - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}\right)}\right)}{\left|x-scale\right|} \]
      10. Applied rewrites21.7%

        \[\leadsto 0.25 \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \left(\left(0.5 + 0.5 \cdot \cos \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right) - \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}\right)}\right)}{\left|x-scale\right|} \]

      if 6.40000000000000004e161 < x-scale

      1. Initial program 0.1%

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

        \[\leadsto \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 \color{blue}{\left(\left(\frac{{a}^{2}}{{y-scale}^{2}} + \frac{{b}^{2}}{{x-scale}^{2}}\right) - \sqrt{{\left(\frac{{b}^{2}}{{x-scale}^{2}} - \frac{{a}^{2}}{{y-scale}^{2}}\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}}} \]
      3. Step-by-step derivation
        1. Applied rewrites0.2%

          \[\leadsto \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 \color{blue}{\left(\left(\frac{{a}^{2}}{{y-scale}^{2}} + \frac{{b}^{2}}{{x-scale}^{2}}\right) - \sqrt{{\left(\frac{{b}^{2}}{{x-scale}^{2}} - \frac{{a}^{2}}{{y-scale}^{2}}\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. Taylor expanded in x-scale around 0

          \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{\color{blue}{{x-scale}^{2}}}}}{\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}}} \]
        3. Step-by-step derivation
          1. lower-/.f64N/A

            \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{{x-scale}^{\color{blue}{2}}}}}{\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. lower--.f64N/A

            \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{{x-scale}^{2}}}}{\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}}} \]
          3. lower-pow.f64N/A

            \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{{x-scale}^{2}}}}{\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}}} \]
          4. lower-sqrt.f64N/A

            \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{{x-scale}^{2}}}}{\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}}} \]
          5. lower-pow.f64N/A

            \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{{x-scale}^{2}}}}{\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}}} \]
          6. lower-pow.f642.2

            \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{{x-scale}^{2}}}}{\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}}} \]
        4. Applied rewrites2.2%

          \[\leadsto \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 \frac{{b}^{2} - \sqrt{{b}^{4}}}{\color{blue}{{x-scale}^{2}}}}}{\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}}} \]
      4. Recombined 2 regimes into one program.
      5. Add Preprocessing

      Alternative 3: 23.7% accurate, 5.2× speedup?

      \[\begin{array}{l} t_0 := \left|a\right| \cdot b\\ t_1 := \left|\left|x-scale\right|\right|\\ \mathbf{if}\;\left|x-scale\right| \leq 7.6 \cdot 10^{+152}:\\ \;\;\;\;0.25 \cdot \frac{\left|a\right| \cdot \left({\left(\left|x-scale\right|\right)}^{2} \cdot \sqrt{8 \cdot \left(\left(0.5 + 0.5 \cdot \cos \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right) - \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}\right)}\right)}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\frac{\sqrt{\left(\left(\left|a\right| \cdot \left|a\right| - \sqrt{{\left(\left|a\right|\right)}^{4}}\right) \cdot {t\_0}^{4}\right) \cdot 8}}{t\_1} \cdot \left|x-scale\right|\right) \cdot \left|x-scale\right|}{t\_0} \cdot \frac{0.25}{t\_0}\\ \end{array} \]
      (FPCore (a b angle x-scale y-scale)
       :precision binary64
       (let* ((t_0 (* (fabs a) b)) (t_1 (fabs (fabs x-scale))))
         (if (<= (fabs x-scale) 7.6e+152)
           (*
            0.25
            (/
             (*
              (fabs a)
              (*
               (pow (fabs x-scale) 2.0)
               (sqrt
                (*
                 8.0
                 (-
                  (+ 0.5 (* 0.5 (cos (* 0.011111111111111112 (* angle PI)))))
                  (sqrt (pow (cos (* 0.005555555555555556 (* angle PI))) 4.0)))))))
             t_1))
           (*
            (/
             (*
              (*
               (/
                (sqrt
                 (*
                  (*
                   (- (* (fabs a) (fabs a)) (sqrt (pow (fabs a) 4.0)))
                   (pow t_0 4.0))
                  8.0))
                t_1)
               (fabs x-scale))
              (fabs x-scale))
             t_0)
            (/ 0.25 t_0)))))
      double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
      	double t_0 = fabs(a) * b;
      	double t_1 = fabs(fabs(x_45_scale));
      	double tmp;
      	if (fabs(x_45_scale) <= 7.6e+152) {
      		tmp = 0.25 * ((fabs(a) * (pow(fabs(x_45_scale), 2.0) * sqrt((8.0 * ((0.5 + (0.5 * cos((0.011111111111111112 * (angle * ((double) M_PI)))))) - sqrt(pow(cos((0.005555555555555556 * (angle * ((double) M_PI)))), 4.0))))))) / t_1);
      	} else {
      		tmp = ((((sqrt(((((fabs(a) * fabs(a)) - sqrt(pow(fabs(a), 4.0))) * pow(t_0, 4.0)) * 8.0)) / t_1) * fabs(x_45_scale)) * fabs(x_45_scale)) / t_0) * (0.25 / t_0);
      	}
      	return tmp;
      }
      
      public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
      	double t_0 = Math.abs(a) * b;
      	double t_1 = Math.abs(Math.abs(x_45_scale));
      	double tmp;
      	if (Math.abs(x_45_scale) <= 7.6e+152) {
      		tmp = 0.25 * ((Math.abs(a) * (Math.pow(Math.abs(x_45_scale), 2.0) * Math.sqrt((8.0 * ((0.5 + (0.5 * Math.cos((0.011111111111111112 * (angle * Math.PI))))) - Math.sqrt(Math.pow(Math.cos((0.005555555555555556 * (angle * Math.PI))), 4.0))))))) / t_1);
      	} else {
      		tmp = ((((Math.sqrt(((((Math.abs(a) * Math.abs(a)) - Math.sqrt(Math.pow(Math.abs(a), 4.0))) * Math.pow(t_0, 4.0)) * 8.0)) / t_1) * Math.abs(x_45_scale)) * Math.abs(x_45_scale)) / t_0) * (0.25 / t_0);
      	}
      	return tmp;
      }
      
      def code(a, b, angle, x_45_scale, y_45_scale):
      	t_0 = math.fabs(a) * b
      	t_1 = math.fabs(math.fabs(x_45_scale))
      	tmp = 0
      	if math.fabs(x_45_scale) <= 7.6e+152:
      		tmp = 0.25 * ((math.fabs(a) * (math.pow(math.fabs(x_45_scale), 2.0) * math.sqrt((8.0 * ((0.5 + (0.5 * math.cos((0.011111111111111112 * (angle * math.pi))))) - math.sqrt(math.pow(math.cos((0.005555555555555556 * (angle * math.pi))), 4.0))))))) / t_1)
      	else:
      		tmp = ((((math.sqrt(((((math.fabs(a) * math.fabs(a)) - math.sqrt(math.pow(math.fabs(a), 4.0))) * math.pow(t_0, 4.0)) * 8.0)) / t_1) * math.fabs(x_45_scale)) * math.fabs(x_45_scale)) / t_0) * (0.25 / t_0)
      	return tmp
      
      function code(a, b, angle, x_45_scale, y_45_scale)
      	t_0 = Float64(abs(a) * b)
      	t_1 = abs(abs(x_45_scale))
      	tmp = 0.0
      	if (abs(x_45_scale) <= 7.6e+152)
      		tmp = Float64(0.25 * Float64(Float64(abs(a) * Float64((abs(x_45_scale) ^ 2.0) * sqrt(Float64(8.0 * Float64(Float64(0.5 + Float64(0.5 * cos(Float64(0.011111111111111112 * Float64(angle * pi))))) - sqrt((cos(Float64(0.005555555555555556 * Float64(angle * pi))) ^ 4.0))))))) / t_1));
      	else
      		tmp = Float64(Float64(Float64(Float64(Float64(sqrt(Float64(Float64(Float64(Float64(abs(a) * abs(a)) - sqrt((abs(a) ^ 4.0))) * (t_0 ^ 4.0)) * 8.0)) / t_1) * abs(x_45_scale)) * abs(x_45_scale)) / t_0) * Float64(0.25 / t_0));
      	end
      	return tmp
      end
      
      function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale)
      	t_0 = abs(a) * b;
      	t_1 = abs(abs(x_45_scale));
      	tmp = 0.0;
      	if (abs(x_45_scale) <= 7.6e+152)
      		tmp = 0.25 * ((abs(a) * ((abs(x_45_scale) ^ 2.0) * sqrt((8.0 * ((0.5 + (0.5 * cos((0.011111111111111112 * (angle * pi))))) - sqrt((cos((0.005555555555555556 * (angle * pi))) ^ 4.0))))))) / t_1);
      	else
      		tmp = ((((sqrt(((((abs(a) * abs(a)) - sqrt((abs(a) ^ 4.0))) * (t_0 ^ 4.0)) * 8.0)) / t_1) * abs(x_45_scale)) * abs(x_45_scale)) / t_0) * (0.25 / t_0);
      	end
      	tmp_2 = tmp;
      end
      
      code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[Abs[a], $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[Abs[x$45$scale], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Abs[x$45$scale], $MachinePrecision], 7.6e+152], N[(0.25 * N[(N[(N[Abs[a], $MachinePrecision] * N[(N[Power[N[Abs[x$45$scale], $MachinePrecision], 2.0], $MachinePrecision] * N[Sqrt[N[(8.0 * N[(N[(0.5 + N[(0.5 * N[Cos[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Sqrt[N[Power[N[Cos[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 4.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[Sqrt[N[(N[(N[(N[(N[Abs[a], $MachinePrecision] * N[Abs[a], $MachinePrecision]), $MachinePrecision] - N[Sqrt[N[Power[N[Abs[a], $MachinePrecision], 4.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[t$95$0, 4.0], $MachinePrecision]), $MachinePrecision] * 8.0), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision] * N[Abs[x$45$scale], $MachinePrecision]), $MachinePrecision] * N[Abs[x$45$scale], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(0.25 / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
      
      \begin{array}{l}
      t_0 := \left|a\right| \cdot b\\
      t_1 := \left|\left|x-scale\right|\right|\\
      \mathbf{if}\;\left|x-scale\right| \leq 7.6 \cdot 10^{+152}:\\
      \;\;\;\;0.25 \cdot \frac{\left|a\right| \cdot \left({\left(\left|x-scale\right|\right)}^{2} \cdot \sqrt{8 \cdot \left(\left(0.5 + 0.5 \cdot \cos \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right) - \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}\right)}\right)}{t\_1}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\left(\frac{\sqrt{\left(\left(\left|a\right| \cdot \left|a\right| - \sqrt{{\left(\left|a\right|\right)}^{4}}\right) \cdot {t\_0}^{4}\right) \cdot 8}}{t\_1} \cdot \left|x-scale\right|\right) \cdot \left|x-scale\right|}{t\_0} \cdot \frac{0.25}{t\_0}\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x-scale < 7.6000000000000001e152

        1. Initial program 0.1%

          \[\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. Taylor expanded in y-scale around 0

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

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

          \[\leadsto \frac{1}{4} \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{b}^{4} \cdot \left({\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}\right)}{{x-scale}^{2}}}\right)}{\color{blue}{{b}^{2}}} \]
        5. Step-by-step derivation
          1. lower-/.f64N/A

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

          \[\leadsto 0.25 \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{b}^{4} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} - \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}\right)}{{x-scale}^{2}}}\right)}{\color{blue}{{b}^{2}}} \]
        7. Applied rewrites17.3%

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

          \[\leadsto \frac{1}{4} \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)\right) - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}\right)}\right)}{\left|x-scale\right|} \]
        9. Step-by-step derivation
          1. lower-/.f64N/A

            \[\leadsto \frac{1}{4} \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \left(\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)\right) - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}\right)}\right)}{\left|x-scale\right|} \]
        10. Applied rewrites21.7%

          \[\leadsto 0.25 \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \left(\left(0.5 + 0.5 \cdot \cos \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right) - \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}\right)}\right)}{\left|x-scale\right|} \]

        if 7.6000000000000001e152 < x-scale

        1. Initial program 0.1%

          \[\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. Taylor expanded in y-scale around 0

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

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

          \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
        5. Step-by-step derivation
          1. lower--.f64N/A

            \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          2. lower-pow.f64N/A

            \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          3. lower-sqrt.f64N/A

            \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          4. lower-pow.f640.7

            \[\leadsto 0.25 \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
        6. Applied rewrites0.7%

          \[\leadsto 0.25 \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
        7. Applied rewrites2.5%

          \[\leadsto \frac{0.25 \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot \left(a \cdot a - \sqrt{{a}^{4}}\right)\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot b\right)}} \]
        8. Step-by-step derivation
          1. lift-/.f64N/A

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

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

      Alternative 4: 22.6% accurate, 6.6× speedup?

      \[\begin{array}{l} t_0 := \left|a\right| \cdot \left|b\right|\\ \mathbf{if}\;\left|b\right| \leq 5.8 \cdot 10^{-18}:\\ \;\;\;\;0.25 \cdot \left(\frac{\left|a\right| \cdot \left(x-scale \cdot x-scale\right)}{\left|b\right|} \cdot \frac{\frac{\sqrt{8 \cdot \left(\left(1 - \sqrt{{\cos \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)}^{4}}\right) \cdot {\left(\left|b\right|\right)}^{4}\right)}}{\left|x-scale\right|}}{\left|b\right|}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\frac{\sqrt{\left(\left(\left|a\right| \cdot \left|a\right| - \sqrt{{\left(\left|a\right|\right)}^{4}}\right) \cdot {t\_0}^{4}\right) \cdot 8}}{\left|x-scale\right|} \cdot x-scale\right) \cdot x-scale}{t\_0} \cdot \frac{0.25}{t\_0}\\ \end{array} \]
      (FPCore (a b angle x-scale y-scale)
       :precision binary64
       (let* ((t_0 (* (fabs a) (fabs b))))
         (if (<= (fabs b) 5.8e-18)
           (*
            0.25
            (*
             (/ (* (fabs a) (* x-scale x-scale)) (fabs b))
             (/
              (/
               (sqrt
                (*
                 8.0
                 (*
                  (-
                   1.0
                   (sqrt (pow (cos (* (* PI angle) 0.005555555555555556)) 4.0)))
                  (pow (fabs b) 4.0))))
               (fabs x-scale))
              (fabs b))))
           (*
            (/
             (*
              (*
               (/
                (sqrt
                 (*
                  (*
                   (- (* (fabs a) (fabs a)) (sqrt (pow (fabs a) 4.0)))
                   (pow t_0 4.0))
                  8.0))
                (fabs x-scale))
               x-scale)
              x-scale)
             t_0)
            (/ 0.25 t_0)))))
      double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
      	double t_0 = fabs(a) * fabs(b);
      	double tmp;
      	if (fabs(b) <= 5.8e-18) {
      		tmp = 0.25 * (((fabs(a) * (x_45_scale * x_45_scale)) / fabs(b)) * ((sqrt((8.0 * ((1.0 - sqrt(pow(cos(((((double) M_PI) * angle) * 0.005555555555555556)), 4.0))) * pow(fabs(b), 4.0)))) / fabs(x_45_scale)) / fabs(b)));
      	} else {
      		tmp = ((((sqrt(((((fabs(a) * fabs(a)) - sqrt(pow(fabs(a), 4.0))) * pow(t_0, 4.0)) * 8.0)) / fabs(x_45_scale)) * x_45_scale) * x_45_scale) / t_0) * (0.25 / t_0);
      	}
      	return tmp;
      }
      
      public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
      	double t_0 = Math.abs(a) * Math.abs(b);
      	double tmp;
      	if (Math.abs(b) <= 5.8e-18) {
      		tmp = 0.25 * (((Math.abs(a) * (x_45_scale * x_45_scale)) / Math.abs(b)) * ((Math.sqrt((8.0 * ((1.0 - Math.sqrt(Math.pow(Math.cos(((Math.PI * angle) * 0.005555555555555556)), 4.0))) * Math.pow(Math.abs(b), 4.0)))) / Math.abs(x_45_scale)) / Math.abs(b)));
      	} else {
      		tmp = ((((Math.sqrt(((((Math.abs(a) * Math.abs(a)) - Math.sqrt(Math.pow(Math.abs(a), 4.0))) * Math.pow(t_0, 4.0)) * 8.0)) / Math.abs(x_45_scale)) * x_45_scale) * x_45_scale) / t_0) * (0.25 / t_0);
      	}
      	return tmp;
      }
      
      def code(a, b, angle, x_45_scale, y_45_scale):
      	t_0 = math.fabs(a) * math.fabs(b)
      	tmp = 0
      	if math.fabs(b) <= 5.8e-18:
      		tmp = 0.25 * (((math.fabs(a) * (x_45_scale * x_45_scale)) / math.fabs(b)) * ((math.sqrt((8.0 * ((1.0 - math.sqrt(math.pow(math.cos(((math.pi * angle) * 0.005555555555555556)), 4.0))) * math.pow(math.fabs(b), 4.0)))) / math.fabs(x_45_scale)) / math.fabs(b)))
      	else:
      		tmp = ((((math.sqrt(((((math.fabs(a) * math.fabs(a)) - math.sqrt(math.pow(math.fabs(a), 4.0))) * math.pow(t_0, 4.0)) * 8.0)) / math.fabs(x_45_scale)) * x_45_scale) * x_45_scale) / t_0) * (0.25 / t_0)
      	return tmp
      
      function code(a, b, angle, x_45_scale, y_45_scale)
      	t_0 = Float64(abs(a) * abs(b))
      	tmp = 0.0
      	if (abs(b) <= 5.8e-18)
      		tmp = Float64(0.25 * Float64(Float64(Float64(abs(a) * Float64(x_45_scale * x_45_scale)) / abs(b)) * Float64(Float64(sqrt(Float64(8.0 * Float64(Float64(1.0 - sqrt((cos(Float64(Float64(pi * angle) * 0.005555555555555556)) ^ 4.0))) * (abs(b) ^ 4.0)))) / abs(x_45_scale)) / abs(b))));
      	else
      		tmp = Float64(Float64(Float64(Float64(Float64(sqrt(Float64(Float64(Float64(Float64(abs(a) * abs(a)) - sqrt((abs(a) ^ 4.0))) * (t_0 ^ 4.0)) * 8.0)) / abs(x_45_scale)) * x_45_scale) * x_45_scale) / t_0) * Float64(0.25 / t_0));
      	end
      	return tmp
      end
      
      function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale)
      	t_0 = abs(a) * abs(b);
      	tmp = 0.0;
      	if (abs(b) <= 5.8e-18)
      		tmp = 0.25 * (((abs(a) * (x_45_scale * x_45_scale)) / abs(b)) * ((sqrt((8.0 * ((1.0 - sqrt((cos(((pi * angle) * 0.005555555555555556)) ^ 4.0))) * (abs(b) ^ 4.0)))) / abs(x_45_scale)) / abs(b)));
      	else
      		tmp = ((((sqrt(((((abs(a) * abs(a)) - sqrt((abs(a) ^ 4.0))) * (t_0 ^ 4.0)) * 8.0)) / abs(x_45_scale)) * x_45_scale) * x_45_scale) / t_0) * (0.25 / t_0);
      	end
      	tmp_2 = tmp;
      end
      
      code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[Abs[a], $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[b], $MachinePrecision], 5.8e-18], N[(0.25 * N[(N[(N[(N[Abs[a], $MachinePrecision] * N[(x$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision] / N[Abs[b], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sqrt[N[(8.0 * N[(N[(1.0 - N[Sqrt[N[Power[N[Cos[N[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision], 4.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[N[Abs[b], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[x$45$scale], $MachinePrecision]), $MachinePrecision] / N[Abs[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[Sqrt[N[(N[(N[(N[(N[Abs[a], $MachinePrecision] * N[Abs[a], $MachinePrecision]), $MachinePrecision] - N[Sqrt[N[Power[N[Abs[a], $MachinePrecision], 4.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[t$95$0, 4.0], $MachinePrecision]), $MachinePrecision] * 8.0), $MachinePrecision]], $MachinePrecision] / N[Abs[x$45$scale], $MachinePrecision]), $MachinePrecision] * x$45$scale), $MachinePrecision] * x$45$scale), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(0.25 / t$95$0), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      t_0 := \left|a\right| \cdot \left|b\right|\\
      \mathbf{if}\;\left|b\right| \leq 5.8 \cdot 10^{-18}:\\
      \;\;\;\;0.25 \cdot \left(\frac{\left|a\right| \cdot \left(x-scale \cdot x-scale\right)}{\left|b\right|} \cdot \frac{\frac{\sqrt{8 \cdot \left(\left(1 - \sqrt{{\cos \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)}^{4}}\right) \cdot {\left(\left|b\right|\right)}^{4}\right)}}{\left|x-scale\right|}}{\left|b\right|}\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\left(\frac{\sqrt{\left(\left(\left|a\right| \cdot \left|a\right| - \sqrt{{\left(\left|a\right|\right)}^{4}}\right) \cdot {t\_0}^{4}\right) \cdot 8}}{\left|x-scale\right|} \cdot x-scale\right) \cdot x-scale}{t\_0} \cdot \frac{0.25}{t\_0}\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if b < 5.8e-18

        1. Initial program 0.1%

          \[\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. Taylor expanded in y-scale around 0

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

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

          \[\leadsto \frac{1}{4} \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{b}^{4} \cdot \left({\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}\right)}{{x-scale}^{2}}}\right)}{\color{blue}{{b}^{2}}} \]
        5. Step-by-step derivation
          1. lower-/.f64N/A

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

          \[\leadsto 0.25 \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{b}^{4} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} - \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}\right)}{{x-scale}^{2}}}\right)}{\color{blue}{{b}^{2}}} \]
        7. Applied rewrites17.3%

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

          \[\leadsto \frac{1}{4} \cdot \left(\frac{a \cdot \left(x-scale \cdot x-scale\right)}{b} \cdot \frac{\frac{\sqrt{8 \cdot \left(\left(1 - \sqrt{{\cos \left(\left(\pi \cdot angle\right) \cdot \frac{1}{180}\right)}^{4}}\right) \cdot {b}^{4}\right)}}{\left|x-scale\right|}}{b}\right) \]
        9. Step-by-step derivation
          1. Applied rewrites17.8%

            \[\leadsto 0.25 \cdot \left(\frac{a \cdot \left(x-scale \cdot x-scale\right)}{b} \cdot \frac{\frac{\sqrt{8 \cdot \left(\left(1 - \sqrt{{\cos \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)}^{4}}\right) \cdot {b}^{4}\right)}}{\left|x-scale\right|}}{b}\right) \]

          if 5.8e-18 < b

          1. Initial program 0.1%

            \[\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. Taylor expanded in y-scale around 0

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

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

            \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          5. Step-by-step derivation
            1. lower--.f64N/A

              \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
            2. lower-pow.f64N/A

              \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
            3. lower-sqrt.f64N/A

              \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
            4. lower-pow.f640.7

              \[\leadsto 0.25 \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          6. Applied rewrites0.7%

            \[\leadsto 0.25 \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          7. Applied rewrites2.5%

            \[\leadsto \frac{0.25 \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot \left(a \cdot a - \sqrt{{a}^{4}}\right)\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot b\right)}} \]
          8. Step-by-step derivation
            1. lift-/.f64N/A

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

            \[\leadsto \frac{\left(\frac{\sqrt{\left(\left(a \cdot a - \sqrt{{a}^{4}}\right) \cdot {\left(a \cdot b\right)}^{4}\right) \cdot 8}}{\left|x-scale\right|} \cdot x-scale\right) \cdot x-scale}{a \cdot b} \cdot \color{blue}{\frac{0.25}{a \cdot b}} \]
        10. Recombined 2 regimes into one program.
        11. Add Preprocessing

        Alternative 5: 17.5% accurate, 6.3× speedup?

        \[\begin{array}{l} t_0 := \left|a\right| \cdot \left|b\right|\\ t_1 := \frac{\left(\frac{\sqrt{\left(\left(\left|a\right| \cdot \left|a\right| - \sqrt{{\left(\left|a\right|\right)}^{4}}\right) \cdot {t\_0}^{4}\right) \cdot 8}}{\left|x-scale\right|} \cdot x-scale\right) \cdot x-scale}{t\_0} \cdot \frac{0.25}{t\_0}\\ \mathbf{if}\;\left|b\right| \leq 2.25 \cdot 10^{-156}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\left|b\right| \leq 5.8 \cdot 10^{-18}:\\ \;\;\;\;\frac{\left(\left|a\right| \cdot \left(x-scale \cdot x-scale\right)\right) \cdot \frac{\sqrt{8 \cdot \left(\left(1 - \sqrt{{\cos \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)}^{4}}\right) \cdot {\left(\left|b\right|\right)}^{4}\right)}}{\left|x-scale\right|}}{\left|b\right| \cdot \left|b\right|} \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
        (FPCore (a b angle x-scale y-scale)
         :precision binary64
         (let* ((t_0 (* (fabs a) (fabs b)))
                (t_1
                 (*
                  (/
                   (*
                    (*
                     (/
                      (sqrt
                       (*
                        (*
                         (- (* (fabs a) (fabs a)) (sqrt (pow (fabs a) 4.0)))
                         (pow t_0 4.0))
                        8.0))
                      (fabs x-scale))
                     x-scale)
                    x-scale)
                   t_0)
                  (/ 0.25 t_0))))
           (if (<= (fabs b) 2.25e-156)
             t_1
             (if (<= (fabs b) 5.8e-18)
               (*
                (/
                 (*
                  (* (fabs a) (* x-scale x-scale))
                  (/
                   (sqrt
                    (*
                     8.0
                     (*
                      (-
                       1.0
                       (sqrt (pow (cos (* (* PI angle) 0.005555555555555556)) 4.0)))
                      (pow (fabs b) 4.0))))
                   (fabs x-scale)))
                 (* (fabs b) (fabs b)))
                0.25)
               t_1))))
        double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
        	double t_0 = fabs(a) * fabs(b);
        	double t_1 = ((((sqrt(((((fabs(a) * fabs(a)) - sqrt(pow(fabs(a), 4.0))) * pow(t_0, 4.0)) * 8.0)) / fabs(x_45_scale)) * x_45_scale) * x_45_scale) / t_0) * (0.25 / t_0);
        	double tmp;
        	if (fabs(b) <= 2.25e-156) {
        		tmp = t_1;
        	} else if (fabs(b) <= 5.8e-18) {
        		tmp = (((fabs(a) * (x_45_scale * x_45_scale)) * (sqrt((8.0 * ((1.0 - sqrt(pow(cos(((((double) M_PI) * angle) * 0.005555555555555556)), 4.0))) * pow(fabs(b), 4.0)))) / fabs(x_45_scale))) / (fabs(b) * fabs(b))) * 0.25;
        	} else {
        		tmp = t_1;
        	}
        	return tmp;
        }
        
        public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
        	double t_0 = Math.abs(a) * Math.abs(b);
        	double t_1 = ((((Math.sqrt(((((Math.abs(a) * Math.abs(a)) - Math.sqrt(Math.pow(Math.abs(a), 4.0))) * Math.pow(t_0, 4.0)) * 8.0)) / Math.abs(x_45_scale)) * x_45_scale) * x_45_scale) / t_0) * (0.25 / t_0);
        	double tmp;
        	if (Math.abs(b) <= 2.25e-156) {
        		tmp = t_1;
        	} else if (Math.abs(b) <= 5.8e-18) {
        		tmp = (((Math.abs(a) * (x_45_scale * x_45_scale)) * (Math.sqrt((8.0 * ((1.0 - Math.sqrt(Math.pow(Math.cos(((Math.PI * angle) * 0.005555555555555556)), 4.0))) * Math.pow(Math.abs(b), 4.0)))) / Math.abs(x_45_scale))) / (Math.abs(b) * Math.abs(b))) * 0.25;
        	} else {
        		tmp = t_1;
        	}
        	return tmp;
        }
        
        def code(a, b, angle, x_45_scale, y_45_scale):
        	t_0 = math.fabs(a) * math.fabs(b)
        	t_1 = ((((math.sqrt(((((math.fabs(a) * math.fabs(a)) - math.sqrt(math.pow(math.fabs(a), 4.0))) * math.pow(t_0, 4.0)) * 8.0)) / math.fabs(x_45_scale)) * x_45_scale) * x_45_scale) / t_0) * (0.25 / t_0)
        	tmp = 0
        	if math.fabs(b) <= 2.25e-156:
        		tmp = t_1
        	elif math.fabs(b) <= 5.8e-18:
        		tmp = (((math.fabs(a) * (x_45_scale * x_45_scale)) * (math.sqrt((8.0 * ((1.0 - math.sqrt(math.pow(math.cos(((math.pi * angle) * 0.005555555555555556)), 4.0))) * math.pow(math.fabs(b), 4.0)))) / math.fabs(x_45_scale))) / (math.fabs(b) * math.fabs(b))) * 0.25
        	else:
        		tmp = t_1
        	return tmp
        
        function code(a, b, angle, x_45_scale, y_45_scale)
        	t_0 = Float64(abs(a) * abs(b))
        	t_1 = Float64(Float64(Float64(Float64(Float64(sqrt(Float64(Float64(Float64(Float64(abs(a) * abs(a)) - sqrt((abs(a) ^ 4.0))) * (t_0 ^ 4.0)) * 8.0)) / abs(x_45_scale)) * x_45_scale) * x_45_scale) / t_0) * Float64(0.25 / t_0))
        	tmp = 0.0
        	if (abs(b) <= 2.25e-156)
        		tmp = t_1;
        	elseif (abs(b) <= 5.8e-18)
        		tmp = Float64(Float64(Float64(Float64(abs(a) * Float64(x_45_scale * x_45_scale)) * Float64(sqrt(Float64(8.0 * Float64(Float64(1.0 - sqrt((cos(Float64(Float64(pi * angle) * 0.005555555555555556)) ^ 4.0))) * (abs(b) ^ 4.0)))) / abs(x_45_scale))) / Float64(abs(b) * abs(b))) * 0.25);
        	else
        		tmp = t_1;
        	end
        	return tmp
        end
        
        function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale)
        	t_0 = abs(a) * abs(b);
        	t_1 = ((((sqrt(((((abs(a) * abs(a)) - sqrt((abs(a) ^ 4.0))) * (t_0 ^ 4.0)) * 8.0)) / abs(x_45_scale)) * x_45_scale) * x_45_scale) / t_0) * (0.25 / t_0);
        	tmp = 0.0;
        	if (abs(b) <= 2.25e-156)
        		tmp = t_1;
        	elseif (abs(b) <= 5.8e-18)
        		tmp = (((abs(a) * (x_45_scale * x_45_scale)) * (sqrt((8.0 * ((1.0 - sqrt((cos(((pi * angle) * 0.005555555555555556)) ^ 4.0))) * (abs(b) ^ 4.0)))) / abs(x_45_scale))) / (abs(b) * abs(b))) * 0.25;
        	else
        		tmp = t_1;
        	end
        	tmp_2 = tmp;
        end
        
        code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[Abs[a], $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(N[(N[Sqrt[N[(N[(N[(N[(N[Abs[a], $MachinePrecision] * N[Abs[a], $MachinePrecision]), $MachinePrecision] - N[Sqrt[N[Power[N[Abs[a], $MachinePrecision], 4.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[t$95$0, 4.0], $MachinePrecision]), $MachinePrecision] * 8.0), $MachinePrecision]], $MachinePrecision] / N[Abs[x$45$scale], $MachinePrecision]), $MachinePrecision] * x$45$scale), $MachinePrecision] * x$45$scale), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(0.25 / t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[b], $MachinePrecision], 2.25e-156], t$95$1, If[LessEqual[N[Abs[b], $MachinePrecision], 5.8e-18], N[(N[(N[(N[(N[Abs[a], $MachinePrecision] * N[(x$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(8.0 * N[(N[(1.0 - N[Sqrt[N[Power[N[Cos[N[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision], 4.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[N[Abs[b], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[x$45$scale], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Abs[b], $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision], t$95$1]]]]
        
        \begin{array}{l}
        t_0 := \left|a\right| \cdot \left|b\right|\\
        t_1 := \frac{\left(\frac{\sqrt{\left(\left(\left|a\right| \cdot \left|a\right| - \sqrt{{\left(\left|a\right|\right)}^{4}}\right) \cdot {t\_0}^{4}\right) \cdot 8}}{\left|x-scale\right|} \cdot x-scale\right) \cdot x-scale}{t\_0} \cdot \frac{0.25}{t\_0}\\
        \mathbf{if}\;\left|b\right| \leq 2.25 \cdot 10^{-156}:\\
        \;\;\;\;t\_1\\
        
        \mathbf{elif}\;\left|b\right| \leq 5.8 \cdot 10^{-18}:\\
        \;\;\;\;\frac{\left(\left|a\right| \cdot \left(x-scale \cdot x-scale\right)\right) \cdot \frac{\sqrt{8 \cdot \left(\left(1 - \sqrt{{\cos \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)}^{4}}\right) \cdot {\left(\left|b\right|\right)}^{4}\right)}}{\left|x-scale\right|}}{\left|b\right| \cdot \left|b\right|} \cdot 0.25\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_1\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if b < 2.24999999999999993e-156 or 5.8e-18 < b

          1. Initial program 0.1%

            \[\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. Taylor expanded in y-scale around 0

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

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

            \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          5. Step-by-step derivation
            1. lower--.f64N/A

              \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
            2. lower-pow.f64N/A

              \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
            3. lower-sqrt.f64N/A

              \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
            4. lower-pow.f640.7

              \[\leadsto 0.25 \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          6. Applied rewrites0.7%

            \[\leadsto 0.25 \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          7. Applied rewrites2.5%

            \[\leadsto \frac{0.25 \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot \left(a \cdot a - \sqrt{{a}^{4}}\right)\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot b\right)}} \]
          8. Step-by-step derivation
            1. lift-/.f64N/A

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

            \[\leadsto \frac{\left(\frac{\sqrt{\left(\left(a \cdot a - \sqrt{{a}^{4}}\right) \cdot {\left(a \cdot b\right)}^{4}\right) \cdot 8}}{\left|x-scale\right|} \cdot x-scale\right) \cdot x-scale}{a \cdot b} \cdot \color{blue}{\frac{0.25}{a \cdot b}} \]

          if 2.24999999999999993e-156 < b < 5.8e-18

          1. Initial program 0.1%

            \[\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. Taylor expanded in y-scale around 0

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

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

            \[\leadsto \frac{1}{4} \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{b}^{4} \cdot \left({\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{2} - \sqrt{{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}^{4}}\right)}{{x-scale}^{2}}}\right)}{\color{blue}{{b}^{2}}} \]
          5. Step-by-step derivation
            1. lower-/.f64N/A

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

            \[\leadsto 0.25 \cdot \frac{a \cdot \left({x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{b}^{4} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} - \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}\right)}{{x-scale}^{2}}}\right)}{\color{blue}{{b}^{2}}} \]
          7. Applied rewrites8.1%

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

            \[\leadsto \frac{\left(a \cdot \left(x-scale \cdot x-scale\right)\right) \cdot \frac{\sqrt{8 \cdot \left(\left(1 - \sqrt{{\cos \left(\left(\pi \cdot angle\right) \cdot \frac{1}{180}\right)}^{4}}\right) \cdot {b}^{4}\right)}}{\left|x-scale\right|}}{b \cdot b} \cdot \frac{1}{4} \]
          9. Step-by-step derivation
            1. Applied rewrites8.4%

              \[\leadsto \frac{\left(a \cdot \left(x-scale \cdot x-scale\right)\right) \cdot \frac{\sqrt{8 \cdot \left(\left(1 - \sqrt{{\cos \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)}^{4}}\right) \cdot {b}^{4}\right)}}{\left|x-scale\right|}}{b \cdot b} \cdot 0.25 \]
          10. Recombined 2 regimes into one program.
          11. Add Preprocessing

          Alternative 6: 15.2% accurate, 9.9× speedup?

          \[\frac{\left(\frac{\sqrt{\left(\left(a \cdot a - \sqrt{{a}^{4}}\right) \cdot {\left(a \cdot b\right)}^{4}\right) \cdot 8}}{\left|x-scale\right|} \cdot x-scale\right) \cdot x-scale}{a \cdot b} \cdot \frac{0.25}{a \cdot b} \]
          (FPCore (a b angle x-scale y-scale)
           :precision binary64
           (*
            (/
             (*
              (*
               (/
                (sqrt (* (* (- (* a a) (sqrt (pow a 4.0))) (pow (* a b) 4.0)) 8.0))
                (fabs x-scale))
               x-scale)
              x-scale)
             (* a b))
            (/ 0.25 (* a b))))
          double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
          	return ((((sqrt(((((a * a) - sqrt(pow(a, 4.0))) * pow((a * b), 4.0)) * 8.0)) / fabs(x_45_scale)) * x_45_scale) * x_45_scale) / (a * b)) * (0.25 / (a * b));
          }
          
          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, 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
              real(8), intent (in) :: y_45scale
              code = ((((sqrt(((((a * a) - sqrt((a ** 4.0d0))) * ((a * b) ** 4.0d0)) * 8.0d0)) / abs(x_45scale)) * x_45scale) * x_45scale) / (a * b)) * (0.25d0 / (a * b))
          end function
          
          public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
          	return ((((Math.sqrt(((((a * a) - Math.sqrt(Math.pow(a, 4.0))) * Math.pow((a * b), 4.0)) * 8.0)) / Math.abs(x_45_scale)) * x_45_scale) * x_45_scale) / (a * b)) * (0.25 / (a * b));
          }
          
          def code(a, b, angle, x_45_scale, y_45_scale):
          	return ((((math.sqrt(((((a * a) - math.sqrt(math.pow(a, 4.0))) * math.pow((a * b), 4.0)) * 8.0)) / math.fabs(x_45_scale)) * x_45_scale) * x_45_scale) / (a * b)) * (0.25 / (a * b))
          
          function code(a, b, angle, x_45_scale, y_45_scale)
          	return Float64(Float64(Float64(Float64(Float64(sqrt(Float64(Float64(Float64(Float64(a * a) - sqrt((a ^ 4.0))) * (Float64(a * b) ^ 4.0)) * 8.0)) / abs(x_45_scale)) * x_45_scale) * x_45_scale) / Float64(a * b)) * Float64(0.25 / Float64(a * b)))
          end
          
          function tmp = code(a, b, angle, x_45_scale, y_45_scale)
          	tmp = ((((sqrt(((((a * a) - sqrt((a ^ 4.0))) * ((a * b) ^ 4.0)) * 8.0)) / abs(x_45_scale)) * x_45_scale) * x_45_scale) / (a * b)) * (0.25 / (a * b));
          end
          
          code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(N[(N[(N[(N[(N[Sqrt[N[(N[(N[(N[(a * a), $MachinePrecision] - N[Sqrt[N[Power[a, 4.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[N[(a * b), $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] * 8.0), $MachinePrecision]], $MachinePrecision] / N[Abs[x$45$scale], $MachinePrecision]), $MachinePrecision] * x$45$scale), $MachinePrecision] * x$45$scale), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(0.25 / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
          
          \frac{\left(\frac{\sqrt{\left(\left(a \cdot a - \sqrt{{a}^{4}}\right) \cdot {\left(a \cdot b\right)}^{4}\right) \cdot 8}}{\left|x-scale\right|} \cdot x-scale\right) \cdot x-scale}{a \cdot b} \cdot \frac{0.25}{a \cdot b}
          
          Derivation
          1. Initial program 0.1%

            \[\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. Taylor expanded in y-scale around 0

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

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

            \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          5. Step-by-step derivation
            1. lower--.f64N/A

              \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
            2. lower-pow.f64N/A

              \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
            3. lower-sqrt.f64N/A

              \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
            4. lower-pow.f640.7

              \[\leadsto 0.25 \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          6. Applied rewrites0.7%

            \[\leadsto 0.25 \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          7. Applied rewrites2.5%

            \[\leadsto \frac{0.25 \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot \left(a \cdot a - \sqrt{{a}^{4}}\right)\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot b\right)}} \]
          8. Step-by-step derivation
            1. lift-/.f64N/A

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

            \[\leadsto \frac{\left(\frac{\sqrt{\left(\left(a \cdot a - \sqrt{{a}^{4}}\right) \cdot {\left(a \cdot b\right)}^{4}\right) \cdot 8}}{\left|x-scale\right|} \cdot x-scale\right) \cdot x-scale}{a \cdot b} \cdot \color{blue}{\frac{0.25}{a \cdot b}} \]
          10. Add Preprocessing

          Alternative 7: 6.6% accurate, 9.9× speedup?

          \[\frac{0.25 \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot \left(a \cdot a - \sqrt{{a}^{4}}\right)\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\left(a \cdot b\right) \cdot \left(a \cdot b\right)} \]
          (FPCore (a b angle x-scale y-scale)
           :precision binary64
           (/
            (*
             0.25
             (*
              (/
               (sqrt (* 8.0 (* (pow (* a b) 4.0) (- (* a a) (sqrt (pow a 4.0))))))
               (fabs x-scale))
              (* x-scale x-scale)))
            (* (* a b) (* a b))))
          double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
          	return (0.25 * ((sqrt((8.0 * (pow((a * b), 4.0) * ((a * a) - sqrt(pow(a, 4.0)))))) / fabs(x_45_scale)) * (x_45_scale * x_45_scale))) / ((a * b) * (a * b));
          }
          
          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, 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
              real(8), intent (in) :: y_45scale
              code = (0.25d0 * ((sqrt((8.0d0 * (((a * b) ** 4.0d0) * ((a * a) - sqrt((a ** 4.0d0)))))) / abs(x_45scale)) * (x_45scale * x_45scale))) / ((a * b) * (a * b))
          end function
          
          public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
          	return (0.25 * ((Math.sqrt((8.0 * (Math.pow((a * b), 4.0) * ((a * a) - Math.sqrt(Math.pow(a, 4.0)))))) / Math.abs(x_45_scale)) * (x_45_scale * x_45_scale))) / ((a * b) * (a * b));
          }
          
          def code(a, b, angle, x_45_scale, y_45_scale):
          	return (0.25 * ((math.sqrt((8.0 * (math.pow((a * b), 4.0) * ((a * a) - math.sqrt(math.pow(a, 4.0)))))) / math.fabs(x_45_scale)) * (x_45_scale * x_45_scale))) / ((a * b) * (a * b))
          
          function code(a, b, angle, x_45_scale, y_45_scale)
          	return Float64(Float64(0.25 * Float64(Float64(sqrt(Float64(8.0 * Float64((Float64(a * b) ^ 4.0) * Float64(Float64(a * a) - sqrt((a ^ 4.0)))))) / abs(x_45_scale)) * Float64(x_45_scale * x_45_scale))) / Float64(Float64(a * b) * Float64(a * b)))
          end
          
          function tmp = code(a, b, angle, x_45_scale, y_45_scale)
          	tmp = (0.25 * ((sqrt((8.0 * (((a * b) ^ 4.0) * ((a * a) - sqrt((a ^ 4.0)))))) / abs(x_45_scale)) * (x_45_scale * x_45_scale))) / ((a * b) * (a * b));
          end
          
          code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(N[(0.25 * N[(N[(N[Sqrt[N[(8.0 * N[(N[Power[N[(a * b), $MachinePrecision], 4.0], $MachinePrecision] * N[(N[(a * a), $MachinePrecision] - N[Sqrt[N[Power[a, 4.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[x$45$scale], $MachinePrecision]), $MachinePrecision] * N[(x$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(a * b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
          
          \frac{0.25 \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot \left(a \cdot a - \sqrt{{a}^{4}}\right)\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}
          
          Derivation
          1. Initial program 0.1%

            \[\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. Taylor expanded in y-scale around 0

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

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

            \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          5. Step-by-step derivation
            1. lower--.f64N/A

              \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
            2. lower-pow.f64N/A

              \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
            3. lower-sqrt.f64N/A

              \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
            4. lower-pow.f640.7

              \[\leadsto 0.25 \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          6. Applied rewrites0.7%

            \[\leadsto 0.25 \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          7. Applied rewrites2.5%

            \[\leadsto \frac{0.25 \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot \left(a \cdot a - \sqrt{{a}^{4}}\right)\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot b\right)}} \]
          8. Step-by-step derivation
            1. lift-*.f64N/A

              \[\leadsto \frac{\frac{1}{4} \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot \left(a \cdot a - \sqrt{{a}^{4}}\right)\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\left(a \cdot a\right) \cdot \color{blue}{\left(b \cdot b\right)}} \]
            2. lift-*.f64N/A

              \[\leadsto \frac{\frac{1}{4} \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot \left(a \cdot a - \sqrt{{a}^{4}}\right)\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\left(a \cdot a\right) \cdot \left(\color{blue}{b} \cdot b\right)} \]
            3. lift-*.f64N/A

              \[\leadsto \frac{\frac{1}{4} \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot \left(a \cdot a - \sqrt{{a}^{4}}\right)\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\left(a \cdot a\right) \cdot \left(b \cdot \color{blue}{b}\right)} \]
            4. unswap-sqrN/A

              \[\leadsto \frac{\frac{1}{4} \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot \left(a \cdot a - \sqrt{{a}^{4}}\right)\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\left(a \cdot b\right) \cdot \color{blue}{\left(a \cdot b\right)}} \]
            5. lift-*.f64N/A

              \[\leadsto \frac{\frac{1}{4} \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot \left(a \cdot a - \sqrt{{a}^{4}}\right)\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\left(a \cdot b\right) \cdot \left(\color{blue}{a} \cdot b\right)} \]
            6. lift-*.f64N/A

              \[\leadsto \frac{\frac{1}{4} \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot \left(a \cdot a - \sqrt{{a}^{4}}\right)\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\left(a \cdot b\right) \cdot \left(a \cdot \color{blue}{b}\right)} \]
            7. lower-*.f646.6

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

            \[\leadsto \frac{0.25 \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot \left(a \cdot a - \sqrt{{a}^{4}}\right)\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\left(a \cdot b\right) \cdot \color{blue}{\left(a \cdot b\right)}} \]
          10. Add Preprocessing

          Alternative 8: 3.4% accurate, 14.3× speedup?

          \[\frac{0.25 \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot 0\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\left(a \cdot a\right) \cdot \left(b \cdot b\right)} \]
          (FPCore (a b angle x-scale y-scale)
           :precision binary64
           (/
            (*
             0.25
             (*
              (/ (sqrt (* 8.0 (* (pow (* a b) 4.0) 0.0))) (fabs x-scale))
              (* x-scale x-scale)))
            (* (* a a) (* b b))))
          double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
          	return (0.25 * ((sqrt((8.0 * (pow((a * b), 4.0) * 0.0))) / fabs(x_45_scale)) * (x_45_scale * x_45_scale))) / ((a * a) * (b * b));
          }
          
          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, 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
              real(8), intent (in) :: y_45scale
              code = (0.25d0 * ((sqrt((8.0d0 * (((a * b) ** 4.0d0) * 0.0d0))) / abs(x_45scale)) * (x_45scale * x_45scale))) / ((a * a) * (b * b))
          end function
          
          public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
          	return (0.25 * ((Math.sqrt((8.0 * (Math.pow((a * b), 4.0) * 0.0))) / Math.abs(x_45_scale)) * (x_45_scale * x_45_scale))) / ((a * a) * (b * b));
          }
          
          def code(a, b, angle, x_45_scale, y_45_scale):
          	return (0.25 * ((math.sqrt((8.0 * (math.pow((a * b), 4.0) * 0.0))) / math.fabs(x_45_scale)) * (x_45_scale * x_45_scale))) / ((a * a) * (b * b))
          
          function code(a, b, angle, x_45_scale, y_45_scale)
          	return Float64(Float64(0.25 * Float64(Float64(sqrt(Float64(8.0 * Float64((Float64(a * b) ^ 4.0) * 0.0))) / abs(x_45_scale)) * Float64(x_45_scale * x_45_scale))) / Float64(Float64(a * a) * Float64(b * b)))
          end
          
          function tmp = code(a, b, angle, x_45_scale, y_45_scale)
          	tmp = (0.25 * ((sqrt((8.0 * (((a * b) ^ 4.0) * 0.0))) / abs(x_45_scale)) * (x_45_scale * x_45_scale))) / ((a * a) * (b * b));
          end
          
          code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(N[(0.25 * N[(N[(N[Sqrt[N[(8.0 * N[(N[Power[N[(a * b), $MachinePrecision], 4.0], $MachinePrecision] * 0.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[x$45$scale], $MachinePrecision]), $MachinePrecision] * N[(x$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(a * a), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
          
          \frac{0.25 \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot 0\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\left(a \cdot a\right) \cdot \left(b \cdot b\right)}
          
          Derivation
          1. Initial program 0.1%

            \[\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. Taylor expanded in y-scale around 0

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

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

            \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          5. Step-by-step derivation
            1. lower--.f64N/A

              \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
            2. lower-pow.f64N/A

              \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
            3. lower-sqrt.f64N/A

              \[\leadsto \frac{1}{4} \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
            4. lower-pow.f640.7

              \[\leadsto 0.25 \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          6. Applied rewrites0.7%

            \[\leadsto 0.25 \cdot \frac{{x-scale}^{2} \cdot \sqrt{8 \cdot \frac{{a}^{4} \cdot \left({b}^{4} \cdot \left({a}^{2} - \sqrt{{a}^{4}}\right)\right)}{{x-scale}^{2}}}}{{a}^{2} \cdot {b}^{2}} \]
          7. Applied rewrites2.5%

            \[\leadsto \frac{0.25 \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot \left(a \cdot a - \sqrt{{a}^{4}}\right)\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\color{blue}{\left(a \cdot a\right) \cdot \left(b \cdot b\right)}} \]
          8. Taylor expanded in a around 0

            \[\leadsto \frac{\frac{1}{4} \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot 0\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\left(a \cdot a\right) \cdot \left(b \cdot b\right)} \]
          9. Step-by-step derivation
            1. Applied rewrites3.4%

              \[\leadsto \frac{0.25 \cdot \left(\frac{\sqrt{8 \cdot \left({\left(a \cdot b\right)}^{4} \cdot 0\right)}}{\left|x-scale\right|} \cdot \left(x-scale \cdot x-scale\right)\right)}{\left(a \cdot a\right) \cdot \left(b \cdot b\right)} \]
            2. Add Preprocessing

            Reproduce

            ?
            herbie shell --seed 2025181 
            (FPCore (a b angle x-scale y-scale)
              :name "b 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))))