
(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 9 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 (hypot (* a (sin (* PI (expm1 (log1p (* 0.005555555555555556 angle_m)))))) (* b (cos (* PI (* 0.005555555555555556 angle_m))))) 2.0))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow(hypot((a * sin((((double) M_PI) * expm1(log1p((0.005555555555555556 * angle_m)))))), (b * cos((((double) M_PI) * (0.005555555555555556 * angle_m))))), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow(Math.hypot((a * Math.sin((Math.PI * Math.expm1(Math.log1p((0.005555555555555556 * angle_m)))))), (b * Math.cos((Math.PI * (0.005555555555555556 * angle_m))))), 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow(math.hypot((a * math.sin((math.pi * math.expm1(math.log1p((0.005555555555555556 * angle_m)))))), (b * math.cos((math.pi * (0.005555555555555556 * angle_m))))), 2.0)
angle_m = abs(angle) function code(a, b, angle_m) return hypot(Float64(a * sin(Float64(pi * expm1(log1p(Float64(0.005555555555555556 * angle_m)))))), Float64(b * cos(Float64(pi * Float64(0.005555555555555556 * angle_m))))) ^ 2.0 end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[Power[N[Sqrt[N[(a * N[Sin[N[(Pi * N[(Exp[N[Log[1 + N[(0.005555555555555556 * angle$95$m), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(b * N[Cos[N[(Pi * N[(0.005555555555555556 * angle$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{\left(\mathsf{hypot}\left(a \cdot \sin \left(\pi \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(0.005555555555555556 \cdot angle\_m\right)\right)\right), b \cdot \cos \left(\pi \cdot \left(0.005555555555555556 \cdot angle\_m\right)\right)\right)\right)}^{2}
\end{array}
Initial program 78.2%
associate-*l/78.2%
associate-/l*78.3%
cos-neg78.3%
distribute-lft-neg-out78.3%
distribute-frac-neg78.3%
distribute-frac-neg78.3%
distribute-lft-neg-out78.3%
cos-neg78.3%
associate-*l/78.3%
associate-/l*78.3%
Simplified78.3%
+-commutative78.3%
associate-*r/78.3%
associate-*l/78.3%
unpow278.3%
associate-*r/78.2%
associate-*l/78.2%
unpow278.2%
associate-*r*78.2%
unpow278.2%
Applied egg-rr78.3%
Applied egg-rr78.3%
expm1-log1p-u65.4%
expm1-undefine54.5%
*-commutative54.5%
Applied egg-rr54.5%
expm1-define65.4%
Simplified65.4%
Final simplification65.4%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (let* ((t_0 (/ angle_m (/ 180.0 PI)))) (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double t_0 = angle_m / (180.0 / ((double) M_PI));
return pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double t_0 = angle_m / (180.0 / Math.PI);
return Math.pow((a * Math.sin(t_0)), 2.0) + Math.pow((b * Math.cos(t_0)), 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): t_0 = angle_m / (180.0 / math.pi) return math.pow((a * math.sin(t_0)), 2.0) + math.pow((b * math.cos(t_0)), 2.0)
angle_m = abs(angle) function code(a, b, angle_m) t_0 = Float64(angle_m / Float64(180.0 / pi)) return Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) t_0 = angle_m / (180.0 / pi); tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := Block[{t$95$0 = N[(angle$95$m / N[(180.0 / Pi), $MachinePrecision]), $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}
angle_m = \left|angle\right|
\\
\begin{array}{l}
t_0 := \frac{angle\_m}{\frac{180}{\pi}}\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
Initial program 78.2%
associate-*l/78.2%
associate-*r/78.3%
clear-num78.3%
un-div-inv78.3%
Applied egg-rr78.3%
expm1-log1p-u65.3%
expm1-undefine54.5%
associate-*l/54.5%
associate-*r/54.5%
div-inv54.5%
metadata-eval54.5%
Applied egg-rr54.5%
expm1-define65.3%
associate-*r*65.3%
*-commutative65.3%
associate-*r*65.3%
Simplified65.3%
expm1-log1p-u78.4%
*-commutative78.4%
metadata-eval78.4%
div-inv78.3%
associate-/r/78.3%
Applied egg-rr78.3%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (let* ((t_0 (* angle_m (* PI 0.005555555555555556)))) (pow (hypot (* a (sin t_0)) (* b (cos t_0))) 2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double t_0 = angle_m * (((double) M_PI) * 0.005555555555555556);
return pow(hypot((a * sin(t_0)), (b * cos(t_0))), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double t_0 = angle_m * (Math.PI * 0.005555555555555556);
return Math.pow(Math.hypot((a * Math.sin(t_0)), (b * Math.cos(t_0))), 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): t_0 = angle_m * (math.pi * 0.005555555555555556) return math.pow(math.hypot((a * math.sin(t_0)), (b * math.cos(t_0))), 2.0)
angle_m = abs(angle) function code(a, b, angle_m) t_0 = Float64(angle_m * Float64(pi * 0.005555555555555556)) return hypot(Float64(a * sin(t_0)), Float64(b * cos(t_0))) ^ 2.0 end
angle_m = abs(angle); function tmp = code(a, b, angle_m) t_0 = angle_m * (pi * 0.005555555555555556); tmp = hypot((a * sin(t_0)), (b * cos(t_0))) ^ 2.0; end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := Block[{t$95$0 = N[(angle$95$m * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, N[Power[N[Sqrt[N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(b * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
t_0 := angle\_m \cdot \left(\pi \cdot 0.005555555555555556\right)\\
{\left(\mathsf{hypot}\left(a \cdot \sin t\_0, b \cdot \cos t\_0\right)\right)}^{2}
\end{array}
\end{array}
Initial program 78.2%
associate-*l/78.2%
associate-/l*78.3%
cos-neg78.3%
distribute-lft-neg-out78.3%
distribute-frac-neg78.3%
distribute-frac-neg78.3%
distribute-lft-neg-out78.3%
cos-neg78.3%
associate-*l/78.3%
associate-/l*78.3%
Simplified78.3%
Applied egg-rr78.3%
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 78.2%
associate-*l/78.2%
associate-/l*78.3%
cos-neg78.3%
distribute-lft-neg-out78.3%
distribute-frac-neg78.3%
distribute-frac-neg78.3%
distribute-lft-neg-out78.3%
cos-neg78.3%
associate-*l/78.3%
associate-/l*78.3%
Simplified78.3%
Taylor expanded in angle around 0 77.6%
Final simplification77.6%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (if (<= b 9.5e-48) (pow (* a (sin (* PI (* 0.005555555555555556 angle_m)))) 2.0) (pow (* b (cos (* angle_m (* PI 0.005555555555555556)))) 2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (b <= 9.5e-48) {
tmp = pow((a * sin((((double) M_PI) * (0.005555555555555556 * angle_m)))), 2.0);
} else {
tmp = pow((b * cos((angle_m * (((double) M_PI) * 0.005555555555555556)))), 2.0);
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (b <= 9.5e-48) {
tmp = Math.pow((a * Math.sin((Math.PI * (0.005555555555555556 * angle_m)))), 2.0);
} else {
tmp = Math.pow((b * Math.cos((angle_m * (Math.PI * 0.005555555555555556)))), 2.0);
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if b <= 9.5e-48: tmp = math.pow((a * math.sin((math.pi * (0.005555555555555556 * angle_m)))), 2.0) else: tmp = math.pow((b * math.cos((angle_m * (math.pi * 0.005555555555555556)))), 2.0) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (b <= 9.5e-48) tmp = Float64(a * sin(Float64(pi * Float64(0.005555555555555556 * angle_m)))) ^ 2.0; else tmp = Float64(b * cos(Float64(angle_m * Float64(pi * 0.005555555555555556)))) ^ 2.0; end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (b <= 9.5e-48) tmp = (a * sin((pi * (0.005555555555555556 * angle_m)))) ^ 2.0; else tmp = (b * cos((angle_m * (pi * 0.005555555555555556)))) ^ 2.0; end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[b, 9.5e-48], N[Power[N[(a * N[Sin[N[(Pi * N[(0.005555555555555556 * angle$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[Power[N[(b * N[Cos[N[(angle$95$m * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.5 \cdot 10^{-48}:\\
\;\;\;\;{\left(a \cdot \sin \left(\pi \cdot \left(0.005555555555555556 \cdot angle\_m\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;{\left(b \cdot \cos \left(angle\_m \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if b < 9.50000000000000036e-48Initial program 75.2%
associate-*l/75.2%
associate-/l*75.2%
cos-neg75.2%
distribute-lft-neg-out75.2%
distribute-frac-neg75.2%
distribute-frac-neg75.2%
distribute-lft-neg-out75.2%
cos-neg75.2%
associate-*l/75.2%
associate-/l*75.2%
Simplified75.2%
Taylor expanded in a around inf 33.7%
unpow233.7%
*-commutative33.7%
associate-*r*33.8%
unpow233.8%
swap-sqr42.0%
unpow242.0%
associate-*r*42.0%
*-commutative42.0%
associate-*r*42.1%
Simplified42.1%
if 9.50000000000000036e-48 < b Initial program 85.2%
associate-*l/85.2%
associate-/l*85.2%
cos-neg85.2%
distribute-lft-neg-out85.2%
distribute-frac-neg85.2%
distribute-frac-neg85.2%
distribute-lft-neg-out85.2%
cos-neg85.2%
associate-*l/85.3%
associate-/l*85.4%
Simplified85.4%
+-commutative85.4%
associate-*r/85.3%
associate-*l/85.2%
unpow285.2%
associate-*r/85.2%
associate-*l/85.2%
unpow285.2%
associate-*r*85.3%
unpow285.3%
Applied egg-rr85.4%
Taylor expanded in b around inf 81.4%
*-commutative81.4%
unpow281.4%
unpow281.4%
swap-sqr81.4%
*-commutative81.4%
*-commutative81.4%
associate-*r*76.1%
*-commutative76.1%
*-commutative76.1%
*-commutative76.1%
associate-*r*81.5%
*-commutative81.5%
unpow281.5%
Simplified81.6%
Final simplification54.1%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (if (<= b 1.75e-47) (pow (* a (sin (* PI (* 0.005555555555555556 angle_m)))) 2.0) (pow (* b (cos (* 0.005555555555555556 (* PI angle_m)))) 2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (b <= 1.75e-47) {
tmp = pow((a * sin((((double) M_PI) * (0.005555555555555556 * angle_m)))), 2.0);
} else {
tmp = pow((b * cos((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 (b <= 1.75e-47) {
tmp = Math.pow((a * Math.sin((Math.PI * (0.005555555555555556 * angle_m)))), 2.0);
} else {
tmp = Math.pow((b * Math.cos((0.005555555555555556 * (Math.PI * angle_m)))), 2.0);
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if b <= 1.75e-47: tmp = math.pow((a * math.sin((math.pi * (0.005555555555555556 * angle_m)))), 2.0) else: tmp = math.pow((b * math.cos((0.005555555555555556 * (math.pi * angle_m)))), 2.0) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (b <= 1.75e-47) tmp = Float64(a * sin(Float64(pi * Float64(0.005555555555555556 * angle_m)))) ^ 2.0; else tmp = Float64(b * cos(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 (b <= 1.75e-47) tmp = (a * sin((pi * (0.005555555555555556 * angle_m)))) ^ 2.0; else tmp = (b * cos((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[b, 1.75e-47], N[Power[N[(a * N[Sin[N[(Pi * N[(0.005555555555555556 * angle$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[Power[N[(b * N[Cos[N[(0.005555555555555556 * N[(Pi * angle$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.75 \cdot 10^{-47}:\\
\;\;\;\;{\left(a \cdot \sin \left(\pi \cdot \left(0.005555555555555556 \cdot angle\_m\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;{\left(b \cdot \cos \left(0.005555555555555556 \cdot \left(\pi \cdot angle\_m\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if b < 1.7499999999999999e-47Initial program 75.2%
associate-*l/75.2%
associate-/l*75.2%
cos-neg75.2%
distribute-lft-neg-out75.2%
distribute-frac-neg75.2%
distribute-frac-neg75.2%
distribute-lft-neg-out75.2%
cos-neg75.2%
associate-*l/75.2%
associate-/l*75.2%
Simplified75.2%
Taylor expanded in a around inf 33.7%
unpow233.7%
*-commutative33.7%
associate-*r*33.8%
unpow233.8%
swap-sqr42.0%
unpow242.0%
associate-*r*42.0%
*-commutative42.0%
associate-*r*42.1%
Simplified42.1%
if 1.7499999999999999e-47 < b Initial program 85.2%
associate-*l/85.2%
associate-/l*85.2%
cos-neg85.2%
distribute-lft-neg-out85.2%
distribute-frac-neg85.2%
distribute-frac-neg85.2%
distribute-lft-neg-out85.2%
cos-neg85.2%
associate-*l/85.3%
associate-/l*85.4%
Simplified85.4%
Taylor expanded in a around 0 81.4%
*-commutative81.4%
associate-*r*81.6%
unpow281.6%
unpow281.6%
swap-sqr81.6%
unpow281.6%
associate-*r*81.4%
*-commutative81.4%
Simplified81.4%
Final simplification54.1%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (if (<= a 2.2e+152) (* b b) (pow (* a (sin (* angle_m (* PI 0.005555555555555556)))) 2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (a <= 2.2e+152) {
tmp = b * b;
} else {
tmp = pow((a * sin((angle_m * (((double) M_PI) * 0.005555555555555556)))), 2.0);
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (a <= 2.2e+152) {
tmp = b * b;
} else {
tmp = Math.pow((a * Math.sin((angle_m * (Math.PI * 0.005555555555555556)))), 2.0);
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if a <= 2.2e+152: tmp = b * b else: tmp = math.pow((a * math.sin((angle_m * (math.pi * 0.005555555555555556)))), 2.0) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (a <= 2.2e+152) tmp = Float64(b * b); else tmp = Float64(a * sin(Float64(angle_m * Float64(pi * 0.005555555555555556)))) ^ 2.0; end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (a <= 2.2e+152) tmp = b * b; else tmp = (a * sin((angle_m * (pi * 0.005555555555555556)))) ^ 2.0; end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[a, 2.2e+152], N[(b * b), $MachinePrecision], N[Power[N[(a * N[Sin[N[(angle$95$m * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.2 \cdot 10^{+152}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;{\left(a \cdot \sin \left(angle\_m \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 2.1999999999999998e152Initial program 76.5%
associate-*l/76.6%
associate-/l*76.5%
cos-neg76.5%
distribute-lft-neg-out76.5%
distribute-frac-neg76.5%
distribute-frac-neg76.5%
distribute-lft-neg-out76.5%
cos-neg76.5%
associate-*l/76.6%
associate-/l*76.6%
Simplified76.6%
Taylor expanded in angle around 0 60.3%
unpow260.3%
Applied egg-rr60.3%
if 2.1999999999999998e152 < a Initial program 95.5%
associate-*l/95.4%
associate-/l*95.6%
cos-neg95.6%
distribute-lft-neg-out95.6%
distribute-frac-neg95.6%
distribute-frac-neg95.6%
distribute-lft-neg-out95.6%
cos-neg95.6%
associate-*l/95.6%
associate-/l*95.6%
Simplified95.6%
+-commutative95.6%
associate-*r/95.6%
associate-*l/95.6%
unpow295.6%
associate-*r/95.4%
associate-*l/95.5%
unpow295.5%
associate-*r*95.5%
unpow295.5%
Applied egg-rr95.6%
Taylor expanded in b around 0 70.5%
unpow270.5%
*-commutative70.5%
*-commutative70.5%
associate-*r*70.5%
unpow270.5%
swap-sqr75.0%
unpow275.0%
Simplified75.0%
Final simplification61.7%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (if (<= a 1.6e+153) (* b b) (pow (* a (sin (* 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.6e+153) {
tmp = b * b;
} else {
tmp = pow((a * sin((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.6e+153) {
tmp = b * b;
} else {
tmp = Math.pow((a * Math.sin((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.6e+153: tmp = b * b else: tmp = math.pow((a * math.sin((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.6e+153) tmp = Float64(b * b); else tmp = Float64(a * sin(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.6e+153) tmp = b * b; else tmp = (a * sin((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.6e+153], N[(b * b), $MachinePrecision], N[Power[N[(a * N[Sin[N[(0.005555555555555556 * N[(Pi * angle$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.6 \cdot 10^{+153}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;{\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(\pi \cdot angle\_m\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 1.6000000000000001e153Initial program 76.5%
associate-*l/76.6%
associate-/l*76.5%
cos-neg76.5%
distribute-lft-neg-out76.5%
distribute-frac-neg76.5%
distribute-frac-neg76.5%
distribute-lft-neg-out76.5%
cos-neg76.5%
associate-*l/76.6%
associate-/l*76.6%
Simplified76.6%
Taylor expanded in angle around 0 60.3%
unpow260.3%
Applied egg-rr60.3%
if 1.6000000000000001e153 < a Initial program 95.5%
associate-*l/95.4%
associate-/l*95.6%
cos-neg95.6%
distribute-lft-neg-out95.6%
distribute-frac-neg95.6%
distribute-frac-neg95.6%
distribute-lft-neg-out95.6%
cos-neg95.6%
associate-*l/95.6%
associate-/l*95.6%
Simplified95.6%
Taylor expanded in a around inf 70.5%
unpow270.5%
*-commutative70.5%
associate-*r*70.5%
unpow270.5%
swap-sqr75.0%
unpow275.0%
associate-*r*75.0%
*-commutative75.0%
Simplified75.0%
Final simplification61.7%
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 78.2%
associate-*l/78.2%
associate-/l*78.3%
cos-neg78.3%
distribute-lft-neg-out78.3%
distribute-frac-neg78.3%
distribute-frac-neg78.3%
distribute-lft-neg-out78.3%
cos-neg78.3%
associate-*l/78.3%
associate-/l*78.3%
Simplified78.3%
Taylor expanded in angle around 0 59.0%
unpow259.0%
Applied egg-rr59.0%
herbie shell --seed 2024143
(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)))