
(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 7 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 (* angle (* 0.005555555555555556 PI)))) 2.0)))
double code(double a, double b, double angle) {
return pow(a, 2.0) + pow((b * sin((angle * (0.005555555555555556 * ((double) M_PI))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow(a, 2.0) + Math.pow((b * Math.sin((angle * (0.005555555555555556 * Math.PI)))), 2.0);
}
def code(a, b, angle): return math.pow(a, 2.0) + math.pow((b * math.sin((angle * (0.005555555555555556 * math.pi)))), 2.0)
function code(a, b, angle) return Float64((a ^ 2.0) + (Float64(b * sin(Float64(angle * Float64(0.005555555555555556 * pi)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a ^ 2.0) + ((b * sin((angle * (0.005555555555555556 * pi)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(angle * N[(0.005555555555555556 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{a}^{2} + {\left(b \cdot \sin \left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right)\right)}^{2}
\end{array}
Initial program 79.4%
Taylor expanded in angle around 0 79.6%
Taylor expanded in angle around inf 79.7%
associate-*r*79.6%
*-commutative79.6%
associate-*l*79.8%
Simplified79.8%
Final simplification79.8%
(FPCore (a b angle) :precision binary64 (+ (pow a 2.0) (pow (* b (sin (* 0.005555555555555556 (* angle PI)))) 2.0)))
double code(double a, double b, double angle) {
return pow(a, 2.0) + pow((b * sin((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow(a, 2.0) + Math.pow((b * Math.sin((0.005555555555555556 * (angle * Math.PI)))), 2.0);
}
def code(a, b, angle): return math.pow(a, 2.0) + math.pow((b * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0)
function code(a, b, angle) return Float64((a ^ 2.0) + (Float64(b * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a ^ 2.0) + ((b * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{a}^{2} + {\left(b \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}
\end{array}
Initial program 79.4%
Taylor expanded in angle around 0 79.6%
Taylor expanded in angle around inf 79.7%
Final simplification79.7%
(FPCore (a b angle)
:precision binary64
(if (<= b -9.2e+38)
(+ (pow a 2.0) (pow (* 0.005555555555555556 (* PI (* b angle))) 2.0))
(if (<= b 67000000000000.0)
(+ (pow a 2.0) (pow (* b 0.0) 2.0))
(+
(pow a 2.0)
(*
(* angle 0.005555555555555556)
(* (* b PI) (* angle (* 0.005555555555555556 (* b PI)))))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= -9.2e+38) {
tmp = pow(a, 2.0) + pow((0.005555555555555556 * (((double) M_PI) * (b * angle))), 2.0);
} else if (b <= 67000000000000.0) {
tmp = pow(a, 2.0) + pow((b * 0.0), 2.0);
} else {
tmp = pow(a, 2.0) + ((angle * 0.005555555555555556) * ((b * ((double) M_PI)) * (angle * (0.005555555555555556 * (b * ((double) M_PI))))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= -9.2e+38) {
tmp = Math.pow(a, 2.0) + Math.pow((0.005555555555555556 * (Math.PI * (b * angle))), 2.0);
} else if (b <= 67000000000000.0) {
tmp = Math.pow(a, 2.0) + Math.pow((b * 0.0), 2.0);
} else {
tmp = Math.pow(a, 2.0) + ((angle * 0.005555555555555556) * ((b * Math.PI) * (angle * (0.005555555555555556 * (b * Math.PI)))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= -9.2e+38: tmp = math.pow(a, 2.0) + math.pow((0.005555555555555556 * (math.pi * (b * angle))), 2.0) elif b <= 67000000000000.0: tmp = math.pow(a, 2.0) + math.pow((b * 0.0), 2.0) else: tmp = math.pow(a, 2.0) + ((angle * 0.005555555555555556) * ((b * math.pi) * (angle * (0.005555555555555556 * (b * math.pi))))) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= -9.2e+38) tmp = Float64((a ^ 2.0) + (Float64(0.005555555555555556 * Float64(pi * Float64(b * angle))) ^ 2.0)); elseif (b <= 67000000000000.0) tmp = Float64((a ^ 2.0) + (Float64(b * 0.0) ^ 2.0)); else tmp = Float64((a ^ 2.0) + Float64(Float64(angle * 0.005555555555555556) * Float64(Float64(b * pi) * Float64(angle * Float64(0.005555555555555556 * Float64(b * pi)))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= -9.2e+38) tmp = (a ^ 2.0) + ((0.005555555555555556 * (pi * (b * angle))) ^ 2.0); elseif (b <= 67000000000000.0) tmp = (a ^ 2.0) + ((b * 0.0) ^ 2.0); else tmp = (a ^ 2.0) + ((angle * 0.005555555555555556) * ((b * pi) * (angle * (0.005555555555555556 * (b * pi))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, -9.2e+38], N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(0.005555555555555556 * N[(Pi * N[(b * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 67000000000000.0], N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(b * 0.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 2.0], $MachinePrecision] + N[(N[(angle * 0.005555555555555556), $MachinePrecision] * N[(N[(b * Pi), $MachinePrecision] * N[(angle * N[(0.005555555555555556 * N[(b * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.2 \cdot 10^{+38}:\\
\;\;\;\;{a}^{2} + {\left(0.005555555555555556 \cdot \left(\pi \cdot \left(b \cdot angle\right)\right)\right)}^{2}\\
\mathbf{elif}\;b \leq 67000000000000:\\
\;\;\;\;{a}^{2} + {\left(b \cdot 0\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;{a}^{2} + \left(angle \cdot 0.005555555555555556\right) \cdot \left(\left(b \cdot \pi\right) \cdot \left(angle \cdot \left(0.005555555555555556 \cdot \left(b \cdot \pi\right)\right)\right)\right)\\
\end{array}
\end{array}
if b < -9.2000000000000005e38Initial program 85.3%
Taylor expanded in angle around 0 85.3%
Taylor expanded in angle around 0 81.5%
associate-*r*81.5%
*-commutative81.5%
Simplified81.5%
if -9.2000000000000005e38 < b < 6.7e13Initial program 75.7%
Taylor expanded in angle around 0 76.0%
add-cube-cbrt76.1%
pow376.2%
div-inv76.2%
metadata-eval76.2%
Applied egg-rr76.2%
Taylor expanded in angle around 0 73.2%
if 6.7e13 < b Initial program 85.3%
Taylor expanded in angle around 0 85.2%
Taylor expanded in angle around 0 80.8%
*-commutative80.8%
Simplified80.8%
unpow280.8%
associate-*r*80.9%
*-commutative80.9%
associate-*l*80.9%
associate-*r*80.9%
*-commutative80.9%
associate-*l*80.9%
Applied egg-rr80.9%
Final simplification76.3%
(FPCore (a b angle) :precision binary64 (if (or (<= b -3.35e+38) (not (<= b 67000000000000.0))) (+ (pow a 2.0) (* (pow (* angle (* b PI)) 2.0) 3.08641975308642e-5)) (+ (pow a 2.0) (pow (* b 0.0) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if ((b <= -3.35e+38) || !(b <= 67000000000000.0)) {
tmp = pow(a, 2.0) + (pow((angle * (b * ((double) M_PI))), 2.0) * 3.08641975308642e-5);
} else {
tmp = pow(a, 2.0) + pow((b * 0.0), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if ((b <= -3.35e+38) || !(b <= 67000000000000.0)) {
tmp = Math.pow(a, 2.0) + (Math.pow((angle * (b * Math.PI)), 2.0) * 3.08641975308642e-5);
} else {
tmp = Math.pow(a, 2.0) + Math.pow((b * 0.0), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if (b <= -3.35e+38) or not (b <= 67000000000000.0): tmp = math.pow(a, 2.0) + (math.pow((angle * (b * math.pi)), 2.0) * 3.08641975308642e-5) else: tmp = math.pow(a, 2.0) + math.pow((b * 0.0), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if ((b <= -3.35e+38) || !(b <= 67000000000000.0)) tmp = Float64((a ^ 2.0) + Float64((Float64(angle * Float64(b * pi)) ^ 2.0) * 3.08641975308642e-5)); else tmp = Float64((a ^ 2.0) + (Float64(b * 0.0) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if ((b <= -3.35e+38) || ~((b <= 67000000000000.0))) tmp = (a ^ 2.0) + (((angle * (b * pi)) ^ 2.0) * 3.08641975308642e-5); else tmp = (a ^ 2.0) + ((b * 0.0) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[Or[LessEqual[b, -3.35e+38], N[Not[LessEqual[b, 67000000000000.0]], $MachinePrecision]], N[(N[Power[a, 2.0], $MachinePrecision] + N[(N[Power[N[(angle * N[(b * Pi), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(b * 0.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.35 \cdot 10^{+38} \lor \neg \left(b \leq 67000000000000\right):\\
\;\;\;\;{a}^{2} + {\left(angle \cdot \left(b \cdot \pi\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\
\mathbf{else}:\\
\;\;\;\;{a}^{2} + {\left(b \cdot 0\right)}^{2}\\
\end{array}
\end{array}
if b < -3.35000000000000012e38 or 6.7e13 < b Initial program 85.3%
Taylor expanded in angle around 0 85.2%
Taylor expanded in angle around 0 81.1%
*-commutative81.1%
Simplified81.1%
*-commutative81.1%
unpow-prod-down81.1%
metadata-eval81.1%
Applied egg-rr81.1%
if -3.35000000000000012e38 < b < 6.7e13Initial program 75.7%
Taylor expanded in angle around 0 76.0%
add-cube-cbrt76.1%
pow376.2%
div-inv76.2%
metadata-eval76.2%
Applied egg-rr76.2%
Taylor expanded in angle around 0 73.2%
Final simplification76.3%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* angle (* b PI))))
(if (<= b -3.35e+38)
(+ (pow a 2.0) (pow (* 0.005555555555555556 t_0) 2.0))
(if (<= b 3.4e+14)
(+ (pow a 2.0) (pow (* b 0.0) 2.0))
(+ (pow a 2.0) (* (pow t_0 2.0) 3.08641975308642e-5))))))
double code(double a, double b, double angle) {
double t_0 = angle * (b * ((double) M_PI));
double tmp;
if (b <= -3.35e+38) {
tmp = pow(a, 2.0) + pow((0.005555555555555556 * t_0), 2.0);
} else if (b <= 3.4e+14) {
tmp = pow(a, 2.0) + pow((b * 0.0), 2.0);
} else {
tmp = pow(a, 2.0) + (pow(t_0, 2.0) * 3.08641975308642e-5);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = angle * (b * Math.PI);
double tmp;
if (b <= -3.35e+38) {
tmp = Math.pow(a, 2.0) + Math.pow((0.005555555555555556 * t_0), 2.0);
} else if (b <= 3.4e+14) {
tmp = Math.pow(a, 2.0) + Math.pow((b * 0.0), 2.0);
} else {
tmp = Math.pow(a, 2.0) + (Math.pow(t_0, 2.0) * 3.08641975308642e-5);
}
return tmp;
}
def code(a, b, angle): t_0 = angle * (b * math.pi) tmp = 0 if b <= -3.35e+38: tmp = math.pow(a, 2.0) + math.pow((0.005555555555555556 * t_0), 2.0) elif b <= 3.4e+14: tmp = math.pow(a, 2.0) + math.pow((b * 0.0), 2.0) else: tmp = math.pow(a, 2.0) + (math.pow(t_0, 2.0) * 3.08641975308642e-5) return tmp
function code(a, b, angle) t_0 = Float64(angle * Float64(b * pi)) tmp = 0.0 if (b <= -3.35e+38) tmp = Float64((a ^ 2.0) + (Float64(0.005555555555555556 * t_0) ^ 2.0)); elseif (b <= 3.4e+14) tmp = Float64((a ^ 2.0) + (Float64(b * 0.0) ^ 2.0)); else tmp = Float64((a ^ 2.0) + Float64((t_0 ^ 2.0) * 3.08641975308642e-5)); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = angle * (b * pi); tmp = 0.0; if (b <= -3.35e+38) tmp = (a ^ 2.0) + ((0.005555555555555556 * t_0) ^ 2.0); elseif (b <= 3.4e+14) tmp = (a ^ 2.0) + ((b * 0.0) ^ 2.0); else tmp = (a ^ 2.0) + ((t_0 ^ 2.0) * 3.08641975308642e-5); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(angle * N[(b * Pi), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.35e+38], N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(0.005555555555555556 * t$95$0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.4e+14], N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(b * 0.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 2.0], $MachinePrecision] + N[(N[Power[t$95$0, 2.0], $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := angle \cdot \left(b \cdot \pi\right)\\
\mathbf{if}\;b \leq -3.35 \cdot 10^{+38}:\\
\;\;\;\;{a}^{2} + {\left(0.005555555555555556 \cdot t_0\right)}^{2}\\
\mathbf{elif}\;b \leq 3.4 \cdot 10^{+14}:\\
\;\;\;\;{a}^{2} + {\left(b \cdot 0\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;{a}^{2} + {t_0}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\
\end{array}
\end{array}
if b < -3.35000000000000012e38Initial program 85.3%
Taylor expanded in angle around 0 85.3%
Taylor expanded in angle around 0 81.5%
*-commutative81.5%
Simplified81.5%
if -3.35000000000000012e38 < b < 3.4e14Initial program 75.7%
Taylor expanded in angle around 0 76.0%
add-cube-cbrt76.1%
pow376.2%
div-inv76.2%
metadata-eval76.2%
Applied egg-rr76.2%
Taylor expanded in angle around 0 73.2%
if 3.4e14 < b Initial program 85.3%
Taylor expanded in angle around 0 85.2%
Taylor expanded in angle around 0 80.8%
*-commutative80.8%
Simplified80.8%
*-commutative80.8%
unpow-prod-down80.9%
metadata-eval80.9%
Applied egg-rr80.9%
Final simplification76.3%
(FPCore (a b angle)
:precision binary64
(if (<= b -3.35e+38)
(+ (pow a 2.0) (pow (* 0.005555555555555556 (* PI (* b angle))) 2.0))
(if (<= b 1.4e+15)
(+ (pow a 2.0) (pow (* b 0.0) 2.0))
(+ (pow a 2.0) (* (pow (* angle (* b PI)) 2.0) 3.08641975308642e-5)))))
double code(double a, double b, double angle) {
double tmp;
if (b <= -3.35e+38) {
tmp = pow(a, 2.0) + pow((0.005555555555555556 * (((double) M_PI) * (b * angle))), 2.0);
} else if (b <= 1.4e+15) {
tmp = pow(a, 2.0) + pow((b * 0.0), 2.0);
} else {
tmp = pow(a, 2.0) + (pow((angle * (b * ((double) M_PI))), 2.0) * 3.08641975308642e-5);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= -3.35e+38) {
tmp = Math.pow(a, 2.0) + Math.pow((0.005555555555555556 * (Math.PI * (b * angle))), 2.0);
} else if (b <= 1.4e+15) {
tmp = Math.pow(a, 2.0) + Math.pow((b * 0.0), 2.0);
} else {
tmp = Math.pow(a, 2.0) + (Math.pow((angle * (b * Math.PI)), 2.0) * 3.08641975308642e-5);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= -3.35e+38: tmp = math.pow(a, 2.0) + math.pow((0.005555555555555556 * (math.pi * (b * angle))), 2.0) elif b <= 1.4e+15: tmp = math.pow(a, 2.0) + math.pow((b * 0.0), 2.0) else: tmp = math.pow(a, 2.0) + (math.pow((angle * (b * math.pi)), 2.0) * 3.08641975308642e-5) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= -3.35e+38) tmp = Float64((a ^ 2.0) + (Float64(0.005555555555555556 * Float64(pi * Float64(b * angle))) ^ 2.0)); elseif (b <= 1.4e+15) tmp = Float64((a ^ 2.0) + (Float64(b * 0.0) ^ 2.0)); else tmp = Float64((a ^ 2.0) + Float64((Float64(angle * Float64(b * pi)) ^ 2.0) * 3.08641975308642e-5)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= -3.35e+38) tmp = (a ^ 2.0) + ((0.005555555555555556 * (pi * (b * angle))) ^ 2.0); elseif (b <= 1.4e+15) tmp = (a ^ 2.0) + ((b * 0.0) ^ 2.0); else tmp = (a ^ 2.0) + (((angle * (b * pi)) ^ 2.0) * 3.08641975308642e-5); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, -3.35e+38], N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(0.005555555555555556 * N[(Pi * N[(b * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.4e+15], N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(b * 0.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 2.0], $MachinePrecision] + N[(N[Power[N[(angle * N[(b * Pi), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.35 \cdot 10^{+38}:\\
\;\;\;\;{a}^{2} + {\left(0.005555555555555556 \cdot \left(\pi \cdot \left(b \cdot angle\right)\right)\right)}^{2}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{+15}:\\
\;\;\;\;{a}^{2} + {\left(b \cdot 0\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;{a}^{2} + {\left(angle \cdot \left(b \cdot \pi\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\
\end{array}
\end{array}
if b < -3.35000000000000012e38Initial program 85.3%
Taylor expanded in angle around 0 85.3%
Taylor expanded in angle around 0 81.5%
associate-*r*81.5%
*-commutative81.5%
Simplified81.5%
if -3.35000000000000012e38 < b < 1.4e15Initial program 75.7%
Taylor expanded in angle around 0 76.0%
add-cube-cbrt76.1%
pow376.2%
div-inv76.2%
metadata-eval76.2%
Applied egg-rr76.2%
Taylor expanded in angle around 0 73.2%
if 1.4e15 < b Initial program 85.3%
Taylor expanded in angle around 0 85.2%
Taylor expanded in angle around 0 80.8%
*-commutative80.8%
Simplified80.8%
*-commutative80.8%
unpow-prod-down80.9%
metadata-eval80.9%
Applied egg-rr80.9%
Final simplification76.3%
(FPCore (a b angle) :precision binary64 (+ (pow a 2.0) (pow (* b 0.0) 2.0)))
double code(double a, double b, double angle) {
return pow(a, 2.0) + pow((b * 0.0), 2.0);
}
real(8) function code(a, b, angle)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = (a ** 2.0d0) + ((b * 0.0d0) ** 2.0d0)
end function
public static double code(double a, double b, double angle) {
return Math.pow(a, 2.0) + Math.pow((b * 0.0), 2.0);
}
def code(a, b, angle): return math.pow(a, 2.0) + math.pow((b * 0.0), 2.0)
function code(a, b, angle) return Float64((a ^ 2.0) + (Float64(b * 0.0) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a ^ 2.0) + ((b * 0.0) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(b * 0.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{a}^{2} + {\left(b \cdot 0\right)}^{2}
\end{array}
Initial program 79.4%
Taylor expanded in angle around 0 79.6%
add-cube-cbrt79.5%
pow379.7%
div-inv79.6%
metadata-eval79.6%
Applied egg-rr79.6%
Taylor expanded in angle around 0 62.2%
Final simplification62.2%
herbie shell --seed 2023174
(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)))