
(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}
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (/ 1.0 (/ 180.0 (* angle PI))))) 2.0) (* b b)))
double code(double a, double b, double angle) {
return pow((a * sin((1.0 / (180.0 / (angle * ((double) M_PI)))))), 2.0) + (b * b);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((1.0 / (180.0 / (angle * Math.PI))))), 2.0) + (b * b);
}
def code(a, b, angle): return math.pow((a * math.sin((1.0 / (180.0 / (angle * math.pi))))), 2.0) + (b * b)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(1.0 / Float64(180.0 / Float64(angle * pi))))) ^ 2.0) + Float64(b * b)) end
function tmp = code(a, b, angle) tmp = ((a * sin((1.0 / (180.0 / (angle * pi))))) ^ 2.0) + (b * b); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(1.0 / N[(180.0 / N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\frac{1}{\frac{180}{angle \cdot \pi}}\right)\right)}^{2} + b \cdot b
\end{array}
Initial program 80.2%
associate-*l/80.1%
associate-/l*80.2%
cos-neg80.2%
distribute-lft-neg-out80.2%
distribute-frac-neg80.2%
distribute-frac-neg80.2%
distribute-lft-neg-out80.2%
cos-neg80.2%
associate-*l/80.1%
associate-/l*80.1%
Simplified80.1%
Taylor expanded in angle around 0 80.6%
associate-*r/80.5%
clear-num80.6%
Applied egg-rr80.6%
*-rgt-identity80.6%
unpow280.6%
Applied egg-rr80.6%
(FPCore (a b angle) :precision binary64 (if (<= b 1.95e-156) (pow (* a (sin (* PI (* angle 0.005555555555555556)))) 2.0) (+ (pow b 2.0) (* 3.08641975308642e-5 (pow (* a (* angle PI)) 2.0)))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.95e-156) {
tmp = pow((a * sin((((double) M_PI) * (angle * 0.005555555555555556)))), 2.0);
} else {
tmp = pow(b, 2.0) + (3.08641975308642e-5 * pow((a * (angle * ((double) M_PI))), 2.0));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 1.95e-156) {
tmp = Math.pow((a * Math.sin((Math.PI * (angle * 0.005555555555555556)))), 2.0);
} else {
tmp = Math.pow(b, 2.0) + (3.08641975308642e-5 * Math.pow((a * (angle * Math.PI)), 2.0));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 1.95e-156: tmp = math.pow((a * math.sin((math.pi * (angle * 0.005555555555555556)))), 2.0) else: tmp = math.pow(b, 2.0) + (3.08641975308642e-5 * math.pow((a * (angle * math.pi)), 2.0)) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 1.95e-156) tmp = Float64(a * sin(Float64(pi * Float64(angle * 0.005555555555555556)))) ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(3.08641975308642e-5 * (Float64(a * Float64(angle * pi)) ^ 2.0))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 1.95e-156) tmp = (a * sin((pi * (angle * 0.005555555555555556)))) ^ 2.0; else tmp = (b ^ 2.0) + (3.08641975308642e-5 * ((a * (angle * pi)) ^ 2.0)); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 1.95e-156], N[Power[N[(a * N[Sin[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(3.08641975308642e-5 * N[Power[N[(a * N[(angle * Pi), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.95 \cdot 10^{-156}:\\
\;\;\;\;{\left(a \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + 3.08641975308642 \cdot 10^{-5} \cdot {\left(a \cdot \left(angle \cdot \pi\right)\right)}^{2}\\
\end{array}
\end{array}
if b < 1.9500000000000001e-156Initial program 78.0%
associate-*l/77.9%
associate-/l*77.9%
cos-neg77.9%
distribute-lft-neg-out77.9%
distribute-frac-neg77.9%
distribute-frac-neg77.9%
distribute-lft-neg-out77.9%
cos-neg77.9%
associate-*l/77.8%
associate-/l*77.8%
Simplified77.8%
Taylor expanded in a around inf 37.4%
unpow237.4%
*-commutative37.4%
associate-*r*37.5%
unpow237.5%
swap-sqr39.5%
unpow239.5%
associate-*r*39.4%
*-commutative39.4%
associate-*r*39.5%
Simplified39.5%
if 1.9500000000000001e-156 < b Initial program 83.4%
associate-*l/83.4%
associate-/l*83.5%
cos-neg83.5%
distribute-lft-neg-out83.5%
distribute-frac-neg83.5%
distribute-frac-neg83.5%
distribute-lft-neg-out83.5%
cos-neg83.5%
associate-*l/83.4%
associate-/l*83.4%
Simplified83.4%
Taylor expanded in angle around 0 84.7%
Taylor expanded in angle around 0 73.7%
fma-define73.7%
unpow273.7%
unpow273.7%
swap-sqr73.7%
unpow273.7%
Simplified73.7%
fma-undefine73.7%
*-rgt-identity73.7%
+-commutative73.7%
*-rgt-identity73.7%
pow-prod-down82.4%
Applied egg-rr82.4%
Final simplification56.9%
(FPCore (a b angle) :precision binary64 (if (<= b 6.8e-157) (pow (* a (sin (* PI (* angle 0.005555555555555556)))) 2.0) (+ (* b b) (pow (* a (* (* angle PI) 0.005555555555555556)) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 6.8e-157) {
tmp = pow((a * sin((((double) M_PI) * (angle * 0.005555555555555556)))), 2.0);
} else {
tmp = (b * b) + pow((a * ((angle * ((double) M_PI)) * 0.005555555555555556)), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 6.8e-157) {
tmp = Math.pow((a * Math.sin((Math.PI * (angle * 0.005555555555555556)))), 2.0);
} else {
tmp = (b * b) + Math.pow((a * ((angle * Math.PI) * 0.005555555555555556)), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 6.8e-157: tmp = math.pow((a * math.sin((math.pi * (angle * 0.005555555555555556)))), 2.0) else: tmp = (b * b) + math.pow((a * ((angle * math.pi) * 0.005555555555555556)), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 6.8e-157) tmp = Float64(a * sin(Float64(pi * Float64(angle * 0.005555555555555556)))) ^ 2.0; else tmp = Float64(Float64(b * b) + (Float64(a * Float64(Float64(angle * pi) * 0.005555555555555556)) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 6.8e-157) tmp = (a * sin((pi * (angle * 0.005555555555555556)))) ^ 2.0; else tmp = (b * b) + ((a * ((angle * pi) * 0.005555555555555556)) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 6.8e-157], N[Power[N[(a * N[Sin[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[(b * b), $MachinePrecision] + N[Power[N[(a * N[(N[(angle * Pi), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.8 \cdot 10^{-157}:\\
\;\;\;\;{\left(a \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;b \cdot b + {\left(a \cdot \left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\right)\right)}^{2}\\
\end{array}
\end{array}
if b < 6.79999999999999955e-157Initial program 78.0%
associate-*l/77.9%
associate-/l*77.9%
cos-neg77.9%
distribute-lft-neg-out77.9%
distribute-frac-neg77.9%
distribute-frac-neg77.9%
distribute-lft-neg-out77.9%
cos-neg77.9%
associate-*l/77.8%
associate-/l*77.8%
Simplified77.8%
Taylor expanded in a around inf 37.4%
unpow237.4%
*-commutative37.4%
associate-*r*37.5%
unpow237.5%
swap-sqr39.5%
unpow239.5%
associate-*r*39.4%
*-commutative39.4%
associate-*r*39.5%
Simplified39.5%
if 6.79999999999999955e-157 < b Initial program 83.4%
associate-*l/83.4%
associate-/l*83.5%
cos-neg83.5%
distribute-lft-neg-out83.5%
distribute-frac-neg83.5%
distribute-frac-neg83.5%
distribute-lft-neg-out83.5%
cos-neg83.5%
associate-*l/83.4%
associate-/l*83.4%
Simplified83.4%
Taylor expanded in angle around 0 84.7%
associate-*r/84.7%
clear-num84.8%
Applied egg-rr84.8%
*-rgt-identity84.8%
unpow284.8%
Applied egg-rr84.8%
Taylor expanded in angle around 0 82.4%
Final simplification56.9%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (* angle PI) 0.005555555555555556)))
(if (<= b 2.4e-157)
(pow (* a (sin t_0)) 2.0)
(+ (* b b) (pow (* a t_0) 2.0)))))
double code(double a, double b, double angle) {
double t_0 = (angle * ((double) M_PI)) * 0.005555555555555556;
double tmp;
if (b <= 2.4e-157) {
tmp = pow((a * sin(t_0)), 2.0);
} else {
tmp = (b * b) + pow((a * t_0), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = (angle * Math.PI) * 0.005555555555555556;
double tmp;
if (b <= 2.4e-157) {
tmp = Math.pow((a * Math.sin(t_0)), 2.0);
} else {
tmp = (b * b) + Math.pow((a * t_0), 2.0);
}
return tmp;
}
def code(a, b, angle): t_0 = (angle * math.pi) * 0.005555555555555556 tmp = 0 if b <= 2.4e-157: tmp = math.pow((a * math.sin(t_0)), 2.0) else: tmp = (b * b) + math.pow((a * t_0), 2.0) return tmp
function code(a, b, angle) t_0 = Float64(Float64(angle * pi) * 0.005555555555555556) tmp = 0.0 if (b <= 2.4e-157) tmp = Float64(a * sin(t_0)) ^ 2.0; else tmp = Float64(Float64(b * b) + (Float64(a * t_0) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = (angle * pi) * 0.005555555555555556; tmp = 0.0; if (b <= 2.4e-157) tmp = (a * sin(t_0)) ^ 2.0; else tmp = (b * b) + ((a * t_0) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle * Pi), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]}, If[LessEqual[b, 2.4e-157], N[Power[N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[(b * b), $MachinePrecision] + N[Power[N[(a * t$95$0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(angle \cdot \pi\right) \cdot 0.005555555555555556\\
\mathbf{if}\;b \leq 2.4 \cdot 10^{-157}:\\
\;\;\;\;{\left(a \cdot \sin t\_0\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;b \cdot b + {\left(a \cdot t\_0\right)}^{2}\\
\end{array}
\end{array}
if b < 2.4e-157Initial program 78.0%
associate-*l/77.9%
associate-/l*77.9%
cos-neg77.9%
distribute-lft-neg-out77.9%
distribute-frac-neg77.9%
distribute-frac-neg77.9%
distribute-lft-neg-out77.9%
cos-neg77.9%
associate-*l/77.8%
associate-/l*77.8%
Simplified77.8%
Taylor expanded in a around inf 37.4%
unpow237.4%
*-commutative37.4%
associate-*r*37.5%
unpow237.5%
swap-sqr39.5%
unpow239.5%
associate-*r*39.4%
*-commutative39.4%
Simplified39.4%
if 2.4e-157 < b Initial program 83.4%
associate-*l/83.4%
associate-/l*83.5%
cos-neg83.5%
distribute-lft-neg-out83.5%
distribute-frac-neg83.5%
distribute-frac-neg83.5%
distribute-lft-neg-out83.5%
cos-neg83.5%
associate-*l/83.4%
associate-/l*83.4%
Simplified83.4%
Taylor expanded in angle around 0 84.7%
associate-*r/84.7%
clear-num84.8%
Applied egg-rr84.8%
*-rgt-identity84.8%
unpow284.8%
Applied egg-rr84.8%
Taylor expanded in angle around 0 82.4%
Final simplification56.9%
(FPCore (a b angle) :precision binary64 (+ (* b b) (pow (* a (sin (* angle (/ PI 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return (b * b) + pow((a * sin((angle * (((double) M_PI) / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return (b * b) + Math.pow((a * Math.sin((angle * (Math.PI / 180.0)))), 2.0);
}
def code(a, b, angle): return (b * b) + math.pow((a * math.sin((angle * (math.pi / 180.0)))), 2.0)
function code(a, b, angle) return Float64(Float64(b * b) + (Float64(a * sin(Float64(angle * Float64(pi / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (b * b) + ((a * sin((angle * (pi / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(b * b), $MachinePrecision] + N[Power[N[(a * N[Sin[N[(angle * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot b + {\left(a \cdot \sin \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2}
\end{array}
Initial program 80.2%
associate-*l/80.1%
associate-/l*80.2%
cos-neg80.2%
distribute-lft-neg-out80.2%
distribute-frac-neg80.2%
distribute-frac-neg80.2%
distribute-lft-neg-out80.2%
cos-neg80.2%
associate-*l/80.1%
associate-/l*80.1%
Simplified80.1%
Taylor expanded in angle around 0 80.6%
*-rgt-identity80.6%
unpow280.6%
Applied egg-rr80.6%
Final simplification80.6%
(FPCore (a b angle) :precision binary64 (if (<= a 2.5e-133) (pow b 2.0) (+ (* b b) (pow (* a (* (* angle PI) 0.005555555555555556)) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 2.5e-133) {
tmp = pow(b, 2.0);
} else {
tmp = (b * b) + pow((a * ((angle * ((double) M_PI)) * 0.005555555555555556)), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 2.5e-133) {
tmp = Math.pow(b, 2.0);
} else {
tmp = (b * b) + Math.pow((a * ((angle * Math.PI) * 0.005555555555555556)), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 2.5e-133: tmp = math.pow(b, 2.0) else: tmp = (b * b) + math.pow((a * ((angle * math.pi) * 0.005555555555555556)), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 2.5e-133) tmp = b ^ 2.0; else tmp = Float64(Float64(b * b) + (Float64(a * Float64(Float64(angle * pi) * 0.005555555555555556)) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 2.5e-133) tmp = b ^ 2.0; else tmp = (b * b) + ((a * ((angle * pi) * 0.005555555555555556)) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 2.5e-133], N[Power[b, 2.0], $MachinePrecision], N[(N[(b * b), $MachinePrecision] + N[Power[N[(a * N[(N[(angle * Pi), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.5 \cdot 10^{-133}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;b \cdot b + {\left(a \cdot \left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 2.5e-133Initial program 82.2%
associate-*l/82.1%
associate-/l*82.1%
cos-neg82.1%
distribute-lft-neg-out82.1%
distribute-frac-neg82.1%
distribute-frac-neg82.1%
distribute-lft-neg-out82.1%
cos-neg82.1%
associate-*l/82.0%
associate-/l*82.0%
Simplified82.0%
Taylor expanded in angle around 0 67.4%
if 2.5e-133 < a Initial program 77.2%
associate-*l/77.3%
associate-/l*77.3%
cos-neg77.3%
distribute-lft-neg-out77.3%
distribute-frac-neg77.3%
distribute-frac-neg77.3%
distribute-lft-neg-out77.3%
cos-neg77.3%
associate-*l/77.3%
associate-/l*77.4%
Simplified77.4%
Taylor expanded in angle around 0 77.2%
associate-*r/77.1%
clear-num77.1%
Applied egg-rr77.1%
*-rgt-identity77.1%
unpow277.1%
Applied egg-rr77.1%
Taylor expanded in angle around 0 72.4%
Final simplification69.4%
(FPCore (a b angle) :precision binary64 (if (<= a 2.15e+95) (pow b 2.0) (* 3.08641975308642e-5 (* (* angle PI) (* a (* a (* angle PI)))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 2.15e+95) {
tmp = pow(b, 2.0);
} else {
tmp = 3.08641975308642e-5 * ((angle * ((double) M_PI)) * (a * (a * (angle * ((double) M_PI)))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 2.15e+95) {
tmp = Math.pow(b, 2.0);
} else {
tmp = 3.08641975308642e-5 * ((angle * Math.PI) * (a * (a * (angle * Math.PI))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 2.15e+95: tmp = math.pow(b, 2.0) else: tmp = 3.08641975308642e-5 * ((angle * math.pi) * (a * (a * (angle * math.pi)))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 2.15e+95) tmp = b ^ 2.0; else tmp = Float64(3.08641975308642e-5 * Float64(Float64(angle * pi) * Float64(a * Float64(a * Float64(angle * pi))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 2.15e+95) tmp = b ^ 2.0; else tmp = 3.08641975308642e-5 * ((angle * pi) * (a * (a * (angle * pi)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 2.15e+95], N[Power[b, 2.0], $MachinePrecision], N[(3.08641975308642e-5 * N[(N[(angle * Pi), $MachinePrecision] * N[(a * N[(a * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.15 \cdot 10^{+95}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;3.08641975308642 \cdot 10^{-5} \cdot \left(\left(angle \cdot \pi\right) \cdot \left(a \cdot \left(a \cdot \left(angle \cdot \pi\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 2.15e95Initial program 77.8%
associate-*l/77.7%
associate-/l*77.7%
cos-neg77.7%
distribute-lft-neg-out77.7%
distribute-frac-neg77.7%
distribute-frac-neg77.7%
distribute-lft-neg-out77.7%
cos-neg77.7%
associate-*l/77.6%
associate-/l*77.7%
Simplified77.7%
Taylor expanded in angle around 0 62.8%
if 2.15e95 < a Initial program 90.2%
associate-*l/90.1%
associate-/l*90.3%
cos-neg90.3%
distribute-lft-neg-out90.3%
distribute-frac-neg90.3%
distribute-frac-neg90.3%
distribute-lft-neg-out90.3%
cos-neg90.3%
associate-*l/90.3%
associate-/l*90.3%
Simplified90.3%
Taylor expanded in a around inf 65.0%
unpow265.0%
*-commutative65.0%
associate-*r*65.2%
unpow265.2%
swap-sqr71.2%
unpow271.2%
associate-*r*71.1%
*-commutative71.1%
Simplified71.1%
Taylor expanded in angle around 0 68.0%
unpow268.0%
unpow268.0%
unpow268.0%
swap-sqr67.9%
swap-sqr74.0%
unpow274.0%
Simplified74.0%
unpow274.0%
associate-*r*76.0%
Applied egg-rr76.0%
Final simplification65.3%
(FPCore (a b angle) :precision binary64 (* 3.08641975308642e-5 (* (* angle PI) (* a (* a (* angle PI))))))
double code(double a, double b, double angle) {
return 3.08641975308642e-5 * ((angle * ((double) M_PI)) * (a * (a * (angle * ((double) M_PI)))));
}
public static double code(double a, double b, double angle) {
return 3.08641975308642e-5 * ((angle * Math.PI) * (a * (a * (angle * Math.PI))));
}
def code(a, b, angle): return 3.08641975308642e-5 * ((angle * math.pi) * (a * (a * (angle * math.pi))))
function code(a, b, angle) return Float64(3.08641975308642e-5 * Float64(Float64(angle * pi) * Float64(a * Float64(a * Float64(angle * pi))))) end
function tmp = code(a, b, angle) tmp = 3.08641975308642e-5 * ((angle * pi) * (a * (a * (angle * pi)))); end
code[a_, b_, angle_] := N[(3.08641975308642e-5 * N[(N[(angle * Pi), $MachinePrecision] * N[(a * N[(a * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3.08641975308642 \cdot 10^{-5} \cdot \left(\left(angle \cdot \pi\right) \cdot \left(a \cdot \left(a \cdot \left(angle \cdot \pi\right)\right)\right)\right)
\end{array}
Initial program 80.2%
associate-*l/80.1%
associate-/l*80.2%
cos-neg80.2%
distribute-lft-neg-out80.2%
distribute-frac-neg80.2%
distribute-frac-neg80.2%
distribute-lft-neg-out80.2%
cos-neg80.2%
associate-*l/80.1%
associate-/l*80.1%
Simplified80.1%
Taylor expanded in a around inf 34.2%
unpow234.2%
*-commutative34.2%
associate-*r*34.2%
unpow234.2%
swap-sqr36.2%
unpow236.2%
associate-*r*36.2%
*-commutative36.2%
Simplified36.2%
Taylor expanded in angle around 0 34.1%
unpow234.1%
unpow234.1%
unpow234.1%
swap-sqr34.1%
swap-sqr34.0%
unpow234.0%
Simplified34.0%
unpow234.0%
associate-*r*34.8%
Applied egg-rr34.8%
Final simplification34.8%
(FPCore (a b angle) :precision binary64 (* 3.08641975308642e-5 (* (* a angle) (* PI (* a (* angle PI))))))
double code(double a, double b, double angle) {
return 3.08641975308642e-5 * ((a * angle) * (((double) M_PI) * (a * (angle * ((double) M_PI)))));
}
public static double code(double a, double b, double angle) {
return 3.08641975308642e-5 * ((a * angle) * (Math.PI * (a * (angle * Math.PI))));
}
def code(a, b, angle): return 3.08641975308642e-5 * ((a * angle) * (math.pi * (a * (angle * math.pi))))
function code(a, b, angle) return Float64(3.08641975308642e-5 * Float64(Float64(a * angle) * Float64(pi * Float64(a * Float64(angle * pi))))) end
function tmp = code(a, b, angle) tmp = 3.08641975308642e-5 * ((a * angle) * (pi * (a * (angle * pi)))); end
code[a_, b_, angle_] := N[(3.08641975308642e-5 * N[(N[(a * angle), $MachinePrecision] * N[(Pi * N[(a * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3.08641975308642 \cdot 10^{-5} \cdot \left(\left(a \cdot angle\right) \cdot \left(\pi \cdot \left(a \cdot \left(angle \cdot \pi\right)\right)\right)\right)
\end{array}
Initial program 80.2%
associate-*l/80.1%
associate-/l*80.2%
cos-neg80.2%
distribute-lft-neg-out80.2%
distribute-frac-neg80.2%
distribute-frac-neg80.2%
distribute-lft-neg-out80.2%
cos-neg80.2%
associate-*l/80.1%
associate-/l*80.1%
Simplified80.1%
Taylor expanded in a around inf 34.2%
unpow234.2%
*-commutative34.2%
associate-*r*34.2%
unpow234.2%
swap-sqr36.2%
unpow236.2%
associate-*r*36.2%
*-commutative36.2%
Simplified36.2%
Taylor expanded in angle around 0 34.1%
unpow234.1%
unpow234.1%
unpow234.1%
swap-sqr34.1%
swap-sqr34.0%
unpow234.0%
Simplified34.0%
unpow234.0%
associate-*r*34.0%
associate-*l*34.0%
Applied egg-rr34.0%
herbie shell --seed 2024146
(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)))