\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 -1.7329648173606777 \cdot 10^{-137}:\\
\;\;\;\;-\frac{8 \cdot \frac{{a}^{2} \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {b}^{2}\right)\right)}{{y-scale}^{2}} + \left(4 \cdot \frac{{a}^{2} \cdot \left({b}^{2} \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}\right)}{{y-scale}^{2}} + 4 \cdot \frac{{a}^{2} \cdot \left({b}^{2} \cdot {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}\right)}{{y-scale}^{2}}\right)}{{x-scale}^{2}}\\
\mathbf{elif}\;y-scale \leq 3.5416718894034183 \cdot 10^{-162}:\\
\;\;\;\;\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)}{x-scale} \cdot \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}}{y-scale}}{y-scale}\\
\mathbf{elif}\;y-scale \leq 3.6337643582651225 \cdot 10^{+127}:\\
\;\;\;\;-\frac{8 \cdot \frac{{a}^{2} \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {b}^{2}\right)\right)}{{x-scale}^{2}} + \left(4 \cdot \frac{{a}^{2} \cdot \left({b}^{2} \cdot {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}\right)}{{x-scale}^{2}} + 4 \cdot \frac{{a}^{2} \cdot \left({b}^{2} \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}\right)}{{x-scale}^{2}}\right)}{{y-scale}^{2}}\\
\mathbf{elif}\;y-scale \leq 8.76096232538358 \cdot 10^{+201}:\\
\;\;\;\;\frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)}{x-scale} \cdot \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)}{x-scale}}{y-scale} - \left(4 \cdot \frac{\frac{{\left(a \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}}{y-scale}}{y-scale}\\
\mathbf{else}:\\
\;\;\;\;-{a}^{2} \cdot \left(4 \cdot \frac{{b}^{2} \cdot {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}{{y-scale}^{2} \cdot {x-scale}^{2}} + \left(8 \cdot \frac{{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {b}^{2}\right)}{{y-scale}^{2} \cdot {x-scale}^{2}} + 4 \cdot \frac{{b}^{2} \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}{{y-scale}^{2} \cdot {x-scale}^{2}}\right)\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 (<= y-scale -1.7329648173606777e-137)
(-
(/
(+
(*
8.0
(/
(*
(pow a 2.0)
(*
(pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
(*
(pow (cos (* 0.005555555555555556 (* angle PI))) 2.0)
(pow b 2.0))))
(pow y-scale 2.0)))
(+
(*
4.0
(/
(*
(pow a 2.0)
(*
(pow b 2.0)
(pow (sin (* 0.005555555555555556 (* angle PI))) 4.0)))
(pow y-scale 2.0)))
(*
4.0
(/
(*
(pow a 2.0)
(*
(pow b 2.0)
(pow (cos (* 0.005555555555555556 (* angle PI))) 4.0)))
(pow y-scale 2.0)))))
(pow x-scale 2.0)))
(if (<= y-scale 3.5416718894034183e-162)
(/
(-
(*
(/
(*
(* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* PI (/ angle 180.0))))
(cos (* PI (/ angle 180.0))))
x-scale)
(/
(/
(*
(* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* PI (/ angle 180.0))))
(cos (* PI (/ angle 180.0))))
x-scale)
y-scale))
(*
(*
4.0
(/
(/
(+
(pow (* a (sin (* PI (/ angle 180.0)))) 2.0)
(pow (* b (cos (* PI (/ angle 180.0)))) 2.0))
x-scale)
x-scale))
(/
(+
(pow (* a (cos (* PI (/ angle 180.0)))) 2.0)
(pow (* b (sin (* PI (/ angle 180.0)))) 2.0))
y-scale)))
y-scale)
(if (<= y-scale 3.6337643582651225e+127)
(-
(/
(+
(*
8.0
(/
(*
(pow a 2.0)
(*
(pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
(*
(pow (cos (* 0.005555555555555556 (* angle PI))) 2.0)
(pow b 2.0))))
(pow x-scale 2.0)))
(+
(*
4.0
(/
(*
(pow a 2.0)
(*
(pow b 2.0)
(pow (cos (* 0.005555555555555556 (* angle PI))) 4.0)))
(pow x-scale 2.0)))
(*
4.0
(/
(*
(pow a 2.0)
(*
(pow b 2.0)
(pow (sin (* 0.005555555555555556 (* angle PI))) 4.0)))
(pow x-scale 2.0)))))
(pow y-scale 2.0)))
(if (<= y-scale 8.76096232538358e+201)
(/
(-
(*
(/
(*
(*
(* 2.0 (- (pow b 2.0) (pow a 2.0)))
(sin (* PI (/ angle 180.0))))
(cos (* PI (/ angle 180.0))))
x-scale)
(/
(/
(*
(*
(* 2.0 (- (pow b 2.0) (pow a 2.0)))
(sin (* PI (/ angle 180.0))))
(cos (* PI (/ angle 180.0))))
x-scale)
y-scale))
(*
(*
4.0
(/
(/
(+
(pow (* a (sin (* PI (/ angle 180.0)))) 2.0)
(pow (* b (cos (* PI (/ angle 180.0)))) 2.0))
x-scale)
x-scale))
(/
(+
(pow (* a (cos (* PI (/ angle 180.0)))) 2.0)
(pow (* b (sin (* PI (/ angle 180.0)))) 2.0))
y-scale)))
y-scale)
(-
(*
(pow a 2.0)
(+
(*
4.0
(/
(*
(pow b 2.0)
(pow (cos (* 0.005555555555555556 (* angle PI))) 4.0))
(* (pow y-scale 2.0) (pow x-scale 2.0))))
(+
(*
8.0
(/
(*
(pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
(*
(pow (cos (* 0.005555555555555556 (* angle PI))) 2.0)
(pow b 2.0)))
(* (pow y-scale 2.0) (pow x-scale 2.0))))
(*
4.0
(/
(*
(pow b 2.0)
(pow (sin (* 0.005555555555555556 (* angle PI))) 4.0))
(* (pow y-scale 2.0) (pow x-scale 2.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 <= -1.7329648173606777e-137) {
tmp = -(((8.0 * ((pow(a, 2.0) * (pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * pow(b, 2.0)))) / pow(y_45_scale, 2.0))) + ((4.0 * ((pow(a, 2.0) * (pow(b, 2.0) * pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 4.0))) / pow(y_45_scale, 2.0))) + (4.0 * ((pow(a, 2.0) * (pow(b, 2.0) * pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 4.0))) / pow(y_45_scale, 2.0))))) / pow(x_45_scale, 2.0));
} else if (y_45_scale <= 3.5416718894034183e-162) {
tmp = ((((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin(((double) M_PI) * (angle / 180.0))) * cos(((double) M_PI) * (angle / 180.0))) / x_45_scale) * (((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin(((double) M_PI) * (angle / 180.0))) * cos(((double) M_PI) * (angle / 180.0))) / x_45_scale) / y_45_scale)) - ((4.0 * (((pow((a * sin(((double) M_PI) * (angle / 180.0))), 2.0) + pow((b * cos(((double) M_PI) * (angle / 180.0))), 2.0)) / x_45_scale) / x_45_scale)) * ((pow((a * cos(((double) M_PI) * (angle / 180.0))), 2.0) + pow((b * sin(((double) M_PI) * (angle / 180.0))), 2.0)) / y_45_scale))) / y_45_scale;
} else if (y_45_scale <= 3.6337643582651225e+127) {
tmp = -(((8.0 * ((pow(a, 2.0) * (pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * pow(b, 2.0)))) / pow(x_45_scale, 2.0))) + ((4.0 * ((pow(a, 2.0) * (pow(b, 2.0) * pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 4.0))) / pow(x_45_scale, 2.0))) + (4.0 * ((pow(a, 2.0) * (pow(b, 2.0) * pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 4.0))) / pow(x_45_scale, 2.0))))) / pow(y_45_scale, 2.0));
} else if (y_45_scale <= 8.76096232538358e+201) {
tmp = ((((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin(((double) M_PI) * (angle / 180.0))) * cos(((double) M_PI) * (angle / 180.0))) / x_45_scale) * (((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin(((double) M_PI) * (angle / 180.0))) * cos(((double) M_PI) * (angle / 180.0))) / x_45_scale) / y_45_scale)) - ((4.0 * (((pow((a * sin(((double) M_PI) * (angle / 180.0))), 2.0) + pow((b * cos(((double) M_PI) * (angle / 180.0))), 2.0)) / x_45_scale) / x_45_scale)) * ((pow((a * cos(((double) M_PI) * (angle / 180.0))), 2.0) + pow((b * sin(((double) M_PI) * (angle / 180.0))), 2.0)) / y_45_scale))) / y_45_scale;
} else {
tmp = -(pow(a, 2.0) * ((4.0 * ((pow(b, 2.0) * pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 4.0)) / (pow(y_45_scale, 2.0) * pow(x_45_scale, 2.0)))) + ((8.0 * ((pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * pow(b, 2.0))) / (pow(y_45_scale, 2.0) * pow(x_45_scale, 2.0)))) + (4.0 * ((pow(b, 2.0) * pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 4.0)) / (pow(y_45_scale, 2.0) * pow(x_45_scale, 2.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 y-scale < -1.7329648173606777e-137Initial program 39.9
Taylor expanded around 0 34.9
if -1.7329648173606777e-137 < y-scale < 3.5416718894034183e-162 or 3.63376435826512253e127 < y-scale < 8.7609623253835804e201Initial program 46.5
rmApplied associate-*r/_binary64_172544.4
Applied associate-*l/_binary64_172643.4
Applied sub-div_binary64_179043.4
if 3.5416718894034183e-162 < y-scale < 3.63376435826512253e127Initial program 40.9
Taylor expanded around 0 33.3
if 8.7609623253835804e201 < y-scale Initial program 35.7
Taylor expanded around 0 35.4
Final simplification36.6
herbie shell --seed 2021058
(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))))