
(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 8 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}
(FPCore (a b angle)
:precision binary64
(+
(pow
(*
a
(sin
(expm1
(fma
0.005555555555555556
(* angle PI)
(* -1.54320987654321e-5 (pow (* angle PI) 2.0))))))
2.0)
(pow (* b (cos (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(expm1(fma(0.005555555555555556, (angle * ((double) M_PI)), (-1.54320987654321e-5 * pow((angle * ((double) M_PI)), 2.0)))))), 2.0) + pow((b * cos((((double) M_PI) * (angle / 180.0)))), 2.0);
}
function code(a, b, angle) return Float64((Float64(a * sin(expm1(fma(0.005555555555555556, Float64(angle * pi), Float64(-1.54320987654321e-5 * (Float64(angle * pi) ^ 2.0)))))) ^ 2.0) + (Float64(b * cos(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(Exp[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision] + N[(-1.54320987654321e-5 * N[Power[N[(angle * Pi), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\mathsf{expm1}\left(\mathsf{fma}\left(0.005555555555555556, angle \cdot \pi, -1.54320987654321 \cdot 10^{-5} \cdot {\left(angle \cdot \pi\right)}^{2}\right)\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 86.7%
associate-*l/86.7%
associate-*r/86.7%
expm1-log1p-u74.2%
*-commutative74.2%
associate-*l/74.1%
associate-*r/74.1%
div-inv74.1%
metadata-eval74.1%
Applied egg-rr74.1%
Taylor expanded in angle around 0 86.9%
+-commutative86.9%
*-commutative86.9%
fma-define86.9%
*-commutative86.9%
*-commutative86.9%
unpow286.9%
unpow286.9%
swap-sqr86.9%
unpow286.9%
*-commutative86.9%
Simplified86.9%
Final simplification86.9%
(FPCore (a b angle) :precision binary64 (+ (pow (* b (cos (* PI (/ angle 180.0)))) 2.0) (pow (* a (sin (expm1 (log1p (* PI (* 0.005555555555555556 angle)))))) 2.0)))
double code(double a, double b, double angle) {
return pow((b * cos((((double) M_PI) * (angle / 180.0)))), 2.0) + pow((a * sin(expm1(log1p((((double) M_PI) * (0.005555555555555556 * angle)))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((b * Math.cos((Math.PI * (angle / 180.0)))), 2.0) + Math.pow((a * Math.sin(Math.expm1(Math.log1p((Math.PI * (0.005555555555555556 * angle)))))), 2.0);
}
def code(a, b, angle): return math.pow((b * math.cos((math.pi * (angle / 180.0)))), 2.0) + math.pow((a * math.sin(math.expm1(math.log1p((math.pi * (0.005555555555555556 * angle)))))), 2.0)
function code(a, b, angle) return Float64((Float64(b * cos(Float64(pi * Float64(angle / 180.0)))) ^ 2.0) + (Float64(a * sin(expm1(log1p(Float64(pi * Float64(0.005555555555555556 * angle)))))) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(b * N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(a * N[Sin[N[(Exp[N[Log[1 + N[(Pi * N[(0.005555555555555556 * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(b \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(a \cdot \sin \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right)\right)}^{2}
\end{array}
Initial program 86.7%
associate-*l/86.7%
associate-*r/86.7%
expm1-log1p-u74.2%
*-commutative74.2%
associate-*l/74.1%
associate-*r/74.1%
div-inv74.1%
metadata-eval74.1%
Applied egg-rr74.1%
Final simplification74.1%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* 0.005555555555555556 (* angle PI)))) 2.0) (pow (* b (cos (* angle (/ PI 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0) + pow((b * cos((angle * (((double) M_PI) / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((0.005555555555555556 * (angle * Math.PI)))), 2.0) + Math.pow((b * Math.cos((angle * (Math.PI / 180.0)))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0) + math.pow((b * math.cos((angle * (math.pi / 180.0)))), 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0) + (Float64(b * cos(Float64(angle * Float64(pi / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0) + ((b * cos((angle * (pi / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[N[(angle * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2}
\end{array}
Initial program 86.7%
associate-*l/86.7%
associate-/l*86.7%
associate-*l/86.6%
associate-/l*86.7%
Simplified86.7%
Taylor expanded in angle around inf 86.7%
Final simplification86.7%
(FPCore (a b angle) :precision binary64 (+ (pow (* b (cos (* PI (/ angle 180.0)))) 2.0) (pow (* a (sin (/ angle (/ 180.0 PI)))) 2.0)))
double code(double a, double b, double angle) {
return pow((b * cos((((double) M_PI) * (angle / 180.0)))), 2.0) + pow((a * sin((angle / (180.0 / ((double) M_PI))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((b * Math.cos((Math.PI * (angle / 180.0)))), 2.0) + Math.pow((a * Math.sin((angle / (180.0 / Math.PI)))), 2.0);
}
def code(a, b, angle): return math.pow((b * math.cos((math.pi * (angle / 180.0)))), 2.0) + math.pow((a * math.sin((angle / (180.0 / math.pi)))), 2.0)
function code(a, b, angle) return Float64((Float64(b * cos(Float64(pi * Float64(angle / 180.0)))) ^ 2.0) + (Float64(a * sin(Float64(angle / Float64(180.0 / pi)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((b * cos((pi * (angle / 180.0)))) ^ 2.0) + ((a * sin((angle / (180.0 / pi)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(b * N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(a * N[Sin[N[(angle / N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(b \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(a \cdot \sin \left(\frac{angle}{\frac{180}{\pi}}\right)\right)}^{2}
\end{array}
Initial program 86.7%
associate-*l/86.7%
associate-*r/86.7%
clear-num86.7%
un-div-inv86.8%
Applied egg-rr86.8%
Final simplification86.8%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* 0.005555555555555556 (* angle PI)))) 2.0) (pow b 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0) + pow(b, 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((0.005555555555555556 * (angle * Math.PI)))), 2.0) + Math.pow(b, 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0) + math.pow(b, 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0) + (b ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0) + (b ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {b}^{2}
\end{array}
Initial program 86.7%
associate-*l/86.7%
associate-/l*86.7%
associate-*l/86.6%
associate-/l*86.7%
Simplified86.7%
Taylor expanded in angle around 0 86.7%
Taylor expanded in a around 0 86.7%
Final simplification86.7%
(FPCore (a b angle)
:precision binary64
(if (<= angle 2.9e-13)
(+
(pow b 2.0)
(*
0.005555555555555556
(* a (* (* angle PI) (* a (* 0.005555555555555556 (* angle PI)))))))
(+
(pow b 2.0)
(*
0.005555555555555556
(* a (* (* angle PI) (* a (* 0.005555555555555556 (/ PI angle)))))))))
double code(double a, double b, double angle) {
double tmp;
if (angle <= 2.9e-13) {
tmp = pow(b, 2.0) + (0.005555555555555556 * (a * ((angle * ((double) M_PI)) * (a * (0.005555555555555556 * (angle * ((double) M_PI)))))));
} else {
tmp = pow(b, 2.0) + (0.005555555555555556 * (a * ((angle * ((double) M_PI)) * (a * (0.005555555555555556 * (((double) M_PI) / angle))))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (angle <= 2.9e-13) {
tmp = Math.pow(b, 2.0) + (0.005555555555555556 * (a * ((angle * Math.PI) * (a * (0.005555555555555556 * (angle * Math.PI))))));
} else {
tmp = Math.pow(b, 2.0) + (0.005555555555555556 * (a * ((angle * Math.PI) * (a * (0.005555555555555556 * (Math.PI / angle))))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if angle <= 2.9e-13: tmp = math.pow(b, 2.0) + (0.005555555555555556 * (a * ((angle * math.pi) * (a * (0.005555555555555556 * (angle * math.pi)))))) else: tmp = math.pow(b, 2.0) + (0.005555555555555556 * (a * ((angle * math.pi) * (a * (0.005555555555555556 * (math.pi / angle)))))) return tmp
function code(a, b, angle) tmp = 0.0 if (angle <= 2.9e-13) tmp = Float64((b ^ 2.0) + Float64(0.005555555555555556 * Float64(a * Float64(Float64(angle * pi) * Float64(a * Float64(0.005555555555555556 * Float64(angle * pi))))))); else tmp = Float64((b ^ 2.0) + Float64(0.005555555555555556 * Float64(a * Float64(Float64(angle * pi) * Float64(a * Float64(0.005555555555555556 * Float64(pi / angle))))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (angle <= 2.9e-13) tmp = (b ^ 2.0) + (0.005555555555555556 * (a * ((angle * pi) * (a * (0.005555555555555556 * (angle * pi)))))); else tmp = (b ^ 2.0) + (0.005555555555555556 * (a * ((angle * pi) * (a * (0.005555555555555556 * (pi / angle)))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[angle, 2.9e-13], N[(N[Power[b, 2.0], $MachinePrecision] + N[(0.005555555555555556 * N[(a * N[(N[(angle * Pi), $MachinePrecision] * N[(a * N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(0.005555555555555556 * N[(a * N[(N[(angle * Pi), $MachinePrecision] * N[(a * N[(0.005555555555555556 * N[(Pi / angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 2.9 \cdot 10^{-13}:\\
\;\;\;\;{b}^{2} + 0.005555555555555556 \cdot \left(a \cdot \left(\left(angle \cdot \pi\right) \cdot \left(a \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + 0.005555555555555556 \cdot \left(a \cdot \left(\left(angle \cdot \pi\right) \cdot \left(a \cdot \left(0.005555555555555556 \cdot \frac{\pi}{angle}\right)\right)\right)\right)\\
\end{array}
\end{array}
if angle < 2.8999999999999998e-13Initial program 92.1%
associate-*l/92.1%
associate-/l*92.2%
associate-*l/92.2%
associate-/l*92.2%
Simplified92.2%
Taylor expanded in angle around 0 92.2%
Taylor expanded in angle around 0 87.8%
unpow287.8%
associate-*l*87.8%
*-commutative87.8%
associate-*l*87.8%
*-commutative87.8%
associate-*l*87.8%
*-commutative87.8%
associate-*l*87.8%
*-commutative87.8%
Applied egg-rr87.8%
*-commutative87.8%
associate-*l*87.8%
*-commutative87.8%
associate-*r*87.9%
associate-*r*87.8%
*-commutative87.8%
associate-*r*87.8%
Simplified87.8%
if 2.8999999999999998e-13 < angle Initial program 65.4%
associate-*l/65.4%
associate-/l*65.2%
associate-*l/65.0%
associate-/l*65.1%
Simplified65.1%
Taylor expanded in angle around 0 65.0%
Taylor expanded in angle around 0 52.3%
unpow252.3%
associate-*l*52.3%
*-commutative52.3%
associate-*l*52.3%
*-commutative52.3%
associate-*l*52.3%
*-commutative52.3%
associate-*l*52.3%
*-commutative52.3%
Applied egg-rr52.3%
*-commutative52.3%
associate-*l*52.3%
*-commutative52.3%
associate-*r*52.3%
associate-*r*52.3%
*-commutative52.3%
associate-*r*52.3%
Simplified52.3%
*-commutative52.3%
associate-*r*52.3%
add-exp-log52.3%
sum-log52.3%
remove-double-neg52.3%
unsub-neg52.3%
exp-diff52.3%
add-exp-log52.3%
add-sqr-sqrt5.8%
sqrt-unprod63.6%
sqr-neg63.6%
sqrt-unprod57.9%
add-sqr-sqrt63.6%
remove-double-neg63.6%
add-exp-log63.6%
Applied egg-rr63.6%
associate-/l*63.6%
Simplified63.6%
Final simplification82.9%
(FPCore (a b angle)
:precision binary64
(if (<= angle 2.4e+14)
(+
(pow b 2.0)
(*
(* a 0.005555555555555556)
(* (* angle PI) (* a (* PI (* 0.005555555555555556 angle))))))
(+
(pow b 2.0)
(*
0.005555555555555556
(* a (* (* angle PI) (* a (* 0.005555555555555556 (/ PI angle)))))))))
double code(double a, double b, double angle) {
double tmp;
if (angle <= 2.4e+14) {
tmp = pow(b, 2.0) + ((a * 0.005555555555555556) * ((angle * ((double) M_PI)) * (a * (((double) M_PI) * (0.005555555555555556 * angle)))));
} else {
tmp = pow(b, 2.0) + (0.005555555555555556 * (a * ((angle * ((double) M_PI)) * (a * (0.005555555555555556 * (((double) M_PI) / angle))))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (angle <= 2.4e+14) {
tmp = Math.pow(b, 2.0) + ((a * 0.005555555555555556) * ((angle * Math.PI) * (a * (Math.PI * (0.005555555555555556 * angle)))));
} else {
tmp = Math.pow(b, 2.0) + (0.005555555555555556 * (a * ((angle * Math.PI) * (a * (0.005555555555555556 * (Math.PI / angle))))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if angle <= 2.4e+14: tmp = math.pow(b, 2.0) + ((a * 0.005555555555555556) * ((angle * math.pi) * (a * (math.pi * (0.005555555555555556 * angle))))) else: tmp = math.pow(b, 2.0) + (0.005555555555555556 * (a * ((angle * math.pi) * (a * (0.005555555555555556 * (math.pi / angle)))))) return tmp
function code(a, b, angle) tmp = 0.0 if (angle <= 2.4e+14) tmp = Float64((b ^ 2.0) + Float64(Float64(a * 0.005555555555555556) * Float64(Float64(angle * pi) * Float64(a * Float64(pi * Float64(0.005555555555555556 * angle)))))); else tmp = Float64((b ^ 2.0) + Float64(0.005555555555555556 * Float64(a * Float64(Float64(angle * pi) * Float64(a * Float64(0.005555555555555556 * Float64(pi / angle))))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (angle <= 2.4e+14) tmp = (b ^ 2.0) + ((a * 0.005555555555555556) * ((angle * pi) * (a * (pi * (0.005555555555555556 * angle))))); else tmp = (b ^ 2.0) + (0.005555555555555556 * (a * ((angle * pi) * (a * (0.005555555555555556 * (pi / angle)))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[angle, 2.4e+14], N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(a * 0.005555555555555556), $MachinePrecision] * N[(N[(angle * Pi), $MachinePrecision] * N[(a * N[(Pi * N[(0.005555555555555556 * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(0.005555555555555556 * N[(a * N[(N[(angle * Pi), $MachinePrecision] * N[(a * N[(0.005555555555555556 * N[(Pi / angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 2.4 \cdot 10^{+14}:\\
\;\;\;\;{b}^{2} + \left(a \cdot 0.005555555555555556\right) \cdot \left(\left(angle \cdot \pi\right) \cdot \left(a \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + 0.005555555555555556 \cdot \left(a \cdot \left(\left(angle \cdot \pi\right) \cdot \left(a \cdot \left(0.005555555555555556 \cdot \frac{\pi}{angle}\right)\right)\right)\right)\\
\end{array}
\end{array}
if angle < 2.4e14Initial program 92.0%
associate-*l/92.0%
associate-/l*92.0%
associate-*l/92.0%
associate-/l*92.1%
Simplified92.1%
Taylor expanded in angle around 0 92.0%
Taylor expanded in angle around 0 87.7%
unpow287.7%
associate-*r*87.7%
associate-*l*87.7%
*-commutative87.7%
associate-*l*87.7%
*-commutative87.7%
associate-*l*87.7%
*-commutative87.7%
Applied egg-rr87.7%
if 2.4e14 < angle Initial program 63.2%
associate-*l/63.1%
associate-/l*63.0%
associate-*l/62.7%
associate-/l*62.7%
Simplified62.7%
Taylor expanded in angle around 0 63.0%
Taylor expanded in angle around 0 49.0%
unpow249.0%
associate-*l*49.0%
*-commutative49.0%
associate-*l*49.0%
*-commutative49.0%
associate-*l*49.0%
*-commutative49.0%
associate-*l*49.0%
*-commutative49.0%
Applied egg-rr49.0%
*-commutative49.0%
associate-*l*49.0%
*-commutative49.0%
associate-*r*49.0%
associate-*r*49.0%
*-commutative49.0%
associate-*r*49.0%
Simplified49.0%
*-commutative49.0%
associate-*r*49.0%
add-exp-log49.0%
sum-log49.0%
remove-double-neg49.0%
unsub-neg49.0%
exp-diff49.0%
add-exp-log49.0%
add-sqr-sqrt0.0%
sqrt-unprod61.5%
sqr-neg61.5%
sqrt-unprod61.5%
add-sqr-sqrt61.5%
remove-double-neg61.5%
add-exp-log61.5%
Applied egg-rr61.5%
associate-/l*61.5%
Simplified61.5%
Final simplification82.9%
(FPCore (a b angle) :precision binary64 (+ (pow b 2.0) (* 0.005555555555555556 (* a (* (* angle PI) (* a (* 0.005555555555555556 (* angle PI))))))))
double code(double a, double b, double angle) {
return pow(b, 2.0) + (0.005555555555555556 * (a * ((angle * ((double) M_PI)) * (a * (0.005555555555555556 * (angle * ((double) M_PI)))))));
}
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0) + (0.005555555555555556 * (a * ((angle * Math.PI) * (a * (0.005555555555555556 * (angle * Math.PI))))));
}
def code(a, b, angle): return math.pow(b, 2.0) + (0.005555555555555556 * (a * ((angle * math.pi) * (a * (0.005555555555555556 * (angle * math.pi))))))
function code(a, b, angle) return Float64((b ^ 2.0) + Float64(0.005555555555555556 * Float64(a * Float64(Float64(angle * pi) * Float64(a * Float64(0.005555555555555556 * Float64(angle * pi))))))) end
function tmp = code(a, b, angle) tmp = (b ^ 2.0) + (0.005555555555555556 * (a * ((angle * pi) * (a * (0.005555555555555556 * (angle * pi)))))); end
code[a_, b_, angle_] := N[(N[Power[b, 2.0], $MachinePrecision] + N[(0.005555555555555556 * N[(a * N[(N[(angle * Pi), $MachinePrecision] * N[(a * N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{b}^{2} + 0.005555555555555556 \cdot \left(a \cdot \left(\left(angle \cdot \pi\right) \cdot \left(a \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\right)\right)
\end{array}
Initial program 86.7%
associate-*l/86.7%
associate-/l*86.7%
associate-*l/86.6%
associate-/l*86.7%
Simplified86.7%
Taylor expanded in angle around 0 86.7%
Taylor expanded in angle around 0 80.6%
unpow280.6%
associate-*l*80.6%
*-commutative80.6%
associate-*l*80.6%
*-commutative80.6%
associate-*l*80.6%
*-commutative80.6%
associate-*l*80.6%
*-commutative80.6%
Applied egg-rr80.6%
*-commutative80.6%
associate-*l*80.6%
*-commutative80.6%
associate-*r*80.6%
associate-*r*80.6%
*-commutative80.6%
associate-*r*80.6%
Simplified80.6%
Final simplification80.6%
herbie shell --seed 2024052
(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)))