
(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 8 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}
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (expm1 (log1p (* angle (* PI 0.005555555555555556)))))) 2.0) (pow b 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
return pow((a * sin(expm1(log1p((angle * (((double) M_PI) * 0.005555555555555556)))))), 2.0) + pow(b, 2.0);
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin(Math.expm1(Math.log1p((angle * (Math.PI * 0.005555555555555556)))))), 2.0) + Math.pow(b, 2.0);
}
angle = abs(angle) def code(a, b, angle): return math.pow((a * math.sin(math.expm1(math.log1p((angle * (math.pi * 0.005555555555555556)))))), 2.0) + math.pow(b, 2.0)
angle = abs(angle) function code(a, b, angle) return Float64((Float64(a * sin(expm1(log1p(Float64(angle * Float64(pi * 0.005555555555555556)))))) ^ 2.0) + (b ^ 2.0)) end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(Exp[N[Log[1 + N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle = |angle|\\
\\
{\left(a \cdot \sin \left(\mathsf{expm1}\left(\mathsf{log1p}\left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)\right)}^{2} + {b}^{2}
\end{array}
Initial program 80.0%
associate-*l/79.9%
associate-*r/80.0%
associate-*l/79.8%
associate-*r/79.9%
Simplified79.9%
Taylor expanded in angle around 0 80.3%
div-inv80.3%
metadata-eval80.3%
expm1-log1p-u67.8%
Applied egg-rr67.8%
Final simplification67.8%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (+ (pow b 2.0) (pow (* a (sin (* 0.005555555555555556 (* angle PI)))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
return pow(b, 2.0) + pow((a * sin((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0);
}
angle = Math.abs(angle);
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);
}
angle = abs(angle) def code(a, b, angle): return math.pow(b, 2.0) + math.pow((a * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0)
angle = abs(angle) function code(a, b, angle) return Float64((b ^ 2.0) + (Float64(a * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0)) end
angle = abs(angle) function tmp = code(a, b, angle) tmp = (b ^ 2.0) + ((a * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0); end
NOTE: angle should be positive before calling this function 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}
angle = |angle|\\
\\
{b}^{2} + {\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}
\end{array}
Initial program 80.0%
associate-*l/79.9%
associate-*r/80.0%
associate-*l/79.8%
associate-*r/79.9%
Simplified79.9%
Taylor expanded in angle around 0 80.3%
associate-*r/80.2%
expm1-log1p-u80.2%
associate-*r/80.3%
div-inv80.3%
metadata-eval80.3%
Applied egg-rr80.3%
Taylor expanded in a around 0 80.3%
Final simplification80.3%
NOTE: angle should be positive before calling this function
(FPCore (a b angle)
:precision binary64
(if (<= a 2.35e-33)
(* b b)
(+
(pow b 2.0)
(* 3.08641975308642e-5 (* PI (* (* angle (* a PI)) (* a angle)))))))angle = abs(angle);
double code(double a, double b, double angle) {
double tmp;
if (a <= 2.35e-33) {
tmp = b * b;
} else {
tmp = pow(b, 2.0) + (3.08641975308642e-5 * (((double) M_PI) * ((angle * (a * ((double) M_PI))) * (a * angle))));
}
return tmp;
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 2.35e-33) {
tmp = b * b;
} else {
tmp = Math.pow(b, 2.0) + (3.08641975308642e-5 * (Math.PI * ((angle * (a * Math.PI)) * (a * angle))));
}
return tmp;
}
angle = abs(angle) def code(a, b, angle): tmp = 0 if a <= 2.35e-33: tmp = b * b else: tmp = math.pow(b, 2.0) + (3.08641975308642e-5 * (math.pi * ((angle * (a * math.pi)) * (a * angle)))) return tmp
angle = abs(angle) function code(a, b, angle) tmp = 0.0 if (a <= 2.35e-33) tmp = Float64(b * b); else tmp = Float64((b ^ 2.0) + Float64(3.08641975308642e-5 * Float64(pi * Float64(Float64(angle * Float64(a * pi)) * Float64(a * angle))))); end return tmp end
angle = abs(angle) function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 2.35e-33) tmp = b * b; else tmp = (b ^ 2.0) + (3.08641975308642e-5 * (pi * ((angle * (a * pi)) * (a * angle)))); end tmp_2 = tmp; end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[a, 2.35e-33], N[(b * b), $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(3.08641975308642e-5 * N[(Pi * N[(N[(angle * N[(a * Pi), $MachinePrecision]), $MachinePrecision] * N[(a * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle = |angle|\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.35 \cdot 10^{-33}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + 3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \left(\left(angle \cdot \left(a \cdot \pi\right)\right) \cdot \left(a \cdot angle\right)\right)\right)\\
\end{array}
\end{array}
if a < 2.3500000000000001e-33Initial program 77.9%
associate-*l/77.9%
associate-*r/77.9%
associate-*l/77.7%
associate-*r/77.8%
Simplified77.8%
Taylor expanded in angle around 0 78.2%
div-inv78.2%
metadata-eval78.2%
expm1-log1p-u66.4%
Applied egg-rr66.4%
Taylor expanded in angle around 0 63.0%
*-commutative63.0%
unpow263.0%
unpow263.0%
swap-sqr63.0%
unpow263.0%
swap-sqr72.4%
associate-*r*72.4%
associate-*r*72.4%
unpow272.4%
associate-*r*72.4%
*-commutative72.4%
associate-*r*72.4%
*-commutative72.4%
*-commutative72.4%
Simplified72.4%
Taylor expanded in angle around 0 63.9%
unpow263.9%
Simplified63.9%
if 2.3500000000000001e-33 < a Initial program 85.5%
associate-*l/85.4%
associate-*r/85.5%
associate-*l/85.5%
associate-*r/85.5%
Simplified85.5%
Taylor expanded in angle around 0 85.6%
div-inv85.6%
metadata-eval85.6%
expm1-log1p-u71.7%
Applied egg-rr71.7%
Taylor expanded in angle around 0 72.2%
*-commutative72.2%
unpow272.2%
unpow272.2%
swap-sqr72.2%
unpow272.2%
swap-sqr83.4%
associate-*r*83.5%
associate-*r*83.4%
unpow283.4%
associate-*r*83.4%
*-commutative83.4%
associate-*r*83.5%
*-commutative83.5%
*-commutative83.5%
Simplified83.5%
unpow283.5%
*-commutative83.5%
associate-*r*83.6%
*-commutative83.6%
associate-*r*83.5%
*-commutative83.5%
Applied egg-rr83.5%
Final simplification69.3%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (if (<= a 1.6e-33) (* b b) (fma 3.08641975308642e-5 (pow (* a (* angle PI)) 2.0) (* b b))))
angle = abs(angle);
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.6e-33) {
tmp = b * b;
} else {
tmp = fma(3.08641975308642e-5, pow((a * (angle * ((double) M_PI))), 2.0), (b * b));
}
return tmp;
}
angle = abs(angle) function code(a, b, angle) tmp = 0.0 if (a <= 1.6e-33) tmp = Float64(b * b); else tmp = fma(3.08641975308642e-5, (Float64(a * Float64(angle * pi)) ^ 2.0), Float64(b * b)); end return tmp end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[a, 1.6e-33], N[(b * b), $MachinePrecision], N[(3.08641975308642e-5 * N[Power[N[(a * N[(angle * Pi), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle = |angle|\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.6 \cdot 10^{-33}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, {\left(a \cdot \left(angle \cdot \pi\right)\right)}^{2}, b \cdot b\right)\\
\end{array}
\end{array}
if a < 1.59999999999999988e-33Initial program 77.9%
associate-*l/77.9%
associate-*r/77.9%
associate-*l/77.7%
associate-*r/77.8%
Simplified77.8%
Taylor expanded in angle around 0 78.2%
div-inv78.2%
metadata-eval78.2%
expm1-log1p-u66.4%
Applied egg-rr66.4%
Taylor expanded in angle around 0 63.0%
*-commutative63.0%
unpow263.0%
unpow263.0%
swap-sqr63.0%
unpow263.0%
swap-sqr72.4%
associate-*r*72.4%
associate-*r*72.4%
unpow272.4%
associate-*r*72.4%
*-commutative72.4%
associate-*r*72.4%
*-commutative72.4%
*-commutative72.4%
Simplified72.4%
Taylor expanded in angle around 0 63.9%
unpow263.9%
Simplified63.9%
if 1.59999999999999988e-33 < a Initial program 85.5%
associate-*l/85.4%
associate-*r/85.5%
associate-*l/85.5%
associate-*r/85.5%
Simplified85.5%
Taylor expanded in angle around 0 85.6%
div-inv85.6%
metadata-eval85.6%
expm1-log1p-u71.7%
Applied egg-rr71.7%
Taylor expanded in angle around 0 72.2%
*-commutative72.2%
unpow272.2%
unpow272.2%
swap-sqr72.2%
unpow272.2%
swap-sqr83.4%
associate-*r*83.5%
associate-*r*83.4%
unpow283.4%
associate-*r*83.4%
*-commutative83.4%
associate-*r*83.5%
*-commutative83.5%
*-commutative83.5%
Simplified83.5%
Taylor expanded in angle around 0 72.2%
fma-def72.2%
associate-*r*72.2%
unpow272.2%
unpow272.2%
swap-sqr83.5%
unpow283.5%
swap-sqr83.5%
*-commutative83.5%
associate-*l*83.5%
*-commutative83.5%
associate-*l*83.4%
unpow283.4%
associate-*l*83.5%
*-commutative83.5%
associate-*r*83.4%
unpow283.4%
Simplified83.4%
Final simplification69.2%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (if (<= a 1.05e-33) (* b b) (fma b b (* 3.08641975308642e-5 (pow (* angle (* a PI)) 2.0)))))
angle = abs(angle);
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.05e-33) {
tmp = b * b;
} else {
tmp = fma(b, b, (3.08641975308642e-5 * pow((angle * (a * ((double) M_PI))), 2.0)));
}
return tmp;
}
angle = abs(angle) function code(a, b, angle) tmp = 0.0 if (a <= 1.05e-33) tmp = Float64(b * b); else tmp = fma(b, b, Float64(3.08641975308642e-5 * (Float64(angle * Float64(a * pi)) ^ 2.0))); end return tmp end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[a, 1.05e-33], N[(b * b), $MachinePrecision], N[(b * b + N[(3.08641975308642e-5 * N[Power[N[(angle * N[(a * Pi), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle = |angle|\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.05 \cdot 10^{-33}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, b, 3.08641975308642 \cdot 10^{-5} \cdot {\left(angle \cdot \left(a \cdot \pi\right)\right)}^{2}\right)\\
\end{array}
\end{array}
if a < 1.05e-33Initial program 77.9%
associate-*l/77.9%
associate-*r/77.9%
associate-*l/77.7%
associate-*r/77.8%
Simplified77.8%
Taylor expanded in angle around 0 78.2%
div-inv78.2%
metadata-eval78.2%
expm1-log1p-u66.4%
Applied egg-rr66.4%
Taylor expanded in angle around 0 63.0%
*-commutative63.0%
unpow263.0%
unpow263.0%
swap-sqr63.0%
unpow263.0%
swap-sqr72.4%
associate-*r*72.4%
associate-*r*72.4%
unpow272.4%
associate-*r*72.4%
*-commutative72.4%
associate-*r*72.4%
*-commutative72.4%
*-commutative72.4%
Simplified72.4%
Taylor expanded in angle around 0 63.9%
unpow263.9%
Simplified63.9%
if 1.05e-33 < a Initial program 85.5%
associate-*l/85.4%
associate-*r/85.5%
associate-*l/85.5%
associate-*r/85.5%
Simplified85.5%
Taylor expanded in angle around 0 85.6%
div-inv85.6%
metadata-eval85.6%
expm1-log1p-u71.7%
Applied egg-rr71.7%
Taylor expanded in angle around 0 72.2%
*-commutative72.2%
unpow272.2%
unpow272.2%
swap-sqr72.2%
unpow272.2%
swap-sqr83.4%
associate-*r*83.5%
associate-*r*83.4%
unpow283.4%
associate-*r*83.4%
*-commutative83.4%
associate-*r*83.5%
*-commutative83.5%
*-commutative83.5%
Simplified83.5%
+-commutative83.5%
*-rgt-identity83.5%
pow283.5%
fma-def83.5%
*-commutative83.5%
*-commutative83.5%
associate-*r*83.5%
Applied egg-rr83.5%
Final simplification69.3%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (if (<= a 1.35e-33) (* b b) (pow (hypot b (* 0.005555555555555556 (* angle (* a PI)))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.35e-33) {
tmp = b * b;
} else {
tmp = pow(hypot(b, (0.005555555555555556 * (angle * (a * ((double) M_PI))))), 2.0);
}
return tmp;
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.35e-33) {
tmp = b * b;
} else {
tmp = Math.pow(Math.hypot(b, (0.005555555555555556 * (angle * (a * Math.PI)))), 2.0);
}
return tmp;
}
angle = abs(angle) def code(a, b, angle): tmp = 0 if a <= 1.35e-33: tmp = b * b else: tmp = math.pow(math.hypot(b, (0.005555555555555556 * (angle * (a * math.pi)))), 2.0) return tmp
angle = abs(angle) function code(a, b, angle) tmp = 0.0 if (a <= 1.35e-33) tmp = Float64(b * b); else tmp = hypot(b, Float64(0.005555555555555556 * Float64(angle * Float64(a * pi)))) ^ 2.0; end return tmp end
angle = abs(angle) function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.35e-33) tmp = b * b; else tmp = hypot(b, (0.005555555555555556 * (angle * (a * pi)))) ^ 2.0; end tmp_2 = tmp; end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[a, 1.35e-33], N[(b * b), $MachinePrecision], N[Power[N[Sqrt[b ^ 2 + N[(0.005555555555555556 * N[(angle * N[(a * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
angle = |angle|\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.35 \cdot 10^{-33}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(b, 0.005555555555555556 \cdot \left(angle \cdot \left(a \cdot \pi\right)\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 1.35e-33Initial program 77.9%
associate-*l/77.9%
associate-*r/77.9%
associate-*l/77.7%
associate-*r/77.8%
Simplified77.8%
Taylor expanded in angle around 0 78.2%
div-inv78.2%
metadata-eval78.2%
expm1-log1p-u66.4%
Applied egg-rr66.4%
Taylor expanded in angle around 0 63.0%
*-commutative63.0%
unpow263.0%
unpow263.0%
swap-sqr63.0%
unpow263.0%
swap-sqr72.4%
associate-*r*72.4%
associate-*r*72.4%
unpow272.4%
associate-*r*72.4%
*-commutative72.4%
associate-*r*72.4%
*-commutative72.4%
*-commutative72.4%
Simplified72.4%
Taylor expanded in angle around 0 63.9%
unpow263.9%
Simplified63.9%
if 1.35e-33 < a Initial program 85.5%
associate-*l/85.4%
associate-*r/85.5%
associate-*l/85.5%
associate-*r/85.5%
Simplified85.5%
Taylor expanded in angle around 0 85.6%
div-inv85.6%
metadata-eval85.6%
expm1-log1p-u71.7%
Applied egg-rr71.7%
Taylor expanded in angle around 0 72.2%
*-commutative72.2%
unpow272.2%
unpow272.2%
swap-sqr72.2%
unpow272.2%
swap-sqr83.4%
associate-*r*83.5%
associate-*r*83.4%
unpow283.4%
associate-*r*83.4%
*-commutative83.4%
associate-*r*83.5%
*-commutative83.5%
*-commutative83.5%
Simplified83.5%
add-sqr-sqrt83.4%
pow283.4%
Applied egg-rr83.4%
Final simplification69.2%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (if (<= a 1e-33) (* b b) (pow (hypot b (* angle (* 0.005555555555555556 (* a PI)))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
double tmp;
if (a <= 1e-33) {
tmp = b * b;
} else {
tmp = pow(hypot(b, (angle * (0.005555555555555556 * (a * ((double) M_PI))))), 2.0);
}
return tmp;
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1e-33) {
tmp = b * b;
} else {
tmp = Math.pow(Math.hypot(b, (angle * (0.005555555555555556 * (a * Math.PI)))), 2.0);
}
return tmp;
}
angle = abs(angle) def code(a, b, angle): tmp = 0 if a <= 1e-33: tmp = b * b else: tmp = math.pow(math.hypot(b, (angle * (0.005555555555555556 * (a * math.pi)))), 2.0) return tmp
angle = abs(angle) function code(a, b, angle) tmp = 0.0 if (a <= 1e-33) tmp = Float64(b * b); else tmp = hypot(b, Float64(angle * Float64(0.005555555555555556 * Float64(a * pi)))) ^ 2.0; end return tmp end
angle = abs(angle) function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1e-33) tmp = b * b; else tmp = hypot(b, (angle * (0.005555555555555556 * (a * pi)))) ^ 2.0; end tmp_2 = tmp; end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[a, 1e-33], N[(b * b), $MachinePrecision], N[Power[N[Sqrt[b ^ 2 + N[(angle * N[(0.005555555555555556 * N[(a * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
angle = |angle|\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 10^{-33}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(b, angle \cdot \left(0.005555555555555556 \cdot \left(a \cdot \pi\right)\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 1.0000000000000001e-33Initial program 77.9%
associate-*l/77.9%
associate-*r/77.9%
associate-*l/77.7%
associate-*r/77.8%
Simplified77.8%
Taylor expanded in angle around 0 78.2%
div-inv78.2%
metadata-eval78.2%
expm1-log1p-u66.4%
Applied egg-rr66.4%
Taylor expanded in angle around 0 63.0%
*-commutative63.0%
unpow263.0%
unpow263.0%
swap-sqr63.0%
unpow263.0%
swap-sqr72.4%
associate-*r*72.4%
associate-*r*72.4%
unpow272.4%
associate-*r*72.4%
*-commutative72.4%
associate-*r*72.4%
*-commutative72.4%
*-commutative72.4%
Simplified72.4%
Taylor expanded in angle around 0 63.9%
unpow263.9%
Simplified63.9%
if 1.0000000000000001e-33 < a Initial program 85.5%
associate-*l/85.4%
associate-*r/85.5%
associate-*l/85.5%
associate-*r/85.5%
Simplified85.5%
Taylor expanded in angle around 0 85.6%
div-inv85.6%
metadata-eval85.6%
expm1-log1p-u71.7%
Applied egg-rr71.7%
Taylor expanded in angle around 0 72.2%
*-commutative72.2%
unpow272.2%
unpow272.2%
swap-sqr72.2%
unpow272.2%
swap-sqr83.4%
associate-*r*83.5%
associate-*r*83.4%
unpow283.4%
associate-*r*83.4%
*-commutative83.4%
associate-*r*83.5%
*-commutative83.5%
*-commutative83.5%
Simplified83.5%
expm1-log1p-u81.9%
expm1-udef74.8%
Applied egg-rr74.8%
expm1-def81.9%
expm1-log1p83.4%
associate-*r*83.5%
*-commutative83.5%
Simplified83.5%
Final simplification69.3%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (* b b))
angle = abs(angle);
double code(double a, double b, double angle) {
return b * b;
}
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 = b * b
end function
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
return b * b;
}
angle = abs(angle) def code(a, b, angle): return b * b
angle = abs(angle) function code(a, b, angle) return Float64(b * b) end
angle = abs(angle) function tmp = code(a, b, angle) tmp = b * b; end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := N[(b * b), $MachinePrecision]
\begin{array}{l}
angle = |angle|\\
\\
b \cdot b
\end{array}
Initial program 80.0%
associate-*l/79.9%
associate-*r/80.0%
associate-*l/79.8%
associate-*r/79.9%
Simplified79.9%
Taylor expanded in angle around 0 80.3%
div-inv80.3%
metadata-eval80.3%
expm1-log1p-u67.8%
Applied egg-rr67.8%
Taylor expanded in angle around 0 65.5%
*-commutative65.5%
unpow265.5%
unpow265.5%
swap-sqr65.5%
unpow265.5%
swap-sqr75.4%
associate-*r*75.4%
associate-*r*75.4%
unpow275.4%
associate-*r*75.4%
*-commutative75.4%
associate-*r*75.4%
*-commutative75.4%
*-commutative75.4%
Simplified75.4%
Taylor expanded in angle around 0 62.2%
unpow262.2%
Simplified62.2%
Final simplification62.2%
herbie shell --seed 2023279
(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)))