\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.111515566880726 \cdot 10^{-12}:\\
\;\;\;\;0.25 \cdot \left(\left(a \cdot \left(\sqrt{8} \cdot \left(x-scale \cdot y-scale\right)\right)\right) \cdot \sqrt{\frac{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}}{y-scale \cdot y-scale} + \left(\frac{{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}}{x-scale \cdot x-scale} + \sqrt{\frac{{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}{{x-scale}^{4}} + \left(2 \cdot \frac{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot {\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2}}{{\left(x-scale \cdot y-scale\right)}^{2}} + \frac{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4}}{{y-scale}^{4}}\right)}\right)}\right)\\
\mathbf{elif}\;x-scale \leq 1.1057039992029384 \cdot 10^{-242}:\\
\;\;\;\;0.25 \cdot \left(\left(\sqrt{8} \cdot y-scale\right) \cdot \sqrt{\left(a \cdot a\right) \cdot {\log \left(e^{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}\right)}^{2} + \left({\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left(b \cdot b\right) + \sqrt{{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {a}^{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({\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(x-scale \cdot \sqrt{8}\right) \cdot \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left(a \cdot a\right) + \left({\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot \left(b \cdot b\right) + \sqrt{{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{4} \cdot {a}^{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(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 (<= x-scale -2.111515566880726e-12)
(*
0.25
(*
(* a (* (sqrt 8.0) (* x-scale y-scale)))
(sqrt
(+
(/
(pow (cos (* 0.005555555555555556 (* angle PI))) 2.0)
(* y-scale y-scale))
(+
(/
(pow (sin (* 0.005555555555555556 (* angle PI))) 2.0)
(* x-scale x-scale))
(sqrt
(+
(/
(pow (sin (* 0.005555555555555556 (* angle PI))) 4.0)
(pow x-scale 4.0))
(+
(*
2.0
(/
(*
(pow (cos (* 0.005555555555555556 (* angle PI))) 2.0)
(pow (sin (* 0.005555555555555556 (* angle PI))) 2.0))
(pow (* x-scale y-scale) 2.0)))
(/
(pow (cos (* 0.005555555555555556 (* angle PI))) 4.0)
(pow y-scale 4.0))))))))))
(if (<= x-scale 1.1057039992029384e-242)
(*
0.25
(*
(* (sqrt 8.0) y-scale)
(sqrt
(+
(*
(* a a)
(pow (log (exp (sin (* 0.005555555555555556 (* angle PI))))) 2.0))
(+
(* (pow (cos (* 0.005555555555555556 (* angle PI))) 2.0) (* b b))
(sqrt
(+
(*
(pow (sin (* 0.005555555555555556 (* angle PI))) 4.0)
(pow a 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)
(*
(pow (cos (* 0.005555555555555556 (* angle PI))) 2.0)
(* b b)))))))))))))
(*
0.25
(*
(* x-scale (sqrt 8.0))
(sqrt
(+
(* (pow (cos (* 0.005555555555555556 (* angle PI))) 2.0) (* a a))
(+
(* (pow (sin (* 0.005555555555555556 (* angle PI))) 2.0) (* b b))
(sqrt
(+
(*
(pow (cos (* 0.005555555555555556 (* angle PI))) 4.0)
(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)))))))))))))))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.111515566880726e-12) {
tmp = 0.25 * ((a * (sqrt(8.0) * (x_45_scale * y_45_scale))) * sqrt((pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) / (y_45_scale * y_45_scale)) + ((pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) / (x_45_scale * x_45_scale)) + sqrt((pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 4.0) / pow(x_45_scale, 4.0)) + ((2.0 * ((pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * pow(sin(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(y_45_scale, 4.0)))))));
} else if (x_45_scale <= 1.1057039992029384e-242) {
tmp = 0.25 * ((sqrt(8.0) * y_45_scale) * sqrt(((a * a) * pow(log(exp(sin(0.005555555555555556 * (angle * ((double) M_PI))))), 2.0)) + ((pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (b * b)) + sqrt((pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 4.0) * pow(a, 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) * (pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (b * b))))))))));
} else {
tmp = 0.25 * ((x_45_scale * sqrt(8.0)) * sqrt((pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (a * a)) + ((pow(sin(0.005555555555555556 * (angle * ((double) M_PI))), 2.0) * (b * b)) + sqrt((pow(cos(0.005555555555555556 * (angle * ((double) M_PI))), 4.0) * 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)))))))));
}
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.111515566880726e-12Initial program 63.4
Taylor expanded around inf 60.7
Simplified60.7
if -2.111515566880726e-12 < x-scale < 1.1057039992029384e-242Initial program 63.6
Taylor expanded around 0 56.9
Simplified56.9
rmApplied add-log-exp_binary6457.1
if 1.1057039992029384e-242 < x-scale Initial program 63.4
Taylor expanded around 0 55.3
Simplified55.3
Taylor expanded around 0 55.3
Final simplification57.2
herbie shell --seed 2021148
(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))))