\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}\;x-scale \leq -9.686447355558264 \cdot 10^{-85}:\\
\;\;\;\;-\frac{8 \cdot \frac{\left(a \cdot a\right) \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 \left(b \cdot b\right)\right)\right)}{x-scale \cdot x-scale} + 4 \cdot \left(\frac{a \cdot a}{x-scale \cdot x-scale} \cdot \left(\left(b \cdot b\right) \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} + \left(b \cdot b\right) \cdot {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}\right)\right)}{y-scale \cdot y-scale}\\
\mathbf{elif}\;x-scale \leq 2.0170200688955704 \cdot 10^{-213}:\\
\;\;\;\;\frac{\left(\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}\right) \cdot \left(x-scale \cdot y-scale\right) - y-scale \cdot \left(\left(4 \cdot \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}\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}\right)}{y-scale \cdot \left(x-scale \cdot y-scale\right)}\\
\mathbf{elif}\;x-scale \leq 7.323676854415406 \cdot 10^{+156}:\\
\;\;\;\;\left(8 \cdot \frac{\left(a \cdot a\right) \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}\right)}{\left(x-scale \cdot x-scale\right) \cdot \left(y-scale \cdot y-scale\right)} + 4 \cdot \left(\frac{a \cdot a}{\left(x-scale \cdot x-scale\right) \cdot \left(y-scale \cdot y-scale\right)} \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} + {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}\right)\right)\right) \cdot \left(-b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\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} - \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} \cdot \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)}{y-scale}\\
\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 (<= x-scale -9.686447355558264e-85)
(-
(/
(+
(*
8.0
(/
(*
(* a a)
(*
(pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
(* (pow (cos (* 0.005555555555555556 (* angle PI))) 2.0) (* b b))))
(* x-scale x-scale)))
(*
4.0
(*
(/ (* a a) (* x-scale x-scale))
(+
(* (* b b) (pow (sin (* 0.005555555555555556 (* angle PI))) 4.0))
(* (* b b) (pow (cos (* 0.005555555555555556 (* angle PI))) 4.0))))))
(* y-scale y-scale)))
(if (<= x-scale 2.0170200688955704e-213)
(/
(-
(*
(*
(/
(*
(* (* 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))
(* x-scale y-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))
(/
(+
(pow (* a (cos (* PI (/ angle 180.0)))) 2.0)
(pow (* b (sin (* PI (/ angle 180.0)))) 2.0))
y-scale))))
(* y-scale (* x-scale y-scale)))
(if (<= x-scale 7.323676854415406e+156)
(*
(+
(*
8.0
(/
(*
(* a a)
(*
(pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
(pow (cos (* 0.005555555555555556 (* angle PI))) 2.0)))
(* (* x-scale x-scale) (* y-scale y-scale))))
(*
4.0
(*
(/ (* a a) (* (* x-scale x-scale) (* y-scale y-scale)))
(+
(pow (sin (* 0.005555555555555556 (* angle PI))) 4.0)
(pow (cos (* 0.005555555555555556 (* angle PI))) 4.0)))))
(- (* b b)))
(/
(-
(*
(/
(*
(*
(* 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))
(*
(/
(+
(pow (* a (cos (* PI (/ angle 180.0)))) 2.0)
(pow (* b (sin (* PI (/ angle 180.0)))) 2.0))
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))))
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 (x_45_scale <= -9.686447355558264e-85) {
tmp = -(((8.0 * (((a * a) * (pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (b * b)))) / (x_45_scale * x_45_scale))) + (4.0 * (((a * a) / (x_45_scale * x_45_scale)) * (((b * b) * pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 4.0)) + ((b * b) * pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 4.0)))))) / (y_45_scale * y_45_scale));
} else if (x_45_scale <= 2.0170200688955704e-213) {
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)) * (x_45_scale * y_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)) * ((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 * (x_45_scale * y_45_scale));
} else if (x_45_scale <= 7.323676854415406e+156) {
tmp = ((8.0 * (((a * a) * (pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0))) / ((x_45_scale * x_45_scale) * (y_45_scale * y_45_scale)))) + (4.0 * (((a * a) / ((x_45_scale * x_45_scale) * (y_45_scale * y_45_scale))) * (pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 4.0) + pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 4.0))))) * -(b * b);
} else {
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)) - (((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) * (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)))) / 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 x-scale < -9.68644735555826416e-85Initial program 38.5
Taylor expanded around 0 35.7
Simplified35.8
if -9.68644735555826416e-85 < x-scale < 2.0170200688955704e-213Initial program 50.7
rmApplied associate-*r/_binary64_2050.7
Applied frac-times_binary64_8848.0
Applied associate-*l/_binary64_2147.9
Applied frac-sub_binary64_8748.2
if 2.0170200688955704e-213 < x-scale < 7.3236768544154057e156Initial program 41.4
Taylor expanded around 0 36.4
Simplified36.4
if 7.3236768544154057e156 < x-scale Initial program 37.2
rmApplied associate-*r/_binary64_2035.7
Applied associate-*l/_binary64_2134.8
Applied sub-div_binary64_8534.9
Final simplification37.9
herbie shell --seed 2021007
(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))))