
(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 11 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 (let* ((t_0 (* angle (* PI 0.005555555555555556)))) (+ (pow (* a (cos (/ 1.0 (/ 1.0 t_0)))) 2.0) (pow (* b (sin t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = angle * (((double) M_PI) * 0.005555555555555556);
return pow((a * cos((1.0 / (1.0 / t_0)))), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = angle * (Math.PI * 0.005555555555555556);
return Math.pow((a * Math.cos((1.0 / (1.0 / t_0)))), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle): t_0 = angle * (math.pi * 0.005555555555555556) return math.pow((a * math.cos((1.0 / (1.0 / t_0)))), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(angle * Float64(pi * 0.005555555555555556)) return Float64((Float64(a * cos(Float64(1.0 / Float64(1.0 / t_0)))) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = angle * (pi * 0.005555555555555556); tmp = ((a * cos((1.0 / (1.0 / t_0)))) ^ 2.0) + ((b * sin(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[N[(1.0 / N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]], $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 := angle \cdot \left(\pi \cdot 0.005555555555555556\right)\\
{\left(a \cdot \cos \left(\frac{1}{\frac{1}{t\_0}}\right)\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
\end{array}
Initial program 77.5%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
associate-*r/N/A
div-invN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6477.5
Applied rewrites77.5%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
associate-*r/N/A
div-invN/A
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lift-/.f64N/A
div-invN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-/.f6477.5
Applied rewrites77.5%
lift-/.f64N/A
lift-/.f64N/A
clear-numN/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lower-/.f6477.6
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
lower-*.f6477.7
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lift-*.f6477.7
Applied rewrites77.7%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
remove-double-divN/A
*-commutativeN/A
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lift-*.f64N/A
lift-*.f6477.8
Applied rewrites77.8%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (cos (* angle (* PI 0.005555555555555556)))) 2.0) (pow (* b (sin (/ 1.0 (/ 180.0 (* angle PI))))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * cos((angle * (((double) M_PI) * 0.005555555555555556)))), 2.0) + pow((b * sin((1.0 / (180.0 / (angle * ((double) M_PI)))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.cos((angle * (Math.PI * 0.005555555555555556)))), 2.0) + Math.pow((b * Math.sin((1.0 / (180.0 / (angle * Math.PI))))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.cos((angle * (math.pi * 0.005555555555555556)))), 2.0) + math.pow((b * math.sin((1.0 / (180.0 / (angle * math.pi))))), 2.0)
function code(a, b, angle) return Float64((Float64(a * cos(Float64(angle * Float64(pi * 0.005555555555555556)))) ^ 2.0) + (Float64(b * sin(Float64(1.0 / Float64(180.0 / Float64(angle * pi))))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * cos((angle * (pi * 0.005555555555555556)))) ^ 2.0) + ((b * sin((1.0 / (180.0 / (angle * pi))))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Cos[N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(1.0 / N[(180.0 / N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \cos \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{1}{\frac{180}{angle \cdot \pi}}\right)\right)}^{2}
\end{array}
Initial program 77.5%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
div-invN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval77.6
Applied rewrites77.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6477.6
Applied rewrites77.6%
Final simplification77.6%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (cos (* angle (* PI 0.005555555555555556)))) 2.0) (pow (* b (sin (* 0.005555555555555556 (* angle PI)))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * cos((angle * (((double) M_PI) * 0.005555555555555556)))), 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 * Math.cos((angle * (Math.PI * 0.005555555555555556)))), 2.0) + Math.pow((b * Math.sin((0.005555555555555556 * (angle * Math.PI)))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.cos((angle * (math.pi * 0.005555555555555556)))), 2.0) + math.pow((b * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0)
function code(a, b, angle) return Float64((Float64(a * cos(Float64(angle * Float64(pi * 0.005555555555555556)))) ^ 2.0) + (Float64(b * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * cos((angle * (pi * 0.005555555555555556)))) ^ 2.0) + ((b * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Cos[N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 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}
\\
{\left(a \cdot \cos \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}
\end{array}
Initial program 77.5%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
div-invN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval77.6
Applied rewrites77.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6477.6
Applied rewrites77.6%
Final simplification77.6%
(FPCore (a b angle) :precision binary64 (+ (* a a) (pow (* b (sin (/ 1.0 (/ (/ 180.0 angle) PI)))) 2.0)))
double code(double a, double b, double angle) {
return (a * a) + pow((b * sin((1.0 / ((180.0 / angle) / ((double) M_PI))))), 2.0);
}
public static double code(double a, double b, double angle) {
return (a * a) + Math.pow((b * Math.sin((1.0 / ((180.0 / angle) / Math.PI)))), 2.0);
}
def code(a, b, angle): return (a * a) + math.pow((b * math.sin((1.0 / ((180.0 / angle) / math.pi)))), 2.0)
function code(a, b, angle) return Float64(Float64(a * a) + (Float64(b * sin(Float64(1.0 / Float64(Float64(180.0 / angle) / pi)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a * a) + ((b * sin((1.0 / ((180.0 / angle) / pi)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(1.0 / N[(N[(180.0 / angle), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a + {\left(b \cdot \sin \left(\frac{1}{\frac{\frac{180}{angle}}{\pi}}\right)\right)}^{2}
\end{array}
Initial program 77.5%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
div-invN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval77.6
Applied rewrites77.6%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
associate-*r/N/A
div-invN/A
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lift-/.f64N/A
div-invN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-/.f6477.6
Applied rewrites77.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6477.4
Applied rewrites77.4%
(FPCore (a b angle) :precision binary64 (+ (* a a) (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return (a * a) + pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return (a * a) + Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0);
}
def code(a, b, angle): return (a * a) + math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0)
function code(a, b, angle) return Float64(Float64(a * a) + (Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a * a) + ((b * sin((pi * (angle / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 77.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6477.4
Applied rewrites77.4%
(FPCore (a b angle)
:precision binary64
(if (<= a 6.4e+69)
(fma
(*
(* angle (* PI PI))
(fma b (* b 3.08641975308642e-5) (* (* a a) -3.08641975308642e-5)))
angle
(* a a))
(* a a)))
double code(double a, double b, double angle) {
double tmp;
if (a <= 6.4e+69) {
tmp = fma(((angle * (((double) M_PI) * ((double) M_PI))) * fma(b, (b * 3.08641975308642e-5), ((a * a) * -3.08641975308642e-5))), angle, (a * a));
} else {
tmp = a * a;
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 6.4e+69) tmp = fma(Float64(Float64(angle * Float64(pi * pi)) * fma(b, Float64(b * 3.08641975308642e-5), Float64(Float64(a * a) * -3.08641975308642e-5))), angle, Float64(a * a)); else tmp = Float64(a * a); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 6.4e+69], N[(N[(N[(angle * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * N[(b * N[(b * 3.08641975308642e-5), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * -3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * angle + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(a * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 6.4 \cdot 10^{+69}:\\
\;\;\;\;\mathsf{fma}\left(\left(angle \cdot \left(\pi \cdot \pi\right)\right) \cdot \mathsf{fma}\left(b, b \cdot 3.08641975308642 \cdot 10^{-5}, \left(a \cdot a\right) \cdot -3.08641975308642 \cdot 10^{-5}\right), angle, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 6.3999999999999997e69Initial program 75.9%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites43.2%
Applied rewrites46.5%
if 6.3999999999999997e69 < a Initial program 84.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6482.1
Applied rewrites82.1%
(FPCore (a b angle)
:precision binary64
(if (<= b 2.7e-36)
(* a a)
(if (<= b 3e+183)
(fma
(* angle angle)
(* PI (* PI (* b (* b 3.08641975308642e-5))))
(* a a))
(* 3.08641975308642e-5 (* (* angle (* angle b)) (* b (* PI PI)))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 2.7e-36) {
tmp = a * a;
} else if (b <= 3e+183) {
tmp = fma((angle * angle), (((double) M_PI) * (((double) M_PI) * (b * (b * 3.08641975308642e-5)))), (a * a));
} else {
tmp = 3.08641975308642e-5 * ((angle * (angle * b)) * (b * (((double) M_PI) * ((double) M_PI))));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 2.7e-36) tmp = Float64(a * a); elseif (b <= 3e+183) tmp = fma(Float64(angle * angle), Float64(pi * Float64(pi * Float64(b * Float64(b * 3.08641975308642e-5)))), Float64(a * a)); else tmp = Float64(3.08641975308642e-5 * Float64(Float64(angle * Float64(angle * b)) * Float64(b * Float64(pi * pi)))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 2.7e-36], N[(a * a), $MachinePrecision], If[LessEqual[b, 3e+183], N[(N[(angle * angle), $MachinePrecision] * N[(Pi * N[(Pi * N[(b * N[(b * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(3.08641975308642e-5 * N[(N[(angle * N[(angle * b), $MachinePrecision]), $MachinePrecision] * N[(b * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.7 \cdot 10^{-36}:\\
\;\;\;\;a \cdot a\\
\mathbf{elif}\;b \leq 3 \cdot 10^{+183}:\\
\;\;\;\;\mathsf{fma}\left(angle \cdot angle, \pi \cdot \left(\pi \cdot \left(b \cdot \left(b \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\right), a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;3.08641975308642 \cdot 10^{-5} \cdot \left(\left(angle \cdot \left(angle \cdot b\right)\right) \cdot \left(b \cdot \left(\pi \cdot \pi\right)\right)\right)\\
\end{array}
\end{array}
if b < 2.70000000000000007e-36Initial program 75.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6461.9
Applied rewrites61.9%
if 2.70000000000000007e-36 < b < 2.99999999999999996e183Initial program 72.1%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites36.2%
Taylor expanded in b around inf
Applied rewrites59.8%
if 2.99999999999999996e183 < b Initial program 99.7%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites46.5%
Taylor expanded in b around inf
Applied rewrites63.2%
Applied rewrites83.8%
Final simplification63.6%
(FPCore (a b angle) :precision binary64 (if (<= b 4.9e+149) (* a a) (* (* angle (* angle b)) (* b (* (* PI PI) 3.08641975308642e-5)))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 4.9e+149) {
tmp = a * a;
} else {
tmp = (angle * (angle * b)) * (b * ((((double) M_PI) * ((double) M_PI)) * 3.08641975308642e-5));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 4.9e+149) {
tmp = a * a;
} else {
tmp = (angle * (angle * b)) * (b * ((Math.PI * Math.PI) * 3.08641975308642e-5));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 4.9e+149: tmp = a * a else: tmp = (angle * (angle * b)) * (b * ((math.pi * math.pi) * 3.08641975308642e-5)) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 4.9e+149) tmp = Float64(a * a); else tmp = Float64(Float64(angle * Float64(angle * b)) * Float64(b * Float64(Float64(pi * pi) * 3.08641975308642e-5))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 4.9e+149) tmp = a * a; else tmp = (angle * (angle * b)) * (b * ((pi * pi) * 3.08641975308642e-5)); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 4.9e+149], N[(a * a), $MachinePrecision], N[(N[(angle * N[(angle * b), $MachinePrecision]), $MachinePrecision] * N[(b * N[(N[(Pi * Pi), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.9 \cdot 10^{+149}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(angle \cdot \left(angle \cdot b\right)\right) \cdot \left(b \cdot \left(\left(\pi \cdot \pi\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\\
\end{array}
\end{array}
if b < 4.9000000000000001e149Initial program 74.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6459.4
Applied rewrites59.4%
if 4.9000000000000001e149 < b Initial program 99.8%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites47.3%
Taylor expanded in b around inf
Applied rewrites67.3%
Applied rewrites87.0%
Final simplification62.6%
(FPCore (a b angle) :precision binary64 (if (<= b 2.2e+149) (* a a) (* angle (* angle (* b (* b (* (* PI PI) 3.08641975308642e-5)))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 2.2e+149) {
tmp = a * a;
} else {
tmp = angle * (angle * (b * (b * ((((double) M_PI) * ((double) M_PI)) * 3.08641975308642e-5))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 2.2e+149) {
tmp = a * a;
} else {
tmp = angle * (angle * (b * (b * ((Math.PI * Math.PI) * 3.08641975308642e-5))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 2.2e+149: tmp = a * a else: tmp = angle * (angle * (b * (b * ((math.pi * math.pi) * 3.08641975308642e-5)))) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 2.2e+149) tmp = Float64(a * a); else tmp = Float64(angle * Float64(angle * Float64(b * Float64(b * Float64(Float64(pi * pi) * 3.08641975308642e-5))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 2.2e+149) tmp = a * a; else tmp = angle * (angle * (b * (b * ((pi * pi) * 3.08641975308642e-5)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 2.2e+149], N[(a * a), $MachinePrecision], N[(angle * N[(angle * N[(b * N[(b * N[(N[(Pi * Pi), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.2 \cdot 10^{+149}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;angle \cdot \left(angle \cdot \left(b \cdot \left(b \cdot \left(\left(\pi \cdot \pi\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\right)\right)\\
\end{array}
\end{array}
if b < 2.2e149Initial program 74.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6459.4
Applied rewrites59.4%
if 2.2e149 < b Initial program 99.8%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites47.3%
Taylor expanded in b around inf
Applied rewrites67.3%
Applied rewrites68.4%
Final simplification60.5%
(FPCore (a b angle) :precision binary64 (if (<= b 5e+149) (* a a) (* (* 3.08641975308642e-5 (* angle angle)) (* (* PI PI) (* b b)))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 5e+149) {
tmp = a * a;
} else {
tmp = (3.08641975308642e-5 * (angle * angle)) * ((((double) M_PI) * ((double) M_PI)) * (b * b));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 5e+149) {
tmp = a * a;
} else {
tmp = (3.08641975308642e-5 * (angle * angle)) * ((Math.PI * Math.PI) * (b * b));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 5e+149: tmp = a * a else: tmp = (3.08641975308642e-5 * (angle * angle)) * ((math.pi * math.pi) * (b * b)) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 5e+149) tmp = Float64(a * a); else tmp = Float64(Float64(3.08641975308642e-5 * Float64(angle * angle)) * Float64(Float64(pi * pi) * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 5e+149) tmp = a * a; else tmp = (3.08641975308642e-5 * (angle * angle)) * ((pi * pi) * (b * b)); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 5e+149], N[(a * a), $MachinePrecision], N[(N[(3.08641975308642e-5 * N[(angle * angle), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5 \cdot 10^{+149}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot \left(b \cdot b\right)\right)\\
\end{array}
\end{array}
if b < 4.9999999999999999e149Initial program 74.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6459.4
Applied rewrites59.4%
if 4.9999999999999999e149 < b Initial program 99.8%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites47.3%
Taylor expanded in b around inf
Applied rewrites67.3%
Taylor expanded in b around inf
Applied rewrites67.3%
Final simplification60.3%
(FPCore (a b angle) :precision binary64 (* a a))
double code(double a, double b, double angle) {
return a * a;
}
real(8) function code(a, b, angle)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = a * a
end function
public static double code(double a, double b, double angle) {
return a * a;
}
def code(a, b, angle): return a * a
function code(a, b, angle) return Float64(a * a) end
function tmp = code(a, b, angle) tmp = a * a; end
code[a_, b_, angle_] := N[(a * a), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a
\end{array}
Initial program 77.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6456.2
Applied rewrites56.2%
herbie shell --seed 2024234
(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)))