
(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 13 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 (cos (* PI (* angle 0.005555555555555556))))
(t_1 (* b (sin (* (* PI angle) 0.005555555555555556)))))
(fma
t_1
t_1
(*
a
(*
a
(fma
0.5
(fma
t_0
t_0
(-
0.0
(fma
(cos
(*
(* angle (* (sqrt (* PI (sqrt PI))) (sqrt (sqrt PI))))
0.011111111111111112))
-0.5
0.5)))
0.5))))))
double code(double a, double b, double angle) {
double t_0 = cos((((double) M_PI) * (angle * 0.005555555555555556)));
double t_1 = b * sin(((((double) M_PI) * angle) * 0.005555555555555556));
return fma(t_1, t_1, (a * (a * fma(0.5, fma(t_0, t_0, (0.0 - fma(cos(((angle * (sqrt((((double) M_PI) * sqrt(((double) M_PI)))) * sqrt(sqrt(((double) M_PI))))) * 0.011111111111111112)), -0.5, 0.5))), 0.5))));
}
function code(a, b, angle) t_0 = cos(Float64(pi * Float64(angle * 0.005555555555555556))) t_1 = Float64(b * sin(Float64(Float64(pi * angle) * 0.005555555555555556))) return fma(t_1, t_1, Float64(a * Float64(a * fma(0.5, fma(t_0, t_0, Float64(0.0 - fma(cos(Float64(Float64(angle * Float64(sqrt(Float64(pi * sqrt(pi))) * sqrt(sqrt(pi)))) * 0.011111111111111112)), -0.5, 0.5))), 0.5)))) end
code[a_, b_, angle_] := Block[{t$95$0 = N[Cos[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(b * N[Sin[N[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(t$95$1 * t$95$1 + N[(a * N[(a * N[(0.5 * N[(t$95$0 * t$95$0 + N[(0.0 - N[(N[Cos[N[(N[(angle * N[(N[Sqrt[N[(Pi * N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Sqrt[Pi], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\\
t_1 := b \cdot \sin \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)\\
\mathsf{fma}\left(t\_1, t\_1, a \cdot \left(a \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(t\_0, t\_0, 0 - \mathsf{fma}\left(\cos \left(\left(angle \cdot \left(\sqrt{\pi \cdot \sqrt{\pi}} \cdot \sqrt{\sqrt{\pi}}\right)\right) \cdot 0.011111111111111112\right), -0.5, 0.5\right)\right), 0.5\right)\right)\right)
\end{array}
\end{array}
Initial program 74.3%
associate-*r/N/A
clear-numN/A
inv-powN/A
pow-to-expN/A
exp-lowering-exp.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6441.8
Applied egg-rr41.8%
Applied egg-rr74.4%
Applied egg-rr74.5%
add-sqr-sqrtN/A
sqrt-unprodN/A
add-sqr-sqrtN/A
associate-*r*N/A
add-sqr-sqrtN/A
pow3N/A
sqrt-prodN/A
pow1/2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
pow3N/A
add-sqr-sqrtN/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
sqrt-lowering-sqrt.f64N/A
PI-lowering-PI.f64N/A
pow1/2N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
Applied egg-rr74.5%
Final simplification74.5%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (cos (* PI (* angle 0.005555555555555556))))
(t_1 (* b (sin (* (* PI angle) 0.005555555555555556)))))
(fma
t_1
t_1
(*
a
(*
a
(fma
0.5
(fma
t_0
t_0
(- 0.0 (fma (cos (* (* PI angle) 0.011111111111111112)) -0.5 0.5)))
0.5))))))
double code(double a, double b, double angle) {
double t_0 = cos((((double) M_PI) * (angle * 0.005555555555555556)));
double t_1 = b * sin(((((double) M_PI) * angle) * 0.005555555555555556));
return fma(t_1, t_1, (a * (a * fma(0.5, fma(t_0, t_0, (0.0 - fma(cos(((((double) M_PI) * angle) * 0.011111111111111112)), -0.5, 0.5))), 0.5))));
}
function code(a, b, angle) t_0 = cos(Float64(pi * Float64(angle * 0.005555555555555556))) t_1 = Float64(b * sin(Float64(Float64(pi * angle) * 0.005555555555555556))) return fma(t_1, t_1, Float64(a * Float64(a * fma(0.5, fma(t_0, t_0, Float64(0.0 - fma(cos(Float64(Float64(pi * angle) * 0.011111111111111112)), -0.5, 0.5))), 0.5)))) end
code[a_, b_, angle_] := Block[{t$95$0 = N[Cos[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(b * N[Sin[N[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(t$95$1 * t$95$1 + N[(a * N[(a * N[(0.5 * N[(t$95$0 * t$95$0 + N[(0.0 - N[(N[Cos[N[(N[(Pi * angle), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\\
t_1 := b \cdot \sin \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)\\
\mathsf{fma}\left(t\_1, t\_1, a \cdot \left(a \cdot \mathsf{fma}\left(0.5, \mathsf{fma}\left(t\_0, t\_0, 0 - \mathsf{fma}\left(\cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right), -0.5, 0.5\right)\right), 0.5\right)\right)\right)
\end{array}
\end{array}
Initial program 74.3%
associate-*r/N/A
clear-numN/A
inv-powN/A
pow-to-expN/A
exp-lowering-exp.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6441.8
Applied egg-rr41.8%
Applied egg-rr74.4%
Applied egg-rr74.5%
Final simplification74.5%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* b (sin (* (* PI angle) 0.005555555555555556)))))
(fma
t_0
t_0
(* a (* a (fma 0.5 (cos (* (* PI angle) 0.011111111111111112)) 0.5))))))
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 * fma(0.5, cos(((((double) M_PI) * angle) * 0.011111111111111112)), 0.5))));
}
function code(a, b, angle) t_0 = Float64(b * sin(Float64(Float64(pi * angle) * 0.005555555555555556))) return fma(t_0, t_0, Float64(a * Float64(a * fma(0.5, cos(Float64(Float64(pi * angle) * 0.011111111111111112)), 0.5)))) end
code[a_, b_, angle_] := Block[{t$95$0 = N[(b * N[Sin[N[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0 + N[(a * N[(a * N[(0.5 * N[Cos[N[(N[(Pi * angle), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot \sin \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)\\
\mathsf{fma}\left(t\_0, t\_0, a \cdot \left(a \cdot \mathsf{fma}\left(0.5, \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right), 0.5\right)\right)\right)
\end{array}
\end{array}
Initial program 74.3%
associate-*r/N/A
clear-numN/A
inv-powN/A
pow-to-expN/A
exp-lowering-exp.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6441.8
Applied egg-rr41.8%
Applied egg-rr74.4%
(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(Float64(pi * 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[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $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(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)\\
\mathsf{fma}\left(t\_0, t\_0, a \cdot a\right)
\end{array}
\end{array}
Initial program 74.3%
associate-*r/N/A
clear-numN/A
inv-powN/A
pow-to-expN/A
exp-lowering-exp.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6441.8
Applied egg-rr41.8%
Applied egg-rr74.4%
Taylor expanded in angle around 0
Simplified73.6%
Final simplification73.6%
(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 74.3%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6473.6
Simplified73.6%
(FPCore (a b angle)
:precision binary64
(if (<= angle 3.5e-162)
(* a a)
(if (<= angle 6600000.0)
(fma
a
(* a (fma 0.5 (cos (* (* PI angle) 0.011111111111111112)) 0.5))
(* (* b b) (* (* angle angle) (* PI (* PI 3.08641975308642e-5)))))
(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 <= 3.5e-162) {
tmp = a * a;
} else if (angle <= 6600000.0) {
tmp = fma(a, (a * fma(0.5, cos(((((double) M_PI) * angle) * 0.011111111111111112)), 0.5)), ((b * b) * ((angle * angle) * (((double) M_PI) * (((double) M_PI) * 3.08641975308642e-5)))));
} 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 (angle <= 3.5e-162) tmp = Float64(a * a); elseif (angle <= 6600000.0) tmp = fma(a, Float64(a * fma(0.5, cos(Float64(Float64(pi * angle) * 0.011111111111111112)), 0.5)), Float64(Float64(b * b) * Float64(Float64(angle * angle) * Float64(pi * Float64(pi * 3.08641975308642e-5))))); 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[angle, 3.5e-162], N[(a * a), $MachinePrecision], If[LessEqual[angle, 6600000.0], N[(a * N[(a * N[(0.5 * N[Cos[N[(N[(Pi * angle), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(N[(angle * angle), $MachinePrecision] * N[(Pi * N[(Pi * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}\;angle \leq 3.5 \cdot 10^{-162}:\\
\;\;\;\;a \cdot a\\
\mathbf{elif}\;angle \leq 6600000:\\
\;\;\;\;\mathsf{fma}\left(a, a \cdot \mathsf{fma}\left(0.5, \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right), 0.5\right), \left(b \cdot b\right) \cdot \left(\left(angle \cdot angle\right) \cdot \left(\pi \cdot \left(\pi \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\right)\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 angle < 3.4999999999999999e-162Initial program 79.0%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6457.2
Simplified57.2%
if 3.4999999999999999e-162 < angle < 6.6e6Initial program 99.3%
associate-*r/N/A
clear-numN/A
inv-powN/A
pow-to-expN/A
exp-lowering-exp.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6499.0
Applied egg-rr99.0%
Applied egg-rr99.2%
Taylor expanded in b around 0
unpow2N/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
Simplified96.9%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/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.f6496.7
Simplified96.7%
if 6.6e6 < angle Initial program 51.2%
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-rr20.2%
Taylor expanded in angle around 0
Simplified51.4%
Final simplification61.2%
(FPCore (a b angle)
:precision binary64
(if (<= angle 1.8e-162)
(* a a)
(if (<= angle 470.0)
(fma
(* angle angle)
(* PI (* PI (* (* b b) 3.08641975308642e-5)))
(* 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 <= 1.8e-162) {
tmp = a * a;
} else if (angle <= 470.0) {
tmp = fma((angle * angle), (((double) M_PI) * (((double) M_PI) * ((b * b) * 3.08641975308642e-5))), (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 (angle <= 1.8e-162) tmp = Float64(a * a); elseif (angle <= 470.0) tmp = fma(Float64(angle * angle), Float64(pi * Float64(pi * Float64(Float64(b * b) * 3.08641975308642e-5))), 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[angle, 1.8e-162], N[(a * a), $MachinePrecision], If[LessEqual[angle, 470.0], N[(N[(angle * angle), $MachinePrecision] * N[(Pi * N[(Pi * N[(N[(b * b), $MachinePrecision] * 3.08641975308642e-5), $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}\;angle \leq 1.8 \cdot 10^{-162}:\\
\;\;\;\;a \cdot a\\
\mathbf{elif}\;angle \leq 470:\\
\;\;\;\;\mathsf{fma}\left(angle \cdot angle, \pi \cdot \left(\pi \cdot \left(\left(b \cdot b\right) \cdot 3.08641975308642 \cdot 10^{-5}\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 angle < 1.7999999999999999e-162Initial program 79.0%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6457.2
Simplified57.2%
if 1.7999999999999999e-162 < angle < 470Initial program 99.8%
Taylor expanded in angle around 0
accelerator-lowering-fma.f64N/A
Simplified67.6%
Taylor expanded in b around inf
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6496.4
Simplified96.4%
if 470 < angle Initial program 52.3%
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-rr20.8%
Taylor expanded in angle around 0
Simplified50.6%
Final simplification60.6%
(FPCore (a b angle)
:precision binary64
(if (<= a 1.7e+54)
(fma
(*
(* PI angle)
(* PI (fma b (* b 3.08641975308642e-5) (* a (* a -3.08641975308642e-5)))))
angle
(* a a))
(* (* a a) (fma 0.5 (cos (* (* PI angle) 0.011111111111111112)) 0.5))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.7e+54) {
tmp = fma(((((double) M_PI) * angle) * (((double) M_PI) * fma(b, (b * 3.08641975308642e-5), (a * (a * -3.08641975308642e-5))))), angle, (a * a));
} else {
tmp = (a * a) * fma(0.5, cos(((((double) M_PI) * angle) * 0.011111111111111112)), 0.5);
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 1.7e+54) tmp = fma(Float64(Float64(pi * angle) * Float64(pi * fma(b, Float64(b * 3.08641975308642e-5), Float64(a * Float64(a * -3.08641975308642e-5))))), angle, Float64(a * a)); else tmp = Float64(Float64(a * a) * fma(0.5, cos(Float64(Float64(pi * angle) * 0.011111111111111112)), 0.5)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 1.7e+54], N[(N[(N[(Pi * angle), $MachinePrecision] * N[(Pi * N[(b * N[(b * 3.08641975308642e-5), $MachinePrecision] + N[(a * N[(a * -3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * angle + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * N[(0.5 * N[Cos[N[(N[(Pi * angle), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.7 \cdot 10^{+54}:\\
\;\;\;\;\mathsf{fma}\left(\left(\pi \cdot angle\right) \cdot \left(\pi \cdot \mathsf{fma}\left(b, b \cdot 3.08641975308642 \cdot 10^{-5}, a \cdot \left(a \cdot -3.08641975308642 \cdot 10^{-5}\right)\right)\right), angle, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \mathsf{fma}\left(0.5, \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right), 0.5\right)\\
\end{array}
\end{array}
if a < 1.7e54Initial program 70.0%
Taylor expanded in angle around 0
accelerator-lowering-fma.f64N/A
Simplified40.8%
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr44.8%
if 1.7e54 < a Initial program 87.5%
associate-*r/N/A
clear-numN/A
inv-powN/A
pow-to-expN/A
exp-lowering-exp.f64N/A
*-lowering-*.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6448.1
Applied egg-rr48.1%
Applied egg-rr87.5%
Taylor expanded in b around 0
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6484.4
Simplified84.4%
Final simplification54.7%
(FPCore (a b angle)
:precision binary64
(if (<= a 4.8e+54)
(fma
(*
(* PI angle)
(* 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 <= 4.8e+54) {
tmp = fma(((((double) M_PI) * angle) * (((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 <= 4.8e+54) tmp = fma(Float64(Float64(pi * angle) * Float64(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, 4.8e+54], N[(N[(N[(Pi * angle), $MachinePrecision] * N[(Pi * N[(b * N[(b * 3.08641975308642e-5), $MachinePrecision] + N[(a * N[(a * -3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * angle + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(a * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 4.8 \cdot 10^{+54}:\\
\;\;\;\;\mathsf{fma}\left(\left(\pi \cdot angle\right) \cdot \left(\pi \cdot \mathsf{fma}\left(b, b \cdot 3.08641975308642 \cdot 10^{-5}, a \cdot \left(a \cdot -3.08641975308642 \cdot 10^{-5}\right)\right)\right), angle, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 4.79999999999999997e54Initial program 70.0%
Taylor expanded in angle around 0
accelerator-lowering-fma.f64N/A
Simplified40.8%
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr44.8%
if 4.79999999999999997e54 < a Initial program 87.5%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6484.3
Simplified84.3%
(FPCore (a b angle)
:precision binary64
(if (<= b 1.02e+22)
(* a a)
(fma
(* angle angle)
(* PI (* PI (* (* b b) 3.08641975308642e-5)))
(* a a))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.02e+22) {
tmp = a * a;
} else {
tmp = fma((angle * angle), (((double) M_PI) * (((double) M_PI) * ((b * b) * 3.08641975308642e-5))), (a * a));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 1.02e+22) tmp = Float64(a * a); else tmp = fma(Float64(angle * angle), Float64(pi * Float64(pi * Float64(Float64(b * b) * 3.08641975308642e-5))), Float64(a * a)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 1.02e+22], N[(a * a), $MachinePrecision], N[(N[(angle * angle), $MachinePrecision] * N[(Pi * N[(Pi * N[(N[(b * b), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.02 \cdot 10^{+22}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(angle \cdot angle, \pi \cdot \left(\pi \cdot \left(\left(b \cdot b\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right), a \cdot a\right)\\
\end{array}
\end{array}
if b < 1.02e22Initial program 72.7%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6460.6
Simplified60.6%
if 1.02e22 < b Initial program 79.9%
Taylor expanded in angle around 0
accelerator-lowering-fma.f64N/A
Simplified37.4%
Taylor expanded in b around inf
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6463.2
Simplified63.2%
(FPCore (a b angle) :precision binary64 (if (<= b 4e+151) (* a a) (* angle (* (* angle (* PI 3.08641975308642e-5)) (* PI (* b b))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 4e+151) {
tmp = a * a;
} else {
tmp = angle * ((angle * (((double) M_PI) * 3.08641975308642e-5)) * (((double) M_PI) * (b * b)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 4e+151) {
tmp = a * a;
} else {
tmp = angle * ((angle * (Math.PI * 3.08641975308642e-5)) * (Math.PI * (b * b)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 4e+151: tmp = a * a else: tmp = angle * ((angle * (math.pi * 3.08641975308642e-5)) * (math.pi * (b * b))) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 4e+151) tmp = Float64(a * a); else tmp = Float64(angle * Float64(Float64(angle * Float64(pi * 3.08641975308642e-5)) * Float64(pi * Float64(b * b)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 4e+151) tmp = a * a; else tmp = angle * ((angle * (pi * 3.08641975308642e-5)) * (pi * (b * b))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 4e+151], N[(a * a), $MachinePrecision], N[(angle * N[(N[(angle * N[(Pi * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision] * N[(Pi * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4 \cdot 10^{+151}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;angle \cdot \left(\left(angle \cdot \left(\pi \cdot 3.08641975308642 \cdot 10^{-5}\right)\right) \cdot \left(\pi \cdot \left(b \cdot b\right)\right)\right)\\
\end{array}
\end{array}
if b < 4.00000000000000007e151Initial program 72.0%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6457.8
Simplified57.8%
if 4.00000000000000007e151 < b Initial program 99.7%
Taylor expanded in angle around 0
accelerator-lowering-fma.f64N/A
Simplified41.9%
Taylor expanded in b around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
unpow2N/A
*-lowering-*.f6473.7
Simplified73.7%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*r*N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f6474.4
Applied egg-rr74.4%
Final simplification59.2%
(FPCore (a b angle) :precision binary64 (if (<= b 1.02e+152) (* a a) (* (* angle angle) (* PI (* 3.08641975308642e-5 (* PI (* b b)))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.02e+152) {
tmp = a * a;
} else {
tmp = (angle * angle) * (((double) M_PI) * (3.08641975308642e-5 * (((double) M_PI) * (b * b))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 1.02e+152) {
tmp = a * a;
} else {
tmp = (angle * angle) * (Math.PI * (3.08641975308642e-5 * (Math.PI * (b * b))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 1.02e+152: tmp = a * a else: tmp = (angle * angle) * (math.pi * (3.08641975308642e-5 * (math.pi * (b * b)))) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 1.02e+152) tmp = Float64(a * a); else tmp = Float64(Float64(angle * angle) * Float64(pi * Float64(3.08641975308642e-5 * Float64(pi * Float64(b * b))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 1.02e+152) tmp = a * a; else tmp = (angle * angle) * (pi * (3.08641975308642e-5 * (pi * (b * b)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 1.02e+152], N[(a * a), $MachinePrecision], N[(N[(angle * angle), $MachinePrecision] * N[(Pi * N[(3.08641975308642e-5 * N[(Pi * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.02 \cdot 10^{+152}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(angle \cdot angle\right) \cdot \left(\pi \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \left(b \cdot b\right)\right)\right)\right)\\
\end{array}
\end{array}
if b < 1.01999999999999999e152Initial program 72.0%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6457.8
Simplified57.8%
if 1.01999999999999999e152 < b Initial program 99.7%
Taylor expanded in angle around 0
accelerator-lowering-fma.f64N/A
Simplified41.9%
Taylor expanded in b around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
unpow2N/A
*-lowering-*.f6473.7
Simplified73.7%
(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 74.3%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6456.1
Simplified56.1%
herbie shell --seed 2024197
(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)))