
(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 13 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}
(FPCore (a b angle) :precision binary64 (let* ((t_0 (/ (* angle PI) 180.0))) (+ (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 * ((double) M_PI)) / 180.0;
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 * Math.PI) / 180.0;
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 * math.pi) / 180.0 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 * pi) / 180.0) 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 * pi) / 180.0; 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 * Pi), $MachinePrecision] / 180.0), $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 \cdot \pi}{180}\\
{\left(a \cdot \sin t_0\right)}^{2} + {\left(b \cdot \cos t_0\right)}^{2}
\end{array}
\end{array}
Initial program 80.2%
associate-*l/80.6%
Applied egg-rr80.6%
associate-*l/80.6%
Applied egg-rr80.6%
Final simplification80.6%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* angle (/ PI 180.0)))) (+ (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 * (((double) M_PI) / 180.0);
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 * (Math.PI / 180.0);
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 * (math.pi / 180.0) 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(angle * Float64(pi / 180.0)) 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 * (pi / 180.0); tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(angle * N[(Pi / 180.0), $MachinePrecision]), $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 := angle \cdot \frac{\pi}{180}\\
{\left(a \cdot \sin t_0\right)}^{2} + {\left(b \cdot \cos t_0\right)}^{2}
\end{array}
\end{array}
Initial program 80.2%
associate-*l/80.6%
associate-*r/80.6%
associate-*l/80.6%
associate-*r/80.6%
Simplified80.6%
Final simplification80.6%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (/ (* angle PI) 180.0))) 2.0) (pow (* b (cos (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(((angle * ((double) M_PI)) / 180.0))), 2.0) + pow((b * cos((((double) M_PI) * (angle / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin(((angle * Math.PI) / 180.0))), 2.0) + Math.pow((b * Math.cos((Math.PI * (angle / 180.0)))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin(((angle * math.pi) / 180.0))), 2.0) + math.pow((b * math.cos((math.pi * (angle / 180.0)))), 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(angle * pi) / 180.0))) ^ 2.0) + (Float64(b * cos(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin(((angle * pi) / 180.0))) ^ 2.0) + ((b * cos((pi * (angle / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(angle * Pi), $MachinePrecision] / 180.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} + {\left(b \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 80.2%
associate-*l/80.6%
Applied egg-rr80.6%
Final simplification80.6%
(FPCore (a b angle) :precision binary64 (+ (pow b 2.0) (pow (* a (sin (* (* angle PI) 0.005555555555555556))) 2.0)))
double code(double a, double b, double angle) {
return pow(b, 2.0) + pow((a * sin(((angle * ((double) M_PI)) * 0.005555555555555556))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0) + Math.pow((a * Math.sin(((angle * Math.PI) * 0.005555555555555556))), 2.0);
}
def code(a, b, angle): return math.pow(b, 2.0) + math.pow((a * math.sin(((angle * math.pi) * 0.005555555555555556))), 2.0)
function code(a, b, angle) return Float64((b ^ 2.0) + (Float64(a * sin(Float64(Float64(angle * pi) * 0.005555555555555556))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (b ^ 2.0) + ((a * sin(((angle * pi) * 0.005555555555555556))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[b, 2.0], $MachinePrecision] + N[Power[N[(a * N[Sin[N[(N[(angle * Pi), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{b}^{2} + {\left(a \cdot \sin \left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\right)\right)}^{2}
\end{array}
Initial program 80.2%
associate-*l/80.6%
associate-*r/80.6%
associate-*l/80.6%
associate-*r/80.6%
Simplified80.6%
Taylor expanded in angle around 0 79.9%
Taylor expanded in angle around inf 79.5%
Final simplification79.5%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* angle (/ PI 180.0)))) 2.0) (pow b 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin((angle * (((double) M_PI) / 180.0)))), 2.0) + pow(b, 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((angle * (Math.PI / 180.0)))), 2.0) + Math.pow(b, 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin((angle * (math.pi / 180.0)))), 2.0) + math.pow(b, 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(angle * Float64(pi / 180.0)))) ^ 2.0) + (b ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin((angle * (pi / 180.0)))) ^ 2.0) + (b ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(angle * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2} + {b}^{2}
\end{array}
Initial program 80.2%
associate-*l/80.6%
associate-*r/80.6%
associate-*l/80.6%
associate-*r/80.6%
Simplified80.6%
Taylor expanded in angle around 0 79.9%
Final simplification79.9%
(FPCore (a b angle)
:precision binary64
(if (<= angle 8e-5)
(+
(pow b 2.0)
(* (* a angle) (* PI (* (* PI (* a angle)) 3.08641975308642e-5))))
(+
(pow b 2.0)
(* (* a a) (- 0.5 (* 0.5 (cos (* (* angle PI) 0.011111111111111112))))))))
double code(double a, double b, double angle) {
double tmp;
if (angle <= 8e-5) {
tmp = pow(b, 2.0) + ((a * angle) * (((double) M_PI) * ((((double) M_PI) * (a * angle)) * 3.08641975308642e-5)));
} else {
tmp = pow(b, 2.0) + ((a * a) * (0.5 - (0.5 * cos(((angle * ((double) M_PI)) * 0.011111111111111112)))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (angle <= 8e-5) {
tmp = Math.pow(b, 2.0) + ((a * angle) * (Math.PI * ((Math.PI * (a * angle)) * 3.08641975308642e-5)));
} else {
tmp = Math.pow(b, 2.0) + ((a * a) * (0.5 - (0.5 * Math.cos(((angle * Math.PI) * 0.011111111111111112)))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if angle <= 8e-5: tmp = math.pow(b, 2.0) + ((a * angle) * (math.pi * ((math.pi * (a * angle)) * 3.08641975308642e-5))) else: tmp = math.pow(b, 2.0) + ((a * a) * (0.5 - (0.5 * math.cos(((angle * math.pi) * 0.011111111111111112))))) return tmp
function code(a, b, angle) tmp = 0.0 if (angle <= 8e-5) tmp = Float64((b ^ 2.0) + Float64(Float64(a * angle) * Float64(pi * Float64(Float64(pi * Float64(a * angle)) * 3.08641975308642e-5)))); else tmp = Float64((b ^ 2.0) + Float64(Float64(a * a) * Float64(0.5 - Float64(0.5 * cos(Float64(Float64(angle * pi) * 0.011111111111111112)))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (angle <= 8e-5) tmp = (b ^ 2.0) + ((a * angle) * (pi * ((pi * (a * angle)) * 3.08641975308642e-5))); else tmp = (b ^ 2.0) + ((a * a) * (0.5 - (0.5 * cos(((angle * pi) * 0.011111111111111112))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[angle, 8e-5], N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(a * angle), $MachinePrecision] * N[(Pi * N[(N[(Pi * N[(a * angle), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(N[(angle * Pi), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 8 \cdot 10^{-5}:\\
\;\;\;\;{b}^{2} + \left(a \cdot angle\right) \cdot \left(\pi \cdot \left(\left(\pi \cdot \left(a \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + \left(a \cdot a\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right)\\
\end{array}
\end{array}
if angle < 8.00000000000000065e-5Initial program 86.7%
associate-*l/86.6%
associate-*r/86.7%
associate-*l/86.7%
associate-*r/86.6%
Simplified86.6%
Taylor expanded in angle around 0 86.4%
Taylor expanded in angle around 0 83.2%
*-commutative83.2%
associate-*l*83.2%
Simplified83.2%
unpow283.2%
associate-*r*83.3%
*-commutative83.3%
associate-*r*83.3%
*-commutative83.3%
associate-*l*83.3%
associate-*r*83.3%
*-commutative83.3%
*-commutative83.3%
associate-*l*83.3%
associate-*r*83.4%
*-commutative83.4%
associate-*l*83.3%
metadata-eval83.3%
Applied egg-rr83.3%
if 8.00000000000000065e-5 < angle Initial program 61.7%
associate-*l/63.0%
associate-*r/63.1%
associate-*l/63.1%
associate-*r/63.1%
Simplified63.1%
Taylor expanded in angle around 0 61.4%
unpow-prod-down61.4%
*-commutative61.4%
associate-/r/61.4%
associate-/l*61.4%
associate-*r/61.3%
*-commutative61.3%
*-commutative61.3%
associate-*l/61.4%
associate-*r/61.4%
div-inv61.4%
metadata-eval61.4%
unpow261.4%
Applied egg-rr61.4%
unpow261.4%
*-commutative61.4%
associate-*l*54.4%
*-commutative54.4%
associate-*l*61.3%
sqr-sin-a61.3%
count-261.3%
associate-*l*61.5%
*-commutative61.5%
associate-*r*61.4%
associate-*l*61.5%
*-commutative61.5%
associate-*r*61.4%
distribute-lft-out61.4%
metadata-eval61.4%
Applied egg-rr61.4%
Final simplification77.7%
(FPCore (a b angle)
:precision binary64
(if (<= angle 8e-5)
(+
(pow b 2.0)
(* (* a angle) (* PI (* (* PI (* a angle)) 3.08641975308642e-5))))
(+
(pow b 2.0)
(*
(/ (+ -1.0 (cos (* angle (* PI 0.011111111111111112)))) -2.0)
(* a a)))))
double code(double a, double b, double angle) {
double tmp;
if (angle <= 8e-5) {
tmp = pow(b, 2.0) + ((a * angle) * (((double) M_PI) * ((((double) M_PI) * (a * angle)) * 3.08641975308642e-5)));
} else {
tmp = pow(b, 2.0) + (((-1.0 + cos((angle * (((double) M_PI) * 0.011111111111111112)))) / -2.0) * (a * a));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (angle <= 8e-5) {
tmp = Math.pow(b, 2.0) + ((a * angle) * (Math.PI * ((Math.PI * (a * angle)) * 3.08641975308642e-5)));
} else {
tmp = Math.pow(b, 2.0) + (((-1.0 + Math.cos((angle * (Math.PI * 0.011111111111111112)))) / -2.0) * (a * a));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if angle <= 8e-5: tmp = math.pow(b, 2.0) + ((a * angle) * (math.pi * ((math.pi * (a * angle)) * 3.08641975308642e-5))) else: tmp = math.pow(b, 2.0) + (((-1.0 + math.cos((angle * (math.pi * 0.011111111111111112)))) / -2.0) * (a * a)) return tmp
function code(a, b, angle) tmp = 0.0 if (angle <= 8e-5) tmp = Float64((b ^ 2.0) + Float64(Float64(a * angle) * Float64(pi * Float64(Float64(pi * Float64(a * angle)) * 3.08641975308642e-5)))); else tmp = Float64((b ^ 2.0) + Float64(Float64(Float64(-1.0 + cos(Float64(angle * Float64(pi * 0.011111111111111112)))) / -2.0) * Float64(a * a))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (angle <= 8e-5) tmp = (b ^ 2.0) + ((a * angle) * (pi * ((pi * (a * angle)) * 3.08641975308642e-5))); else tmp = (b ^ 2.0) + (((-1.0 + cos((angle * (pi * 0.011111111111111112)))) / -2.0) * (a * a)); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[angle, 8e-5], N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(a * angle), $MachinePrecision] * N[(Pi * N[(N[(Pi * N[(a * angle), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(N[(-1.0 + N[Cos[N[(angle * N[(Pi * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 8 \cdot 10^{-5}:\\
\;\;\;\;{b}^{2} + \left(a \cdot angle\right) \cdot \left(\pi \cdot \left(\left(\pi \cdot \left(a \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + \frac{-1 + \cos \left(angle \cdot \left(\pi \cdot 0.011111111111111112\right)\right)}{-2} \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if angle < 8.00000000000000065e-5Initial program 86.7%
associate-*l/86.6%
associate-*r/86.7%
associate-*l/86.7%
associate-*r/86.6%
Simplified86.6%
Taylor expanded in angle around 0 86.4%
Taylor expanded in angle around 0 83.2%
*-commutative83.2%
associate-*l*83.2%
Simplified83.2%
unpow283.2%
associate-*r*83.3%
*-commutative83.3%
associate-*r*83.3%
*-commutative83.3%
associate-*l*83.3%
associate-*r*83.3%
*-commutative83.3%
*-commutative83.3%
associate-*l*83.3%
associate-*r*83.4%
*-commutative83.4%
associate-*l*83.3%
metadata-eval83.3%
Applied egg-rr83.3%
if 8.00000000000000065e-5 < angle Initial program 61.7%
associate-*l/63.0%
associate-*r/63.1%
associate-*l/63.1%
associate-*r/63.1%
Simplified63.1%
Taylor expanded in angle around 0 61.4%
unpow-prod-down61.4%
*-commutative61.4%
associate-/r/61.4%
associate-/l*61.4%
associate-*r/61.3%
*-commutative61.3%
*-commutative61.3%
associate-*l/61.4%
associate-*r/61.4%
div-inv61.4%
metadata-eval61.4%
unpow261.4%
Applied egg-rr61.4%
unpow261.4%
*-commutative61.4%
associate-*l*54.4%
*-commutative54.4%
associate-*l*61.3%
sin-mult61.3%
frac-2neg61.3%
Applied egg-rr61.4%
neg-sub061.4%
cos-061.4%
associate--r-61.4%
metadata-eval61.4%
associate-*l*61.4%
Simplified61.4%
Final simplification77.7%
(FPCore (a b angle)
:precision binary64
(if (<= a 1.25e-154)
(* b b)
(+
(pow b 2.0)
(* (* a angle) (* PI (* (* PI (* a angle)) 3.08641975308642e-5))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.25e-154) {
tmp = b * b;
} else {
tmp = pow(b, 2.0) + ((a * angle) * (((double) M_PI) * ((((double) M_PI) * (a * angle)) * 3.08641975308642e-5)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.25e-154) {
tmp = b * b;
} else {
tmp = Math.pow(b, 2.0) + ((a * angle) * (Math.PI * ((Math.PI * (a * angle)) * 3.08641975308642e-5)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.25e-154: tmp = b * b else: tmp = math.pow(b, 2.0) + ((a * angle) * (math.pi * ((math.pi * (a * angle)) * 3.08641975308642e-5))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.25e-154) tmp = Float64(b * b); else tmp = Float64((b ^ 2.0) + Float64(Float64(a * angle) * Float64(pi * Float64(Float64(pi * Float64(a * angle)) * 3.08641975308642e-5)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.25e-154) tmp = b * b; else tmp = (b ^ 2.0) + ((a * angle) * (pi * ((pi * (a * angle)) * 3.08641975308642e-5))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.25e-154], N[(b * b), $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(a * angle), $MachinePrecision] * N[(Pi * N[(N[(Pi * N[(a * angle), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.25 \cdot 10^{-154}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + \left(a \cdot angle\right) \cdot \left(\pi \cdot \left(\left(\pi \cdot \left(a \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\\
\end{array}
\end{array}
if a < 1.25000000000000005e-154Initial program 80.2%
associate-*l/80.8%
associate-*r/80.8%
associate-*l/80.9%
associate-*r/80.8%
Simplified80.8%
Taylor expanded in angle around 0 80.2%
Taylor expanded in angle around 0 73.2%
*-commutative73.2%
associate-*l*73.2%
Simplified73.2%
unpow-prod-down73.3%
*-commutative73.3%
associate-*r*73.2%
*-commutative73.2%
associate-*l*73.3%
metadata-eval73.3%
Applied egg-rr73.3%
Taylor expanded in angle around 0 61.0%
unpow261.0%
Simplified61.0%
if 1.25000000000000005e-154 < a Initial program 80.2%
associate-*l/80.2%
associate-*r/80.2%
associate-*l/80.2%
associate-*r/80.2%
Simplified80.2%
Taylor expanded in angle around 0 79.5%
Taylor expanded in angle around 0 76.7%
*-commutative76.7%
associate-*l*76.7%
Simplified76.7%
unpow276.7%
associate-*r*76.7%
*-commutative76.7%
associate-*r*76.8%
*-commutative76.8%
associate-*l*76.8%
associate-*r*76.9%
*-commutative76.9%
*-commutative76.9%
associate-*l*76.8%
associate-*r*76.9%
*-commutative76.9%
associate-*l*76.8%
metadata-eval76.8%
Applied egg-rr76.8%
Final simplification67.3%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* PI (* a angle))))
(if (<= a 1.25e-154)
(* b b)
(fma t_0 (* t_0 3.08641975308642e-5) (* b b)))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (a * angle);
double tmp;
if (a <= 1.25e-154) {
tmp = b * b;
} else {
tmp = fma(t_0, (t_0 * 3.08641975308642e-5), (b * b));
}
return tmp;
}
function code(a, b, angle) t_0 = Float64(pi * Float64(a * angle)) tmp = 0.0 if (a <= 1.25e-154) tmp = Float64(b * b); else tmp = fma(t_0, Float64(t_0 * 3.08641975308642e-5), Float64(b * b)); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(a * angle), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, 1.25e-154], N[(b * b), $MachinePrecision], N[(t$95$0 * N[(t$95$0 * 3.08641975308642e-5), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(a \cdot angle\right)\\
\mathbf{if}\;a \leq 1.25 \cdot 10^{-154}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, t_0 \cdot 3.08641975308642 \cdot 10^{-5}, b \cdot b\right)\\
\end{array}
\end{array}
if a < 1.25000000000000005e-154Initial program 80.2%
associate-*l/80.8%
associate-*r/80.8%
associate-*l/80.9%
associate-*r/80.8%
Simplified80.8%
Taylor expanded in angle around 0 80.2%
Taylor expanded in angle around 0 73.2%
*-commutative73.2%
associate-*l*73.2%
Simplified73.2%
unpow-prod-down73.3%
*-commutative73.3%
associate-*r*73.2%
*-commutative73.2%
associate-*l*73.3%
metadata-eval73.3%
Applied egg-rr73.3%
Taylor expanded in angle around 0 61.0%
unpow261.0%
Simplified61.0%
if 1.25000000000000005e-154 < a Initial program 80.2%
associate-*l/80.2%
associate-*r/80.2%
associate-*l/80.2%
associate-*r/80.2%
Simplified80.2%
Taylor expanded in angle around 0 79.5%
Taylor expanded in angle around 0 76.7%
*-commutative76.7%
associate-*l*76.7%
Simplified76.7%
unpow-prod-down76.7%
*-commutative76.7%
associate-*r*76.7%
*-commutative76.7%
associate-*l*76.7%
metadata-eval76.7%
Applied egg-rr76.7%
unpow276.7%
associate-*l*76.8%
fma-def76.8%
associate-*r*76.8%
*-commutative76.8%
associate-*l*76.8%
*-commutative76.8%
associate-*r*76.8%
*-rgt-identity76.8%
unpow276.8%
Applied egg-rr76.8%
associate-*r*76.8%
*-commutative76.8%
associate-*r*76.7%
associate-*l*76.8%
Simplified76.8%
Final simplification67.3%
(FPCore (a b angle)
:precision binary64
(if (<= a 1.25e-154)
(* b b)
(fma
(* (* a angle) (* PI 3.08641975308642e-5))
(* angle (* a PI))
(* b b))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.25e-154) {
tmp = b * b;
} else {
tmp = fma(((a * angle) * (((double) M_PI) * 3.08641975308642e-5)), (angle * (a * ((double) M_PI))), (b * b));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 1.25e-154) tmp = Float64(b * b); else tmp = fma(Float64(Float64(a * angle) * Float64(pi * 3.08641975308642e-5)), Float64(angle * Float64(a * pi)), Float64(b * b)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 1.25e-154], N[(b * b), $MachinePrecision], N[(N[(N[(a * angle), $MachinePrecision] * N[(Pi * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision] * N[(angle * N[(a * Pi), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.25 \cdot 10^{-154}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(a \cdot angle\right) \cdot \left(\pi \cdot 3.08641975308642 \cdot 10^{-5}\right), angle \cdot \left(a \cdot \pi\right), b \cdot b\right)\\
\end{array}
\end{array}
if a < 1.25000000000000005e-154Initial program 80.2%
associate-*l/80.8%
associate-*r/80.8%
associate-*l/80.9%
associate-*r/80.8%
Simplified80.8%
Taylor expanded in angle around 0 80.2%
Taylor expanded in angle around 0 73.2%
*-commutative73.2%
associate-*l*73.2%
Simplified73.2%
unpow-prod-down73.3%
*-commutative73.3%
associate-*r*73.2%
*-commutative73.2%
associate-*l*73.3%
metadata-eval73.3%
Applied egg-rr73.3%
Taylor expanded in angle around 0 61.0%
unpow261.0%
Simplified61.0%
if 1.25000000000000005e-154 < a Initial program 80.2%
associate-*l/80.2%
associate-*r/80.2%
associate-*l/80.2%
associate-*r/80.2%
Simplified80.2%
Taylor expanded in angle around 0 79.5%
Taylor expanded in angle around 0 76.7%
*-commutative76.7%
associate-*l*76.7%
Simplified76.7%
unpow-prod-down76.7%
*-commutative76.7%
associate-*r*76.7%
*-commutative76.7%
associate-*l*76.7%
metadata-eval76.7%
Applied egg-rr76.7%
*-commutative76.7%
unpow276.7%
associate-*r*76.8%
fma-def76.8%
associate-*r*76.7%
associate-*r*76.8%
*-commutative76.8%
associate-*l*76.8%
*-rgt-identity76.8%
unpow276.8%
Applied egg-rr76.8%
Final simplification67.3%
(FPCore (a b angle) :precision binary64 (if (<= a 1.25e-154) (* b b) (fma 3.08641975308642e-5 (pow (* PI (* a angle)) 2.0) (* b b))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.25e-154) {
tmp = b * b;
} else {
tmp = fma(3.08641975308642e-5, pow((((double) M_PI) * (a * angle)), 2.0), (b * b));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 1.25e-154) tmp = Float64(b * b); else tmp = fma(3.08641975308642e-5, (Float64(pi * Float64(a * angle)) ^ 2.0), Float64(b * b)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 1.25e-154], N[(b * b), $MachinePrecision], N[(3.08641975308642e-5 * N[Power[N[(Pi * N[(a * angle), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.25 \cdot 10^{-154}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(3.08641975308642 \cdot 10^{-5}, {\left(\pi \cdot \left(a \cdot angle\right)\right)}^{2}, b \cdot b\right)\\
\end{array}
\end{array}
if a < 1.25000000000000005e-154Initial program 80.2%
associate-*l/80.8%
associate-*r/80.8%
associate-*l/80.9%
associate-*r/80.8%
Simplified80.8%
Taylor expanded in angle around 0 80.2%
Taylor expanded in angle around 0 73.2%
*-commutative73.2%
associate-*l*73.2%
Simplified73.2%
unpow-prod-down73.3%
*-commutative73.3%
associate-*r*73.2%
*-commutative73.2%
associate-*l*73.3%
metadata-eval73.3%
Applied egg-rr73.3%
Taylor expanded in angle around 0 61.0%
unpow261.0%
Simplified61.0%
if 1.25000000000000005e-154 < a Initial program 80.2%
associate-*l/80.2%
associate-*r/80.2%
associate-*l/80.2%
associate-*r/80.2%
Simplified80.2%
Taylor expanded in angle around 0 79.5%
Taylor expanded in angle around 0 76.7%
*-commutative76.7%
associate-*l*76.7%
Simplified76.7%
unpow-prod-down76.7%
*-commutative76.7%
associate-*r*76.7%
*-commutative76.7%
associate-*l*76.7%
metadata-eval76.7%
Applied egg-rr76.7%
Taylor expanded in angle around 0 57.0%
fma-def57.0%
unpow257.0%
*-commutative57.0%
unpow257.0%
unpow257.0%
unpow257.0%
swap-sqr57.1%
swap-sqr76.7%
associate-*r*76.8%
associate-*r*76.7%
unpow276.7%
associate-*r*76.7%
*-commutative76.7%
associate-*r*76.7%
Simplified76.7%
Final simplification67.3%
(FPCore (a b angle) :precision binary64 (if (<= a 1.25e-154) (* b b) (fma b b (* 3.08641975308642e-5 (pow (* angle (* a PI)) 2.0)))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.25e-154) {
tmp = b * b;
} else {
tmp = fma(b, b, (3.08641975308642e-5 * pow((angle * (a * ((double) M_PI))), 2.0)));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 1.25e-154) tmp = Float64(b * b); else tmp = fma(b, b, Float64(3.08641975308642e-5 * (Float64(angle * Float64(a * pi)) ^ 2.0))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 1.25e-154], 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}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.25 \cdot 10^{-154}:\\
\;\;\;\;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.25000000000000005e-154Initial program 80.2%
associate-*l/80.8%
associate-*r/80.8%
associate-*l/80.9%
associate-*r/80.8%
Simplified80.8%
Taylor expanded in angle around 0 80.2%
Taylor expanded in angle around 0 73.2%
*-commutative73.2%
associate-*l*73.2%
Simplified73.2%
unpow-prod-down73.3%
*-commutative73.3%
associate-*r*73.2%
*-commutative73.2%
associate-*l*73.3%
metadata-eval73.3%
Applied egg-rr73.3%
Taylor expanded in angle around 0 61.0%
unpow261.0%
Simplified61.0%
if 1.25000000000000005e-154 < a Initial program 80.2%
associate-*l/80.2%
associate-*r/80.2%
associate-*l/80.2%
associate-*r/80.2%
Simplified80.2%
Taylor expanded in angle around 0 79.5%
Taylor expanded in angle around 0 76.7%
*-commutative76.7%
associate-*l*76.7%
Simplified76.7%
unpow-prod-down76.7%
*-commutative76.7%
associate-*r*76.7%
*-commutative76.7%
associate-*l*76.7%
metadata-eval76.7%
Applied egg-rr76.7%
+-commutative76.7%
*-rgt-identity76.7%
unpow276.7%
fma-def76.7%
associate-*r*76.7%
*-commutative76.7%
associate-*l*76.7%
Applied egg-rr76.7%
Final simplification67.3%
(FPCore (a b angle) :precision binary64 (* b b))
double code(double a, double b, double angle) {
return b * b;
}
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
public static double code(double a, double b, double angle) {
return b * b;
}
def code(a, b, angle): return b * b
function code(a, b, angle) return Float64(b * b) end
function tmp = code(a, b, angle) tmp = b * b; end
code[a_, b_, angle_] := N[(b * b), $MachinePrecision]
\begin{array}{l}
\\
b \cdot b
\end{array}
Initial program 80.2%
associate-*l/80.6%
associate-*r/80.6%
associate-*l/80.6%
associate-*r/80.6%
Simplified80.6%
Taylor expanded in angle around 0 79.9%
Taylor expanded in angle around 0 74.6%
*-commutative74.6%
associate-*l*74.6%
Simplified74.6%
unpow-prod-down74.6%
*-commutative74.6%
associate-*r*74.6%
*-commutative74.6%
associate-*l*74.6%
metadata-eval74.6%
Applied egg-rr74.6%
Taylor expanded in angle around 0 56.1%
unpow256.1%
Simplified56.1%
Final simplification56.1%
herbie shell --seed 2023297
(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)))