
(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
(+
(pow
(*
a
(sin (* (sqrt angle_m) (* (* PI 0.005555555555555556) (sqrt angle_m)))))
2.0)
(pow b 2.0)))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow((a * sin((sqrt(angle_m) * ((((double) M_PI) * 0.005555555555555556) * sqrt(angle_m))))), 2.0) + pow(b, 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow((a * Math.sin((Math.sqrt(angle_m) * ((Math.PI * 0.005555555555555556) * Math.sqrt(angle_m))))), 2.0) + Math.pow(b, 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow((a * math.sin((math.sqrt(angle_m) * ((math.pi * 0.005555555555555556) * math.sqrt(angle_m))))), 2.0) + math.pow(b, 2.0)
angle_m = abs(angle) function code(a, b, angle_m) return Float64((Float64(a * sin(Float64(sqrt(angle_m) * Float64(Float64(pi * 0.005555555555555556) * sqrt(angle_m))))) ^ 2.0) + (b ^ 2.0)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = ((a * sin((sqrt(angle_m) * ((pi * 0.005555555555555556) * sqrt(angle_m))))) ^ 2.0) + (b ^ 2.0); end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[N[(a * N[Sin[N[(N[Sqrt[angle$95$m], $MachinePrecision] * N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * N[Sqrt[angle$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{\left(a \cdot \sin \left(\sqrt{angle\_m} \cdot \left(\left(\pi \cdot 0.005555555555555556\right) \cdot \sqrt{angle\_m}\right)\right)\right)}^{2} + {b}^{2}
\end{array}
Initial program 76.3%
unpow276.3%
*-commutative76.3%
associate-*r/75.9%
associate-/l*76.3%
unpow276.3%
*-commutative76.3%
associate-*r/75.9%
associate-/l*76.4%
Simplified76.4%
associate-/r/76.4%
add-sqr-sqrt39.0%
associate-*r*39.0%
div-inv39.0%
metadata-eval39.0%
Applied egg-rr39.0%
Taylor expanded in angle around 0 39.4%
Final simplification39.4%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (+ (pow (* a (log1p (expm1 (sin (* (* PI 0.005555555555555556) angle_m))))) 2.0) (pow b 2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow((a * log1p(expm1(sin(((((double) M_PI) * 0.005555555555555556) * angle_m))))), 2.0) + pow(b, 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow((a * Math.log1p(Math.expm1(Math.sin(((Math.PI * 0.005555555555555556) * angle_m))))), 2.0) + Math.pow(b, 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow((a * math.log1p(math.expm1(math.sin(((math.pi * 0.005555555555555556) * angle_m))))), 2.0) + math.pow(b, 2.0)
angle_m = abs(angle) function code(a, b, angle_m) return Float64((Float64(a * log1p(expm1(sin(Float64(Float64(pi * 0.005555555555555556) * angle_m))))) ^ 2.0) + (b ^ 2.0)) end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[N[(a * N[Log[1 + N[(Exp[N[Sin[N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * angle$95$m), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{\left(a \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin \left(\left(\pi \cdot 0.005555555555555556\right) \cdot angle\_m\right)\right)\right)\right)}^{2} + {b}^{2}
\end{array}
Initial program 76.3%
unpow276.3%
swap-sqr76.3%
*-commutative76.3%
associate-*r/75.9%
associate-*l/76.4%
*-commutative76.4%
swap-sqr76.4%
unpow276.4%
*-commutative76.4%
associate-*r/76.0%
associate-*l/76.4%
*-commutative76.4%
Simplified76.4%
Taylor expanded in angle around 0 76.5%
log1p-expm1-u76.5%
div-inv76.5%
metadata-eval76.5%
Applied egg-rr76.5%
Final simplification76.5%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (+ (pow (* a (sin (* angle_m (/ PI 180.0)))) 2.0) (pow b 2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow((a * sin((angle_m * (((double) M_PI) / 180.0)))), 2.0) + pow(b, 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow((a * Math.sin((angle_m * (Math.PI / 180.0)))), 2.0) + Math.pow(b, 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow((a * math.sin((angle_m * (math.pi / 180.0)))), 2.0) + math.pow(b, 2.0)
angle_m = abs(angle) function code(a, b, angle_m) return Float64((Float64(a * sin(Float64(angle_m * Float64(pi / 180.0)))) ^ 2.0) + (b ^ 2.0)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = ((a * sin((angle_m * (pi / 180.0)))) ^ 2.0) + (b ^ 2.0); end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[N[(a * N[Sin[N[(angle$95$m * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{\left(a \cdot \sin \left(angle\_m \cdot \frac{\pi}{180}\right)\right)}^{2} + {b}^{2}
\end{array}
Initial program 76.3%
unpow276.3%
swap-sqr76.3%
*-commutative76.3%
associate-*r/75.9%
associate-*l/76.4%
*-commutative76.4%
swap-sqr76.4%
unpow276.4%
*-commutative76.4%
associate-*r/76.0%
associate-*l/76.4%
*-commutative76.4%
Simplified76.4%
Taylor expanded in angle around 0 69.1%
associate-*r*69.1%
Simplified69.1%
Taylor expanded in angle around 0 76.5%
Final simplification76.5%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= a 4.1e-128)
(pow b 2.0)
(+
(pow (* b (cos (* angle_m (/ PI 180.0)))) 2.0)
(*
(* PI 0.005555555555555556)
(* (* angle_m (* a (* PI 0.005555555555555556))) (* a angle_m))))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (a <= 4.1e-128) {
tmp = pow(b, 2.0);
} else {
tmp = pow((b * cos((angle_m * (((double) M_PI) / 180.0)))), 2.0) + ((((double) M_PI) * 0.005555555555555556) * ((angle_m * (a * (((double) M_PI) * 0.005555555555555556))) * (a * angle_m)));
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (a <= 4.1e-128) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow((b * Math.cos((angle_m * (Math.PI / 180.0)))), 2.0) + ((Math.PI * 0.005555555555555556) * ((angle_m * (a * (Math.PI * 0.005555555555555556))) * (a * angle_m)));
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if a <= 4.1e-128: tmp = math.pow(b, 2.0) else: tmp = math.pow((b * math.cos((angle_m * (math.pi / 180.0)))), 2.0) + ((math.pi * 0.005555555555555556) * ((angle_m * (a * (math.pi * 0.005555555555555556))) * (a * angle_m))) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (a <= 4.1e-128) tmp = b ^ 2.0; else tmp = Float64((Float64(b * cos(Float64(angle_m * Float64(pi / 180.0)))) ^ 2.0) + Float64(Float64(pi * 0.005555555555555556) * Float64(Float64(angle_m * Float64(a * Float64(pi * 0.005555555555555556))) * Float64(a * angle_m)))); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (a <= 4.1e-128) tmp = b ^ 2.0; else tmp = ((b * cos((angle_m * (pi / 180.0)))) ^ 2.0) + ((pi * 0.005555555555555556) * ((angle_m * (a * (pi * 0.005555555555555556))) * (a * angle_m))); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[a, 4.1e-128], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[N[(b * N[Cos[N[(angle$95$m * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * N[(N[(angle$95$m * N[(a * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * angle$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 4.1 \cdot 10^{-128}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{\left(b \cdot \cos \left(angle\_m \cdot \frac{\pi}{180}\right)\right)}^{2} + \left(\pi \cdot 0.005555555555555556\right) \cdot \left(\left(angle\_m \cdot \left(a \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right) \cdot \left(a \cdot angle\_m\right)\right)\\
\end{array}
\end{array}
if a < 4.1e-128Initial program 76.1%
unpow276.1%
swap-sqr76.1%
*-commutative76.1%
associate-*r/75.6%
associate-*l/76.2%
*-commutative76.2%
swap-sqr76.1%
unpow276.1%
*-commutative76.1%
associate-*r/75.6%
associate-*l/76.3%
*-commutative76.3%
Simplified76.3%
Taylor expanded in angle around 0 68.3%
*-commutative68.3%
associate-*r*68.3%
associate-*l*68.3%
*-commutative68.3%
*-commutative68.3%
Simplified68.3%
Taylor expanded in angle around 0 67.9%
Taylor expanded in angle around 0 58.3%
if 4.1e-128 < a Initial program 76.6%
unpow276.6%
swap-sqr76.6%
*-commutative76.6%
associate-*r/76.6%
associate-*l/76.8%
*-commutative76.8%
swap-sqr76.8%
unpow276.8%
*-commutative76.8%
associate-*r/76.8%
associate-*l/76.8%
*-commutative76.8%
Simplified76.8%
Taylor expanded in angle around 0 71.4%
*-commutative71.4%
associate-*r*71.4%
associate-*l*71.4%
*-commutative71.4%
*-commutative71.4%
Simplified71.4%
unpow271.4%
*-commutative71.4%
metadata-eval71.4%
div-inv71.4%
associate-*r*71.5%
associate-*l*71.4%
*-commutative71.4%
div-inv71.4%
metadata-eval71.4%
Applied egg-rr71.4%
Final simplification62.5%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= a 1.1e-128)
(pow b 2.0)
(+
(*
(*
(* PI 0.005555555555555556)
(* angle_m (* a (* PI 0.005555555555555556))))
(* a angle_m))
(pow (* b (cos (* angle_m (/ PI 180.0)))) 2.0))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (a <= 1.1e-128) {
tmp = pow(b, 2.0);
} else {
tmp = (((((double) M_PI) * 0.005555555555555556) * (angle_m * (a * (((double) M_PI) * 0.005555555555555556)))) * (a * angle_m)) + pow((b * cos((angle_m * (((double) M_PI) / 180.0)))), 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.1e-128) {
tmp = Math.pow(b, 2.0);
} else {
tmp = (((Math.PI * 0.005555555555555556) * (angle_m * (a * (Math.PI * 0.005555555555555556)))) * (a * angle_m)) + Math.pow((b * Math.cos((angle_m * (Math.PI / 180.0)))), 2.0);
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if a <= 1.1e-128: tmp = math.pow(b, 2.0) else: tmp = (((math.pi * 0.005555555555555556) * (angle_m * (a * (math.pi * 0.005555555555555556)))) * (a * angle_m)) + math.pow((b * math.cos((angle_m * (math.pi / 180.0)))), 2.0) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (a <= 1.1e-128) tmp = b ^ 2.0; else tmp = Float64(Float64(Float64(Float64(pi * 0.005555555555555556) * Float64(angle_m * Float64(a * Float64(pi * 0.005555555555555556)))) * Float64(a * angle_m)) + (Float64(b * cos(Float64(angle_m * Float64(pi / 180.0)))) ^ 2.0)); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (a <= 1.1e-128) tmp = b ^ 2.0; else tmp = (((pi * 0.005555555555555556) * (angle_m * (a * (pi * 0.005555555555555556)))) * (a * angle_m)) + ((b * cos((angle_m * (pi / 180.0)))) ^ 2.0); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[a, 1.1e-128], N[Power[b, 2.0], $MachinePrecision], N[(N[(N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * N[(angle$95$m * N[(a * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * angle$95$m), $MachinePrecision]), $MachinePrecision] + N[Power[N[(b * N[Cos[N[(angle$95$m * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.1 \cdot 10^{-128}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\pi \cdot 0.005555555555555556\right) \cdot \left(angle\_m \cdot \left(a \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right) \cdot \left(a \cdot angle\_m\right) + {\left(b \cdot \cos \left(angle\_m \cdot \frac{\pi}{180}\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 1.10000000000000005e-128Initial program 76.1%
unpow276.1%
swap-sqr76.1%
*-commutative76.1%
associate-*r/75.6%
associate-*l/76.2%
*-commutative76.2%
swap-sqr76.1%
unpow276.1%
*-commutative76.1%
associate-*r/75.6%
associate-*l/76.3%
*-commutative76.3%
Simplified76.3%
Taylor expanded in angle around 0 68.3%
*-commutative68.3%
associate-*r*68.3%
associate-*l*68.3%
*-commutative68.3%
*-commutative68.3%
Simplified68.3%
Taylor expanded in angle around 0 67.9%
Taylor expanded in angle around 0 58.3%
if 1.10000000000000005e-128 < a Initial program 76.6%
unpow276.6%
swap-sqr76.6%
*-commutative76.6%
associate-*r/76.6%
associate-*l/76.8%
*-commutative76.8%
swap-sqr76.8%
unpow276.8%
*-commutative76.8%
associate-*r/76.8%
associate-*l/76.8%
*-commutative76.8%
Simplified76.8%
Taylor expanded in angle around 0 71.4%
*-commutative71.4%
associate-*r*71.4%
associate-*l*71.4%
*-commutative71.4%
*-commutative71.4%
Simplified71.4%
unpow271.5%
*-commutative71.5%
metadata-eval71.5%
div-inv71.5%
*-commutative71.5%
associate-*r*71.5%
associate-*l*71.5%
*-commutative71.5%
div-inv71.5%
metadata-eval71.5%
Applied egg-rr71.4%
Final simplification62.5%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= a 2e-64)
(pow b 2.0)
(+
(pow b 2.0)
(*
angle_m
(*
(* a 0.005555555555555556)
(* PI (* (* PI 0.005555555555555556) (* a angle_m))))))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (a <= 2e-64) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + (angle_m * ((a * 0.005555555555555556) * (((double) M_PI) * ((((double) M_PI) * 0.005555555555555556) * (a * angle_m)))));
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (a <= 2e-64) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + (angle_m * ((a * 0.005555555555555556) * (Math.PI * ((Math.PI * 0.005555555555555556) * (a * angle_m)))));
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if a <= 2e-64: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + (angle_m * ((a * 0.005555555555555556) * (math.pi * ((math.pi * 0.005555555555555556) * (a * angle_m))))) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (a <= 2e-64) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(angle_m * Float64(Float64(a * 0.005555555555555556) * Float64(pi * Float64(Float64(pi * 0.005555555555555556) * Float64(a * angle_m)))))); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (a <= 2e-64) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + (angle_m * ((a * 0.005555555555555556) * (pi * ((pi * 0.005555555555555556) * (a * angle_m))))); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[a, 2e-64], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(angle$95$m * N[(N[(a * 0.005555555555555556), $MachinePrecision] * N[(Pi * N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * N[(a * angle$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2 \cdot 10^{-64}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + angle\_m \cdot \left(\left(a \cdot 0.005555555555555556\right) \cdot \left(\pi \cdot \left(\left(\pi \cdot 0.005555555555555556\right) \cdot \left(a \cdot angle\_m\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.99999999999999993e-64Initial program 75.6%
unpow275.6%
swap-sqr75.6%
*-commutative75.6%
associate-*r/75.2%
associate-*l/75.7%
*-commutative75.7%
swap-sqr75.7%
unpow275.7%
*-commutative75.7%
associate-*r/75.2%
associate-*l/75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in angle around 0 67.6%
*-commutative67.6%
associate-*r*67.6%
associate-*l*67.6%
*-commutative67.6%
*-commutative67.6%
Simplified67.6%
Taylor expanded in angle around 0 67.2%
Taylor expanded in angle around 0 58.3%
if 1.99999999999999993e-64 < a Initial program 77.9%
unpow277.9%
swap-sqr77.9%
*-commutative77.9%
associate-*r/77.9%
associate-*l/78.1%
*-commutative78.1%
swap-sqr78.1%
unpow278.1%
*-commutative78.1%
associate-*r/78.1%
associate-*l/78.1%
*-commutative78.1%
Simplified78.1%
Taylor expanded in angle around 0 73.6%
*-commutative73.6%
associate-*r*73.6%
associate-*l*73.7%
*-commutative73.7%
*-commutative73.7%
Simplified73.7%
Taylor expanded in angle around 0 73.8%
unpow273.8%
associate-*r*73.7%
associate-*l*73.8%
associate-*l*73.7%
associate-*l*73.7%
*-commutative73.7%
Applied egg-rr73.7%
associate-*l*69.9%
*-commutative69.9%
associate-*r*69.9%
*-commutative69.9%
*-commutative69.9%
Simplified69.9%
Final simplification61.5%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(let* ((t_0 (* a (* PI 0.005555555555555556))))
(if (<= a 5.3e-64)
(pow b 2.0)
(+ (pow b 2.0) (* t_0 (* angle_m (* angle_m t_0)))))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double t_0 = a * (((double) M_PI) * 0.005555555555555556);
double tmp;
if (a <= 5.3e-64) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + (t_0 * (angle_m * (angle_m * t_0)));
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double t_0 = a * (Math.PI * 0.005555555555555556);
double tmp;
if (a <= 5.3e-64) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + (t_0 * (angle_m * (angle_m * t_0)));
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): t_0 = a * (math.pi * 0.005555555555555556) tmp = 0 if a <= 5.3e-64: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + (t_0 * (angle_m * (angle_m * t_0))) return tmp
angle_m = abs(angle) function code(a, b, angle_m) t_0 = Float64(a * Float64(pi * 0.005555555555555556)) tmp = 0.0 if (a <= 5.3e-64) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(t_0 * Float64(angle_m * Float64(angle_m * t_0)))); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) t_0 = a * (pi * 0.005555555555555556); tmp = 0.0; if (a <= 5.3e-64) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + (t_0 * (angle_m * (angle_m * t_0))); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := Block[{t$95$0 = N[(a * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, 5.3e-64], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(t$95$0 * N[(angle$95$m * N[(angle$95$m * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
t_0 := a \cdot \left(\pi \cdot 0.005555555555555556\right)\\
\mathbf{if}\;a \leq 5.3 \cdot 10^{-64}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + t\_0 \cdot \left(angle\_m \cdot \left(angle\_m \cdot t\_0\right)\right)\\
\end{array}
\end{array}
if a < 5.3000000000000002e-64Initial program 75.6%
unpow275.6%
swap-sqr75.6%
*-commutative75.6%
associate-*r/75.2%
associate-*l/75.7%
*-commutative75.7%
swap-sqr75.7%
unpow275.7%
*-commutative75.7%
associate-*r/75.2%
associate-*l/75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in angle around 0 67.6%
*-commutative67.6%
associate-*r*67.6%
associate-*l*67.6%
*-commutative67.6%
*-commutative67.6%
Simplified67.6%
Taylor expanded in angle around 0 67.2%
Taylor expanded in angle around 0 58.3%
if 5.3000000000000002e-64 < a Initial program 77.9%
unpow277.9%
swap-sqr77.9%
*-commutative77.9%
associate-*r/77.9%
associate-*l/78.1%
*-commutative78.1%
swap-sqr78.1%
unpow278.1%
*-commutative78.1%
associate-*r/78.1%
associate-*l/78.1%
*-commutative78.1%
Simplified78.1%
Taylor expanded in angle around 0 73.6%
*-commutative73.6%
associate-*r*73.6%
associate-*l*73.7%
*-commutative73.7%
*-commutative73.7%
Simplified73.7%
Taylor expanded in angle around 0 73.8%
unpow273.8%
associate-*l*73.7%
associate-*r*72.4%
associate-*l*72.4%
*-commutative72.4%
*-commutative72.4%
Applied egg-rr72.4%
Final simplification62.2%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= a 3.8e-64)
(pow b 2.0)
(+
(pow b 2.0)
(*
PI
(*
(* angle_m (* a (* PI 0.005555555555555556)))
(* angle_m (* a 0.005555555555555556)))))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (a <= 3.8e-64) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + (((double) M_PI) * ((angle_m * (a * (((double) M_PI) * 0.005555555555555556))) * (angle_m * (a * 0.005555555555555556))));
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (a <= 3.8e-64) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + (Math.PI * ((angle_m * (a * (Math.PI * 0.005555555555555556))) * (angle_m * (a * 0.005555555555555556))));
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if a <= 3.8e-64: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + (math.pi * ((angle_m * (a * (math.pi * 0.005555555555555556))) * (angle_m * (a * 0.005555555555555556)))) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (a <= 3.8e-64) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(pi * Float64(Float64(angle_m * Float64(a * Float64(pi * 0.005555555555555556))) * Float64(angle_m * Float64(a * 0.005555555555555556))))); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (a <= 3.8e-64) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + (pi * ((angle_m * (a * (pi * 0.005555555555555556))) * (angle_m * (a * 0.005555555555555556)))); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[a, 3.8e-64], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(Pi * N[(N[(angle$95$m * N[(a * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(angle$95$m * N[(a * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.8 \cdot 10^{-64}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + \pi \cdot \left(\left(angle\_m \cdot \left(a \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right) \cdot \left(angle\_m \cdot \left(a \cdot 0.005555555555555556\right)\right)\right)\\
\end{array}
\end{array}
if a < 3.8000000000000002e-64Initial program 75.6%
unpow275.6%
swap-sqr75.6%
*-commutative75.6%
associate-*r/75.2%
associate-*l/75.7%
*-commutative75.7%
swap-sqr75.7%
unpow275.7%
*-commutative75.7%
associate-*r/75.2%
associate-*l/75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in angle around 0 67.6%
*-commutative67.6%
associate-*r*67.6%
associate-*l*67.6%
*-commutative67.6%
*-commutative67.6%
Simplified67.6%
Taylor expanded in angle around 0 67.2%
Taylor expanded in angle around 0 58.3%
if 3.8000000000000002e-64 < a Initial program 77.9%
unpow277.9%
swap-sqr77.9%
*-commutative77.9%
associate-*r/77.9%
associate-*l/78.1%
*-commutative78.1%
swap-sqr78.1%
unpow278.1%
*-commutative78.1%
associate-*r/78.1%
associate-*l/78.1%
*-commutative78.1%
Simplified78.1%
Taylor expanded in angle around 0 73.6%
*-commutative73.6%
associate-*r*73.6%
associate-*l*73.7%
*-commutative73.7%
*-commutative73.7%
Simplified73.7%
Taylor expanded in angle around 0 73.8%
unpow273.8%
associate-*r*73.7%
associate-*r*73.7%
associate-*l*73.7%
*-commutative73.7%
associate-*l*73.7%
Applied egg-rr73.7%
Final simplification62.5%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= a 1.18e-64)
(pow b 2.0)
(+
(pow b 2.0)
(*
(*
(* PI 0.005555555555555556)
(* angle_m (* a (* PI 0.005555555555555556))))
(* a angle_m)))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (a <= 1.18e-64) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + (((((double) M_PI) * 0.005555555555555556) * (angle_m * (a * (((double) M_PI) * 0.005555555555555556)))) * (a * 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.18e-64) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + (((Math.PI * 0.005555555555555556) * (angle_m * (a * (Math.PI * 0.005555555555555556)))) * (a * angle_m));
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if a <= 1.18e-64: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + (((math.pi * 0.005555555555555556) * (angle_m * (a * (math.pi * 0.005555555555555556)))) * (a * angle_m)) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (a <= 1.18e-64) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(Float64(Float64(pi * 0.005555555555555556) * Float64(angle_m * Float64(a * Float64(pi * 0.005555555555555556)))) * Float64(a * angle_m))); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (a <= 1.18e-64) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + (((pi * 0.005555555555555556) * (angle_m * (a * (pi * 0.005555555555555556)))) * (a * angle_m)); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[a, 1.18e-64], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * N[(angle$95$m * N[(a * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * angle$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.18 \cdot 10^{-64}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + \left(\left(\pi \cdot 0.005555555555555556\right) \cdot \left(angle\_m \cdot \left(a \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right) \cdot \left(a \cdot angle\_m\right)\\
\end{array}
\end{array}
if a < 1.17999999999999996e-64Initial program 75.6%
unpow275.6%
swap-sqr75.6%
*-commutative75.6%
associate-*r/75.2%
associate-*l/75.7%
*-commutative75.7%
swap-sqr75.7%
unpow275.7%
*-commutative75.7%
associate-*r/75.2%
associate-*l/75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in angle around 0 67.6%
*-commutative67.6%
associate-*r*67.6%
associate-*l*67.6%
*-commutative67.6%
*-commutative67.6%
Simplified67.6%
Taylor expanded in angle around 0 67.2%
Taylor expanded in angle around 0 58.3%
if 1.17999999999999996e-64 < a Initial program 77.9%
unpow277.9%
swap-sqr77.9%
*-commutative77.9%
associate-*r/77.9%
associate-*l/78.1%
*-commutative78.1%
swap-sqr78.1%
unpow278.1%
*-commutative78.1%
associate-*r/78.1%
associate-*l/78.1%
*-commutative78.1%
Simplified78.1%
Taylor expanded in angle around 0 73.6%
*-commutative73.6%
associate-*r*73.6%
associate-*l*73.7%
*-commutative73.7%
*-commutative73.7%
Simplified73.7%
Taylor expanded in angle around 0 73.8%
unpow273.8%
*-commutative73.8%
metadata-eval73.8%
div-inv73.8%
*-commutative73.8%
associate-*r*73.8%
associate-*l*73.7%
*-commutative73.7%
div-inv73.7%
metadata-eval73.7%
Applied egg-rr73.7%
Final simplification62.6%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (pow b 2.0))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow(b, 2.0);
}
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 ** 2.0d0
end function
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow(b, 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow(b, 2.0)
angle_m = abs(angle) function code(a, b, angle_m) return b ^ 2.0 end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = b ^ 2.0; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[Power[b, 2.0], $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{b}^{2}
\end{array}
Initial program 76.3%
unpow276.3%
swap-sqr76.3%
*-commutative76.3%
associate-*r/75.9%
associate-*l/76.4%
*-commutative76.4%
swap-sqr76.4%
unpow276.4%
*-commutative76.4%
associate-*r/76.0%
associate-*l/76.4%
*-commutative76.4%
Simplified76.4%
Taylor expanded in angle around 0 69.3%
*-commutative69.3%
associate-*r*69.3%
associate-*l*69.3%
*-commutative69.3%
*-commutative69.3%
Simplified69.3%
Taylor expanded in angle around 0 69.0%
Taylor expanded in angle around 0 51.3%
Final simplification51.3%
herbie shell --seed 2024040
(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)))