
(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}
Herbie found 5 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}
(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)))
(if (<=
(-
(* 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)))
0.0)
(-
(pow (/ (/ (* (* (* 2.0 (* b b)) t_1) t_2) x-scale) y-scale) 2.0)
(*
(* 4.0 (* (/ b x-scale) (/ b x-scale)))
(/ (/ (pow a 2.0) y-scale) y-scale)))
(*
(/ (pow (* a b) 2.0) (* (* y-scale x-scale) (* y-scale x-scale)))
-4.0))))
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;
double tmp;
if (((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))) <= 0.0) {
tmp = pow((((((2.0 * (b * b)) * t_1) * t_2) / x_45_scale) / y_45_scale), 2.0) - ((4.0 * ((b / x_45_scale) * (b / x_45_scale))) * ((pow(a, 2.0) / y_45_scale) / y_45_scale));
} else {
tmp = (pow((a * b), 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0;
}
return tmp;
}
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;
double tmp;
if (((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))) <= 0.0) {
tmp = Math.pow((((((2.0 * (b * b)) * t_1) * t_2) / x_45_scale) / y_45_scale), 2.0) - ((4.0 * ((b / x_45_scale) * (b / x_45_scale))) * ((Math.pow(a, 2.0) / y_45_scale) / y_45_scale));
} else {
tmp = (Math.pow((a * b), 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0;
}
return tmp;
}
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 tmp = 0 if ((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))) <= 0.0: tmp = math.pow((((((2.0 * (b * b)) * t_1) * t_2) / x_45_scale) / y_45_scale), 2.0) - ((4.0 * ((b / x_45_scale) * (b / x_45_scale))) * ((math.pow(a, 2.0) / y_45_scale) / y_45_scale)) else: tmp = (math.pow((a * b), 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0 return tmp
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) tmp = 0.0 if (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))) <= 0.0) tmp = Float64((Float64(Float64(Float64(Float64(Float64(2.0 * Float64(b * b)) * t_1) * t_2) / x_45_scale) / y_45_scale) ^ 2.0) - Float64(Float64(4.0 * Float64(Float64(b / x_45_scale) * Float64(b / x_45_scale))) * Float64(Float64((a ^ 2.0) / y_45_scale) / y_45_scale))); else tmp = Float64(Float64((Float64(a * b) ^ 2.0) / Float64(Float64(y_45_scale * x_45_scale) * Float64(y_45_scale * x_45_scale))) * -4.0); end return tmp end
function tmp_2 = 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 = 0.0; if (((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))) <= 0.0) tmp = ((((((2.0 * (b * b)) * t_1) * t_2) / x_45_scale) / y_45_scale) ^ 2.0) - ((4.0 * ((b / x_45_scale) * (b / x_45_scale))) * (((a ^ 2.0) / y_45_scale) / y_45_scale)); else tmp = (((a * b) ^ 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0; end tmp_2 = tmp; 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]}, If[LessEqual[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], 0.0], N[(N[Power[N[(N[(N[(N[(N[(2.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision] / x$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision], 2.0], $MachinePrecision] - N[(N[(4.0 * N[(N[(b / x$45$scale), $MachinePrecision] * N[(b / x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Power[a, 2.0], $MachinePrecision] / y$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(a * b), $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.0), $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}\\
\mathbf{if}\;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} \leq 0:\\
\;\;\;\;{\left(\frac{\frac{\left(\left(2 \cdot \left(b \cdot b\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\right)}^{2} - \left(4 \cdot \left(\frac{b}{x-scale} \cdot \frac{b}{x-scale}\right)\right) \cdot \frac{\frac{{a}^{2}}{y-scale}}{y-scale}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(a \cdot b\right)}^{2}}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)} \cdot -4\\
\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))) < 0.0Initial program 76.9%
Taylor expanded in angle around 0
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6468.7
Applied rewrites68.7%
Applied rewrites75.2%
Taylor expanded in angle around 0
lift-pow.f6474.7
Applied rewrites74.7%
Taylor expanded in a around 0
pow2N/A
pow2N/A
pow2N/A
lift-*.f6482.3
Applied rewrites82.3%
if 0.0 < (-.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.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites76.3%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6476.3
Applied rewrites76.3%
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) PI))
(t_1 (sin t_0))
(t_2 (* 0.005555555555555556 (* angle PI)))
(t_3 (cos t_0))
(t_4
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_3) x-scale)
y-scale)))
(if (<=
(-
(* t_4 t_4)
(*
(*
4.0
(/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_3) 2.0)) x-scale) x-scale))
(/ (/ (+ (pow (* a t_3) 2.0) (pow (* b t_1) 2.0)) y-scale) y-scale)))
-1e-259)
(-
(pow
(/ (* 2.0 (* (pow b 2.0) (* (cos t_2) (sin t_2)))) (* y-scale x-scale))
2.0)
(*
(/ (* a a) (* y-scale y-scale))
(* (* (/ b x-scale) (/ b x-scale)) 4.0)))
(*
(/ (pow (* a b) 2.0) (* (* y-scale x-scale) (* y-scale x-scale)))
-4.0))))
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 = 0.005555555555555556 * (angle * ((double) M_PI));
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) / y_45_scale;
double tmp;
if (((t_4 * t_4) - ((4.0 * (((pow((a * t_1), 2.0) + pow((b * t_3), 2.0)) / x_45_scale) / x_45_scale)) * (((pow((a * t_3), 2.0) + pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale))) <= -1e-259) {
tmp = pow(((2.0 * (pow(b, 2.0) * (cos(t_2) * sin(t_2)))) / (y_45_scale * x_45_scale)), 2.0) - (((a * a) / (y_45_scale * y_45_scale)) * (((b / x_45_scale) * (b / x_45_scale)) * 4.0));
} else {
tmp = (pow((a * b), 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0;
}
return tmp;
}
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 = 0.005555555555555556 * (angle * Math.PI);
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) / y_45_scale;
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) / x_45_scale)) * (((Math.pow((a * t_3), 2.0) + Math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale))) <= -1e-259) {
tmp = Math.pow(((2.0 * (Math.pow(b, 2.0) * (Math.cos(t_2) * Math.sin(t_2)))) / (y_45_scale * x_45_scale)), 2.0) - (((a * a) / (y_45_scale * y_45_scale)) * (((b / x_45_scale) * (b / x_45_scale)) * 4.0));
} else {
tmp = (Math.pow((a * b), 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0;
}
return tmp;
}
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 = 0.005555555555555556 * (angle * math.pi) 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) / y_45_scale 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) / x_45_scale)) * (((math.pow((a * t_3), 2.0) + math.pow((b * t_1), 2.0)) / y_45_scale) / y_45_scale))) <= -1e-259: tmp = math.pow(((2.0 * (math.pow(b, 2.0) * (math.cos(t_2) * math.sin(t_2)))) / (y_45_scale * x_45_scale)), 2.0) - (((a * a) / (y_45_scale * y_45_scale)) * (((b / x_45_scale) * (b / x_45_scale)) * 4.0)) else: tmp = (math.pow((a * b), 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0 return tmp
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 = Float64(0.005555555555555556 * Float64(angle * pi)) 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) / y_45_scale) 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) / x_45_scale)) * Float64(Float64(Float64((Float64(a * t_3) ^ 2.0) + (Float64(b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale))) <= -1e-259) tmp = Float64((Float64(Float64(2.0 * Float64((b ^ 2.0) * Float64(cos(t_2) * sin(t_2)))) / Float64(y_45_scale * x_45_scale)) ^ 2.0) - Float64(Float64(Float64(a * a) / Float64(y_45_scale * y_45_scale)) * Float64(Float64(Float64(b / x_45_scale) * Float64(b / x_45_scale)) * 4.0))); else tmp = Float64(Float64((Float64(a * b) ^ 2.0) / Float64(Float64(y_45_scale * x_45_scale) * Float64(y_45_scale * x_45_scale))) * -4.0); end return tmp end
function tmp_2 = code(a, b, angle, x_45_scale, y_45_scale) t_0 = (angle / 180.0) * pi; t_1 = sin(t_0); t_2 = 0.005555555555555556 * (angle * pi); t_3 = cos(t_0); t_4 = ((((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * t_1) * t_3) / x_45_scale) / y_45_scale; tmp = 0.0; if (((t_4 * t_4) - ((4.0 * (((((a * t_1) ^ 2.0) + ((b * t_3) ^ 2.0)) / x_45_scale) / x_45_scale)) * (((((a * t_3) ^ 2.0) + ((b * t_1) ^ 2.0)) / y_45_scale) / y_45_scale))) <= -1e-259) tmp = (((2.0 * ((b ^ 2.0) * (cos(t_2) * sin(t_2)))) / (y_45_scale * x_45_scale)) ^ 2.0) - (((a * a) / (y_45_scale * y_45_scale)) * (((b / x_45_scale) * (b / x_45_scale)) * 4.0)); else tmp = (((a * b) ^ 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0; end tmp_2 = tmp; 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[(0.005555555555555556 * N[(angle * Pi), $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), $MachinePrecision] / y$45$scale), $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), $MachinePrecision] / x$45$scale), $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), $MachinePrecision] / y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e-259], N[(N[Power[N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] * N[(N[Cos[t$95$2], $MachinePrecision] * N[Sin[t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] - N[(N[(N[(a * a), $MachinePrecision] / N[(y$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(b / x$45$scale), $MachinePrecision] * N[(b / x$45$scale), $MachinePrecision]), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(a * b), $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
t_1 := \sin t\_0\\
t_2 := 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\
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}}{y-scale}\\
\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}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot t\_3\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale} \leq -1 \cdot 10^{-259}:\\
\;\;\;\;{\left(\frac{2 \cdot \left({b}^{2} \cdot \left(\cos t\_2 \cdot \sin t\_2\right)\right)}{y-scale \cdot x-scale}\right)}^{2} - \frac{a \cdot a}{y-scale \cdot y-scale} \cdot \left(\left(\frac{b}{x-scale} \cdot \frac{b}{x-scale}\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(a \cdot b\right)}^{2}}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)} \cdot -4\\
\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))) < -1.0000000000000001e-259Initial program 39.9%
Applied rewrites29.1%
Taylor expanded in angle around 0
pow2N/A
pow2N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6431.2
Applied rewrites31.2%
Taylor expanded in a around 0
lower-*.f64N/A
lower-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
Applied rewrites42.9%
Taylor expanded in angle around 0
pow2N/A
lift-*.f6446.9
Applied rewrites46.9%
if -1.0000000000000001e-259 < (-.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 23.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites79.0%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6479.0
Applied rewrites79.0%
(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)))
(if (<=
(-
(* 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)))
-1e-259)
(*
(/ 4.0 x-scale)
(/ (* (pow a 2.0) (* -1.0 (/ (* b b) (* y-scale y-scale)))) x-scale))
(*
(/ (pow (* a b) 2.0) (* (* y-scale x-scale) (* y-scale x-scale)))
-4.0))))
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;
double tmp;
if (((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))) <= -1e-259) {
tmp = (4.0 / x_45_scale) * ((pow(a, 2.0) * (-1.0 * ((b * b) / (y_45_scale * y_45_scale)))) / x_45_scale);
} else {
tmp = (pow((a * b), 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0;
}
return tmp;
}
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;
double tmp;
if (((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))) <= -1e-259) {
tmp = (4.0 / x_45_scale) * ((Math.pow(a, 2.0) * (-1.0 * ((b * b) / (y_45_scale * y_45_scale)))) / x_45_scale);
} else {
tmp = (Math.pow((a * b), 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0;
}
return tmp;
}
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 tmp = 0 if ((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))) <= -1e-259: tmp = (4.0 / x_45_scale) * ((math.pow(a, 2.0) * (-1.0 * ((b * b) / (y_45_scale * y_45_scale)))) / x_45_scale) else: tmp = (math.pow((a * b), 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0 return tmp
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) tmp = 0.0 if (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))) <= -1e-259) tmp = Float64(Float64(4.0 / x_45_scale) * Float64(Float64((a ^ 2.0) * Float64(-1.0 * Float64(Float64(b * b) / Float64(y_45_scale * y_45_scale)))) / x_45_scale)); else tmp = Float64(Float64((Float64(a * b) ^ 2.0) / Float64(Float64(y_45_scale * x_45_scale) * Float64(y_45_scale * x_45_scale))) * -4.0); end return tmp end
function tmp_2 = 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 = 0.0; if (((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))) <= -1e-259) tmp = (4.0 / x_45_scale) * (((a ^ 2.0) * (-1.0 * ((b * b) / (y_45_scale * y_45_scale)))) / x_45_scale); else tmp = (((a * b) ^ 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0; end tmp_2 = tmp; 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]}, If[LessEqual[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], -1e-259], N[(N[(4.0 / x$45$scale), $MachinePrecision] * N[(N[(N[Power[a, 2.0], $MachinePrecision] * N[(-1.0 * N[(N[(b * b), $MachinePrecision] / N[(y$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x$45$scale), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(a * b), $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.0), $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}\\
\mathbf{if}\;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} \leq -1 \cdot 10^{-259}:\\
\;\;\;\;\frac{4}{x-scale} \cdot \frac{{a}^{2} \cdot \left(-1 \cdot \frac{b \cdot b}{y-scale \cdot y-scale}\right)}{x-scale}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(a \cdot b\right)}^{2}}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)} \cdot -4\\
\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))) < -1.0000000000000001e-259Initial program 39.9%
Taylor expanded in x-scale around 0
Applied rewrites25.9%
Applied rewrites28.6%
Taylor expanded in a around 0
Applied rewrites51.6%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6457.8
Applied rewrites57.8%
if -1.0000000000000001e-259 < (-.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 23.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites79.0%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6479.0
Applied rewrites79.0%
(FPCore (a b angle x-scale y-scale) :precision binary64 (* (/ (pow (* a b) 2.0) (* (* y-scale x-scale) (* y-scale x-scale))) -4.0))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return (pow((a * b), 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, angle, x_45scale, y_45scale)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
code = (((a * b) ** 2.0d0) / ((y_45scale * x_45scale) * (y_45scale * x_45scale))) * (-4.0d0)
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return (Math.pow((a * b), 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0;
}
def code(a, b, angle, x_45_scale, y_45_scale): return (math.pow((a * b), 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0
function code(a, b, angle, x_45_scale, y_45_scale) return Float64(Float64((Float64(a * b) ^ 2.0) / Float64(Float64(y_45_scale * x_45_scale) * Float64(y_45_scale * x_45_scale))) * -4.0) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) tmp = (((a * b) ^ 2.0) / ((y_45_scale * x_45_scale) * (y_45_scale * x_45_scale))) * -4.0; end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(N[(N[Power[N[(a * b), $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(y$45$scale * x$45$scale), $MachinePrecision] * N[(y$45$scale * x$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(a \cdot b\right)}^{2}}{\left(y-scale \cdot x-scale\right) \cdot \left(y-scale \cdot x-scale\right)} \cdot -4
\end{array}
Initial program 24.8%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites78.1%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6478.1
Applied rewrites78.1%
(FPCore (a b angle x-scale y-scale) :precision binary64 (* (* -4.0 (/ (* a a) (pow (* x-scale y-scale) 2.0))) (* b b)))
double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return (-4.0 * ((a * a) / pow((x_45_scale * y_45_scale), 2.0))) * (b * b);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, angle, x_45scale, y_45scale)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale
real(8), intent (in) :: y_45scale
code = ((-4.0d0) * ((a * a) / ((x_45scale * y_45scale) ** 2.0d0))) * (b * b)
end function
public static double code(double a, double b, double angle, double x_45_scale, double y_45_scale) {
return (-4.0 * ((a * a) / Math.pow((x_45_scale * y_45_scale), 2.0))) * (b * b);
}
def code(a, b, angle, x_45_scale, y_45_scale): return (-4.0 * ((a * a) / math.pow((x_45_scale * y_45_scale), 2.0))) * (b * b)
function code(a, b, angle, x_45_scale, y_45_scale) return Float64(Float64(-4.0 * Float64(Float64(a * a) / (Float64(x_45_scale * y_45_scale) ^ 2.0))) * Float64(b * b)) end
function tmp = code(a, b, angle, x_45_scale, y_45_scale) tmp = (-4.0 * ((a * a) / ((x_45_scale * y_45_scale) ^ 2.0))) * (b * b); end
code[a_, b_, angle_, x$45$scale_, y$45$scale_] := N[(N[(-4.0 * N[(N[(a * a), $MachinePrecision] / N[Power[N[(x$45$scale * y$45$scale), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-4 \cdot \frac{a \cdot a}{{\left(x-scale \cdot y-scale\right)}^{2}}\right) \cdot \left(b \cdot b\right)
\end{array}
Initial program 24.8%
Taylor expanded in b around 0
Applied rewrites54.5%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f6461.6
Applied rewrites61.6%
herbie shell --seed 2025092
(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))))