\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}\;b \leq -6.1587270237545874 \cdot 10^{+231} \lor \neg \left(b \leq -5.990122747829383 \cdot 10^{+177}\right):\\
\;\;\;\;-4 \cdot \left(\left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right) \cdot \left(\frac{a}{x-scale} \cdot \frac{b}{y-scale}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{{\left(b \cdot a\right)}^{2}}{\left(x-scale \cdot y-scale\right) \cdot \left(x-scale \cdot y-scale\right)}\\
\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 (or (<= b -6.1587270237545874e+231) (not (<= b -5.990122747829383e+177))) (* -4.0 (* (* (/ a x-scale) (/ b y-scale)) (* (/ a x-scale) (/ b y-scale)))) (* -4.0 (/ (pow (* b a) 2.0) (* (* x-scale y-scale) (* x-scale y-scale))))))
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 ((b <= -6.1587270237545874e+231) || !(b <= -5.990122747829383e+177)) {
tmp = -4.0 * (((a / x_45_scale) * (b / y_45_scale)) * ((a / x_45_scale) * (b / y_45_scale)));
} else {
tmp = -4.0 * (pow((b * a), 2.0) / ((x_45_scale * y_45_scale) * (x_45_scale * y_45_scale)));
}
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 b < -6.15872702375458742e231 or -5.9901227478293832e177 < b Initial program 40.5
Taylor expanded around 0 39.0
Simplified36.0
rmApplied pow2_binary64_186436.0
Applied pow2_binary64_186436.0
Applied pow-prod-down_binary64_185426.9
rmApplied add-sqr-sqrt_binary64_180526.9
Simplified28.4
Simplified5.9
if -6.15872702375458742e231 < b < -5.9901227478293832e177Initial program 64.0
Taylor expanded around 0 64.0
Simplified64.0
rmApplied pow2_binary64_186464.0
Applied pow2_binary64_186464.0
Applied pow-prod-down_binary64_185434.2
rmApplied add-sqr-sqrt_binary64_180534.2
Simplified34.2
Simplified25.1
Final simplification6.5
herbie shell --seed 2020358
(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))))