
(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 12 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 (+ (pow (* a (cos (* (* PI angle) 0.005555555555555556))) 2.0) (pow (* b (sin (* 0.005555555555555556 (/ 1.0 (/ 1.0 (* PI angle)))))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * cos(((((double) M_PI) * angle) * 0.005555555555555556))), 2.0) + pow((b * sin((0.005555555555555556 * (1.0 / (1.0 / (((double) M_PI) * angle)))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.cos(((Math.PI * angle) * 0.005555555555555556))), 2.0) + Math.pow((b * Math.sin((0.005555555555555556 * (1.0 / (1.0 / (Math.PI * angle)))))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.cos(((math.pi * angle) * 0.005555555555555556))), 2.0) + math.pow((b * math.sin((0.005555555555555556 * (1.0 / (1.0 / (math.pi * angle)))))), 2.0)
function code(a, b, angle) return Float64((Float64(a * cos(Float64(Float64(pi * angle) * 0.005555555555555556))) ^ 2.0) + (Float64(b * sin(Float64(0.005555555555555556 * Float64(1.0 / Float64(1.0 / Float64(pi * angle)))))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * cos(((pi * angle) * 0.005555555555555556))) ^ 2.0) + ((b * sin((0.005555555555555556 * (1.0 / (1.0 / (pi * angle)))))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Cos[N[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(0.005555555555555556 * N[(1.0 / N[(1.0 / N[(Pi * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \cos \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)\right)}^{2} + {\left(b \cdot \sin \left(0.005555555555555556 \cdot \frac{1}{\frac{1}{\pi \cdot angle}}\right)\right)}^{2}
\end{array}
Initial program 76.5%
lift-PI.f64N/A
div-invN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval76.5
Applied rewrites76.5%
lift-PI.f64N/A
clear-numN/A
associate-*r/N/A
*-commutativeN/A
div-invN/A
times-fracN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6476.5
Applied rewrites76.5%
lift-PI.f64N/A
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lower-/.f6476.5
Applied rewrites76.5%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (cos (* (* PI angle) 0.005555555555555556))) 2.0) (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * cos(((((double) M_PI) * angle) * 0.005555555555555556))), 2.0) + pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.cos(((Math.PI * angle) * 0.005555555555555556))), 2.0) + Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.cos(((math.pi * angle) * 0.005555555555555556))), 2.0) + math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0)
function code(a, b, angle) return Float64((Float64(a * cos(Float64(Float64(pi * angle) * 0.005555555555555556))) ^ 2.0) + (Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * cos(((pi * angle) * 0.005555555555555556))) ^ 2.0) + ((b * sin((pi * (angle / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Cos[N[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \cos \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 76.5%
lift-PI.f64N/A
div-invN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval76.5
Applied rewrites76.5%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (* PI angle) 0.005555555555555556)) (t_1 (sin t_0)))
(fma
(* (* b t_1) (* t_1 (sqrt b)))
(sqrt b)
(* 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 = sin(t_0);
return fma(((b * t_1) * (t_1 * sqrt(b))), sqrt(b), (a * (a * (0.5 + (0.5 * cos((t_0 * 2.0)))))));
}
function code(a, b, angle) t_0 = Float64(Float64(pi * angle) * 0.005555555555555556) t_1 = sin(t_0) return fma(Float64(Float64(b * t_1) * Float64(t_1 * sqrt(b))), sqrt(b), Float64(a * Float64(a * Float64(0.5 + Float64(0.5 * cos(Float64(t_0 * 2.0))))))) end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]}, Block[{t$95$1 = N[Sin[t$95$0], $MachinePrecision]}, N[(N[(N[(b * t$95$1), $MachinePrecision] * N[(t$95$1 * N[Sqrt[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[b], $MachinePrecision] + N[(a * N[(a * N[(0.5 + N[(0.5 * N[Cos[N[(t$95$0 * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\pi \cdot angle\right) \cdot 0.005555555555555556\\
t_1 := \sin t\_0\\
\mathsf{fma}\left(\left(b \cdot t\_1\right) \cdot \left(t\_1 \cdot \sqrt{b}\right), \sqrt{b}, a \cdot \left(a \cdot \left(0.5 + 0.5 \cdot \cos \left(t\_0 \cdot 2\right)\right)\right)\right)
\end{array}
\end{array}
Initial program 76.5%
lift-PI.f64N/A
div-invN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval76.5
Applied rewrites76.5%
lift-PI.f64N/A
clear-numN/A
associate-*r/N/A
*-commutativeN/A
div-invN/A
times-fracN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6476.5
Applied rewrites76.5%
lift-PI.f64N/A
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lower-/.f6476.5
Applied rewrites76.5%
Applied rewrites38.0%
Final simplification38.0%
(FPCore (a b angle) :precision binary64 (+ (pow (* b (sin (* 0.005555555555555556 (/ 1.0 (/ 1.0 (* PI angle)))))) 2.0) (* a a)))
double code(double a, double b, double angle) {
return pow((b * sin((0.005555555555555556 * (1.0 / (1.0 / (((double) M_PI) * angle)))))), 2.0) + (a * a);
}
public static double code(double a, double b, double angle) {
return Math.pow((b * Math.sin((0.005555555555555556 * (1.0 / (1.0 / (Math.PI * angle)))))), 2.0) + (a * a);
}
def code(a, b, angle): return math.pow((b * math.sin((0.005555555555555556 * (1.0 / (1.0 / (math.pi * angle)))))), 2.0) + (a * a)
function code(a, b, angle) return Float64((Float64(b * sin(Float64(0.005555555555555556 * Float64(1.0 / Float64(1.0 / Float64(pi * angle)))))) ^ 2.0) + Float64(a * a)) end
function tmp = code(a, b, angle) tmp = ((b * sin((0.005555555555555556 * (1.0 / (1.0 / (pi * angle)))))) ^ 2.0) + (a * a); end
code[a_, b_, angle_] := N[(N[Power[N[(b * N[Sin[N[(0.005555555555555556 * N[(1.0 / N[(1.0 / N[(Pi * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(b \cdot \sin \left(0.005555555555555556 \cdot \frac{1}{\frac{1}{\pi \cdot angle}}\right)\right)}^{2} + a \cdot a
\end{array}
Initial program 76.5%
lift-PI.f64N/A
div-invN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval76.5
Applied rewrites76.5%
lift-PI.f64N/A
clear-numN/A
associate-*r/N/A
*-commutativeN/A
div-invN/A
times-fracN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6476.5
Applied rewrites76.5%
lift-PI.f64N/A
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lower-/.f6476.5
Applied rewrites76.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6475.8
Applied rewrites75.8%
Final simplification75.8%
(FPCore (a b angle) :precision binary64 (+ (pow (* b (sin (* PI (/ angle 180.0)))) 2.0) (* a a)))
double code(double a, double b, double angle) {
return pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0) + (a * a);
}
public static double code(double a, double b, double angle) {
return Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0) + (a * a);
}
def code(a, b, angle): return math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0) + (a * a)
function code(a, b, angle) return Float64((Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0) + Float64(a * a)) end
function tmp = code(a, b, angle) tmp = ((b * sin((pi * (angle / 180.0)))) ^ 2.0) + (a * a); end
code[a_, b_, angle_] := N[(N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + a \cdot a
\end{array}
Initial program 76.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6475.7
Applied rewrites75.7%
Final simplification75.7%
(FPCore (a b angle)
:precision binary64
(let* ((t_0
(*
(* a a)
(fma 0.5 (cos (* PI (* angle 0.011111111111111112))) 0.5))))
(if (<= (/ angle 180.0) 4e-8)
(fma b (* (* b (* PI PI)) (* (* angle angle) 3.08641975308642e-5)) t_0)
(fma (* b b) 0.5 t_0))))
double code(double a, double b, double angle) {
double t_0 = (a * a) * fma(0.5, cos((((double) M_PI) * (angle * 0.011111111111111112))), 0.5);
double tmp;
if ((angle / 180.0) <= 4e-8) {
tmp = fma(b, ((b * (((double) M_PI) * ((double) M_PI))) * ((angle * angle) * 3.08641975308642e-5)), t_0);
} else {
tmp = fma((b * b), 0.5, t_0);
}
return tmp;
}
function code(a, b, angle) t_0 = Float64(Float64(a * a) * fma(0.5, cos(Float64(pi * Float64(angle * 0.011111111111111112))), 0.5)) tmp = 0.0 if (Float64(angle / 180.0) <= 4e-8) tmp = fma(b, Float64(Float64(b * Float64(pi * pi)) * Float64(Float64(angle * angle) * 3.08641975308642e-5)), t_0); else tmp = fma(Float64(b * b), 0.5, t_0); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(a * a), $MachinePrecision] * N[(0.5 * N[Cos[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(angle / 180.0), $MachinePrecision], 4e-8], N[(b * N[(N[(b * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * N[(N[(angle * angle), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * 0.5 + t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(a \cdot a\right) \cdot \mathsf{fma}\left(0.5, \cos \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right), 0.5\right)\\
\mathbf{if}\;\frac{angle}{180} \leq 4 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(b, \left(b \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right), t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, 0.5, t\_0\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 4.0000000000000001e-8Initial program 82.7%
lift-PI.f64N/A
div-invN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval82.8
Applied rewrites82.8%
Applied rewrites54.9%
Taylor expanded in angle around 0
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6475.4
Applied rewrites75.4%
if 4.0000000000000001e-8 < (/.f64 angle #s(literal 180 binary64)) Initial program 60.5%
lift-PI.f64N/A
div-invN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval60.5
Applied rewrites60.5%
Applied rewrites51.8%
Taylor expanded in b around 0
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
*-commutativeN/A
lower-*.f6459.2
Applied rewrites59.2%
Final simplification70.8%
(FPCore (a b angle)
:precision binary64
(if (<= a 1.55e-39)
(fma
(*
(* PI angle)
(* PI (fma b (* b 3.08641975308642e-5) (* (* a a) -3.08641975308642e-5))))
angle
(* a a))
(fma
(* b b)
0.5
(* (* 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.55e-39) {
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 = fma((b * b), 0.5, ((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.55e-39) tmp = fma(Float64(Float64(pi * angle) * Float64(pi * fma(b, Float64(b * 3.08641975308642e-5), Float64(Float64(a * a) * -3.08641975308642e-5)))), angle, Float64(a * a)); else tmp = fma(Float64(b * b), 0.5, Float64(Float64(a * a) * fma(0.5, cos(Float64(pi * Float64(angle * 0.011111111111111112))), 0.5))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 1.55e-39], N[(N[(N[(Pi * angle), $MachinePrecision] * N[(Pi * N[(b * N[(b * 3.08641975308642e-5), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * -3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * angle + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * 0.5 + N[(N[(a * a), $MachinePrecision] * N[(0.5 * N[Cos[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.55 \cdot 10^{-39}:\\
\;\;\;\;\mathsf{fma}\left(\left(\pi \cdot angle\right) \cdot \left(\pi \cdot \mathsf{fma}\left(b, b \cdot 3.08641975308642 \cdot 10^{-5}, \left(a \cdot a\right) \cdot -3.08641975308642 \cdot 10^{-5}\right)\right), angle, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot b, 0.5, \left(a \cdot a\right) \cdot \mathsf{fma}\left(0.5, \cos \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right), 0.5\right)\right)\\
\end{array}
\end{array}
if a < 1.54999999999999985e-39Initial program 75.6%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites45.8%
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites49.3%
if 1.54999999999999985e-39 < a Initial program 78.3%
lift-PI.f64N/A
div-invN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval78.4
Applied rewrites78.4%
Applied rewrites60.9%
Taylor expanded in b around 0
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
*-commutativeN/A
lower-*.f6472.9
Applied rewrites72.9%
(FPCore (a b angle)
:precision binary64
(if (<= a 1.45e-152)
(* angle (* (* PI angle) (* PI (* 3.08641975308642e-5 (* b b)))))
(if (<= a 3.5e+144)
(fma
(* angle angle)
(*
PI
(*
PI
(fma (* b b) 3.08641975308642e-5 (* (* a a) -3.08641975308642e-5))))
(* a a))
(* a a))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.45e-152) {
tmp = angle * ((((double) M_PI) * angle) * (((double) M_PI) * (3.08641975308642e-5 * (b * b))));
} else if (a <= 3.5e+144) {
tmp = fma((angle * angle), (((double) M_PI) * (((double) M_PI) * fma((b * b), 3.08641975308642e-5, ((a * a) * -3.08641975308642e-5)))), (a * a));
} else {
tmp = a * a;
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 1.45e-152) tmp = Float64(angle * Float64(Float64(pi * angle) * Float64(pi * Float64(3.08641975308642e-5 * Float64(b * b))))); elseif (a <= 3.5e+144) tmp = fma(Float64(angle * angle), Float64(pi * Float64(pi * fma(Float64(b * b), 3.08641975308642e-5, Float64(Float64(a * a) * -3.08641975308642e-5)))), Float64(a * a)); else tmp = Float64(a * a); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 1.45e-152], N[(angle * N[(N[(Pi * angle), $MachinePrecision] * N[(Pi * N[(3.08641975308642e-5 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 3.5e+144], N[(N[(angle * angle), $MachinePrecision] * N[(Pi * N[(Pi * N[(N[(b * b), $MachinePrecision] * 3.08641975308642e-5 + N[(N[(a * a), $MachinePrecision] * -3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(a * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.45 \cdot 10^{-152}:\\
\;\;\;\;angle \cdot \left(\left(\pi \cdot angle\right) \cdot \left(\pi \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right)\right)\right)\right)\\
\mathbf{elif}\;a \leq 3.5 \cdot 10^{+144}:\\
\;\;\;\;\mathsf{fma}\left(angle \cdot angle, \pi \cdot \left(\pi \cdot \mathsf{fma}\left(b \cdot b, 3.08641975308642 \cdot 10^{-5}, \left(a \cdot a\right) \cdot -3.08641975308642 \cdot 10^{-5}\right)\right), a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 1.4500000000000001e-152Initial program 76.2%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites45.1%
Taylor expanded in b around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6441.0
Applied rewrites41.0%
lift-PI.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6445.2
Applied rewrites45.2%
if 1.4500000000000001e-152 < a < 3.4999999999999998e144Initial program 63.1%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites46.7%
if 3.4999999999999998e144 < a Initial program 97.8%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6497.8
Applied rewrites97.8%
Final simplification53.8%
(FPCore (a b angle)
:precision binary64
(if (<= a 3.5e+144)
(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 <= 3.5e+144) {
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 <= 3.5e+144) tmp = fma(Float64(Float64(pi * angle) * Float64(pi * fma(b, Float64(b * 3.08641975308642e-5), Float64(Float64(a * a) * -3.08641975308642e-5)))), angle, Float64(a * a)); else tmp = Float64(a * a); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 3.5e+144], N[(N[(N[(Pi * angle), $MachinePrecision] * N[(Pi * N[(b * N[(b * 3.08641975308642e-5), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * -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 3.5 \cdot 10^{+144}:\\
\;\;\;\;\mathsf{fma}\left(\left(\pi \cdot angle\right) \cdot \left(\pi \cdot \mathsf{fma}\left(b, b \cdot 3.08641975308642 \cdot 10^{-5}, \left(a \cdot a\right) \cdot -3.08641975308642 \cdot 10^{-5}\right)\right), angle, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 3.4999999999999998e144Initial program 72.5%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites45.6%
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites48.4%
if 3.4999999999999998e144 < a Initial program 97.8%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6497.8
Applied rewrites97.8%
(FPCore (a b angle) :precision binary64 (if (<= b 9.8e+67) (* a a) (* angle (* (* PI angle) (* PI (* 3.08641975308642e-5 (* b b)))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 9.8e+67) {
tmp = a * a;
} else {
tmp = angle * ((((double) M_PI) * angle) * (((double) M_PI) * (3.08641975308642e-5 * (b * b))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 9.8e+67) {
tmp = a * a;
} else {
tmp = angle * ((Math.PI * angle) * (Math.PI * (3.08641975308642e-5 * (b * b))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 9.8e+67: tmp = a * a else: tmp = angle * ((math.pi * angle) * (math.pi * (3.08641975308642e-5 * (b * b)))) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 9.8e+67) tmp = Float64(a * a); else tmp = Float64(angle * Float64(Float64(pi * angle) * Float64(pi * Float64(3.08641975308642e-5 * Float64(b * b))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 9.8e+67) tmp = a * a; else tmp = angle * ((pi * angle) * (pi * (3.08641975308642e-5 * (b * b)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 9.8e+67], N[(a * a), $MachinePrecision], N[(angle * N[(N[(Pi * angle), $MachinePrecision] * N[(Pi * N[(3.08641975308642e-5 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.8 \cdot 10^{+67}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;angle \cdot \left(\left(\pi \cdot angle\right) \cdot \left(\pi \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right)\right)\right)\right)\\
\end{array}
\end{array}
if b < 9.7999999999999998e67Initial program 75.7%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.6
Applied rewrites57.6%
if 9.7999999999999998e67 < b Initial program 79.7%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites28.9%
Taylor expanded in b around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6453.6
Applied rewrites53.6%
lift-PI.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6457.8
Applied rewrites57.8%
Final simplification57.6%
(FPCore (a b angle) :precision binary64 (if (<= b 9.8e+67) (* a a) (* (* angle angle) (* PI (* PI (* 3.08641975308642e-5 (* b b)))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 9.8e+67) {
tmp = a * a;
} else {
tmp = (angle * angle) * (((double) M_PI) * (((double) M_PI) * (3.08641975308642e-5 * (b * b))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 9.8e+67) {
tmp = a * a;
} else {
tmp = (angle * angle) * (Math.PI * (Math.PI * (3.08641975308642e-5 * (b * b))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 9.8e+67: tmp = a * a else: tmp = (angle * angle) * (math.pi * (math.pi * (3.08641975308642e-5 * (b * b)))) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 9.8e+67) tmp = Float64(a * a); else tmp = Float64(Float64(angle * angle) * Float64(pi * Float64(pi * Float64(3.08641975308642e-5 * Float64(b * b))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 9.8e+67) tmp = a * a; else tmp = (angle * angle) * (pi * (pi * (3.08641975308642e-5 * (b * b)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 9.8e+67], N[(a * a), $MachinePrecision], N[(N[(angle * angle), $MachinePrecision] * N[(Pi * N[(Pi * N[(3.08641975308642e-5 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.8 \cdot 10^{+67}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(angle \cdot angle\right) \cdot \left(\pi \cdot \left(\pi \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right)\right)\right)\right)\\
\end{array}
\end{array}
if b < 9.7999999999999998e67Initial program 75.7%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.6
Applied rewrites57.6%
if 9.7999999999999998e67 < b Initial program 79.7%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites28.9%
Taylor expanded in b around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6453.6
Applied rewrites53.6%
Final simplification56.9%
(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 76.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6454.8
Applied rewrites54.8%
herbie shell --seed 2024214
(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)))