\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}\;y-scale \leq 3.382588394384935 \cdot 10^{-302}:\\
\;\;\;\;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({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {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({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left(b \cdot b\right)\right)\right)\right)\right)}\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;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({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {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(b \cdot b\right)\right)\right)\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 (<= y-scale 3.382588394384935e-302)
(*
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))
(+
(*
(pow (sin (* 0.005555555555555556 (* angle PI))) 4.0)
(pow b 4.0))
(*
2.0
(*
(* a a)
(*
(pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
(*
(pow (cos (* 0.005555555555555556 (* angle PI))) 2.0)
(* b b)))))))))))))
(*
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 (cos (* 0.005555555555555556 (* angle PI))) 4.0)
(pow b 4.0))
(*
2.0
(*
(* a a)
(*
(pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
(* b b))))))))))))))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 (y_45_scale <= 3.382588394384935e-302) {
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)) + ((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) * (pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (b * b))))))))));
} else {
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(cos(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)))))))));
}
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.382588394384935e-302Initial program 63.5
Taylor expanded around 0 59.4
Simplified59.4
if 3.382588394384935e-302 < y-scale Initial program 63.4
Taylor expanded around 0 55.5
Simplified55.5
Taylor expanded around 0 55.6
Taylor expanded around 0 55.6
Final simplification57.5
herbie shell --seed 2021020
(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))))