
(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 (log1p (expm1 (sin (* angle (* PI 0.005555555555555556)))))) 2.0) (pow (* b (cos (/ PI (/ 180.0 angle)))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * log1p(expm1(sin((angle * (((double) M_PI) * 0.005555555555555556)))))), 2.0) + pow((b * cos((((double) M_PI) / (180.0 / angle)))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.log1p(Math.expm1(Math.sin((angle * (Math.PI * 0.005555555555555556)))))), 2.0) + Math.pow((b * Math.cos((Math.PI / (180.0 / angle)))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.log1p(math.expm1(math.sin((angle * (math.pi * 0.005555555555555556)))))), 2.0) + math.pow((b * math.cos((math.pi / (180.0 / angle)))), 2.0)
function code(a, b, angle) return Float64((Float64(a * log1p(expm1(sin(Float64(angle * Float64(pi * 0.005555555555555556)))))) ^ 2.0) + (Float64(b * cos(Float64(pi / Float64(180.0 / angle)))) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Log[1 + N[(Exp[N[Sin[N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[N[(Pi / N[(180.0 / angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{\pi}{\frac{180}{angle}}\right)\right)}^{2}
\end{array}
Initial program 77.5%
*-commutative77.5%
clear-num77.6%
un-div-inv77.7%
Applied egg-rr77.7%
associate-*l/77.6%
div-inv77.6%
metadata-eval77.6%
associate-*r*77.7%
log1p-expm1-u77.7%
Applied egg-rr77.7%
(FPCore (a b angle) :precision binary64 (+ (pow (* b (cos (/ PI (/ 180.0 angle)))) 2.0) (pow (* a (expm1 (log1p (sin (/ angle (/ 180.0 PI)))))) 2.0)))
double code(double a, double b, double angle) {
return pow((b * cos((((double) M_PI) / (180.0 / angle)))), 2.0) + pow((a * expm1(log1p(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 / (180.0 / angle)))), 2.0) + Math.pow((a * Math.expm1(Math.log1p(Math.sin((angle / (180.0 / Math.PI)))))), 2.0);
}
def code(a, b, angle): return math.pow((b * math.cos((math.pi / (180.0 / angle)))), 2.0) + math.pow((a * math.expm1(math.log1p(math.sin((angle / (180.0 / math.pi)))))), 2.0)
function code(a, b, angle) return Float64((Float64(b * cos(Float64(pi / Float64(180.0 / angle)))) ^ 2.0) + (Float64(a * expm1(log1p(sin(Float64(angle / Float64(180.0 / pi)))))) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(b * N[Cos[N[(Pi / N[(180.0 / angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(a * N[(Exp[N[Log[1 + N[Sin[N[(angle / N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(b \cdot \cos \left(\frac{\pi}{\frac{180}{angle}}\right)\right)}^{2} + {\left(a \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\frac{angle}{\frac{180}{\pi}}\right)\right)\right)\right)}^{2}
\end{array}
Initial program 77.5%
*-commutative77.5%
clear-num77.6%
un-div-inv77.7%
Applied egg-rr77.7%
associate-*l/77.6%
div-inv77.6%
metadata-eval77.6%
associate-*r*77.7%
log1p-expm1-u77.7%
Applied egg-rr77.7%
log1p-expm1-u77.7%
associate-*r*77.6%
*-commutative77.6%
expm1-log1p-u77.6%
*-commutative77.6%
associate-*r*77.7%
metadata-eval77.7%
div-inv77.7%
clear-num77.7%
un-div-inv77.7%
Applied egg-rr77.7%
Final simplification77.7%
(FPCore (a b angle) :precision binary64 (+ (pow (* b (cos (/ PI (/ 180.0 angle)))) 2.0) (pow (* a (sin (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return pow((b * cos((((double) M_PI) / (180.0 / angle)))), 2.0) + pow((a * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((b * Math.cos((Math.PI / (180.0 / angle)))), 2.0) + Math.pow((a * Math.sin((Math.PI * (angle / 180.0)))), 2.0);
}
def code(a, b, angle): return math.pow((b * math.cos((math.pi / (180.0 / angle)))), 2.0) + math.pow((a * math.sin((math.pi * (angle / 180.0)))), 2.0)
function code(a, b, angle) return Float64((Float64(b * cos(Float64(pi / Float64(180.0 / angle)))) ^ 2.0) + (Float64(a * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((b * cos((pi / (180.0 / angle)))) ^ 2.0) + ((a * sin((pi * (angle / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(b * N[Cos[N[(Pi / N[(180.0 / angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(a * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(b \cdot \cos \left(\frac{\pi}{\frac{180}{angle}}\right)\right)}^{2} + {\left(a \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 77.5%
*-commutative77.5%
clear-num77.6%
un-div-inv77.7%
Applied egg-rr77.7%
Final simplification77.7%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* angle (* PI 0.005555555555555556)))) (pow (hypot (* a (sin t_0)) (* b (cos t_0))) 2.0)))
double code(double a, double b, double angle) {
double t_0 = angle * (((double) M_PI) * 0.005555555555555556);
return pow(hypot((a * sin(t_0)), (b * cos(t_0))), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = angle * (Math.PI * 0.005555555555555556);
return Math.pow(Math.hypot((a * Math.sin(t_0)), (b * Math.cos(t_0))), 2.0);
}
def code(a, b, angle): t_0 = angle * (math.pi * 0.005555555555555556) return math.pow(math.hypot((a * math.sin(t_0)), (b * math.cos(t_0))), 2.0)
function code(a, b, angle) t_0 = Float64(angle * Float64(pi * 0.005555555555555556)) return hypot(Float64(a * sin(t_0)), Float64(b * cos(t_0))) ^ 2.0 end
function tmp = code(a, b, angle) t_0 = angle * (pi * 0.005555555555555556); tmp = hypot((a * sin(t_0)), (b * cos(t_0))) ^ 2.0; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, N[Power[N[Sqrt[N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(b * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := angle \cdot \left(\pi \cdot 0.005555555555555556\right)\\
{\left(\mathsf{hypot}\left(a \cdot \sin t\_0, b \cdot \cos t\_0\right)\right)}^{2}
\end{array}
\end{array}
Initial program 77.5%
associate-*l/77.5%
associate-/l*77.6%
cos-neg77.6%
distribute-lft-neg-out77.6%
distribute-frac-neg77.6%
distribute-frac-neg77.6%
distribute-lft-neg-out77.6%
cos-neg77.6%
associate-*l/77.6%
associate-/l*77.6%
Simplified77.6%
Applied egg-rr77.6%
(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 77.5%
associate-*l/77.5%
associate-/l*77.6%
cos-neg77.6%
distribute-lft-neg-out77.6%
distribute-frac-neg77.6%
distribute-frac-neg77.6%
distribute-lft-neg-out77.6%
cos-neg77.6%
associate-*l/77.6%
associate-/l*77.6%
Simplified77.6%
Taylor expanded in angle around 0 77.4%
Final simplification77.4%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* PI (/ angle 180.0)))) 2.0) (pow b 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin((((double) M_PI) * (angle / 180.0)))), 2.0) + pow(b, 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((Math.PI * (angle / 180.0)))), 2.0) + Math.pow(b, 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin((math.pi * (angle / 180.0)))), 2.0) + math.pow(b, 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0) + (b ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin((pi * (angle / 180.0)))) ^ 2.0) + (b ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {b}^{2}
\end{array}
Initial program 77.5%
*-commutative77.5%
clear-num77.6%
un-div-inv77.7%
Applied egg-rr77.7%
add-sqr-sqrt77.6%
div-inv77.6%
times-frac77.7%
Applied egg-rr77.7%
Taylor expanded in angle around 0 77.4%
Final simplification77.4%
(FPCore (a b angle)
:precision binary64
(if (<= b 6e-144)
(pow (* a (sin (* 0.005555555555555556 (* angle PI)))) 2.0)
(+
(*
(* a angle)
(*
0.005555555555555556
(* (* PI 0.005555555555555556) (* angle (* a PI)))))
(pow (* b (cos (* angle (/ PI 180.0)))) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 6e-144) {
tmp = pow((a * sin((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0);
} else {
tmp = ((a * angle) * (0.005555555555555556 * ((((double) M_PI) * 0.005555555555555556) * (angle * (a * ((double) M_PI)))))) + pow((b * cos((angle * (((double) M_PI) / 180.0)))), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 6e-144) {
tmp = Math.pow((a * Math.sin((0.005555555555555556 * (angle * Math.PI)))), 2.0);
} else {
tmp = ((a * angle) * (0.005555555555555556 * ((Math.PI * 0.005555555555555556) * (angle * (a * Math.PI))))) + Math.pow((b * Math.cos((angle * (Math.PI / 180.0)))), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 6e-144: tmp = math.pow((a * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0) else: tmp = ((a * angle) * (0.005555555555555556 * ((math.pi * 0.005555555555555556) * (angle * (a * math.pi))))) + math.pow((b * math.cos((angle * (math.pi / 180.0)))), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 6e-144) tmp = Float64(a * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0; else tmp = Float64(Float64(Float64(a * angle) * Float64(0.005555555555555556 * Float64(Float64(pi * 0.005555555555555556) * Float64(angle * Float64(a * pi))))) + (Float64(b * cos(Float64(angle * Float64(pi / 180.0)))) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 6e-144) tmp = (a * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0; else tmp = ((a * angle) * (0.005555555555555556 * ((pi * 0.005555555555555556) * (angle * (a * pi))))) + ((b * cos((angle * (pi / 180.0)))) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 6e-144], N[Power[N[(a * N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[(N[(a * angle), $MachinePrecision] * N[(0.005555555555555556 * N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * N[(angle * N[(a * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(b * N[Cos[N[(angle * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6 \cdot 10^{-144}:\\
\;\;\;\;{\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot angle\right) \cdot \left(0.005555555555555556 \cdot \left(\left(\pi \cdot 0.005555555555555556\right) \cdot \left(angle \cdot \left(a \cdot \pi\right)\right)\right)\right) + {\left(b \cdot \cos \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2}\\
\end{array}
\end{array}
if b < 5.9999999999999997e-144Initial program 78.8%
associate-*l/78.7%
associate-/l*78.8%
cos-neg78.8%
distribute-lft-neg-out78.8%
distribute-frac-neg78.8%
distribute-frac-neg78.8%
distribute-lft-neg-out78.8%
cos-neg78.8%
associate-*l/78.9%
associate-/l*78.9%
Simplified78.9%
Taylor expanded in a around inf 39.9%
unpow239.9%
*-commutative39.9%
associate-*r*40.1%
unpow240.1%
swap-sqr44.3%
unpow244.3%
associate-*r*44.1%
*-commutative44.1%
Simplified44.1%
if 5.9999999999999997e-144 < b Initial program 75.5%
associate-*l/75.5%
associate-/l*75.5%
cos-neg75.5%
distribute-lft-neg-out75.5%
distribute-frac-neg75.5%
distribute-frac-neg75.5%
distribute-lft-neg-out75.5%
cos-neg75.5%
associate-*l/75.6%
associate-/l*75.5%
Simplified75.5%
Taylor expanded in angle around 0 73.2%
*-commutative73.2%
*-commutative73.2%
associate-*l*73.2%
Simplified73.2%
unpow273.2%
associate-*r*73.2%
*-commutative73.2%
metadata-eval73.2%
div-inv73.2%
associate-*r*73.2%
associate-*r*73.2%
*-commutative73.2%
div-inv73.2%
metadata-eval73.2%
*-commutative73.2%
Applied egg-rr73.2%
*-commutative73.2%
*-commutative73.2%
associate-*l*73.3%
associate-*l*73.3%
*-commutative73.3%
Simplified73.3%
Final simplification55.1%
(FPCore (a b angle) :precision binary64 (if (<= b 6e-144) (pow (* a (sin (* 0.005555555555555556 (* angle PI)))) 2.0) (+ (pow b 2.0) (pow (* 0.005555555555555556 (* PI (* a angle))) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 6e-144) {
tmp = pow((a * sin((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0);
} else {
tmp = pow(b, 2.0) + pow((0.005555555555555556 * (((double) M_PI) * (a * angle))), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 6e-144) {
tmp = Math.pow((a * Math.sin((0.005555555555555556 * (angle * Math.PI)))), 2.0);
} else {
tmp = Math.pow(b, 2.0) + Math.pow((0.005555555555555556 * (Math.PI * (a * angle))), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 6e-144: tmp = math.pow((a * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0) else: tmp = math.pow(b, 2.0) + math.pow((0.005555555555555556 * (math.pi * (a * angle))), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 6e-144) tmp = Float64(a * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0; else tmp = Float64((b ^ 2.0) + (Float64(0.005555555555555556 * Float64(pi * Float64(a * angle))) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 6e-144) tmp = (a * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0; else tmp = (b ^ 2.0) + ((0.005555555555555556 * (pi * (a * angle))) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 6e-144], N[Power[N[(a * N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[Power[N[(0.005555555555555556 * N[(Pi * N[(a * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6 \cdot 10^{-144}:\\
\;\;\;\;{\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + {\left(0.005555555555555556 \cdot \left(\pi \cdot \left(a \cdot angle\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if b < 5.9999999999999997e-144Initial program 78.8%
associate-*l/78.7%
associate-/l*78.8%
cos-neg78.8%
distribute-lft-neg-out78.8%
distribute-frac-neg78.8%
distribute-frac-neg78.8%
distribute-lft-neg-out78.8%
cos-neg78.8%
associate-*l/78.9%
associate-/l*78.9%
Simplified78.9%
Taylor expanded in a around inf 39.9%
unpow239.9%
*-commutative39.9%
associate-*r*40.1%
unpow240.1%
swap-sqr44.3%
unpow244.3%
associate-*r*44.1%
*-commutative44.1%
Simplified44.1%
if 5.9999999999999997e-144 < b Initial program 75.5%
associate-*l/75.5%
associate-/l*75.5%
cos-neg75.5%
distribute-lft-neg-out75.5%
distribute-frac-neg75.5%
distribute-frac-neg75.5%
distribute-lft-neg-out75.5%
cos-neg75.5%
associate-*l/75.6%
associate-/l*75.5%
Simplified75.5%
Taylor expanded in angle around 0 73.2%
*-commutative73.2%
*-commutative73.2%
associate-*l*73.2%
Simplified73.2%
Taylor expanded in angle around 0 73.2%
Final simplification55.0%
(FPCore (a b angle) :precision binary64 (if (<= b 1.7e-68) (pow (* a (sin (* 0.005555555555555556 (* angle PI)))) 2.0) (* b b)))
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.7e-68) {
tmp = pow((a * sin((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0);
} else {
tmp = b * b;
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 1.7e-68) {
tmp = Math.pow((a * Math.sin((0.005555555555555556 * (angle * Math.PI)))), 2.0);
} else {
tmp = b * b;
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 1.7e-68: tmp = math.pow((a * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0) else: tmp = b * b return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 1.7e-68) tmp = Float64(a * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0; else tmp = Float64(b * b); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 1.7e-68) tmp = (a * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0; else tmp = b * b; end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 1.7e-68], N[Power[N[(a * N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(b * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.7 \cdot 10^{-68}:\\
\;\;\;\;{\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;b \cdot b\\
\end{array}
\end{array}
if b < 1.70000000000000009e-68Initial program 76.3%
associate-*l/76.2%
associate-/l*76.4%
cos-neg76.4%
distribute-lft-neg-out76.4%
distribute-frac-neg76.4%
distribute-frac-neg76.4%
distribute-lft-neg-out76.4%
cos-neg76.4%
associate-*l/76.4%
associate-/l*76.4%
Simplified76.4%
Taylor expanded in a around inf 38.6%
unpow238.6%
*-commutative38.6%
associate-*r*38.8%
unpow238.8%
swap-sqr43.1%
unpow243.1%
associate-*r*43.0%
*-commutative43.0%
Simplified43.0%
if 1.70000000000000009e-68 < b Initial program 80.4%
associate-*l/80.4%
associate-/l*80.4%
cos-neg80.4%
distribute-lft-neg-out80.4%
distribute-frac-neg80.4%
distribute-frac-neg80.4%
distribute-lft-neg-out80.4%
cos-neg80.4%
associate-*l/80.5%
associate-/l*80.4%
Simplified80.4%
Taylor expanded in angle around 0 71.5%
unpow271.5%
Applied egg-rr71.5%
(FPCore (a b angle) :precision binary64 (if (<= angle 8.8e+166) (* b b) (cbrt (pow b 6.0))))
double code(double a, double b, double angle) {
double tmp;
if (angle <= 8.8e+166) {
tmp = b * b;
} else {
tmp = cbrt(pow(b, 6.0));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (angle <= 8.8e+166) {
tmp = b * b;
} else {
tmp = Math.cbrt(Math.pow(b, 6.0));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (angle <= 8.8e+166) tmp = Float64(b * b); else tmp = cbrt((b ^ 6.0)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[angle, 8.8e+166], N[(b * b), $MachinePrecision], N[Power[N[Power[b, 6.0], $MachinePrecision], 1/3], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 8.8 \cdot 10^{+166}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{b}^{6}}\\
\end{array}
\end{array}
if angle < 8.7999999999999996e166Initial program 79.7%
associate-*l/79.6%
associate-/l*79.7%
cos-neg79.7%
distribute-lft-neg-out79.7%
distribute-frac-neg79.7%
distribute-frac-neg79.7%
distribute-lft-neg-out79.7%
cos-neg79.7%
associate-*l/79.8%
associate-/l*79.8%
Simplified79.8%
Taylor expanded in angle around 0 58.8%
unpow258.8%
Applied egg-rr58.8%
if 8.7999999999999996e166 < angle Initial program 61.4%
associate-*l/61.2%
associate-/l*61.4%
cos-neg61.4%
distribute-lft-neg-out61.4%
distribute-frac-neg61.4%
distribute-frac-neg61.4%
distribute-lft-neg-out61.4%
cos-neg61.4%
associate-*l/61.5%
associate-/l*61.2%
Simplified61.2%
Taylor expanded in angle around 0 32.2%
add-sqr-sqrt32.2%
sqrt-unprod37.4%
pow-prod-up37.4%
metadata-eval37.4%
Applied egg-rr37.4%
add-cbrt-cube35.4%
pow1/335.4%
add-sqr-sqrt35.4%
sqrt-pow135.4%
metadata-eval35.4%
pow-prod-up35.4%
metadata-eval35.4%
Applied egg-rr35.4%
unpow1/335.4%
Simplified35.4%
(FPCore (a b angle) :precision binary64 (* b b))
double code(double a, double b, double angle) {
return b * b;
}
real(8) function code(a, b, angle)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = b * b
end function
public static double code(double a, double b, double angle) {
return b * b;
}
def code(a, b, angle): return b * b
function code(a, b, angle) return Float64(b * b) end
function tmp = code(a, b, angle) tmp = b * b; end
code[a_, b_, angle_] := N[(b * b), $MachinePrecision]
\begin{array}{l}
\\
b \cdot b
\end{array}
Initial program 77.5%
associate-*l/77.5%
associate-/l*77.6%
cos-neg77.6%
distribute-lft-neg-out77.6%
distribute-frac-neg77.6%
distribute-frac-neg77.6%
distribute-lft-neg-out77.6%
cos-neg77.6%
associate-*l/77.6%
associate-/l*77.6%
Simplified77.6%
Taylor expanded in angle around 0 55.7%
unpow255.7%
Applied egg-rr55.7%
herbie shell --seed 2024137
(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)))