
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (/ angle 180)))) (+ (pow (* a (cos t_0)) 2) (pow (* b (sin t_0)) 2))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle / 180.0);
return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle / 180.0);
return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle): t_0 = math.pi * (angle / 180.0) return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(pi * Float64(angle / 180.0)) return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = pi * (angle / 180.0); tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (/ angle 180)))) (+ (pow (* a (cos t_0)) 2) (pow (* b (sin t_0)) 2))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle / 180.0);
return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle / 180.0);
return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle): t_0 = math.pi * (angle / 180.0) return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(pi * Float64(angle / 180.0)) return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = pi * (angle / 180.0); tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
(FPCore (a b angle) :precision binary64 (let* ((t_0 (/ 1 (/ (/ 180 angle) PI)))) (+ (pow (* a (cos t_0)) 2) (pow (* b (sin t_0)) 2))))
double code(double a, double b, double angle) {
double t_0 = 1.0 / ((180.0 / angle) / ((double) M_PI));
return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = 1.0 / ((180.0 / angle) / Math.PI);
return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle): t_0 = 1.0 / ((180.0 / angle) / math.pi) return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(1.0 / Float64(Float64(180.0 / angle) / pi)) return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = 1.0 / ((180.0 / angle) / pi); tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(1 / N[(N[(180 / angle), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \frac{1}{\frac{\frac{180}{angle}}{\pi}}\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
Initial program 80.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
*-commutativeN/A
lower-*.f6480.3%
Applied rewrites80.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
*-commutativeN/A
lower-*.f6480.3%
Applied rewrites80.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6480.3%
Applied rewrites80.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6480.3%
Applied rewrites80.3%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (* 1/180 PI) angle))) (+ (pow (* a (cos t_0)) 2) (pow (* b (sin t_0)) 2))))
double code(double a, double b, double angle) {
double t_0 = (0.005555555555555556 * ((double) M_PI)) * angle;
return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = (0.005555555555555556 * Math.PI) * angle;
return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle): t_0 = (0.005555555555555556 * math.pi) * angle return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(Float64(0.005555555555555556 * pi) * angle) return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = (0.005555555555555556 * pi) * angle; tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(1/180 * Pi), $MachinePrecision] * angle), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left(\frac{1}{180} \cdot \pi\right) \cdot angle\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
Initial program 80.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval80.4%
Applied rewrites80.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval80.4%
Applied rewrites80.4%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (* 1/180 angle) PI))) (+ (pow (* a (cos t_0)) 2) (pow (* b (sin t_0)) 2))))
double code(double a, double b, double angle) {
double t_0 = (0.005555555555555556 * angle) * ((double) M_PI);
return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = (0.005555555555555556 * angle) * Math.PI;
return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle): t_0 = (0.005555555555555556 * angle) * math.pi return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(Float64(0.005555555555555556 * angle) * pi) return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = (0.005555555555555556 * angle) * pi; tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(1/180 * angle), $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left(\frac{1}{180} \cdot angle\right) \cdot \pi\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
Initial program 80.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.4%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval80.4%
Applied rewrites80.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.4%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval80.4%
Applied rewrites80.4%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (* (* b PI) (fabs angle)) 1/180))
(t_1 (* 1/2 (cos (* (* 1/90 PI) (fabs angle))))))
(if (<= (fabs angle) 3458764513820541/4611686018427387904)
(+
(* (* (+ (cos (* -1/90 (* (fabs angle) PI))) 1) 1/2) (* a a))
(* t_0 t_0))
(+ (* (* (- 1/2 t_1) b) b) (* (* (+ 1/2 t_1) a) a)))))double code(double a, double b, double angle) {
double t_0 = ((b * ((double) M_PI)) * fabs(angle)) * 0.005555555555555556;
double t_1 = 0.5 * cos(((0.011111111111111112 * ((double) M_PI)) * fabs(angle)));
double tmp;
if (fabs(angle) <= 0.00075) {
tmp = (((cos((-0.011111111111111112 * (fabs(angle) * ((double) M_PI)))) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0);
} else {
tmp = (((0.5 - t_1) * b) * b) + (((0.5 + t_1) * a) * a);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = ((b * Math.PI) * Math.abs(angle)) * 0.005555555555555556;
double t_1 = 0.5 * Math.cos(((0.011111111111111112 * Math.PI) * Math.abs(angle)));
double tmp;
if (Math.abs(angle) <= 0.00075) {
tmp = (((Math.cos((-0.011111111111111112 * (Math.abs(angle) * Math.PI))) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0);
} else {
tmp = (((0.5 - t_1) * b) * b) + (((0.5 + t_1) * a) * a);
}
return tmp;
}
def code(a, b, angle): t_0 = ((b * math.pi) * math.fabs(angle)) * 0.005555555555555556 t_1 = 0.5 * math.cos(((0.011111111111111112 * math.pi) * math.fabs(angle))) tmp = 0 if math.fabs(angle) <= 0.00075: tmp = (((math.cos((-0.011111111111111112 * (math.fabs(angle) * math.pi))) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0) else: tmp = (((0.5 - t_1) * b) * b) + (((0.5 + t_1) * a) * a) return tmp
function code(a, b, angle) t_0 = Float64(Float64(Float64(b * pi) * abs(angle)) * 0.005555555555555556) t_1 = Float64(0.5 * cos(Float64(Float64(0.011111111111111112 * pi) * abs(angle)))) tmp = 0.0 if (abs(angle) <= 0.00075) tmp = Float64(Float64(Float64(Float64(cos(Float64(-0.011111111111111112 * Float64(abs(angle) * pi))) + 1.0) * 0.5) * Float64(a * a)) + Float64(t_0 * t_0)); else tmp = Float64(Float64(Float64(Float64(0.5 - t_1) * b) * b) + Float64(Float64(Float64(0.5 + t_1) * a) * a)); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = ((b * pi) * abs(angle)) * 0.005555555555555556; t_1 = 0.5 * cos(((0.011111111111111112 * pi) * abs(angle))); tmp = 0.0; if (abs(angle) <= 0.00075) tmp = (((cos((-0.011111111111111112 * (abs(angle) * pi))) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0); else tmp = (((0.5 - t_1) * b) * b) + (((0.5 + t_1) * a) * a); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(N[(b * Pi), $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision] * 1/180), $MachinePrecision]}, Block[{t$95$1 = N[(1/2 * N[Cos[N[(N[(1/90 * Pi), $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[angle], $MachinePrecision], 3458764513820541/4611686018427387904], N[(N[(N[(N[(N[Cos[N[(-1/90 * N[(N[Abs[angle], $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 1), $MachinePrecision] * 1/2), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1/2 - t$95$1), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision] + N[(N[(N[(1/2 + t$95$1), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left(\left(b \cdot \pi\right) \cdot \left|angle\right|\right) \cdot \frac{1}{180}\\
t_1 := \frac{1}{2} \cdot \cos \left(\left(\frac{1}{90} \cdot \pi\right) \cdot \left|angle\right|\right)\\
\mathbf{if}\;\left|angle\right| \leq \frac{3458764513820541}{4611686018427387904}:\\
\;\;\;\;\left(\left(\cos \left(\frac{-1}{90} \cdot \left(\left|angle\right| \cdot \pi\right)\right) + 1\right) \cdot \frac{1}{2}\right) \cdot \left(a \cdot a\right) + t\_0 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\frac{1}{2} - t\_1\right) \cdot b\right) \cdot b + \left(\left(\frac{1}{2} + t\_1\right) \cdot a\right) \cdot a\\
\end{array}
if angle < 7.5000000000000002e-4Initial program 80.4%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6475.8%
Applied rewrites75.8%
Applied rewrites75.8%
if 7.5000000000000002e-4 < angle Initial program 80.4%
Applied rewrites68.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6468.2%
Applied rewrites68.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6468.3%
Applied rewrites68.3%
(FPCore (a b angle) :precision binary64 (+ (* (+ 1/2 (* 1/2 (cos (* (* angle PI) 1/90)))) (* a a)) (pow (* b (sin (* PI (/ angle 180)))) 2)))
double code(double a, double b, double angle) {
return ((0.5 + (0.5 * cos(((angle * ((double) M_PI)) * 0.011111111111111112)))) * (a * a)) + pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return ((0.5 + (0.5 * Math.cos(((angle * Math.PI) * 0.011111111111111112)))) * (a * a)) + Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0);
}
def code(a, b, angle): return ((0.5 + (0.5 * math.cos(((angle * math.pi) * 0.011111111111111112)))) * (a * a)) + math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0)
function code(a, b, angle) return Float64(Float64(Float64(0.5 + Float64(0.5 * cos(Float64(Float64(angle * pi) * 0.011111111111111112)))) * Float64(a * a)) + (Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((0.5 + (0.5 * cos(((angle * pi) * 0.011111111111111112)))) * (a * a)) + ((b * sin((pi * (angle / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(N[(1/2 + N[(1/2 * N[Cos[N[(N[(angle * Pi), $MachinePrecision] * 1/90), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]
\left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(angle \cdot \pi\right) \cdot \frac{1}{90}\right)\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
Initial program 80.4%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-*.f64N/A
swap-sqrN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites80.4%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (* (* b PI) (fabs angle)) 1/180))
(t_1 (* -1/90 (* (fabs angle) PI))))
(if (<= (fabs angle) 350)
(+ (* (* (+ (cos t_1) 1) 1/2) (* a a)) (* t_0 t_0))
(+
(pow a 2)
(* (- 1/2 (* 1/2 (sin (+ t_1 (* 1/2 PI))))) (* b b))))))double code(double a, double b, double angle) {
double t_0 = ((b * ((double) M_PI)) * fabs(angle)) * 0.005555555555555556;
double t_1 = -0.011111111111111112 * (fabs(angle) * ((double) M_PI));
double tmp;
if (fabs(angle) <= 350.0) {
tmp = (((cos(t_1) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0);
} else {
tmp = pow(a, 2.0) + ((0.5 - (0.5 * sin((t_1 + (0.5 * ((double) M_PI)))))) * (b * b));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = ((b * Math.PI) * Math.abs(angle)) * 0.005555555555555556;
double t_1 = -0.011111111111111112 * (Math.abs(angle) * Math.PI);
double tmp;
if (Math.abs(angle) <= 350.0) {
tmp = (((Math.cos(t_1) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0);
} else {
tmp = Math.pow(a, 2.0) + ((0.5 - (0.5 * Math.sin((t_1 + (0.5 * Math.PI))))) * (b * b));
}
return tmp;
}
def code(a, b, angle): t_0 = ((b * math.pi) * math.fabs(angle)) * 0.005555555555555556 t_1 = -0.011111111111111112 * (math.fabs(angle) * math.pi) tmp = 0 if math.fabs(angle) <= 350.0: tmp = (((math.cos(t_1) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0) else: tmp = math.pow(a, 2.0) + ((0.5 - (0.5 * math.sin((t_1 + (0.5 * math.pi))))) * (b * b)) return tmp
function code(a, b, angle) t_0 = Float64(Float64(Float64(b * pi) * abs(angle)) * 0.005555555555555556) t_1 = Float64(-0.011111111111111112 * Float64(abs(angle) * pi)) tmp = 0.0 if (abs(angle) <= 350.0) tmp = Float64(Float64(Float64(Float64(cos(t_1) + 1.0) * 0.5) * Float64(a * a)) + Float64(t_0 * t_0)); else tmp = Float64((a ^ 2.0) + Float64(Float64(0.5 - Float64(0.5 * sin(Float64(t_1 + Float64(0.5 * pi))))) * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = ((b * pi) * abs(angle)) * 0.005555555555555556; t_1 = -0.011111111111111112 * (abs(angle) * pi); tmp = 0.0; if (abs(angle) <= 350.0) tmp = (((cos(t_1) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0); else tmp = (a ^ 2.0) + ((0.5 - (0.5 * sin((t_1 + (0.5 * pi))))) * (b * b)); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(N[(b * Pi), $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision] * 1/180), $MachinePrecision]}, Block[{t$95$1 = N[(-1/90 * N[(N[Abs[angle], $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[angle], $MachinePrecision], 350], N[(N[(N[(N[(N[Cos[t$95$1], $MachinePrecision] + 1), $MachinePrecision] * 1/2), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 2], $MachinePrecision] + N[(N[(1/2 - N[(1/2 * N[Sin[N[(t$95$1 + N[(1/2 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left(\left(b \cdot \pi\right) \cdot \left|angle\right|\right) \cdot \frac{1}{180}\\
t_1 := \frac{-1}{90} \cdot \left(\left|angle\right| \cdot \pi\right)\\
\mathbf{if}\;\left|angle\right| \leq 350:\\
\;\;\;\;\left(\left(\cos t\_1 + 1\right) \cdot \frac{1}{2}\right) \cdot \left(a \cdot a\right) + t\_0 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;{a}^{2} + \left(\frac{1}{2} - \frac{1}{2} \cdot \sin \left(t\_1 + \frac{1}{2} \cdot \pi\right)\right) \cdot \left(b \cdot b\right)\\
\end{array}
if angle < 350Initial program 80.4%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6475.8%
Applied rewrites75.8%
Applied rewrites75.8%
if 350 < angle Initial program 80.4%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-*.f64N/A
swap-sqrN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites62.8%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
lift-PI.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6462.7%
Applied rewrites62.7%
Taylor expanded in angle around 0
lower-pow.f6462.6%
Applied rewrites62.6%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (* (* b PI) (fabs angle)) 1/180))
(t_1 (* (fabs angle) PI)))
(if (<= (fabs angle) 350)
(+ (* (* (+ (cos (* -1/90 t_1)) 1) 1/2) (* a a)) (* t_0 t_0))
(+ (pow a 2) (* (- 1/2 (* 1/2 (cos (* t_1 1/90)))) (* b b))))))double code(double a, double b, double angle) {
double t_0 = ((b * ((double) M_PI)) * fabs(angle)) * 0.005555555555555556;
double t_1 = fabs(angle) * ((double) M_PI);
double tmp;
if (fabs(angle) <= 350.0) {
tmp = (((cos((-0.011111111111111112 * t_1)) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0);
} else {
tmp = pow(a, 2.0) + ((0.5 - (0.5 * cos((t_1 * 0.011111111111111112)))) * (b * b));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = ((b * Math.PI) * Math.abs(angle)) * 0.005555555555555556;
double t_1 = Math.abs(angle) * Math.PI;
double tmp;
if (Math.abs(angle) <= 350.0) {
tmp = (((Math.cos((-0.011111111111111112 * t_1)) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0);
} else {
tmp = Math.pow(a, 2.0) + ((0.5 - (0.5 * Math.cos((t_1 * 0.011111111111111112)))) * (b * b));
}
return tmp;
}
def code(a, b, angle): t_0 = ((b * math.pi) * math.fabs(angle)) * 0.005555555555555556 t_1 = math.fabs(angle) * math.pi tmp = 0 if math.fabs(angle) <= 350.0: tmp = (((math.cos((-0.011111111111111112 * t_1)) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0) else: tmp = math.pow(a, 2.0) + ((0.5 - (0.5 * math.cos((t_1 * 0.011111111111111112)))) * (b * b)) return tmp
function code(a, b, angle) t_0 = Float64(Float64(Float64(b * pi) * abs(angle)) * 0.005555555555555556) t_1 = Float64(abs(angle) * pi) tmp = 0.0 if (abs(angle) <= 350.0) tmp = Float64(Float64(Float64(Float64(cos(Float64(-0.011111111111111112 * t_1)) + 1.0) * 0.5) * Float64(a * a)) + Float64(t_0 * t_0)); else tmp = Float64((a ^ 2.0) + Float64(Float64(0.5 - Float64(0.5 * cos(Float64(t_1 * 0.011111111111111112)))) * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = ((b * pi) * abs(angle)) * 0.005555555555555556; t_1 = abs(angle) * pi; tmp = 0.0; if (abs(angle) <= 350.0) tmp = (((cos((-0.011111111111111112 * t_1)) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0); else tmp = (a ^ 2.0) + ((0.5 - (0.5 * cos((t_1 * 0.011111111111111112)))) * (b * b)); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(N[(b * Pi), $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision] * 1/180), $MachinePrecision]}, Block[{t$95$1 = N[(N[Abs[angle], $MachinePrecision] * Pi), $MachinePrecision]}, If[LessEqual[N[Abs[angle], $MachinePrecision], 350], N[(N[(N[(N[(N[Cos[N[(-1/90 * t$95$1), $MachinePrecision]], $MachinePrecision] + 1), $MachinePrecision] * 1/2), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 2], $MachinePrecision] + N[(N[(1/2 - N[(1/2 * N[Cos[N[(t$95$1 * 1/90), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left(\left(b \cdot \pi\right) \cdot \left|angle\right|\right) \cdot \frac{1}{180}\\
t_1 := \left|angle\right| \cdot \pi\\
\mathbf{if}\;\left|angle\right| \leq 350:\\
\;\;\;\;\left(\left(\cos \left(\frac{-1}{90} \cdot t\_1\right) + 1\right) \cdot \frac{1}{2}\right) \cdot \left(a \cdot a\right) + t\_0 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;{a}^{2} + \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(t\_1 \cdot \frac{1}{90}\right)\right) \cdot \left(b \cdot b\right)\\
\end{array}
if angle < 350Initial program 80.4%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6475.8%
Applied rewrites75.8%
Applied rewrites75.8%
if 350 < angle Initial program 80.4%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-*.f64N/A
swap-sqrN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites62.8%
Taylor expanded in angle around 0
lower-pow.f6462.7%
Applied rewrites62.7%
(FPCore (a b angle) :precision binary64 (+ (pow a 2) (pow (* b (sin (* PI (/ angle 180)))) 2)))
double code(double a, double b, double angle) {
return pow(a, 2.0) + pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow(a, 2.0) + Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0);
}
def code(a, b, angle): return math.pow(a, 2.0) + math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0)
function code(a, b, angle) return Float64((a ^ 2.0) + (Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a ^ 2.0) + ((b * sin((pi * (angle / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[a, 2], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]
{a}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
Initial program 80.4%
Taylor expanded in angle around 0
lower-pow.f6480.3%
Applied rewrites80.3%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (* (* (fabs b) PI) angle) 1/180)))
(if (<=
(fabs b)
7436652464262241/8749002899132047697490008908470485461412677723572849745703082425639811996797503692894052708092215296)
(* (pow a 2) (+ 1/2 (* 1/2 (cos (* 1/90 (* angle PI))))))
(+
(* (* (+ (cos (* -1/90 (* angle PI))) 1) 1/2) (* a a))
(* t_0 t_0)))))double code(double a, double b, double angle) {
double t_0 = ((fabs(b) * ((double) M_PI)) * angle) * 0.005555555555555556;
double tmp;
if (fabs(b) <= 8.5e-85) {
tmp = pow(a, 2.0) * (0.5 + (0.5 * cos((0.011111111111111112 * (angle * ((double) M_PI))))));
} else {
tmp = (((cos((-0.011111111111111112 * (angle * ((double) M_PI)))) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = ((Math.abs(b) * Math.PI) * angle) * 0.005555555555555556;
double tmp;
if (Math.abs(b) <= 8.5e-85) {
tmp = Math.pow(a, 2.0) * (0.5 + (0.5 * Math.cos((0.011111111111111112 * (angle * Math.PI)))));
} else {
tmp = (((Math.cos((-0.011111111111111112 * (angle * Math.PI))) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0);
}
return tmp;
}
def code(a, b, angle): t_0 = ((math.fabs(b) * math.pi) * angle) * 0.005555555555555556 tmp = 0 if math.fabs(b) <= 8.5e-85: tmp = math.pow(a, 2.0) * (0.5 + (0.5 * math.cos((0.011111111111111112 * (angle * math.pi))))) else: tmp = (((math.cos((-0.011111111111111112 * (angle * math.pi))) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0) return tmp
function code(a, b, angle) t_0 = Float64(Float64(Float64(abs(b) * pi) * angle) * 0.005555555555555556) tmp = 0.0 if (abs(b) <= 8.5e-85) tmp = Float64((a ^ 2.0) * Float64(0.5 + Float64(0.5 * cos(Float64(0.011111111111111112 * Float64(angle * pi)))))); else tmp = Float64(Float64(Float64(Float64(cos(Float64(-0.011111111111111112 * Float64(angle * pi))) + 1.0) * 0.5) * Float64(a * a)) + Float64(t_0 * t_0)); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = ((abs(b) * pi) * angle) * 0.005555555555555556; tmp = 0.0; if (abs(b) <= 8.5e-85) tmp = (a ^ 2.0) * (0.5 + (0.5 * cos((0.011111111111111112 * (angle * pi))))); else tmp = (((cos((-0.011111111111111112 * (angle * pi))) + 1.0) * 0.5) * (a * a)) + (t_0 * t_0); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(N[(N[Abs[b], $MachinePrecision] * Pi), $MachinePrecision] * angle), $MachinePrecision] * 1/180), $MachinePrecision]}, If[LessEqual[N[Abs[b], $MachinePrecision], 7436652464262241/8749002899132047697490008908470485461412677723572849745703082425639811996797503692894052708092215296], N[(N[Power[a, 2], $MachinePrecision] * N[(1/2 + N[(1/2 * N[Cos[N[(1/90 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[Cos[N[(-1/90 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 1), $MachinePrecision] * 1/2), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \left(\left(\left|b\right| \cdot \pi\right) \cdot angle\right) \cdot \frac{1}{180}\\
\mathbf{if}\;\left|b\right| \leq \frac{7436652464262241}{8749002899132047697490008908470485461412677723572849745703082425639811996797503692894052708092215296}:\\
\;\;\;\;{a}^{2} \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \pi\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\cos \left(\frac{-1}{90} \cdot \left(angle \cdot \pi\right)\right) + 1\right) \cdot \frac{1}{2}\right) \cdot \left(a \cdot a\right) + t\_0 \cdot t\_0\\
\end{array}
if b < 8.5000000000000005e-85Initial program 80.4%
Applied rewrites68.2%
Taylor expanded in a around 0
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6425.6%
Applied rewrites25.6%
Applied rewrites25.6%
Taylor expanded in a around inf
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6457.2%
Applied rewrites57.2%
if 8.5000000000000005e-85 < b Initial program 80.4%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6475.8%
Applied rewrites75.8%
Applied rewrites75.8%
(FPCore (a b angle)
:precision binary64
(if (<=
(fabs b)
7436652464262241/8749002899132047697490008908470485461412677723572849745703082425639811996797503692894052708092215296)
(* (pow a 2) (+ 1/2 (* 1/2 (cos (* 1/90 (* angle PI))))))
(+ (pow (* a 1) 2) (pow (* 1/180 (* angle (* (fabs b) PI))) 2))))double code(double a, double b, double angle) {
double tmp;
if (fabs(b) <= 8.5e-85) {
tmp = pow(a, 2.0) * (0.5 + (0.5 * cos((0.011111111111111112 * (angle * ((double) M_PI))))));
} else {
tmp = pow((a * 1.0), 2.0) + pow((0.005555555555555556 * (angle * (fabs(b) * ((double) M_PI)))), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (Math.abs(b) <= 8.5e-85) {
tmp = Math.pow(a, 2.0) * (0.5 + (0.5 * Math.cos((0.011111111111111112 * (angle * Math.PI)))));
} else {
tmp = Math.pow((a * 1.0), 2.0) + Math.pow((0.005555555555555556 * (angle * (Math.abs(b) * Math.PI))), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if math.fabs(b) <= 8.5e-85: tmp = math.pow(a, 2.0) * (0.5 + (0.5 * math.cos((0.011111111111111112 * (angle * math.pi))))) else: tmp = math.pow((a * 1.0), 2.0) + math.pow((0.005555555555555556 * (angle * (math.fabs(b) * math.pi))), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (abs(b) <= 8.5e-85) tmp = Float64((a ^ 2.0) * Float64(0.5 + Float64(0.5 * cos(Float64(0.011111111111111112 * Float64(angle * pi)))))); else tmp = Float64((Float64(a * 1.0) ^ 2.0) + (Float64(0.005555555555555556 * Float64(angle * Float64(abs(b) * pi))) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (abs(b) <= 8.5e-85) tmp = (a ^ 2.0) * (0.5 + (0.5 * cos((0.011111111111111112 * (angle * pi))))); else tmp = ((a * 1.0) ^ 2.0) + ((0.005555555555555556 * (angle * (abs(b) * pi))) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[N[Abs[b], $MachinePrecision], 7436652464262241/8749002899132047697490008908470485461412677723572849745703082425639811996797503692894052708092215296], N[(N[Power[a, 2], $MachinePrecision] * N[(1/2 + N[(1/2 * N[Cos[N[(1/90 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(a * 1), $MachinePrecision], 2], $MachinePrecision] + N[Power[N[(1/180 * N[(angle * N[(N[Abs[b], $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|b\right| \leq \frac{7436652464262241}{8749002899132047697490008908470485461412677723572849745703082425639811996797503692894052708092215296}:\\
\;\;\;\;{a}^{2} \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\frac{1}{90} \cdot \left(angle \cdot \pi\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(a \cdot 1\right)}^{2} + {\left(\frac{1}{180} \cdot \left(angle \cdot \left(\left|b\right| \cdot \pi\right)\right)\right)}^{2}\\
\end{array}
if b < 8.5000000000000005e-85Initial program 80.4%
Applied rewrites68.2%
Taylor expanded in a around 0
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6425.6%
Applied rewrites25.6%
Applied rewrites25.6%
Taylor expanded in a around inf
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6457.2%
Applied rewrites57.2%
if 8.5000000000000005e-85 < b Initial program 80.4%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6475.8%
Applied rewrites75.8%
Taylor expanded in angle around 0
Applied rewrites75.5%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* -1/90 (* angle PI)))
(t_1 (* PI (/ angle 180)))
(t_2 (* (* (* b PI) angle) 1/180)))
(if (<=
(+ (pow (* a (cos t_1)) 2) (pow (* b (sin t_1)) 2))
5890680864316837/2945340432158418383223693624588738123559693482299075088767878449688292160397327779966295692450325070170031945807812908771881611572255401942922812303597144053805349165872996110766935565946816006053119311086960734516644260779498911850068592403100913453684334767056261910363295677456051671938422478104563288264146944)
(* (- 1/2 (* (- (sin (- (* -1/2 PI) t_0))) 1/2)) (* b b))
(+ (* (* (+ (cos t_0) 1) 1/2) (* a a)) (* t_2 t_2)))))double code(double a, double b, double angle) {
double t_0 = -0.011111111111111112 * (angle * ((double) M_PI));
double t_1 = ((double) M_PI) * (angle / 180.0);
double t_2 = ((b * ((double) M_PI)) * angle) * 0.005555555555555556;
double tmp;
if ((pow((a * cos(t_1)), 2.0) + pow((b * sin(t_1)), 2.0)) <= 2e-297) {
tmp = (0.5 - (-sin(((-0.5 * ((double) M_PI)) - t_0)) * 0.5)) * (b * b);
} else {
tmp = (((cos(t_0) + 1.0) * 0.5) * (a * a)) + (t_2 * t_2);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = -0.011111111111111112 * (angle * Math.PI);
double t_1 = Math.PI * (angle / 180.0);
double t_2 = ((b * Math.PI) * angle) * 0.005555555555555556;
double tmp;
if ((Math.pow((a * Math.cos(t_1)), 2.0) + Math.pow((b * Math.sin(t_1)), 2.0)) <= 2e-297) {
tmp = (0.5 - (-Math.sin(((-0.5 * Math.PI) - t_0)) * 0.5)) * (b * b);
} else {
tmp = (((Math.cos(t_0) + 1.0) * 0.5) * (a * a)) + (t_2 * t_2);
}
return tmp;
}
def code(a, b, angle): t_0 = -0.011111111111111112 * (angle * math.pi) t_1 = math.pi * (angle / 180.0) t_2 = ((b * math.pi) * angle) * 0.005555555555555556 tmp = 0 if (math.pow((a * math.cos(t_1)), 2.0) + math.pow((b * math.sin(t_1)), 2.0)) <= 2e-297: tmp = (0.5 - (-math.sin(((-0.5 * math.pi) - t_0)) * 0.5)) * (b * b) else: tmp = (((math.cos(t_0) + 1.0) * 0.5) * (a * a)) + (t_2 * t_2) return tmp
function code(a, b, angle) t_0 = Float64(-0.011111111111111112 * Float64(angle * pi)) t_1 = Float64(pi * Float64(angle / 180.0)) t_2 = Float64(Float64(Float64(b * pi) * angle) * 0.005555555555555556) tmp = 0.0 if (Float64((Float64(a * cos(t_1)) ^ 2.0) + (Float64(b * sin(t_1)) ^ 2.0)) <= 2e-297) tmp = Float64(Float64(0.5 - Float64(Float64(-sin(Float64(Float64(-0.5 * pi) - t_0))) * 0.5)) * Float64(b * b)); else tmp = Float64(Float64(Float64(Float64(cos(t_0) + 1.0) * 0.5) * Float64(a * a)) + Float64(t_2 * t_2)); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = -0.011111111111111112 * (angle * pi); t_1 = pi * (angle / 180.0); t_2 = ((b * pi) * angle) * 0.005555555555555556; tmp = 0.0; if ((((a * cos(t_1)) ^ 2.0) + ((b * sin(t_1)) ^ 2.0)) <= 2e-297) tmp = (0.5 - (-sin(((-0.5 * pi) - t_0)) * 0.5)) * (b * b); else tmp = (((cos(t_0) + 1.0) * 0.5) * (a * a)) + (t_2 * t_2); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(-1/90 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(Pi * N[(angle / 180), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(b * Pi), $MachinePrecision] * angle), $MachinePrecision] * 1/180), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(a * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision], 5890680864316837/2945340432158418383223693624588738123559693482299075088767878449688292160397327779966295692450325070170031945807812908771881611572255401942922812303597144053805349165872996110766935565946816006053119311086960734516644260779498911850068592403100913453684334767056261910363295677456051671938422478104563288264146944], N[(N[(1/2 - N[((-N[Sin[N[(N[(-1/2 * Pi), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]) * 1/2), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[Cos[t$95$0], $MachinePrecision] + 1), $MachinePrecision] * 1/2), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \frac{-1}{90} \cdot \left(angle \cdot \pi\right)\\
t_1 := \pi \cdot \frac{angle}{180}\\
t_2 := \left(\left(b \cdot \pi\right) \cdot angle\right) \cdot \frac{1}{180}\\
\mathbf{if}\;{\left(a \cdot \cos t\_1\right)}^{2} + {\left(b \cdot \sin t\_1\right)}^{2} \leq \frac{5890680864316837}{2945340432158418383223693624588738123559693482299075088767878449688292160397327779966295692450325070170031945807812908771881611572255401942922812303597144053805349165872996110766935565946816006053119311086960734516644260779498911850068592403100913453684334767056261910363295677456051671938422478104563288264146944}:\\
\;\;\;\;\left(\frac{1}{2} - \left(-\sin \left(\frac{-1}{2} \cdot \pi - t\_0\right)\right) \cdot \frac{1}{2}\right) \cdot \left(b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\cos t\_0 + 1\right) \cdot \frac{1}{2}\right) \cdot \left(a \cdot a\right) + t\_2 \cdot t\_2\\
\end{array}
if (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) < 2.0000000000000001e-297Initial program 80.4%
Applied rewrites68.2%
Taylor expanded in a around 0
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6425.6%
Applied rewrites25.6%
Applied rewrites25.6%
lift-cos.f64N/A
sin-+PI/2-revN/A
lift-PI.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
sub-negate-revN/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower--.f64N/A
lower-*.f64N/A
metadata-eval25.6%
Applied rewrites25.6%
if 2.0000000000000001e-297 < (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) Initial program 80.4%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6475.8%
Applied rewrites75.8%
Applied rewrites75.8%
(FPCore (a b angle) :precision binary64 (* (* (- 1/2 (* (cos (* 1/90 (* angle PI))) 1/2)) b) b))
double code(double a, double b, double angle) {
return ((0.5 - (cos((0.011111111111111112 * (angle * ((double) M_PI)))) * 0.5)) * b) * b;
}
public static double code(double a, double b, double angle) {
return ((0.5 - (Math.cos((0.011111111111111112 * (angle * Math.PI))) * 0.5)) * b) * b;
}
def code(a, b, angle): return ((0.5 - (math.cos((0.011111111111111112 * (angle * math.pi))) * 0.5)) * b) * b
function code(a, b, angle) return Float64(Float64(Float64(0.5 - Float64(cos(Float64(0.011111111111111112 * Float64(angle * pi))) * 0.5)) * b) * b) end
function tmp = code(a, b, angle) tmp = ((0.5 - (cos((0.011111111111111112 * (angle * pi))) * 0.5)) * b) * b; end
code[a_, b_, angle_] := N[(N[(N[(1/2 - N[(N[Cos[N[(1/90 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]
\left(\left(\frac{1}{2} - \cos \left(\frac{1}{90} \cdot \left(angle \cdot \pi\right)\right) \cdot \frac{1}{2}\right) \cdot b\right) \cdot b
Initial program 80.4%
Applied rewrites68.2%
Taylor expanded in a around 0
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6425.6%
Applied rewrites25.6%
Applied rewrites25.6%
Applied rewrites25.9%
(FPCore (a b angle) :precision binary64 (* (- 1/2 1/2) (* b b)))
double code(double a, double b, double angle) {
return (0.5 - 0.5) * (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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = (0.5d0 - 0.5d0) * (b * b)
end function
public static double code(double a, double b, double angle) {
return (0.5 - 0.5) * (b * b);
}
def code(a, b, angle): return (0.5 - 0.5) * (b * b)
function code(a, b, angle) return Float64(Float64(0.5 - 0.5) * Float64(b * b)) end
function tmp = code(a, b, angle) tmp = (0.5 - 0.5) * (b * b); end
code[a_, b_, angle_] := N[(N[(1/2 - 1/2), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]
\left(\frac{1}{2} - \frac{1}{2}\right) \cdot \left(b \cdot b\right)
Initial program 80.4%
Applied rewrites68.2%
Taylor expanded in a around 0
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6425.6%
Applied rewrites25.6%
Applied rewrites25.6%
Taylor expanded in angle around 0
Applied rewrites10.6%
herbie shell --seed 2025285 -o generate:evaluate
(FPCore (a b angle)
:name "ab-angle->ABCF C"
:precision binary64
(+ (pow (* a (cos (* PI (/ angle 180)))) 2) (pow (* b (sin (* PI (/ angle 180)))) 2)))