\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} \cdot \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}}{y-scale}}{y-scale}
\begin{array}{l}
\mathbf{if}\;x-scale \leq -1.6489576853730736 \cdot 10^{+112}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\
t_1 := \cos t_0\\
t_2 := \sin t_0\\
t_3 := {t_1}^{2}\\
t_4 := {x-scale}^{2} \cdot y-scale\\
t_5 := \frac{{b}^{2} \cdot {t_2}^{4}}{t_4} \cdot -4\\
t_6 := 4 \cdot \frac{{b}^{2} \cdot {t_1}^{4}}{t_4}\\
\mathbf{if}\;x-scale \leq -2.1174803085575703 \cdot 10^{-162}:\\
\;\;\;\;\frac{a \cdot \left(a \cdot \left(t_5 - \left(t_6 + 8 \cdot \frac{t_3 \cdot \left({b}^{2} \cdot {t_2}^{2}\right)}{t_4}\right)\right)\right)}{y-scale}\\
\mathbf{elif}\;x-scale \leq 2.539472045982003 \cdot 10^{-83}:\\
\;\;\;\;\begin{array}{l}
t_7 := \pi \cdot \frac{angle}{180}\\
t_8 := \sin t_7\\
t_9 := \cos t_7\\
t_10 := \left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t_8\right) \cdot t_9\\
\frac{\frac{t_10 \cdot \frac{\frac{t_10}{x-scale}}{y-scale} - \left(4 \cdot \frac{{\left(a \cdot t_8\right)}^{2} + {\left(b \cdot t_9\right)}^{2}}{x-scale}\right) \cdot \frac{{\left(a \cdot t_9\right)}^{2} + {\left(b \cdot t_8\right)}^{2}}{y-scale}}{x-scale}}{y-scale}
\end{array}\\
\mathbf{elif}\;x-scale \leq 2.8890770969222315 \cdot 10^{+46}:\\
\;\;\;\;\frac{{a}^{2} \cdot \left(t_5 - \left(t_6 + 8 \cdot \frac{t_3 \cdot \left({b}^{2} \cdot {\log \left(e^{t_2}\right)}^{2}\right)}{t_4}\right)\right)}{y-scale}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}\\
\end{array}
(FPCore (a b angle x-scale y-scale)
:precision binary64
(-
(*
(/
(/
(*
(* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* (/ angle 180.0) PI)))
(cos (* (/ angle 180.0) PI)))
x-scale)
y-scale)
(/
(/
(*
(* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* (/ angle 180.0) PI)))
(cos (* (/ angle 180.0) PI)))
x-scale)
y-scale))
(*
(*
4.0
(/
(/
(+
(pow (* a (sin (* (/ angle 180.0) PI))) 2.0)
(pow (* b (cos (* (/ angle 180.0) PI))) 2.0))
x-scale)
x-scale))
(/
(/
(+
(pow (* a (cos (* (/ angle 180.0) PI))) 2.0)
(pow (* b (sin (* (/ angle 180.0) PI))) 2.0))
y-scale)
y-scale))))(FPCore (a b angle x-scale y-scale)
:precision binary64
(if (<= x-scale -1.6489576853730736e+112)
0.0
(let* ((t_0 (* 0.005555555555555556 (* angle PI)))
(t_1 (cos t_0))
(t_2 (sin t_0))
(t_3 (pow t_1 2.0))
(t_4 (* (pow x-scale 2.0) y-scale))
(t_5 (* (/ (* (pow b 2.0) (pow t_2 4.0)) t_4) -4.0))
(t_6 (* 4.0 (/ (* (pow b 2.0) (pow t_1 4.0)) t_4))))
(if (<= x-scale -2.1174803085575703e-162)
(/
(*
a
(*
a
(-
t_5
(+ t_6 (* 8.0 (/ (* t_3 (* (pow b 2.0) (pow t_2 2.0))) t_4))))))
y-scale)
(if (<= x-scale 2.539472045982003e-83)
(let* ((t_7 (* PI (/ angle 180.0)))
(t_8 (sin t_7))
(t_9 (cos t_7))
(t_10 (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_8) t_9)))
(/
(/
(-
(* t_10 (/ (/ t_10 x-scale) y-scale))
(*
(* 4.0 (/ (+ (pow (* a t_8) 2.0) (pow (* b t_9) 2.0)) x-scale))
(/ (+ (pow (* a t_9) 2.0) (pow (* b t_8) 2.0)) y-scale)))
x-scale)
y-scale))
(if (<= x-scale 2.8890770969222315e+46)
(/
(*
(pow a 2.0)
(-
t_5
(+
t_6
(*
8.0
(/ (* t_3 (* (pow b 2.0) (pow (log (exp t_2)) 2.0))) t_4)))))
y-scale)
0.0))))))double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return ((((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin((angle / 180.0) * ((double) M_PI))) * cos((angle / 180.0) * ((double) M_PI))) / x_45_scale) / y_45_scale) * (((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin((angle / 180.0) * ((double) M_PI))) * cos((angle / 180.0) * ((double) M_PI))) / x_45_scale) / y_45_scale)) - ((4.0 * (((pow((a * sin((angle / 180.0) * ((double) M_PI))), 2.0) + pow((b * cos((angle / 180.0) * ((double) M_PI))), 2.0)) / x_45_scale) / x_45_scale)) * (((pow((a * cos((angle / 180.0) * ((double) M_PI))), 2.0) + pow((b * sin((angle / 180.0) * ((double) M_PI))), 2.0)) / y_45_scale) / y_45_scale));
}
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double tmp;
if (x_45_scale <= -1.6489576853730736e+112) {
tmp = 0.0;
} else {
double t_0 = 0.005555555555555556 * (angle * ((double) M_PI));
double t_1 = cos(t_0);
double t_2 = sin(t_0);
double t_3 = pow(t_1, 2.0);
double t_4 = pow(x_45_scale, 2.0) * y_45_scale;
double t_5 = ((pow(b, 2.0) * pow(t_2, 4.0)) / t_4) * -4.0;
double t_6 = 4.0 * ((pow(b, 2.0) * pow(t_1, 4.0)) / t_4);
double tmp_1;
if (x_45_scale <= -2.1174803085575703e-162) {
tmp_1 = (a * (a * (t_5 - (t_6 + (8.0 * ((t_3 * (pow(b, 2.0) * pow(t_2, 2.0))) / t_4)))))) / y_45_scale;
} else if (x_45_scale <= 2.539472045982003e-83) {
double t_7 = ((double) M_PI) * (angle / 180.0);
double t_8 = sin(t_7);
double t_9 = cos(t_7);
double t_10 = ((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * t_8) * t_9;
tmp_1 = (((t_10 * ((t_10 / x_45_scale) / y_45_scale)) - ((4.0 * ((pow((a * t_8), 2.0) + pow((b * t_9), 2.0)) / x_45_scale)) * ((pow((a * t_9), 2.0) + pow((b * t_8), 2.0)) / y_45_scale))) / x_45_scale) / y_45_scale;
} else if (x_45_scale <= 2.8890770969222315e+46) {
tmp_1 = (pow(a, 2.0) * (t_5 - (t_6 + (8.0 * ((t_3 * (pow(b, 2.0) * pow(log(exp(t_2)), 2.0))) / t_4))))) / y_45_scale;
} else {
tmp_1 = 0.0;
}
tmp = tmp_1;
}
return tmp;
}



