
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (/ angle 180.0)))) (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
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.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\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}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (/ angle 180.0)))) (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
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.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\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}
\end{array}
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* PI (* angle 0.005555555555555556)))
(t_1 (cos t_0))
(t_2 (* b (sin t_0))))
(fma
t_2
t_2
(*
(* a a)
(+
0.5
(*
0.5
(fma
t_1
t_1
(-
(fma
(cos
(*
(* angle (* (* (sqrt PI) (cbrt PI)) (cbrt (sqrt PI))))
0.011111111111111112))
-0.5
0.5)))))))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle * 0.005555555555555556);
double t_1 = cos(t_0);
double t_2 = b * sin(t_0);
return fma(t_2, t_2, ((a * a) * (0.5 + (0.5 * fma(t_1, t_1, -fma(cos(((angle * ((sqrt(((double) M_PI)) * cbrt(((double) M_PI))) * cbrt(sqrt(((double) M_PI))))) * 0.011111111111111112)), -0.5, 0.5))))));
}
function code(a, b, angle) t_0 = Float64(pi * Float64(angle * 0.005555555555555556)) t_1 = cos(t_0) t_2 = Float64(b * sin(t_0)) return fma(t_2, t_2, Float64(Float64(a * a) * Float64(0.5 + Float64(0.5 * fma(t_1, t_1, Float64(-fma(cos(Float64(Float64(angle * Float64(Float64(sqrt(pi) * cbrt(pi)) * cbrt(sqrt(pi)))) * 0.011111111111111112)), -0.5, 0.5))))))) end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]}, N[(t$95$2 * t$95$2 + N[(N[(a * a), $MachinePrecision] * N[(0.5 + N[(0.5 * N[(t$95$1 * t$95$1 + (-N[(N[Cos[N[(N[(angle * N[(N[(N[Sqrt[Pi], $MachinePrecision] * N[Power[Pi, 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[N[Sqrt[Pi], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(angle \cdot 0.005555555555555556\right)\\
t_1 := \cos t\_0\\
t_2 := b \cdot \sin t\_0\\
\mathsf{fma}\left(t\_2, t\_2, \left(a \cdot a\right) \cdot \left(0.5 + 0.5 \cdot \mathsf{fma}\left(t\_1, t\_1, -\mathsf{fma}\left(\cos \left(\left(angle \cdot \left(\left(\sqrt{\pi} \cdot \sqrt[3]{\pi}\right) \cdot \sqrt[3]{\sqrt{\pi}}\right)\right) \cdot 0.011111111111111112\right), -0.5, 0.5\right)\right)\right)\right)
\end{array}
\end{array}
Initial program 82.0%
+-commutativeN/A
unpow2N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr82.1%
metadata-evalN/A
div-invN/A
cos-2N/A
sqr-cos-aN/A
div-invN/A
metadata-evalN/A
sqr-sin-aN/A
div-invN/A
metadata-evalN/A
Applied egg-rr82.2%
add-cbrt-cubeN/A
pow1/3N/A
add-sqr-sqrtN/A
associate-*r*N/A
unpow-prod-downN/A
pow1/3N/A
*-lowering-*.f64N/A
pow-lowering-pow.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f64N/A
sqrt-lowering-sqrt.f64N/A
PI-lowering-PI.f64N/A
cbrt-lowering-cbrt.f64N/A
sqrt-lowering-sqrt.f64N/A
PI-lowering-PI.f6482.2
Applied egg-rr82.2%
associate-*l*N/A
*-commutativeN/A
unpow-prod-downN/A
pow1/3N/A
add-sqr-sqrtN/A
pow3N/A
rem-cbrt-cubeN/A
pow1/3N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
PI-lowering-PI.f64N/A
cbrt-lowering-cbrt.f64N/A
PI-lowering-PI.f6482.2
Applied egg-rr82.2%
Final simplification82.2%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* PI (* angle 0.005555555555555556)))
(t_1 (cos t_0))
(t_2 (* b (sin t_0))))
(fma
t_2
t_2
(*
(* a a)
(+
0.5
(*
0.5
(fma
t_1
t_1
(- (fma (cos (* 0.011111111111111112 (* PI angle))) -0.5 0.5)))))))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle * 0.005555555555555556);
double t_1 = cos(t_0);
double t_2 = b * sin(t_0);
return fma(t_2, t_2, ((a * a) * (0.5 + (0.5 * fma(t_1, t_1, -fma(cos((0.011111111111111112 * (((double) M_PI) * angle))), -0.5, 0.5))))));
}
function code(a, b, angle) t_0 = Float64(pi * Float64(angle * 0.005555555555555556)) t_1 = cos(t_0) t_2 = Float64(b * sin(t_0)) return fma(t_2, t_2, Float64(Float64(a * a) * Float64(0.5 + Float64(0.5 * fma(t_1, t_1, Float64(-fma(cos(Float64(0.011111111111111112 * Float64(pi * angle))), -0.5, 0.5))))))) end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]}, N[(t$95$2 * t$95$2 + N[(N[(a * a), $MachinePrecision] * N[(0.5 + N[(0.5 * N[(t$95$1 * t$95$1 + (-N[(N[Cos[N[(0.011111111111111112 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(angle \cdot 0.005555555555555556\right)\\
t_1 := \cos t\_0\\
t_2 := b \cdot \sin t\_0\\
\mathsf{fma}\left(t\_2, t\_2, \left(a \cdot a\right) \cdot \left(0.5 + 0.5 \cdot \mathsf{fma}\left(t\_1, t\_1, -\mathsf{fma}\left(\cos \left(0.011111111111111112 \cdot \left(\pi \cdot angle\right)\right), -0.5, 0.5\right)\right)\right)\right)
\end{array}
\end{array}
Initial program 82.0%
+-commutativeN/A
unpow2N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr82.1%
metadata-evalN/A
div-invN/A
cos-2N/A
sqr-cos-aN/A
div-invN/A
metadata-evalN/A
sqr-sin-aN/A
div-invN/A
metadata-evalN/A
Applied egg-rr82.2%
Final simplification82.2%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* b (sin (* PI (* angle 0.005555555555555556)))))
(t_1 (cos (* 0.011111111111111112 (* PI angle)))))
(fma
t_0
t_0
(* (* a a) (+ (+ 0.5 (+ 0.25 (* t_1 0.25))) (fma t_1 0.25 -0.25))))))
double code(double a, double b, double angle) {
double t_0 = b * sin((((double) M_PI) * (angle * 0.005555555555555556)));
double t_1 = cos((0.011111111111111112 * (((double) M_PI) * angle)));
return fma(t_0, t_0, ((a * a) * ((0.5 + (0.25 + (t_1 * 0.25))) + fma(t_1, 0.25, -0.25))));
}
function code(a, b, angle) t_0 = Float64(b * sin(Float64(pi * Float64(angle * 0.005555555555555556)))) t_1 = cos(Float64(0.011111111111111112 * Float64(pi * angle))) return fma(t_0, t_0, Float64(Float64(a * a) * Float64(Float64(0.5 + Float64(0.25 + Float64(t_1 * 0.25))) + fma(t_1, 0.25, -0.25)))) end
code[a_, b_, angle_] := Block[{t$95$0 = N[(b * N[Sin[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(0.011111111111111112 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(t$95$0 * t$95$0 + N[(N[(a * a), $MachinePrecision] * N[(N[(0.5 + N[(0.25 + N[(t$95$1 * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * 0.25 + -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\\
t_1 := \cos \left(0.011111111111111112 \cdot \left(\pi \cdot angle\right)\right)\\
\mathsf{fma}\left(t\_0, t\_0, \left(a \cdot a\right) \cdot \left(\left(0.5 + \left(0.25 + t\_1 \cdot 0.25\right)\right) + \mathsf{fma}\left(t\_1, 0.25, -0.25\right)\right)\right)
\end{array}
\end{array}
Initial program 82.0%
+-commutativeN/A
unpow2N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr82.1%
metadata-evalN/A
div-invN/A
cos-2N/A
sqr-cos-aN/A
div-invN/A
metadata-evalN/A
sqr-sin-aN/A
div-invN/A
metadata-evalN/A
Applied egg-rr82.2%
distribute-rgt-inN/A
associate-+r+N/A
+-lowering-+.f64N/A
Applied egg-rr82.1%
Final simplification82.1%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (* angle 0.005555555555555556))) (t_1 (* b (sin t_0)))) (fma t_1 t_1 (* (* a a) (+ 0.5 (* 0.5 (cos (* t_0 2.0))))))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle * 0.005555555555555556);
double t_1 = b * sin(t_0);
return fma(t_1, t_1, ((a * a) * (0.5 + (0.5 * cos((t_0 * 2.0))))));
}
function code(a, b, angle) t_0 = Float64(pi * Float64(angle * 0.005555555555555556)) t_1 = Float64(b * sin(t_0)) return fma(t_1, t_1, Float64(Float64(a * a) * Float64(0.5 + Float64(0.5 * cos(Float64(t_0 * 2.0)))))) end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]}, N[(t$95$1 * t$95$1 + N[(N[(a * a), $MachinePrecision] * N[(0.5 + N[(0.5 * N[Cos[N[(t$95$0 * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(angle \cdot 0.005555555555555556\right)\\
t_1 := b \cdot \sin t\_0\\
\mathsf{fma}\left(t\_1, t\_1, \left(a \cdot a\right) \cdot \left(0.5 + 0.5 \cdot \cos \left(t\_0 \cdot 2\right)\right)\right)
\end{array}
\end{array}
Initial program 82.0%
+-commutativeN/A
unpow2N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr82.1%
Final simplification82.1%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* b (sin (* PI (* angle 0.005555555555555556)))))) (fma t_0 t_0 (* a a))))
double code(double a, double b, double angle) {
double t_0 = b * sin((((double) M_PI) * (angle * 0.005555555555555556)));
return fma(t_0, t_0, (a * a));
}
function code(a, b, angle) t_0 = Float64(b * sin(Float64(pi * Float64(angle * 0.005555555555555556)))) return fma(t_0, t_0, Float64(a * a)) end
code[a_, b_, angle_] := Block[{t$95$0 = N[(b * N[Sin[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0 + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\\
\mathsf{fma}\left(t\_0, t\_0, a \cdot a\right)
\end{array}
\end{array}
Initial program 82.0%
+-commutativeN/A
unpow2N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr82.1%
metadata-evalN/A
div-invN/A
cos-2N/A
sqr-cos-aN/A
div-invN/A
metadata-evalN/A
sqr-sin-aN/A
div-invN/A
metadata-evalN/A
Applied egg-rr82.2%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6482.1
Simplified82.1%
(FPCore (a b angle) :precision binary64 (+ (* a a) (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return (a * a) + pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return (a * a) + Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0);
}
def code(a, b, angle): return (a * a) + math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0)
function code(a, b, angle) return Float64(Float64(a * a) + (Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a * a) + ((b * sin((pi * (angle / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 82.0%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6481.9
Simplified81.9%
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) 2e-172)
(* a a)
(if (<= (/ angle 180.0) 2e-13)
(fma
(* angle angle)
(* (* PI PI) (* 3.08641975308642e-5 (* b b)))
(* a a))
(fma
a
a
(*
(* b b)
(- 0.5 (* 0.5 (cos (* (* PI (* angle 0.005555555555555556)) 2.0)))))))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= 2e-172) {
tmp = a * a;
} else if ((angle / 180.0) <= 2e-13) {
tmp = fma((angle * angle), ((((double) M_PI) * ((double) M_PI)) * (3.08641975308642e-5 * (b * b))), (a * a));
} else {
tmp = fma(a, a, ((b * b) * (0.5 - (0.5 * cos(((((double) M_PI) * (angle * 0.005555555555555556)) * 2.0))))));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= 2e-172) tmp = Float64(a * a); elseif (Float64(angle / 180.0) <= 2e-13) tmp = fma(Float64(angle * angle), Float64(Float64(pi * pi) * Float64(3.08641975308642e-5 * Float64(b * b))), Float64(a * a)); else tmp = fma(a, a, Float64(Float64(b * b) * Float64(0.5 - Float64(0.5 * cos(Float64(Float64(pi * Float64(angle * 0.005555555555555556)) * 2.0)))))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], 2e-172], N[(a * a), $MachinePrecision], If[LessEqual[N[(angle / 180.0), $MachinePrecision], 2e-13], N[(N[(angle * angle), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * N[(3.08641975308642e-5 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(a * a + N[(N[(b * b), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 2 \cdot 10^{-172}:\\
\;\;\;\;a \cdot a\\
\mathbf{elif}\;\frac{angle}{180} \leq 2 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(angle \cdot angle, \left(\pi \cdot \pi\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right)\right), a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, a, \left(b \cdot b\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(\left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right) \cdot 2\right)\right)\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 2.0000000000000001e-172Initial program 85.7%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6462.7
Simplified62.7%
if 2.0000000000000001e-172 < (/.f64 angle #s(literal 180 binary64)) < 2.0000000000000001e-13Initial program 99.6%
Taylor expanded in angle around 0
accelerator-lowering-fma.f64N/A
Simplified69.6%
Taylor expanded in b around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6491.8
Simplified91.8%
if 2.0000000000000001e-13 < (/.f64 angle #s(literal 180 binary64)) Initial program 61.6%
rem-exp-logN/A
unpow2N/A
*-commutativeN/A
associate-*r*N/A
log-prodN/A
exp-sumN/A
rem-exp-logN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr29.3%
Taylor expanded in angle around 0
Simplified62.5%
Final simplification66.7%
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) 2e-172)
(* a a)
(if (<= (/ angle 180.0) 2e-13)
(fma
(* angle angle)
(* (* PI PI) (* 3.08641975308642e-5 (* b b)))
(* a a))
(fma
(* b b)
(fma -0.5 (cos (* angle (* 2.0 (* PI 0.005555555555555556)))) 0.5)
(* a a)))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= 2e-172) {
tmp = a * a;
} else if ((angle / 180.0) <= 2e-13) {
tmp = fma((angle * angle), ((((double) M_PI) * ((double) M_PI)) * (3.08641975308642e-5 * (b * b))), (a * a));
} else {
tmp = fma((b * b), fma(-0.5, cos((angle * (2.0 * (((double) M_PI) * 0.005555555555555556)))), 0.5), (a * a));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= 2e-172) tmp = Float64(a * a); elseif (Float64(angle / 180.0) <= 2e-13) tmp = fma(Float64(angle * angle), Float64(Float64(pi * pi) * Float64(3.08641975308642e-5 * Float64(b * b))), Float64(a * a)); else tmp = fma(Float64(b * b), fma(-0.5, cos(Float64(angle * Float64(2.0 * Float64(pi * 0.005555555555555556)))), 0.5), Float64(a * a)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], 2e-172], N[(a * a), $MachinePrecision], If[LessEqual[N[(angle / 180.0), $MachinePrecision], 2e-13], N[(N[(angle * angle), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * N[(3.08641975308642e-5 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(-0.5 * N[Cos[N[(angle * N[(2.0 * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 2 \cdot 10^{-172}:\\
\;\;\;\;a \cdot a\\
\mathbf{elif}\;\frac{angle}{180} \leq 2 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(angle \cdot angle, \left(\pi \cdot \pi\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right)\right), a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(-0.5, \cos \left(angle \cdot \left(2 \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right), 0.5\right), a \cdot a\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 2.0000000000000001e-172Initial program 85.7%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6462.7
Simplified62.7%
if 2.0000000000000001e-172 < (/.f64 angle #s(literal 180 binary64)) < 2.0000000000000001e-13Initial program 99.6%
Taylor expanded in angle around 0
accelerator-lowering-fma.f64N/A
Simplified69.6%
Taylor expanded in b around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6491.8
Simplified91.8%
if 2.0000000000000001e-13 < (/.f64 angle #s(literal 180 binary64)) Initial program 61.6%
*-commutativeN/A
unpow-prod-downN/A
*-lowering-*.f64N/A
Applied egg-rr61.8%
metadata-evalN/A
div-invN/A
associate-*r/N/A
clear-numN/A
unpow-1N/A
exp-to-powN/A
*-commutativeN/A
exp-prodN/A
pow-lowering-pow.f64N/A
exp-lowering-exp.f64N/A
clear-numN/A
associate-*r/N/A
log-recN/A
associate-*r/N/A
clear-numN/A
unpow-1N/A
exp-to-powN/A
rem-log-expN/A
neg-lowering-neg.f64N/A
rem-log-expN/A
exp-to-powN/A
unpow-1N/A
Applied egg-rr61.7%
Taylor expanded in angle around 0
accelerator-lowering-fma.f64N/A
Simplified62.2%
Final simplification66.7%
(FPCore (a b angle)
:precision binary64
(if (<= a 1.05e+62)
(fma
(*
(* angle (* PI PI))
(fma b (* b 3.08641975308642e-5) (* a (* a -3.08641975308642e-5))))
angle
(* a a))
(* a a)))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.05e+62) {
tmp = fma(((angle * (((double) M_PI) * ((double) M_PI))) * fma(b, (b * 3.08641975308642e-5), (a * (a * -3.08641975308642e-5)))), angle, (a * a));
} else {
tmp = a * a;
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 1.05e+62) tmp = fma(Float64(Float64(angle * Float64(pi * pi)) * fma(b, Float64(b * 3.08641975308642e-5), Float64(a * Float64(a * -3.08641975308642e-5)))), angle, Float64(a * a)); else tmp = Float64(a * a); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 1.05e+62], N[(N[(N[(angle * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * N[(b * N[(b * 3.08641975308642e-5), $MachinePrecision] + N[(a * N[(a * -3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * angle + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(a * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.05 \cdot 10^{+62}:\\
\;\;\;\;\mathsf{fma}\left(\left(angle \cdot \left(\pi \cdot \pi\right)\right) \cdot \mathsf{fma}\left(b, b \cdot 3.08641975308642 \cdot 10^{-5}, a \cdot \left(a \cdot -3.08641975308642 \cdot 10^{-5}\right)\right), angle, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 1.05e62Initial program 81.2%
Taylor expanded in angle around 0
accelerator-lowering-fma.f64N/A
Simplified53.2%
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr55.7%
if 1.05e62 < a Initial program 85.2%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6484.1
Simplified84.1%
(FPCore (a b angle)
:precision binary64
(if (<= b 8.5e-106)
(* a a)
(if (<= b 3.3e+136)
(fma
(* angle angle)
(* (* PI PI) (* 3.08641975308642e-5 (* b b)))
(* a a))
(* PI (* (* angle (* PI (* b b))) (* angle 3.08641975308642e-5))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 8.5e-106) {
tmp = a * a;
} else if (b <= 3.3e+136) {
tmp = fma((angle * angle), ((((double) M_PI) * ((double) M_PI)) * (3.08641975308642e-5 * (b * b))), (a * a));
} else {
tmp = ((double) M_PI) * ((angle * (((double) M_PI) * (b * b))) * (angle * 3.08641975308642e-5));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 8.5e-106) tmp = Float64(a * a); elseif (b <= 3.3e+136) tmp = fma(Float64(angle * angle), Float64(Float64(pi * pi) * Float64(3.08641975308642e-5 * Float64(b * b))), Float64(a * a)); else tmp = Float64(pi * Float64(Float64(angle * Float64(pi * Float64(b * b))) * Float64(angle * 3.08641975308642e-5))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 8.5e-106], N[(a * a), $MachinePrecision], If[LessEqual[b, 3.3e+136], N[(N[(angle * angle), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * N[(3.08641975308642e-5 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(Pi * N[(N[(angle * N[(Pi * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(angle * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8.5 \cdot 10^{-106}:\\
\;\;\;\;a \cdot a\\
\mathbf{elif}\;b \leq 3.3 \cdot 10^{+136}:\\
\;\;\;\;\mathsf{fma}\left(angle \cdot angle, \left(\pi \cdot \pi\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right)\right), a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \left(\left(angle \cdot \left(\pi \cdot \left(b \cdot b\right)\right)\right) \cdot \left(angle \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\\
\end{array}
\end{array}
if b < 8.4999999999999998e-106Initial program 81.3%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6466.6
Simplified66.6%
if 8.4999999999999998e-106 < b < 3.29999999999999992e136Initial program 74.3%
Taylor expanded in angle around 0
accelerator-lowering-fma.f64N/A
Simplified46.1%
Taylor expanded in b around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6469.4
Simplified69.4%
if 3.29999999999999992e136 < b Initial program 95.2%
Taylor expanded in angle around 0
accelerator-lowering-fma.f64N/A
Simplified36.8%
Taylor expanded in b around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6467.7
Simplified67.7%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6475.1
Applied egg-rr75.1%
Final simplification68.7%
(FPCore (a b angle) :precision binary64 (if (<= b 2.2e+87) (* a a) (* PI (* (* angle (* PI (* b b))) (* angle 3.08641975308642e-5)))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 2.2e+87) {
tmp = a * a;
} else {
tmp = ((double) M_PI) * ((angle * (((double) M_PI) * (b * b))) * (angle * 3.08641975308642e-5));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 2.2e+87) {
tmp = a * a;
} else {
tmp = Math.PI * ((angle * (Math.PI * (b * b))) * (angle * 3.08641975308642e-5));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 2.2e+87: tmp = a * a else: tmp = math.pi * ((angle * (math.pi * (b * b))) * (angle * 3.08641975308642e-5)) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 2.2e+87) tmp = Float64(a * a); else tmp = Float64(pi * Float64(Float64(angle * Float64(pi * Float64(b * b))) * Float64(angle * 3.08641975308642e-5))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 2.2e+87) tmp = a * a; else tmp = pi * ((angle * (pi * (b * b))) * (angle * 3.08641975308642e-5)); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 2.2e+87], N[(a * a), $MachinePrecision], N[(Pi * N[(N[(angle * N[(Pi * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(angle * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.2 \cdot 10^{+87}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\pi \cdot \left(\left(angle \cdot \left(\pi \cdot \left(b \cdot b\right)\right)\right) \cdot \left(angle \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\\
\end{array}
\end{array}
if b < 2.2000000000000001e87Initial program 80.3%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6467.3
Simplified67.3%
if 2.2000000000000001e87 < b Initial program 87.8%
Taylor expanded in angle around 0
accelerator-lowering-fma.f64N/A
Simplified40.5%
Taylor expanded in b around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6459.2
Simplified59.2%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6464.6
Applied egg-rr64.6%
Final simplification66.6%
(FPCore (a b angle) :precision binary64 (if (<= b 2.6e+87) (* a a) (* 3.08641975308642e-5 (* (* PI (* b b)) (* PI (* angle angle))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 2.6e+87) {
tmp = a * a;
} else {
tmp = 3.08641975308642e-5 * ((((double) M_PI) * (b * b)) * (((double) M_PI) * (angle * angle)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 2.6e+87) {
tmp = a * a;
} else {
tmp = 3.08641975308642e-5 * ((Math.PI * (b * b)) * (Math.PI * (angle * angle)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 2.6e+87: tmp = a * a else: tmp = 3.08641975308642e-5 * ((math.pi * (b * b)) * (math.pi * (angle * angle))) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 2.6e+87) tmp = Float64(a * a); else tmp = Float64(3.08641975308642e-5 * Float64(Float64(pi * Float64(b * b)) * Float64(pi * Float64(angle * angle)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 2.6e+87) tmp = a * a; else tmp = 3.08641975308642e-5 * ((pi * (b * b)) * (pi * (angle * angle))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 2.6e+87], N[(a * a), $MachinePrecision], N[(3.08641975308642e-5 * N[(N[(Pi * N[(b * b), $MachinePrecision]), $MachinePrecision] * N[(Pi * N[(angle * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.6 \cdot 10^{+87}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;3.08641975308642 \cdot 10^{-5} \cdot \left(\left(\pi \cdot \left(b \cdot b\right)\right) \cdot \left(\pi \cdot \left(angle \cdot angle\right)\right)\right)\\
\end{array}
\end{array}
if b < 2.59999999999999998e87Initial program 80.3%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6467.3
Simplified67.3%
if 2.59999999999999998e87 < b Initial program 87.8%
Taylor expanded in angle around 0
accelerator-lowering-fma.f64N/A
Simplified40.5%
Taylor expanded in b around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6459.2
Simplified59.2%
associate-*r*N/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f6459.3
Applied egg-rr59.3%
Final simplification65.4%
(FPCore (a b angle) :precision binary64 (if (<= b 2.6e+87) (* a a) (* (* PI (* PI (* b b))) (* (* angle angle) 3.08641975308642e-5))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 2.6e+87) {
tmp = a * a;
} else {
tmp = (((double) M_PI) * (((double) M_PI) * (b * b))) * ((angle * angle) * 3.08641975308642e-5);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 2.6e+87) {
tmp = a * a;
} else {
tmp = (Math.PI * (Math.PI * (b * b))) * ((angle * angle) * 3.08641975308642e-5);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 2.6e+87: tmp = a * a else: tmp = (math.pi * (math.pi * (b * b))) * ((angle * angle) * 3.08641975308642e-5) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 2.6e+87) tmp = Float64(a * a); else tmp = Float64(Float64(pi * Float64(pi * Float64(b * b))) * Float64(Float64(angle * angle) * 3.08641975308642e-5)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 2.6e+87) tmp = a * a; else tmp = (pi * (pi * (b * b))) * ((angle * angle) * 3.08641975308642e-5); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 2.6e+87], N[(a * a), $MachinePrecision], N[(N[(Pi * N[(Pi * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(angle * angle), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.6 \cdot 10^{+87}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\pi \cdot \left(\pi \cdot \left(b \cdot b\right)\right)\right) \cdot \left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\\
\end{array}
\end{array}
if b < 2.59999999999999998e87Initial program 80.3%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6467.3
Simplified67.3%
if 2.59999999999999998e87 < b Initial program 87.8%
Taylor expanded in angle around 0
accelerator-lowering-fma.f64N/A
Simplified40.5%
Taylor expanded in b around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6459.2
Simplified59.2%
(FPCore (a b angle) :precision binary64 (* a a))
double code(double a, double b, double angle) {
return a * a;
}
real(8) function code(a, b, angle)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = a * a
end function
public static double code(double a, double b, double angle) {
return a * a;
}
def code(a, b, angle): return a * a
function code(a, b, angle) return Float64(a * a) end
function tmp = code(a, b, angle) tmp = a * a; end
code[a_, b_, angle_] := N[(a * a), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a
\end{array}
Initial program 82.0%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6460.1
Simplified60.1%
herbie shell --seed 2024204
(FPCore (a b angle)
:name "ab-angle->ABCF C"
:precision binary64
(+ (pow (* a (cos (* PI (/ angle 180.0)))) 2.0) (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))