
(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 13 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}
(FPCore (a b angle) :precision binary64 (+ (* b b) (pow (* (sin (/ 0.005555555555555556 (/ 1.0 (* angle PI)))) a) 2.0)))
double code(double a, double b, double angle) {
return (b * b) + pow((sin((0.005555555555555556 / (1.0 / (angle * ((double) M_PI))))) * a), 2.0);
}
public static double code(double a, double b, double angle) {
return (b * b) + Math.pow((Math.sin((0.005555555555555556 / (1.0 / (angle * Math.PI)))) * a), 2.0);
}
def code(a, b, angle): return (b * b) + math.pow((math.sin((0.005555555555555556 / (1.0 / (angle * math.pi)))) * a), 2.0)
function code(a, b, angle) return Float64(Float64(b * b) + (Float64(sin(Float64(0.005555555555555556 / Float64(1.0 / Float64(angle * pi)))) * a) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (b * b) + ((sin((0.005555555555555556 / (1.0 / (angle * pi)))) * a) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(b * b), $MachinePrecision] + N[Power[N[(N[Sin[N[(0.005555555555555556 / N[(1.0 / N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot b + {\left(\sin \left(\frac{0.005555555555555556}{\frac{1}{angle \cdot \pi}}\right) \cdot a\right)}^{2}
\end{array}
Initial program 80.0%
Taylor expanded in angle around 0
Applied rewrites80.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6480.1
Applied rewrites80.1%
lift-/.f64N/A
clear-numN/A
div-invN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6480.2
Applied rewrites80.2%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6480.2
Applied rewrites80.2%
Final simplification80.2%
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) 5e+14)
(+
(pow (* 1.0 b) 2.0)
(pow (* (* (* PI 0.005555555555555556) angle) a) 2.0))
(/
1.0
(/
1.0
(fma
(* (* 1.0 b) 1.0)
b
(*
(* a a)
(-
0.5
(* (cos (* (* (* angle PI) 0.005555555555555556) 2.0)) 0.5))))))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= 5e+14) {
tmp = pow((1.0 * b), 2.0) + pow((((((double) M_PI) * 0.005555555555555556) * angle) * a), 2.0);
} else {
tmp = 1.0 / (1.0 / fma(((1.0 * b) * 1.0), b, ((a * a) * (0.5 - (cos((((angle * ((double) M_PI)) * 0.005555555555555556) * 2.0)) * 0.5)))));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= 5e+14) tmp = Float64((Float64(1.0 * b) ^ 2.0) + (Float64(Float64(Float64(pi * 0.005555555555555556) * angle) * a) ^ 2.0)); else tmp = Float64(1.0 / Float64(1.0 / fma(Float64(Float64(1.0 * b) * 1.0), b, Float64(Float64(a * a) * Float64(0.5 - Float64(cos(Float64(Float64(Float64(angle * pi) * 0.005555555555555556) * 2.0)) * 0.5)))))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], 5e+14], N[(N[Power[N[(1.0 * b), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * angle), $MachinePrecision] * a), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 / N[(N[(N[(1.0 * b), $MachinePrecision] * 1.0), $MachinePrecision] * b + N[(N[(a * a), $MachinePrecision] * N[(0.5 - N[(N[Cos[N[(N[(N[(angle * Pi), $MachinePrecision] * 0.005555555555555556), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 5 \cdot 10^{+14}:\\
\;\;\;\;{\left(1 \cdot b\right)}^{2} + {\left(\left(\left(\pi \cdot 0.005555555555555556\right) \cdot angle\right) \cdot a\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{\mathsf{fma}\left(\left(1 \cdot b\right) \cdot 1, b, \left(a \cdot a\right) \cdot \left(0.5 - \cos \left(\left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\right) \cdot 2\right) \cdot 0.5\right)\right)}}\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 5e14Initial program 85.5%
Taylor expanded in angle around 0
Applied rewrites85.5%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6482.3
Applied rewrites82.3%
if 5e14 < (/.f64 angle #s(literal 180 binary64)) Initial program 64.0%
Taylor expanded in angle around 0
Applied rewrites64.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6464.0
Applied rewrites64.0%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
Applied rewrites64.0%
Final simplification77.7%
(FPCore (a b angle) :precision binary64 (+ (pow (* (sin (* (/ angle 180.0) PI)) a) 2.0) (* b b)))
double code(double a, double b, double angle) {
return pow((sin(((angle / 180.0) * ((double) M_PI))) * a), 2.0) + (b * b);
}
public static double code(double a, double b, double angle) {
return Math.pow((Math.sin(((angle / 180.0) * Math.PI)) * a), 2.0) + (b * b);
}
def code(a, b, angle): return math.pow((math.sin(((angle / 180.0) * math.pi)) * a), 2.0) + (b * b)
function code(a, b, angle) return Float64((Float64(sin(Float64(Float64(angle / 180.0) * pi)) * a) ^ 2.0) + Float64(b * b)) end
function tmp = code(a, b, angle) tmp = ((sin(((angle / 180.0) * pi)) * a) ^ 2.0) + (b * b); end
code[a_, b_, angle_] := N[(N[Power[N[(N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision], 2.0], $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot a\right)}^{2} + b \cdot b
\end{array}
Initial program 80.0%
Taylor expanded in angle around 0
Applied rewrites80.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6480.1
Applied rewrites80.1%
Final simplification80.1%
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) 5e+14)
(fma
(* (* PI PI) (* (* (* angle a) angle) 3.08641975308642e-5))
a
(*
(* (+ (* (cos (* (* (* angle 0.005555555555555556) PI) 2.0)) 0.5) 0.5) b)
b))
(/
1.0
(/
1.0
(fma
(* (* 1.0 b) 1.0)
b
(*
(* a a)
(-
0.5
(* (cos (* (* (* angle PI) 0.005555555555555556) 2.0)) 0.5))))))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= 5e+14) {
tmp = fma(((((double) M_PI) * ((double) M_PI)) * (((angle * a) * angle) * 3.08641975308642e-5)), a, ((((cos((((angle * 0.005555555555555556) * ((double) M_PI)) * 2.0)) * 0.5) + 0.5) * b) * b));
} else {
tmp = 1.0 / (1.0 / fma(((1.0 * b) * 1.0), b, ((a * a) * (0.5 - (cos((((angle * ((double) M_PI)) * 0.005555555555555556) * 2.0)) * 0.5)))));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= 5e+14) tmp = fma(Float64(Float64(pi * pi) * Float64(Float64(Float64(angle * a) * angle) * 3.08641975308642e-5)), a, Float64(Float64(Float64(Float64(cos(Float64(Float64(Float64(angle * 0.005555555555555556) * pi) * 2.0)) * 0.5) + 0.5) * b) * b)); else tmp = Float64(1.0 / Float64(1.0 / fma(Float64(Float64(1.0 * b) * 1.0), b, Float64(Float64(a * a) * Float64(0.5 - Float64(cos(Float64(Float64(Float64(angle * pi) * 0.005555555555555556) * 2.0)) * 0.5)))))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], 5e+14], N[(N[(N[(Pi * Pi), $MachinePrecision] * N[(N[(N[(angle * a), $MachinePrecision] * angle), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision] * a + N[(N[(N[(N[(N[Cos[N[(N[(N[(angle * 0.005555555555555556), $MachinePrecision] * Pi), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision] + 0.5), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 / N[(N[(N[(1.0 * b), $MachinePrecision] * 1.0), $MachinePrecision] * b + N[(N[(a * a), $MachinePrecision] * N[(0.5 - N[(N[Cos[N[(N[(N[(angle * Pi), $MachinePrecision] * 0.005555555555555556), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 5 \cdot 10^{+14}:\\
\;\;\;\;\mathsf{fma}\left(\left(\pi \cdot \pi\right) \cdot \left(\left(\left(angle \cdot a\right) \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right), a, \left(\left(\cos \left(\left(\left(angle \cdot 0.005555555555555556\right) \cdot \pi\right) \cdot 2\right) \cdot 0.5 + 0.5\right) \cdot b\right) \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{\mathsf{fma}\left(\left(1 \cdot b\right) \cdot 1, b, \left(a \cdot a\right) \cdot \left(0.5 - \cos \left(\left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\right) \cdot 2\right) \cdot 0.5\right)\right)}}\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 5e14Initial program 85.5%
Applied rewrites60.2%
Taylor expanded in angle around 0
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f6480.5
Applied rewrites80.5%
if 5e14 < (/.f64 angle #s(literal 180 binary64)) Initial program 64.0%
Taylor expanded in angle around 0
Applied rewrites64.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6464.0
Applied rewrites64.0%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
Applied rewrites64.0%
Final simplification76.3%
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) 5e+14)
(fma
(* (* PI PI) (* (* (* angle a) angle) 3.08641975308642e-5))
a
(*
(* (+ (* (cos (* (* (* angle 0.005555555555555556) PI) 2.0)) 0.5) 0.5) b)
b))
(fma
(* (fma -0.5 (cos (* 0.011111111111111112 (* angle PI))) 0.5) a)
a
(* (* 1.0 b) b))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= 5e+14) {
tmp = fma(((((double) M_PI) * ((double) M_PI)) * (((angle * a) * angle) * 3.08641975308642e-5)), a, ((((cos((((angle * 0.005555555555555556) * ((double) M_PI)) * 2.0)) * 0.5) + 0.5) * b) * b));
} else {
tmp = fma((fma(-0.5, cos((0.011111111111111112 * (angle * ((double) M_PI)))), 0.5) * a), a, ((1.0 * b) * b));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= 5e+14) tmp = fma(Float64(Float64(pi * pi) * Float64(Float64(Float64(angle * a) * angle) * 3.08641975308642e-5)), a, Float64(Float64(Float64(Float64(cos(Float64(Float64(Float64(angle * 0.005555555555555556) * pi) * 2.0)) * 0.5) + 0.5) * b) * b)); else tmp = fma(Float64(fma(-0.5, cos(Float64(0.011111111111111112 * Float64(angle * pi))), 0.5) * a), a, Float64(Float64(1.0 * b) * b)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], 5e+14], N[(N[(N[(Pi * Pi), $MachinePrecision] * N[(N[(N[(angle * a), $MachinePrecision] * angle), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision] * a + N[(N[(N[(N[(N[Cos[N[(N[(N[(angle * 0.005555555555555556), $MachinePrecision] * Pi), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision] + 0.5), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-0.5 * N[Cos[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision] * a), $MachinePrecision] * a + N[(N[(1.0 * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 5 \cdot 10^{+14}:\\
\;\;\;\;\mathsf{fma}\left(\left(\pi \cdot \pi\right) \cdot \left(\left(\left(angle \cdot a\right) \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right), a, \left(\left(\cos \left(\left(\left(angle \cdot 0.005555555555555556\right) \cdot \pi\right) \cdot 2\right) \cdot 0.5 + 0.5\right) \cdot b\right) \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.5, \cos \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right), 0.5\right) \cdot a, a, \left(1 \cdot b\right) \cdot b\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 5e14Initial program 85.5%
Applied rewrites60.2%
Taylor expanded in angle around 0
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f6480.5
Applied rewrites80.5%
if 5e14 < (/.f64 angle #s(literal 180 binary64)) Initial program 64.0%
Applied rewrites33.3%
lift-exp.f64N/A
lift-log.f64N/A
rem-exp-log64.0
Applied rewrites63.9%
Taylor expanded in angle around 0
Applied rewrites64.0%
Final simplification76.3%
(FPCore (a b angle)
:precision binary64
(if (<= a 5.6e-15)
(fma
(* (fma -0.5 (cos (* 0.011111111111111112 (* angle PI))) 0.5) a)
a
(* (* 1.0 b) b))
(if (<= a 5e+139)
(+
(* (* (* (* a a) PI) PI) (* (* angle angle) 3.08641975308642e-5))
(pow (* 1.0 b) 2.0))
(* (* (* (* 3.08641975308642e-5 a) angle) (* angle a)) (* PI PI)))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 5.6e-15) {
tmp = fma((fma(-0.5, cos((0.011111111111111112 * (angle * ((double) M_PI)))), 0.5) * a), a, ((1.0 * b) * b));
} else if (a <= 5e+139) {
tmp = ((((a * a) * ((double) M_PI)) * ((double) M_PI)) * ((angle * angle) * 3.08641975308642e-5)) + pow((1.0 * b), 2.0);
} else {
tmp = (((3.08641975308642e-5 * a) * angle) * (angle * a)) * (((double) M_PI) * ((double) M_PI));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 5.6e-15) tmp = fma(Float64(fma(-0.5, cos(Float64(0.011111111111111112 * Float64(angle * pi))), 0.5) * a), a, Float64(Float64(1.0 * b) * b)); elseif (a <= 5e+139) tmp = Float64(Float64(Float64(Float64(Float64(a * a) * pi) * pi) * Float64(Float64(angle * angle) * 3.08641975308642e-5)) + (Float64(1.0 * b) ^ 2.0)); else tmp = Float64(Float64(Float64(Float64(3.08641975308642e-5 * a) * angle) * Float64(angle * a)) * Float64(pi * pi)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 5.6e-15], N[(N[(N[(-0.5 * N[Cos[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision] * a), $MachinePrecision] * a + N[(N[(1.0 * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 5e+139], N[(N[(N[(N[(N[(a * a), $MachinePrecision] * Pi), $MachinePrecision] * Pi), $MachinePrecision] * N[(N[(angle * angle), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision] + N[Power[N[(1.0 * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(3.08641975308642e-5 * a), $MachinePrecision] * angle), $MachinePrecision] * N[(angle * a), $MachinePrecision]), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 5.6 \cdot 10^{-15}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.5, \cos \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right), 0.5\right) \cdot a, a, \left(1 \cdot b\right) \cdot b\right)\\
\mathbf{elif}\;a \leq 5 \cdot 10^{+139}:\\
\;\;\;\;\left(\left(\left(a \cdot a\right) \cdot \pi\right) \cdot \pi\right) \cdot \left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) + {\left(1 \cdot b\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(3.08641975308642 \cdot 10^{-5} \cdot a\right) \cdot angle\right) \cdot \left(angle \cdot a\right)\right) \cdot \left(\pi \cdot \pi\right)\\
\end{array}
\end{array}
if a < 5.60000000000000028e-15Initial program 78.3%
Applied rewrites51.4%
lift-exp.f64N/A
lift-log.f64N/A
rem-exp-log70.6
Applied rewrites70.6%
Taylor expanded in angle around 0
Applied rewrites70.5%
if 5.60000000000000028e-15 < a < 5.0000000000000003e139Initial program 70.5%
Taylor expanded in angle around 0
Applied rewrites71.4%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f6466.9
Applied rewrites66.9%
if 5.0000000000000003e139 < a Initial program 95.6%
Taylor expanded in angle around 0
Applied rewrites95.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.9%
Taylor expanded in a around inf
Applied rewrites78.5%
Applied rewrites92.9%
Final simplification73.6%
(FPCore (a b angle)
:precision binary64
(if (<= a 5.6e-15)
(fma
(* (fma -0.5 (cos (* 0.011111111111111112 (* angle PI))) 0.5) a)
a
(* (* 1.0 b) b))
(if (<= a 5e+139)
(fma
(* (* (* 3.08641975308642e-5 (* a a)) PI) PI)
(* angle angle)
(* b b))
(* (* (* (* 3.08641975308642e-5 a) angle) (* angle a)) (* PI PI)))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 5.6e-15) {
tmp = fma((fma(-0.5, cos((0.011111111111111112 * (angle * ((double) M_PI)))), 0.5) * a), a, ((1.0 * b) * b));
} else if (a <= 5e+139) {
tmp = fma((((3.08641975308642e-5 * (a * a)) * ((double) M_PI)) * ((double) M_PI)), (angle * angle), (b * b));
} else {
tmp = (((3.08641975308642e-5 * a) * angle) * (angle * a)) * (((double) M_PI) * ((double) M_PI));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 5.6e-15) tmp = fma(Float64(fma(-0.5, cos(Float64(0.011111111111111112 * Float64(angle * pi))), 0.5) * a), a, Float64(Float64(1.0 * b) * b)); elseif (a <= 5e+139) tmp = fma(Float64(Float64(Float64(3.08641975308642e-5 * Float64(a * a)) * pi) * pi), Float64(angle * angle), Float64(b * b)); else tmp = Float64(Float64(Float64(Float64(3.08641975308642e-5 * a) * angle) * Float64(angle * a)) * Float64(pi * pi)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 5.6e-15], N[(N[(N[(-0.5 * N[Cos[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision] * a), $MachinePrecision] * a + N[(N[(1.0 * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 5e+139], N[(N[(N[(N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision] * Pi), $MachinePrecision] * N[(angle * angle), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(3.08641975308642e-5 * a), $MachinePrecision] * angle), $MachinePrecision] * N[(angle * a), $MachinePrecision]), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 5.6 \cdot 10^{-15}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.5, \cos \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right), 0.5\right) \cdot a, a, \left(1 \cdot b\right) \cdot b\right)\\
\mathbf{elif}\;a \leq 5 \cdot 10^{+139}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right) \cdot \pi\right) \cdot \pi, angle \cdot angle, b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(3.08641975308642 \cdot 10^{-5} \cdot a\right) \cdot angle\right) \cdot \left(angle \cdot a\right)\right) \cdot \left(\pi \cdot \pi\right)\\
\end{array}
\end{array}
if a < 5.60000000000000028e-15Initial program 78.3%
Applied rewrites51.4%
lift-exp.f64N/A
lift-log.f64N/A
rem-exp-log70.6
Applied rewrites70.6%
Taylor expanded in angle around 0
Applied rewrites70.5%
if 5.60000000000000028e-15 < a < 5.0000000000000003e139Initial program 70.5%
Taylor expanded in angle around 0
Applied rewrites71.4%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites31.7%
Taylor expanded in a around inf
Applied rewrites66.8%
if 5.0000000000000003e139 < a Initial program 95.6%
Taylor expanded in angle around 0
Applied rewrites95.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.9%
Taylor expanded in a around inf
Applied rewrites78.5%
Applied rewrites92.9%
Final simplification73.5%
(FPCore (a b angle)
:precision binary64
(if (<= a 3.75e-65)
(* (fma (cos (* 0.011111111111111112 (* angle PI))) 0.5 0.5) (* b b))
(if (<= a 5e+139)
(fma
(* (* (* 3.08641975308642e-5 (* a a)) PI) PI)
(* angle angle)
(* b b))
(* (* (* (* 3.08641975308642e-5 a) angle) (* angle a)) (* PI PI)))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 3.75e-65) {
tmp = fma(cos((0.011111111111111112 * (angle * ((double) M_PI)))), 0.5, 0.5) * (b * b);
} else if (a <= 5e+139) {
tmp = fma((((3.08641975308642e-5 * (a * a)) * ((double) M_PI)) * ((double) M_PI)), (angle * angle), (b * b));
} else {
tmp = (((3.08641975308642e-5 * a) * angle) * (angle * a)) * (((double) M_PI) * ((double) M_PI));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 3.75e-65) tmp = Float64(fma(cos(Float64(0.011111111111111112 * Float64(angle * pi))), 0.5, 0.5) * Float64(b * b)); elseif (a <= 5e+139) tmp = fma(Float64(Float64(Float64(3.08641975308642e-5 * Float64(a * a)) * pi) * pi), Float64(angle * angle), Float64(b * b)); else tmp = Float64(Float64(Float64(Float64(3.08641975308642e-5 * a) * angle) * Float64(angle * a)) * Float64(pi * pi)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 3.75e-65], N[(N[(N[Cos[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 5e+139], N[(N[(N[(N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision] * Pi), $MachinePrecision] * N[(angle * angle), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(3.08641975308642e-5 * a), $MachinePrecision] * angle), $MachinePrecision] * N[(angle * a), $MachinePrecision]), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.75 \cdot 10^{-65}:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right), 0.5, 0.5\right) \cdot \left(b \cdot b\right)\\
\mathbf{elif}\;a \leq 5 \cdot 10^{+139}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right) \cdot \pi\right) \cdot \pi, angle \cdot angle, b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(3.08641975308642 \cdot 10^{-5} \cdot a\right) \cdot angle\right) \cdot \left(angle \cdot a\right)\right) \cdot \left(\pi \cdot \pi\right)\\
\end{array}
\end{array}
if a < 3.7500000000000001e-65Initial program 79.4%
Applied rewrites50.3%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6464.6
Applied rewrites64.6%
if 3.7500000000000001e-65 < a < 5.0000000000000003e139Initial program 68.9%
Taylor expanded in angle around 0
Applied rewrites69.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites35.4%
Taylor expanded in a around inf
Applied rewrites64.3%
if 5.0000000000000003e139 < a Initial program 95.6%
Taylor expanded in angle around 0
Applied rewrites95.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.9%
Taylor expanded in a around inf
Applied rewrites78.5%
Applied rewrites92.9%
Final simplification69.0%
(FPCore (a b angle)
:precision binary64
(if (<= a 3.75e-65)
(* b b)
(if (<= a 5e+139)
(fma
(* (* (* 3.08641975308642e-5 (* a a)) PI) PI)
(* angle angle)
(* b b))
(* (* (* (* 3.08641975308642e-5 a) angle) (* angle a)) (* PI PI)))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 3.75e-65) {
tmp = b * b;
} else if (a <= 5e+139) {
tmp = fma((((3.08641975308642e-5 * (a * a)) * ((double) M_PI)) * ((double) M_PI)), (angle * angle), (b * b));
} else {
tmp = (((3.08641975308642e-5 * a) * angle) * (angle * a)) * (((double) M_PI) * ((double) M_PI));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 3.75e-65) tmp = Float64(b * b); elseif (a <= 5e+139) tmp = fma(Float64(Float64(Float64(3.08641975308642e-5 * Float64(a * a)) * pi) * pi), Float64(angle * angle), Float64(b * b)); else tmp = Float64(Float64(Float64(Float64(3.08641975308642e-5 * a) * angle) * Float64(angle * a)) * Float64(pi * pi)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 3.75e-65], N[(b * b), $MachinePrecision], If[LessEqual[a, 5e+139], N[(N[(N[(N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision] * Pi), $MachinePrecision] * N[(angle * angle), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(3.08641975308642e-5 * a), $MachinePrecision] * angle), $MachinePrecision] * N[(angle * a), $MachinePrecision]), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.75 \cdot 10^{-65}:\\
\;\;\;\;b \cdot b\\
\mathbf{elif}\;a \leq 5 \cdot 10^{+139}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right) \cdot \pi\right) \cdot \pi, angle \cdot angle, b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(3.08641975308642 \cdot 10^{-5} \cdot a\right) \cdot angle\right) \cdot \left(angle \cdot a\right)\right) \cdot \left(\pi \cdot \pi\right)\\
\end{array}
\end{array}
if a < 3.7500000000000001e-65Initial program 79.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6464.6
Applied rewrites64.6%
if 3.7500000000000001e-65 < a < 5.0000000000000003e139Initial program 68.9%
Taylor expanded in angle around 0
Applied rewrites69.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites35.4%
Taylor expanded in a around inf
Applied rewrites64.3%
if 5.0000000000000003e139 < a Initial program 95.6%
Taylor expanded in angle around 0
Applied rewrites95.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.9%
Taylor expanded in a around inf
Applied rewrites78.5%
Applied rewrites92.9%
Final simplification69.0%
(FPCore (a b angle) :precision binary64 (if (<= a 2.7e+139) (* b b) (* (* (* (* 3.08641975308642e-5 a) angle) (* angle a)) (* PI PI))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 2.7e+139) {
tmp = b * b;
} else {
tmp = (((3.08641975308642e-5 * a) * angle) * (angle * a)) * (((double) M_PI) * ((double) M_PI));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 2.7e+139) {
tmp = b * b;
} else {
tmp = (((3.08641975308642e-5 * a) * angle) * (angle * a)) * (Math.PI * Math.PI);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 2.7e+139: tmp = b * b else: tmp = (((3.08641975308642e-5 * a) * angle) * (angle * a)) * (math.pi * math.pi) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 2.7e+139) tmp = Float64(b * b); else tmp = Float64(Float64(Float64(Float64(3.08641975308642e-5 * a) * angle) * Float64(angle * a)) * Float64(pi * pi)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 2.7e+139) tmp = b * b; else tmp = (((3.08641975308642e-5 * a) * angle) * (angle * a)) * (pi * pi); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 2.7e+139], N[(b * b), $MachinePrecision], N[(N[(N[(N[(3.08641975308642e-5 * a), $MachinePrecision] * angle), $MachinePrecision] * N[(angle * a), $MachinePrecision]), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.7 \cdot 10^{+139}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(3.08641975308642 \cdot 10^{-5} \cdot a\right) \cdot angle\right) \cdot \left(angle \cdot a\right)\right) \cdot \left(\pi \cdot \pi\right)\\
\end{array}
\end{array}
if a < 2.6999999999999998e139Initial program 77.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6462.6
Applied rewrites62.6%
if 2.6999999999999998e139 < a Initial program 95.6%
Taylor expanded in angle around 0
Applied rewrites95.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.9%
Taylor expanded in a around inf
Applied rewrites78.5%
Applied rewrites92.9%
Final simplification67.4%
(FPCore (a b angle) :precision binary64 (if (<= a 5e+139) (* b b) (* (* (* (* (* angle a) angle) a) 3.08641975308642e-5) (* PI PI))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 5e+139) {
tmp = b * b;
} else {
tmp = ((((angle * a) * angle) * a) * 3.08641975308642e-5) * (((double) M_PI) * ((double) M_PI));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 5e+139) {
tmp = b * b;
} else {
tmp = ((((angle * a) * angle) * a) * 3.08641975308642e-5) * (Math.PI * Math.PI);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 5e+139: tmp = b * b else: tmp = ((((angle * a) * angle) * a) * 3.08641975308642e-5) * (math.pi * math.pi) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 5e+139) tmp = Float64(b * b); else tmp = Float64(Float64(Float64(Float64(Float64(angle * a) * angle) * a) * 3.08641975308642e-5) * Float64(pi * pi)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 5e+139) tmp = b * b; else tmp = ((((angle * a) * angle) * a) * 3.08641975308642e-5) * (pi * pi); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 5e+139], N[(b * b), $MachinePrecision], N[(N[(N[(N[(N[(angle * a), $MachinePrecision] * angle), $MachinePrecision] * a), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 5 \cdot 10^{+139}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\left(angle \cdot a\right) \cdot angle\right) \cdot a\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \left(\pi \cdot \pi\right)\\
\end{array}
\end{array}
if a < 5.0000000000000003e139Initial program 77.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6462.6
Applied rewrites62.6%
if 5.0000000000000003e139 < a Initial program 95.6%
Taylor expanded in angle around 0
Applied rewrites95.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.9%
Taylor expanded in a around inf
Applied rewrites78.5%
Applied rewrites88.2%
Final simplification66.6%
(FPCore (a b angle) :precision binary64 (if (<= a 5.2e+139) (* b b) (* (* (* (* angle angle) a) (* PI PI)) (* 3.08641975308642e-5 a))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 5.2e+139) {
tmp = b * b;
} else {
tmp = (((angle * angle) * a) * (((double) M_PI) * ((double) M_PI))) * (3.08641975308642e-5 * a);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 5.2e+139) {
tmp = b * b;
} else {
tmp = (((angle * angle) * a) * (Math.PI * Math.PI)) * (3.08641975308642e-5 * a);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 5.2e+139: tmp = b * b else: tmp = (((angle * angle) * a) * (math.pi * math.pi)) * (3.08641975308642e-5 * a) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 5.2e+139) tmp = Float64(b * b); else tmp = Float64(Float64(Float64(Float64(angle * angle) * a) * Float64(pi * pi)) * Float64(3.08641975308642e-5 * a)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 5.2e+139) tmp = b * b; else tmp = (((angle * angle) * a) * (pi * pi)) * (3.08641975308642e-5 * a); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 5.2e+139], N[(b * b), $MachinePrecision], N[(N[(N[(N[(angle * angle), $MachinePrecision] * a), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * N[(3.08641975308642e-5 * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 5.2 \cdot 10^{+139}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(angle \cdot angle\right) \cdot a\right) \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot a\right)\\
\end{array}
\end{array}
if a < 5.20000000000000044e139Initial program 77.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6462.6
Applied rewrites62.6%
if 5.20000000000000044e139 < a Initial program 95.6%
Taylor expanded in angle around 0
Applied rewrites95.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.9%
Taylor expanded in a around inf
Applied rewrites78.5%
Applied rewrites78.6%
Final simplification65.1%
(FPCore (a b angle) :precision binary64 (* b b))
double code(double a, double b, double angle) {
return b * b;
}
real(8) function code(a, b, angle)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = b * b
end function
public static double code(double a, double b, double angle) {
return b * b;
}
def code(a, b, angle): return b * b
function code(a, b, angle) return Float64(b * b) end
function tmp = code(a, b, angle) tmp = b * b; end
code[a_, b_, angle_] := N[(b * b), $MachinePrecision]
\begin{array}{l}
\\
b \cdot b
\end{array}
Initial program 80.0%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6456.7
Applied rewrites56.7%
herbie shell --seed 2024235
(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)))