
(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 11 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 (* (/ angle 180.0) PI))) 2.0)
(pow
(*
b
(cos
(*
(pow (pow PI 0.08333333333333333) 8.0)
(* (cbrt PI) (* angle 0.005555555555555556)))))
2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(((angle / 180.0) * ((double) M_PI)))), 2.0) + pow((b * cos((pow(pow(((double) M_PI), 0.08333333333333333), 8.0) * (cbrt(((double) M_PI)) * (angle * 0.005555555555555556))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin(((angle / 180.0) * Math.PI))), 2.0) + Math.pow((b * Math.cos((Math.pow(Math.pow(Math.PI, 0.08333333333333333), 8.0) * (Math.cbrt(Math.PI) * (angle * 0.005555555555555556))))), 2.0);
}
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(angle / 180.0) * pi))) ^ 2.0) + (Float64(b * cos(Float64(((pi ^ 0.08333333333333333) ^ 8.0) * Float64(cbrt(pi) * Float64(angle * 0.005555555555555556))))) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[N[(N[Power[N[Power[Pi, 0.08333333333333333], $MachinePrecision], 8.0], $MachinePrecision] * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left({\left({\pi}^{0.08333333333333333}\right)}^{8} \cdot \left(\sqrt[3]{\pi} \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)\right)}^{2}
\end{array}
Initial program 80.9%
expm1-log1p-u62.7%
associate-*l/62.7%
associate-*r/62.7%
div-inv62.7%
metadata-eval62.7%
Applied egg-rr62.7%
expm1-log1p-u81.0%
metadata-eval81.0%
div-inv81.0%
associate-*r/80.6%
associate-*l/80.9%
*-commutative80.9%
add-cube-cbrt80.9%
associate-*l*81.0%
pow281.0%
div-inv81.0%
metadata-eval81.0%
Applied egg-rr81.0%
add-sqr-sqrt81.1%
pow281.1%
pow1/381.1%
sqrt-pow181.1%
metadata-eval81.1%
Applied egg-rr81.1%
pow-pow81.1%
add-sqr-sqrt81.1%
unpow-prod-down81.1%
sqrt-pow181.1%
metadata-eval81.1%
metadata-eval81.1%
sqrt-pow181.1%
metadata-eval81.1%
metadata-eval81.1%
Applied egg-rr81.1%
pow-sqr81.1%
metadata-eval81.1%
Simplified81.1%
Final simplification81.1%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* angle (/ PI 180.0)))) 2.0) (pow (* b (log1p (expm1 (cos (* angle (* PI 0.005555555555555556)))))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin((angle * (((double) M_PI) / 180.0)))), 2.0) + pow((b * log1p(expm1(cos((angle * (((double) M_PI) * 0.005555555555555556)))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((angle * (Math.PI / 180.0)))), 2.0) + Math.pow((b * Math.log1p(Math.expm1(Math.cos((angle * (Math.PI * 0.005555555555555556)))))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin((angle * (math.pi / 180.0)))), 2.0) + math.pow((b * math.log1p(math.expm1(math.cos((angle * (math.pi * 0.005555555555555556)))))), 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(angle * Float64(pi / 180.0)))) ^ 2.0) + (Float64(b * log1p(expm1(cos(Float64(angle * Float64(pi * 0.005555555555555556)))))) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(angle * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Log[1 + N[(Exp[N[Cos[N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2} + {\left(b \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)\right)}^{2}
\end{array}
Initial program 80.9%
associate-*l/80.5%
associate-/l*80.9%
cos-neg80.9%
distribute-lft-neg-out80.9%
distribute-frac-neg80.9%
distribute-frac-neg80.9%
distribute-lft-neg-out80.9%
cos-neg80.9%
associate-*l/80.6%
associate-/l*81.0%
Simplified81.0%
associate-*r/80.6%
associate-*l/80.9%
log1p-expm1-u80.9%
associate-*l/80.6%
associate-*r/81.0%
div-inv81.0%
metadata-eval81.0%
Applied egg-rr81.0%
Final simplification81.0%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (/ angle 180.0) PI))) 2.0) (pow (* b (cos (expm1 (log1p (* angle (* PI 0.005555555555555556)))))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(((angle / 180.0) * ((double) M_PI)))), 2.0) + pow((b * cos(expm1(log1p((angle * (((double) M_PI) * 0.005555555555555556)))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin(((angle / 180.0) * Math.PI))), 2.0) + Math.pow((b * Math.cos(Math.expm1(Math.log1p((angle * (Math.PI * 0.005555555555555556)))))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin(((angle / 180.0) * math.pi))), 2.0) + math.pow((b * math.cos(math.expm1(math.log1p((angle * (math.pi * 0.005555555555555556)))))), 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(angle / 180.0) * pi))) ^ 2.0) + (Float64(b * cos(expm1(log1p(Float64(angle * Float64(pi * 0.005555555555555556)))))) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[N[(Exp[N[Log[1 + N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(\mathsf{expm1}\left(\mathsf{log1p}\left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)\right)}^{2}
\end{array}
Initial program 80.9%
expm1-log1p-u62.7%
associate-*l/62.7%
associate-*r/62.7%
div-inv62.7%
metadata-eval62.7%
Applied egg-rr62.7%
Final simplification62.7%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* angle (/ PI 180.0)))) (+ (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 * (((double) M_PI) / 180.0);
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 * (Math.PI / 180.0);
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 * (math.pi / 180.0) 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(angle * Float64(pi / 180.0)) 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 * (pi / 180.0); tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(angle * N[(Pi / 180.0), $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}
\\
\begin{array}{l}
t_0 := angle \cdot \frac{\pi}{180}\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
Initial program 80.9%
associate-*l/80.5%
associate-/l*80.9%
cos-neg80.9%
distribute-lft-neg-out80.9%
distribute-frac-neg80.9%
distribute-frac-neg80.9%
distribute-lft-neg-out80.9%
cos-neg80.9%
associate-*l/80.6%
associate-/l*81.0%
Simplified81.0%
Final simplification81.0%
(FPCore (a b angle) :precision binary64 (+ (pow b 2.0) (pow (* a (sin (* 0.005555555555555556 (* angle PI)))) 2.0)))
double code(double a, double b, double angle) {
return pow(b, 2.0) + pow((a * sin((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0) + Math.pow((a * Math.sin((0.005555555555555556 * (angle * Math.PI)))), 2.0);
}
def code(a, b, angle): return math.pow(b, 2.0) + math.pow((a * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0)
function code(a, b, angle) return Float64((b ^ 2.0) + (Float64(a * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (b ^ 2.0) + ((a * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[b, 2.0], $MachinePrecision] + N[Power[N[(a * N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{b}^{2} + {\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}
\end{array}
Initial program 80.9%
associate-*l/80.5%
associate-/l*80.9%
cos-neg80.9%
distribute-lft-neg-out80.9%
distribute-frac-neg80.9%
distribute-frac-neg80.9%
distribute-lft-neg-out80.9%
cos-neg80.9%
associate-*l/80.6%
associate-/l*81.0%
Simplified81.0%
Taylor expanded in angle around 0 80.9%
Taylor expanded in angle around inf 80.5%
Final simplification80.5%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* angle (/ PI 180.0)))) 2.0) (pow b 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin((angle * (((double) M_PI) / 180.0)))), 2.0) + pow(b, 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((angle * (Math.PI / 180.0)))), 2.0) + Math.pow(b, 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin((angle * (math.pi / 180.0)))), 2.0) + math.pow(b, 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(angle * Float64(pi / 180.0)))) ^ 2.0) + (b ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin((angle * (pi / 180.0)))) ^ 2.0) + (b ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(angle * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2} + {b}^{2}
\end{array}
Initial program 80.9%
associate-*l/80.5%
associate-/l*80.9%
cos-neg80.9%
distribute-lft-neg-out80.9%
distribute-frac-neg80.9%
distribute-frac-neg80.9%
distribute-lft-neg-out80.9%
cos-neg80.9%
associate-*l/80.6%
associate-/l*81.0%
Simplified81.0%
Taylor expanded in angle around 0 80.9%
Final simplification80.9%
(FPCore (a b angle)
:precision binary64
(if (<= a 8.7e+27)
(pow b 2.0)
(+
(pow b 2.0)
(*
(* PI 0.005555555555555556)
(* (* a angle) (* PI (* 0.005555555555555556 (* a angle))))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 8.7e+27) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + ((((double) M_PI) * 0.005555555555555556) * ((a * angle) * (((double) M_PI) * (0.005555555555555556 * (a * angle)))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 8.7e+27) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + ((Math.PI * 0.005555555555555556) * ((a * angle) * (Math.PI * (0.005555555555555556 * (a * angle)))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 8.7e+27: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + ((math.pi * 0.005555555555555556) * ((a * angle) * (math.pi * (0.005555555555555556 * (a * angle))))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 8.7e+27) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(Float64(pi * 0.005555555555555556) * Float64(Float64(a * angle) * Float64(pi * Float64(0.005555555555555556 * Float64(a * angle)))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 8.7e+27) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + ((pi * 0.005555555555555556) * ((a * angle) * (pi * (0.005555555555555556 * (a * angle))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 8.7e+27], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * N[(N[(a * angle), $MachinePrecision] * N[(Pi * N[(0.005555555555555556 * N[(a * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 8.7 \cdot 10^{+27}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + \left(\pi \cdot 0.005555555555555556\right) \cdot \left(\left(a \cdot angle\right) \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot \left(a \cdot angle\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 8.7000000000000004e27Initial program 78.9%
associate-*l/78.4%
associate-/l*78.9%
cos-neg78.9%
distribute-lft-neg-out78.9%
distribute-frac-neg78.9%
distribute-frac-neg78.9%
distribute-lft-neg-out78.9%
cos-neg78.9%
associate-*l/78.5%
associate-/l*79.0%
Simplified79.0%
Taylor expanded in angle around 0 78.8%
Taylor expanded in angle around 0 73.2%
*-commutative73.2%
*-commutative73.2%
associate-*l*73.2%
Simplified73.2%
Taylor expanded in angle around 0 66.0%
if 8.7000000000000004e27 < a Initial program 88.6%
associate-*l/88.8%
associate-/l*88.9%
cos-neg88.9%
distribute-lft-neg-out88.9%
distribute-frac-neg88.9%
distribute-frac-neg88.9%
distribute-lft-neg-out88.9%
cos-neg88.9%
associate-*l/89.0%
associate-/l*88.9%
Simplified88.9%
Taylor expanded in angle around 0 88.9%
Taylor expanded in angle around 0 85.7%
*-commutative85.7%
*-commutative85.7%
associate-*l*85.6%
Simplified85.6%
unpow285.6%
associate-*r*85.7%
*-commutative85.7%
associate-*l*85.7%
associate-*r*85.8%
*-commutative85.8%
associate-*l*85.7%
Applied egg-rr85.7%
Final simplification70.1%
(FPCore (a b angle)
:precision binary64
(if (<= a 2.2e+27)
(pow b 2.0)
(+
(pow b 2.0)
(*
(* angle (* a PI))
(* 0.005555555555555556 (* PI (* 0.005555555555555556 (* a angle))))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 2.2e+27) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + ((angle * (a * ((double) M_PI))) * (0.005555555555555556 * (((double) M_PI) * (0.005555555555555556 * (a * angle)))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 2.2e+27) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + ((angle * (a * Math.PI)) * (0.005555555555555556 * (Math.PI * (0.005555555555555556 * (a * angle)))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 2.2e+27: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + ((angle * (a * math.pi)) * (0.005555555555555556 * (math.pi * (0.005555555555555556 * (a * angle))))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 2.2e+27) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(Float64(angle * Float64(a * pi)) * Float64(0.005555555555555556 * Float64(pi * Float64(0.005555555555555556 * Float64(a * angle)))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 2.2e+27) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + ((angle * (a * pi)) * (0.005555555555555556 * (pi * (0.005555555555555556 * (a * angle))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 2.2e+27], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(angle * N[(a * Pi), $MachinePrecision]), $MachinePrecision] * N[(0.005555555555555556 * N[(Pi * N[(0.005555555555555556 * N[(a * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.2 \cdot 10^{+27}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + \left(angle \cdot \left(a \cdot \pi\right)\right) \cdot \left(0.005555555555555556 \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot \left(a \cdot angle\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 2.1999999999999999e27Initial program 78.9%
associate-*l/78.4%
associate-/l*78.9%
cos-neg78.9%
distribute-lft-neg-out78.9%
distribute-frac-neg78.9%
distribute-frac-neg78.9%
distribute-lft-neg-out78.9%
cos-neg78.9%
associate-*l/78.5%
associate-/l*79.0%
Simplified79.0%
Taylor expanded in angle around 0 78.8%
Taylor expanded in angle around 0 73.2%
*-commutative73.2%
*-commutative73.2%
associate-*l*73.2%
Simplified73.2%
Taylor expanded in angle around 0 66.0%
if 2.1999999999999999e27 < a Initial program 88.6%
associate-*l/88.8%
associate-/l*88.9%
cos-neg88.9%
distribute-lft-neg-out88.9%
distribute-frac-neg88.9%
distribute-frac-neg88.9%
distribute-lft-neg-out88.9%
cos-neg88.9%
associate-*l/89.0%
associate-/l*88.9%
Simplified88.9%
Taylor expanded in angle around 0 88.9%
Taylor expanded in angle around 0 85.7%
*-commutative85.7%
*-commutative85.7%
associate-*l*85.6%
Simplified85.6%
unpow285.6%
associate-*r*85.7%
associate-*r*85.7%
*-commutative85.7%
associate-*l*85.7%
associate-*r*85.7%
*-commutative85.7%
associate-*l*85.7%
Applied egg-rr85.7%
Final simplification70.1%
(FPCore (a b angle)
:precision binary64
(if (<= a 3.5e+27)
(pow b 2.0)
(+
(pow b 2.0)
(*
0.005555555555555556
(* (* PI (* 0.005555555555555556 (* a angle))) (* angle (* a PI)))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 3.5e+27) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + (0.005555555555555556 * ((((double) M_PI) * (0.005555555555555556 * (a * angle))) * (angle * (a * ((double) M_PI)))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 3.5e+27) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + (0.005555555555555556 * ((Math.PI * (0.005555555555555556 * (a * angle))) * (angle * (a * Math.PI))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 3.5e+27: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + (0.005555555555555556 * ((math.pi * (0.005555555555555556 * (a * angle))) * (angle * (a * math.pi)))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 3.5e+27) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(0.005555555555555556 * Float64(Float64(pi * Float64(0.005555555555555556 * Float64(a * angle))) * Float64(angle * Float64(a * pi))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 3.5e+27) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + (0.005555555555555556 * ((pi * (0.005555555555555556 * (a * angle))) * (angle * (a * pi)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 3.5e+27], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(0.005555555555555556 * N[(N[(Pi * N[(0.005555555555555556 * N[(a * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(angle * N[(a * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.5 \cdot 10^{+27}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + 0.005555555555555556 \cdot \left(\left(\pi \cdot \left(0.005555555555555556 \cdot \left(a \cdot angle\right)\right)\right) \cdot \left(angle \cdot \left(a \cdot \pi\right)\right)\right)\\
\end{array}
\end{array}
if a < 3.5000000000000002e27Initial program 78.9%
associate-*l/78.4%
associate-/l*78.9%
cos-neg78.9%
distribute-lft-neg-out78.9%
distribute-frac-neg78.9%
distribute-frac-neg78.9%
distribute-lft-neg-out78.9%
cos-neg78.9%
associate-*l/78.5%
associate-/l*79.0%
Simplified79.0%
Taylor expanded in angle around 0 78.8%
Taylor expanded in angle around 0 73.2%
*-commutative73.2%
*-commutative73.2%
associate-*l*73.2%
Simplified73.2%
Taylor expanded in angle around 0 66.0%
if 3.5000000000000002e27 < a Initial program 88.6%
associate-*l/88.8%
associate-/l*88.9%
cos-neg88.9%
distribute-lft-neg-out88.9%
distribute-frac-neg88.9%
distribute-frac-neg88.9%
distribute-lft-neg-out88.9%
cos-neg88.9%
associate-*l/89.0%
associate-/l*88.9%
Simplified88.9%
Taylor expanded in angle around 0 88.9%
Taylor expanded in angle around 0 85.7%
*-commutative85.7%
*-commutative85.7%
associate-*l*85.6%
Simplified85.6%
unpow285.6%
*-commutative85.6%
associate-*r*85.7%
associate-*r*85.7%
*-commutative85.7%
associate-*l*85.7%
associate-*r*85.7%
*-commutative85.7%
associate-*l*85.8%
Applied egg-rr85.8%
Final simplification70.1%
(FPCore (a b angle) :precision binary64 (if (<= a 3.1e+152) (pow b 2.0) (pow (* (* PI 0.005555555555555556) (* a angle)) 2.0)))
double code(double a, double b, double angle) {
double tmp;
if (a <= 3.1e+152) {
tmp = pow(b, 2.0);
} else {
tmp = pow(((((double) M_PI) * 0.005555555555555556) * (a * angle)), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 3.1e+152) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(((Math.PI * 0.005555555555555556) * (a * angle)), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 3.1e+152: tmp = math.pow(b, 2.0) else: tmp = math.pow(((math.pi * 0.005555555555555556) * (a * angle)), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 3.1e+152) tmp = b ^ 2.0; else tmp = Float64(Float64(pi * 0.005555555555555556) * Float64(a * angle)) ^ 2.0; end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 3.1e+152) tmp = b ^ 2.0; else tmp = ((pi * 0.005555555555555556) * (a * angle)) ^ 2.0; end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 3.1e+152], N[Power[b, 2.0], $MachinePrecision], N[Power[N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * N[(a * angle), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.1 \cdot 10^{+152}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{\left(\left(\pi \cdot 0.005555555555555556\right) \cdot \left(a \cdot angle\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 3.1e152Initial program 78.4%
associate-*l/78.0%
associate-/l*78.4%
cos-neg78.4%
distribute-lft-neg-out78.4%
distribute-frac-neg78.4%
distribute-frac-neg78.4%
distribute-lft-neg-out78.4%
cos-neg78.4%
associate-*l/78.1%
associate-/l*78.5%
Simplified78.5%
Taylor expanded in angle around 0 78.4%
Taylor expanded in angle around 0 72.6%
*-commutative72.6%
*-commutative72.6%
associate-*l*72.6%
Simplified72.6%
Taylor expanded in angle around 0 63.3%
if 3.1e152 < a Initial program 99.7%
associate-*l/99.7%
associate-/l*99.7%
cos-neg99.7%
distribute-lft-neg-out99.7%
distribute-frac-neg99.7%
distribute-frac-neg99.7%
distribute-lft-neg-out99.7%
cos-neg99.7%
associate-*l/99.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in angle around 0 99.7%
Taylor expanded in angle around 0 99.7%
*-commutative99.7%
*-commutative99.7%
associate-*l*99.6%
Simplified99.6%
add-cube-cbrt99.0%
pow399.1%
Applied egg-rr99.1%
Taylor expanded in angle around inf 64.0%
associate-*r*64.0%
unpow264.0%
unpow264.0%
swap-sqr86.9%
*-commutative86.9%
*-commutative86.9%
unpow286.9%
swap-sqr86.9%
*-commutative86.9%
*-commutative86.9%
metadata-eval86.9%
swap-sqr86.9%
unpow286.9%
associate-*r*87.0%
*-commutative87.0%
Simplified87.0%
Final simplification66.1%
(FPCore (a b angle) :precision binary64 (pow b 2.0))
double code(double a, double b, double angle) {
return pow(b, 2.0);
}
real(8) function code(a, b, angle)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = b ** 2.0d0
end function
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0);
}
def code(a, b, angle): return math.pow(b, 2.0)
function code(a, b, angle) return b ^ 2.0 end
function tmp = code(a, b, angle) tmp = b ^ 2.0; end
code[a_, b_, angle_] := N[Power[b, 2.0], $MachinePrecision]
\begin{array}{l}
\\
{b}^{2}
\end{array}
Initial program 80.9%
associate-*l/80.5%
associate-/l*80.9%
cos-neg80.9%
distribute-lft-neg-out80.9%
distribute-frac-neg80.9%
distribute-frac-neg80.9%
distribute-lft-neg-out80.9%
cos-neg80.9%
associate-*l/80.6%
associate-/l*81.0%
Simplified81.0%
Taylor expanded in angle around 0 80.9%
Taylor expanded in angle around 0 75.8%
*-commutative75.8%
*-commutative75.8%
associate-*l*75.8%
Simplified75.8%
Taylor expanded in angle around 0 58.2%
Final simplification58.2%
herbie shell --seed 2024055
(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)))