\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}\;y-scale \leq -9.224708582620995 \cdot 10^{+55}:\\
\;\;\;\;0\\
\mathbf{elif}\;y-scale \leq -9.294060461641668 \cdot 10^{-99}:\\
\;\;\;\;\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(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t_1\right) \cdot t_2}{x-scale}}{y-scale}\\
t_4 := \sqrt{\frac{\left(4 \cdot \frac{{\left(a \cdot t_1\right)}^{2} + {\left(b \cdot t_2\right)}^{2}}{x-scale}\right) \cdot \frac{{\left(a \cdot t_2\right)}^{2} + {\left(b \cdot t_1\right)}^{2}}{y-scale}}{y-scale \cdot x-scale}}\\
t_5 := t_4 \cdot t_4\\
\mathsf{fma}\left(t_3, t_3, -t_5\right) + \mathsf{fma}\left(-t_4, t_4, t_5\right)
\end{array}\\
\mathbf{elif}\;y-scale \leq 3.7037763838567126 \cdot 10^{-63}:\\
\;\;\;\;0\\
\mathbf{elif}\;y-scale \leq 3753026579.000717:\\
\;\;\;\;\begin{array}{l}
t_6 := 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\
t_7 := {x-scale}^{2} \cdot {y-scale}^{2}\\
t_8 := \cos t_6\\
t_9 := \sin t_6\\
{a}^{2} \cdot \left(\frac{{b}^{2} \cdot {t_9}^{4}}{t_7} \cdot -4 - \left(8 \cdot \frac{{t_8}^{2} \cdot \left({b}^{2} \cdot {t_9}^{2}\right)}{t_7} + 4 \cdot \frac{{b}^{2} \cdot {t_8}^{4}}{t_7}\right)\right)
\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 (<= y-scale -9.224708582620995e+55)
0.0
(if (<= y-scale -9.294060461641668e-99)
(let* ((t_0 (* (/ angle 180.0) PI))
(t_1 (sin t_0))
(t_2 (cos t_0))
(t_3
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_2) x-scale)
y-scale))
(t_4
(sqrt
(/
(*
(* 4.0 (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) x-scale))
(/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) y-scale))
(* y-scale x-scale))))
(t_5 (* t_4 t_4)))
(+ (fma t_3 t_3 (- t_5)) (fma (- t_4) t_4 t_5)))
(if (<= y-scale 3.7037763838567126e-63)
0.0
(if (<= y-scale 3753026579.000717)
(let* ((t_6 (* 0.005555555555555556 (* angle PI)))
(t_7 (* (pow x-scale 2.0) (pow y-scale 2.0)))
(t_8 (cos t_6))
(t_9 (sin t_6)))
(*
(pow a 2.0)
(-
(* (/ (* (pow b 2.0) (pow t_9 4.0)) t_7) -4.0)
(+
(* 8.0 (/ (* (pow t_8 2.0) (* (pow b 2.0) (pow t_9 2.0))) t_7))
(* 4.0 (/ (* (pow b 2.0) (pow t_8 4.0)) t_7))))))
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 (y_45_scale <= -9.224708582620995e+55) {
tmp = 0.0;
} else if (y_45_scale <= -9.294060461641668e-99) {
double t_0 = (angle / 180.0) * ((double) M_PI);
double t_1 = sin(t_0);
double t_2 = cos(t_0);
double t_3 = ((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale;
double t_4 = sqrt(((4.0 * ((pow((a * t_1), 2.0) + pow((b * t_2), 2.0)) / x_45_scale)) * ((pow((a * t_2), 2.0) + pow((b * t_1), 2.0)) / y_45_scale)) / (y_45_scale * x_45_scale));
double t_5 = t_4 * t_4;
tmp = fma(t_3, t_3, -t_5) + fma(-t_4, t_4, t_5);
} else if (y_45_scale <= 3.7037763838567126e-63) {
tmp = 0.0;
} else if (y_45_scale <= 3753026579.000717) {
double t_6 = 0.005555555555555556 * (angle * ((double) M_PI));
double t_7 = pow(x_45_scale, 2.0) * pow(y_45_scale, 2.0);
double t_8 = cos(t_6);
double t_9 = sin(t_6);
tmp = pow(a, 2.0) * ((((pow(b, 2.0) * pow(t_9, 4.0)) / t_7) * -4.0) - ((8.0 * ((pow(t_8, 2.0) * (pow(b, 2.0) * pow(t_9, 2.0))) / t_7)) + (4.0 * ((pow(b, 2.0) * pow(t_8, 4.0)) / t_7))));
} 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
if y-scale < -9.22470858262099455e55 or -9.29406046164166839e-99 < y-scale < 3.7037763838567126e-63 or 3753026579.000717 < y-scale Initial program 40.5
Taylor expanded in b around 0 42.2
Simplified29.6
if -9.22470858262099455e55 < y-scale < -9.29406046164166839e-99Initial program 41.0
Applied associate-*r/_binary6441.0
Applied frac-times_binary6439.8
Applied add-sqr-sqrt_binary6438.3
Applied prod-diff_binary6438.3
if 3.7037763838567126e-63 < y-scale < 3753026579.000717Initial program 42.0
Taylor expanded in a around 0 32.4
Final simplification30.9
herbie shell --seed 2021313
(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))))