Bits error versus a



Bits error versus b



Bits error versus angle



Bits error versus x-scale



Bits error versus y-scale
Results
if x-scale < -1.6489576853730736e112 or 2.8890770969222315e46 < x-scale Initial program 36.4
Taylor expanded in b around 0 34.9
Simplified22.2
if -1.6489576853730736e112 < x-scale < -2.1174803085575703e-162Initial program 41.3
Applied associate-*r/_binary6440.6
Applied associate-*l/_binary6439.9
Applied sub-div_binary6440.1
Taylor expanded in a around 0 29.8
Applied unpow2_binary6429.8
Applied associate-*r*_binary6425.7
if -2.1174803085575703e-162 < x-scale < 2.5394720459820031e-83Initial program 49.8
Applied associate-*r/_binary6449.5
Applied associate-*l/_binary6449.4
Applied sub-div_binary6449.4
Applied associate-*r/_binary6449.4
Applied associate-*l/_binary6446.9
Applied associate-*l/_binary6446.2
Applied sub-div_binary6446.1
if 2.5394720459820031e-83 < x-scale < 2.8890770969222315e46Initial program 41.2
Applied associate-*r/_binary6440.9
Applied associate-*l/_binary6440.2
Applied sub-div_binary6440.4
Taylor expanded in a around 0 28.6
Applied add-log-exp_binary6428.6
Final simplification28.2
herbie shell --seed 2022067
(FPCore (a b angle x-scale y-scale)
:name "Simplification of discriminant from scale-rotated-ellipse"
:precision binary64
(- (* (/ (/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* (/ angle 180.0) PI))) (cos (* (/ angle 180.0) PI))) x-scale) y-scale) (/ (/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* (/ angle 180.0) PI))) (cos (* (/ angle 180.0) PI))) x-scale) y-scale)) (* (* 4.0 (/ (/ (+ (pow (* a (sin (* (/ angle 180.0) PI))) 2.0) (pow (* b (cos (* (/ angle 180.0) PI))) 2.0)) x-scale) x-scale)) (/ (/ (+ (pow (* a (cos (* (/ angle 180.0) PI))) 2.0) (pow (* b (sin (* (/ angle 180.0) PI))) 2.0)) y-scale) y-scale))))