
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (/ angle 180.0)))) (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle / 180.0);
return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle / 180.0);
return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle): t_0 = math.pi * (angle / 180.0) return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(pi * Float64(angle / 180.0)) return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = pi * (angle / 180.0); tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (/ angle 180.0)))) (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle / 180.0);
return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle / 180.0);
return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle): t_0 = math.pi * (angle / 180.0) return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(pi * Float64(angle / 180.0)) return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = pi * (angle / 180.0); tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
\end{array}
(FPCore (a b angle) :precision binary64 (+ (* a a) (pow (* b (sin (/ PI (/ 180.0 angle)))) 2.0)))
double code(double a, double b, double angle) {
return (a * a) + pow((b * sin((((double) M_PI) / (180.0 / angle)))), 2.0);
}
public static double code(double a, double b, double angle) {
return (a * a) + Math.pow((b * Math.sin((Math.PI / (180.0 / angle)))), 2.0);
}
def code(a, b, angle): return (a * a) + math.pow((b * math.sin((math.pi / (180.0 / angle)))), 2.0)
function code(a, b, angle) return Float64(Float64(a * a) + (Float64(b * sin(Float64(pi / Float64(180.0 / angle)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a * a) + ((b * sin((pi / (180.0 / angle)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi / N[(180.0 / angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a + {\left(b \cdot \sin \left(\frac{\pi}{\frac{180}{angle}}\right)\right)}^{2}
\end{array}
Initial program 78.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6478.8
Applied rewrites78.8%
lift-PI.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6478.9
Applied rewrites78.9%
(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(Float64(pi * 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[(N[(Pi * angle), $MachinePrecision] / 180.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a + {\left(b \cdot \sin \left(\frac{\pi \cdot angle}{180}\right)\right)}^{2}
\end{array}
Initial program 78.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6478.8
Applied rewrites78.8%
lift-PI.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6478.9
Applied rewrites78.9%
(FPCore (a b angle) :precision binary64 (+ (* a a) (pow (* b (sin (* PI (* angle 0.005555555555555556)))) 2.0)))
double code(double a, double b, double angle) {
return (a * a) + pow((b * sin((((double) M_PI) * (angle * 0.005555555555555556)))), 2.0);
}
public static double code(double a, double b, double angle) {
return (a * a) + Math.pow((b * Math.sin((Math.PI * (angle * 0.005555555555555556)))), 2.0);
}
def code(a, b, angle): return (a * a) + math.pow((b * math.sin((math.pi * (angle * 0.005555555555555556)))), 2.0)
function code(a, b, angle) return Float64(Float64(a * a) + (Float64(b * sin(Float64(pi * Float64(angle * 0.005555555555555556)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a * a) + ((b * sin((pi * (angle * 0.005555555555555556)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a + {\left(b \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2}
\end{array}
Initial program 78.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6478.8
Applied rewrites78.8%
Applied rewrites63.0%
Applied rewrites78.8%
Final simplification78.8%
(FPCore (a b angle) :precision binary64 (+ (* a a) (pow (* b (sin (* angle (* PI 0.005555555555555556)))) 2.0)))
double code(double a, double b, double angle) {
return (a * a) + pow((b * sin((angle * (((double) M_PI) * 0.005555555555555556)))), 2.0);
}
public static double code(double a, double b, double angle) {
return (a * a) + Math.pow((b * Math.sin((angle * (Math.PI * 0.005555555555555556)))), 2.0);
}
def code(a, b, angle): return (a * a) + math.pow((b * math.sin((angle * (math.pi * 0.005555555555555556)))), 2.0)
function code(a, b, angle) return Float64(Float64(a * a) + (Float64(b * sin(Float64(angle * Float64(pi * 0.005555555555555556)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a * a) + ((b * sin((angle * (pi * 0.005555555555555556)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a + {\left(b \cdot \sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}
\end{array}
Initial program 78.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6478.8
Applied rewrites78.8%
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6478.8
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
div-invN/A
metadata-evalN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6478.8
Applied rewrites78.8%
Final simplification78.8%
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) 1e-5)
(+
(* a a)
(pow
(*
b
(*
angle
(*
PI
(fma
(* (* angle angle) -2.8577960676726107e-8)
(* PI PI)
0.005555555555555556))))
2.0))
(fma
(* b (fma -0.5 (cos (* PI (* angle 0.011111111111111112))) 0.5))
b
(* a a))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= 1e-5) {
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(-0.5, cos((((double) M_PI) * (angle * 0.011111111111111112))), 0.5)), b, (a * a));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= 1e-5) 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(-0.5, cos(Float64(pi * Float64(angle * 0.011111111111111112))), 0.5)), b, Float64(a * a)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], 1e-5], 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[(-0.5 * N[Cos[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] * b + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 10^{-5}:\\
\;\;\;\;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(-0.5, \cos \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right), 0.5\right), b, a \cdot a\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 1.00000000000000008e-5Initial program 87.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6487.3
Applied rewrites87.3%
Taylor expanded in angle around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
+-commutativeN/A
associate-*r*N/A
unpow3N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
Applied rewrites81.9%
if 1.00000000000000008e-5 < (/.f64 angle #s(literal 180 binary64)) Initial program 57.3%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6459.8
Applied rewrites59.8%
lift-PI.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6459.9
Applied rewrites59.9%
Applied rewrites59.8%
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) 1e-5)
(+
(* a a)
(pow
(*
angle
(*
b
(*
PI
(fma
(* (* angle angle) -2.8577960676726107e-8)
(* PI PI)
0.005555555555555556))))
2.0))
(fma
(* b (fma -0.5 (cos (* PI (* angle 0.011111111111111112))) 0.5))
b
(* a a))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= 1e-5) {
tmp = (a * a) + pow((angle * (b * (((double) M_PI) * fma(((angle * angle) * -2.8577960676726107e-8), (((double) M_PI) * ((double) M_PI)), 0.005555555555555556)))), 2.0);
} else {
tmp = fma((b * fma(-0.5, cos((((double) M_PI) * (angle * 0.011111111111111112))), 0.5)), b, (a * a));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= 1e-5) tmp = Float64(Float64(a * a) + (Float64(angle * Float64(b * Float64(pi * fma(Float64(Float64(angle * angle) * -2.8577960676726107e-8), Float64(pi * pi), 0.005555555555555556)))) ^ 2.0)); else tmp = fma(Float64(b * fma(-0.5, cos(Float64(pi * Float64(angle * 0.011111111111111112))), 0.5)), b, Float64(a * a)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], 1e-5], N[(N[(a * a), $MachinePrecision] + N[Power[N[(angle * N[(b * 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[(-0.5 * N[Cos[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] * b + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 10^{-5}:\\
\;\;\;\;a \cdot a + {\left(angle \cdot \left(b \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(-0.5, \cos \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right), 0.5\right), b, a \cdot a\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 1.00000000000000008e-5Initial program 87.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6487.3
Applied rewrites87.3%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
+-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites81.9%
if 1.00000000000000008e-5 < (/.f64 angle #s(literal 180 binary64)) Initial program 57.3%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6459.8
Applied rewrites59.8%
lift-PI.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6459.9
Applied rewrites59.9%
Applied rewrites59.8%
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) 1e-5)
(+ (* a a) (pow (* b (* angle (* PI 0.005555555555555556))) 2.0))
(fma
(* b (fma -0.5 (cos (* PI (* angle 0.011111111111111112))) 0.5))
b
(* a a))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= 1e-5) {
tmp = (a * a) + pow((b * (angle * (((double) M_PI) * 0.005555555555555556))), 2.0);
} else {
tmp = fma((b * fma(-0.5, cos((((double) M_PI) * (angle * 0.011111111111111112))), 0.5)), b, (a * a));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= 1e-5) tmp = Float64(Float64(a * a) + (Float64(b * Float64(angle * Float64(pi * 0.005555555555555556))) ^ 2.0)); else tmp = fma(Float64(b * fma(-0.5, cos(Float64(pi * Float64(angle * 0.011111111111111112))), 0.5)), b, Float64(a * a)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], 1e-5], N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(b * N[(-0.5 * N[Cos[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] * b + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 10^{-5}:\\
\;\;\;\;a \cdot a + {\left(b \cdot \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot \mathsf{fma}\left(-0.5, \cos \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right), 0.5\right), b, a \cdot a\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 1.00000000000000008e-5Initial program 87.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6487.3
Applied rewrites87.3%
Taylor expanded in angle around 0
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6483.1
Applied rewrites83.1%
if 1.00000000000000008e-5 < (/.f64 angle #s(literal 180 binary64)) Initial program 57.3%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6459.8
Applied rewrites59.8%
lift-PI.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6459.9
Applied rewrites59.9%
Applied rewrites59.8%
Final simplification75.9%
(FPCore (a b angle) :precision binary64 (if (<= b 3.2e-9) (* a a) (+ (* a a) (pow (* b (* angle (* PI 0.005555555555555556))) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 3.2e-9) {
tmp = a * a;
} else {
tmp = (a * a) + pow((b * (angle * (((double) M_PI) * 0.005555555555555556))), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 3.2e-9) {
tmp = a * a;
} else {
tmp = (a * a) + Math.pow((b * (angle * (Math.PI * 0.005555555555555556))), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 3.2e-9: tmp = a * a else: tmp = (a * a) + math.pow((b * (angle * (math.pi * 0.005555555555555556))), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 3.2e-9) tmp = Float64(a * a); else tmp = Float64(Float64(a * a) + (Float64(b * Float64(angle * Float64(pi * 0.005555555555555556))) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 3.2e-9) tmp = a * a; else tmp = (a * a) + ((b * (angle * (pi * 0.005555555555555556))) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 3.2e-9], N[(a * a), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.2 \cdot 10^{-9}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + {\left(b \cdot \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if b < 3.20000000000000012e-9Initial program 76.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6461.0
Applied rewrites61.0%
if 3.20000000000000012e-9 < b Initial program 83.2%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6483.2
Applied rewrites83.2%
Taylor expanded in angle around 0
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6480.2
Applied rewrites80.2%
Final simplification66.4%
(FPCore (a b angle)
:precision binary64
(if (<= b 3.2e-9)
(* a a)
(fma
(* (* PI PI) (* b (* angle (* b angle))))
3.08641975308642e-5
(* a a))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 3.2e-9) {
tmp = a * a;
} else {
tmp = fma(((((double) M_PI) * ((double) M_PI)) * (b * (angle * (b * angle)))), 3.08641975308642e-5, (a * a));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 3.2e-9) tmp = Float64(a * a); else tmp = fma(Float64(Float64(pi * pi) * Float64(b * Float64(angle * Float64(b * angle)))), 3.08641975308642e-5, Float64(a * a)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 3.2e-9], N[(a * a), $MachinePrecision], N[(N[(N[(Pi * Pi), $MachinePrecision] * N[(b * N[(angle * N[(b * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5 + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.2 \cdot 10^{-9}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\pi \cdot \pi\right) \cdot \left(b \cdot \left(angle \cdot \left(b \cdot angle\right)\right)\right), 3.08641975308642 \cdot 10^{-5}, a \cdot a\right)\\
\end{array}
\end{array}
if b < 3.20000000000000012e-9Initial program 76.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6461.0
Applied rewrites61.0%
if 3.20000000000000012e-9 < b Initial program 83.2%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6483.2
Applied rewrites83.2%
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-fma.f64N/A
Applied rewrites61.3%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites78.9%
Final simplification66.1%
(FPCore (a b angle)
:precision binary64
(if (<= b 3.2e-9)
(* a a)
(fma
b
(* (* angle (* b angle)) (* (* PI PI) 3.08641975308642e-5))
(* a a))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 3.2e-9) {
tmp = a * a;
} else {
tmp = fma(b, ((angle * (b * angle)) * ((((double) M_PI) * ((double) M_PI)) * 3.08641975308642e-5)), (a * a));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 3.2e-9) tmp = Float64(a * a); else tmp = fma(b, Float64(Float64(angle * Float64(b * angle)) * Float64(Float64(pi * pi) * 3.08641975308642e-5)), Float64(a * a)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 3.2e-9], N[(a * a), $MachinePrecision], N[(b * N[(N[(angle * N[(b * angle), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.2 \cdot 10^{-9}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, \left(angle \cdot \left(b \cdot angle\right)\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot 3.08641975308642 \cdot 10^{-5}\right), a \cdot a\right)\\
\end{array}
\end{array}
if b < 3.20000000000000012e-9Initial program 76.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6461.0
Applied rewrites61.0%
if 3.20000000000000012e-9 < b Initial program 83.2%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6483.2
Applied rewrites83.2%
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-fma.f64N/A
Applied rewrites61.3%
lift-*.f64N/A
lift-*.f64N/A
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
associate-*l*N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites78.8%
Final simplification66.1%
(FPCore (a b angle)
:precision binary64
(if (<= b 3.2e-9)
(* a a)
(fma
b
(* b (* angle (* angle (* (* PI PI) 3.08641975308642e-5))))
(* a a))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 3.2e-9) {
tmp = a * a;
} else {
tmp = fma(b, (b * (angle * (angle * ((((double) M_PI) * ((double) M_PI)) * 3.08641975308642e-5)))), (a * a));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 3.2e-9) tmp = Float64(a * a); else tmp = fma(b, Float64(b * Float64(angle * Float64(angle * Float64(Float64(pi * pi) * 3.08641975308642e-5)))), Float64(a * a)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 3.2e-9], N[(a * a), $MachinePrecision], N[(b * N[(b * N[(angle * N[(angle * N[(N[(Pi * Pi), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.2 \cdot 10^{-9}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, b \cdot \left(angle \cdot \left(angle \cdot \left(\left(\pi \cdot \pi\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\right), a \cdot a\right)\\
\end{array}
\end{array}
if b < 3.20000000000000012e-9Initial program 76.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6461.0
Applied rewrites61.0%
if 3.20000000000000012e-9 < b Initial program 83.2%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6483.2
Applied rewrites83.2%
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-fma.f64N/A
Applied rewrites61.3%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites72.2%
Final simplification64.2%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* angle (* b PI)))) (if (<= b 7.2e+152) (* a a) (* 3.08641975308642e-5 (* t_0 t_0)))))
double code(double a, double b, double angle) {
double t_0 = angle * (b * ((double) M_PI));
double tmp;
if (b <= 7.2e+152) {
tmp = a * a;
} else {
tmp = 3.08641975308642e-5 * (t_0 * t_0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = angle * (b * Math.PI);
double tmp;
if (b <= 7.2e+152) {
tmp = a * a;
} else {
tmp = 3.08641975308642e-5 * (t_0 * t_0);
}
return tmp;
}
def code(a, b, angle): t_0 = angle * (b * math.pi) tmp = 0 if b <= 7.2e+152: tmp = a * a else: tmp = 3.08641975308642e-5 * (t_0 * t_0) return tmp
function code(a, b, angle) t_0 = Float64(angle * Float64(b * pi)) tmp = 0.0 if (b <= 7.2e+152) tmp = Float64(a * a); else tmp = Float64(3.08641975308642e-5 * Float64(t_0 * t_0)); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = angle * (b * pi); tmp = 0.0; if (b <= 7.2e+152) tmp = a * a; else tmp = 3.08641975308642e-5 * (t_0 * t_0); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(angle * N[(b * Pi), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 7.2e+152], N[(a * a), $MachinePrecision], N[(3.08641975308642e-5 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := angle \cdot \left(b \cdot \pi\right)\\
\mathbf{if}\;b \leq 7.2 \cdot 10^{+152}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;3.08641975308642 \cdot 10^{-5} \cdot \left(t\_0 \cdot t\_0\right)\\
\end{array}
\end{array}
if b < 7.1999999999999998e152Initial program 74.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.8
Applied rewrites57.8%
if 7.1999999999999998e152 < b Initial program 99.8%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6499.8
Applied rewrites99.8%
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-fma.f64N/A
Applied rewrites62.5%
Taylor expanded in b around inf
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f6462.5
Applied rewrites62.5%
Taylor expanded in b around 0
lower-*.f64N/A
unpow2N/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6484.2
Applied rewrites84.2%
Final simplification61.6%
(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 78.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6454.1
Applied rewrites54.1%
herbie shell --seed 2024216
(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)))