
(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 8 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 (+ (pow a 2.0) (pow (* b (sin (* PI (* angle 0.005555555555555556)))) 2.0)))
double code(double a, double b, double angle) {
return pow(a, 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, 2.0) + Math.pow((b * Math.sin((Math.PI * (angle * 0.005555555555555556)))), 2.0);
}
def code(a, b, angle): return math.pow(a, 2.0) + math.pow((b * math.sin((math.pi * (angle * 0.005555555555555556)))), 2.0)
function code(a, b, angle) return Float64((a ^ 2.0) + (Float64(b * sin(Float64(pi * Float64(angle * 0.005555555555555556)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a ^ 2.0) + ((b * sin((pi * (angle * 0.005555555555555556)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[a, 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}
\\
{a}^{2} + {\left(b \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2}
\end{array}
Initial program 81.6%
associate-*r/81.4%
metadata-eval81.4%
metadata-eval81.4%
distribute-neg-frac281.4%
distribute-frac-neg81.4%
distribute-rgt-neg-out81.4%
associate-/l*81.6%
neg-mul-181.6%
*-commutative81.6%
associate-/l*81.5%
metadata-eval81.5%
metadata-eval81.5%
Simplified81.5%
Taylor expanded in angle around 0 82.4%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* PI (* angle 0.005555555555555556))))
(if (<= a 2.6e-138)
(pow (* b (sin t_0)) 2.0)
(+ (* a a) (pow (* b t_0) 2.0)))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle * 0.005555555555555556);
double tmp;
if (a <= 2.6e-138) {
tmp = pow((b * sin(t_0)), 2.0);
} else {
tmp = (a * a) + pow((b * t_0), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle * 0.005555555555555556);
double tmp;
if (a <= 2.6e-138) {
tmp = Math.pow((b * Math.sin(t_0)), 2.0);
} else {
tmp = (a * a) + Math.pow((b * t_0), 2.0);
}
return tmp;
}
def code(a, b, angle): t_0 = math.pi * (angle * 0.005555555555555556) tmp = 0 if a <= 2.6e-138: tmp = math.pow((b * math.sin(t_0)), 2.0) else: tmp = (a * a) + math.pow((b * t_0), 2.0) return tmp
function code(a, b, angle) t_0 = Float64(pi * Float64(angle * 0.005555555555555556)) tmp = 0.0 if (a <= 2.6e-138) tmp = Float64(b * sin(t_0)) ^ 2.0; else tmp = Float64(Float64(a * a) + (Float64(b * t_0) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = pi * (angle * 0.005555555555555556); tmp = 0.0; if (a <= 2.6e-138) tmp = (b * sin(t_0)) ^ 2.0; else tmp = (a * a) + ((b * t_0) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, 2.6e-138], N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * t$95$0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(angle \cdot 0.005555555555555556\right)\\
\mathbf{if}\;a \leq 2.6 \cdot 10^{-138}:\\
\;\;\;\;{\left(b \cdot \sin t\_0\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + {\left(b \cdot t\_0\right)}^{2}\\
\end{array}
\end{array}
if a < 2.6e-138Initial program 84.9%
associate-*r/84.9%
metadata-eval84.9%
metadata-eval84.9%
distribute-neg-frac284.9%
distribute-frac-neg84.9%
distribute-rgt-neg-out84.9%
associate-/l*84.9%
neg-mul-184.9%
*-commutative84.9%
associate-/l*85.0%
metadata-eval85.0%
metadata-eval85.0%
Simplified85.0%
Taylor expanded in a around 0 41.7%
*-commutative41.7%
associate-*r*41.6%
*-commutative41.6%
*-commutative41.6%
unpow241.6%
unpow241.6%
swap-sqr49.1%
unpow249.1%
Simplified49.1%
if 2.6e-138 < a Initial program 73.7%
associate-*r/73.4%
metadata-eval73.4%
metadata-eval73.4%
distribute-neg-frac273.4%
distribute-frac-neg73.4%
distribute-rgt-neg-out73.4%
associate-/l*73.7%
neg-mul-173.7%
*-commutative73.7%
associate-/l*73.6%
metadata-eval73.6%
metadata-eval73.6%
Simplified73.6%
Taylor expanded in angle around 0 75.3%
metadata-eval75.3%
div-inv75.3%
associate-*r/75.2%
Applied egg-rr75.2%
unpow275.2%
Applied egg-rr75.2%
Taylor expanded in angle around 0 72.0%
*-commutative72.0%
associate-*r*72.0%
*-commutative72.0%
associate-*l*71.9%
Simplified71.9%
Final simplification56.0%
(FPCore (a b angle) :precision binary64 (if (<= a 2.6e-138) (pow (* b (sin (* angle (* PI 0.005555555555555556)))) 2.0) (+ (* a a) (pow (* b (* PI (* angle 0.005555555555555556))) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 2.6e-138) {
tmp = pow((b * sin((angle * (((double) M_PI) * 0.005555555555555556)))), 2.0);
} else {
tmp = (a * a) + pow((b * (((double) M_PI) * (angle * 0.005555555555555556))), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 2.6e-138) {
tmp = Math.pow((b * Math.sin((angle * (Math.PI * 0.005555555555555556)))), 2.0);
} else {
tmp = (a * a) + Math.pow((b * (Math.PI * (angle * 0.005555555555555556))), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 2.6e-138: tmp = math.pow((b * math.sin((angle * (math.pi * 0.005555555555555556)))), 2.0) else: tmp = (a * a) + math.pow((b * (math.pi * (angle * 0.005555555555555556))), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 2.6e-138) tmp = Float64(b * sin(Float64(angle * Float64(pi * 0.005555555555555556)))) ^ 2.0; else tmp = Float64(Float64(a * a) + (Float64(b * Float64(pi * Float64(angle * 0.005555555555555556))) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 2.6e-138) tmp = (b * sin((angle * (pi * 0.005555555555555556)))) ^ 2.0; else tmp = (a * a) + ((b * (pi * (angle * 0.005555555555555556))) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 2.6e-138], N[Power[N[(b * N[Sin[N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.6 \cdot 10^{-138}:\\
\;\;\;\;{\left(b \cdot \sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + {\left(b \cdot \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 2.6e-138Initial program 84.9%
associate-*r/84.9%
metadata-eval84.9%
metadata-eval84.9%
distribute-neg-frac284.9%
distribute-frac-neg84.9%
distribute-rgt-neg-out84.9%
associate-/l*84.9%
neg-mul-184.9%
*-commutative84.9%
associate-/l*85.0%
metadata-eval85.0%
metadata-eval85.0%
Simplified85.0%
Taylor expanded in angle around 0 85.4%
Taylor expanded in a around 0 41.7%
*-commutative41.7%
associate-*r*41.6%
*-commutative41.6%
associate-*r*41.6%
unpow241.6%
unpow241.6%
swap-sqr49.0%
unpow249.0%
*-commutative49.0%
Simplified49.0%
if 2.6e-138 < a Initial program 73.7%
associate-*r/73.4%
metadata-eval73.4%
metadata-eval73.4%
distribute-neg-frac273.4%
distribute-frac-neg73.4%
distribute-rgt-neg-out73.4%
associate-/l*73.7%
neg-mul-173.7%
*-commutative73.7%
associate-/l*73.6%
metadata-eval73.6%
metadata-eval73.6%
Simplified73.6%
Taylor expanded in angle around 0 75.3%
metadata-eval75.3%
div-inv75.3%
associate-*r/75.2%
Applied egg-rr75.2%
unpow275.2%
Applied egg-rr75.2%
Taylor expanded in angle around 0 72.0%
*-commutative72.0%
associate-*r*72.0%
*-commutative72.0%
associate-*l*71.9%
Simplified71.9%
Final simplification55.9%
(FPCore (a b angle) :precision binary64 (if (<= a 2.6e-138) (pow (* b (sin (* 0.005555555555555556 (* PI angle)))) 2.0) (+ (* a a) (pow (* b (* PI (* angle 0.005555555555555556))) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 2.6e-138) {
tmp = pow((b * sin((0.005555555555555556 * (((double) M_PI) * angle)))), 2.0);
} else {
tmp = (a * a) + pow((b * (((double) M_PI) * (angle * 0.005555555555555556))), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 2.6e-138) {
tmp = Math.pow((b * Math.sin((0.005555555555555556 * (Math.PI * angle)))), 2.0);
} else {
tmp = (a * a) + Math.pow((b * (Math.PI * (angle * 0.005555555555555556))), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 2.6e-138: tmp = math.pow((b * math.sin((0.005555555555555556 * (math.pi * angle)))), 2.0) else: tmp = (a * a) + math.pow((b * (math.pi * (angle * 0.005555555555555556))), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 2.6e-138) tmp = Float64(b * sin(Float64(0.005555555555555556 * Float64(pi * angle)))) ^ 2.0; else tmp = Float64(Float64(a * a) + (Float64(b * Float64(pi * Float64(angle * 0.005555555555555556))) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 2.6e-138) tmp = (b * sin((0.005555555555555556 * (pi * angle)))) ^ 2.0; else tmp = (a * a) + ((b * (pi * (angle * 0.005555555555555556))) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 2.6e-138], N[Power[N[(b * N[Sin[N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.6 \cdot 10^{-138}:\\
\;\;\;\;{\left(b \cdot \sin \left(0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + {\left(b \cdot \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 2.6e-138Initial program 84.9%
associate-*r/84.9%
metadata-eval84.9%
metadata-eval84.9%
distribute-neg-frac284.9%
distribute-frac-neg84.9%
distribute-rgt-neg-out84.9%
associate-/l*84.9%
neg-mul-184.9%
*-commutative84.9%
associate-/l*85.0%
metadata-eval85.0%
metadata-eval85.0%
Simplified85.0%
Taylor expanded in a around 0 41.7%
*-commutative41.7%
associate-*r*41.6%
*-commutative41.6%
*-commutative41.6%
unpow241.6%
unpow241.6%
swap-sqr49.1%
unpow249.1%
*-commutative49.1%
*-commutative49.1%
*-commutative49.1%
associate-*r*49.1%
Simplified49.1%
if 2.6e-138 < a Initial program 73.7%
associate-*r/73.4%
metadata-eval73.4%
metadata-eval73.4%
distribute-neg-frac273.4%
distribute-frac-neg73.4%
distribute-rgt-neg-out73.4%
associate-/l*73.7%
neg-mul-173.7%
*-commutative73.7%
associate-/l*73.6%
metadata-eval73.6%
metadata-eval73.6%
Simplified73.6%
Taylor expanded in angle around 0 75.3%
metadata-eval75.3%
div-inv75.3%
associate-*r/75.2%
Applied egg-rr75.2%
unpow275.2%
Applied egg-rr75.2%
Taylor expanded in angle around 0 72.0%
*-commutative72.0%
associate-*r*72.0%
*-commutative72.0%
associate-*l*71.9%
Simplified71.9%
Final simplification56.0%
(FPCore (a b angle) :precision binary64 (+ (* a a) (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return (a * a) + pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return (a * a) + Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0);
}
def code(a, b, angle): return (a * a) + math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0)
function code(a, b, angle) return Float64(Float64(a * a) + (Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a * a) + ((b * sin((pi * (angle / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 81.6%
associate-*r/81.4%
metadata-eval81.4%
metadata-eval81.4%
distribute-neg-frac281.4%
distribute-frac-neg81.4%
distribute-rgt-neg-out81.4%
associate-/l*81.6%
neg-mul-181.6%
*-commutative81.6%
associate-/l*81.5%
metadata-eval81.5%
metadata-eval81.5%
Simplified81.5%
Taylor expanded in angle around 0 82.4%
metadata-eval82.4%
div-inv82.3%
associate-*r/82.3%
Applied egg-rr82.3%
unpow282.3%
Applied egg-rr82.3%
frac-2neg82.3%
distribute-frac-neg82.3%
metadata-eval82.3%
Applied egg-rr82.3%
distribute-neg-frac282.3%
metadata-eval82.3%
associate-/l*82.3%
Simplified82.3%
(FPCore (a b angle) :precision binary64 (if (<= b 4.8e-118) (* a a) (+ (* a a) (pow (* b (* PI (* angle 0.005555555555555556))) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 4.8e-118) {
tmp = a * a;
} else {
tmp = (a * a) + pow((b * (((double) M_PI) * (angle * 0.005555555555555556))), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 4.8e-118) {
tmp = a * a;
} else {
tmp = (a * a) + Math.pow((b * (Math.PI * (angle * 0.005555555555555556))), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 4.8e-118: tmp = a * a else: tmp = (a * a) + math.pow((b * (math.pi * (angle * 0.005555555555555556))), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 4.8e-118) tmp = Float64(a * a); else tmp = Float64(Float64(a * a) + (Float64(b * Float64(pi * Float64(angle * 0.005555555555555556))) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 4.8e-118) tmp = a * a; else tmp = (a * a) + ((b * (pi * (angle * 0.005555555555555556))) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 4.8e-118], N[(a * a), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.8 \cdot 10^{-118}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + {\left(b \cdot \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if b < 4.8000000000000003e-118Initial program 82.1%
associate-*r/82.0%
metadata-eval82.0%
metadata-eval82.0%
distribute-neg-frac282.0%
distribute-frac-neg82.0%
distribute-rgt-neg-out82.0%
associate-/l*82.1%
neg-mul-182.1%
*-commutative82.1%
associate-/l*82.1%
metadata-eval82.1%
metadata-eval82.1%
Simplified82.1%
Taylor expanded in angle around 0 66.2%
unpow283.3%
Applied egg-rr66.2%
if 4.8000000000000003e-118 < b Initial program 80.3%
associate-*r/80.3%
metadata-eval80.3%
metadata-eval80.3%
distribute-neg-frac280.3%
distribute-frac-neg80.3%
distribute-rgt-neg-out80.3%
associate-/l*80.3%
neg-mul-180.3%
*-commutative80.3%
associate-/l*80.4%
metadata-eval80.4%
metadata-eval80.4%
Simplified80.4%
Taylor expanded in angle around 0 80.4%
metadata-eval80.4%
div-inv80.4%
associate-*r/80.3%
Applied egg-rr80.3%
unpow280.3%
Applied egg-rr80.3%
Taylor expanded in angle around 0 76.2%
*-commutative76.2%
associate-*r*76.3%
*-commutative76.3%
associate-*l*76.3%
Simplified76.3%
Final simplification69.5%
(FPCore (a b angle) :precision binary64 (if (<= b 4e-118) (* a a) (+ (* a a) (pow (* 0.005555555555555556 (* PI (* b angle))) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 4e-118) {
tmp = a * a;
} else {
tmp = (a * a) + pow((0.005555555555555556 * (((double) M_PI) * (b * angle))), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 4e-118) {
tmp = a * a;
} else {
tmp = (a * a) + Math.pow((0.005555555555555556 * (Math.PI * (b * angle))), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 4e-118: tmp = a * a else: tmp = (a * a) + math.pow((0.005555555555555556 * (math.pi * (b * angle))), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 4e-118) tmp = Float64(a * a); else tmp = Float64(Float64(a * a) + (Float64(0.005555555555555556 * Float64(pi * Float64(b * angle))) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 4e-118) tmp = a * a; else tmp = (a * a) + ((0.005555555555555556 * (pi * (b * angle))) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 4e-118], N[(a * a), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[Power[N[(0.005555555555555556 * N[(Pi * N[(b * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4 \cdot 10^{-118}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + {\left(0.005555555555555556 \cdot \left(\pi \cdot \left(b \cdot angle\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if b < 3.99999999999999994e-118Initial program 82.1%
associate-*r/82.0%
metadata-eval82.0%
metadata-eval82.0%
distribute-neg-frac282.0%
distribute-frac-neg82.0%
distribute-rgt-neg-out82.0%
associate-/l*82.1%
neg-mul-182.1%
*-commutative82.1%
associate-/l*82.1%
metadata-eval82.1%
metadata-eval82.1%
Simplified82.1%
Taylor expanded in angle around 0 66.2%
unpow283.3%
Applied egg-rr66.2%
if 3.99999999999999994e-118 < b Initial program 80.3%
associate-*r/80.3%
metadata-eval80.3%
metadata-eval80.3%
distribute-neg-frac280.3%
distribute-frac-neg80.3%
distribute-rgt-neg-out80.3%
associate-/l*80.3%
neg-mul-180.3%
*-commutative80.3%
associate-/l*80.4%
metadata-eval80.4%
metadata-eval80.4%
Simplified80.4%
Taylor expanded in angle around 0 80.4%
metadata-eval80.4%
div-inv80.4%
associate-*r/80.3%
Applied egg-rr80.3%
unpow280.3%
Applied egg-rr80.3%
Taylor expanded in angle around 0 76.3%
associate-*r*76.3%
Simplified76.3%
Final simplification69.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.6%
associate-*r/81.4%
metadata-eval81.4%
metadata-eval81.4%
distribute-neg-frac281.4%
distribute-frac-neg81.4%
distribute-rgt-neg-out81.4%
associate-/l*81.6%
neg-mul-181.6%
*-commutative81.6%
associate-/l*81.5%
metadata-eval81.5%
metadata-eval81.5%
Simplified81.5%
Taylor expanded in angle around 0 59.4%
unpow282.3%
Applied egg-rr59.4%
herbie shell --seed 2024131
(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)))