
(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 10 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
(+
(pow
(*
a
(sin
(*
(pow PI 0.16666666666666666)
(*
(* 0.005555555555555556 (* angle (pow PI 0.6666666666666666)))
(pow PI 0.16666666666666666)))))
2.0)
(pow (* b 1.0) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin((pow(((double) M_PI), 0.16666666666666666) * ((0.005555555555555556 * (angle * pow(((double) M_PI), 0.6666666666666666))) * pow(((double) M_PI), 0.16666666666666666))))), 2.0) + pow((b * 1.0), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((Math.pow(Math.PI, 0.16666666666666666) * ((0.005555555555555556 * (angle * Math.pow(Math.PI, 0.6666666666666666))) * Math.pow(Math.PI, 0.16666666666666666))))), 2.0) + Math.pow((b * 1.0), 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin((math.pow(math.pi, 0.16666666666666666) * ((0.005555555555555556 * (angle * math.pow(math.pi, 0.6666666666666666))) * math.pow(math.pi, 0.16666666666666666))))), 2.0) + math.pow((b * 1.0), 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64((pi ^ 0.16666666666666666) * Float64(Float64(0.005555555555555556 * Float64(angle * (pi ^ 0.6666666666666666))) * (pi ^ 0.16666666666666666))))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin(((pi ^ 0.16666666666666666) * ((0.005555555555555556 * (angle * (pi ^ 0.6666666666666666))) * (pi ^ 0.16666666666666666))))) ^ 2.0) + ((b * 1.0) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[Power[Pi, 0.16666666666666666], $MachinePrecision] * N[(N[(0.005555555555555556 * N[(angle * N[Power[Pi, 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[Pi, 0.16666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left({\pi}^{0.16666666666666666} \cdot \left(\left(0.005555555555555556 \cdot \left(angle \cdot {\pi}^{0.6666666666666666}\right)\right) \cdot {\pi}^{0.16666666666666666}\right)\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}
\end{array}
Initial program 77.5%
lift-*.f64N/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*r*N/A
add-sqr-sqrtN/A
cbrt-prodN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites77.6%
Taylor expanded in angle around 0
Applied rewrites77.6%
Final simplification77.6%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* angle (* 0.005555555555555556 PI)))) 2.0) (* b b)))
double code(double a, double b, double angle) {
return pow((a * sin((angle * (0.005555555555555556 * ((double) M_PI))))), 2.0) + (b * b);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((angle * (0.005555555555555556 * Math.PI)))), 2.0) + (b * b);
}
def code(a, b, angle): return math.pow((a * math.sin((angle * (0.005555555555555556 * math.pi)))), 2.0) + (b * b)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(angle * Float64(0.005555555555555556 * pi)))) ^ 2.0) + Float64(b * b)) end
function tmp = code(a, b, angle) tmp = ((a * sin((angle * (0.005555555555555556 * pi)))) ^ 2.0) + (b * b); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(angle * N[(0.005555555555555556 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right)\right)}^{2} + b \cdot b
\end{array}
Initial program 77.5%
lift-*.f64N/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*r*N/A
add-sqr-sqrtN/A
cbrt-prodN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites77.6%
Taylor expanded in angle around 0
Applied rewrites77.6%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
associate-*l*N/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-upN/A
metadata-evalN/A
lift-pow.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-upN/A
metadata-evalN/A
Applied rewrites77.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6477.6
Applied rewrites77.6%
Final simplification77.6%
(FPCore (a b angle) :precision binary64 (fma (* a (fma (cos (* angle (* PI 0.011111111111111112))) -0.5 0.5)) a (* b (* 1.0 (* b 1.0)))))
double code(double a, double b, double angle) {
return fma((a * fma(cos((angle * (((double) M_PI) * 0.011111111111111112))), -0.5, 0.5)), a, (b * (1.0 * (b * 1.0))));
}
function code(a, b, angle) return fma(Float64(a * fma(cos(Float64(angle * Float64(pi * 0.011111111111111112))), -0.5, 0.5)), a, Float64(b * Float64(1.0 * Float64(b * 1.0)))) end
code[a_, b_, angle_] := N[(N[(a * N[(N[Cos[N[(angle * N[(Pi * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision] * a + N[(b * N[(1.0 * N[(b * 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a \cdot \mathsf{fma}\left(\cos \left(angle \cdot \left(\pi \cdot 0.011111111111111112\right)\right), -0.5, 0.5\right), a, b \cdot \left(1 \cdot \left(b \cdot 1\right)\right)\right)
\end{array}
Initial program 77.5%
lift-*.f64N/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*r*N/A
add-sqr-sqrtN/A
cbrt-prodN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites77.6%
Taylor expanded in angle around 0
Applied rewrites77.6%
Applied rewrites68.3%
(FPCore (a b angle)
:precision binary64
(if (<= b 7.2e-109)
(fma
(*
(* angle PI)
(* PI (fma (* a a) 3.08641975308642e-5 (* (* b b) -3.08641975308642e-5))))
angle
(* b b))
(if (<= b 6.5e+131)
(*
(* b b)
(fma
angle
(* angle (* -3.08641975308642e-5 (* PI PI)))
(fma
(* a (* a (* PI (* PI (* angle angle)))))
(/ 3.08641975308642e-5 (* b b))
1.0)))
(* b b))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 7.2e-109) {
tmp = fma(((angle * ((double) M_PI)) * (((double) M_PI) * fma((a * a), 3.08641975308642e-5, ((b * b) * -3.08641975308642e-5)))), angle, (b * b));
} else if (b <= 6.5e+131) {
tmp = (b * b) * fma(angle, (angle * (-3.08641975308642e-5 * (((double) M_PI) * ((double) M_PI)))), fma((a * (a * (((double) M_PI) * (((double) M_PI) * (angle * angle))))), (3.08641975308642e-5 / (b * b)), 1.0));
} else {
tmp = b * b;
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 7.2e-109) tmp = fma(Float64(Float64(angle * pi) * Float64(pi * fma(Float64(a * a), 3.08641975308642e-5, Float64(Float64(b * b) * -3.08641975308642e-5)))), angle, Float64(b * b)); elseif (b <= 6.5e+131) tmp = Float64(Float64(b * b) * fma(angle, Float64(angle * Float64(-3.08641975308642e-5 * Float64(pi * pi))), fma(Float64(a * Float64(a * Float64(pi * Float64(pi * Float64(angle * angle))))), Float64(3.08641975308642e-5 / Float64(b * b)), 1.0))); else tmp = Float64(b * b); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 7.2e-109], N[(N[(N[(angle * Pi), $MachinePrecision] * N[(Pi * N[(N[(a * a), $MachinePrecision] * 3.08641975308642e-5 + N[(N[(b * b), $MachinePrecision] * -3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * angle + N[(b * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.5e+131], N[(N[(b * b), $MachinePrecision] * N[(angle * N[(angle * N[(-3.08641975308642e-5 * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a * N[(a * N[(Pi * N[(Pi * N[(angle * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(3.08641975308642e-5 / N[(b * b), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.2 \cdot 10^{-109}:\\
\;\;\;\;\mathsf{fma}\left(\left(angle \cdot \pi\right) \cdot \left(\pi \cdot \mathsf{fma}\left(a \cdot a, 3.08641975308642 \cdot 10^{-5}, \left(b \cdot b\right) \cdot -3.08641975308642 \cdot 10^{-5}\right)\right), angle, b \cdot b\right)\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{+131}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \mathsf{fma}\left(angle, angle \cdot \left(-3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \pi\right)\right), \mathsf{fma}\left(a \cdot \left(a \cdot \left(\pi \cdot \left(\pi \cdot \left(angle \cdot angle\right)\right)\right)\right), \frac{3.08641975308642 \cdot 10^{-5}}{b \cdot b}, 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot b\\
\end{array}
\end{array}
if b < 7.2000000000000001e-109Initial program 77.0%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites42.5%
Applied rewrites44.9%
if 7.2000000000000001e-109 < b < 6.5e131Initial program 64.3%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites52.8%
Taylor expanded in b around inf
Applied rewrites57.6%
if 6.5e131 < b Initial program 95.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6495.6
Applied rewrites95.6%
Final simplification54.1%
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) 5e-171)
(* b b)
(if (<= (/ angle 180.0) 5e+143)
(fma
(* angle angle)
(* PI (* PI (* a (* a 3.08641975308642e-5))))
(* b b))
(* a (* a (* 3.08641975308642e-5 (* PI (* angle (* angle PI)))))))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= 5e-171) {
tmp = b * b;
} else if ((angle / 180.0) <= 5e+143) {
tmp = fma((angle * angle), (((double) M_PI) * (((double) M_PI) * (a * (a * 3.08641975308642e-5)))), (b * b));
} else {
tmp = a * (a * (3.08641975308642e-5 * (((double) M_PI) * (angle * (angle * ((double) M_PI))))));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= 5e-171) tmp = Float64(b * b); elseif (Float64(angle / 180.0) <= 5e+143) tmp = fma(Float64(angle * angle), Float64(pi * Float64(pi * Float64(a * Float64(a * 3.08641975308642e-5)))), Float64(b * b)); else tmp = Float64(a * Float64(a * Float64(3.08641975308642e-5 * Float64(pi * Float64(angle * Float64(angle * pi)))))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], 5e-171], N[(b * b), $MachinePrecision], If[LessEqual[N[(angle / 180.0), $MachinePrecision], 5e+143], N[(N[(angle * angle), $MachinePrecision] * N[(Pi * N[(Pi * N[(a * N[(a * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], N[(a * N[(a * N[(3.08641975308642e-5 * N[(Pi * N[(angle * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 5 \cdot 10^{-171}:\\
\;\;\;\;b \cdot b\\
\mathbf{elif}\;\frac{angle}{180} \leq 5 \cdot 10^{+143}:\\
\;\;\;\;\mathsf{fma}\left(angle \cdot angle, \pi \cdot \left(\pi \cdot \left(a \cdot \left(a \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\right), b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(a \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \left(angle \cdot \left(angle \cdot \pi\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 4.99999999999999992e-171Initial program 81.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.9
Applied rewrites57.9%
if 4.99999999999999992e-171 < (/.f64 angle #s(literal 180 binary64)) < 5.00000000000000012e143Initial program 79.8%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites51.1%
Taylor expanded in b around 0
Applied rewrites70.0%
if 5.00000000000000012e143 < (/.f64 angle #s(literal 180 binary64)) Initial program 59.4%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites19.6%
Taylor expanded in b around 0
Applied rewrites41.0%
Applied rewrites49.5%
Final simplification59.5%
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) 5e-171)
(* b b)
(if (<= (/ angle 180.0) 5e+132)
(fma
(* angle angle)
(* a (* a (* 3.08641975308642e-5 (* PI PI))))
(* b b))
(* a (* a (* 3.08641975308642e-5 (* PI (* angle (* angle PI)))))))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= 5e-171) {
tmp = b * b;
} else if ((angle / 180.0) <= 5e+132) {
tmp = fma((angle * angle), (a * (a * (3.08641975308642e-5 * (((double) M_PI) * ((double) M_PI))))), (b * b));
} else {
tmp = a * (a * (3.08641975308642e-5 * (((double) M_PI) * (angle * (angle * ((double) M_PI))))));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= 5e-171) tmp = Float64(b * b); elseif (Float64(angle / 180.0) <= 5e+132) tmp = fma(Float64(angle * angle), Float64(a * Float64(a * Float64(3.08641975308642e-5 * Float64(pi * pi)))), Float64(b * b)); else tmp = Float64(a * Float64(a * Float64(3.08641975308642e-5 * Float64(pi * Float64(angle * Float64(angle * pi)))))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], 5e-171], N[(b * b), $MachinePrecision], If[LessEqual[N[(angle / 180.0), $MachinePrecision], 5e+132], N[(N[(angle * angle), $MachinePrecision] * N[(a * N[(a * N[(3.08641975308642e-5 * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], N[(a * N[(a * N[(3.08641975308642e-5 * N[(Pi * N[(angle * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq 5 \cdot 10^{-171}:\\
\;\;\;\;b \cdot b\\
\mathbf{elif}\;\frac{angle}{180} \leq 5 \cdot 10^{+132}:\\
\;\;\;\;\mathsf{fma}\left(angle \cdot angle, a \cdot \left(a \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \pi\right)\right)\right), b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(a \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \left(angle \cdot \left(angle \cdot \pi\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if (/.f64 angle #s(literal 180 binary64)) < 4.99999999999999992e-171Initial program 81.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.9
Applied rewrites57.9%
if 4.99999999999999992e-171 < (/.f64 angle #s(literal 180 binary64)) < 5.0000000000000001e132Initial program 79.4%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites52.0%
Taylor expanded in b around 0
Applied rewrites69.5%
if 5.0000000000000001e132 < (/.f64 angle #s(literal 180 binary64)) Initial program 60.4%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites19.1%
Taylor expanded in b around 0
Applied rewrites42.6%
Applied rewrites50.8%
Final simplification59.5%
(FPCore (a b angle)
:precision binary64
(if (<= b 1.05e+117)
(fma
(*
(* angle PI)
(* PI (fma (* a a) 3.08641975308642e-5 (* (* b b) -3.08641975308642e-5))))
angle
(* b b))
(* b b)))
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.05e+117) {
tmp = fma(((angle * ((double) M_PI)) * (((double) M_PI) * fma((a * a), 3.08641975308642e-5, ((b * b) * -3.08641975308642e-5)))), angle, (b * b));
} else {
tmp = b * b;
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 1.05e+117) tmp = fma(Float64(Float64(angle * pi) * Float64(pi * fma(Float64(a * a), 3.08641975308642e-5, Float64(Float64(b * b) * -3.08641975308642e-5)))), angle, Float64(b * b)); else tmp = Float64(b * b); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 1.05e+117], N[(N[(N[(angle * Pi), $MachinePrecision] * N[(Pi * N[(N[(a * a), $MachinePrecision] * 3.08641975308642e-5 + N[(N[(b * b), $MachinePrecision] * -3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * angle + N[(b * b), $MachinePrecision]), $MachinePrecision], N[(b * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.05 \cdot 10^{+117}:\\
\;\;\;\;\mathsf{fma}\left(\left(angle \cdot \pi\right) \cdot \left(\pi \cdot \mathsf{fma}\left(a \cdot a, 3.08641975308642 \cdot 10^{-5}, \left(b \cdot b\right) \cdot -3.08641975308642 \cdot 10^{-5}\right)\right), angle, b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot b\\
\end{array}
\end{array}
if b < 1.0500000000000001e117Initial program 73.9%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites43.2%
Applied rewrites45.3%
if 1.0500000000000001e117 < b Initial program 96.0%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6491.8
Applied rewrites91.8%
(FPCore (a b angle) :precision binary64 (if (<= a 3.9e+152) (* b b) (* a (* a (* 3.08641975308642e-5 (* PI (* angle (* angle PI))))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 3.9e+152) {
tmp = b * b;
} else {
tmp = a * (a * (3.08641975308642e-5 * (((double) M_PI) * (angle * (angle * ((double) M_PI))))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 3.9e+152) {
tmp = b * b;
} else {
tmp = a * (a * (3.08641975308642e-5 * (Math.PI * (angle * (angle * Math.PI)))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 3.9e+152: tmp = b * b else: tmp = a * (a * (3.08641975308642e-5 * (math.pi * (angle * (angle * math.pi))))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 3.9e+152) tmp = Float64(b * b); else tmp = Float64(a * Float64(a * Float64(3.08641975308642e-5 * Float64(pi * Float64(angle * Float64(angle * pi)))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 3.9e+152) tmp = b * b; else tmp = a * (a * (3.08641975308642e-5 * (pi * (angle * (angle * pi))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 3.9e+152], N[(b * b), $MachinePrecision], N[(a * N[(a * N[(3.08641975308642e-5 * N[(Pi * N[(angle * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.9 \cdot 10^{+152}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(a \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \left(angle \cdot \left(angle \cdot \pi\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 3.90000000000000011e152Initial program 74.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6458.5
Applied rewrites58.5%
if 3.90000000000000011e152 < a Initial program 96.5%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites39.9%
Taylor expanded in b around 0
Applied rewrites46.0%
Applied rewrites55.9%
Final simplification58.2%
(FPCore (a b angle) :precision binary64 (if (<= a 3.9e+152) (* b b) (* (* angle (* angle PI)) (* 3.08641975308642e-5 (* PI (* a a))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 3.9e+152) {
tmp = b * b;
} else {
tmp = (angle * (angle * ((double) M_PI))) * (3.08641975308642e-5 * (((double) M_PI) * (a * a)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 3.9e+152) {
tmp = b * b;
} else {
tmp = (angle * (angle * Math.PI)) * (3.08641975308642e-5 * (Math.PI * (a * a)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 3.9e+152: tmp = b * b else: tmp = (angle * (angle * math.pi)) * (3.08641975308642e-5 * (math.pi * (a * a))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 3.9e+152) tmp = Float64(b * b); else tmp = Float64(Float64(angle * Float64(angle * pi)) * Float64(3.08641975308642e-5 * Float64(pi * Float64(a * a)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 3.9e+152) tmp = b * b; else tmp = (angle * (angle * pi)) * (3.08641975308642e-5 * (pi * (a * a))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 3.9e+152], N[(b * b), $MachinePrecision], N[(N[(angle * N[(angle * Pi), $MachinePrecision]), $MachinePrecision] * N[(3.08641975308642e-5 * N[(Pi * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.9 \cdot 10^{+152}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(angle \cdot \left(angle \cdot \pi\right)\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \left(a \cdot a\right)\right)\right)\\
\end{array}
\end{array}
if a < 3.90000000000000011e152Initial program 74.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6458.5
Applied rewrites58.5%
if 3.90000000000000011e152 < a Initial program 96.5%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites39.9%
Taylor expanded in b around 0
Applied rewrites46.0%
Applied rewrites46.3%
Final simplification57.0%
(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 77.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6455.2
Applied rewrites55.2%
herbie shell --seed 2024234
(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)))