
(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
(*
b
(sin
(*
(* (* angle 0.005555555555555556) (sqrt (* PI (sqrt PI))))
(sqrt (sqrt PI)))))
2.0)))
double code(double a, double b, double angle) {
return (a * a) + pow((b * sin((((angle * 0.005555555555555556) * sqrt((((double) M_PI) * sqrt(((double) M_PI))))) * sqrt(sqrt(((double) M_PI)))))), 2.0);
}
public static double code(double a, double b, double angle) {
return (a * a) + Math.pow((b * Math.sin((((angle * 0.005555555555555556) * Math.sqrt((Math.PI * Math.sqrt(Math.PI)))) * Math.sqrt(Math.sqrt(Math.PI))))), 2.0);
}
def code(a, b, angle): return (a * a) + math.pow((b * math.sin((((angle * 0.005555555555555556) * math.sqrt((math.pi * math.sqrt(math.pi)))) * math.sqrt(math.sqrt(math.pi))))), 2.0)
function code(a, b, angle) return Float64(Float64(a * a) + (Float64(b * sin(Float64(Float64(Float64(angle * 0.005555555555555556) * sqrt(Float64(pi * sqrt(pi)))) * sqrt(sqrt(pi))))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a * a) + ((b * sin((((angle * 0.005555555555555556) * sqrt((pi * sqrt(pi)))) * sqrt(sqrt(pi))))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(N[(N[(angle * 0.005555555555555556), $MachinePrecision] * N[Sqrt[N[(Pi * N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[Sqrt[Pi], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a + {\left(b \cdot \sin \left(\left(\left(angle \cdot 0.005555555555555556\right) \cdot \sqrt{\pi \cdot \sqrt{\pi}}\right) \cdot \sqrt{\sqrt{\pi}}\right)\right)}^{2}
\end{array}
Initial program 81.0%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6481.4
Applied rewrites81.4%
lift-PI.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-PI.f64N/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lift-*.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lift-PI.f64N/A
lower-sqrt.f6481.4
Applied rewrites81.4%
lift-*.f64N/A
lift-PI.f64N/A
lift-sqrt.f64N/A
lift-PI.f64N/A
lift-sqrt.f64N/A
associate-*l*N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-*r*N/A
lift-*.f64N/A
sqrt-unprodN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
Applied rewrites81.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 81.0%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6481.4
Applied rewrites81.4%
(FPCore (a b angle) :precision binary64 (+ (* a a) (pow (* b (sin (* 0.005555555555555556 (* angle PI)))) 2.0)))
double code(double a, double b, double angle) {
return (a * a) + pow((b * sin((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0);
}
public static double code(double a, double b, double angle) {
return (a * a) + Math.pow((b * Math.sin((0.005555555555555556 * (angle * Math.PI)))), 2.0);
}
def code(a, b, angle): return (a * a) + math.pow((b * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0)
function code(a, b, angle) return Float64(Float64(a * a) + (Float64(b * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a * a) + ((b * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a + {\left(b \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}
\end{array}
Initial program 81.0%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6481.4
Applied rewrites81.4%
lift-PI.f64N/A
div-invN/A
metadata-evalN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6481.0
Applied rewrites81.0%
Final simplification81.0%
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) 2e+24)
(+
(* a a)
(pow
(*
b
(*
angle
(*
PI
(fma
(* (* angle angle) -2.8577960676726107e-8)
(* PI PI)
0.005555555555555556))))
2.0))
(fma
(* b (fma (cos (* (* angle PI) 0.011111111111111112)) -0.5 0.5))
b
(* a a))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= 2e+24) {
tmp = (a * a) + pow((b * (angle * (((double) M_PI) * fma(((angle * angle) * -2.8577960676726107e-8), (((double) M_PI) * ((double) M_PI)), 0.005555555555555556)))), 2.0);
} else {
tmp = fma((b * fma(cos(((angle * ((double) M_PI)) * 0.011111111111111112)), -0.5, 0.5)), b, (a * a));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= 2e+24) tmp = Float64(Float64(a * a) + (Float64(b * Float64(angle * Float64(pi * fma(Float64(Float64(angle * angle) * -2.8577960676726107e-8), Float64(pi * pi), 0.005555555555555556)))) ^ 2.0)); else tmp = fma(Float64(b * fma(cos(Float64(Float64(angle * pi) * 0.011111111111111112)), -0.5, 0.5)), b, Float64(a * a)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], 2e+24], N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[(angle * N[(Pi * N[(N[(N[(angle * angle), $MachinePrecision] * -2.8577960676726107e-8), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision] + 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(b * N[(N[Cos[N[(N[(angle * Pi), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision] * b + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 2 \cdot 10^{+24}:\\
\;\;\;\;a \cdot a + {\left(b \cdot \left(angle \cdot \left(\pi \cdot \mathsf{fma}\left(\left(angle \cdot angle\right) \cdot -2.8577960676726107 \cdot 10^{-8}, \pi \cdot \pi, 0.005555555555555556\right)\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\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, a \cdot a\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 2e24Initial program 88.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6489.0
Applied rewrites89.0%
Taylor expanded in angle around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
unpow3N/A
unpow2N/A
associate-*r*N/A
Applied rewrites83.7%
if 2e24 < (/.f64 angle #s(literal 180 binary64)) Initial program 59.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6459.8
Applied rewrites59.8%
Applied rewrites59.7%
Final simplification77.5%
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) 2e-5)
(+ (* a a) (pow (* 0.005555555555555556 (* b (* angle PI))) 2.0))
(fma
(* b (fma (cos (* (* angle PI) 0.011111111111111112)) -0.5 0.5))
b
(* a a))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= 2e-5) {
tmp = (a * a) + pow((0.005555555555555556 * (b * (angle * ((double) M_PI)))), 2.0);
} else {
tmp = fma((b * fma(cos(((angle * ((double) M_PI)) * 0.011111111111111112)), -0.5, 0.5)), b, (a * a));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= 2e-5) tmp = Float64(Float64(a * a) + (Float64(0.005555555555555556 * Float64(b * Float64(angle * pi))) ^ 2.0)); else tmp = fma(Float64(b * fma(cos(Float64(Float64(angle * pi) * 0.011111111111111112)), -0.5, 0.5)), b, Float64(a * a)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], 2e-5], N[(N[(a * a), $MachinePrecision] + N[Power[N[(0.005555555555555556 * N[(b * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(b * N[(N[Cos[N[(N[(angle * Pi), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision] * b + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 2 \cdot 10^{-5}:\\
\;\;\;\;a \cdot a + {\left(0.005555555555555556 \cdot \left(b \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\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, a \cdot a\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 2.00000000000000016e-5Initial program 88.7%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6489.1
Applied rewrites89.1%
Taylor expanded in angle around 0
lower-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6484.9
Applied rewrites84.9%
if 2.00000000000000016e-5 < (/.f64 angle #s(literal 180 binary64)) Initial program 61.3%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6462.0
Applied rewrites62.0%
Applied rewrites61.6%
Final simplification78.3%
(FPCore (a b angle) :precision binary64 (if (<= b 3.2e-110) (* a a) (+ (* a a) (pow (* 0.005555555555555556 (* b (* angle PI))) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 3.2e-110) {
tmp = a * a;
} else {
tmp = (a * a) + pow((0.005555555555555556 * (b * (angle * ((double) M_PI)))), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 3.2e-110) {
tmp = a * a;
} else {
tmp = (a * a) + Math.pow((0.005555555555555556 * (b * (angle * Math.PI))), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 3.2e-110: tmp = a * a else: tmp = (a * a) + math.pow((0.005555555555555556 * (b * (angle * math.pi))), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 3.2e-110) tmp = Float64(a * a); else tmp = Float64(Float64(a * a) + (Float64(0.005555555555555556 * Float64(b * Float64(angle * pi))) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 3.2e-110) tmp = a * a; else tmp = (a * a) + ((0.005555555555555556 * (b * (angle * pi))) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 3.2e-110], N[(a * a), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[Power[N[(0.005555555555555556 * N[(b * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.2 \cdot 10^{-110}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + {\left(0.005555555555555556 \cdot \left(b \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if b < 3.20000000000000028e-110Initial program 78.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6462.6
Applied rewrites62.6%
if 3.20000000000000028e-110 < b Initial program 85.3%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6485.3
Applied rewrites85.3%
Taylor expanded in angle around 0
lower-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6482.7
Applied rewrites82.7%
(FPCore (a b angle)
:precision binary64
(if (<= b 3.2e-110)
(* a a)
(if (<= b 1.1e+140)
(fma
3.08641975308642e-5
(* (* b b) (* angle (* angle (* PI PI))))
(* a a))
(* b (* (* b PI) (* (* angle angle) (* PI 3.08641975308642e-5)))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 3.2e-110) {
tmp = a * a;
} else if (b <= 1.1e+140) {
tmp = fma(3.08641975308642e-5, ((b * b) * (angle * (angle * (((double) M_PI) * ((double) M_PI))))), (a * a));
} else {
tmp = b * ((b * ((double) M_PI)) * ((angle * angle) * (((double) M_PI) * 3.08641975308642e-5)));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 3.2e-110) tmp = Float64(a * a); elseif (b <= 1.1e+140) tmp = fma(3.08641975308642e-5, Float64(Float64(b * b) * Float64(angle * Float64(angle * Float64(pi * pi)))), Float64(a * a)); else tmp = Float64(b * Float64(Float64(b * pi) * Float64(Float64(angle * angle) * Float64(pi * 3.08641975308642e-5)))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 3.2e-110], N[(a * a), $MachinePrecision], If[LessEqual[b, 1.1e+140], N[(3.08641975308642e-5 * N[(N[(b * b), $MachinePrecision] * N[(angle * N[(angle * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(b * N[(N[(b * Pi), $MachinePrecision] * N[(N[(angle * angle), $MachinePrecision] * N[(Pi * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.2 \cdot 10^{-110}:\\
\;\;\;\;a \cdot a\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{+140}:\\
\;\;\;\;\mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, \left(b \cdot b\right) \cdot \left(angle \cdot \left(angle \cdot \left(\pi \cdot \pi\right)\right)\right), a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\left(b \cdot \pi\right) \cdot \left(\left(angle \cdot angle\right) \cdot \left(\pi \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\right)\\
\end{array}
\end{array}
if b < 3.20000000000000028e-110Initial program 78.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6462.6
Applied rewrites62.6%
if 3.20000000000000028e-110 < b < 1.0999999999999999e140Initial program 72.7%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6472.7
Applied rewrites72.7%
Taylor expanded in angle around 0
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6465.9
Applied rewrites65.9%
if 1.0999999999999999e140 < b Initial program 99.7%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in angle around 0
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6456.0
Applied rewrites56.0%
Taylor expanded in b around inf
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites56.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
Applied rewrites66.2%
Final simplification63.7%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* PI (* angle PI))))
(if (<= b 5e+110)
(fma (* angle (* b b)) (* t_0 3.08641975308642e-5) (* a a))
(fma 3.08641975308642e-5 (* b (* b (* angle t_0))) (* a a)))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle * ((double) M_PI));
double tmp;
if (b <= 5e+110) {
tmp = fma((angle * (b * b)), (t_0 * 3.08641975308642e-5), (a * a));
} else {
tmp = fma(3.08641975308642e-5, (b * (b * (angle * t_0))), (a * a));
}
return tmp;
}
function code(a, b, angle) t_0 = Float64(pi * Float64(angle * pi)) tmp = 0.0 if (b <= 5e+110) tmp = fma(Float64(angle * Float64(b * b)), Float64(t_0 * 3.08641975308642e-5), Float64(a * a)); else tmp = fma(3.08641975308642e-5, Float64(b * Float64(b * Float64(angle * t_0))), Float64(a * a)); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 5e+110], N[(N[(angle * N[(b * b), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * 3.08641975308642e-5), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(3.08641975308642e-5 * N[(b * N[(b * N[(angle * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(angle \cdot \pi\right)\\
\mathbf{if}\;b \leq 5 \cdot 10^{+110}:\\
\;\;\;\;\mathsf{fma}\left(angle \cdot \left(b \cdot b\right), t\_0 \cdot 3.08641975308642 \cdot 10^{-5}, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, b \cdot \left(b \cdot \left(angle \cdot t\_0\right)\right), a \cdot a\right)\\
\end{array}
\end{array}
if b < 4.99999999999999978e110Initial program 78.2%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6478.7
Applied rewrites78.7%
Taylor expanded in angle around 0
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6463.2
Applied rewrites63.2%
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites70.1%
if 4.99999999999999978e110 < b Initial program 94.0%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6494.0
Applied rewrites94.0%
Taylor expanded in angle around 0
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6454.7
Applied rewrites54.7%
lift-PI.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6485.5
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f6485.5
Applied rewrites85.5%
Final simplification72.8%
(FPCore (a b angle)
:precision binary64
(if (<= b 3.2e-110)
(* a a)
(fma
3.08641975308642e-5
(* b (* b (* angle (* PI (* angle PI)))))
(* a a))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 3.2e-110) {
tmp = a * a;
} else {
tmp = fma(3.08641975308642e-5, (b * (b * (angle * (((double) M_PI) * (angle * ((double) M_PI)))))), (a * a));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 3.2e-110) tmp = Float64(a * a); else tmp = fma(3.08641975308642e-5, Float64(b * Float64(b * Float64(angle * Float64(pi * Float64(angle * pi))))), Float64(a * a)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 3.2e-110], N[(a * a), $MachinePrecision], N[(3.08641975308642e-5 * N[(b * N[(b * N[(angle * N[(Pi * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.2 \cdot 10^{-110}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, b \cdot \left(b \cdot \left(angle \cdot \left(\pi \cdot \left(angle \cdot \pi\right)\right)\right)\right), a \cdot a\right)\\
\end{array}
\end{array}
if b < 3.20000000000000028e-110Initial program 78.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6462.6
Applied rewrites62.6%
if 3.20000000000000028e-110 < b Initial program 85.3%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6485.3
Applied rewrites85.3%
Taylor expanded in angle around 0
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6461.3
Applied rewrites61.3%
lift-PI.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6477.4
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f6477.4
Applied rewrites77.4%
Final simplification67.6%
(FPCore (a b angle) :precision binary64 (if (<= b 1.55e+98) (* a a) (* b (* (* b PI) (* (* angle angle) (* PI 3.08641975308642e-5))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.55e+98) {
tmp = a * a;
} else {
tmp = b * ((b * ((double) M_PI)) * ((angle * angle) * (((double) M_PI) * 3.08641975308642e-5)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 1.55e+98) {
tmp = a * a;
} else {
tmp = b * ((b * Math.PI) * ((angle * angle) * (Math.PI * 3.08641975308642e-5)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 1.55e+98: tmp = a * a else: tmp = b * ((b * math.pi) * ((angle * angle) * (math.pi * 3.08641975308642e-5))) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 1.55e+98) tmp = Float64(a * a); else tmp = Float64(b * Float64(Float64(b * pi) * Float64(Float64(angle * angle) * Float64(pi * 3.08641975308642e-5)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 1.55e+98) tmp = a * a; else tmp = b * ((b * pi) * ((angle * angle) * (pi * 3.08641975308642e-5))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 1.55e+98], N[(a * a), $MachinePrecision], N[(b * N[(N[(b * Pi), $MachinePrecision] * N[(N[(angle * angle), $MachinePrecision] * N[(Pi * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.55 \cdot 10^{+98}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\left(b \cdot \pi\right) \cdot \left(\left(angle \cdot angle\right) \cdot \left(\pi \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\right)\\
\end{array}
\end{array}
if b < 1.5500000000000001e98Initial program 78.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6463.3
Applied rewrites63.3%
if 1.5500000000000001e98 < b Initial program 91.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6491.5
Applied rewrites91.5%
Taylor expanded in angle around 0
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6454.5
Applied rewrites54.5%
Taylor expanded in b around inf
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites54.5%
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
Applied rewrites62.4%
Final simplification63.1%
(FPCore (a b angle) :precision binary64 (if (<= b 1.12e+160) (* a a) (* (* b b) (* (* PI PI) (* (* angle angle) 3.08641975308642e-5)))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.12e+160) {
tmp = a * a;
} else {
tmp = (b * b) * ((((double) M_PI) * ((double) M_PI)) * ((angle * angle) * 3.08641975308642e-5));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 1.12e+160) {
tmp = a * a;
} else {
tmp = (b * b) * ((Math.PI * Math.PI) * ((angle * angle) * 3.08641975308642e-5));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 1.12e+160: tmp = a * a else: tmp = (b * b) * ((math.pi * math.pi) * ((angle * angle) * 3.08641975308642e-5)) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 1.12e+160) tmp = Float64(a * a); else tmp = Float64(Float64(b * b) * Float64(Float64(pi * pi) * Float64(Float64(angle * angle) * 3.08641975308642e-5))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 1.12e+160) tmp = a * a; else tmp = (b * b) * ((pi * pi) * ((angle * angle) * 3.08641975308642e-5)); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 1.12e+160], N[(a * a), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * N[(N[(angle * angle), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.12 \cdot 10^{+160}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot \left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\\
\end{array}
\end{array}
if b < 1.12e160Initial program 77.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6461.2
Applied rewrites61.2%
if 1.12e160 < b Initial program 99.7%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in angle around 0
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6457.7
Applied rewrites57.7%
Taylor expanded in b around inf
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites57.7%
Final simplification60.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 81.0%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.1
Applied rewrites57.1%
herbie shell --seed 2024219
(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)))