
(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 (+ (* (* a a) (pow (cos (* 0.005555555555555556 (* angle PI))) 2.0)) (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return ((a * a) * pow(cos((0.005555555555555556 * (angle * ((double) M_PI)))), 2.0)) + 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(Math.cos((0.005555555555555556 * (angle * Math.PI))), 2.0)) + Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0);
}
def code(a, b, angle): return ((a * a) * math.pow(math.cos((0.005555555555555556 * (angle * math.pi))), 2.0)) + math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0)
function code(a, b, angle) return Float64(Float64(Float64(a * a) * (cos(Float64(0.005555555555555556 * Float64(angle * pi))) ^ 2.0)) + (Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * a) * (cos((0.005555555555555556 * (angle * pi))) ^ 2.0)) + ((b * sin((pi * (angle / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(N[(a * a), $MachinePrecision] * N[Power[N[Cos[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $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 a\right) \cdot {\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 76.5%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-cos.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6476.5
Simplified76.5%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* PI (/ angle 180.0))))
(if (<= (+ (pow (* b (sin t_0)) 2.0) (pow (* a (cos t_0)) 2.0)) 2e+305)
(* a a)
(* (* angle PI) (* 3.08641975308642e-5 (* a (* a a)))))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle / 180.0);
double tmp;
if ((pow((b * sin(t_0)), 2.0) + pow((a * cos(t_0)), 2.0)) <= 2e+305) {
tmp = a * a;
} else {
tmp = (angle * ((double) M_PI)) * (3.08641975308642e-5 * (a * (a * a)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle / 180.0);
double tmp;
if ((Math.pow((b * Math.sin(t_0)), 2.0) + Math.pow((a * Math.cos(t_0)), 2.0)) <= 2e+305) {
tmp = a * a;
} else {
tmp = (angle * Math.PI) * (3.08641975308642e-5 * (a * (a * a)));
}
return tmp;
}
def code(a, b, angle): t_0 = math.pi * (angle / 180.0) tmp = 0 if (math.pow((b * math.sin(t_0)), 2.0) + math.pow((a * math.cos(t_0)), 2.0)) <= 2e+305: tmp = a * a else: tmp = (angle * math.pi) * (3.08641975308642e-5 * (a * (a * a))) return tmp
function code(a, b, angle) t_0 = Float64(pi * Float64(angle / 180.0)) tmp = 0.0 if (Float64((Float64(b * sin(t_0)) ^ 2.0) + (Float64(a * cos(t_0)) ^ 2.0)) <= 2e+305) tmp = Float64(a * a); else tmp = Float64(Float64(angle * pi) * Float64(3.08641975308642e-5 * Float64(a * Float64(a * a)))); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = pi * (angle / 180.0); tmp = 0.0; if ((((b * sin(t_0)) ^ 2.0) + ((a * cos(t_0)) ^ 2.0)) <= 2e+305) tmp = a * a; else tmp = (angle * pi) * (3.08641975308642e-5 * (a * (a * a))); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 2e+305], N[(a * a), $MachinePrecision], N[(N[(angle * Pi), $MachinePrecision] * N[(3.08641975308642e-5 * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
\mathbf{if}\;{\left(b \cdot \sin t\_0\right)}^{2} + {\left(a \cdot \cos t\_0\right)}^{2} \leq 2 \cdot 10^{+305}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(angle \cdot \pi\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot \left(a \cdot a\right)\right)\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) < 1.9999999999999999e305Initial program 64.5%
Taylor expanded in angle around 0
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6418.1
Simplified18.1%
Taylor expanded in a around inf
unpow2N/A
lower-*.f6445.3
Simplified45.3%
if 1.9999999999999999e305 < (+.f64 (pow.f64 (*.f64 a (cos.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (sin.f64 (*.f64 (PI.f64) (/.f64 angle #s(literal 180 binary64))))) #s(literal 2 binary64))) Initial program 97.9%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6440.2
Simplified40.2%
Taylor expanded in angle around -inf
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
unpow3N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
Simplified29.5%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-PI.f6438.4
Simplified38.4%
Final simplification42.8%
(FPCore (a b angle) :precision binary64 (+ (pow (* b (sin (* PI (/ angle 180.0)))) 2.0) (pow (* a (cos (* 0.005555555555555556 (* angle PI)))) 2.0)))
double code(double a, double b, double angle) {
return pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0) + pow((a * cos((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0) + Math.pow((a * Math.cos((0.005555555555555556 * (angle * Math.PI)))), 2.0);
}
def code(a, b, angle): return math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0) + math.pow((a * math.cos((0.005555555555555556 * (angle * math.pi)))), 2.0)
function code(a, b, angle) return Float64((Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0) + (Float64(a * cos(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((b * sin((pi * (angle / 180.0)))) ^ 2.0) + ((a * cos((0.005555555555555556 * (angle * pi)))) ^ 2.0); 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[Power[N[(a * N[Cos[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(a \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}
\end{array}
Initial program 76.5%
Taylor expanded in a around 0
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-cos.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6476.5
Simplified76.5%
Final simplification76.5%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* 0.005555555555555556 (* angle PI)))) (+ (* (* a a) (pow (cos t_0) 2.0)) (pow (* b (sin t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = 0.005555555555555556 * (angle * ((double) M_PI));
return ((a * a) * pow(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 = 0.005555555555555556 * (angle * Math.PI);
return ((a * a) * Math.pow(Math.cos(t_0), 2.0)) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle): t_0 = 0.005555555555555556 * (angle * math.pi) return ((a * a) * math.pow(math.cos(t_0), 2.0)) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(0.005555555555555556 * Float64(angle * pi)) return Float64(Float64(Float64(a * a) * (cos(t_0) ^ 2.0)) + (Float64(b * sin(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = 0.005555555555555556 * (angle * pi); tmp = ((a * a) * (cos(t_0) ^ 2.0)) + ((b * sin(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(a * a), $MachinePrecision] * N[Power[N[Cos[t$95$0], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\
\left(a \cdot a\right) \cdot {\cos t\_0}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
\end{array}
Initial program 76.5%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-cos.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6476.5
Simplified76.5%
lift-PI.f64N/A
associate-*r/N/A
lift-*.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6476.5
lift-*.f64N/A
*-commutativeN/A
lift-*.f6476.5
Applied egg-rr76.5%
Final simplification76.5%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* b (sin (* angle (* 0.005555555555555556 PI))))))
(fma
t_0
t_0
(* (* a a) (fma 0.5 (cos (* (* angle PI) 0.011111111111111112)) 0.5)))))
double code(double a, double b, double angle) {
double t_0 = b * sin((angle * (0.005555555555555556 * ((double) M_PI))));
return fma(t_0, t_0, ((a * a) * fma(0.5, cos(((angle * ((double) M_PI)) * 0.011111111111111112)), 0.5)));
}
function code(a, b, angle) t_0 = Float64(b * sin(Float64(angle * Float64(0.005555555555555556 * pi)))) return fma(t_0, t_0, Float64(Float64(a * a) * fma(0.5, cos(Float64(Float64(angle * pi) * 0.011111111111111112)), 0.5))) end
code[a_, b_, angle_] := Block[{t$95$0 = N[(b * N[Sin[N[(angle * N[(0.005555555555555556 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0 + N[(N[(a * a), $MachinePrecision] * N[(0.5 * N[Cos[N[(N[(angle * Pi), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot \sin \left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right)\\
\mathsf{fma}\left(t\_0, t\_0, \left(a \cdot a\right) \cdot \mathsf{fma}\left(0.5, \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right), 0.5\right)\right)
\end{array}
\end{array}
Initial program 76.5%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-cos.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6476.5
Simplified76.5%
Applied egg-rr76.4%
Final simplification76.4%
(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 76.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6475.7
Simplified75.7%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (cos (* (* angle PI) 0.011111111111111112))))
(if (<= (/ angle 180.0) 500000.0)
(fma
(* angle (* angle (* b (* (* PI PI) 3.08641975308642e-5))))
b
(* (* a a) (fma 0.5 t_0 0.5)))
(fma (* b (fma t_0 -0.5 0.5)) b (* (* a a) (fma 0.5 1.0 0.5))))))
double code(double a, double b, double angle) {
double t_0 = cos(((angle * ((double) M_PI)) * 0.011111111111111112));
double tmp;
if ((angle / 180.0) <= 500000.0) {
tmp = fma((angle * (angle * (b * ((((double) M_PI) * ((double) M_PI)) * 3.08641975308642e-5)))), b, ((a * a) * fma(0.5, t_0, 0.5)));
} else {
tmp = fma((b * fma(t_0, -0.5, 0.5)), b, ((a * a) * fma(0.5, 1.0, 0.5)));
}
return tmp;
}
function code(a, b, angle) t_0 = cos(Float64(Float64(angle * pi) * 0.011111111111111112)) tmp = 0.0 if (Float64(angle / 180.0) <= 500000.0) tmp = fma(Float64(angle * Float64(angle * Float64(b * Float64(Float64(pi * pi) * 3.08641975308642e-5)))), b, Float64(Float64(a * a) * fma(0.5, t_0, 0.5))); else tmp = fma(Float64(b * fma(t_0, -0.5, 0.5)), b, Float64(Float64(a * a) * fma(0.5, 1.0, 0.5))); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[Cos[N[(N[(angle * Pi), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(angle / 180.0), $MachinePrecision], 500000.0], N[(N[(angle * N[(angle * N[(b * N[(N[(Pi * Pi), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b + N[(N[(a * a), $MachinePrecision] * N[(0.5 * t$95$0 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * N[(t$95$0 * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision] * b + N[(N[(a * a), $MachinePrecision] * N[(0.5 * 1.0 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\\
\mathbf{if}\;\frac{angle}{180} \leq 500000:\\
\;\;\;\;\mathsf{fma}\left(angle \cdot \left(angle \cdot \left(b \cdot \left(\left(\pi \cdot \pi\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\right), b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(0.5, t\_0, 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot \mathsf{fma}\left(t\_0, -0.5, 0.5\right), b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(0.5, 1, 0.5\right)\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 5e5Initial program 82.8%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-cos.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6482.9
Simplified82.9%
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-/.f6482.8
Applied egg-rr82.8%
Applied egg-rr67.9%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f6478.4
Simplified78.4%
if 5e5 < (/.f64 angle #s(literal 180 binary64)) Initial program 59.7%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-cos.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6459.7
Simplified59.7%
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-/.f6459.7
Applied egg-rr59.7%
Applied egg-rr59.4%
Taylor expanded in angle around 0
Simplified59.5%
Final simplification73.2%
(FPCore (a b angle)
:precision binary64
(if (<= b 1.05e+139)
(fma
(* b (fma 1.0 -0.5 0.5))
b
(* (* a a) (fma 0.5 (cos (* (* angle PI) 0.011111111111111112)) 0.5)))
(*
(* b (* b b))
(fma (cos (* angle (* PI 0.011111111111111112))) -0.5 0.5))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.05e+139) {
tmp = fma((b * fma(1.0, -0.5, 0.5)), b, ((a * a) * fma(0.5, cos(((angle * ((double) M_PI)) * 0.011111111111111112)), 0.5)));
} else {
tmp = (b * (b * b)) * fma(cos((angle * (((double) M_PI) * 0.011111111111111112))), -0.5, 0.5);
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 1.05e+139) tmp = fma(Float64(b * fma(1.0, -0.5, 0.5)), b, Float64(Float64(a * a) * fma(0.5, cos(Float64(Float64(angle * pi) * 0.011111111111111112)), 0.5))); else tmp = Float64(Float64(b * Float64(b * b)) * fma(cos(Float64(angle * Float64(pi * 0.011111111111111112))), -0.5, 0.5)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 1.05e+139], N[(N[(b * N[(1.0 * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision] * b + N[(N[(a * a), $MachinePrecision] * N[(0.5 * N[Cos[N[(N[(angle * Pi), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[N[(angle * N[(Pi * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.05 \cdot 10^{+139}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot \mathsf{fma}\left(1, -0.5, 0.5\right), b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(0.5, \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right), 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot \left(b \cdot b\right)\right) \cdot \mathsf{fma}\left(\cos \left(angle \cdot \left(\pi \cdot 0.011111111111111112\right)\right), -0.5, 0.5\right)\\
\end{array}
\end{array}
if b < 1.0499999999999999e139Initial program 73.8%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-cos.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6473.8
Simplified73.8%
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-/.f6473.8
Applied egg-rr73.8%
Applied egg-rr63.6%
Taylor expanded in angle around 0
Simplified55.7%
if 1.0499999999999999e139 < b Initial program 96.6%
Applied egg-rr56.5%
Taylor expanded in a around 0
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-cos.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
metadata-eval63.9
Simplified63.9%
Final simplification56.6%
(FPCore (a b angle) :precision binary64 (fma (* b (fma (cos (* (* angle PI) 0.011111111111111112)) -0.5 0.5)) b (* (* a a) (fma 0.5 1.0 0.5))))
double code(double a, double b, double angle) {
return fma((b * fma(cos(((angle * ((double) M_PI)) * 0.011111111111111112)), -0.5, 0.5)), b, ((a * a) * fma(0.5, 1.0, 0.5)));
}
function code(a, b, angle) return fma(Float64(b * fma(cos(Float64(Float64(angle * pi) * 0.011111111111111112)), -0.5, 0.5)), b, Float64(Float64(a * a) * fma(0.5, 1.0, 0.5))) end
code[a_, b_, angle_] := N[(N[(b * N[(N[Cos[N[(N[(angle * Pi), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision] * b + N[(N[(a * a), $MachinePrecision] * N[(0.5 * 1.0 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(b \cdot \mathsf{fma}\left(\cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right), -0.5, 0.5\right), b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(0.5, 1, 0.5\right)\right)
\end{array}
Initial program 76.5%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-cos.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6476.5
Simplified76.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 egg-rr76.5%
Applied egg-rr65.6%
Taylor expanded in angle around 0
Simplified64.8%
Final simplification64.8%
(FPCore (a b angle)
:precision binary64
(if (<= b 1.05e+139)
(* a a)
(*
(* b (* b b))
(fma (cos (* angle (* PI 0.011111111111111112))) -0.5 0.5))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.05e+139) {
tmp = a * a;
} else {
tmp = (b * (b * b)) * fma(cos((angle * (((double) M_PI) * 0.011111111111111112))), -0.5, 0.5);
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 1.05e+139) tmp = Float64(a * a); else tmp = Float64(Float64(b * Float64(b * b)) * fma(cos(Float64(angle * Float64(pi * 0.011111111111111112))), -0.5, 0.5)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 1.05e+139], N[(a * a), $MachinePrecision], N[(N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[N[(angle * N[(Pi * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.05 \cdot 10^{+139}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot \left(b \cdot b\right)\right) \cdot \mathsf{fma}\left(\cos \left(angle \cdot \left(\pi \cdot 0.011111111111111112\right)\right), -0.5, 0.5\right)\\
\end{array}
\end{array}
if b < 1.0499999999999999e139Initial program 73.8%
Taylor expanded in angle around 0
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6427.9
Simplified27.9%
Taylor expanded in a around inf
unpow2N/A
lower-*.f6455.2
Simplified55.2%
if 1.0499999999999999e139 < b Initial program 96.6%
Applied egg-rr56.5%
Taylor expanded in a around 0
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-cos.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
metadata-eval63.9
Simplified63.9%
(FPCore (a b angle)
:precision binary64
(if (<= b 5.2e+257)
(* a a)
(fma
a
(* a a)
(*
(* angle angle)
(*
(* PI PI)
(fma
(* a (* a a))
-3.08641975308642e-5
(* 3.08641975308642e-5 (* b (* b b)))))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 5.2e+257) {
tmp = a * a;
} else {
tmp = fma(a, (a * a), ((angle * angle) * ((((double) M_PI) * ((double) M_PI)) * fma((a * (a * a)), -3.08641975308642e-5, (3.08641975308642e-5 * (b * (b * b)))))));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 5.2e+257) tmp = Float64(a * a); else tmp = fma(a, Float64(a * a), Float64(Float64(angle * angle) * Float64(Float64(pi * pi) * fma(Float64(a * Float64(a * a)), -3.08641975308642e-5, Float64(3.08641975308642e-5 * Float64(b * Float64(b * b))))))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 5.2e+257], N[(a * a), $MachinePrecision], N[(a * N[(a * a), $MachinePrecision] + N[(N[(angle * angle), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * N[(N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision] * -3.08641975308642e-5 + N[(3.08641975308642e-5 * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.2 \cdot 10^{+257}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, a \cdot a, \left(angle \cdot angle\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot \mathsf{fma}\left(a \cdot \left(a \cdot a\right), -3.08641975308642 \cdot 10^{-5}, 3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot \left(b \cdot b\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if b < 5.20000000000000042e257Initial program 75.6%
Taylor expanded in angle around 0
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6426.7
Simplified26.7%
Taylor expanded in a around inf
unpow2N/A
lower-*.f6455.5
Simplified55.5%
if 5.20000000000000042e257 < b Initial program 100.0%
Taylor expanded in a around 0
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-pow.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-cos.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64100.0
Simplified100.0%
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-/.f6499.7
Applied egg-rr99.7%
Applied egg-rr89.3%
Taylor expanded in angle around 0
+-commutativeN/A
cube-multN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r*N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
Simplified55.6%
Final simplification55.5%
(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
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6426.7
Simplified26.7%
Taylor expanded in a around inf
unpow2N/A
lower-*.f6454.8
Simplified54.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)))