
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (/ angle 180.0) PI))) (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * ((double) M_PI);
return pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * Math.PI;
return Math.pow((a * Math.sin(t_0)), 2.0) + Math.pow((b * Math.cos(t_0)), 2.0);
}
def code(a, b, angle): t_0 = (angle / 180.0) * math.pi return math.pow((a * math.sin(t_0)), 2.0) + math.pow((b * math.cos(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(Float64(angle / 180.0) * pi) return Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = (angle / 180.0) * pi; tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[Power[N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (/ angle 180.0) PI))) (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * ((double) M_PI);
return pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * Math.PI;
return Math.pow((a * Math.sin(t_0)), 2.0) + Math.pow((b * Math.cos(t_0)), 2.0);
}
def code(a, b, angle): t_0 = (angle / 180.0) * math.pi return math.pow((a * math.sin(t_0)), 2.0) + math.pow((b * math.cos(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(Float64(angle / 180.0) * pi) return Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = (angle / 180.0) * pi; tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[Power[N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(let* ((t_0 (* angle_m (* PI (* a 0.005555555555555556)))))
(if (<= (/ angle_m 180.0) 5e-5)
(fma
(* b (fma 0.5 (cos (* PI (* angle_m 0.011111111111111112))) 0.5))
b
(* t_0 t_0))
(fma
(* a (fma (cos (* angle_m (* PI 0.011111111111111112))) -0.5 0.5))
a
(* (* b b) (* 1.0 1.0))))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double t_0 = angle_m * (((double) M_PI) * (a * 0.005555555555555556));
double tmp;
if ((angle_m / 180.0) <= 5e-5) {
tmp = fma((b * fma(0.5, cos((((double) M_PI) * (angle_m * 0.011111111111111112))), 0.5)), b, (t_0 * t_0));
} else {
tmp = fma((a * fma(cos((angle_m * (((double) M_PI) * 0.011111111111111112))), -0.5, 0.5)), a, ((b * b) * (1.0 * 1.0)));
}
return tmp;
}
angle_m = abs(angle) function code(a, b, angle_m) t_0 = Float64(angle_m * Float64(pi * Float64(a * 0.005555555555555556))) tmp = 0.0 if (Float64(angle_m / 180.0) <= 5e-5) tmp = fma(Float64(b * fma(0.5, cos(Float64(pi * Float64(angle_m * 0.011111111111111112))), 0.5)), b, Float64(t_0 * t_0)); else tmp = fma(Float64(a * fma(cos(Float64(angle_m * Float64(pi * 0.011111111111111112))), -0.5, 0.5)), a, Float64(Float64(b * b) * Float64(1.0 * 1.0))); end return tmp end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := Block[{t$95$0 = N[(angle$95$m * N[(Pi * N[(a * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(angle$95$m / 180.0), $MachinePrecision], 5e-5], N[(N[(b * N[(0.5 * N[Cos[N[(Pi * N[(angle$95$m * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] * b + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[Cos[N[(angle$95$m * N[(Pi * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision] * a + N[(N[(b * b), $MachinePrecision] * N[(1.0 * 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
t_0 := angle\_m \cdot \left(\pi \cdot \left(a \cdot 0.005555555555555556\right)\right)\\
\mathbf{if}\;\frac{angle\_m}{180} \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot \mathsf{fma}\left(0.5, \cos \left(\pi \cdot \left(angle\_m \cdot 0.011111111111111112\right)\right), 0.5\right), b, t\_0 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot \mathsf{fma}\left(\cos \left(angle\_m \cdot \left(\pi \cdot 0.011111111111111112\right)\right), -0.5, 0.5\right), a, \left(b \cdot b\right) \cdot \left(1 \cdot 1\right)\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 5.00000000000000024e-5Initial program 87.3%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
lower-*.f6482.3
Applied rewrites82.3%
rem-square-sqrtN/A
sqrt-unprodN/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-*r*N/A
sqrt-prodN/A
pow1/2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f6482.3
Applied rewrites82.3%
Applied rewrites82.3%
if 5.00000000000000024e-5 < (/.f64 angle #s(literal 180 binary64)) Initial program 58.2%
Taylor expanded in angle around 0
Applied rewrites58.6%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
associate-*l/N/A
div-invN/A
times-fracN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6458.7
Applied rewrites58.7%
Applied rewrites58.6%
Final simplification75.2%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(+
(pow (* a (sin (* (/ angle_m 180.0) PI))) 2.0)
(pow
(*
b
(cos
(*
(cbrt PI)
(* (cbrt PI) (* (cbrt PI) (* angle_m 0.005555555555555556))))))
2.0)))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow((a * sin(((angle_m / 180.0) * ((double) M_PI)))), 2.0) + pow((b * cos((cbrt(((double) M_PI)) * (cbrt(((double) M_PI)) * (cbrt(((double) M_PI)) * (angle_m * 0.005555555555555556)))))), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow((a * Math.sin(((angle_m / 180.0) * Math.PI))), 2.0) + Math.pow((b * Math.cos((Math.cbrt(Math.PI) * (Math.cbrt(Math.PI) * (Math.cbrt(Math.PI) * (angle_m * 0.005555555555555556)))))), 2.0);
}
angle_m = abs(angle) function code(a, b, angle_m) return Float64((Float64(a * sin(Float64(Float64(angle_m / 180.0) * pi))) ^ 2.0) + (Float64(b * cos(Float64(cbrt(pi) * Float64(cbrt(pi) * Float64(cbrt(pi) * Float64(angle_m * 0.005555555555555556)))))) ^ 2.0)) end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[N[(a * N[Sin[N[(N[(angle$95$m / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[N[(N[Power[Pi, 1/3], $MachinePrecision] * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[(angle$95$m * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{\left(a \cdot \sin \left(\frac{angle\_m}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(\sqrt[3]{\pi} \cdot \left(\sqrt[3]{\pi} \cdot \left(\sqrt[3]{\pi} \cdot \left(angle\_m \cdot 0.005555555555555556\right)\right)\right)\right)\right)}^{2}
\end{array}
Initial program 78.5%
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-cbrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
div-invN/A
lower-*.f64N/A
metadata-evalN/A
lift-PI.f64N/A
lower-cbrt.f6478.7
Applied rewrites78.7%
Final simplification78.7%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (+ (pow (* a (sin (* 0.005555555555555556 (/ PI (/ 1.0 angle_m))))) 2.0) (* b b)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow((a * sin((0.005555555555555556 * (((double) M_PI) / (1.0 / angle_m))))), 2.0) + (b * b);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow((a * Math.sin((0.005555555555555556 * (Math.PI / (1.0 / angle_m))))), 2.0) + (b * b);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow((a * math.sin((0.005555555555555556 * (math.pi / (1.0 / angle_m))))), 2.0) + (b * b)
angle_m = abs(angle) function code(a, b, angle_m) return Float64((Float64(a * sin(Float64(0.005555555555555556 * Float64(pi / Float64(1.0 / angle_m))))) ^ 2.0) + Float64(b * b)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = ((a * sin((0.005555555555555556 * (pi / (1.0 / angle_m))))) ^ 2.0) + (b * b); end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[N[(a * N[Sin[N[(0.005555555555555556 * N[(Pi / N[(1.0 / angle$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{\left(a \cdot \sin \left(0.005555555555555556 \cdot \frac{\pi}{\frac{1}{angle\_m}}\right)\right)}^{2} + b \cdot b
\end{array}
Initial program 78.5%
Taylor expanded in angle around 0
Applied rewrites78.6%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
associate-*l/N/A
div-invN/A
times-fracN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6478.7
Applied rewrites78.7%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6478.7
Applied rewrites78.7%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (+ (pow (* a (sin (* (/ angle_m 180.0) PI))) 2.0) (* b b)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow((a * sin(((angle_m / 180.0) * ((double) M_PI)))), 2.0) + (b * b);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow((a * Math.sin(((angle_m / 180.0) * Math.PI))), 2.0) + (b * b);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow((a * math.sin(((angle_m / 180.0) * math.pi))), 2.0) + (b * b)
angle_m = abs(angle) function code(a, b, angle_m) return Float64((Float64(a * sin(Float64(Float64(angle_m / 180.0) * pi))) ^ 2.0) + Float64(b * b)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = ((a * sin(((angle_m / 180.0) * pi))) ^ 2.0) + (b * b); end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[N[(a * N[Sin[N[(N[(angle$95$m / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{\left(a \cdot \sin \left(\frac{angle\_m}{180} \cdot \pi\right)\right)}^{2} + b \cdot b
\end{array}
Initial program 78.5%
Taylor expanded in angle around 0
Applied rewrites78.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6478.6
Applied rewrites78.6%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= (/ angle_m 180.0) 4e-148)
(* b b)
(if (<= (/ angle_m 180.0) 3e-25)
(fma
(* angle_m (* angle_m (* PI PI)))
(* 3.08641975308642e-5 (* a a))
(* b b))
(fma
(* a (fma (cos (* angle_m (* PI 0.011111111111111112))) -0.5 0.5))
a
(* (* b b) (* 1.0 1.0))))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if ((angle_m / 180.0) <= 4e-148) {
tmp = b * b;
} else if ((angle_m / 180.0) <= 3e-25) {
tmp = fma((angle_m * (angle_m * (((double) M_PI) * ((double) M_PI)))), (3.08641975308642e-5 * (a * a)), (b * b));
} else {
tmp = fma((a * fma(cos((angle_m * (((double) M_PI) * 0.011111111111111112))), -0.5, 0.5)), a, ((b * b) * (1.0 * 1.0)));
}
return tmp;
}
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (Float64(angle_m / 180.0) <= 4e-148) tmp = Float64(b * b); elseif (Float64(angle_m / 180.0) <= 3e-25) tmp = fma(Float64(angle_m * Float64(angle_m * Float64(pi * pi))), Float64(3.08641975308642e-5 * Float64(a * a)), Float64(b * b)); else tmp = fma(Float64(a * fma(cos(Float64(angle_m * Float64(pi * 0.011111111111111112))), -0.5, 0.5)), a, Float64(Float64(b * b) * Float64(1.0 * 1.0))); end return tmp end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[N[(angle$95$m / 180.0), $MachinePrecision], 4e-148], N[(b * b), $MachinePrecision], If[LessEqual[N[(angle$95$m / 180.0), $MachinePrecision], 3e-25], N[(N[(angle$95$m * N[(angle$95$m * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[Cos[N[(angle$95$m * N[(Pi * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision] * a + N[(N[(b * b), $MachinePrecision] * N[(1.0 * 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle\_m}{180} \leq 4 \cdot 10^{-148}:\\
\;\;\;\;b \cdot b\\
\mathbf{elif}\;\frac{angle\_m}{180} \leq 3 \cdot 10^{-25}:\\
\;\;\;\;\mathsf{fma}\left(angle\_m \cdot \left(angle\_m \cdot \left(\pi \cdot \pi\right)\right), 3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right), b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot \mathsf{fma}\left(\cos \left(angle\_m \cdot \left(\pi \cdot 0.011111111111111112\right)\right), -0.5, 0.5\right), a, \left(b \cdot b\right) \cdot \left(1 \cdot 1\right)\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 3.99999999999999974e-148Initial program 84.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6467.3
Applied rewrites67.3%
if 3.99999999999999974e-148 < (/.f64 angle #s(literal 180 binary64)) < 2.9999999999999998e-25Initial program 99.6%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites67.9%
Taylor expanded in b around 0
Applied rewrites96.5%
if 2.9999999999999998e-25 < (/.f64 angle #s(literal 180 binary64)) Initial program 60.8%
Taylor expanded in angle around 0
Applied rewrites60.6%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
associate-*l/N/A
div-invN/A
times-fracN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6460.7
Applied rewrites60.7%
Applied rewrites60.6%
Final simplification68.3%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= (/ angle_m 180.0) 4e-148)
(* b b)
(if (<= (/ angle_m 180.0) 5e-5)
(fma
(* angle_m (* angle_m (* PI PI)))
(* 3.08641975308642e-5 (* a a))
(* b b))
(fma
(* b 0.5)
b
(*
(* a a)
(fma (cos (* 0.011111111111111112 (* angle_m PI))) -0.5 0.5))))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if ((angle_m / 180.0) <= 4e-148) {
tmp = b * b;
} else if ((angle_m / 180.0) <= 5e-5) {
tmp = fma((angle_m * (angle_m * (((double) M_PI) * ((double) M_PI)))), (3.08641975308642e-5 * (a * a)), (b * b));
} else {
tmp = fma((b * 0.5), b, ((a * a) * fma(cos((0.011111111111111112 * (angle_m * ((double) M_PI)))), -0.5, 0.5)));
}
return tmp;
}
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (Float64(angle_m / 180.0) <= 4e-148) tmp = Float64(b * b); elseif (Float64(angle_m / 180.0) <= 5e-5) tmp = fma(Float64(angle_m * Float64(angle_m * Float64(pi * pi))), Float64(3.08641975308642e-5 * Float64(a * a)), Float64(b * b)); else tmp = fma(Float64(b * 0.5), b, Float64(Float64(a * a) * fma(cos(Float64(0.011111111111111112 * Float64(angle_m * pi))), -0.5, 0.5))); end return tmp end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[N[(angle$95$m / 180.0), $MachinePrecision], 4e-148], N[(b * b), $MachinePrecision], If[LessEqual[N[(angle$95$m / 180.0), $MachinePrecision], 5e-5], N[(N[(angle$95$m * N[(angle$95$m * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], N[(N[(b * 0.5), $MachinePrecision] * b + N[(N[(a * a), $MachinePrecision] * N[(N[Cos[N[(0.011111111111111112 * N[(angle$95$m * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle\_m}{180} \leq 4 \cdot 10^{-148}:\\
\;\;\;\;b \cdot b\\
\mathbf{elif}\;\frac{angle\_m}{180} \leq 5 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(angle\_m \cdot \left(angle\_m \cdot \left(\pi \cdot \pi\right)\right), 3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right), b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot 0.5, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(\cos \left(0.011111111111111112 \cdot \left(angle\_m \cdot \pi\right)\right), -0.5, 0.5\right)\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 3.99999999999999974e-148Initial program 84.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6467.3
Applied rewrites67.3%
if 3.99999999999999974e-148 < (/.f64 angle #s(literal 180 binary64)) < 5.00000000000000024e-5Initial program 99.7%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites66.7%
Taylor expanded in b around 0
Applied rewrites95.8%
if 5.00000000000000024e-5 < (/.f64 angle #s(literal 180 binary64)) Initial program 58.2%
Applied rewrites58.1%
Applied rewrites41.2%
Taylor expanded in b around 0
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6458.7
Applied rewrites58.7%
Final simplification68.4%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= b 2.1e+63)
(fma
(*
(* angle_m (* PI PI))
(fma b (* b -3.08641975308642e-5) (* 3.08641975308642e-5 (* a a))))
angle_m
(* b b))
(* (* b b) (fma 0.5 (cos (* 0.011111111111111112 (* angle_m PI))) 0.5))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (b <= 2.1e+63) {
tmp = fma(((angle_m * (((double) M_PI) * ((double) M_PI))) * fma(b, (b * -3.08641975308642e-5), (3.08641975308642e-5 * (a * a)))), angle_m, (b * b));
} else {
tmp = (b * b) * fma(0.5, cos((0.011111111111111112 * (angle_m * ((double) M_PI)))), 0.5);
}
return tmp;
}
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (b <= 2.1e+63) tmp = fma(Float64(Float64(angle_m * Float64(pi * pi)) * fma(b, Float64(b * -3.08641975308642e-5), Float64(3.08641975308642e-5 * Float64(a * a)))), angle_m, Float64(b * b)); else tmp = Float64(Float64(b * b) * fma(0.5, cos(Float64(0.011111111111111112 * Float64(angle_m * pi))), 0.5)); end return tmp end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[b, 2.1e+63], N[(N[(N[(angle$95$m * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * N[(b * N[(b * -3.08641975308642e-5), $MachinePrecision] + N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * angle$95$m + N[(b * b), $MachinePrecision]), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(0.5 * N[Cos[N[(0.011111111111111112 * N[(angle$95$m * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{+63}:\\
\;\;\;\;\mathsf{fma}\left(\left(angle\_m \cdot \left(\pi \cdot \pi\right)\right) \cdot \mathsf{fma}\left(b, b \cdot -3.08641975308642 \cdot 10^{-5}, 3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right), angle\_m, b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \mathsf{fma}\left(0.5, \cos \left(0.011111111111111112 \cdot \left(angle\_m \cdot \pi\right)\right), 0.5\right)\\
\end{array}
\end{array}
if b < 2.1000000000000002e63Initial program 76.1%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites46.9%
Applied rewrites55.3%
if 2.1000000000000002e63 < b Initial program 91.7%
Applied rewrites79.2%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6491.9
Applied rewrites91.9%
Final simplification61.0%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(let* ((t_0 (* angle_m (* angle_m (* PI PI)))))
(if (<= (/ angle_m 180.0) 4e-148)
(* b b)
(if (<= (/ angle_m 180.0) 7.5e+161)
(fma t_0 (* 3.08641975308642e-5 (* a a)) (* b b))
(if (<= (/ angle_m 180.0) 2e+286)
(* b b)
(fma
t_0
(fma (* a 3.08641975308642e-5) a (* b (* b -3.08641975308642e-5)))
(* b b)))))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double t_0 = angle_m * (angle_m * (((double) M_PI) * ((double) M_PI)));
double tmp;
if ((angle_m / 180.0) <= 4e-148) {
tmp = b * b;
} else if ((angle_m / 180.0) <= 7.5e+161) {
tmp = fma(t_0, (3.08641975308642e-5 * (a * a)), (b * b));
} else if ((angle_m / 180.0) <= 2e+286) {
tmp = b * b;
} else {
tmp = fma(t_0, fma((a * 3.08641975308642e-5), a, (b * (b * -3.08641975308642e-5))), (b * b));
}
return tmp;
}
angle_m = abs(angle) function code(a, b, angle_m) t_0 = Float64(angle_m * Float64(angle_m * Float64(pi * pi))) tmp = 0.0 if (Float64(angle_m / 180.0) <= 4e-148) tmp = Float64(b * b); elseif (Float64(angle_m / 180.0) <= 7.5e+161) tmp = fma(t_0, Float64(3.08641975308642e-5 * Float64(a * a)), Float64(b * b)); elseif (Float64(angle_m / 180.0) <= 2e+286) tmp = Float64(b * b); else tmp = fma(t_0, fma(Float64(a * 3.08641975308642e-5), a, Float64(b * Float64(b * -3.08641975308642e-5))), Float64(b * b)); end return tmp end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := Block[{t$95$0 = N[(angle$95$m * N[(angle$95$m * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(angle$95$m / 180.0), $MachinePrecision], 4e-148], N[(b * b), $MachinePrecision], If[LessEqual[N[(angle$95$m / 180.0), $MachinePrecision], 7.5e+161], N[(t$95$0 * N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(angle$95$m / 180.0), $MachinePrecision], 2e+286], N[(b * b), $MachinePrecision], N[(t$95$0 * N[(N[(a * 3.08641975308642e-5), $MachinePrecision] * a + N[(b * N[(b * -3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
t_0 := angle\_m \cdot \left(angle\_m \cdot \left(\pi \cdot \pi\right)\right)\\
\mathbf{if}\;\frac{angle\_m}{180} \leq 4 \cdot 10^{-148}:\\
\;\;\;\;b \cdot b\\
\mathbf{elif}\;\frac{angle\_m}{180} \leq 7.5 \cdot 10^{+161}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, 3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right), b \cdot b\right)\\
\mathbf{elif}\;\frac{angle\_m}{180} \leq 2 \cdot 10^{+286}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, \mathsf{fma}\left(a \cdot 3.08641975308642 \cdot 10^{-5}, a, b \cdot \left(b \cdot -3.08641975308642 \cdot 10^{-5}\right)\right), b \cdot b\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 3.99999999999999974e-148 or 7.4999999999999995e161 < (/.f64 angle #s(literal 180 binary64)) < 2.00000000000000007e286Initial program 78.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6464.0
Applied rewrites64.0%
if 3.99999999999999974e-148 < (/.f64 angle #s(literal 180 binary64)) < 7.4999999999999995e161Initial program 79.8%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites43.9%
Taylor expanded in b around 0
Applied rewrites75.6%
if 2.00000000000000007e286 < (/.f64 angle #s(literal 180 binary64)) Initial program 65.7%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites57.6%
Applied rewrites57.6%
Final simplification67.0%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(let* ((t_0
(fma
(* angle_m (* angle_m (* PI PI)))
(* 3.08641975308642e-5 (* a a))
(* b b))))
(if (<= (/ angle_m 180.0) 4e-148)
(* b b)
(if (<= (/ angle_m 180.0) 7.5e+161)
t_0
(if (<= (/ angle_m 180.0) 2e+286) (* b b) t_0)))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double t_0 = fma((angle_m * (angle_m * (((double) M_PI) * ((double) M_PI)))), (3.08641975308642e-5 * (a * a)), (b * b));
double tmp;
if ((angle_m / 180.0) <= 4e-148) {
tmp = b * b;
} else if ((angle_m / 180.0) <= 7.5e+161) {
tmp = t_0;
} else if ((angle_m / 180.0) <= 2e+286) {
tmp = b * b;
} else {
tmp = t_0;
}
return tmp;
}
angle_m = abs(angle) function code(a, b, angle_m) t_0 = fma(Float64(angle_m * Float64(angle_m * Float64(pi * pi))), Float64(3.08641975308642e-5 * Float64(a * a)), Float64(b * b)) tmp = 0.0 if (Float64(angle_m / 180.0) <= 4e-148) tmp = Float64(b * b); elseif (Float64(angle_m / 180.0) <= 7.5e+161) tmp = t_0; elseif (Float64(angle_m / 180.0) <= 2e+286) tmp = Float64(b * b); else tmp = t_0; end return tmp end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := Block[{t$95$0 = N[(N[(angle$95$m * N[(angle$95$m * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(angle$95$m / 180.0), $MachinePrecision], 4e-148], N[(b * b), $MachinePrecision], If[LessEqual[N[(angle$95$m / 180.0), $MachinePrecision], 7.5e+161], t$95$0, If[LessEqual[N[(angle$95$m / 180.0), $MachinePrecision], 2e+286], N[(b * b), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(angle\_m \cdot \left(angle\_m \cdot \left(\pi \cdot \pi\right)\right), 3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right), b \cdot b\right)\\
\mathbf{if}\;\frac{angle\_m}{180} \leq 4 \cdot 10^{-148}:\\
\;\;\;\;b \cdot b\\
\mathbf{elif}\;\frac{angle\_m}{180} \leq 7.5 \cdot 10^{+161}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{angle\_m}{180} \leq 2 \cdot 10^{+286}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 3.99999999999999974e-148 or 7.4999999999999995e161 < (/.f64 angle #s(literal 180 binary64)) < 2.00000000000000007e286Initial program 78.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6464.0
Applied rewrites64.0%
if 3.99999999999999974e-148 < (/.f64 angle #s(literal 180 binary64)) < 7.4999999999999995e161 or 2.00000000000000007e286 < (/.f64 angle #s(literal 180 binary64)) Initial program 78.5%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites45.2%
Taylor expanded in b around 0
Applied rewrites73.9%
Final simplification67.0%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= b 2.1e+63)
(fma
(*
(* angle_m (* PI PI))
(fma b (* b -3.08641975308642e-5) (* 3.08641975308642e-5 (* a a))))
angle_m
(* b b))
(* b b)))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (b <= 2.1e+63) {
tmp = fma(((angle_m * (((double) M_PI) * ((double) M_PI))) * fma(b, (b * -3.08641975308642e-5), (3.08641975308642e-5 * (a * a)))), angle_m, (b * b));
} else {
tmp = b * b;
}
return tmp;
}
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (b <= 2.1e+63) tmp = fma(Float64(Float64(angle_m * Float64(pi * pi)) * fma(b, Float64(b * -3.08641975308642e-5), Float64(3.08641975308642e-5 * Float64(a * a)))), angle_m, Float64(b * b)); else tmp = Float64(b * b); end return tmp end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[b, 2.1e+63], N[(N[(N[(angle$95$m * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * N[(b * N[(b * -3.08641975308642e-5), $MachinePrecision] + N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * angle$95$m + N[(b * b), $MachinePrecision]), $MachinePrecision], N[(b * b), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{+63}:\\
\;\;\;\;\mathsf{fma}\left(\left(angle\_m \cdot \left(\pi \cdot \pi\right)\right) \cdot \mathsf{fma}\left(b, b \cdot -3.08641975308642 \cdot 10^{-5}, 3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right), angle\_m, b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot b\\
\end{array}
\end{array}
if b < 2.1000000000000002e63Initial program 76.1%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites46.9%
Applied rewrites55.3%
if 2.1000000000000002e63 < b Initial program 91.7%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6492.0
Applied rewrites92.0%
Final simplification61.0%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (if (<= a 9e+147) (* b b) (* 3.08641975308642e-5 (* (* a a) (* (* angle_m PI) (* angle_m PI))))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (a <= 9e+147) {
tmp = b * b;
} else {
tmp = 3.08641975308642e-5 * ((a * a) * ((angle_m * ((double) M_PI)) * (angle_m * ((double) M_PI))));
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (a <= 9e+147) {
tmp = b * b;
} else {
tmp = 3.08641975308642e-5 * ((a * a) * ((angle_m * Math.PI) * (angle_m * Math.PI)));
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if a <= 9e+147: tmp = b * b else: tmp = 3.08641975308642e-5 * ((a * a) * ((angle_m * math.pi) * (angle_m * math.pi))) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (a <= 9e+147) tmp = Float64(b * b); else tmp = Float64(3.08641975308642e-5 * Float64(Float64(a * a) * Float64(Float64(angle_m * pi) * Float64(angle_m * pi)))); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (a <= 9e+147) tmp = b * b; else tmp = 3.08641975308642e-5 * ((a * a) * ((angle_m * pi) * (angle_m * pi))); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[a, 9e+147], N[(b * b), $MachinePrecision], N[(3.08641975308642e-5 * N[(N[(a * a), $MachinePrecision] * N[(N[(angle$95$m * Pi), $MachinePrecision] * N[(angle$95$m * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 9 \cdot 10^{+147}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;3.08641975308642 \cdot 10^{-5} \cdot \left(\left(a \cdot a\right) \cdot \left(\left(angle\_m \cdot \pi\right) \cdot \left(angle\_m \cdot \pi\right)\right)\right)\\
\end{array}
\end{array}
if a < 9.00000000000000016e147Initial program 76.8%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6463.5
Applied rewrites63.5%
if 9.00000000000000016e147 < a Initial program 91.3%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites50.8%
Taylor expanded in b around 0
Applied rewrites70.9%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (* b b))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return b * b;
}
angle_m = abs(angle)
real(8) function code(a, b, angle_m)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle_m
code = b * b
end function
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return b * b;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return b * b
angle_m = abs(angle) function code(a, b, angle_m) return Float64(b * b) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = b * b; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(b * b), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
b \cdot b
\end{array}
Initial program 78.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6460.3
Applied rewrites60.3%
herbie shell --seed 2024221
(FPCore (a b angle)
:name "ab-angle->ABCF A"
:precision binary64
(+ (pow (* a (sin (* (/ angle 180.0) PI))) 2.0) (pow (* b (cos (* (/ angle 180.0) PI))) 2.0)))