
(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}
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (+ (pow a 2.0) (pow (* (sin (expm1 (log1p (* angle (* PI 0.005555555555555556))))) b) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
return pow(a, 2.0) + pow((sin(expm1(log1p((angle * (((double) M_PI) * 0.005555555555555556))))) * b), 2.0);
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
return Math.pow(a, 2.0) + Math.pow((Math.sin(Math.expm1(Math.log1p((angle * (Math.PI * 0.005555555555555556))))) * b), 2.0);
}
angle = abs(angle) def code(a, b, angle): return math.pow(a, 2.0) + math.pow((math.sin(math.expm1(math.log1p((angle * (math.pi * 0.005555555555555556))))) * b), 2.0)
angle = abs(angle) function code(a, b, angle) return Float64((a ^ 2.0) + (Float64(sin(expm1(log1p(Float64(angle * Float64(pi * 0.005555555555555556))))) * b) ^ 2.0)) end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(N[Sin[N[(Exp[N[Log[1 + N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle = |angle|\\
\\
{a}^{2} + {\left(\sin \left(\mathsf{expm1}\left(\mathsf{log1p}\left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right) \cdot b\right)}^{2}
\end{array}
Initial program 75.7%
Taylor expanded in angle around 0 75.8%
Taylor expanded in b around 0 75.8%
*-commutative75.8%
metadata-eval75.8%
*-commutative75.8%
associate-/r/75.8%
associate-/l*75.8%
*-commutative75.8%
associate-/l*75.8%
metadata-eval75.8%
*-commutative75.8%
associate-*r/75.9%
Simplified75.9%
expm1-log1p-u60.4%
div-inv60.4%
metadata-eval60.4%
Applied egg-rr60.4%
Final simplification60.4%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (+ (pow a 2.0) (pow (* b (sin (* PI (* angle -0.005555555555555556)))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
return pow(a, 2.0) + pow((b * sin((((double) M_PI) * (angle * -0.005555555555555556)))), 2.0);
}
angle = Math.abs(angle);
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);
}
angle = abs(angle) def code(a, b, angle): return math.pow(a, 2.0) + math.pow((b * math.sin((math.pi * (angle * -0.005555555555555556)))), 2.0)
angle = abs(angle) function code(a, b, angle) return Float64((a ^ 2.0) + (Float64(b * sin(Float64(pi * Float64(angle * -0.005555555555555556)))) ^ 2.0)) end
angle = abs(angle) function tmp = code(a, b, angle) tmp = (a ^ 2.0) + ((b * sin((pi * (angle * -0.005555555555555556)))) ^ 2.0); end
NOTE: angle should be positive before calling this function 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}
angle = |angle|\\
\\
{a}^{2} + {\left(b \cdot \sin \left(\pi \cdot \left(angle \cdot -0.005555555555555556\right)\right)\right)}^{2}
\end{array}
Initial program 75.7%
unpow275.7%
swap-sqr66.5%
sqr-neg66.5%
swap-sqr75.7%
unpow275.7%
distribute-lft-neg-out75.7%
distribute-rgt-neg-in75.7%
sin-neg75.7%
distribute-rgt-neg-out75.7%
distribute-frac-neg75.7%
unpow275.7%
associate-*l*74.3%
Simplified75.7%
Taylor expanded in angle around 0 75.8%
Final simplification75.8%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (+ (pow a 2.0) (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
return pow(a, 2.0) + pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
return Math.pow(a, 2.0) + Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0);
}
angle = abs(angle) def code(a, b, angle): return math.pow(a, 2.0) + math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0)
angle = abs(angle) function code(a, b, angle) return Float64((a ^ 2.0) + (Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
angle = abs(angle) function tmp = code(a, b, angle) tmp = (a ^ 2.0) + ((b * sin((pi * (angle / 180.0)))) ^ 2.0); end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle = |angle|\\
\\
{a}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 75.7%
Taylor expanded in angle around 0 75.8%
Final simplification75.8%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (+ (pow a 2.0) (pow (* b (sin (/ (* angle PI) 180.0))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
return pow(a, 2.0) + pow((b * sin(((angle * ((double) M_PI)) / 180.0))), 2.0);
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
return Math.pow(a, 2.0) + Math.pow((b * Math.sin(((angle * Math.PI) / 180.0))), 2.0);
}
angle = abs(angle) def code(a, b, angle): return math.pow(a, 2.0) + math.pow((b * math.sin(((angle * math.pi) / 180.0))), 2.0)
angle = abs(angle) function code(a, b, angle) return Float64((a ^ 2.0) + (Float64(b * sin(Float64(Float64(angle * pi) / 180.0))) ^ 2.0)) end
angle = abs(angle) function tmp = code(a, b, angle) tmp = (a ^ 2.0) + ((b * sin(((angle * pi) / 180.0))) ^ 2.0); end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(N[(angle * Pi), $MachinePrecision] / 180.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle = |angle|\\
\\
{a}^{2} + {\left(b \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2}
\end{array}
Initial program 75.7%
unpow275.7%
swap-sqr66.5%
sqr-neg66.5%
swap-sqr75.7%
unpow275.7%
distribute-lft-neg-out75.7%
distribute-rgt-neg-in75.7%
sin-neg75.7%
distribute-rgt-neg-out75.7%
distribute-frac-neg75.7%
unpow275.7%
associate-*l*74.3%
Simplified75.7%
Taylor expanded in angle around 0 75.8%
add-sqr-sqrt41.5%
sqrt-unprod56.8%
swap-sqr56.8%
metadata-eval56.8%
metadata-eval56.8%
metadata-eval56.8%
metadata-eval56.8%
swap-sqr56.8%
div-inv56.8%
div-inv56.8%
sqrt-unprod34.3%
add-sqr-sqrt75.8%
associate-*r/75.8%
Applied egg-rr75.8%
Final simplification75.8%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (+ (pow a 2.0) (pow (* b (sin (* angle (/ PI 180.0)))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
return pow(a, 2.0) + pow((b * sin((angle * (((double) M_PI) / 180.0)))), 2.0);
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
return Math.pow(a, 2.0) + Math.pow((b * Math.sin((angle * (Math.PI / 180.0)))), 2.0);
}
angle = abs(angle) def code(a, b, angle): return math.pow(a, 2.0) + math.pow((b * math.sin((angle * (math.pi / 180.0)))), 2.0)
angle = abs(angle) function code(a, b, angle) return Float64((a ^ 2.0) + (Float64(b * sin(Float64(angle * Float64(pi / 180.0)))) ^ 2.0)) end
angle = abs(angle) function tmp = code(a, b, angle) tmp = (a ^ 2.0) + ((b * sin((angle * (pi / 180.0)))) ^ 2.0); end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(angle * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle = |angle|\\
\\
{a}^{2} + {\left(b \cdot \sin \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2}
\end{array}
Initial program 75.7%
Taylor expanded in angle around 0 75.8%
Taylor expanded in b around 0 75.8%
*-commutative75.8%
metadata-eval75.8%
*-commutative75.8%
associate-/r/75.8%
associate-/l*75.8%
*-commutative75.8%
associate-/l*75.8%
metadata-eval75.8%
*-commutative75.8%
associate-*r/75.9%
Simplified75.9%
Final simplification75.9%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (if (<= b 2.2e-13) (* a a) (fma 3.08641975308642e-5 (pow (* PI (* angle b)) 2.0) (* a a))))
angle = abs(angle);
double code(double a, double b, double angle) {
double tmp;
if (b <= 2.2e-13) {
tmp = a * a;
} else {
tmp = fma(3.08641975308642e-5, pow((((double) M_PI) * (angle * b)), 2.0), (a * a));
}
return tmp;
}
angle = abs(angle) function code(a, b, angle) tmp = 0.0 if (b <= 2.2e-13) tmp = Float64(a * a); else tmp = fma(3.08641975308642e-5, (Float64(pi * Float64(angle * b)) ^ 2.0), Float64(a * a)); end return tmp end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[b, 2.2e-13], N[(a * a), $MachinePrecision], N[(3.08641975308642e-5 * N[Power[N[(Pi * N[(angle * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle = |angle|\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.2 \cdot 10^{-13}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, {\left(\pi \cdot \left(angle \cdot b\right)\right)}^{2}, a \cdot a\right)\\
\end{array}
\end{array}
if b < 2.19999999999999997e-13Initial program 74.0%
Taylor expanded in angle around 0 74.3%
Taylor expanded in angle around 0 67.6%
*-commutative67.6%
Simplified67.6%
*-commutative67.6%
unpow-prod-down67.5%
*-commutative67.5%
associate-*l*67.5%
metadata-eval67.5%
Applied egg-rr67.5%
Taylor expanded in a around inf 58.9%
unpow258.9%
Simplified58.9%
if 2.19999999999999997e-13 < b Initial program 80.0%
Taylor expanded in angle around 0 79.8%
Taylor expanded in angle around 0 75.9%
*-commutative75.9%
Simplified75.9%
*-commutative75.9%
unpow-prod-down76.0%
*-commutative76.0%
associate-*l*76.1%
metadata-eval76.1%
Applied egg-rr76.1%
Taylor expanded in a around 0 56.1%
fma-def56.1%
unpow256.1%
*-commutative56.1%
unpow256.1%
unpow256.1%
swap-sqr56.1%
swap-sqr76.0%
unpow276.0%
*-commutative76.0%
associate-*r*76.2%
unpow276.2%
Simplified76.2%
Final simplification63.8%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (if (<= b 2.9e-13) (* a a) (pow (hypot a (* 0.005555555555555556 (* angle (* PI b)))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
double tmp;
if (b <= 2.9e-13) {
tmp = a * a;
} else {
tmp = pow(hypot(a, (0.005555555555555556 * (angle * (((double) M_PI) * b)))), 2.0);
}
return tmp;
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 2.9e-13) {
tmp = a * a;
} else {
tmp = Math.pow(Math.hypot(a, (0.005555555555555556 * (angle * (Math.PI * b)))), 2.0);
}
return tmp;
}
angle = abs(angle) def code(a, b, angle): tmp = 0 if b <= 2.9e-13: tmp = a * a else: tmp = math.pow(math.hypot(a, (0.005555555555555556 * (angle * (math.pi * b)))), 2.0) return tmp
angle = abs(angle) function code(a, b, angle) tmp = 0.0 if (b <= 2.9e-13) tmp = Float64(a * a); else tmp = hypot(a, Float64(0.005555555555555556 * Float64(angle * Float64(pi * b)))) ^ 2.0; end return tmp end
angle = abs(angle) function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 2.9e-13) tmp = a * a; else tmp = hypot(a, (0.005555555555555556 * (angle * (pi * b)))) ^ 2.0; end tmp_2 = tmp; end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[b, 2.9e-13], N[(a * a), $MachinePrecision], N[Power[N[Sqrt[a ^ 2 + N[(0.005555555555555556 * N[(angle * N[(Pi * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
angle = |angle|\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.9 \cdot 10^{-13}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, 0.005555555555555556 \cdot \left(angle \cdot \left(\pi \cdot b\right)\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if b < 2.8999999999999998e-13Initial program 74.0%
Taylor expanded in angle around 0 74.3%
Taylor expanded in angle around 0 67.6%
*-commutative67.6%
Simplified67.6%
*-commutative67.6%
unpow-prod-down67.5%
*-commutative67.5%
associate-*l*67.5%
metadata-eval67.5%
Applied egg-rr67.5%
Taylor expanded in a around inf 58.9%
unpow258.9%
Simplified58.9%
if 2.8999999999999998e-13 < b Initial program 80.0%
Taylor expanded in angle around 0 79.8%
Taylor expanded in angle around 0 75.9%
*-commutative75.9%
Simplified75.9%
*-commutative75.9%
unpow-prod-down76.0%
*-commutative76.0%
associate-*l*76.1%
metadata-eval76.1%
Applied egg-rr76.1%
add-sqr-sqrt76.0%
pow276.0%
Applied egg-rr75.9%
Final simplification63.7%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (if (<= b 2.2e-13) (* a a) (pow (hypot a (* 0.005555555555555556 (* PI (* angle b)))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
double tmp;
if (b <= 2.2e-13) {
tmp = a * a;
} else {
tmp = pow(hypot(a, (0.005555555555555556 * (((double) M_PI) * (angle * b)))), 2.0);
}
return tmp;
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 2.2e-13) {
tmp = a * a;
} else {
tmp = Math.pow(Math.hypot(a, (0.005555555555555556 * (Math.PI * (angle * b)))), 2.0);
}
return tmp;
}
angle = abs(angle) def code(a, b, angle): tmp = 0 if b <= 2.2e-13: tmp = a * a else: tmp = math.pow(math.hypot(a, (0.005555555555555556 * (math.pi * (angle * b)))), 2.0) return tmp
angle = abs(angle) function code(a, b, angle) tmp = 0.0 if (b <= 2.2e-13) tmp = Float64(a * a); else tmp = hypot(a, Float64(0.005555555555555556 * Float64(pi * Float64(angle * b)))) ^ 2.0; end return tmp end
angle = abs(angle) function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 2.2e-13) tmp = a * a; else tmp = hypot(a, (0.005555555555555556 * (pi * (angle * b)))) ^ 2.0; end tmp_2 = tmp; end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[b, 2.2e-13], N[(a * a), $MachinePrecision], N[Power[N[Sqrt[a ^ 2 + N[(0.005555555555555556 * N[(Pi * N[(angle * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
angle = |angle|\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.2 \cdot 10^{-13}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, 0.005555555555555556 \cdot \left(\pi \cdot \left(angle \cdot b\right)\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if b < 2.19999999999999997e-13Initial program 74.0%
Taylor expanded in angle around 0 74.3%
Taylor expanded in angle around 0 67.6%
*-commutative67.6%
Simplified67.6%
*-commutative67.6%
unpow-prod-down67.5%
*-commutative67.5%
associate-*l*67.5%
metadata-eval67.5%
Applied egg-rr67.5%
Taylor expanded in a around inf 58.9%
unpow258.9%
Simplified58.9%
if 2.19999999999999997e-13 < b Initial program 80.0%
Taylor expanded in angle around 0 79.8%
Taylor expanded in angle around 0 75.9%
*-commutative75.9%
Simplified75.9%
*-commutative75.9%
unpow-prod-down76.0%
*-commutative76.0%
associate-*l*76.1%
metadata-eval76.1%
Applied egg-rr76.1%
expm1-log1p-u74.6%
expm1-udef57.6%
Applied egg-rr57.6%
expm1-def74.4%
expm1-log1p75.9%
*-commutative75.9%
associate-*r*75.9%
Simplified75.9%
Final simplification63.7%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (if (<= b 2.6e-13) (* a a) (pow (hypot a (* (* angle 0.005555555555555556) (* PI b))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
double tmp;
if (b <= 2.6e-13) {
tmp = a * a;
} else {
tmp = pow(hypot(a, ((angle * 0.005555555555555556) * (((double) M_PI) * b))), 2.0);
}
return tmp;
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 2.6e-13) {
tmp = a * a;
} else {
tmp = Math.pow(Math.hypot(a, ((angle * 0.005555555555555556) * (Math.PI * b))), 2.0);
}
return tmp;
}
angle = abs(angle) def code(a, b, angle): tmp = 0 if b <= 2.6e-13: tmp = a * a else: tmp = math.pow(math.hypot(a, ((angle * 0.005555555555555556) * (math.pi * b))), 2.0) return tmp
angle = abs(angle) function code(a, b, angle) tmp = 0.0 if (b <= 2.6e-13) tmp = Float64(a * a); else tmp = hypot(a, Float64(Float64(angle * 0.005555555555555556) * Float64(pi * b))) ^ 2.0; end return tmp end
angle = abs(angle) function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 2.6e-13) tmp = a * a; else tmp = hypot(a, ((angle * 0.005555555555555556) * (pi * b))) ^ 2.0; end tmp_2 = tmp; end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[b, 2.6e-13], N[(a * a), $MachinePrecision], N[Power[N[Sqrt[a ^ 2 + N[(N[(angle * 0.005555555555555556), $MachinePrecision] * N[(Pi * b), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
angle = |angle|\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.6 \cdot 10^{-13}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, \left(angle \cdot 0.005555555555555556\right) \cdot \left(\pi \cdot b\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if b < 2.6e-13Initial program 74.0%
Taylor expanded in angle around 0 74.3%
Taylor expanded in angle around 0 67.6%
*-commutative67.6%
Simplified67.6%
*-commutative67.6%
unpow-prod-down67.5%
*-commutative67.5%
associate-*l*67.5%
metadata-eval67.5%
Applied egg-rr67.5%
Taylor expanded in a around inf 58.9%
unpow258.9%
Simplified58.9%
if 2.6e-13 < b Initial program 80.0%
Taylor expanded in angle around 0 79.8%
Taylor expanded in angle around 0 75.9%
*-commutative75.9%
Simplified75.9%
*-commutative75.9%
unpow-prod-down76.0%
*-commutative76.0%
associate-*l*76.1%
metadata-eval76.1%
Applied egg-rr76.1%
expm1-log1p-u74.6%
expm1-udef57.6%
Applied egg-rr57.6%
expm1-def74.4%
expm1-log1p75.9%
associate-*r*76.0%
Simplified76.0%
Final simplification63.7%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (* a a))
angle = abs(angle);
double code(double a, double b, double angle) {
return a * a;
}
NOTE: angle should be positive before calling this function
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
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
return a * a;
}
angle = abs(angle) def code(a, b, angle): return a * a
angle = abs(angle) function code(a, b, angle) return Float64(a * a) end
angle = abs(angle) function tmp = code(a, b, angle) tmp = a * a; end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := N[(a * a), $MachinePrecision]
\begin{array}{l}
angle = |angle|\\
\\
a \cdot a
\end{array}
Initial program 75.7%
Taylor expanded in angle around 0 75.8%
Taylor expanded in angle around 0 69.9%
*-commutative69.9%
Simplified69.9%
*-commutative69.9%
unpow-prod-down69.9%
*-commutative69.9%
associate-*l*70.0%
metadata-eval70.0%
Applied egg-rr70.0%
Taylor expanded in a around inf 51.9%
unpow251.9%
Simplified51.9%
Final simplification51.9%
herbie shell --seed 2023287
(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)))