
(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}
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* angle (* PI 0.005555555555555556))) (t_1 (cos t_0))) (+ (pow (* (sin t_0) a) 2.0) (* b (* t_1 (* b t_1))))))
double code(double a, double b, double angle) {
double t_0 = angle * (((double) M_PI) * 0.005555555555555556);
double t_1 = cos(t_0);
return pow((sin(t_0) * a), 2.0) + (b * (t_1 * (b * t_1)));
}
public static double code(double a, double b, double angle) {
double t_0 = angle * (Math.PI * 0.005555555555555556);
double t_1 = Math.cos(t_0);
return Math.pow((Math.sin(t_0) * a), 2.0) + (b * (t_1 * (b * t_1)));
}
def code(a, b, angle): t_0 = angle * (math.pi * 0.005555555555555556) t_1 = math.cos(t_0) return math.pow((math.sin(t_0) * a), 2.0) + (b * (t_1 * (b * t_1)))
function code(a, b, angle) t_0 = Float64(angle * Float64(pi * 0.005555555555555556)) t_1 = cos(t_0) return Float64((Float64(sin(t_0) * a) ^ 2.0) + Float64(b * Float64(t_1 * Float64(b * t_1)))) end
function tmp = code(a, b, angle) t_0 = angle * (pi * 0.005555555555555556); t_1 = cos(t_0); tmp = ((sin(t_0) * a) ^ 2.0) + (b * (t_1 * (b * t_1))); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[t$95$0], $MachinePrecision]}, N[(N[Power[N[(N[Sin[t$95$0], $MachinePrecision] * a), $MachinePrecision], 2.0], $MachinePrecision] + N[(b * N[(t$95$1 * N[(b * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := angle \cdot \left(\pi \cdot 0.005555555555555556\right)\\
t_1 := \cos t\_0\\
{\left(\sin t\_0 \cdot a\right)}^{2} + b \cdot \left(t\_1 \cdot \left(b \cdot t\_1\right)\right)
\end{array}
\end{array}
Initial program 80.4%
associate-*l/80.5%
associate-/l*80.5%
cos-neg80.5%
distribute-lft-neg-out80.5%
distribute-frac-neg80.5%
distribute-frac-neg80.5%
distribute-lft-neg-out80.5%
cos-neg80.5%
associate-*l/80.4%
associate-/l*80.5%
Simplified80.5%
unpow280.5%
associate-*r*80.1%
*-commutative80.1%
div-inv80.1%
metadata-eval80.1%
div-inv80.1%
metadata-eval80.1%
Applied egg-rr80.1%
associate-*l*80.5%
*-commutative80.5%
unpow280.5%
Applied egg-rr80.5%
unpow280.5%
*-commutative80.5%
associate-*r*80.5%
div-inv80.5%
metadata-eval80.5%
div-inv80.5%
metadata-eval80.5%
Applied egg-rr80.5%
Final simplification80.5%
(FPCore (a b angle) :precision binary64 (+ (pow (* b (cos (* angle (/ PI 180.0)))) 2.0) (pow (* a (sin (* 0.005555555555555556 (* angle PI)))) 2.0)))
double code(double a, double b, double angle) {
return pow((b * cos((angle * (((double) M_PI) / 180.0)))), 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 * Math.cos((angle * (Math.PI / 180.0)))), 2.0) + Math.pow((a * Math.sin((0.005555555555555556 * (angle * Math.PI)))), 2.0);
}
def code(a, b, angle): return math.pow((b * math.cos((angle * (math.pi / 180.0)))), 2.0) + math.pow((a * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0)
function code(a, b, angle) return Float64((Float64(b * cos(Float64(angle * Float64(pi / 180.0)))) ^ 2.0) + (Float64(a * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((b * cos((angle * (pi / 180.0)))) ^ 2.0) + ((a * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(b * N[Cos[N[(angle * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 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}
\\
{\left(b \cdot \cos \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2} + {\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}
\end{array}
Initial program 80.4%
associate-*l/80.5%
associate-/l*80.5%
cos-neg80.5%
distribute-lft-neg-out80.5%
distribute-frac-neg80.5%
distribute-frac-neg80.5%
distribute-lft-neg-out80.5%
cos-neg80.5%
associate-*l/80.4%
associate-/l*80.5%
Simplified80.5%
Taylor expanded in angle around inf 80.4%
Final simplification80.4%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* angle (/ PI 180.0)))) 2.0) (pow (* b (cos (* 0.005555555555555556 (* angle PI)))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin((angle * (((double) M_PI) / 180.0)))), 2.0) + pow((b * cos((0.005555555555555556 * (angle * ((double) M_PI))))), 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.cos((0.005555555555555556 * (angle * Math.PI)))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin((angle * (math.pi / 180.0)))), 2.0) + math.pow((b * math.cos((0.005555555555555556 * (angle * math.pi)))), 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(angle * Float64(pi / 180.0)))) ^ 2.0) + (Float64(b * cos(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin((angle * (pi / 180.0)))) ^ 2.0) + ((b * cos((0.005555555555555556 * (angle * pi)))) ^ 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[Cos[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $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 \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}
\end{array}
Initial program 80.4%
associate-*l/80.5%
associate-/l*80.5%
cos-neg80.5%
distribute-lft-neg-out80.5%
distribute-frac-neg80.5%
distribute-frac-neg80.5%
distribute-lft-neg-out80.5%
cos-neg80.5%
associate-*l/80.4%
associate-/l*80.5%
Simplified80.5%
Taylor expanded in angle around inf 80.4%
Final simplification80.4%
(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.4%
associate-*l/80.5%
associate-/l*80.5%
cos-neg80.5%
distribute-lft-neg-out80.5%
distribute-frac-neg80.5%
distribute-frac-neg80.5%
distribute-lft-neg-out80.5%
cos-neg80.5%
associate-*l/80.4%
associate-/l*80.5%
Simplified80.5%
Final simplification80.5%
(FPCore (a b angle) :precision binary64 (+ (pow (* (sin (* angle (* PI 0.005555555555555556))) a) 2.0) (pow b 2.0)))
double code(double a, double b, double angle) {
return pow((sin((angle * (((double) M_PI) * 0.005555555555555556))) * a), 2.0) + pow(b, 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((Math.sin((angle * (Math.PI * 0.005555555555555556))) * a), 2.0) + Math.pow(b, 2.0);
}
def code(a, b, angle): return math.pow((math.sin((angle * (math.pi * 0.005555555555555556))) * a), 2.0) + math.pow(b, 2.0)
function code(a, b, angle) return Float64((Float64(sin(Float64(angle * Float64(pi * 0.005555555555555556))) * a) ^ 2.0) + (b ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((sin((angle * (pi * 0.005555555555555556))) * a) ^ 2.0) + (b ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(N[Sin[N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right) \cdot a\right)}^{2} + {b}^{2}
\end{array}
Initial program 80.4%
associate-*l/80.5%
associate-/l*80.5%
cos-neg80.5%
distribute-lft-neg-out80.5%
distribute-frac-neg80.5%
distribute-frac-neg80.5%
distribute-lft-neg-out80.5%
cos-neg80.5%
associate-*l/80.4%
associate-/l*80.5%
Simplified80.5%
unpow280.5%
associate-*r*80.1%
*-commutative80.1%
div-inv80.1%
metadata-eval80.1%
div-inv80.1%
metadata-eval80.1%
Applied egg-rr80.1%
associate-*l*80.5%
*-commutative80.5%
unpow280.5%
Applied egg-rr80.5%
Taylor expanded in angle around 0 80.1%
Final simplification80.1%
(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(Float64(angle * 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[(N[(angle * Pi), $MachinePrecision] / 180.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} + {b}^{2}
\end{array}
Initial program 80.4%
associate-*l/80.5%
associate-/l*80.5%
cos-neg80.5%
distribute-lft-neg-out80.5%
distribute-frac-neg80.5%
distribute-frac-neg80.5%
distribute-lft-neg-out80.5%
cos-neg80.5%
associate-*l/80.4%
associate-/l*80.5%
Simplified80.5%
Taylor expanded in angle around 0 80.1%
associate-*r/80.1%
Applied egg-rr80.1%
Final simplification80.1%
(FPCore (a b angle) :precision binary64 (if (<= a 2e+35) (pow b 2.0) (fma b b (* 3.08641975308642e-5 (pow (* angle (* PI a)) 2.0)))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 2e+35) {
tmp = pow(b, 2.0);
} else {
tmp = fma(b, b, (3.08641975308642e-5 * pow((angle * (((double) M_PI) * a)), 2.0)));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 2e+35) tmp = b ^ 2.0; else tmp = fma(b, b, Float64(3.08641975308642e-5 * (Float64(angle * Float64(pi * a)) ^ 2.0))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 2e+35], N[Power[b, 2.0], $MachinePrecision], N[(b * b + N[(3.08641975308642e-5 * N[Power[N[(angle * N[(Pi * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2 \cdot 10^{+35}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, b, 3.08641975308642 \cdot 10^{-5} \cdot {\left(angle \cdot \left(\pi \cdot a\right)\right)}^{2}\right)\\
\end{array}
\end{array}
if a < 1.9999999999999999e35Initial program 79.1%
associate-*l/79.2%
associate-/l*79.2%
cos-neg79.2%
distribute-lft-neg-out79.2%
distribute-frac-neg79.2%
distribute-frac-neg79.2%
distribute-lft-neg-out79.2%
cos-neg79.2%
associate-*l/79.1%
associate-/l*79.2%
Simplified79.2%
Taylor expanded in angle around 0 78.7%
Taylor expanded in angle around 0 72.2%
*-commutative72.2%
*-commutative72.2%
associate-*l*72.2%
Simplified72.2%
Taylor expanded in angle around 0 64.1%
if 1.9999999999999999e35 < a Initial program 85.6%
associate-*l/85.4%
associate-/l*85.4%
cos-neg85.4%
distribute-lft-neg-out85.4%
distribute-frac-neg85.4%
distribute-frac-neg85.4%
distribute-lft-neg-out85.4%
cos-neg85.4%
associate-*l/85.4%
associate-/l*85.4%
Simplified85.4%
Taylor expanded in angle around 0 85.3%
Taylor expanded in angle around 0 82.2%
*-commutative82.2%
*-commutative82.2%
associate-*l*82.1%
Simplified82.1%
+-commutative82.1%
*-rgt-identity82.1%
pow282.1%
fma-define82.1%
unpow-prod-down82.1%
metadata-eval82.1%
associate-*r*82.2%
*-commutative82.2%
associate-*l*82.2%
Applied egg-rr82.2%
Final simplification67.8%
(FPCore (a b angle)
:precision binary64
(if (<= a 2e+35)
(pow b 2.0)
(+
(pow b 2.0)
(*
(* PI 0.005555555555555556)
(* (* angle (* PI (* 0.005555555555555556 a))) (* angle a))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 2e+35) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + ((((double) M_PI) * 0.005555555555555556) * ((angle * (((double) M_PI) * (0.005555555555555556 * a))) * (angle * a)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 2e+35) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + ((Math.PI * 0.005555555555555556) * ((angle * (Math.PI * (0.005555555555555556 * a))) * (angle * a)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 2e+35: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + ((math.pi * 0.005555555555555556) * ((angle * (math.pi * (0.005555555555555556 * a))) * (angle * a))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 2e+35) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(Float64(pi * 0.005555555555555556) * Float64(Float64(angle * Float64(pi * Float64(0.005555555555555556 * a))) * Float64(angle * a)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 2e+35) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + ((pi * 0.005555555555555556) * ((angle * (pi * (0.005555555555555556 * a))) * (angle * a))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 2e+35], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * N[(N[(angle * N[(Pi * N[(0.005555555555555556 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(angle * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2 \cdot 10^{+35}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + \left(\pi \cdot 0.005555555555555556\right) \cdot \left(\left(angle \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot a\right)\right)\right) \cdot \left(angle \cdot a\right)\right)\\
\end{array}
\end{array}
if a < 1.9999999999999999e35Initial program 79.1%
associate-*l/79.2%
associate-/l*79.2%
cos-neg79.2%
distribute-lft-neg-out79.2%
distribute-frac-neg79.2%
distribute-frac-neg79.2%
distribute-lft-neg-out79.2%
cos-neg79.2%
associate-*l/79.1%
associate-/l*79.2%
Simplified79.2%
Taylor expanded in angle around 0 78.7%
Taylor expanded in angle around 0 72.2%
*-commutative72.2%
*-commutative72.2%
associate-*l*72.2%
Simplified72.2%
Taylor expanded in angle around 0 64.1%
if 1.9999999999999999e35 < a Initial program 85.6%
associate-*l/85.4%
associate-/l*85.4%
cos-neg85.4%
distribute-lft-neg-out85.4%
distribute-frac-neg85.4%
distribute-frac-neg85.4%
distribute-lft-neg-out85.4%
cos-neg85.4%
associate-*l/85.4%
associate-/l*85.4%
Simplified85.4%
Taylor expanded in angle around 0 85.3%
Taylor expanded in angle around 0 82.2%
*-commutative82.2%
*-commutative82.2%
associate-*l*82.1%
Simplified82.1%
unpow282.1%
associate-*r*82.1%
*-commutative82.1%
metadata-eval82.1%
div-inv82.1%
associate-*l*82.1%
div-inv82.1%
metadata-eval82.1%
*-commutative82.1%
*-commutative82.1%
associate-*l*82.1%
metadata-eval82.1%
div-inv82.1%
associate-*r*82.2%
clear-num82.2%
div-inv82.3%
associate-/r/82.2%
*-commutative82.2%
div-inv82.2%
metadata-eval82.2%
Applied egg-rr82.2%
Final simplification67.8%
(FPCore (a b angle)
:precision binary64
(if (<= a 2e+35)
(pow b 2.0)
(+
(pow b 2.0)
(*
(* angle (* PI a))
(* 0.005555555555555556 (* angle (* PI (* 0.005555555555555556 a))))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 2e+35) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + ((angle * (((double) M_PI) * a)) * (0.005555555555555556 * (angle * (((double) M_PI) * (0.005555555555555556 * a)))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 2e+35) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + ((angle * (Math.PI * a)) * (0.005555555555555556 * (angle * (Math.PI * (0.005555555555555556 * a)))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 2e+35: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + ((angle * (math.pi * a)) * (0.005555555555555556 * (angle * (math.pi * (0.005555555555555556 * a))))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 2e+35) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(Float64(angle * Float64(pi * a)) * Float64(0.005555555555555556 * Float64(angle * Float64(pi * Float64(0.005555555555555556 * a)))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 2e+35) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + ((angle * (pi * a)) * (0.005555555555555556 * (angle * (pi * (0.005555555555555556 * a))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 2e+35], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(angle * N[(Pi * a), $MachinePrecision]), $MachinePrecision] * N[(0.005555555555555556 * N[(angle * N[(Pi * N[(0.005555555555555556 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2 \cdot 10^{+35}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + \left(angle \cdot \left(\pi \cdot a\right)\right) \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \left(\pi \cdot \left(0.005555555555555556 \cdot a\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.9999999999999999e35Initial program 79.1%
associate-*l/79.2%
associate-/l*79.2%
cos-neg79.2%
distribute-lft-neg-out79.2%
distribute-frac-neg79.2%
distribute-frac-neg79.2%
distribute-lft-neg-out79.2%
cos-neg79.2%
associate-*l/79.1%
associate-/l*79.2%
Simplified79.2%
Taylor expanded in angle around 0 78.7%
Taylor expanded in angle around 0 72.2%
*-commutative72.2%
*-commutative72.2%
associate-*l*72.2%
Simplified72.2%
Taylor expanded in angle around 0 64.1%
if 1.9999999999999999e35 < a Initial program 85.6%
associate-*l/85.4%
associate-/l*85.4%
cos-neg85.4%
distribute-lft-neg-out85.4%
distribute-frac-neg85.4%
distribute-frac-neg85.4%
distribute-lft-neg-out85.4%
cos-neg85.4%
associate-*l/85.4%
associate-/l*85.4%
Simplified85.4%
Taylor expanded in angle around 0 85.3%
Taylor expanded in angle around 0 82.2%
*-commutative82.2%
*-commutative82.2%
associate-*l*82.1%
Simplified82.1%
unpow282.1%
associate-*r*82.1%
*-commutative82.1%
*-commutative82.1%
associate-*l*82.1%
metadata-eval82.1%
div-inv82.1%
associate-*r*82.1%
clear-num82.1%
div-inv82.2%
associate-/r/82.1%
*-commutative82.1%
div-inv82.1%
metadata-eval82.1%
associate-*r*82.1%
*-commutative82.1%
associate-*l*82.2%
Applied egg-rr82.2%
Final simplification67.8%
(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.4%
associate-*l/80.5%
associate-/l*80.5%
cos-neg80.5%
distribute-lft-neg-out80.5%
distribute-frac-neg80.5%
distribute-frac-neg80.5%
distribute-lft-neg-out80.5%
cos-neg80.5%
associate-*l/80.4%
associate-/l*80.5%
Simplified80.5%
Taylor expanded in angle around 0 80.1%
Taylor expanded in angle around 0 74.3%
*-commutative74.3%
*-commutative74.3%
associate-*l*74.3%
Simplified74.3%
Taylor expanded in angle around 0 57.6%
Final simplification57.6%
herbie shell --seed 2024067
(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)))