\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 -3.385064100868585 \cdot 10^{-109}:\\
\;\;\;\;-\left(4 \cdot \frac{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {b}^{2}}{{x-scale}^{2} \cdot {y-scale}^{2}} + \left(8 \cdot \frac{{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({b}^{2} \cdot {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}\right)}{{x-scale}^{2} \cdot {y-scale}^{2}} + 4 \cdot \frac{{b}^{2} \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}{{x-scale}^{2} \cdot {y-scale}^{2}}\right)\right) \cdot {a}^{2}\\
\mathbf{elif}\;y-scale \leq 6.4656518320160655 \cdot 10^{-124}:\\
\;\;\;\;\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 \left(\sqrt[3]{\sin \left(\pi \cdot \frac{angle}{180}\right)} \cdot \left(\sqrt[3]{\sin \left(\pi \cdot \frac{angle}{180}\right)} \cdot \sqrt[3]{\sin \left(\pi \cdot \frac{angle}{180}\right)}\right)\right)\right)}^{2}}{y-scale}}{y-scale}\\
\mathbf{elif}\;y-scale \leq 5.339580685756118 \cdot 10^{+148}:\\
\;\;\;\;-\frac{8 \cdot \frac{\left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left({b}^{2} \cdot {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}\right)\right) \cdot {a}^{2}}{{y-scale}^{2}} + \left(4 \cdot \frac{\left({b}^{2} \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}\right) \cdot {a}^{2}}{{y-scale}^{2}} + 4 \cdot \frac{\left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {b}^{2}\right) \cdot {a}^{2}}{{y-scale}^{2}}\right)}{{x-scale}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x-scale \cdot \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) - 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{\frac{{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \left(\sqrt[3]{\sin \left(\pi \cdot \frac{angle}{180}\right)} \cdot \left(\sqrt[3]{\sin \left(\pi \cdot \frac{angle}{180}\right)} \cdot \sqrt[3]{\sin \left(\pi \cdot \frac{angle}{180}\right)}\right)\right)\right)}^{2}}{y-scale}}{y-scale}\right)}{y-scale \cdot x-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 (<= y-scale -3.385064100868585e-109)
(-
(*
(+
(*
4.0
(/
(* (pow (cos (* 0.005555555555555556 (* angle PI))) 4.0) (pow b 2.0))
(* (pow x-scale 2.0) (pow y-scale 2.0))))
(+
(*
8.0
(/
(*
(pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
(*
(pow b 2.0)
(pow (cos (* 0.005555555555555556 (* angle PI))) 2.0)))
(* (pow x-scale 2.0) (pow y-scale 2.0))))
(*
4.0
(/
(* (pow b 2.0) (pow (sin (* 0.005555555555555556 (* angle PI))) 4.0))
(* (pow x-scale 2.0) (pow y-scale 2.0))))))
(pow a 2.0)))
(if (<= y-scale 6.4656518320160655e-124)
(/
(-
(*
(/
(*
(* (* 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
(*
(cbrt (sin (* PI (/ angle 180.0))))
(*
(cbrt (sin (* PI (/ angle 180.0))))
(cbrt (sin (* PI (/ angle 180.0)))))))
2.0))
y-scale)))
y-scale)
(if (<= y-scale 5.339580685756118e+148)
(-
(/
(+
(*
8.0
(/
(*
(*
(pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
(*
(pow b 2.0)
(pow (cos (* 0.005555555555555556 (* angle PI))) 2.0)))
(pow a 2.0))
(pow y-scale 2.0)))
(+
(*
4.0
(/
(*
(*
(pow b 2.0)
(pow (sin (* 0.005555555555555556 (* angle PI))) 4.0))
(pow a 2.0))
(pow y-scale 2.0)))
(*
4.0
(/
(*
(*
(pow (cos (* 0.005555555555555556 (* angle PI))) 4.0)
(pow b 2.0))
(pow a 2.0))
(pow y-scale 2.0)))))
(pow x-scale 2.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)
(/
(/
(*
(*
(* 2.0 (- (pow b 2.0) (pow a 2.0)))
(sin (* PI (/ angle 180.0))))
(cos (* PI (/ angle 180.0))))
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
(*
(cbrt (sin (* PI (/ angle 180.0))))
(*
(cbrt (sin (* PI (/ angle 180.0))))
(cbrt (sin (* PI (/ angle 180.0)))))))
2.0))
y-scale)
y-scale))))
(* y-scale x-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 (y_45_scale <= -3.385064100868585e-109) {
tmp = -(((4.0 * ((pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 4.0) * pow(b, 2.0)) / (pow(x_45_scale, 2.0) * pow(y_45_scale, 2.0)))) + ((8.0 * ((pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (pow(b, 2.0) * pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0))) / (pow(x_45_scale, 2.0) * pow(y_45_scale, 2.0)))) + (4.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)))))) * pow(a, 2.0));
} else if (y_45_scale <= 6.4656518320160655e-124) {
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 * (cbrt(sin(((double) M_PI) * (angle / 180.0))) * (cbrt(sin(((double) M_PI) * (angle / 180.0))) * cbrt(sin(((double) M_PI) * (angle / 180.0)))))), 2.0)) / y_45_scale))) / y_45_scale;
} else if (y_45_scale <= 5.339580685756118e+148) {
tmp = -(((8.0 * (((pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (pow(b, 2.0) * pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0))) * pow(a, 2.0)) / pow(y_45_scale, 2.0))) + ((4.0 * (((pow(b, 2.0) * pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 4.0)) * pow(a, 2.0)) / pow(y_45_scale, 2.0))) + (4.0 * (((pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 4.0) * pow(b, 2.0)) * pow(a, 2.0)) / pow(y_45_scale, 2.0))))) / pow(x_45_scale, 2.0));
} else {
tmp = ((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) * (((((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))) - (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 * (cbrt(sin(((double) M_PI) * (angle / 180.0))) * (cbrt(sin(((double) M_PI) * (angle / 180.0))) * cbrt(sin(((double) M_PI) * (angle / 180.0)))))), 2.0)) / y_45_scale) / y_45_scale)))) / (y_45_scale * x_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 y-scale < -3.3850641008685852e-109Initial program 38.4
rmApplied add-cube-cbrt_binary64_11338.6
Simplified38.6
Simplified38.6
Taylor expanded around 0 34.4
if -3.3850641008685852e-109 < y-scale < 6.4656518320160655e-124Initial program 50.5
rmApplied add-cube-cbrt_binary64_11350.6
Simplified50.6
Simplified50.6
rmApplied associate-*r/_binary64_2048.4
Applied associate-*l/_binary64_2147.0
Applied sub-div_binary64_8547.0
if 6.4656518320160655e-124 < y-scale < 5.3395806857561178e148Initial program 39.2
rmApplied add-cube-cbrt_binary64_11339.8
Simplified39.8
Simplified39.8
Taylor expanded around 0 32.5
if 5.3395806857561178e148 < y-scale Initial program 37.0
rmApplied add-cube-cbrt_binary64_11337.0
Simplified37.0
Simplified37.0
rmApplied associate-*r/_binary64_2037.0
Applied associate-*l/_binary64_2136.2
Applied associate-*l/_binary64_2136.2
Applied frac-sub_binary64_8735.5
Final simplification36.7
herbie shell --seed 2021059
(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))))