
(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}
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(+
(pow (* a (cos (/ PI (/ -180.0 angle_m)))) 2.0)
(pow
(*
b
(sin (* (sqrt angle_m) (* (* PI -0.005555555555555556) (sqrt angle_m)))))
2.0)))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow((a * cos((((double) M_PI) / (-180.0 / angle_m)))), 2.0) + pow((b * sin((sqrt(angle_m) * ((((double) M_PI) * -0.005555555555555556) * sqrt(angle_m))))), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow((a * Math.cos((Math.PI / (-180.0 / angle_m)))), 2.0) + Math.pow((b * Math.sin((Math.sqrt(angle_m) * ((Math.PI * -0.005555555555555556) * Math.sqrt(angle_m))))), 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow((a * math.cos((math.pi / (-180.0 / angle_m)))), 2.0) + math.pow((b * math.sin((math.sqrt(angle_m) * ((math.pi * -0.005555555555555556) * math.sqrt(angle_m))))), 2.0)
angle_m = abs(angle) function code(a, b, angle_m) return Float64((Float64(a * cos(Float64(pi / Float64(-180.0 / angle_m)))) ^ 2.0) + (Float64(b * sin(Float64(sqrt(angle_m) * Float64(Float64(pi * -0.005555555555555556) * sqrt(angle_m))))) ^ 2.0)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = ((a * cos((pi / (-180.0 / angle_m)))) ^ 2.0) + ((b * sin((sqrt(angle_m) * ((pi * -0.005555555555555556) * sqrt(angle_m))))) ^ 2.0); end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[N[(a * N[Cos[N[(Pi / N[(-180.0 / angle$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(N[Sqrt[angle$95$m], $MachinePrecision] * N[(N[(Pi * -0.005555555555555556), $MachinePrecision] * N[Sqrt[angle$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{\left(a \cdot \cos \left(\frac{\pi}{\frac{-180}{angle_m}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\sqrt{angle_m} \cdot \left(\left(\pi \cdot -0.005555555555555556\right) \cdot \sqrt{angle_m}\right)\right)\right)}^{2}
\end{array}
Initial program 77.4%
Simplified77.5%
associate-/r/77.5%
add-sqr-sqrt36.8%
associate-*r*36.8%
div-inv36.8%
metadata-eval36.8%
Applied egg-rr36.8%
Final simplification36.8%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (let* ((t_0 (* angle_m (/ PI -180.0)))) (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double t_0 = angle_m * (((double) M_PI) / -180.0);
return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double t_0 = angle_m * (Math.PI / -180.0);
return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): t_0 = angle_m * (math.pi / -180.0) return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
angle_m = abs(angle) function code(a, b, angle_m) t_0 = Float64(angle_m * Float64(pi / -180.0)) return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) t_0 = angle_m * (pi / -180.0); tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0); end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := Block[{t$95$0 = N[(angle$95$m * N[(Pi / -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}
angle_m = \left|angle\right|
\\
\begin{array}{l}
t_0 := angle_m \cdot \frac{\pi}{-180}\\
{\left(a \cdot \cos t_0\right)}^{2} + {\left(b \cdot \sin t_0\right)}^{2}
\end{array}
\end{array}
Initial program 77.4%
Simplified77.5%
Final simplification77.5%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (+ (pow a 2.0) (pow (* b (sin (* -0.005555555555555556 (* PI angle_m)))) 2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow(a, 2.0) + pow((b * sin((-0.005555555555555556 * (((double) M_PI) * angle_m)))), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow(a, 2.0) + Math.pow((b * Math.sin((-0.005555555555555556 * (Math.PI * angle_m)))), 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow(a, 2.0) + math.pow((b * math.sin((-0.005555555555555556 * (math.pi * angle_m)))), 2.0)
angle_m = abs(angle) function code(a, b, angle_m) return Float64((a ^ 2.0) + (Float64(b * sin(Float64(-0.005555555555555556 * Float64(pi * angle_m)))) ^ 2.0)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = (a ^ 2.0) + ((b * sin((-0.005555555555555556 * (pi * angle_m)))) ^ 2.0); end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(-0.005555555555555556 * N[(Pi * angle$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{a}^{2} + {\left(b \cdot \sin \left(-0.005555555555555556 \cdot \left(\pi \cdot angle_m\right)\right)\right)}^{2}
\end{array}
Initial program 77.4%
Simplified77.5%
Taylor expanded in angle around 0 76.6%
Taylor expanded in angle around inf 76.6%
Final simplification76.6%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (+ (pow (* b (sin (* angle_m (/ PI -180.0)))) 2.0) (pow a 2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow((b * sin((angle_m * (((double) M_PI) / -180.0)))), 2.0) + pow(a, 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow((b * Math.sin((angle_m * (Math.PI / -180.0)))), 2.0) + Math.pow(a, 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow((b * math.sin((angle_m * (math.pi / -180.0)))), 2.0) + math.pow(a, 2.0)
angle_m = abs(angle) function code(a, b, angle_m) return Float64((Float64(b * sin(Float64(angle_m * Float64(pi / -180.0)))) ^ 2.0) + (a ^ 2.0)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = ((b * sin((angle_m * (pi / -180.0)))) ^ 2.0) + (a ^ 2.0); end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[N[(b * N[Sin[N[(angle$95$m * N[(Pi / -180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{\left(b \cdot \sin \left(angle_m \cdot \frac{\pi}{-180}\right)\right)}^{2} + {a}^{2}
\end{array}
Initial program 77.4%
Simplified77.5%
Taylor expanded in angle around 0 76.6%
Final simplification76.6%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= b 2.7e-80)
(pow a 2.0)
(+
(pow a 2.0)
(*
b
(*
(* PI angle_m)
(*
angle_m
(* -0.005555555555555556 (* -0.005555555555555556 (* PI b)))))))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (b <= 2.7e-80) {
tmp = pow(a, 2.0);
} else {
tmp = pow(a, 2.0) + (b * ((((double) M_PI) * angle_m) * (angle_m * (-0.005555555555555556 * (-0.005555555555555556 * (((double) M_PI) * b))))));
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (b <= 2.7e-80) {
tmp = Math.pow(a, 2.0);
} else {
tmp = Math.pow(a, 2.0) + (b * ((Math.PI * angle_m) * (angle_m * (-0.005555555555555556 * (-0.005555555555555556 * (Math.PI * b))))));
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if b <= 2.7e-80: tmp = math.pow(a, 2.0) else: tmp = math.pow(a, 2.0) + (b * ((math.pi * angle_m) * (angle_m * (-0.005555555555555556 * (-0.005555555555555556 * (math.pi * b)))))) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (b <= 2.7e-80) tmp = a ^ 2.0; else tmp = Float64((a ^ 2.0) + Float64(b * Float64(Float64(pi * angle_m) * Float64(angle_m * Float64(-0.005555555555555556 * Float64(-0.005555555555555556 * Float64(pi * b))))))); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (b <= 2.7e-80) tmp = a ^ 2.0; else tmp = (a ^ 2.0) + (b * ((pi * angle_m) * (angle_m * (-0.005555555555555556 * (-0.005555555555555556 * (pi * b)))))); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[b, 2.7e-80], N[Power[a, 2.0], $MachinePrecision], N[(N[Power[a, 2.0], $MachinePrecision] + N[(b * N[(N[(Pi * angle$95$m), $MachinePrecision] * N[(angle$95$m * N[(-0.005555555555555556 * N[(-0.005555555555555556 * N[(Pi * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.7 \cdot 10^{-80}:\\
\;\;\;\;{a}^{2}\\
\mathbf{else}:\\
\;\;\;\;{a}^{2} + b \cdot \left(\left(\pi \cdot angle_m\right) \cdot \left(angle_m \cdot \left(-0.005555555555555556 \cdot \left(-0.005555555555555556 \cdot \left(\pi \cdot b\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if b < 2.7000000000000002e-80Initial program 74.9%
Simplified75.1%
Taylor expanded in angle around 0 74.3%
Taylor expanded in angle around 0 65.1%
unpow265.1%
associate-*l*65.0%
*-commutative65.0%
associate-*l*65.1%
*-commutative65.1%
associate-*r*65.1%
*-commutative65.1%
associate-*l*65.1%
*-commutative65.1%
Applied egg-rr65.1%
*-commutative65.1%
associate-*r*64.6%
*-commutative64.6%
*-commutative64.6%
rem-square-sqrt36.8%
fabs-sqr36.8%
rem-square-sqrt50.7%
fabs-mul50.7%
unpow150.7%
sqr-pow30.3%
fabs-sqr30.3%
sqr-pow64.6%
unpow164.6%
associate-*r*64.6%
*-commutative64.6%
*-commutative64.6%
fabs-mul64.6%
Simplified41.2%
Taylor expanded in a around inf 56.1%
if 2.7000000000000002e-80 < b Initial program 83.8%
Simplified83.8%
Taylor expanded in angle around 0 82.7%
Taylor expanded in angle around 0 80.4%
unpow280.4%
associate-*l*80.4%
*-commutative80.4%
associate-*l*80.4%
*-commutative80.4%
associate-*r*80.4%
*-commutative80.4%
associate-*l*80.4%
*-commutative80.4%
Applied egg-rr80.4%
associate-*r*80.4%
*-commutative80.4%
associate-*r*80.4%
associate-*l*80.4%
*-commutative80.4%
associate-*l*80.4%
*-commutative80.4%
Simplified80.4%
Final simplification62.9%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (let* ((t_0 (* angle_m (* -0.005555555555555556 (* PI b))))) (if (<= b 4e-80) (pow a 2.0) (+ (pow a 2.0) (* t_0 t_0)))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double t_0 = angle_m * (-0.005555555555555556 * (((double) M_PI) * b));
double tmp;
if (b <= 4e-80) {
tmp = pow(a, 2.0);
} else {
tmp = pow(a, 2.0) + (t_0 * t_0);
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double t_0 = angle_m * (-0.005555555555555556 * (Math.PI * b));
double tmp;
if (b <= 4e-80) {
tmp = Math.pow(a, 2.0);
} else {
tmp = Math.pow(a, 2.0) + (t_0 * t_0);
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): t_0 = angle_m * (-0.005555555555555556 * (math.pi * b)) tmp = 0 if b <= 4e-80: tmp = math.pow(a, 2.0) else: tmp = math.pow(a, 2.0) + (t_0 * t_0) return tmp
angle_m = abs(angle) function code(a, b, angle_m) t_0 = Float64(angle_m * Float64(-0.005555555555555556 * Float64(pi * b))) tmp = 0.0 if (b <= 4e-80) tmp = a ^ 2.0; else tmp = Float64((a ^ 2.0) + Float64(t_0 * t_0)); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) t_0 = angle_m * (-0.005555555555555556 * (pi * b)); tmp = 0.0; if (b <= 4e-80) tmp = a ^ 2.0; else tmp = (a ^ 2.0) + (t_0 * t_0); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := Block[{t$95$0 = N[(angle$95$m * N[(-0.005555555555555556 * N[(Pi * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 4e-80], N[Power[a, 2.0], $MachinePrecision], N[(N[Power[a, 2.0], $MachinePrecision] + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
t_0 := angle_m \cdot \left(-0.005555555555555556 \cdot \left(\pi \cdot b\right)\right)\\
\mathbf{if}\;b \leq 4 \cdot 10^{-80}:\\
\;\;\;\;{a}^{2}\\
\mathbf{else}:\\
\;\;\;\;{a}^{2} + t_0 \cdot t_0\\
\end{array}
\end{array}
if b < 3.99999999999999985e-80Initial program 74.9%
Simplified75.1%
Taylor expanded in angle around 0 74.3%
Taylor expanded in angle around 0 65.1%
unpow265.1%
associate-*l*65.0%
*-commutative65.0%
associate-*l*65.1%
*-commutative65.1%
associate-*r*65.1%
*-commutative65.1%
associate-*l*65.1%
*-commutative65.1%
Applied egg-rr65.1%
*-commutative65.1%
associate-*r*64.6%
*-commutative64.6%
*-commutative64.6%
rem-square-sqrt36.8%
fabs-sqr36.8%
rem-square-sqrt50.7%
fabs-mul50.7%
unpow150.7%
sqr-pow30.3%
fabs-sqr30.3%
sqr-pow64.6%
unpow164.6%
associate-*r*64.6%
*-commutative64.6%
*-commutative64.6%
fabs-mul64.6%
Simplified41.2%
Taylor expanded in a around inf 56.1%
if 3.99999999999999985e-80 < b Initial program 83.8%
Simplified83.8%
Taylor expanded in angle around 0 82.7%
Taylor expanded in angle around 0 80.4%
unpow280.4%
associate-*r*80.3%
*-commutative80.3%
associate-*l*80.4%
*-commutative80.4%
associate-*r*80.3%
*-commutative80.3%
associate-*l*80.3%
*-commutative80.3%
Applied egg-rr80.3%
Final simplification62.9%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= b 1.65e-79)
(pow a 2.0)
(+
(pow a 2.0)
(*
-0.005555555555555556
(*
(* angle_m (* -0.005555555555555556 (* PI b)))
(* b (* PI angle_m)))))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (b <= 1.65e-79) {
tmp = pow(a, 2.0);
} else {
tmp = pow(a, 2.0) + (-0.005555555555555556 * ((angle_m * (-0.005555555555555556 * (((double) M_PI) * b))) * (b * (((double) M_PI) * angle_m))));
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (b <= 1.65e-79) {
tmp = Math.pow(a, 2.0);
} else {
tmp = Math.pow(a, 2.0) + (-0.005555555555555556 * ((angle_m * (-0.005555555555555556 * (Math.PI * b))) * (b * (Math.PI * angle_m))));
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if b <= 1.65e-79: tmp = math.pow(a, 2.0) else: tmp = math.pow(a, 2.0) + (-0.005555555555555556 * ((angle_m * (-0.005555555555555556 * (math.pi * b))) * (b * (math.pi * angle_m)))) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (b <= 1.65e-79) tmp = a ^ 2.0; else tmp = Float64((a ^ 2.0) + Float64(-0.005555555555555556 * Float64(Float64(angle_m * Float64(-0.005555555555555556 * Float64(pi * b))) * Float64(b * Float64(pi * angle_m))))); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (b <= 1.65e-79) tmp = a ^ 2.0; else tmp = (a ^ 2.0) + (-0.005555555555555556 * ((angle_m * (-0.005555555555555556 * (pi * b))) * (b * (pi * angle_m)))); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[b, 1.65e-79], N[Power[a, 2.0], $MachinePrecision], N[(N[Power[a, 2.0], $MachinePrecision] + N[(-0.005555555555555556 * N[(N[(angle$95$m * N[(-0.005555555555555556 * N[(Pi * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(b * N[(Pi * angle$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.65 \cdot 10^{-79}:\\
\;\;\;\;{a}^{2}\\
\mathbf{else}:\\
\;\;\;\;{a}^{2} + -0.005555555555555556 \cdot \left(\left(angle_m \cdot \left(-0.005555555555555556 \cdot \left(\pi \cdot b\right)\right)\right) \cdot \left(b \cdot \left(\pi \cdot angle_m\right)\right)\right)\\
\end{array}
\end{array}
if b < 1.6499999999999999e-79Initial program 74.9%
Simplified75.1%
Taylor expanded in angle around 0 74.3%
Taylor expanded in angle around 0 65.1%
unpow265.1%
associate-*l*65.0%
*-commutative65.0%
associate-*l*65.1%
*-commutative65.1%
associate-*r*65.1%
*-commutative65.1%
associate-*l*65.1%
*-commutative65.1%
Applied egg-rr65.1%
*-commutative65.1%
associate-*r*64.6%
*-commutative64.6%
*-commutative64.6%
rem-square-sqrt36.8%
fabs-sqr36.8%
rem-square-sqrt50.7%
fabs-mul50.7%
unpow150.7%
sqr-pow30.3%
fabs-sqr30.3%
sqr-pow64.6%
unpow164.6%
associate-*r*64.6%
*-commutative64.6%
*-commutative64.6%
fabs-mul64.6%
Simplified41.2%
Taylor expanded in a around inf 56.1%
if 1.6499999999999999e-79 < b Initial program 83.8%
Simplified83.8%
Taylor expanded in angle around 0 82.7%
Taylor expanded in angle around 0 80.4%
unpow280.4%
*-commutative80.4%
associate-*r*80.4%
associate-*r*80.3%
*-commutative80.3%
associate-*l*80.3%
*-commutative80.3%
*-commutative80.3%
associate-*l*80.4%
*-commutative80.4%
Applied egg-rr80.4%
Final simplification62.9%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (pow a 2.0))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow(a, 2.0);
}
angle_m = abs(angle)
real(8) function code(a, b, angle_m)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle_m
code = a ** 2.0d0
end function
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow(a, 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow(a, 2.0)
angle_m = abs(angle) function code(a, b, angle_m) return a ^ 2.0 end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = a ^ 2.0; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[Power[a, 2.0], $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{a}^{2}
\end{array}
Initial program 77.4%
Simplified77.5%
Taylor expanded in angle around 0 76.6%
Taylor expanded in angle around 0 69.4%
unpow269.4%
associate-*l*69.4%
*-commutative69.4%
associate-*l*69.4%
*-commutative69.4%
associate-*r*69.4%
*-commutative69.4%
associate-*l*69.4%
*-commutative69.4%
Applied egg-rr69.4%
*-commutative69.4%
associate-*r*67.6%
*-commutative67.6%
*-commutative67.6%
rem-square-sqrt36.5%
fabs-sqr36.5%
rem-square-sqrt50.9%
fabs-mul50.9%
unpow150.9%
sqr-pow26.2%
fabs-sqr26.2%
sqr-pow54.8%
unpow154.8%
associate-*r*54.8%
*-commutative54.8%
*-commutative54.8%
fabs-mul54.8%
Simplified38.0%
Taylor expanded in a around inf 52.7%
Final simplification52.7%
herbie shell --seed 2024014
(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)))