\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}\;\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
t_1 := \cos t_0\\
t_2 := \sin t_0\\
t_3 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t_2\right) \cdot t_1}{x-scale}}{y-scale}\\
t_3 \cdot t_3 - \left(4 \cdot \frac{\frac{{\left(a \cdot t_2\right)}^{2} + {\left(b \cdot t_1\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot t_1\right)}^{2} + {\left(b \cdot t_2\right)}^{2}}{y-scale}}{y-scale} \leq -4.462438616083336 \cdot 10^{-189}
\end{array}:\\
\;\;\;\;\begin{array}{l}
t_4 := \left(y-scale \cdot y-scale\right) \cdot \left(x-scale \cdot x-scale\right)\\
t_5 := 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\
t_6 := \cos t_5\\
t_7 := \sin t_5\\
-\mathsf{fma}\left(4, \frac{\left(a \cdot a\right) \cdot {t_6}^{4}}{t_4}, \mathsf{fma}\left(4, \frac{\left(a \cdot a\right) \cdot {t_7}^{4}}{t_4}, 8 \cdot \frac{\left(a \cdot a\right) \cdot \left({t_6}^{2} \cdot {t_7}^{2}\right)}{t_4}\right)\right) \cdot \left(b \cdot b\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 (let* ((t_0 (* (/ angle 180.0) PI))
(t_1 (cos t_0))
(t_2 (sin t_0))
(t_3
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_2) t_1) x-scale)
y-scale)))
(<=
(-
(* t_3 t_3)
(*
(*
4.0
(/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) x-scale) x-scale))
(/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) y-scale) y-scale)))
-4.462438616083336e-189))
(let* ((t_4 (* (* y-scale y-scale) (* x-scale x-scale)))
(t_5 (* 0.005555555555555556 (* angle PI)))
(t_6 (cos t_5))
(t_7 (sin t_5)))
(-
(*
(fma
4.0
(/ (* (* a a) (pow t_6 4.0)) t_4)
(fma
4.0
(/ (* (* a a) (pow t_7 4.0)) t_4)
(* 8.0 (/ (* (* a a) (* (pow t_6 2.0) (pow t_7 2.0))) t_4))))
(* b b))))
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 t_0 = (angle / 180.0) * ((double) M_PI);
double t_1 = cos(t_0);
double t_2 = sin(t_0);
double t_3 = ((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * t_2) * t_1) / x_45_scale) / y_45_scale;
double tmp;
if (((t_3 * t_3) - ((4.0 * (((pow((a * t_2), 2.0) + pow((b * t_1), 2.0)) / x_45_scale) / x_45_scale)) * (((pow((a * t_1), 2.0) + pow((b * t_2), 2.0)) / y_45_scale) / y_45_scale))) <= -4.462438616083336e-189) {
double t_4_1 = (y_45_scale * y_45_scale) * (x_45_scale * x_45_scale);
double t_5_2 = 0.005555555555555556 * (angle * ((double) M_PI));
double t_6_3 = cos(t_5_2);
double t_7_4 = sin(t_5_2);
tmp = -(fma(4.0, (((a * a) * pow(t_6_3, 4.0)) / t_4_1), fma(4.0, (((a * a) * pow(t_7_4, 4.0)) / t_4_1), (8.0 * (((a * a) * (pow(t_6_3, 2.0) * pow(t_7_4, 2.0))) / t_4_1)))) * (b * b));
} 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 (-.f64 (*.f64 (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 2 (-.f64 (pow.f64 b 2) (pow.f64 a 2))) (sin.f64 (*.f64 (/.f64 angle 180) PI.f64))) (cos.f64 (*.f64 (/.f64 angle 180) PI.f64))) x-scale) y-scale) (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 2 (-.f64 (pow.f64 b 2) (pow.f64 a 2))) (sin.f64 (*.f64 (/.f64 angle 180) PI.f64))) (cos.f64 (*.f64 (/.f64 angle 180) PI.f64))) x-scale) y-scale)) (*.f64 (*.f64 4 (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle 180) PI.f64))) 2) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle 180) PI.f64))) 2)) x-scale) x-scale)) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle 180) PI.f64))) 2) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle 180) PI.f64))) 2)) y-scale) y-scale))) < -4.46243861608333627e-189Initial program 48.8
Taylor expanded in b around 0 37.7
Simplified37.7
if -4.46243861608333627e-189 < (-.f64 (*.f64 (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 2 (-.f64 (pow.f64 b 2) (pow.f64 a 2))) (sin.f64 (*.f64 (/.f64 angle 180) PI.f64))) (cos.f64 (*.f64 (/.f64 angle 180) PI.f64))) x-scale) y-scale) (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 2 (-.f64 (pow.f64 b 2) (pow.f64 a 2))) (sin.f64 (*.f64 (/.f64 angle 180) PI.f64))) (cos.f64 (*.f64 (/.f64 angle 180) PI.f64))) x-scale) y-scale)) (*.f64 (*.f64 4 (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle 180) PI.f64))) 2) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle 180) PI.f64))) 2)) x-scale) x-scale)) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle 180) PI.f64))) 2) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle 180) PI.f64))) 2)) y-scale) y-scale))) Initial program 39.9
Taylor expanded in a around 0 39.7
Simplified28.4
Final simplification29.3
herbie shell --seed 2021224
(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))))