
(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 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (/ angle 180.0) PI))) (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * ((double) M_PI);
return pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * Math.PI;
return Math.pow((a * Math.sin(t_0)), 2.0) + Math.pow((b * Math.cos(t_0)), 2.0);
}
def code(a, b, angle): t_0 = (angle / 180.0) * math.pi return math.pow((a * math.sin(t_0)), 2.0) + math.pow((b * math.cos(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(Float64(angle / 180.0) * pi) return Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = (angle / 180.0) * pi; tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[Power[N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* angle (/ (cbrt (pow PI 3.0)) 180.0)))) 2.0) (pow b 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin((angle * (cbrt(pow(((double) M_PI), 3.0)) / 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.cbrt(Math.pow(Math.PI, 3.0)) / 180.0)))), 2.0) + Math.pow(b, 2.0);
}
function code(a, b, angle) return Float64((Float64(a * sin(Float64(angle * Float64(cbrt((pi ^ 3.0)) / 180.0)))) ^ 2.0) + (b ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(angle * N[(N[Power[N[Power[Pi, 3.0], $MachinePrecision], 1/3], $MachinePrecision] / 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{\sqrt[3]{{\pi}^{3}}}{180}\right)\right)}^{2} + {b}^{2}
\end{array}
Initial program 81.3%
associate-*l/81.2%
associate-/l*81.2%
cos-neg81.2%
distribute-lft-neg-out81.2%
distribute-frac-neg81.2%
distribute-frac-neg81.2%
distribute-lft-neg-out81.2%
cos-neg81.2%
associate-*l/81.2%
associate-/l*81.2%
Simplified81.2%
Taylor expanded in angle around 0 81.3%
add-cbrt-cube81.4%
pow381.4%
Applied egg-rr81.4%
Final simplification81.4%
(FPCore (a b angle) :precision binary64 (+ (pow b 2.0) (pow (* a (sin (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return pow(b, 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, 2.0) + Math.pow((a * Math.sin((Math.PI * (angle / 180.0)))), 2.0);
}
def code(a, b, angle): return math.pow(b, 2.0) + math.pow((a * math.sin((math.pi * (angle / 180.0)))), 2.0)
function code(a, b, angle) return Float64((b ^ 2.0) + (Float64(a * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (b ^ 2.0) + ((a * sin((pi * (angle / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[b, 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}
\\
{b}^{2} + {\left(a \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 81.3%
associate-*l/81.2%
Applied egg-rr81.2%
Taylor expanded in angle around 0 81.4%
Final simplification81.4%
(FPCore (a b angle) :precision binary64 (+ (pow b 2.0) (pow (* a (sin (* PI (* angle 0.005555555555555556)))) 2.0)))
double code(double a, double b, double angle) {
return pow(b, 2.0) + pow((a * sin((((double) M_PI) * (angle * 0.005555555555555556)))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0) + Math.pow((a * Math.sin((Math.PI * (angle * 0.005555555555555556)))), 2.0);
}
def code(a, b, angle): return math.pow(b, 2.0) + math.pow((a * math.sin((math.pi * (angle * 0.005555555555555556)))), 2.0)
function code(a, b, angle) return Float64((b ^ 2.0) + (Float64(a * sin(Float64(pi * Float64(angle * 0.005555555555555556)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (b ^ 2.0) + ((a * sin((pi * (angle * 0.005555555555555556)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[b, 2.0], $MachinePrecision] + N[Power[N[(a * N[Sin[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{b}^{2} + {\left(a \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2}
\end{array}
Initial program 81.3%
associate-*l/81.2%
associate-/l*81.2%
cos-neg81.2%
distribute-lft-neg-out81.2%
distribute-frac-neg81.2%
distribute-frac-neg81.2%
distribute-lft-neg-out81.2%
cos-neg81.2%
associate-*l/81.2%
associate-/l*81.2%
Simplified81.2%
Taylor expanded in angle around 0 81.3%
add-cbrt-cube81.4%
pow381.4%
Applied egg-rr81.4%
Taylor expanded in angle around inf 81.3%
associate-*r*81.4%
*-commutative81.4%
*-commutative81.4%
*-commutative81.4%
Simplified81.4%
Final simplification81.4%
(FPCore (a b angle) :precision binary64 (+ (pow b 2.0) (pow (* a (sin (* 0.005555555555555556 (* angle PI)))) 2.0)))
double code(double a, double b, double angle) {
return pow(b, 2.0) + pow((a * sin((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0) + Math.pow((a * Math.sin((0.005555555555555556 * (angle * Math.PI)))), 2.0);
}
def code(a, b, angle): return math.pow(b, 2.0) + math.pow((a * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0)
function code(a, b, angle) return Float64((b ^ 2.0) + (Float64(a * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (b ^ 2.0) + ((a * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[b, 2.0], $MachinePrecision] + N[Power[N[(a * N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{b}^{2} + {\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}
\end{array}
Initial program 81.3%
associate-*l/81.2%
associate-/l*81.2%
cos-neg81.2%
distribute-lft-neg-out81.2%
distribute-frac-neg81.2%
distribute-frac-neg81.2%
distribute-lft-neg-out81.2%
cos-neg81.2%
associate-*l/81.2%
associate-/l*81.2%
Simplified81.2%
Taylor expanded in angle around 0 81.3%
Taylor expanded in angle around inf 81.3%
Final simplification81.3%
(FPCore (a b angle)
:precision binary64
(if (<= a 1.25e-141)
(+
(pow b 2.0)
(pow (+ (+ 1.0 (* 0.005555555555555556 (* angle (* a PI)))) -1.0) 2.0))
(+
(*
(* a (* angle PI))
(* 0.005555555555555556 (* angle (* a (* PI 0.005555555555555556)))))
(pow (* b (cos (* angle (/ PI 180.0)))) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.25e-141) {
tmp = pow(b, 2.0) + pow(((1.0 + (0.005555555555555556 * (angle * (a * ((double) M_PI))))) + -1.0), 2.0);
} else {
tmp = ((a * (angle * ((double) M_PI))) * (0.005555555555555556 * (angle * (a * (((double) M_PI) * 0.005555555555555556))))) + 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 (a <= 1.25e-141) {
tmp = Math.pow(b, 2.0) + Math.pow(((1.0 + (0.005555555555555556 * (angle * (a * Math.PI)))) + -1.0), 2.0);
} else {
tmp = ((a * (angle * Math.PI)) * (0.005555555555555556 * (angle * (a * (Math.PI * 0.005555555555555556))))) + Math.pow((b * Math.cos((angle * (Math.PI / 180.0)))), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.25e-141: tmp = math.pow(b, 2.0) + math.pow(((1.0 + (0.005555555555555556 * (angle * (a * math.pi)))) + -1.0), 2.0) else: tmp = ((a * (angle * math.pi)) * (0.005555555555555556 * (angle * (a * (math.pi * 0.005555555555555556))))) + math.pow((b * math.cos((angle * (math.pi / 180.0)))), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.25e-141) tmp = Float64((b ^ 2.0) + (Float64(Float64(1.0 + Float64(0.005555555555555556 * Float64(angle * Float64(a * pi)))) + -1.0) ^ 2.0)); else tmp = Float64(Float64(Float64(a * Float64(angle * pi)) * Float64(0.005555555555555556 * Float64(angle * Float64(a * Float64(pi * 0.005555555555555556))))) + (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 (a <= 1.25e-141) tmp = (b ^ 2.0) + (((1.0 + (0.005555555555555556 * (angle * (a * pi)))) + -1.0) ^ 2.0); else tmp = ((a * (angle * pi)) * (0.005555555555555556 * (angle * (a * (pi * 0.005555555555555556))))) + ((b * cos((angle * (pi / 180.0)))) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.25e-141], N[(N[Power[b, 2.0], $MachinePrecision] + N[Power[N[(N[(1.0 + N[(0.005555555555555556 * N[(angle * N[(a * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * N[(angle * Pi), $MachinePrecision]), $MachinePrecision] * N[(0.005555555555555556 * N[(angle * N[(a * N[(Pi * 0.005555555555555556), $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}\;a \leq 1.25 \cdot 10^{-141}:\\
\;\;\;\;{b}^{2} + {\left(\left(1 + 0.005555555555555556 \cdot \left(angle \cdot \left(a \cdot \pi\right)\right)\right) + -1\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot \left(angle \cdot \pi\right)\right) \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \left(a \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right) + {\left(b \cdot \cos \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 1.25e-141Initial program 79.7%
associate-*l/79.7%
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.7%
associate-/l*79.7%
Simplified79.7%
Taylor expanded in angle around 0 80.3%
expm1-log1p-u69.2%
expm1-undefine64.6%
*-commutative64.6%
div-inv64.6%
metadata-eval64.6%
Applied egg-rr64.6%
Taylor expanded in angle around 0 72.9%
*-commutative72.9%
associate-*l*72.9%
Simplified72.9%
if 1.25e-141 < a Initial program 84.0%
associate-*l/83.9%
associate-/l*83.9%
cos-neg83.9%
distribute-lft-neg-out83.9%
distribute-frac-neg83.9%
distribute-frac-neg83.9%
distribute-lft-neg-out83.9%
cos-neg83.9%
associate-*l/83.9%
associate-/l*83.9%
Simplified83.9%
Taylor expanded in angle around 0 80.8%
*-commutative80.8%
associate-*r*80.9%
associate-*l*80.8%
*-commutative80.8%
Simplified80.8%
unpow280.8%
associate-*r*80.9%
associate-*l*80.8%
*-commutative80.8%
associate-*l*80.8%
*-commutative80.8%
associate-*l*80.9%
Applied egg-rr80.9%
Final simplification75.7%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* a (* angle PI))))
(if (<= a 1.5e-141)
(+
(pow b 2.0)
(pow (+ (+ 1.0 (* 0.005555555555555556 (* angle (* a PI)))) -1.0) 2.0))
(+
(pow (* b (cos (* angle (/ PI 180.0)))) 2.0)
(* (* t_0 t_0) 3.08641975308642e-5)))))
double code(double a, double b, double angle) {
double t_0 = a * (angle * ((double) M_PI));
double tmp;
if (a <= 1.5e-141) {
tmp = pow(b, 2.0) + pow(((1.0 + (0.005555555555555556 * (angle * (a * ((double) M_PI))))) + -1.0), 2.0);
} else {
tmp = pow((b * cos((angle * (((double) M_PI) / 180.0)))), 2.0) + ((t_0 * t_0) * 3.08641975308642e-5);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = a * (angle * Math.PI);
double tmp;
if (a <= 1.5e-141) {
tmp = Math.pow(b, 2.0) + Math.pow(((1.0 + (0.005555555555555556 * (angle * (a * Math.PI)))) + -1.0), 2.0);
} else {
tmp = Math.pow((b * Math.cos((angle * (Math.PI / 180.0)))), 2.0) + ((t_0 * t_0) * 3.08641975308642e-5);
}
return tmp;
}
def code(a, b, angle): t_0 = a * (angle * math.pi) tmp = 0 if a <= 1.5e-141: tmp = math.pow(b, 2.0) + math.pow(((1.0 + (0.005555555555555556 * (angle * (a * math.pi)))) + -1.0), 2.0) else: tmp = math.pow((b * math.cos((angle * (math.pi / 180.0)))), 2.0) + ((t_0 * t_0) * 3.08641975308642e-5) return tmp
function code(a, b, angle) t_0 = Float64(a * Float64(angle * pi)) tmp = 0.0 if (a <= 1.5e-141) tmp = Float64((b ^ 2.0) + (Float64(Float64(1.0 + Float64(0.005555555555555556 * Float64(angle * Float64(a * pi)))) + -1.0) ^ 2.0)); else tmp = Float64((Float64(b * cos(Float64(angle * Float64(pi / 180.0)))) ^ 2.0) + Float64(Float64(t_0 * t_0) * 3.08641975308642e-5)); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = a * (angle * pi); tmp = 0.0; if (a <= 1.5e-141) tmp = (b ^ 2.0) + (((1.0 + (0.005555555555555556 * (angle * (a * pi)))) + -1.0) ^ 2.0); else tmp = ((b * cos((angle * (pi / 180.0)))) ^ 2.0) + ((t_0 * t_0) * 3.08641975308642e-5); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(a * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, 1.5e-141], N[(N[Power[b, 2.0], $MachinePrecision] + N[Power[N[(N[(1.0 + N[(0.005555555555555556 * N[(angle * N[(a * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(b * N[Cos[N[(angle * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(angle \cdot \pi\right)\\
\mathbf{if}\;a \leq 1.5 \cdot 10^{-141}:\\
\;\;\;\;{b}^{2} + {\left(\left(1 + 0.005555555555555556 \cdot \left(angle \cdot \left(a \cdot \pi\right)\right)\right) + -1\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;{\left(b \cdot \cos \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2} + \left(t\_0 \cdot t\_0\right) \cdot 3.08641975308642 \cdot 10^{-5}\\
\end{array}
\end{array}
if a < 1.49999999999999992e-141Initial program 79.7%
associate-*l/79.7%
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.7%
associate-/l*79.7%
Simplified79.7%
Taylor expanded in angle around 0 80.3%
expm1-log1p-u69.2%
expm1-undefine64.6%
*-commutative64.6%
div-inv64.6%
metadata-eval64.6%
Applied egg-rr64.6%
Taylor expanded in angle around 0 72.9%
*-commutative72.9%
associate-*l*72.9%
Simplified72.9%
if 1.49999999999999992e-141 < a Initial program 84.0%
associate-*l/83.9%
associate-/l*83.9%
cos-neg83.9%
distribute-lft-neg-out83.9%
distribute-frac-neg83.9%
distribute-frac-neg83.9%
distribute-lft-neg-out83.9%
cos-neg83.9%
associate-*l/83.9%
associate-/l*83.9%
Simplified83.9%
Taylor expanded in angle around 0 80.8%
*-commutative80.8%
associate-*r*80.9%
associate-*l*80.8%
*-commutative80.8%
Simplified80.8%
unpow280.8%
associate-*r*80.9%
associate-*r*80.9%
swap-sqr80.8%
*-commutative80.8%
associate-*l*80.8%
*-commutative80.8%
*-commutative80.8%
associate-*l*80.8%
*-commutative80.8%
metadata-eval80.8%
Applied egg-rr80.8%
Final simplification75.7%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* angle (* a PI))))
(if (<= a 2.5e-101)
(+ (pow b 2.0) (pow (+ (+ 1.0 (* 0.005555555555555556 t_0)) -1.0) 2.0))
(+
(pow b 2.0)
(*
t_0
(*
0.005555555555555556
(* (* angle PI) (* a 0.005555555555555556))))))))
double code(double a, double b, double angle) {
double t_0 = angle * (a * ((double) M_PI));
double tmp;
if (a <= 2.5e-101) {
tmp = pow(b, 2.0) + pow(((1.0 + (0.005555555555555556 * t_0)) + -1.0), 2.0);
} else {
tmp = pow(b, 2.0) + (t_0 * (0.005555555555555556 * ((angle * ((double) M_PI)) * (a * 0.005555555555555556))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = angle * (a * Math.PI);
double tmp;
if (a <= 2.5e-101) {
tmp = Math.pow(b, 2.0) + Math.pow(((1.0 + (0.005555555555555556 * t_0)) + -1.0), 2.0);
} else {
tmp = Math.pow(b, 2.0) + (t_0 * (0.005555555555555556 * ((angle * Math.PI) * (a * 0.005555555555555556))));
}
return tmp;
}
def code(a, b, angle): t_0 = angle * (a * math.pi) tmp = 0 if a <= 2.5e-101: tmp = math.pow(b, 2.0) + math.pow(((1.0 + (0.005555555555555556 * t_0)) + -1.0), 2.0) else: tmp = math.pow(b, 2.0) + (t_0 * (0.005555555555555556 * ((angle * math.pi) * (a * 0.005555555555555556)))) return tmp
function code(a, b, angle) t_0 = Float64(angle * Float64(a * pi)) tmp = 0.0 if (a <= 2.5e-101) tmp = Float64((b ^ 2.0) + (Float64(Float64(1.0 + Float64(0.005555555555555556 * t_0)) + -1.0) ^ 2.0)); else tmp = Float64((b ^ 2.0) + Float64(t_0 * Float64(0.005555555555555556 * Float64(Float64(angle * pi) * Float64(a * 0.005555555555555556))))); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = angle * (a * pi); tmp = 0.0; if (a <= 2.5e-101) tmp = (b ^ 2.0) + (((1.0 + (0.005555555555555556 * t_0)) + -1.0) ^ 2.0); else tmp = (b ^ 2.0) + (t_0 * (0.005555555555555556 * ((angle * pi) * (a * 0.005555555555555556)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(angle * N[(a * Pi), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, 2.5e-101], N[(N[Power[b, 2.0], $MachinePrecision] + N[Power[N[(N[(1.0 + N[(0.005555555555555556 * t$95$0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(t$95$0 * N[(0.005555555555555556 * N[(N[(angle * Pi), $MachinePrecision] * N[(a * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := angle \cdot \left(a \cdot \pi\right)\\
\mathbf{if}\;a \leq 2.5 \cdot 10^{-101}:\\
\;\;\;\;{b}^{2} + {\left(\left(1 + 0.005555555555555556 \cdot t\_0\right) + -1\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + t\_0 \cdot \left(0.005555555555555556 \cdot \left(\left(angle \cdot \pi\right) \cdot \left(a \cdot 0.005555555555555556\right)\right)\right)\\
\end{array}
\end{array}
if a < 2.5e-101Initial program 79.7%
associate-*l/79.7%
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.7%
associate-/l*79.7%
Simplified79.7%
Taylor expanded in angle around 0 80.3%
expm1-log1p-u69.4%
expm1-undefine64.9%
*-commutative64.9%
div-inv64.9%
metadata-eval64.9%
Applied egg-rr64.9%
Taylor expanded in angle around 0 72.9%
*-commutative72.9%
associate-*l*72.9%
Simplified72.9%
if 2.5e-101 < a Initial program 84.3%
associate-*l/84.2%
associate-/l*84.2%
cos-neg84.2%
distribute-lft-neg-out84.2%
distribute-frac-neg84.2%
distribute-frac-neg84.2%
distribute-lft-neg-out84.2%
cos-neg84.2%
associate-*l/84.1%
associate-/l*84.1%
Simplified84.1%
Taylor expanded in angle around 0 83.3%
Taylor expanded in angle around 0 80.1%
unpow280.1%
associate-*r*80.1%
associate-*r*80.1%
*-commutative80.1%
*-commutative80.1%
associate-*l*80.2%
Applied egg-rr80.2%
Final simplification75.4%
(FPCore (a b angle)
:precision binary64
(+
(pow b 2.0)
(*
(* angle PI)
(*
(* a 0.005555555555555556)
(* (* angle PI) (* a 0.005555555555555556))))))
double code(double a, double b, double angle) {
return pow(b, 2.0) + ((angle * ((double) M_PI)) * ((a * 0.005555555555555556) * ((angle * ((double) M_PI)) * (a * 0.005555555555555556))));
}
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0) + ((angle * Math.PI) * ((a * 0.005555555555555556) * ((angle * Math.PI) * (a * 0.005555555555555556))));
}
def code(a, b, angle): return math.pow(b, 2.0) + ((angle * math.pi) * ((a * 0.005555555555555556) * ((angle * math.pi) * (a * 0.005555555555555556))))
function code(a, b, angle) return Float64((b ^ 2.0) + Float64(Float64(angle * pi) * Float64(Float64(a * 0.005555555555555556) * Float64(Float64(angle * pi) * Float64(a * 0.005555555555555556))))) end
function tmp = code(a, b, angle) tmp = (b ^ 2.0) + ((angle * pi) * ((a * 0.005555555555555556) * ((angle * pi) * (a * 0.005555555555555556)))); end
code[a_, b_, angle_] := N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(angle * Pi), $MachinePrecision] * N[(N[(a * 0.005555555555555556), $MachinePrecision] * N[(N[(angle * Pi), $MachinePrecision] * N[(a * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{b}^{2} + \left(angle \cdot \pi\right) \cdot \left(\left(a \cdot 0.005555555555555556\right) \cdot \left(\left(angle \cdot \pi\right) \cdot \left(a \cdot 0.005555555555555556\right)\right)\right)
\end{array}
Initial program 81.3%
associate-*l/81.2%
associate-/l*81.2%
cos-neg81.2%
distribute-lft-neg-out81.2%
distribute-frac-neg81.2%
distribute-frac-neg81.2%
distribute-lft-neg-out81.2%
cos-neg81.2%
associate-*l/81.2%
associate-/l*81.2%
Simplified81.2%
Taylor expanded in angle around 0 81.3%
Taylor expanded in angle around 0 76.3%
unpow276.3%
associate-*r*76.3%
associate-*r*76.7%
associate-*r*76.6%
*-commutative76.6%
Applied egg-rr76.6%
Final simplification76.6%
(FPCore (a b angle) :precision binary64 (+ (pow b 2.0) (* (* angle (* a PI)) (* 0.005555555555555556 (* (* angle PI) (* a 0.005555555555555556))))))
double code(double a, double b, double angle) {
return pow(b, 2.0) + ((angle * (a * ((double) M_PI))) * (0.005555555555555556 * ((angle * ((double) M_PI)) * (a * 0.005555555555555556))));
}
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0) + ((angle * (a * Math.PI)) * (0.005555555555555556 * ((angle * Math.PI) * (a * 0.005555555555555556))));
}
def code(a, b, angle): return math.pow(b, 2.0) + ((angle * (a * math.pi)) * (0.005555555555555556 * ((angle * math.pi) * (a * 0.005555555555555556))))
function code(a, b, angle) return Float64((b ^ 2.0) + Float64(Float64(angle * Float64(a * pi)) * Float64(0.005555555555555556 * Float64(Float64(angle * pi) * Float64(a * 0.005555555555555556))))) end
function tmp = code(a, b, angle) tmp = (b ^ 2.0) + ((angle * (a * pi)) * (0.005555555555555556 * ((angle * pi) * (a * 0.005555555555555556)))); end
code[a_, b_, angle_] := N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(angle * N[(a * Pi), $MachinePrecision]), $MachinePrecision] * N[(0.005555555555555556 * N[(N[(angle * Pi), $MachinePrecision] * N[(a * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{b}^{2} + \left(angle \cdot \left(a \cdot \pi\right)\right) \cdot \left(0.005555555555555556 \cdot \left(\left(angle \cdot \pi\right) \cdot \left(a \cdot 0.005555555555555556\right)\right)\right)
\end{array}
Initial program 81.3%
associate-*l/81.2%
associate-/l*81.2%
cos-neg81.2%
distribute-lft-neg-out81.2%
distribute-frac-neg81.2%
distribute-frac-neg81.2%
distribute-lft-neg-out81.2%
cos-neg81.2%
associate-*l/81.2%
associate-/l*81.2%
Simplified81.2%
Taylor expanded in angle around 0 81.3%
Taylor expanded in angle around 0 76.3%
unpow276.3%
associate-*r*76.3%
associate-*r*76.3%
*-commutative76.3%
*-commutative76.3%
associate-*l*76.3%
Applied egg-rr76.3%
Final simplification76.3%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (* angle PI) (* a 0.005555555555555556)))) (+ (pow b 2.0) (* t_0 t_0))))
double code(double a, double b, double angle) {
double t_0 = (angle * ((double) M_PI)) * (a * 0.005555555555555556);
return pow(b, 2.0) + (t_0 * t_0);
}
public static double code(double a, double b, double angle) {
double t_0 = (angle * Math.PI) * (a * 0.005555555555555556);
return Math.pow(b, 2.0) + (t_0 * t_0);
}
def code(a, b, angle): t_0 = (angle * math.pi) * (a * 0.005555555555555556) return math.pow(b, 2.0) + (t_0 * t_0)
function code(a, b, angle) t_0 = Float64(Float64(angle * pi) * Float64(a * 0.005555555555555556)) return Float64((b ^ 2.0) + Float64(t_0 * t_0)) end
function tmp = code(a, b, angle) t_0 = (angle * pi) * (a * 0.005555555555555556); tmp = (b ^ 2.0) + (t_0 * t_0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle * Pi), $MachinePrecision] * N[(a * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[b, 2.0], $MachinePrecision] + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(angle \cdot \pi\right) \cdot \left(a \cdot 0.005555555555555556\right)\\
{b}^{2} + t\_0 \cdot t\_0
\end{array}
\end{array}
Initial program 81.3%
associate-*l/81.2%
associate-/l*81.2%
cos-neg81.2%
distribute-lft-neg-out81.2%
distribute-frac-neg81.2%
distribute-frac-neg81.2%
distribute-lft-neg-out81.2%
cos-neg81.2%
associate-*l/81.2%
associate-/l*81.2%
Simplified81.2%
Taylor expanded in angle around 0 81.3%
Taylor expanded in angle around 0 76.3%
unpow276.3%
associate-*r*76.3%
associate-*r*76.3%
*-commutative76.3%
*-commutative76.3%
Applied egg-rr76.3%
Final simplification76.3%
(FPCore (a b angle) :precision binary64 (+ (pow b 2.0) (* (* a 0.005555555555555556) (* (* angle PI) (* PI (* a (* angle 0.005555555555555556)))))))
double code(double a, double b, double angle) {
return pow(b, 2.0) + ((a * 0.005555555555555556) * ((angle * ((double) M_PI)) * (((double) M_PI) * (a * (angle * 0.005555555555555556)))));
}
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0) + ((a * 0.005555555555555556) * ((angle * Math.PI) * (Math.PI * (a * (angle * 0.005555555555555556)))));
}
def code(a, b, angle): return math.pow(b, 2.0) + ((a * 0.005555555555555556) * ((angle * math.pi) * (math.pi * (a * (angle * 0.005555555555555556)))))
function code(a, b, angle) return Float64((b ^ 2.0) + Float64(Float64(a * 0.005555555555555556) * Float64(Float64(angle * pi) * Float64(pi * Float64(a * Float64(angle * 0.005555555555555556)))))) end
function tmp = code(a, b, angle) tmp = (b ^ 2.0) + ((a * 0.005555555555555556) * ((angle * pi) * (pi * (a * (angle * 0.005555555555555556))))); end
code[a_, b_, angle_] := N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(a * 0.005555555555555556), $MachinePrecision] * N[(N[(angle * Pi), $MachinePrecision] * N[(Pi * N[(a * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{b}^{2} + \left(a \cdot 0.005555555555555556\right) \cdot \left(\left(angle \cdot \pi\right) \cdot \left(\pi \cdot \left(a \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)\right)
\end{array}
Initial program 81.3%
associate-*l/81.2%
associate-/l*81.2%
cos-neg81.2%
distribute-lft-neg-out81.2%
distribute-frac-neg81.2%
distribute-frac-neg81.2%
distribute-lft-neg-out81.2%
cos-neg81.2%
associate-*l/81.2%
associate-/l*81.2%
Simplified81.2%
Taylor expanded in angle around 0 81.3%
Taylor expanded in angle around 0 76.3%
unpow276.3%
associate-*r*76.3%
associate-*l*75.5%
associate-*r*75.5%
*-commutative75.5%
Applied egg-rr75.5%
pow175.5%
associate-*r*75.5%
*-commutative75.5%
associate-*r*75.6%
metadata-eval75.6%
div-inv75.6%
associate-*l*75.5%
div-inv75.6%
metadata-eval75.6%
Applied egg-rr75.6%
unpow175.6%
*-commutative75.6%
Simplified75.6%
Final simplification75.6%
(FPCore (a b angle) :precision binary64 (+ (pow b 2.0) (* (* a 0.005555555555555556) (* (* angle PI) (* angle (/ (* a PI) 180.0))))))
double code(double a, double b, double angle) {
return pow(b, 2.0) + ((a * 0.005555555555555556) * ((angle * ((double) M_PI)) * (angle * ((a * ((double) M_PI)) / 180.0))));
}
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0) + ((a * 0.005555555555555556) * ((angle * Math.PI) * (angle * ((a * Math.PI) / 180.0))));
}
def code(a, b, angle): return math.pow(b, 2.0) + ((a * 0.005555555555555556) * ((angle * math.pi) * (angle * ((a * math.pi) / 180.0))))
function code(a, b, angle) return Float64((b ^ 2.0) + Float64(Float64(a * 0.005555555555555556) * Float64(Float64(angle * pi) * Float64(angle * Float64(Float64(a * pi) / 180.0))))) end
function tmp = code(a, b, angle) tmp = (b ^ 2.0) + ((a * 0.005555555555555556) * ((angle * pi) * (angle * ((a * pi) / 180.0)))); end
code[a_, b_, angle_] := N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(a * 0.005555555555555556), $MachinePrecision] * N[(N[(angle * Pi), $MachinePrecision] * N[(angle * N[(N[(a * Pi), $MachinePrecision] / 180.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{b}^{2} + \left(a \cdot 0.005555555555555556\right) \cdot \left(\left(angle \cdot \pi\right) \cdot \left(angle \cdot \frac{a \cdot \pi}{180}\right)\right)
\end{array}
Initial program 81.3%
associate-*l/81.2%
associate-/l*81.2%
cos-neg81.2%
distribute-lft-neg-out81.2%
distribute-frac-neg81.2%
distribute-frac-neg81.2%
distribute-lft-neg-out81.2%
cos-neg81.2%
associate-*l/81.2%
associate-/l*81.2%
Simplified81.2%
Taylor expanded in angle around 0 81.3%
Taylor expanded in angle around 0 76.3%
unpow276.3%
associate-*r*76.3%
associate-*l*75.5%
associate-*r*75.5%
*-commutative75.5%
Applied egg-rr75.5%
associate-*r*75.5%
add-cube-cbrt75.5%
unpow275.5%
metadata-eval75.5%
div-inv75.5%
clear-num75.5%
associate-*l/75.5%
*-un-lft-identity75.5%
unpow275.5%
add-cube-cbrt75.5%
Applied egg-rr75.5%
associate-/r/75.5%
associate-*l/75.5%
*-commutative75.5%
associate-*l*75.5%
*-commutative75.5%
associate-/l*75.6%
*-commutative75.6%
Simplified75.6%
Final simplification75.6%
herbie shell --seed 2024111
(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)))