(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
(let* ((t_0 (* -4.0 (pow (/ b (* (/ x-scale a) y-scale)) 2.0))))
(if (<= a -1.8e+256)
t_0
(if (<= a -2.8e-197)
(* -4.0 (pow (/ (* a b) (* x-scale y-scale)) 2.0))
(if (<= a -2.05e-272)
t_0
(if (<= a 3.8e-97)
(* -4.0 (pow (/ a (* x-scale (/ y-scale b))) 2.0))
(* -4.0 (pow (/ b (/ x-scale (/ a y-scale))) 2.0))))))))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 t_0 = -4.0 * pow((b / ((x_45_scale / a) * y_45_scale)), 2.0);
double tmp;
if (a <= -1.8e+256) {
tmp = t_0;
} else if (a <= -2.8e-197) {
tmp = -4.0 * pow(((a * b) / (x_45_scale * y_45_scale)), 2.0);
} else if (a <= -2.05e-272) {
tmp = t_0;
} else if (a <= 3.8e-97) {
tmp = -4.0 * pow((a / (x_45_scale * (y_45_scale / b))), 2.0);
} else {
tmp = -4.0 * pow((b / (x_45_scale / (a / y_45_scale))), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return ((((((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * Math.sin(((angle / 180.0) * Math.PI))) * Math.cos(((angle / 180.0) * Math.PI))) / x_45_scale) / y_45_scale) * (((((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * Math.sin(((angle / 180.0) * Math.PI))) * Math.cos(((angle / 180.0) * Math.PI))) / x_45_scale) / y_45_scale)) - ((4.0 * (((Math.pow((a * Math.sin(((angle / 180.0) * Math.PI))), 2.0) + Math.pow((b * Math.cos(((angle / 180.0) * Math.PI))), 2.0)) / x_45_scale) / x_45_scale)) * (((Math.pow((a * Math.cos(((angle / 180.0) * Math.PI))), 2.0) + Math.pow((b * Math.sin(((angle / 180.0) * Math.PI))), 2.0)) / y_45_scale) / y_45_scale));
}
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = -4.0 * Math.pow((b / ((x_45_scale / a) * y_45_scale)), 2.0);
double tmp;
if (a <= -1.8e+256) {
tmp = t_0;
} else if (a <= -2.8e-197) {
tmp = -4.0 * Math.pow(((a * b) / (x_45_scale * y_45_scale)), 2.0);
} else if (a <= -2.05e-272) {
tmp = t_0;
} else if (a <= 3.8e-97) {
tmp = -4.0 * Math.pow((a / (x_45_scale * (y_45_scale / b))), 2.0);
} else {
tmp = -4.0 * Math.pow((b / (x_45_scale / (a / y_45_scale))), 2.0);
}
return tmp;
}
def code(a, b, angle, x_45_scale, y_45_scale): return ((((((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * math.sin(((angle / 180.0) * math.pi))) * math.cos(((angle / 180.0) * math.pi))) / x_45_scale) / y_45_scale) * (((((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * math.sin(((angle / 180.0) * math.pi))) * math.cos(((angle / 180.0) * math.pi))) / x_45_scale) / y_45_scale)) - ((4.0 * (((math.pow((a * math.sin(((angle / 180.0) * math.pi))), 2.0) + math.pow((b * math.cos(((angle / 180.0) * math.pi))), 2.0)) / x_45_scale) / x_45_scale)) * (((math.pow((a * math.cos(((angle / 180.0) * math.pi))), 2.0) + math.pow((b * math.sin(((angle / 180.0) * math.pi))), 2.0)) / y_45_scale) / y_45_scale))
def code(a, b, angle, x_45_scale, y_45_scale): t_0 = -4.0 * math.pow((b / ((x_45_scale / a) * y_45_scale)), 2.0) tmp = 0 if a <= -1.8e+256: tmp = t_0 elif a <= -2.8e-197: tmp = -4.0 * math.pow(((a * b) / (x_45_scale * y_45_scale)), 2.0) elif a <= -2.05e-272: tmp = t_0 elif a <= 3.8e-97: tmp = -4.0 * math.pow((a / (x_45_scale * (y_45_scale / b))), 2.0) else: tmp = -4.0 * math.pow((b / (x_45_scale / (a / y_45_scale))), 2.0) return tmp
function code(a, b, angle, x_45_scale, y_45_scale) return Float64(Float64(Float64(Float64(Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * sin(Float64(Float64(angle / 180.0) * pi))) * cos(Float64(Float64(angle / 180.0) * pi))) / x_45_scale) / y_45_scale) * Float64(Float64(Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * sin(Float64(Float64(angle / 180.0) * pi))) * cos(Float64(Float64(angle / 180.0) * pi))) / x_45_scale) / y_45_scale)) - Float64(Float64(4.0 * Float64(Float64(Float64((Float64(a * sin(Float64(Float64(angle / 180.0) * pi))) ^ 2.0) + (Float64(b * cos(Float64(Float64(angle / 180.0) * pi))) ^ 2.0)) / x_45_scale) / x_45_scale)) * Float64(Float64(Float64((Float64(a * cos(Float64(Float64(angle / 180.0) * pi))) ^ 2.0) + (Float64(b * sin(Float64(Float64(angle / 180.0) * pi))) ^ 2.0)) / y_45_scale) / y_45_scale))) end
function code(a, b, angle, x_45_scale, y_45_scale) t_0 = Float64(-4.0 * (Float64(b / Float64(Float64(x_45_scale / a) * y_45_scale)) ^ 2.0)) tmp = 0.0 if (a <= -1.8e+256) tmp = t_0; elseif (a <= -2.8e-197) tmp = Float64(-4.0 * (Float64(Float64(a * b) / Float64(x_45_scale * y_45_scale)) ^ 2.0)); elseif (a <= -2.05e-272) tmp = t_0; elseif (a <= 3.8e-97) tmp = Float64(-4.0 * (Float64(a / Float64(x_45_scale * Float64(y_45_scale / b))) ^ 2.0)); else tmp = Float64(-4.0 * (Float64(b / Float64(x_45_scale / Float64(a / y_45_scale))) ^ 2.0)); end return tmp end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) tmp = ((((((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * sin(((angle / 180.0) * pi))) * cos(((angle / 180.0) * pi))) / x_45_scale) / y_45_scale) * (((((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * sin(((angle / 180.0) * pi))) * cos(((angle / 180.0) * pi))) / x_45_scale) / y_45_scale)) - ((4.0 * (((((a * sin(((angle / 180.0) * pi))) ^ 2.0) + ((b * cos(((angle / 180.0) * pi))) ^ 2.0)) / x_45_scale) / x_45_scale)) * (((((a * cos(((angle / 180.0) * pi))) ^ 2.0) + ((b * sin(((angle / 180.0) * pi))) ^ 2.0)) / y_45_scale) / y_45_scale)); end
function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale) t_0 = -4.0 * ((b / ((x_45_scale / a) * y_45_scale)) ^ 2.0); tmp = 0.0; if (a <= -1.8e+256) tmp = t_0; elseif (a <= -2.8e-197) tmp = -4.0 * (((a * b) / (x_45_scale * y_45_scale)) ^ 2.0); elseif (a <= -2.05e-272) tmp = t_0; elseif (a <= 3.8e-97) tmp = -4.0 * ((a / (x_45_scale * (y_45_scale / b))) ^ 2.0); else tmp = -4.0 * ((b / (x_45_scale / (a / y_45_scale))) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(N[(N[(N[(N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / x$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision] * N[(N[(N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / x$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]), $MachinePrecision] - N[(N[(4.0 * N[(N[(N[(N[Power[N[(a * N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / x$45$scale), $MachinePrecision] / x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Power[N[(a * N[Cos[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(-4.0 * N[Power[N[(b / N[(N[(x$45$scale / a), $MachinePrecision] * y$45$scale), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -1.8e+256], t$95$0, If[LessEqual[a, -2.8e-197], N[(-4.0 * N[Power[N[(N[(a * b), $MachinePrecision] / N[(x$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, -2.05e-272], t$95$0, If[LessEqual[a, 3.8e-97], N[(-4.0 * N[Power[N[(a / N[(x$45$scale * N[(y$45$scale / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[Power[N[(b / N[(x$45$scale / N[(a / y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]]]]
\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}
t_0 := -4 \cdot {\left(\frac{b}{\frac{x-scale}{a} \cdot y-scale}\right)}^{2}\\
\mathbf{if}\;a \leq -1.8 \cdot 10^{+256}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;a \leq -2.8 \cdot 10^{-197}:\\
\;\;\;\;-4 \cdot {\left(\frac{a \cdot b}{x-scale \cdot y-scale}\right)}^{2}\\
\mathbf{elif}\;a \leq -2.05 \cdot 10^{-272}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;a \leq 3.8 \cdot 10^{-97}:\\
\;\;\;\;-4 \cdot {\left(\frac{a}{x-scale \cdot \frac{y-scale}{b}}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot {\left(\frac{b}{\frac{x-scale}{\frac{a}{y-scale}}}\right)}^{2}\\
\end{array}



Bits error versus a



Bits error versus b



Bits error versus angle



Bits error versus x-scale



Bits error versus y-scale
Results
if a < -1.79999999999999985e256 or -2.8000000000000002e-197 < a < -2.0499999999999999e-272Initial program 41.1
Taylor expanded in angle around 0 43.8
Simplified37.9
Applied egg-rr7.9
Applied egg-rr7.0
Applied egg-rr7.3
if -1.79999999999999985e256 < a < -2.8000000000000002e-197Initial program 41.3
Taylor expanded in angle around 0 37.6
Simplified28.9
Applied egg-rr4.8
Applied egg-rr5.3
Taylor expanded in b around 0 5.0
if -2.0499999999999999e-272 < a < 3.8000000000000001e-97Initial program 34.6
Taylor expanded in angle around 0 37.3
Simplified28.9
Applied egg-rr5.6
Applied egg-rr5.0
Taylor expanded in b around 0 5.0
Simplified6.1
if 3.8000000000000001e-97 < a Initial program 48.3
Taylor expanded in angle around 0 43.6
Simplified35.2
Applied egg-rr6.4
Applied egg-rr6.1
Final simplification5.9
herbie shell --seed 2022156
(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))))