
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (/ angle 180.0) PI))) (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * ((double) M_PI);
return pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * Math.PI;
return Math.pow((a * Math.sin(t_0)), 2.0) + Math.pow((b * Math.cos(t_0)), 2.0);
}
def code(a, b, angle): t_0 = (angle / 180.0) * math.pi return math.pow((a * math.sin(t_0)), 2.0) + math.pow((b * math.cos(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(Float64(angle / 180.0) * pi) return Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = (angle / 180.0) * pi; tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[Power[N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (/ angle 180.0) PI))) (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * ((double) M_PI);
return pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * Math.PI;
return Math.pow((a * Math.sin(t_0)), 2.0) + Math.pow((b * Math.cos(t_0)), 2.0);
}
def code(a, b, angle): t_0 = (angle / 180.0) * math.pi return math.pow((a * math.sin(t_0)), 2.0) + math.pow((b * math.cos(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(Float64(angle / 180.0) * pi) return Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = (angle / 180.0) * pi; tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[Power[N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= (/ angle_m 180.0) 2e-5)
(+
(* b b)
(pow
(*
angle_m
(*
a
(*
PI
(fma
(* (* angle_m angle_m) -2.8577960676726107e-8)
(* PI PI)
0.005555555555555556))))
2.0))
(fma
(* a (fma (cos (* PI (* angle_m 0.011111111111111112))) -0.5 0.5))
a
(* b b))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if ((angle_m / 180.0) <= 2e-5) {
tmp = (b * b) + pow((angle_m * (a * (((double) M_PI) * fma(((angle_m * angle_m) * -2.8577960676726107e-8), (((double) M_PI) * ((double) M_PI)), 0.005555555555555556)))), 2.0);
} else {
tmp = fma((a * fma(cos((((double) M_PI) * (angle_m * 0.011111111111111112))), -0.5, 0.5)), a, (b * b));
}
return tmp;
}
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (Float64(angle_m / 180.0) <= 2e-5) tmp = Float64(Float64(b * b) + (Float64(angle_m * Float64(a * Float64(pi * fma(Float64(Float64(angle_m * angle_m) * -2.8577960676726107e-8), Float64(pi * pi), 0.005555555555555556)))) ^ 2.0)); else tmp = fma(Float64(a * fma(cos(Float64(pi * Float64(angle_m * 0.011111111111111112))), -0.5, 0.5)), a, Float64(b * b)); end return tmp end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[N[(angle$95$m / 180.0), $MachinePrecision], 2e-5], N[(N[(b * b), $MachinePrecision] + N[Power[N[(angle$95$m * N[(a * N[(Pi * N[(N[(N[(angle$95$m * angle$95$m), $MachinePrecision] * -2.8577960676726107e-8), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision] + 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[Cos[N[(Pi * N[(angle$95$m * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle\_m}{180} \leq 2 \cdot 10^{-5}:\\
\;\;\;\;b \cdot b + {\left(angle\_m \cdot \left(a \cdot \left(\pi \cdot \mathsf{fma}\left(\left(angle\_m \cdot angle\_m\right) \cdot -2.8577960676726107 \cdot 10^{-8}, \pi \cdot \pi, 0.005555555555555556\right)\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot \mathsf{fma}\left(\cos \left(\pi \cdot \left(angle\_m \cdot 0.011111111111111112\right)\right), -0.5, 0.5\right), a, b \cdot b\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 2.00000000000000016e-5Initial program 88.5%
Taylor expanded in angle around 0
Applied rewrites88.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*r/N/A
metadata-evalN/A
frac-timesN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
lift-/.f64N/A
/-rgt-identityN/A
lower-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
div-invN/A
metadata-evalN/A
lower-*.f6488.4
Applied rewrites88.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6488.4
Applied rewrites88.4%
Taylor expanded in angle around 0
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
+-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
Applied rewrites83.1%
if 2.00000000000000016e-5 < (/.f64 angle #s(literal 180 binary64)) Initial program 61.4%
Taylor expanded in angle around 0
Applied rewrites62.1%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*r/N/A
metadata-evalN/A
frac-timesN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
lift-/.f64N/A
/-rgt-identityN/A
lower-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
div-invN/A
metadata-evalN/A
lower-*.f6462.2
Applied rewrites62.2%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6462.2
Applied rewrites62.2%
Applied rewrites62.2%
Final simplification77.2%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (+ (pow (* a (sin (* (* PI 0.005555555555555556) angle_m))) 2.0) (* b b)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow((a * sin(((((double) M_PI) * 0.005555555555555556) * angle_m))), 2.0) + (b * b);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow((a * Math.sin(((Math.PI * 0.005555555555555556) * angle_m))), 2.0) + (b * b);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow((a * math.sin(((math.pi * 0.005555555555555556) * angle_m))), 2.0) + (b * b)
angle_m = abs(angle) function code(a, b, angle_m) return Float64((Float64(a * sin(Float64(Float64(pi * 0.005555555555555556) * angle_m))) ^ 2.0) + Float64(b * b)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = ((a * sin(((pi * 0.005555555555555556) * angle_m))) ^ 2.0) + (b * b); end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[N[(a * N[Sin[N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * angle$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{\left(a \cdot \sin \left(\left(\pi \cdot 0.005555555555555556\right) \cdot angle\_m\right)\right)}^{2} + b \cdot b
\end{array}
Initial program 80.9%
Taylor expanded in angle around 0
Applied rewrites81.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*r/N/A
metadata-evalN/A
frac-timesN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
lift-/.f64N/A
/-rgt-identityN/A
lower-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
div-invN/A
metadata-evalN/A
lower-*.f6481.1
Applied rewrites81.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6481.1
Applied rewrites81.1%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= (/ angle_m 180.0) 2e-5)
(+ (* b b) (pow (* a (* 0.005555555555555556 (* PI angle_m))) 2.0))
(fma
(* a (fma (cos (* PI (* angle_m 0.011111111111111112))) -0.5 0.5))
a
(* b b))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if ((angle_m / 180.0) <= 2e-5) {
tmp = (b * b) + pow((a * (0.005555555555555556 * (((double) M_PI) * angle_m))), 2.0);
} else {
tmp = fma((a * fma(cos((((double) M_PI) * (angle_m * 0.011111111111111112))), -0.5, 0.5)), a, (b * b));
}
return tmp;
}
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (Float64(angle_m / 180.0) <= 2e-5) tmp = Float64(Float64(b * b) + (Float64(a * Float64(0.005555555555555556 * Float64(pi * angle_m))) ^ 2.0)); else tmp = fma(Float64(a * fma(cos(Float64(pi * Float64(angle_m * 0.011111111111111112))), -0.5, 0.5)), a, Float64(b * b)); end return tmp end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[N[(angle$95$m / 180.0), $MachinePrecision], 2e-5], N[(N[(b * b), $MachinePrecision] + N[Power[N[(a * N[(0.005555555555555556 * N[(Pi * angle$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[Cos[N[(Pi * N[(angle$95$m * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle\_m}{180} \leq 2 \cdot 10^{-5}:\\
\;\;\;\;b \cdot b + {\left(a \cdot \left(0.005555555555555556 \cdot \left(\pi \cdot angle\_m\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot \mathsf{fma}\left(\cos \left(\pi \cdot \left(angle\_m \cdot 0.011111111111111112\right)\right), -0.5, 0.5\right), a, b \cdot b\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 2.00000000000000016e-5Initial program 88.5%
Taylor expanded in angle around 0
Applied rewrites88.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*r/N/A
metadata-evalN/A
frac-timesN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
lift-/.f64N/A
/-rgt-identityN/A
lower-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
div-invN/A
metadata-evalN/A
lower-*.f6488.4
Applied rewrites88.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6488.4
Applied rewrites88.4%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6484.1
Applied rewrites84.1%
if 2.00000000000000016e-5 < (/.f64 angle #s(literal 180 binary64)) Initial program 61.4%
Taylor expanded in angle around 0
Applied rewrites62.1%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*r/N/A
metadata-evalN/A
frac-timesN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
lift-/.f64N/A
/-rgt-identityN/A
lower-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
div-invN/A
metadata-evalN/A
lower-*.f6462.2
Applied rewrites62.2%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6462.2
Applied rewrites62.2%
Applied rewrites62.2%
Final simplification77.9%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (if (<= a 8.2e-133) (* (* b b) (fma 0.5 (cos (* PI (* angle_m 0.011111111111111112))) 0.5)) (+ (* b b) (pow (* a (* 0.005555555555555556 (* PI angle_m))) 2.0))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (a <= 8.2e-133) {
tmp = (b * b) * fma(0.5, cos((((double) M_PI) * (angle_m * 0.011111111111111112))), 0.5);
} else {
tmp = (b * b) + pow((a * (0.005555555555555556 * (((double) M_PI) * angle_m))), 2.0);
}
return tmp;
}
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (a <= 8.2e-133) tmp = Float64(Float64(b * b) * fma(0.5, cos(Float64(pi * Float64(angle_m * 0.011111111111111112))), 0.5)); else tmp = Float64(Float64(b * b) + (Float64(a * Float64(0.005555555555555556 * Float64(pi * angle_m))) ^ 2.0)); end return tmp end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[a, 8.2e-133], N[(N[(b * b), $MachinePrecision] * N[(0.5 * N[Cos[N[(Pi * N[(angle$95$m * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(b * b), $MachinePrecision] + N[Power[N[(a * N[(0.005555555555555556 * N[(Pi * angle$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 8.2 \cdot 10^{-133}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \mathsf{fma}\left(0.5, \cos \left(\pi \cdot \left(angle\_m \cdot 0.011111111111111112\right)\right), 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot b + {\left(a \cdot \left(0.005555555555555556 \cdot \left(\pi \cdot angle\_m\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 8.20000000000000045e-133Initial program 79.5%
Applied rewrites38.5%
Taylor expanded in b around inf
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-*.f6458.3
Applied rewrites58.3%
if 8.20000000000000045e-133 < a Initial program 83.2%
Taylor expanded in angle around 0
Applied rewrites83.3%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*r/N/A
metadata-evalN/A
frac-timesN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
lift-/.f64N/A
/-rgt-identityN/A
lower-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
div-invN/A
metadata-evalN/A
lower-*.f6483.4
Applied rewrites83.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6483.4
Applied rewrites83.4%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6480.6
Applied rewrites80.6%
Final simplification66.6%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (if (<= a 1.9e-17) (* b b) (+ (* b b) (pow (* a (* 0.005555555555555556 (* PI angle_m))) 2.0))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (a <= 1.9e-17) {
tmp = b * b;
} else {
tmp = (b * b) + pow((a * (0.005555555555555556 * (((double) M_PI) * angle_m))), 2.0);
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (a <= 1.9e-17) {
tmp = b * b;
} else {
tmp = (b * b) + Math.pow((a * (0.005555555555555556 * (Math.PI * angle_m))), 2.0);
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if a <= 1.9e-17: tmp = b * b else: tmp = (b * b) + math.pow((a * (0.005555555555555556 * (math.pi * angle_m))), 2.0) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (a <= 1.9e-17) tmp = Float64(b * b); else tmp = Float64(Float64(b * b) + (Float64(a * Float64(0.005555555555555556 * Float64(pi * angle_m))) ^ 2.0)); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (a <= 1.9e-17) tmp = b * b; else tmp = (b * b) + ((a * (0.005555555555555556 * (pi * angle_m))) ^ 2.0); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[a, 1.9e-17], N[(b * b), $MachinePrecision], N[(N[(b * b), $MachinePrecision] + N[Power[N[(a * N[(0.005555555555555556 * N[(Pi * angle$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.9 \cdot 10^{-17}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;b \cdot b + {\left(a \cdot \left(0.005555555555555556 \cdot \left(\pi \cdot angle\_m\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 1.9000000000000001e-17Initial program 77.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6458.5
Applied rewrites58.5%
if 1.9000000000000001e-17 < a Initial program 88.4%
Taylor expanded in angle around 0
Applied rewrites88.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*r/N/A
metadata-evalN/A
frac-timesN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
lift-/.f64N/A
/-rgt-identityN/A
lower-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
div-invN/A
metadata-evalN/A
lower-*.f6488.5
Applied rewrites88.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6488.5
Applied rewrites88.5%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6486.7
Applied rewrites86.7%
Final simplification66.6%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (if (<= a 1.9e-17) (* b b) (+ (* b b) (pow (* 0.005555555555555556 (* a (* PI angle_m))) 2.0))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (a <= 1.9e-17) {
tmp = b * b;
} else {
tmp = (b * b) + pow((0.005555555555555556 * (a * (((double) M_PI) * angle_m))), 2.0);
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (a <= 1.9e-17) {
tmp = b * b;
} else {
tmp = (b * b) + Math.pow((0.005555555555555556 * (a * (Math.PI * angle_m))), 2.0);
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if a <= 1.9e-17: tmp = b * b else: tmp = (b * b) + math.pow((0.005555555555555556 * (a * (math.pi * angle_m))), 2.0) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (a <= 1.9e-17) tmp = Float64(b * b); else tmp = Float64(Float64(b * b) + (Float64(0.005555555555555556 * Float64(a * Float64(pi * angle_m))) ^ 2.0)); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (a <= 1.9e-17) tmp = b * b; else tmp = (b * b) + ((0.005555555555555556 * (a * (pi * angle_m))) ^ 2.0); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[a, 1.9e-17], N[(b * b), $MachinePrecision], N[(N[(b * b), $MachinePrecision] + N[Power[N[(0.005555555555555556 * N[(a * N[(Pi * angle$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.9 \cdot 10^{-17}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;b \cdot b + {\left(0.005555555555555556 \cdot \left(a \cdot \left(\pi \cdot angle\_m\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 1.9000000000000001e-17Initial program 77.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6458.5
Applied rewrites58.5%
if 1.9000000000000001e-17 < a Initial program 88.4%
Taylor expanded in angle around 0
Applied rewrites88.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*r/N/A
metadata-evalN/A
frac-timesN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
lift-/.f64N/A
/-rgt-identityN/A
lower-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
div-invN/A
metadata-evalN/A
lower-*.f6488.5
Applied rewrites88.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6488.5
Applied rewrites88.5%
Taylor expanded in angle around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6486.6
Applied rewrites86.6%
Final simplification66.6%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= b 1.85e+117)
(fma
(*
(* angle_m (* PI PI))
(fma b (* b -3.08641975308642e-5) (* a (* a 3.08641975308642e-5))))
angle_m
(* b b))
(* b b)))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (b <= 1.85e+117) {
tmp = fma(((angle_m * (((double) M_PI) * ((double) M_PI))) * fma(b, (b * -3.08641975308642e-5), (a * (a * 3.08641975308642e-5)))), angle_m, (b * b));
} else {
tmp = b * b;
}
return tmp;
}
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (b <= 1.85e+117) tmp = fma(Float64(Float64(angle_m * Float64(pi * pi)) * fma(b, Float64(b * -3.08641975308642e-5), Float64(a * Float64(a * 3.08641975308642e-5)))), angle_m, Float64(b * b)); else tmp = Float64(b * b); end return tmp end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[b, 1.85e+117], N[(N[(N[(angle$95$m * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * N[(b * N[(b * -3.08641975308642e-5), $MachinePrecision] + N[(a * N[(a * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * angle$95$m + N[(b * b), $MachinePrecision]), $MachinePrecision], N[(b * b), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.85 \cdot 10^{+117}:\\
\;\;\;\;\mathsf{fma}\left(\left(angle\_m \cdot \left(\pi \cdot \pi\right)\right) \cdot \mathsf{fma}\left(b, b \cdot -3.08641975308642 \cdot 10^{-5}, a \cdot \left(a \cdot 3.08641975308642 \cdot 10^{-5}\right)\right), angle\_m, b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot b\\
\end{array}
\end{array}
if b < 1.8499999999999999e117Initial program 77.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6477.7
Applied rewrites77.7%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites44.8%
Applied rewrites50.7%
if 1.8499999999999999e117 < b Initial program 96.2%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6494.1
Applied rewrites94.1%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= a 1.9e-17)
(* b b)
(if (<= a 1.12e+173)
(fma
(* angle_m (* angle_m (* PI PI)))
(* 3.08641975308642e-5 (* a a))
(* b b))
(* a (* (* a 3.08641975308642e-5) (* PI (* PI (* angle_m angle_m))))))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (a <= 1.9e-17) {
tmp = b * b;
} else if (a <= 1.12e+173) {
tmp = fma((angle_m * (angle_m * (((double) M_PI) * ((double) M_PI)))), (3.08641975308642e-5 * (a * a)), (b * b));
} else {
tmp = a * ((a * 3.08641975308642e-5) * (((double) M_PI) * (((double) M_PI) * (angle_m * angle_m))));
}
return tmp;
}
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (a <= 1.9e-17) tmp = Float64(b * b); elseif (a <= 1.12e+173) tmp = fma(Float64(angle_m * Float64(angle_m * Float64(pi * pi))), Float64(3.08641975308642e-5 * Float64(a * a)), Float64(b * b)); else tmp = Float64(a * Float64(Float64(a * 3.08641975308642e-5) * Float64(pi * Float64(pi * Float64(angle_m * angle_m))))); end return tmp end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[a, 1.9e-17], N[(b * b), $MachinePrecision], If[LessEqual[a, 1.12e+173], N[(N[(angle$95$m * N[(angle$95$m * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], N[(a * N[(N[(a * 3.08641975308642e-5), $MachinePrecision] * N[(Pi * N[(Pi * N[(angle$95$m * angle$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.9 \cdot 10^{-17}:\\
\;\;\;\;b \cdot b\\
\mathbf{elif}\;a \leq 1.12 \cdot 10^{+173}:\\
\;\;\;\;\mathsf{fma}\left(angle\_m \cdot \left(angle\_m \cdot \left(\pi \cdot \pi\right)\right), 3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right), b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(\left(a \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \left(\pi \cdot \left(\pi \cdot \left(angle\_m \cdot angle\_m\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.9000000000000001e-17Initial program 77.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6458.5
Applied rewrites58.5%
if 1.9000000000000001e-17 < a < 1.12e173Initial program 76.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6476.1
Applied rewrites76.1%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites32.7%
Taylor expanded in b around 0
Applied rewrites72.7%
if 1.12e173 < a Initial program 99.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites45.6%
Taylor expanded in b around 0
Applied rewrites56.2%
Applied rewrites71.6%
Final simplification62.4%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (if (<= a 1.3e+159) (* b b) (* a (* (* a 3.08641975308642e-5) (* PI (* PI (* angle_m angle_m)))))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (a <= 1.3e+159) {
tmp = b * b;
} else {
tmp = a * ((a * 3.08641975308642e-5) * (((double) M_PI) * (((double) M_PI) * (angle_m * angle_m))));
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (a <= 1.3e+159) {
tmp = b * b;
} else {
tmp = a * ((a * 3.08641975308642e-5) * (Math.PI * (Math.PI * (angle_m * angle_m))));
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if a <= 1.3e+159: tmp = b * b else: tmp = a * ((a * 3.08641975308642e-5) * (math.pi * (math.pi * (angle_m * angle_m)))) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (a <= 1.3e+159) tmp = Float64(b * b); else tmp = Float64(a * Float64(Float64(a * 3.08641975308642e-5) * Float64(pi * Float64(pi * Float64(angle_m * angle_m))))); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (a <= 1.3e+159) tmp = b * b; else tmp = a * ((a * 3.08641975308642e-5) * (pi * (pi * (angle_m * angle_m)))); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[a, 1.3e+159], N[(b * b), $MachinePrecision], N[(a * N[(N[(a * 3.08641975308642e-5), $MachinePrecision] * N[(Pi * N[(Pi * N[(angle$95$m * angle$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.3 \cdot 10^{+159}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(\left(a \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \left(\pi \cdot \left(\pi \cdot \left(angle\_m \cdot angle\_m\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.3e159Initial program 77.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6459.1
Applied rewrites59.1%
if 1.3e159 < a Initial program 99.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in angle around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
Applied rewrites45.9%
Taylor expanded in b around 0
Applied rewrites58.4%
Applied rewrites70.6%
Final simplification60.9%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (* b b))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return b * b;
}
angle_m = abs(angle)
real(8) function code(a, b, angle_m)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle_m
code = b * b
end function
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return b * b;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return b * b
angle_m = abs(angle) function code(a, b, angle_m) return Float64(b * b) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = b * b; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(b * b), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
b \cdot b
\end{array}
Initial program 80.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6454.1
Applied rewrites54.1%
herbie shell --seed 2024219
(FPCore (a b angle)
:name "ab-angle->ABCF A"
:precision binary64
(+ (pow (* a (sin (* (/ angle 180.0) PI))) 2.0) (pow (* b (cos (* (/ angle 180.0) PI))) 2.0)))