\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}\;a \leq -1.334263419474858 \cdot 10^{+154}:\\
\;\;\;\;0\\
\mathbf{elif}\;a \leq 4.174159469246405 \cdot 10^{+148}:\\
\;\;\;\;\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\
t_1 := \cos t_0\\
t_2 := \sin t_0\\
\frac{b \cdot \left(b \cdot \left(\frac{{t_1}^{2} \cdot \left({a}^{2} \cdot {t_2}^{2}\right)}{y-scale \cdot x-scale} \cdot -8 - \left(4 \cdot \frac{{a}^{2} \cdot {t_1}^{4}}{y-scale \cdot x-scale} + 4 \cdot \frac{{a}^{2} \cdot {t_2}^{4}}{y-scale \cdot x-scale}\right)\right)\right)}{y-scale \cdot x-scale}
\end{array}\\
\mathbf{else}:\\
\;\;\;\;0\\
\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 (<= a -1.334263419474858e+154)
0.0
(if (<= a 4.174159469246405e+148)
(let* ((t_0 (* 0.005555555555555556 (* angle PI)))
(t_1 (cos t_0))
(t_2 (sin t_0)))
(/
(*
b
(*
b
(-
(*
(/
(* (pow t_1 2.0) (* (pow a 2.0) (pow t_2 2.0)))
(* y-scale x-scale))
-8.0)
(+
(* 4.0 (/ (* (pow a 2.0) (pow t_1 4.0)) (* y-scale x-scale)))
(* 4.0 (/ (* (pow a 2.0) (pow t_2 4.0)) (* y-scale x-scale)))))))
(* y-scale x-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 (a <= -1.334263419474858e+154) {
tmp = 0.0;
} else if (a <= 4.174159469246405e+148) {
double t_0 = 0.005555555555555556 * (angle * ((double) M_PI));
double t_1 = cos(t_0);
double t_2 = sin(t_0);
tmp = (b * (b * ((((pow(t_1, 2.0) * (pow(a, 2.0) * pow(t_2, 2.0))) / (y_45_scale * x_45_scale)) * -8.0) - ((4.0 * ((pow(a, 2.0) * pow(t_1, 4.0)) / (y_45_scale * x_45_scale))) + (4.0 * ((pow(a, 2.0) * pow(t_2, 4.0)) / (y_45_scale * x_45_scale))))))) / (y_45_scale * x_45_scale);
} else {
tmp = 0.0;
}
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 a < -1.33426341947485803e154 or 4.1741594692464049e148 < a Initial program 63.6
Taylor expanded in b around 0 64.0
Simplified45.4
if -1.33426341947485803e154 < a < 4.1741594692464049e148Initial program 37.5
Applied associate-*r/_binary6437.5
Applied associate-*l/_binary6436.9
Applied associate-*l/_binary6437.0
Applied frac-sub_binary6436.5
Taylor expanded in b around 0 22.0
Applied unpow2_binary6422.0
Applied associate-*r*_binary6415.2
Final simplification20.1
herbie shell --seed 2022077
(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))))