
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (/ angle 180.0)))) (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle / 180.0);
return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle / 180.0);
return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle): t_0 = math.pi * (angle / 180.0) return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(pi * Float64(angle / 180.0)) return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = pi * (angle / 180.0); tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin 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 (* PI (/ angle 180.0)))) (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle / 180.0);
return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle / 180.0);
return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle): t_0 = math.pi * (angle / 180.0) return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(pi * Float64(angle / 180.0)) return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = pi * (angle / 180.0); tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
\end{array}
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (+ 1.0 (* angle (* 0.005555555555555556 PI)))))
(+
(pow (* a (fma (cos t_0) (cos 1.0) (* (sin t_0) (sin 1.0)))) 2.0)
(pow
(* b (sin (* (cbrt (pow PI 3.0)) (* angle 0.005555555555555556))))
2.0))))
double code(double a, double b, double angle) {
double t_0 = 1.0 + (angle * (0.005555555555555556 * ((double) M_PI)));
return pow((a * fma(cos(t_0), cos(1.0), (sin(t_0) * sin(1.0)))), 2.0) + pow((b * sin((cbrt(pow(((double) M_PI), 3.0)) * (angle * 0.005555555555555556)))), 2.0);
}
function code(a, b, angle) t_0 = Float64(1.0 + Float64(angle * Float64(0.005555555555555556 * pi))) return Float64((Float64(a * fma(cos(t_0), cos(1.0), Float64(sin(t_0) * sin(1.0)))) ^ 2.0) + (Float64(b * sin(Float64(cbrt((pi ^ 3.0)) * Float64(angle * 0.005555555555555556)))) ^ 2.0)) end
code[a_, b_, angle_] := Block[{t$95$0 = N[(1.0 + N[(angle * N[(0.005555555555555556 * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[(N[Cos[t$95$0], $MachinePrecision] * N[Cos[1.0], $MachinePrecision] + N[(N[Sin[t$95$0], $MachinePrecision] * N[Sin[1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(N[Power[N[Power[Pi, 3.0], $MachinePrecision], 1/3], $MachinePrecision] * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + angle \cdot \left(0.005555555555555556 \cdot \pi\right)\\
{\left(a \cdot \mathsf{fma}\left(\cos t\_0, \cos 1, \sin t\_0 \cdot \sin 1\right)\right)}^{2} + {\left(b \cdot \sin \left(\sqrt[3]{{\pi}^{3}} \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2}
\end{array}
\end{array}
Initial program 81.9%
associate-*r/81.7%
metadata-eval81.7%
metadata-eval81.7%
distribute-neg-frac281.7%
distribute-frac-neg81.7%
distribute-rgt-neg-out81.7%
associate-/l*81.9%
neg-mul-181.9%
*-commutative81.9%
associate-/l*81.9%
metadata-eval81.9%
metadata-eval81.9%
Simplified81.9%
metadata-eval81.9%
div-inv81.8%
expm1-log1p-u68.2%
expm1-undefine68.2%
cos-diff68.2%
div-inv68.2%
metadata-eval68.2%
associate-*r*68.0%
*-commutative68.0%
Applied egg-rr68.0%
fma-define68.0%
log1p-undefine68.0%
rem-exp-log68.0%
associate-*r*68.1%
*-commutative68.1%
log1p-undefine68.1%
rem-exp-log81.6%
associate-*r*81.9%
*-commutative81.9%
Simplified81.9%
add-cbrt-cube81.9%
pow381.9%
Applied egg-rr81.9%
(FPCore (a b angle)
:precision binary64
(+
(pow
(*
a
(pow
(cbrt (cos (* (cbrt (pow PI 3.0)) (* angle 0.005555555555555556))))
3.0))
2.0)
(pow (* b (sin (* PI (* angle 0.005555555555555556)))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * pow(cbrt(cos((cbrt(pow(((double) M_PI), 3.0)) * (angle * 0.005555555555555556)))), 3.0)), 2.0) + pow((b * sin((((double) M_PI) * (angle * 0.005555555555555556)))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.pow(Math.cbrt(Math.cos((Math.cbrt(Math.pow(Math.PI, 3.0)) * (angle * 0.005555555555555556)))), 3.0)), 2.0) + Math.pow((b * Math.sin((Math.PI * (angle * 0.005555555555555556)))), 2.0);
}
function code(a, b, angle) return Float64((Float64(a * (cbrt(cos(Float64(cbrt((pi ^ 3.0)) * Float64(angle * 0.005555555555555556)))) ^ 3.0)) ^ 2.0) + (Float64(b * sin(Float64(pi * Float64(angle * 0.005555555555555556)))) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Power[N[Power[N[Cos[N[(N[Power[N[Power[Pi, 3.0], $MachinePrecision], 1/3], $MachinePrecision] * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot {\left(\sqrt[3]{\cos \left(\sqrt[3]{{\pi}^{3}} \cdot \left(angle \cdot 0.005555555555555556\right)\right)}\right)}^{3}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2}
\end{array}
Initial program 81.9%
associate-*r/81.7%
metadata-eval81.7%
metadata-eval81.7%
distribute-neg-frac281.7%
distribute-frac-neg81.7%
distribute-rgt-neg-out81.7%
associate-/l*81.9%
neg-mul-181.9%
*-commutative81.9%
associate-/l*81.9%
metadata-eval81.9%
metadata-eval81.9%
Simplified81.9%
metadata-eval81.9%
div-inv81.8%
add-sqr-sqrt45.4%
pow245.4%
div-inv45.4%
metadata-eval45.4%
associate-*r*45.1%
*-commutative45.1%
Applied egg-rr45.1%
add-cube-cbrt45.1%
pow345.1%
unpow245.1%
add-sqr-sqrt81.6%
associate-*r*81.8%
associate-*r*81.6%
*-commutative81.6%
associate-*r*81.9%
Applied egg-rr81.9%
add-cbrt-cube81.9%
pow381.9%
Applied egg-rr81.9%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (* angle 0.005555555555555556)))) (+ (pow (* b (sin t_0)) 2.0) (pow (* a (cos (pow (cbrt t_0) 3.0))) 2.0))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle * 0.005555555555555556);
return pow((b * sin(t_0)), 2.0) + pow((a * cos(pow(cbrt(t_0), 3.0))), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle * 0.005555555555555556);
return Math.pow((b * Math.sin(t_0)), 2.0) + Math.pow((a * Math.cos(Math.pow(Math.cbrt(t_0), 3.0))), 2.0);
}
function code(a, b, angle) t_0 = Float64(pi * Float64(angle * 0.005555555555555556)) return Float64((Float64(b * sin(t_0)) ^ 2.0) + (Float64(a * cos((cbrt(t_0) ^ 3.0))) ^ 2.0)) end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(a * N[Cos[N[Power[N[Power[t$95$0, 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(angle \cdot 0.005555555555555556\right)\\
{\left(b \cdot \sin t\_0\right)}^{2} + {\left(a \cdot \cos \left({\left(\sqrt[3]{t\_0}\right)}^{3}\right)\right)}^{2}
\end{array}
\end{array}
Initial program 81.9%
associate-*r/81.7%
metadata-eval81.7%
metadata-eval81.7%
distribute-neg-frac281.7%
distribute-frac-neg81.7%
distribute-rgt-neg-out81.7%
associate-/l*81.9%
neg-mul-181.9%
*-commutative81.9%
associate-/l*81.9%
metadata-eval81.9%
metadata-eval81.9%
Simplified81.9%
metadata-eval81.9%
div-inv81.8%
add-sqr-sqrt45.4%
pow245.4%
div-inv45.4%
metadata-eval45.4%
associate-*r*45.1%
*-commutative45.1%
Applied egg-rr45.1%
unpow245.1%
add-sqr-sqrt81.6%
*-commutative81.6%
associate-*r*81.9%
add-sqr-sqrt45.4%
Applied egg-rr45.4%
add-sqr-sqrt81.9%
add-cube-cbrt81.9%
pow381.9%
Applied egg-rr81.9%
Final simplification81.9%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (/ angle 180.0)))) (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle / 180.0);
return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle / 180.0);
return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle): t_0 = math.pi * (angle / 180.0) return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(pi * Float64(angle / 180.0)) return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = pi * (angle / 180.0); tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
\end{array}
Initial program 81.9%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (* angle 0.005555555555555556)))) (pow (hypot (* a (cos t_0)) (* b (sin t_0))) 2.0)))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle * 0.005555555555555556);
return pow(hypot((a * cos(t_0)), (b * sin(t_0))), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle * 0.005555555555555556);
return Math.pow(Math.hypot((a * Math.cos(t_0)), (b * Math.sin(t_0))), 2.0);
}
def code(a, b, angle): t_0 = math.pi * (angle * 0.005555555555555556) return math.pow(math.hypot((a * math.cos(t_0)), (b * math.sin(t_0))), 2.0)
function code(a, b, angle) t_0 = Float64(pi * Float64(angle * 0.005555555555555556)) return hypot(Float64(a * cos(t_0)), Float64(b * sin(t_0))) ^ 2.0 end
function tmp = code(a, b, angle) t_0 = pi * (angle * 0.005555555555555556); tmp = hypot((a * cos(t_0)), (b * sin(t_0))) ^ 2.0; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, N[Power[N[Sqrt[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(angle \cdot 0.005555555555555556\right)\\
{\left(\mathsf{hypot}\left(a \cdot \cos t\_0, b \cdot \sin t\_0\right)\right)}^{2}
\end{array}
\end{array}
Initial program 81.9%
associate-*r/81.7%
metadata-eval81.7%
metadata-eval81.7%
distribute-neg-frac281.7%
distribute-frac-neg81.7%
distribute-rgt-neg-out81.7%
associate-/l*81.9%
neg-mul-181.9%
*-commutative81.9%
associate-/l*81.9%
metadata-eval81.9%
metadata-eval81.9%
Simplified81.9%
metadata-eval81.9%
div-inv81.8%
add-cbrt-cube71.8%
pow371.7%
pow-pow71.8%
div-inv71.8%
metadata-eval71.8%
associate-*r*71.5%
*-commutative71.5%
metadata-eval71.5%
Applied egg-rr71.5%
*-commutative71.5%
*-commutative71.5%
associate-*r*71.8%
Simplified71.8%
add-sqr-sqrt71.8%
pow271.8%
Applied egg-rr81.9%
(FPCore (a b angle) :precision binary64 (+ (pow (* b (sin (* PI (* angle 0.005555555555555556)))) 2.0) (pow a 2.0)))
double code(double a, double b, double angle) {
return pow((b * sin((((double) M_PI) * (angle * 0.005555555555555556)))), 2.0) + pow(a, 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((b * Math.sin((Math.PI * (angle * 0.005555555555555556)))), 2.0) + Math.pow(a, 2.0);
}
def code(a, b, angle): return math.pow((b * math.sin((math.pi * (angle * 0.005555555555555556)))), 2.0) + math.pow(a, 2.0)
function code(a, b, angle) return Float64((Float64(b * sin(Float64(pi * Float64(angle * 0.005555555555555556)))) ^ 2.0) + (a ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((b * sin((pi * (angle * 0.005555555555555556)))) ^ 2.0) + (a ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(b * N[Sin[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(b \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2} + {a}^{2}
\end{array}
Initial program 81.9%
associate-*r/81.7%
metadata-eval81.7%
metadata-eval81.7%
distribute-neg-frac281.7%
distribute-frac-neg81.7%
distribute-rgt-neg-out81.7%
associate-/l*81.9%
neg-mul-181.9%
*-commutative81.9%
associate-/l*81.9%
metadata-eval81.9%
metadata-eval81.9%
Simplified81.9%
Taylor expanded in angle around 0 81.2%
Final simplification81.2%
(FPCore (a b angle) :precision binary64 (if (<= a 3.1e-46) (pow (* b (sin (* angle (* 0.005555555555555556 PI)))) 2.0) (* a a)))
double code(double a, double b, double angle) {
double tmp;
if (a <= 3.1e-46) {
tmp = pow((b * sin((angle * (0.005555555555555556 * ((double) M_PI))))), 2.0);
} else {
tmp = a * a;
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 3.1e-46) {
tmp = Math.pow((b * Math.sin((angle * (0.005555555555555556 * Math.PI)))), 2.0);
} else {
tmp = a * a;
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 3.1e-46: tmp = math.pow((b * math.sin((angle * (0.005555555555555556 * math.pi)))), 2.0) else: tmp = a * a return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 3.1e-46) tmp = Float64(b * sin(Float64(angle * Float64(0.005555555555555556 * pi)))) ^ 2.0; else tmp = Float64(a * a); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 3.1e-46) tmp = (b * sin((angle * (0.005555555555555556 * pi)))) ^ 2.0; else tmp = a * a; end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 3.1e-46], N[Power[N[(b * N[Sin[N[(angle * N[(0.005555555555555556 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(a * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.1 \cdot 10^{-46}:\\
\;\;\;\;{\left(b \cdot \sin \left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 3.1000000000000001e-46Initial program 79.7%
associate-*r/79.5%
metadata-eval79.5%
metadata-eval79.5%
distribute-neg-frac279.5%
distribute-frac-neg79.5%
distribute-rgt-neg-out79.5%
associate-/l*79.7%
neg-mul-179.7%
*-commutative79.7%
associate-/l*79.8%
metadata-eval79.8%
metadata-eval79.8%
Simplified79.7%
Taylor expanded in a around 0 45.0%
unpow245.0%
*-commutative45.0%
unpow245.0%
swap-sqr51.1%
unpow251.1%
*-commutative51.1%
*-commutative51.1%
associate-*r*51.5%
Simplified51.5%
if 3.1000000000000001e-46 < a Initial program 87.4%
associate-*r/87.3%
metadata-eval87.3%
metadata-eval87.3%
distribute-neg-frac287.3%
distribute-frac-neg87.3%
distribute-rgt-neg-out87.3%
associate-/l*87.4%
neg-mul-187.4%
*-commutative87.4%
associate-/l*87.3%
metadata-eval87.3%
metadata-eval87.3%
Simplified87.3%
Taylor expanded in angle around 0 73.9%
unpow273.9%
Applied egg-rr73.9%
Final simplification57.8%
(FPCore (a b angle) :precision binary64 (if (<= a 6.4e-46) (pow (* b (sin (* 0.005555555555555556 (* angle PI)))) 2.0) (* a a)))
double code(double a, double b, double angle) {
double tmp;
if (a <= 6.4e-46) {
tmp = pow((b * sin((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0);
} else {
tmp = a * a;
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 6.4e-46) {
tmp = Math.pow((b * Math.sin((0.005555555555555556 * (angle * Math.PI)))), 2.0);
} else {
tmp = a * a;
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 6.4e-46: tmp = math.pow((b * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0) else: tmp = a * a return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 6.4e-46) tmp = Float64(b * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0; else tmp = Float64(a * a); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 6.4e-46) tmp = (b * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0; else tmp = a * a; end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 6.4e-46], N[Power[N[(b * N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(a * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 6.4 \cdot 10^{-46}:\\
\;\;\;\;{\left(b \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 6.3999999999999998e-46Initial program 79.7%
associate-*r/79.5%
metadata-eval79.5%
metadata-eval79.5%
distribute-neg-frac279.5%
distribute-frac-neg79.5%
distribute-rgt-neg-out79.5%
associate-/l*79.7%
neg-mul-179.7%
*-commutative79.7%
associate-/l*79.8%
metadata-eval79.8%
metadata-eval79.8%
Simplified79.7%
Taylor expanded in a around 0 45.0%
unpow245.0%
*-commutative45.0%
unpow245.0%
swap-sqr51.1%
unpow251.1%
*-commutative51.1%
Simplified51.1%
if 6.3999999999999998e-46 < a Initial program 87.4%
associate-*r/87.3%
metadata-eval87.3%
metadata-eval87.3%
distribute-neg-frac287.3%
distribute-frac-neg87.3%
distribute-rgt-neg-out87.3%
associate-/l*87.4%
neg-mul-187.4%
*-commutative87.4%
associate-/l*87.3%
metadata-eval87.3%
metadata-eval87.3%
Simplified87.3%
Taylor expanded in angle around 0 73.9%
unpow273.9%
Applied egg-rr73.9%
(FPCore (a b angle) :precision binary64 (pow (* a (cos (* angle (* 0.005555555555555556 PI)))) 2.0))
double code(double a, double b, double angle) {
return pow((a * cos((angle * (0.005555555555555556 * ((double) M_PI))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.cos((angle * (0.005555555555555556 * Math.PI)))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.cos((angle * (0.005555555555555556 * math.pi)))), 2.0)
function code(a, b, angle) return Float64(a * cos(Float64(angle * Float64(0.005555555555555556 * pi)))) ^ 2.0 end
function tmp = code(a, b, angle) tmp = (a * cos((angle * (0.005555555555555556 * pi)))) ^ 2.0; end
code[a_, b_, angle_] := N[Power[N[(a * N[Cos[N[(angle * N[(0.005555555555555556 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \cos \left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right)\right)}^{2}
\end{array}
Initial program 81.9%
associate-*r/81.7%
metadata-eval81.7%
metadata-eval81.7%
distribute-neg-frac281.7%
distribute-frac-neg81.7%
distribute-rgt-neg-out81.7%
associate-/l*81.9%
neg-mul-181.9%
*-commutative81.9%
associate-/l*81.9%
metadata-eval81.9%
metadata-eval81.9%
Simplified81.9%
Taylor expanded in a around inf 56.3%
*-commutative56.3%
unpow256.3%
unpow256.3%
swap-sqr56.3%
unpow256.3%
*-commutative56.3%
*-commutative56.3%
associate-*r*56.5%
Simplified56.5%
Final simplification56.5%
(FPCore (a b angle) :precision binary64 (* a a))
double code(double a, double b, double angle) {
return a * a;
}
real(8) function code(a, b, angle)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = a * a
end function
public static double code(double a, double b, double angle) {
return a * a;
}
def code(a, b, angle): return a * a
function code(a, b, angle) return Float64(a * a) end
function tmp = code(a, b, angle) tmp = a * a; end
code[a_, b_, angle_] := N[(a * a), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a
\end{array}
Initial program 81.9%
associate-*r/81.7%
metadata-eval81.7%
metadata-eval81.7%
distribute-neg-frac281.7%
distribute-frac-neg81.7%
distribute-rgt-neg-out81.7%
associate-/l*81.9%
neg-mul-181.9%
*-commutative81.9%
associate-/l*81.9%
metadata-eval81.9%
metadata-eval81.9%
Simplified81.9%
Taylor expanded in angle around 0 56.5%
unpow256.5%
Applied egg-rr56.5%
herbie shell --seed 2024173
(FPCore (a b angle)
:name "ab-angle->ABCF C"
:precision binary64
(+ (pow (* a (cos (* PI (/ angle 180.0)))) 2.0) (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))