
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (/ angle 180.0) PI))) (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * ((double) M_PI);
return pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * Math.PI;
return Math.pow((a * Math.sin(t_0)), 2.0) + Math.pow((b * Math.cos(t_0)), 2.0);
}
def code(a, b, angle): t_0 = (angle / 180.0) * math.pi return math.pow((a * math.sin(t_0)), 2.0) + math.pow((b * math.cos(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(Float64(angle / 180.0) * pi) return Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = (angle / 180.0) * pi; tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[Power[N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (/ angle 180.0) PI))) (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * ((double) M_PI);
return pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * Math.PI;
return Math.pow((a * Math.sin(t_0)), 2.0) + Math.pow((b * Math.cos(t_0)), 2.0);
}
def code(a, b, angle): t_0 = (angle / 180.0) * math.pi return math.pow((a * math.sin(t_0)), 2.0) + math.pow((b * math.cos(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(Float64(angle / 180.0) * pi) return Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = (angle / 180.0) * pi; tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[Power[N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
(FPCore (a b angle)
:precision binary64
(+
(pow
(*
a
(sin
(*
(pow PI 0.16666666666666666)
(*
(* 0.005555555555555556 (* angle (pow PI 0.6666666666666666)))
(pow PI 0.16666666666666666)))))
2.0)
(pow (* b (cos (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin((pow(((double) M_PI), 0.16666666666666666) * ((0.005555555555555556 * (angle * pow(((double) M_PI), 0.6666666666666666))) * pow(((double) M_PI), 0.16666666666666666))))), 2.0) + pow((b * cos((((double) M_PI) * (angle / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((Math.pow(Math.PI, 0.16666666666666666) * ((0.005555555555555556 * (angle * Math.pow(Math.PI, 0.6666666666666666))) * Math.pow(Math.PI, 0.16666666666666666))))), 2.0) + Math.pow((b * Math.cos((Math.PI * (angle / 180.0)))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin((math.pow(math.pi, 0.16666666666666666) * ((0.005555555555555556 * (angle * math.pow(math.pi, 0.6666666666666666))) * math.pow(math.pi, 0.16666666666666666))))), 2.0) + math.pow((b * math.cos((math.pi * (angle / 180.0)))), 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64((pi ^ 0.16666666666666666) * Float64(Float64(0.005555555555555556 * Float64(angle * (pi ^ 0.6666666666666666))) * (pi ^ 0.16666666666666666))))) ^ 2.0) + (Float64(b * cos(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin(((pi ^ 0.16666666666666666) * ((0.005555555555555556 * (angle * (pi ^ 0.6666666666666666))) * (pi ^ 0.16666666666666666))))) ^ 2.0) + ((b * cos((pi * (angle / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[Power[Pi, 0.16666666666666666], $MachinePrecision] * N[(N[(0.005555555555555556 * N[(angle * N[Power[Pi, 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[Pi, 0.16666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left({\pi}^{0.16666666666666666} \cdot \left(\left(0.005555555555555556 \cdot \left(angle \cdot {\pi}^{0.6666666666666666}\right)\right) \cdot {\pi}^{0.16666666666666666}\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 77.5%
lift-*.f64N/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*r*N/A
add-sqr-sqrtN/A
cbrt-prodN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites77.6%
Final simplification77.6%
(FPCore (a b angle) :precision binary64 (+ (pow (* b (cos (* PI (/ angle 180.0)))) 2.0) (pow (* a (sin (* angle (* 0.005555555555555556 PI)))) 2.0)))
double code(double a, double b, double angle) {
return pow((b * cos((((double) M_PI) * (angle / 180.0)))), 2.0) + pow((a * sin((angle * (0.005555555555555556 * ((double) M_PI))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((b * Math.cos((Math.PI * (angle / 180.0)))), 2.0) + Math.pow((a * Math.sin((angle * (0.005555555555555556 * Math.PI)))), 2.0);
}
def code(a, b, angle): return math.pow((b * math.cos((math.pi * (angle / 180.0)))), 2.0) + math.pow((a * math.sin((angle * (0.005555555555555556 * math.pi)))), 2.0)
function code(a, b, angle) return Float64((Float64(b * cos(Float64(pi * Float64(angle / 180.0)))) ^ 2.0) + (Float64(a * sin(Float64(angle * Float64(0.005555555555555556 * pi)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((b * cos((pi * (angle / 180.0)))) ^ 2.0) + ((a * sin((angle * (0.005555555555555556 * pi)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(b * N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(a * N[Sin[N[(angle * N[(0.005555555555555556 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(b \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(a \cdot \sin \left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right)\right)}^{2}
\end{array}
Initial program 77.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval77.6
Applied rewrites77.6%
Final simplification77.6%
(FPCore (a b angle)
:precision binary64
(+
(pow
(*
a
(sin
(*
(* (* 0.005555555555555556 angle) (sqrt (sqrt PI)))
(sqrt (* PI (sqrt PI))))))
2.0)
(pow (* b 1.0) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin((((0.005555555555555556 * angle) * sqrt(sqrt(((double) M_PI)))) * sqrt((((double) M_PI) * sqrt(((double) M_PI))))))), 2.0) + pow((b * 1.0), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((((0.005555555555555556 * angle) * Math.sqrt(Math.sqrt(Math.PI))) * Math.sqrt((Math.PI * Math.sqrt(Math.PI)))))), 2.0) + Math.pow((b * 1.0), 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin((((0.005555555555555556 * angle) * math.sqrt(math.sqrt(math.pi))) * math.sqrt((math.pi * math.sqrt(math.pi)))))), 2.0) + math.pow((b * 1.0), 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(Float64(0.005555555555555556 * angle) * sqrt(sqrt(pi))) * sqrt(Float64(pi * sqrt(pi)))))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin((((0.005555555555555556 * angle) * sqrt(sqrt(pi))) * sqrt((pi * sqrt(pi)))))) ^ 2.0) + ((b * 1.0) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(N[(0.005555555555555556 * angle), $MachinePrecision] * N[Sqrt[N[Sqrt[Pi], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(Pi * N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\left(\left(0.005555555555555556 \cdot angle\right) \cdot \sqrt{\sqrt{\pi}}\right) \cdot \sqrt{\pi \cdot \sqrt{\pi}}\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}
\end{array}
Initial program 77.5%
lift-*.f64N/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*r*N/A
add-sqr-sqrtN/A
cbrt-prodN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites77.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
pow2N/A
lift-pow.f64N/A
pow-powN/A
metadata-evalN/A
pow1/3N/A
lift-PI.f64N/A
associate-*l*N/A
Applied rewrites77.4%
lift-*.f64N/A
lift-/.f64N/A
/-rgt-identityN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
associate-*r/N/A
Applied rewrites77.6%
Taylor expanded in angle around 0
Applied rewrites77.6%
Final simplification77.6%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (* 0.005555555555555556 angle))) (t_1 (* a (sin t_0)))) (fma t_1 t_1 (* (* b b) (+ 0.5 (* 0.5 (cos (* 2.0 t_0))))))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (0.005555555555555556 * angle);
double t_1 = a * sin(t_0);
return fma(t_1, t_1, ((b * b) * (0.5 + (0.5 * cos((2.0 * t_0))))));
}
function code(a, b, angle) t_0 = Float64(pi * Float64(0.005555555555555556 * angle)) t_1 = Float64(a * sin(t_0)) return fma(t_1, t_1, Float64(Float64(b * b) * Float64(0.5 + Float64(0.5 * cos(Float64(2.0 * t_0)))))) end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(0.005555555555555556 * angle), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]}, N[(t$95$1 * t$95$1 + N[(N[(b * b), $MachinePrecision] * N[(0.5 + N[(0.5 * N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(0.005555555555555556 \cdot angle\right)\\
t_1 := a \cdot \sin t\_0\\
\mathsf{fma}\left(t\_1, t\_1, \left(b \cdot b\right) \cdot \left(0.5 + 0.5 \cdot \cos \left(2 \cdot t\_0\right)\right)\right)
\end{array}
\end{array}
Initial program 77.5%
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-fma.f6477.5
lift-/.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval76.5
lift-/.f64N/A
div-invN/A
lower-*.f64N/A
metadata-eval77.6
Applied rewrites77.5%
Final simplification77.5%
(FPCore (a b angle) :precision binary64 (+ (pow (* b 1.0) 2.0) (pow (* a (sin (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return pow((b * 1.0), 2.0) + pow((a * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((b * 1.0), 2.0) + Math.pow((a * Math.sin((Math.PI * (angle / 180.0)))), 2.0);
}
def code(a, b, angle): return math.pow((b * 1.0), 2.0) + math.pow((a * math.sin((math.pi * (angle / 180.0)))), 2.0)
function code(a, b, angle) return Float64((Float64(b * 1.0) ^ 2.0) + (Float64(a * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((b * 1.0) ^ 2.0) + ((a * sin((pi * (angle / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(a * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(b \cdot 1\right)}^{2} + {\left(a \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 77.5%
Taylor expanded in angle around 0
Applied rewrites77.5%
Final simplification77.5%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (sqrt (sqrt PI)) (sqrt (* PI (sqrt PI))))))
(if (<= (/ angle 180.0) 1e-22)
(+
(* (* a (* a (* angle angle))) (* PI (* PI 3.08641975308642e-5)))
(pow (* b (cos (/ t_0 (/ 180.0 angle)))) 2.0))
(+
(pow (* b 1.0) 2.0)
(*
(- 0.5 (* 0.5 (cos (* 2.0 (* (* 0.005555555555555556 angle) t_0)))))
(* a a))))))
double code(double a, double b, double angle) {
double t_0 = sqrt(sqrt(((double) M_PI))) * sqrt((((double) M_PI) * sqrt(((double) M_PI))));
double tmp;
if ((angle / 180.0) <= 1e-22) {
tmp = ((a * (a * (angle * angle))) * (((double) M_PI) * (((double) M_PI) * 3.08641975308642e-5))) + pow((b * cos((t_0 / (180.0 / angle)))), 2.0);
} else {
tmp = pow((b * 1.0), 2.0) + ((0.5 - (0.5 * cos((2.0 * ((0.005555555555555556 * angle) * t_0))))) * (a * a));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = Math.sqrt(Math.sqrt(Math.PI)) * Math.sqrt((Math.PI * Math.sqrt(Math.PI)));
double tmp;
if ((angle / 180.0) <= 1e-22) {
tmp = ((a * (a * (angle * angle))) * (Math.PI * (Math.PI * 3.08641975308642e-5))) + Math.pow((b * Math.cos((t_0 / (180.0 / angle)))), 2.0);
} else {
tmp = Math.pow((b * 1.0), 2.0) + ((0.5 - (0.5 * Math.cos((2.0 * ((0.005555555555555556 * angle) * t_0))))) * (a * a));
}
return tmp;
}
def code(a, b, angle): t_0 = math.sqrt(math.sqrt(math.pi)) * math.sqrt((math.pi * math.sqrt(math.pi))) tmp = 0 if (angle / 180.0) <= 1e-22: tmp = ((a * (a * (angle * angle))) * (math.pi * (math.pi * 3.08641975308642e-5))) + math.pow((b * math.cos((t_0 / (180.0 / angle)))), 2.0) else: tmp = math.pow((b * 1.0), 2.0) + ((0.5 - (0.5 * math.cos((2.0 * ((0.005555555555555556 * angle) * t_0))))) * (a * a)) return tmp
function code(a, b, angle) t_0 = Float64(sqrt(sqrt(pi)) * sqrt(Float64(pi * sqrt(pi)))) tmp = 0.0 if (Float64(angle / 180.0) <= 1e-22) tmp = Float64(Float64(Float64(a * Float64(a * Float64(angle * angle))) * Float64(pi * Float64(pi * 3.08641975308642e-5))) + (Float64(b * cos(Float64(t_0 / Float64(180.0 / angle)))) ^ 2.0)); else tmp = Float64((Float64(b * 1.0) ^ 2.0) + Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(Float64(0.005555555555555556 * angle) * t_0))))) * Float64(a * a))); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = sqrt(sqrt(pi)) * sqrt((pi * sqrt(pi))); tmp = 0.0; if ((angle / 180.0) <= 1e-22) tmp = ((a * (a * (angle * angle))) * (pi * (pi * 3.08641975308642e-5))) + ((b * cos((t_0 / (180.0 / angle)))) ^ 2.0); else tmp = ((b * 1.0) ^ 2.0) + ((0.5 - (0.5 * cos((2.0 * ((0.005555555555555556 * angle) * t_0))))) * (a * a)); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[Sqrt[N[Sqrt[Pi], $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(Pi * N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(angle / 180.0), $MachinePrecision], 1e-22], N[(N[(N[(a * N[(a * N[(angle * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(Pi * N[(Pi * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(b * N[Cos[N[(t$95$0 / N[(180.0 / angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(N[(0.005555555555555556 * angle), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\sqrt{\pi}} \cdot \sqrt{\pi \cdot \sqrt{\pi}}\\
\mathbf{if}\;\frac{angle}{180} \leq 10^{-22}:\\
\;\;\;\;\left(a \cdot \left(a \cdot \left(angle \cdot angle\right)\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot 3.08641975308642 \cdot 10^{-5}\right)\right) + {\left(b \cdot \cos \left(\frac{t\_0}{\frac{180}{angle}}\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;{\left(b \cdot 1\right)}^{2} + \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\left(0.005555555555555556 \cdot angle\right) \cdot t\_0\right)\right)\right) \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 1e-22Initial program 84.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6484.0
Applied rewrites84.0%
rem-square-sqrtN/A
sqrt-unprodN/A
lift-PI.f64N/A
add-sqr-sqrtN/A
associate-*r*N/A
sqrt-prodN/A
lift-PI.f64N/A
pow1/2N/A
sqrt-pow1N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
pow-prod-upN/A
lift-pow.f64N/A
lower-*.f64N/A
Applied rewrites84.1%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
metadata-evalN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-PI.f64N/A
distribute-rgt-neg-inN/A
metadata-evalN/A
Applied rewrites74.2%
if 1e-22 < (/.f64 angle #s(literal 180 binary64)) Initial program 60.4%
lift-pow.f64N/A
lift-*.f64N/A
*-commutativeN/A
unpow-prod-downN/A
lower-*.f64N/A
Applied rewrites60.3%
rem-square-sqrtN/A
sqrt-unprodN/A
lift-PI.f64N/A
add-sqr-sqrtN/A
associate-*r*N/A
sqrt-prodN/A
lift-PI.f64N/A
pow1/2N/A
sqrt-pow1N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
pow-prod-upN/A
lift-pow.f64N/A
lower-*.f64N/A
Applied rewrites60.6%
Taylor expanded in angle around 0
Applied rewrites60.5%
Final simplification70.5%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* 0.5 (cos (* 2.0 (* angle (* 0.005555555555555556 PI)))))))
(if (<= a 1.05e+166)
(fma a (* a (- 0.5 t_0)) (* (* b b) (+ 0.5 t_0)))
(* (* PI (* PI 3.08641975308642e-5)) (* (* a angle) (* a angle))))))
double code(double a, double b, double angle) {
double t_0 = 0.5 * cos((2.0 * (angle * (0.005555555555555556 * ((double) M_PI)))));
double tmp;
if (a <= 1.05e+166) {
tmp = fma(a, (a * (0.5 - t_0)), ((b * b) * (0.5 + t_0)));
} else {
tmp = (((double) M_PI) * (((double) M_PI) * 3.08641975308642e-5)) * ((a * angle) * (a * angle));
}
return tmp;
}
function code(a, b, angle) t_0 = Float64(0.5 * cos(Float64(2.0 * Float64(angle * Float64(0.005555555555555556 * pi))))) tmp = 0.0 if (a <= 1.05e+166) tmp = fma(a, Float64(a * Float64(0.5 - t_0)), Float64(Float64(b * b) * Float64(0.5 + t_0))); else tmp = Float64(Float64(pi * Float64(pi * 3.08641975308642e-5)) * Float64(Float64(a * angle) * Float64(a * angle))); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(0.5 * N[Cos[N[(2.0 * N[(angle * N[(0.005555555555555556 * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, 1.05e+166], N[(a * N[(a * N[(0.5 - t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(0.5 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * N[(Pi * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision] * N[(N[(a * angle), $MachinePrecision] * N[(a * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos \left(2 \cdot \left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right)\right)\\
\mathbf{if}\;a \leq 1.05 \cdot 10^{+166}:\\
\;\;\;\;\mathsf{fma}\left(a, a \cdot \left(0.5 - t\_0\right), \left(b \cdot b\right) \cdot \left(0.5 + t\_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\pi \cdot \left(\pi \cdot 3.08641975308642 \cdot 10^{-5}\right)\right) \cdot \left(\left(a \cdot angle\right) \cdot \left(a \cdot angle\right)\right)\\
\end{array}
\end{array}
if a < 1.05e166Initial program 75.3%
lift-*.f64N/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*r*N/A
add-sqr-sqrtN/A
cbrt-prodN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites75.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
pow2N/A
lift-pow.f64N/A
pow-powN/A
metadata-evalN/A
pow1/3N/A
lift-PI.f64N/A
associate-*l*N/A
Applied rewrites75.2%
lift-*.f64N/A
lift-/.f64N/A
/-rgt-identityN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
associate-*r/N/A
Applied rewrites75.3%
Applied rewrites69.0%
if 1.05e166 < a Initial program 96.1%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites40.5%
Taylor expanded in b around 0
Applied rewrites59.8%
Applied rewrites82.5%
Final simplification70.5%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (cos (* PI (* angle 0.011111111111111112)))))
(if (<= a 1.05e+166)
(fma (* a (fma t_0 -0.5 0.5)) a (* (* b b) (fma 0.5 t_0 0.5)))
(* (* PI (* PI 3.08641975308642e-5)) (* (* a angle) (* a angle))))))
double code(double a, double b, double angle) {
double t_0 = cos((((double) M_PI) * (angle * 0.011111111111111112)));
double tmp;
if (a <= 1.05e+166) {
tmp = fma((a * fma(t_0, -0.5, 0.5)), a, ((b * b) * fma(0.5, t_0, 0.5)));
} else {
tmp = (((double) M_PI) * (((double) M_PI) * 3.08641975308642e-5)) * ((a * angle) * (a * angle));
}
return tmp;
}
function code(a, b, angle) t_0 = cos(Float64(pi * Float64(angle * 0.011111111111111112))) tmp = 0.0 if (a <= 1.05e+166) tmp = fma(Float64(a * fma(t_0, -0.5, 0.5)), a, Float64(Float64(b * b) * fma(0.5, t_0, 0.5))); else tmp = Float64(Float64(pi * Float64(pi * 3.08641975308642e-5)) * Float64(Float64(a * angle) * Float64(a * angle))); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[Cos[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[a, 1.05e+166], N[(N[(a * N[(t$95$0 * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision] * a + N[(N[(b * b), $MachinePrecision] * N[(0.5 * t$95$0 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * N[(Pi * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision] * N[(N[(a * angle), $MachinePrecision] * N[(a * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)\\
\mathbf{if}\;a \leq 1.05 \cdot 10^{+166}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot \mathsf{fma}\left(t\_0, -0.5, 0.5\right), a, \left(b \cdot b\right) \cdot \mathsf{fma}\left(0.5, t\_0, 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\pi \cdot \left(\pi \cdot 3.08641975308642 \cdot 10^{-5}\right)\right) \cdot \left(\left(a \cdot angle\right) \cdot \left(a \cdot angle\right)\right)\\
\end{array}
\end{array}
if a < 1.05e166Initial program 75.3%
lift-*.f64N/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*r*N/A
add-sqr-sqrtN/A
cbrt-prodN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites75.4%
Applied rewrites68.9%
if 1.05e166 < a Initial program 96.1%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites40.5%
Taylor expanded in b around 0
Applied rewrites59.8%
Applied rewrites82.5%
Final simplification70.4%
(FPCore (a b angle) :precision binary64 (if (<= a 1.4e+154) (* b b) (* (* PI (* PI 3.08641975308642e-5)) (* (* a angle) (* a angle)))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.4e+154) {
tmp = b * b;
} else {
tmp = (((double) M_PI) * (((double) M_PI) * 3.08641975308642e-5)) * ((a * angle) * (a * angle));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.4e+154) {
tmp = b * b;
} else {
tmp = (Math.PI * (Math.PI * 3.08641975308642e-5)) * ((a * angle) * (a * angle));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.4e+154: tmp = b * b else: tmp = (math.pi * (math.pi * 3.08641975308642e-5)) * ((a * angle) * (a * angle)) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.4e+154) tmp = Float64(b * b); else tmp = Float64(Float64(pi * Float64(pi * 3.08641975308642e-5)) * Float64(Float64(a * angle) * Float64(a * angle))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.4e+154) tmp = b * b; else tmp = (pi * (pi * 3.08641975308642e-5)) * ((a * angle) * (a * angle)); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.4e+154], N[(b * b), $MachinePrecision], N[(N[(Pi * N[(Pi * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision] * N[(N[(a * angle), $MachinePrecision] * N[(a * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(\pi \cdot \left(\pi \cdot 3.08641975308642 \cdot 10^{-5}\right)\right) \cdot \left(\left(a \cdot angle\right) \cdot \left(a \cdot angle\right)\right)\\
\end{array}
\end{array}
if a < 1.4e154Initial program 74.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6458.5
Applied rewrites58.5%
if 1.4e154 < a Initial program 96.5%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites39.9%
Taylor expanded in b around 0
Applied rewrites57.4%
Applied rewrites78.0%
Final simplification60.9%
(FPCore (a b angle) :precision binary64 (if (<= a 1.4e+154) (* b b) (* (* PI (* PI 3.08641975308642e-5)) (* a (* angle (* a angle))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.4e+154) {
tmp = b * b;
} else {
tmp = (((double) M_PI) * (((double) M_PI) * 3.08641975308642e-5)) * (a * (angle * (a * angle)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.4e+154) {
tmp = b * b;
} else {
tmp = (Math.PI * (Math.PI * 3.08641975308642e-5)) * (a * (angle * (a * angle)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.4e+154: tmp = b * b else: tmp = (math.pi * (math.pi * 3.08641975308642e-5)) * (a * (angle * (a * angle))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.4e+154) tmp = Float64(b * b); else tmp = Float64(Float64(pi * Float64(pi * 3.08641975308642e-5)) * Float64(a * Float64(angle * Float64(a * angle)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.4e+154) tmp = b * b; else tmp = (pi * (pi * 3.08641975308642e-5)) * (a * (angle * (a * angle))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.4e+154], N[(b * b), $MachinePrecision], N[(N[(Pi * N[(Pi * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision] * N[(a * N[(angle * N[(a * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(\pi \cdot \left(\pi \cdot 3.08641975308642 \cdot 10^{-5}\right)\right) \cdot \left(a \cdot \left(angle \cdot \left(a \cdot angle\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.4e154Initial program 74.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6458.5
Applied rewrites58.5%
if 1.4e154 < a Initial program 96.5%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites39.9%
Taylor expanded in b around 0
Applied rewrites57.4%
Applied rewrites77.9%
Final simplification60.9%
(FPCore (a b angle) :precision binary64 (if (<= a 1.4e+154) (* b b) (* (* a (* a (* angle angle))) (* PI (* PI 3.08641975308642e-5)))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.4e+154) {
tmp = b * b;
} else {
tmp = (a * (a * (angle * angle))) * (((double) M_PI) * (((double) M_PI) * 3.08641975308642e-5));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.4e+154) {
tmp = b * b;
} else {
tmp = (a * (a * (angle * angle))) * (Math.PI * (Math.PI * 3.08641975308642e-5));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.4e+154: tmp = b * b else: tmp = (a * (a * (angle * angle))) * (math.pi * (math.pi * 3.08641975308642e-5)) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.4e+154) tmp = Float64(b * b); else tmp = Float64(Float64(a * Float64(a * Float64(angle * angle))) * Float64(pi * Float64(pi * 3.08641975308642e-5))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.4e+154) tmp = b * b; else tmp = (a * (a * (angle * angle))) * (pi * (pi * 3.08641975308642e-5)); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.4e+154], N[(b * b), $MachinePrecision], N[(N[(a * N[(a * N[(angle * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(Pi * N[(Pi * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot \left(a \cdot \left(angle \cdot angle\right)\right)\right) \cdot \left(\pi \cdot \left(\pi \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\\
\end{array}
\end{array}
if a < 1.4e154Initial program 74.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6458.5
Applied rewrites58.5%
if 1.4e154 < a Initial program 96.5%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites39.9%
Taylor expanded in b around 0
Applied rewrites57.4%
(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 77.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6455.2
Applied rewrites55.2%
herbie shell --seed 2024234
(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)))