
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) PI))
(t_1 (sin t_0))
(t_2 (cos t_0))
(t_3
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_2) x-scale)
y-scale)))
(-
(* t_3 t_3)
(*
(*
4.0
(/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) x-scale) x-scale))
(/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) y-scale) y-scale)))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (angle / 180.0) * ((double) M_PI);
double t_1 = sin(t_0);
double t_2 = cos(t_0);
double t_3 = ((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale;
return (t_3 * t_3) - ((4.0 * (((pow((a * t_1), 2.0) + pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((pow((a * t_2), 2.0) + pow((b * t_1), 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 = (angle / 180.0) * Math.PI;
double t_1 = Math.sin(t_0);
double t_2 = Math.cos(t_0);
double t_3 = ((((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale;
return (t_3 * t_3) - ((4.0 * (((Math.pow((a * t_1), 2.0) + Math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((Math.pow((a * t_2), 2.0) + Math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale));
}
def code(a, b, angle, x_45_scale, y_45_scale): t_0 = (angle / 180.0) * math.pi t_1 = math.sin(t_0) t_2 = math.cos(t_0) t_3 = ((((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale return (t_3 * t_3) - ((4.0 * (((math.pow((a * t_1), 2.0) + math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((math.pow((a * t_2), 2.0) + math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale))
function code(a, b, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(angle / 180.0) * pi) t_1 = sin(t_0) t_2 = cos(t_0) t_3 = Float64(Float64(Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale) return Float64(Float64(t_3 * t_3) - Float64(Float64(4.0 * Float64(Float64(Float64((Float64(a * t_1) ^ 2.0) + (Float64(b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale)) * Float64(Float64(Float64((Float64(a * t_2) ^ 2.0) + (Float64(b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale))) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) t_0 = (angle / 180.0) * pi; t_1 = sin(t_0); t_2 = cos(t_0); t_3 = ((((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale; tmp = (t_3 * t_3) - ((4.0 * (((((a * t_1) ^ 2.0) + ((b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale)) * (((((a * t_2) ^ 2.0) + ((b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale)); end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, Block[{t$95$1 = N[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision] / x$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]}, N[(N[(t$95$3 * t$95$3), $MachinePrecision] - N[(N[(4.0 * N[(N[(N[(N[Power[N[(a * t$95$1), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$2), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / x$45$scale), $MachinePrecision] / x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Power[N[(a * t$95$2), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
t_3 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\\
t\_3 \cdot t\_3 - \left(4 \cdot \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) PI))
(t_1 (sin t_0))
(t_2 (cos t_0))
(t_3
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_2) x-scale)
y-scale)))
(-
(* t_3 t_3)
(*
(*
4.0
(/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) x-scale) x-scale))
(/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) y-scale) y-scale)))))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
double t_0 = (angle / 180.0) * ((double) M_PI);
double t_1 = sin(t_0);
double t_2 = cos(t_0);
double t_3 = ((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale;
return (t_3 * t_3) - ((4.0 * (((pow((a * t_1), 2.0) + pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((pow((a * t_2), 2.0) + pow((b * t_1), 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 = (angle / 180.0) * Math.PI;
double t_1 = Math.sin(t_0);
double t_2 = Math.cos(t_0);
double t_3 = ((((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale;
return (t_3 * t_3) - ((4.0 * (((Math.pow((a * t_1), 2.0) + Math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((Math.pow((a * t_2), 2.0) + Math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale));
}
def code(a, b, angle, x_45_scale, y_45_scale): t_0 = (angle / 180.0) * math.pi t_1 = math.sin(t_0) t_2 = math.cos(t_0) t_3 = ((((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale return (t_3 * t_3) - ((4.0 * (((math.pow((a * t_1), 2.0) + math.pow((b * t_2), 2.0)) / x_45_scale) / x_45_scale)) * (((math.pow((a * t_2), 2.0) + math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale))
function code(a, b, angle, x_45_scale, y_45_scale) t_0 = Float64(Float64(angle / 180.0) * pi) t_1 = sin(t_0) t_2 = cos(t_0) t_3 = Float64(Float64(Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale) return Float64(Float64(t_3 * t_3) - Float64(Float64(4.0 * Float64(Float64(Float64((Float64(a * t_1) ^ 2.0) + (Float64(b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale)) * Float64(Float64(Float64((Float64(a * t_2) ^ 2.0) + (Float64(b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale))) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) t_0 = (angle / 180.0) * pi; t_1 = sin(t_0); t_2 = cos(t_0); t_3 = ((((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_2) / x_45_scale) / y_45_scale; tmp = (t_3 * t_3) - ((4.0 * (((((a * t_1) ^ 2.0) + ((b * t_2) ^ 2.0)) / x_45_scale) / x_45_scale)) * (((((a * t_2) ^ 2.0) + ((b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale)); end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, Block[{t$95$1 = N[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision] / x$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]}, N[(N[(t$95$3 * t$95$3), $MachinePrecision] - N[(N[(4.0 * N[(N[(N[(N[Power[N[(a * t$95$1), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$2), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / x$45$scale), $MachinePrecision] / x$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Power[N[(a * t$95$2), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
t_3 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\\
t\_3 \cdot t\_3 - \left(4 \cdot \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale}
\end{array}
\end{array}
x-scale_m = (fabs.f64 x-scale)
y-scale_m = (fabs.f64 y-scale)
(FPCore (a b angle x-scale_m y-scale_m)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) PI))
(t_1 (sin t_0))
(t_2 (/ (* b a) (sqrt (* x-scale_m y-scale_m))))
(t_3 (cos t_0))
(t_4
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_3) x-scale_m)
y-scale_m)))
(if (<=
(-
(* t_4 t_4)
(*
(*
4.0
(/
(/ (+ (pow (* a t_1) 2.0) (pow (* b t_3) 2.0)) x-scale_m)
x-scale_m))
(/
(/ (+ (pow (* a t_3) 2.0) (pow (* b t_1) 2.0)) y-scale_m)
y-scale_m)))
2e+263)
(* -4.0 (pow (* (/ a y-scale_m) (/ b x-scale_m)) 2.0))
(* -4.0 (* t_2 (/ t_2 (* x-scale_m y-scale_m)))))))x-scale_m = fabs(x_45_scale);
y-scale_m = fabs(y_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
double t_0 = (angle / 180.0) * ((double) M_PI);
double t_1 = sin(t_0);
double t_2 = (b * a) / sqrt((x_45_scale_m * y_45_scale_m));
double t_3 = cos(t_0);
double t_4 = ((((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * t_1) * t_3) / x_45_scale_m) / y_45_scale_m;
double tmp;
if (((t_4 * t_4) - ((4.0 * (((pow((a * t_1), 2.0) + pow((b * t_3), 2.0)) / x_45_scale_m) / x_45_scale_m)) * (((pow((a * t_3), 2.0) + pow((b * t_1), 2.0)) / y_45_scale_m) / y_45_scale_m))) <= 2e+263) {
tmp = -4.0 * pow(((a / y_45_scale_m) * (b / x_45_scale_m)), 2.0);
} else {
tmp = -4.0 * (t_2 * (t_2 / (x_45_scale_m * y_45_scale_m)));
}
return tmp;
}
x-scale_m = Math.abs(x_45_scale);
y-scale_m = Math.abs(y_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
double t_0 = (angle / 180.0) * Math.PI;
double t_1 = Math.sin(t_0);
double t_2 = (b * a) / Math.sqrt((x_45_scale_m * y_45_scale_m));
double t_3 = Math.cos(t_0);
double t_4 = ((((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * t_1) * t_3) / x_45_scale_m) / y_45_scale_m;
double tmp;
if (((t_4 * t_4) - ((4.0 * (((Math.pow((a * t_1), 2.0) + Math.pow((b * t_3), 2.0)) / x_45_scale_m) / x_45_scale_m)) * (((Math.pow((a * t_3), 2.0) + Math.pow((b * t_1), 2.0)) / y_45_scale_m) / y_45_scale_m))) <= 2e+263) {
tmp = -4.0 * Math.pow(((a / y_45_scale_m) * (b / x_45_scale_m)), 2.0);
} else {
tmp = -4.0 * (t_2 * (t_2 / (x_45_scale_m * y_45_scale_m)));
}
return tmp;
}
x-scale_m = math.fabs(x_45_scale) y-scale_m = math.fabs(y_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale_m): t_0 = (angle / 180.0) * math.pi t_1 = math.sin(t_0) t_2 = (b * a) / math.sqrt((x_45_scale_m * y_45_scale_m)) t_3 = math.cos(t_0) t_4 = ((((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * t_1) * t_3) / x_45_scale_m) / y_45_scale_m tmp = 0 if ((t_4 * t_4) - ((4.0 * (((math.pow((a * t_1), 2.0) + math.pow((b * t_3), 2.0)) / x_45_scale_m) / x_45_scale_m)) * (((math.pow((a * t_3), 2.0) + math.pow((b * t_1), 2.0)) / y_45_scale_m) / y_45_scale_m))) <= 2e+263: tmp = -4.0 * math.pow(((a / y_45_scale_m) * (b / x_45_scale_m)), 2.0) else: tmp = -4.0 * (t_2 * (t_2 / (x_45_scale_m * y_45_scale_m))) return tmp
x-scale_m = abs(x_45_scale) y-scale_m = abs(y_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale_m) t_0 = Float64(Float64(angle / 180.0) * pi) t_1 = sin(t_0) t_2 = Float64(Float64(b * a) / sqrt(Float64(x_45_scale_m * y_45_scale_m))) t_3 = cos(t_0) t_4 = Float64(Float64(Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_3) / x_45_scale_m) / y_45_scale_m) tmp = 0.0 if (Float64(Float64(t_4 * t_4) - Float64(Float64(4.0 * Float64(Float64(Float64((Float64(a * t_1) ^ 2.0) + (Float64(b * t_3) ^ 2.0)) / x_45_scale_m) / x_45_scale_m)) * Float64(Float64(Float64((Float64(a * t_3) ^ 2.0) + (Float64(b * t_1) ^ 2.0)) / y_45_scale_m) / y_45_scale_m))) <= 2e+263) tmp = Float64(-4.0 * (Float64(Float64(a / y_45_scale_m) * Float64(b / x_45_scale_m)) ^ 2.0)); else tmp = Float64(-4.0 * Float64(t_2 * Float64(t_2 / Float64(x_45_scale_m * y_45_scale_m)))); end return tmp end
x-scale_m = abs(x_45_scale); y-scale_m = abs(y_45_scale); function tmp_2 = code(a, b, angle, x_45_scale_m, y_45_scale_m) t_0 = (angle / 180.0) * pi; t_1 = sin(t_0); t_2 = (b * a) / sqrt((x_45_scale_m * y_45_scale_m)); t_3 = cos(t_0); t_4 = ((((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_3) / x_45_scale_m) / y_45_scale_m; tmp = 0.0; if (((t_4 * t_4) - ((4.0 * (((((a * t_1) ^ 2.0) + ((b * t_3) ^ 2.0)) / x_45_scale_m) / x_45_scale_m)) * (((((a * t_3) ^ 2.0) + ((b * t_1) ^ 2.0)) / y_45_scale_m) / y_45_scale_m))) <= 2e+263) tmp = -4.0 * (((a / y_45_scale_m) * (b / x_45_scale_m)) ^ 2.0); else tmp = -4.0 * (t_2 * (t_2 / (x_45_scale_m * y_45_scale_m))); end tmp_2 = tmp; end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
y-scale_m = N[Abs[y$45$scale], $MachinePrecision]
code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale$95$m_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, Block[{t$95$1 = N[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(b * a), $MachinePrecision] / N[Sqrt[N[(x$45$scale$95$m * y$45$scale$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$3), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision] / y$45$scale$95$m), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$4 * t$95$4), $MachinePrecision] - N[(N[(4.0 * N[(N[(N[(N[Power[N[(a * t$95$1), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$3), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Power[N[(a * t$95$3), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * t$95$1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / y$45$scale$95$m), $MachinePrecision] / y$45$scale$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+263], N[(-4.0 * N[Power[N[(N[(a / y$45$scale$95$m), $MachinePrecision] * N[(b / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(t$95$2 * N[(t$95$2 / N[(x$45$scale$95$m * y$45$scale$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
y-scale_m = \left|y-scale\right|
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
t_1 := \sin t\_0\\
t_2 := \frac{b \cdot a}{\sqrt{x-scale\_m \cdot y-scale\_m}}\\
t_3 := \cos t\_0\\
t_4 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_3}{x-scale\_m}}{y-scale\_m}\\
\mathbf{if}\;t\_4 \cdot t\_4 - \left(4 \cdot \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_3\right)}^{2}}{x-scale\_m}}{x-scale\_m}\right) \cdot \frac{\frac{{\left(a \cdot t\_3\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale\_m}}{y-scale\_m} \leq 2 \cdot 10^{+263}:\\
\;\;\;\;-4 \cdot {\left(\frac{a}{y-scale\_m} \cdot \frac{b}{x-scale\_m}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(t\_2 \cdot \frac{t\_2}{x-scale\_m \cdot y-scale\_m}\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale) (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale)) (*.f64 (*.f64 #s(literal 4 binary64) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) x-scale) x-scale)) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) y-scale) y-scale))) < 2.00000000000000003e263Initial program 61.5%
Simplified50.5%
Taylor expanded in angle around 0 61.7%
*-commutative61.7%
unpow261.7%
unpow261.7%
swap-sqr64.1%
unpow264.1%
*-commutative64.1%
unpow264.1%
unpow264.1%
swap-sqr73.1%
unpow273.1%
Simplified73.1%
associate-*r/73.1%
Applied egg-rr73.1%
*-commutative73.1%
unpow-prod-down64.1%
Applied egg-rr64.1%
Taylor expanded in a around 0 61.7%
*-commutative61.7%
unpow261.7%
unpow261.7%
swap-sqr64.1%
unpow264.1%
unpow264.1%
swap-sqr73.1%
times-frac91.3%
rem-square-sqrt0.0%
swap-sqr0.0%
times-frac0.0%
times-frac0.0%
swap-sqr0.0%
unpow20.0%
rem-square-sqrt96.8%
*-commutative96.8%
Simplified99.6%
if 2.00000000000000003e263 < (-.f64 (*.f64 (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale) (/.f64 (/.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) (-.f64 (pow.f64 b #s(literal 2 binary64)) (pow.f64 a #s(literal 2 binary64)))) (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) x-scale) y-scale)) (*.f64 (*.f64 #s(literal 4 binary64) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) x-scale) x-scale)) (/.f64 (/.f64 (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) y-scale) y-scale))) Initial program 0.0%
Simplified2.2%
Taylor expanded in angle around 0 38.7%
*-commutative38.7%
unpow238.7%
unpow238.7%
swap-sqr57.1%
unpow257.1%
*-commutative57.1%
unpow257.1%
unpow257.1%
swap-sqr78.6%
unpow278.6%
Simplified78.6%
add-cbrt-cube67.9%
pow1/367.3%
pow367.3%
div-inv66.9%
pow-flip67.3%
metadata-eval67.3%
Applied egg-rr67.3%
unpow1/367.9%
unpow367.9%
add-cbrt-cube78.2%
metadata-eval78.2%
pow-flip77.8%
pow277.8%
div-inv78.6%
associate-/r*83.2%
Applied egg-rr83.2%
add-sqr-sqrt48.9%
*-un-lft-identity48.9%
times-frac49.0%
sqrt-div44.9%
sqrt-pow121.6%
metadata-eval21.6%
pow121.6%
sqrt-div23.5%
sqrt-pow151.1%
metadata-eval51.1%
pow151.1%
Applied egg-rr51.1%
Final simplification70.0%
x-scale_m = (fabs.f64 x-scale)
y-scale_m = (fabs.f64 y-scale)
(FPCore (a b angle x-scale_m y-scale_m)
:precision binary64
(let* ((t_0 (* (/ a x-scale_m) (/ b y-scale_m))))
(if (<= b 1.9e-251)
(* -4.0 (pow (* (/ a y-scale_m) (/ b x-scale_m)) 2.0))
(* -4.0 (* t_0 t_0)))))x-scale_m = fabs(x_45_scale);
y-scale_m = fabs(y_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
double t_0 = (a / x_45_scale_m) * (b / y_45_scale_m);
double tmp;
if (b <= 1.9e-251) {
tmp = -4.0 * pow(((a / y_45_scale_m) * (b / x_45_scale_m)), 2.0);
} else {
tmp = -4.0 * (t_0 * t_0);
}
return tmp;
}
x-scale_m = abs(x_45scale)
y-scale_m = abs(y_45scale)
real(8) function code(a, b, angle, x_45scale_m, y_45scale_m)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale_m
real(8) :: t_0
real(8) :: tmp
t_0 = (a / x_45scale_m) * (b / y_45scale_m)
if (b <= 1.9d-251) then
tmp = (-4.0d0) * (((a / y_45scale_m) * (b / x_45scale_m)) ** 2.0d0)
else
tmp = (-4.0d0) * (t_0 * t_0)
end if
code = tmp
end function
x-scale_m = Math.abs(x_45_scale);
y-scale_m = Math.abs(y_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
double t_0 = (a / x_45_scale_m) * (b / y_45_scale_m);
double tmp;
if (b <= 1.9e-251) {
tmp = -4.0 * Math.pow(((a / y_45_scale_m) * (b / x_45_scale_m)), 2.0);
} else {
tmp = -4.0 * (t_0 * t_0);
}
return tmp;
}
x-scale_m = math.fabs(x_45_scale) y-scale_m = math.fabs(y_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale_m): t_0 = (a / x_45_scale_m) * (b / y_45_scale_m) tmp = 0 if b <= 1.9e-251: tmp = -4.0 * math.pow(((a / y_45_scale_m) * (b / x_45_scale_m)), 2.0) else: tmp = -4.0 * (t_0 * t_0) return tmp
x-scale_m = abs(x_45_scale) y-scale_m = abs(y_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale_m) t_0 = Float64(Float64(a / x_45_scale_m) * Float64(b / y_45_scale_m)) tmp = 0.0 if (b <= 1.9e-251) tmp = Float64(-4.0 * (Float64(Float64(a / y_45_scale_m) * Float64(b / x_45_scale_m)) ^ 2.0)); else tmp = Float64(-4.0 * Float64(t_0 * t_0)); end return tmp end
x-scale_m = abs(x_45_scale); y-scale_m = abs(y_45_scale); function tmp_2 = code(a, b, angle, x_45_scale_m, y_45_scale_m) t_0 = (a / x_45_scale_m) * (b / y_45_scale_m); tmp = 0.0; if (b <= 1.9e-251) tmp = -4.0 * (((a / y_45_scale_m) * (b / x_45_scale_m)) ^ 2.0); else tmp = -4.0 * (t_0 * t_0); end tmp_2 = tmp; end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
y-scale_m = N[Abs[y$45$scale], $MachinePrecision]
code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale$95$m_] := Block[{t$95$0 = N[(N[(a / x$45$scale$95$m), $MachinePrecision] * N[(b / y$45$scale$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 1.9e-251], N[(-4.0 * N[Power[N[(N[(a / y$45$scale$95$m), $MachinePrecision] * N[(b / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
y-scale_m = \left|y-scale\right|
\\
\begin{array}{l}
t_0 := \frac{a}{x-scale\_m} \cdot \frac{b}{y-scale\_m}\\
\mathbf{if}\;b \leq 1.9 \cdot 10^{-251}:\\
\;\;\;\;-4 \cdot {\left(\frac{a}{y-scale\_m} \cdot \frac{b}{x-scale\_m}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(t\_0 \cdot t\_0\right)\\
\end{array}
\end{array}
if b < 1.8999999999999999e-251Initial program 28.5%
Simplified23.3%
Taylor expanded in angle around 0 43.9%
*-commutative43.9%
unpow243.9%
unpow243.9%
swap-sqr57.4%
unpow257.4%
*-commutative57.4%
unpow257.4%
unpow257.4%
swap-sqr73.3%
unpow273.3%
Simplified73.3%
associate-*r/73.3%
Applied egg-rr73.3%
*-commutative73.3%
unpow-prod-down57.4%
Applied egg-rr57.4%
Taylor expanded in a around 0 43.9%
*-commutative43.9%
unpow243.9%
unpow243.9%
swap-sqr57.4%
unpow257.4%
unpow257.4%
swap-sqr73.3%
times-frac91.0%
rem-square-sqrt0.0%
swap-sqr0.0%
times-frac0.0%
times-frac0.0%
swap-sqr0.0%
unpow20.0%
rem-square-sqrt93.1%
*-commutative93.1%
Simplified95.5%
if 1.8999999999999999e-251 < b Initial program 18.0%
Simplified18.0%
Taylor expanded in angle around 0 53.0%
*-commutative53.0%
unpow253.0%
unpow253.0%
swap-sqr63.2%
unpow263.2%
*-commutative63.2%
unpow263.2%
unpow263.2%
swap-sqr80.8%
unpow280.8%
Simplified80.8%
add-cbrt-cube71.2%
pow1/370.9%
pow370.9%
div-inv70.9%
pow-flip71.4%
metadata-eval71.4%
Applied egg-rr71.4%
unpow1/371.7%
unpow371.7%
add-cbrt-cube81.3%
metadata-eval81.3%
pow-flip80.7%
pow280.7%
div-inv80.8%
associate-/r*86.3%
Applied egg-rr86.3%
associate-/r*80.8%
pow280.8%
times-frac97.4%
times-frac93.6%
times-frac95.6%
Applied egg-rr95.6%
x-scale_m = (fabs.f64 x-scale) y-scale_m = (fabs.f64 y-scale) (FPCore (a b angle x-scale_m y-scale_m) :precision binary64 (let* ((t_0 (* (/ a x-scale_m) (/ b y-scale_m)))) (* -4.0 (* t_0 t_0))))
x-scale_m = fabs(x_45_scale);
y-scale_m = fabs(y_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
double t_0 = (a / x_45_scale_m) * (b / y_45_scale_m);
return -4.0 * (t_0 * t_0);
}
x-scale_m = abs(x_45scale)
y-scale_m = abs(y_45scale)
real(8) function code(a, b, angle, x_45scale_m, y_45scale_m)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale_m
real(8) :: t_0
t_0 = (a / x_45scale_m) * (b / y_45scale_m)
code = (-4.0d0) * (t_0 * t_0)
end function
x-scale_m = Math.abs(x_45_scale);
y-scale_m = Math.abs(y_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
double t_0 = (a / x_45_scale_m) * (b / y_45_scale_m);
return -4.0 * (t_0 * t_0);
}
x-scale_m = math.fabs(x_45_scale) y-scale_m = math.fabs(y_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale_m): t_0 = (a / x_45_scale_m) * (b / y_45_scale_m) return -4.0 * (t_0 * t_0)
x-scale_m = abs(x_45_scale) y-scale_m = abs(y_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale_m) t_0 = Float64(Float64(a / x_45_scale_m) * Float64(b / y_45_scale_m)) return Float64(-4.0 * Float64(t_0 * t_0)) end
x-scale_m = abs(x_45_scale); y-scale_m = abs(y_45_scale); function tmp = code(a, b, angle, x_45_scale_m, y_45_scale_m) t_0 = (a / x_45_scale_m) * (b / y_45_scale_m); tmp = -4.0 * (t_0 * t_0); end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
y-scale_m = N[Abs[y$45$scale], $MachinePrecision]
code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale$95$m_] := Block[{t$95$0 = N[(N[(a / x$45$scale$95$m), $MachinePrecision] * N[(b / y$45$scale$95$m), $MachinePrecision]), $MachinePrecision]}, N[(-4.0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
y-scale_m = \left|y-scale\right|
\\
\begin{array}{l}
t_0 := \frac{a}{x-scale\_m} \cdot \frac{b}{y-scale\_m}\\
-4 \cdot \left(t\_0 \cdot t\_0\right)
\end{array}
\end{array}
Initial program 24.0%
Simplified21.1%
Taylor expanded in angle around 0 47.7%
*-commutative47.7%
unpow247.7%
unpow247.7%
swap-sqr59.9%
unpow259.9%
*-commutative59.9%
unpow259.9%
unpow259.9%
swap-sqr76.4%
unpow276.4%
Simplified76.4%
add-cbrt-cube66.7%
pow1/366.2%
pow366.2%
div-inv66.0%
pow-flip66.2%
metadata-eval66.2%
Applied egg-rr66.2%
unpow1/366.6%
unpow366.6%
add-cbrt-cube76.2%
metadata-eval76.2%
pow-flip76.0%
pow276.0%
div-inv76.4%
associate-/r*82.0%
Applied egg-rr82.0%
associate-/r*76.4%
pow276.4%
times-frac93.7%
times-frac88.5%
times-frac94.2%
Applied egg-rr94.2%
x-scale_m = (fabs.f64 x-scale) y-scale_m = (fabs.f64 y-scale) (FPCore (a b angle x-scale_m y-scale_m) :precision binary64 0.0)
x-scale_m = fabs(x_45_scale);
y-scale_m = fabs(y_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
return 0.0;
}
x-scale_m = abs(x_45scale)
y-scale_m = abs(y_45scale)
real(8) function code(a, b, angle, x_45scale_m, y_45scale_m)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale_m
code = 0.0d0
end function
x-scale_m = Math.abs(x_45_scale);
y-scale_m = Math.abs(y_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale_m) {
return 0.0;
}
x-scale_m = math.fabs(x_45_scale) y-scale_m = math.fabs(y_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale_m): return 0.0
x-scale_m = abs(x_45_scale) y-scale_m = abs(y_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale_m) return 0.0 end
x-scale_m = abs(x_45_scale); y-scale_m = abs(y_45_scale); function tmp = code(a, b, angle, x_45_scale_m, y_45_scale_m) tmp = 0.0; end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision] y-scale_m = N[Abs[y$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale$95$m_] := 0.0
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
y-scale_m = \left|y-scale\right|
\\
0
\end{array}
Initial program 24.0%
Simplified21.1%
Taylor expanded in b around 0 22.4%
distribute-rgt-out22.4%
metadata-eval22.4%
mul0-rgt33.4%
Simplified33.4%
herbie shell --seed 2024165
(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))))