\frac{-\sqrt{\left(\left(2 \cdot \frac{4 \cdot \left(\left(b \cdot a\right) \cdot \left(b \cdot \left(-a\right)\right)\right)}{{\left(x-scale \cdot y-scale\right)}^{2}}\right) \cdot \left(\left(b \cdot a\right) \cdot \left(b \cdot \left(-a\right)\right)\right)\right) \cdot \left(\left(\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} + \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}\right) + \sqrt{{\left(\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} - \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}\right)}^{2} + {\left(\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}\right)}^{2}}\right)}}{\frac{4 \cdot \left(\left(b \cdot a\right) \cdot \left(b \cdot \left(-a\right)\right)\right)}{{\left(x-scale \cdot y-scale\right)}^{2}}}\begin{array}{l}
\mathbf{if}\;x-scale \leq 2.1817530525056398 \cdot 10^{-76}:\\
\;\;\;\;0.25 \cdot \left(\left(y-scale \cdot \sqrt{8}\right) \cdot \sqrt{\left(a \cdot a\right) \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} + \left(b \cdot b + \sqrt{{a}^{4} \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} + \left({b}^{4} + 2 \cdot \left(\left(a \cdot a\right) \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left(\left(b \cdot b\right) \cdot {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}\right)\right)\right)\right)}\right)}\right)\\
\mathbf{elif}\;x-scale \leq 15654183408095428:\\
\;\;\;\;\left(\sqrt{\frac{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}}{x-scale \cdot x-scale} + \left(\sqrt{2 \cdot \frac{{\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}}{{\left(x-scale \cdot y-scale\right)}^{2}} + \left(\frac{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}{{x-scale}^{4}} + \frac{{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}{{y-scale}^{4}}\right)} + \frac{{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}}{y-scale \cdot y-scale}\right)} \cdot \left(\sqrt{8} \cdot \left(b \cdot \left(x-scale \cdot y-scale\right)\right)\right)\right) \cdot -0.25\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\left(x-scale \cdot \sqrt{8}\right) \cdot \sqrt{\left(a \cdot a\right) \cdot {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} + \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left(b \cdot b\right) + \sqrt{{a}^{4} \cdot {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} + \left(2 \cdot \left(\left(a \cdot a\right) \cdot \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left(\left(b \cdot b\right) \cdot {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}\right)\right)\right) + {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {b}^{4}\right)}\right)}\right)\\
\end{array}(FPCore (a b angle x-scale y-scale)
:precision binary64
(/
(-
(sqrt
(*
(*
(* 2.0 (/ (* 4.0 (* (* b a) (* b (- a)))) (pow (* x-scale y-scale) 2.0)))
(* (* b a) (* b (- a))))
(+
(+
(/
(/
(+
(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))
(sqrt
(+
(pow
(-
(/
(/
(+
(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))
2.0)
(pow
(/
(/
(*
(*
(* 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)))))))
(/ (* 4.0 (* (* b a) (* b (- a)))) (pow (* x-scale y-scale) 2.0))))(FPCore (a b angle x-scale y-scale)
:precision binary64
(if (<= x-scale 2.1817530525056398e-76)
(*
0.25
(*
(* y-scale (sqrt 8.0))
(sqrt
(+
(* (* a a) (pow (sin (* 0.005555555555555556 (* angle PI))) 2.0))
(+
(* b b)
(sqrt
(+
(* (pow a 4.0) (pow (sin (* 0.005555555555555556 (* angle PI))) 4.0))
(+
(pow b 4.0)
(*
2.0
(*
(* a a)
(*
(pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
(*
(* b b)
(pow
(cos (* 0.005555555555555556 (* angle PI)))
2.0)))))))))))))
(if (<= x-scale 15654183408095428.0)
(*
(*
(sqrt
(+
(/
(pow (cos (* 0.005555555555555556 (* angle PI))) 2.0)
(* x-scale x-scale))
(+
(sqrt
(+
(*
2.0
(/
(*
(pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
(pow (cos (* 0.005555555555555556 (* angle PI))) 2.0))
(pow (* x-scale y-scale) 2.0)))
(+
(/
(pow (cos (* 0.005555555555555556 (* angle PI))) 4.0)
(pow x-scale 4.0))
(/
(pow (sin (* 0.005555555555555556 (* angle PI))) 4.0)
(pow y-scale 4.0)))))
(/
(pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
(* y-scale y-scale)))))
(* (sqrt 8.0) (* b (* x-scale y-scale))))
-0.25)
(*
0.25
(*
(* x-scale (sqrt 8.0))
(sqrt
(+
(* (* a a) (pow (cos (* 0.005555555555555556 (* angle PI))) 2.0))
(+
(* (pow (sin (* 0.005555555555555556 (* angle PI))) 2.0) (* b b))
(sqrt
(+
(*
(pow a 4.0)
(pow (cos (* 0.005555555555555556 (* angle PI))) 4.0))
(+
(*
2.0
(*
(* a a)
(*
(pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
(*
(* b b)
(pow (cos (* 0.005555555555555556 (* angle PI))) 2.0)))))
(*
(pow (sin (* 0.005555555555555556 (* angle PI))) 4.0)
(pow b 4.0)))))))))))))double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return -sqrt(((2.0 * ((4.0 * ((b * a) * (b * -a))) / pow((x_45_scale * y_45_scale), 2.0))) * ((b * a) * (b * -a))) * (((((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)) + sqrt(pow(((((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)), 2.0) + pow((((((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)))) / ((4.0 * ((b * a) * (b * -a))) / pow((x_45_scale * y_45_scale), 2.0));
}
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double tmp;
if (x_45_scale <= 2.1817530525056398e-76) {
tmp = 0.25 * ((y_45_scale * sqrt(8.0)) * sqrt(((a * a) * pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0)) + ((b * b) + sqrt((pow(a, 4.0) * pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 4.0)) + (pow(b, 4.0) + (2.0 * ((a * a) * (pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * ((b * b) * pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0))))))))));
} else if (x_45_scale <= 15654183408095428.0) {
tmp = (sqrt((pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) / (x_45_scale * x_45_scale)) + (sqrt((2.0 * ((pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0)) / pow((x_45_scale * y_45_scale), 2.0))) + ((pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 4.0) / pow(x_45_scale, 4.0)) + (pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 4.0) / pow(y_45_scale, 4.0)))) + (pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) / (y_45_scale * y_45_scale)))) * (sqrt(8.0) * (b * (x_45_scale * y_45_scale)))) * -0.25;
} else {
tmp = 0.25 * ((x_45_scale * sqrt(8.0)) * sqrt(((a * a) * pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0)) + ((pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (b * b)) + sqrt((pow(a, 4.0) * pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 4.0)) + ((2.0 * ((a * a) * (pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * ((b * b) * pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0))))) + (pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 4.0) * pow(b, 4.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 x-scale < 2.1817530525056398e-76Initial program 63.6
Taylor expanded around 0 58.4
Simplified58.4
Taylor expanded around 0 58.4
Taylor expanded around 0 58.4
if 2.1817530525056398e-76 < x-scale < 15654183408095428Initial program 63.1
Taylor expanded around -inf 56.0
Simplified56.0
if 15654183408095428 < x-scale Initial program 63.3
Taylor expanded around 0 51.7
Simplified51.7
Final simplification56.9
herbie shell --seed 2021015
(FPCore (a b angle x-scale y-scale)
:name "a from scale-rotated-ellipse"
:precision binary64
(/ (- (sqrt (* (* (* 2.0 (/ (* 4.0 (* (* b a) (* b (- a)))) (pow (* x-scale y-scale) 2.0))) (* (* b a) (* b (- a)))) (+ (+ (/ (/ (+ (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)) (sqrt (+ (pow (- (/ (/ (+ (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)) 2.0) (pow (/ (/ (* (* (* 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))))))) (/ (* 4.0 (* (* b a) (* b (- a)))) (pow (* x-scale y-scale) 2.0))))