
(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 12 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 (+ (* (+ 0.5 (* 0.5 (cos (* 2.0 (/ (* (pow (sqrt PI) 2.0) angle) -180.0))))) (* a a)) (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return ((0.5 + (0.5 * cos((2.0 * ((pow(sqrt(((double) M_PI)), 2.0) * angle) / -180.0))))) * (a * a)) + pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return ((0.5 + (0.5 * Math.cos((2.0 * ((Math.pow(Math.sqrt(Math.PI), 2.0) * angle) / -180.0))))) * (a * a)) + Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0);
}
def code(a, b, angle): return ((0.5 + (0.5 * math.cos((2.0 * ((math.pow(math.sqrt(math.pi), 2.0) * angle) / -180.0))))) * (a * a)) + math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0)
function code(a, b, angle) return Float64(Float64(Float64(0.5 + Float64(0.5 * cos(Float64(2.0 * Float64(Float64((sqrt(pi) ^ 2.0) * angle) / -180.0))))) * Float64(a * a)) + (Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((0.5 + (0.5 * cos((2.0 * (((sqrt(pi) ^ 2.0) * angle) / -180.0))))) * (a * a)) + ((b * sin((pi * (angle / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(N[(0.5 + N[(0.5 * N[Cos[N[(2.0 * N[(N[(N[Power[N[Sqrt[Pi], $MachinePrecision], 2.0], $MachinePrecision] * angle), $MachinePrecision] / -180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 + 0.5 \cdot \cos \left(2 \cdot \frac{{\left(\sqrt{\pi}\right)}^{2} \cdot angle}{-180}\right)\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 79.7%
unpow-prod-downN/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr79.7%
add-sqr-sqrtN/A
pow2N/A
pow-lowering-pow.f64N/A
sqrt-lowering-sqrt.f64N/A
PI-lowering-PI.f6479.8%
Applied egg-rr79.8%
(FPCore (a b angle) :precision binary64 (+ (pow (* b (sin (* PI (/ angle 180.0)))) 2.0) (* (* a a) (+ 0.5 (* 0.5 (cos (/ 2.0 (/ -180.0 (* PI angle)))))))))
double code(double a, double b, double angle) {
return pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0) + ((a * a) * (0.5 + (0.5 * cos((2.0 / (-180.0 / (((double) M_PI) * angle)))))));
}
public static double code(double a, double b, double angle) {
return Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0) + ((a * a) * (0.5 + (0.5 * Math.cos((2.0 / (-180.0 / (Math.PI * angle)))))));
}
def code(a, b, angle): return math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0) + ((a * a) * (0.5 + (0.5 * math.cos((2.0 / (-180.0 / (math.pi * angle)))))))
function code(a, b, angle) return Float64((Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0) + Float64(Float64(a * a) * Float64(0.5 + Float64(0.5 * cos(Float64(2.0 / Float64(-180.0 / Float64(pi * angle)))))))) end
function tmp = code(a, b, angle) tmp = ((b * sin((pi * (angle / 180.0)))) ^ 2.0) + ((a * a) * (0.5 + (0.5 * cos((2.0 / (-180.0 / (pi * angle))))))); end
code[a_, b_, angle_] := N[(N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(0.5 + N[(0.5 * N[Cos[N[(2.0 / N[(-180.0 / N[(Pi * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + \left(a \cdot a\right) \cdot \left(0.5 + 0.5 \cdot \cos \left(\frac{2}{\frac{-180}{\pi \cdot angle}}\right)\right)
\end{array}
Initial program 79.7%
unpow-prod-downN/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr79.7%
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6479.7%
Applied egg-rr79.7%
Final simplification79.7%
(FPCore (a b angle) :precision binary64 (+ (pow (* b (sin (* PI (/ angle 180.0)))) 2.0) (* (* a a) (+ 0.5 (* 0.5 (cos (* 2.0 (/ PI (/ -180.0 angle)))))))))
double code(double a, double b, double angle) {
return pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0) + ((a * a) * (0.5 + (0.5 * cos((2.0 * (((double) M_PI) / (-180.0 / angle)))))));
}
public static double code(double a, double b, double angle) {
return Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0) + ((a * a) * (0.5 + (0.5 * Math.cos((2.0 * (Math.PI / (-180.0 / angle)))))));
}
def code(a, b, angle): return math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0) + ((a * a) * (0.5 + (0.5 * math.cos((2.0 * (math.pi / (-180.0 / angle)))))))
function code(a, b, angle) return Float64((Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0) + Float64(Float64(a * a) * Float64(0.5 + Float64(0.5 * cos(Float64(2.0 * Float64(pi / Float64(-180.0 / angle)))))))) end
function tmp = code(a, b, angle) tmp = ((b * sin((pi * (angle / 180.0)))) ^ 2.0) + ((a * a) * (0.5 + (0.5 * cos((2.0 * (pi / (-180.0 / angle))))))); end
code[a_, b_, angle_] := N[(N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(0.5 + N[(0.5 * N[Cos[N[(2.0 * N[(Pi / N[(-180.0 / angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + \left(a \cdot a\right) \cdot \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \frac{\pi}{\frac{-180}{angle}}\right)\right)
\end{array}
Initial program 79.7%
unpow-prod-downN/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr79.7%
add-sqr-sqrtN/A
pow2N/A
pow-lowering-pow.f64N/A
sqrt-lowering-sqrt.f64N/A
PI-lowering-PI.f6479.8%
Applied egg-rr79.8%
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
add-sqr-sqrtN/A
associate-*r/N/A
clear-numN/A
un-div-invN/A
metadata-evalN/A
distribute-neg-fracN/A
/-lowering-/.f64N/A
PI-lowering-PI.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f6479.7%
Applied egg-rr79.7%
Final simplification79.7%
(FPCore (a b angle) :precision binary64 (+ (pow (* b (sin (* PI (/ angle 180.0)))) 2.0) (* (* a a) (+ 0.5 (* 0.5 (cos (* 2.0 (/ (* PI angle) -180.0))))))))
double code(double a, double b, double angle) {
return pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0) + ((a * a) * (0.5 + (0.5 * cos((2.0 * ((((double) M_PI) * angle) / -180.0))))));
}
public static double code(double a, double b, double angle) {
return Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0) + ((a * a) * (0.5 + (0.5 * Math.cos((2.0 * ((Math.PI * angle) / -180.0))))));
}
def code(a, b, angle): return math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0) + ((a * a) * (0.5 + (0.5 * math.cos((2.0 * ((math.pi * angle) / -180.0))))))
function code(a, b, angle) return Float64((Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0) + Float64(Float64(a * a) * Float64(0.5 + Float64(0.5 * cos(Float64(2.0 * Float64(Float64(pi * angle) / -180.0))))))) end
function tmp = code(a, b, angle) tmp = ((b * sin((pi * (angle / 180.0)))) ^ 2.0) + ((a * a) * (0.5 + (0.5 * cos((2.0 * ((pi * angle) / -180.0)))))); end
code[a_, b_, angle_] := N[(N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(0.5 + N[(0.5 * N[Cos[N[(2.0 * N[(N[(Pi * angle), $MachinePrecision] / -180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + \left(a \cdot a\right) \cdot \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \frac{\pi \cdot angle}{-180}\right)\right)
\end{array}
Initial program 79.7%
unpow-prod-downN/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr79.7%
Final simplification79.7%
(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 79.7%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6479.3%
Simplified79.3%
(FPCore (a b angle)
:precision binary64
(if (<= a 4.2e-35)
(+
(* a a)
(*
angle
(*
(* angle (* PI PI))
(+ (* (* b b) 3.08641975308642e-5) (* (* a a) -3.08641975308642e-5)))))
(+
(* a a)
(*
b
(*
b
(-
0.5
(*
0.5
(cos (* 2.0 (/ 0.005555555555555556 (/ 1.0 (* PI angle))))))))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 4.2e-35) {
tmp = (a * a) + (angle * ((angle * (((double) M_PI) * ((double) M_PI))) * (((b * b) * 3.08641975308642e-5) + ((a * a) * -3.08641975308642e-5))));
} else {
tmp = (a * a) + (b * (b * (0.5 - (0.5 * cos((2.0 * (0.005555555555555556 / (1.0 / (((double) M_PI) * angle)))))))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 4.2e-35) {
tmp = (a * a) + (angle * ((angle * (Math.PI * Math.PI)) * (((b * b) * 3.08641975308642e-5) + ((a * a) * -3.08641975308642e-5))));
} else {
tmp = (a * a) + (b * (b * (0.5 - (0.5 * Math.cos((2.0 * (0.005555555555555556 / (1.0 / (Math.PI * angle)))))))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 4.2e-35: tmp = (a * a) + (angle * ((angle * (math.pi * math.pi)) * (((b * b) * 3.08641975308642e-5) + ((a * a) * -3.08641975308642e-5)))) else: tmp = (a * a) + (b * (b * (0.5 - (0.5 * math.cos((2.0 * (0.005555555555555556 / (1.0 / (math.pi * angle))))))))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 4.2e-35) tmp = Float64(Float64(a * a) + Float64(angle * Float64(Float64(angle * Float64(pi * pi)) * Float64(Float64(Float64(b * b) * 3.08641975308642e-5) + Float64(Float64(a * a) * -3.08641975308642e-5))))); else tmp = Float64(Float64(a * a) + Float64(b * Float64(b * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.005555555555555556 / Float64(1.0 / Float64(pi * angle)))))))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 4.2e-35) tmp = (a * a) + (angle * ((angle * (pi * pi)) * (((b * b) * 3.08641975308642e-5) + ((a * a) * -3.08641975308642e-5)))); else tmp = (a * a) + (b * (b * (0.5 - (0.5 * cos((2.0 * (0.005555555555555556 / (1.0 / (pi * angle))))))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 4.2e-35], N[(N[(a * a), $MachinePrecision] + N[(angle * N[(N[(angle * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(b * b), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * -3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[(b * N[(b * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.005555555555555556 / N[(1.0 / N[(Pi * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 4.2 \cdot 10^{-35}:\\
\;\;\;\;a \cdot a + angle \cdot \left(\left(angle \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(\left(b \cdot b\right) \cdot 3.08641975308642 \cdot 10^{-5} + \left(a \cdot a\right) \cdot -3.08641975308642 \cdot 10^{-5}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + b \cdot \left(b \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \frac{0.005555555555555556}{\frac{1}{\pi \cdot angle}}\right)\right)\right)\\
\end{array}
\end{array}
if a < 4.2e-35Initial program 77.9%
Taylor expanded in angle around 0
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
Simplified44.6%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr50.6%
if 4.2e-35 < a Initial program 84.4%
unpow2N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
Applied egg-rr84.4%
associate-/r/N/A
associate-*l/N/A
clear-numN/A
div-invN/A
associate-/r*N/A
/-lowering-/.f64N/A
metadata-evalN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6484.4%
Applied egg-rr84.4%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6483.2%
Simplified83.2%
Final simplification59.4%
(FPCore (a b angle)
:precision binary64
(if (<= a 9e-35)
(+
(* a a)
(*
angle
(*
(* angle (* PI PI))
(+ (* (* b b) 3.08641975308642e-5) (* (* a a) -3.08641975308642e-5)))))
(+
(* a a)
(* b (* b (- 0.5 (* 0.5 (cos (* 2.0 (/ PI (/ 180.0 angle)))))))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 9e-35) {
tmp = (a * a) + (angle * ((angle * (((double) M_PI) * ((double) M_PI))) * (((b * b) * 3.08641975308642e-5) + ((a * a) * -3.08641975308642e-5))));
} else {
tmp = (a * a) + (b * (b * (0.5 - (0.5 * cos((2.0 * (((double) M_PI) / (180.0 / angle))))))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 9e-35) {
tmp = (a * a) + (angle * ((angle * (Math.PI * Math.PI)) * (((b * b) * 3.08641975308642e-5) + ((a * a) * -3.08641975308642e-5))));
} else {
tmp = (a * a) + (b * (b * (0.5 - (0.5 * Math.cos((2.0 * (Math.PI / (180.0 / angle))))))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 9e-35: tmp = (a * a) + (angle * ((angle * (math.pi * math.pi)) * (((b * b) * 3.08641975308642e-5) + ((a * a) * -3.08641975308642e-5)))) else: tmp = (a * a) + (b * (b * (0.5 - (0.5 * math.cos((2.0 * (math.pi / (180.0 / angle)))))))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 9e-35) tmp = Float64(Float64(a * a) + Float64(angle * Float64(Float64(angle * Float64(pi * pi)) * Float64(Float64(Float64(b * b) * 3.08641975308642e-5) + Float64(Float64(a * a) * -3.08641975308642e-5))))); else tmp = Float64(Float64(a * a) + Float64(b * Float64(b * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(pi / Float64(180.0 / angle))))))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 9e-35) tmp = (a * a) + (angle * ((angle * (pi * pi)) * (((b * b) * 3.08641975308642e-5) + ((a * a) * -3.08641975308642e-5)))); else tmp = (a * a) + (b * (b * (0.5 - (0.5 * cos((2.0 * (pi / (180.0 / angle)))))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 9e-35], N[(N[(a * a), $MachinePrecision] + N[(angle * N[(N[(angle * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(b * b), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * -3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[(b * N[(b * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(Pi / N[(180.0 / angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 9 \cdot 10^{-35}:\\
\;\;\;\;a \cdot a + angle \cdot \left(\left(angle \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(\left(b \cdot b\right) \cdot 3.08641975308642 \cdot 10^{-5} + \left(a \cdot a\right) \cdot -3.08641975308642 \cdot 10^{-5}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + b \cdot \left(b \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \frac{\pi}{\frac{180}{angle}}\right)\right)\right)\\
\end{array}
\end{array}
if a < 9.0000000000000002e-35Initial program 77.9%
Taylor expanded in angle around 0
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
Simplified44.6%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr50.6%
if 9.0000000000000002e-35 < a Initial program 84.4%
unpow2N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
Applied egg-rr84.4%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6483.2%
Simplified83.2%
Final simplification59.4%
(FPCore (a b angle)
:precision binary64
(if (<= b 4e-35)
(* (+ 1.0 (cos (* (* PI angle) -0.011111111111111112))) (* 0.5 (* a a)))
(+
(* a a)
(* (* angle angle) (* PI (* PI (* (* b b) 3.08641975308642e-5)))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 4e-35) {
tmp = (1.0 + cos(((((double) M_PI) * angle) * -0.011111111111111112))) * (0.5 * (a * a));
} else {
tmp = (a * a) + ((angle * angle) * (((double) M_PI) * (((double) M_PI) * ((b * b) * 3.08641975308642e-5))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 4e-35) {
tmp = (1.0 + Math.cos(((Math.PI * angle) * -0.011111111111111112))) * (0.5 * (a * a));
} else {
tmp = (a * a) + ((angle * angle) * (Math.PI * (Math.PI * ((b * b) * 3.08641975308642e-5))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 4e-35: tmp = (1.0 + math.cos(((math.pi * angle) * -0.011111111111111112))) * (0.5 * (a * a)) else: tmp = (a * a) + ((angle * angle) * (math.pi * (math.pi * ((b * b) * 3.08641975308642e-5)))) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 4e-35) tmp = Float64(Float64(1.0 + cos(Float64(Float64(pi * angle) * -0.011111111111111112))) * Float64(0.5 * Float64(a * a))); else tmp = Float64(Float64(a * a) + Float64(Float64(angle * angle) * Float64(pi * Float64(pi * Float64(Float64(b * b) * 3.08641975308642e-5))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 4e-35) tmp = (1.0 + cos(((pi * angle) * -0.011111111111111112))) * (0.5 * (a * a)); else tmp = (a * a) + ((angle * angle) * (pi * (pi * ((b * b) * 3.08641975308642e-5)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 4e-35], N[(N[(1.0 + N[Cos[N[(N[(Pi * angle), $MachinePrecision] * -0.011111111111111112), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[(N[(angle * angle), $MachinePrecision] * N[(Pi * N[(Pi * N[(N[(b * b), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4 \cdot 10^{-35}:\\
\;\;\;\;\left(1 + \cos \left(\left(\pi \cdot angle\right) \cdot -0.011111111111111112\right)\right) \cdot \left(0.5 \cdot \left(a \cdot a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + \left(angle \cdot angle\right) \cdot \left(\pi \cdot \left(\pi \cdot \left(\left(b \cdot b\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\right)\\
\end{array}
\end{array}
if b < 4.00000000000000003e-35Initial program 79.9%
unpow-prod-downN/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr79.9%
Taylor expanded in a around inf
distribute-lft-inN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt1-inN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
cos-lowering-cos.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6467.5%
Simplified67.5%
if 4.00000000000000003e-35 < b Initial program 79.1%
Taylor expanded in angle around 0
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
Simplified43.9%
Taylor expanded in b around inf
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6462.0%
Simplified62.0%
Final simplification66.1%
(FPCore (a b angle)
:precision binary64
(if (<= b 7e-44)
(* a a)
(+
(* a a)
(* (* angle angle) (* PI (* PI (* (* b b) 3.08641975308642e-5)))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 7e-44) {
tmp = a * a;
} else {
tmp = (a * a) + ((angle * angle) * (((double) M_PI) * (((double) M_PI) * ((b * b) * 3.08641975308642e-5))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 7e-44) {
tmp = a * a;
} else {
tmp = (a * a) + ((angle * angle) * (Math.PI * (Math.PI * ((b * b) * 3.08641975308642e-5))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 7e-44: tmp = a * a else: tmp = (a * a) + ((angle * angle) * (math.pi * (math.pi * ((b * b) * 3.08641975308642e-5)))) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 7e-44) tmp = Float64(a * a); else tmp = Float64(Float64(a * a) + Float64(Float64(angle * angle) * Float64(pi * Float64(pi * Float64(Float64(b * b) * 3.08641975308642e-5))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 7e-44) tmp = a * a; else tmp = (a * a) + ((angle * angle) * (pi * (pi * ((b * b) * 3.08641975308642e-5)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 7e-44], N[(a * a), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[(N[(angle * angle), $MachinePrecision] * N[(Pi * N[(Pi * N[(N[(b * b), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7 \cdot 10^{-44}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + \left(angle \cdot angle\right) \cdot \left(\pi \cdot \left(\pi \cdot \left(\left(b \cdot b\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\right)\\
\end{array}
\end{array}
if b < 6.9999999999999995e-44Initial program 79.8%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6467.3%
Simplified67.3%
if 6.9999999999999995e-44 < b Initial program 79.5%
Taylor expanded in angle around 0
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
Simplified45.1%
Taylor expanded in b around inf
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6463.7%
Simplified63.7%
Final simplification66.3%
(FPCore (a b angle) :precision binary64 (if (<= b 5.6e+162) (* a a) (* (* b (* angle angle)) (* b (* PI (* PI 3.08641975308642e-5))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 5.6e+162) {
tmp = a * a;
} else {
tmp = (b * (angle * angle)) * (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 <= 5.6e+162) {
tmp = a * a;
} else {
tmp = (b * (angle * angle)) * (b * (Math.PI * (Math.PI * 3.08641975308642e-5)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 5.6e+162: tmp = a * a else: tmp = (b * (angle * angle)) * (b * (math.pi * (math.pi * 3.08641975308642e-5))) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 5.6e+162) tmp = Float64(a * a); else tmp = Float64(Float64(b * Float64(angle * angle)) * Float64(b * Float64(pi * Float64(pi * 3.08641975308642e-5)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 5.6e+162) tmp = a * a; else tmp = (b * (angle * angle)) * (b * (pi * (pi * 3.08641975308642e-5))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 5.6e+162], N[(a * a), $MachinePrecision], N[(N[(b * N[(angle * angle), $MachinePrecision]), $MachinePrecision] * N[(b * N[(Pi * N[(Pi * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.6 \cdot 10^{+162}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot \left(angle \cdot angle\right)\right) \cdot \left(b \cdot \left(\pi \cdot \left(\pi \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\right)\\
\end{array}
\end{array}
if b < 5.59999999999999981e162Initial program 78.2%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6462.6%
Simplified62.6%
if 5.59999999999999981e162 < b Initial program 99.8%
Taylor expanded in angle around 0
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
Simplified67.6%
Taylor expanded in a around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6478.7%
Simplified78.7%
associate-*l*N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6478.8%
Applied egg-rr78.8%
Final simplification63.8%
(FPCore (a b angle) :precision binary64 (if (<= b 5.5e+162) (* a a) (* b (* (* angle angle) (* b (* PI (* PI 3.08641975308642e-5)))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 5.5e+162) {
tmp = a * a;
} else {
tmp = b * ((angle * angle) * (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 <= 5.5e+162) {
tmp = a * a;
} else {
tmp = b * ((angle * angle) * (b * (Math.PI * (Math.PI * 3.08641975308642e-5))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 5.5e+162: tmp = a * a else: tmp = b * ((angle * angle) * (b * (math.pi * (math.pi * 3.08641975308642e-5)))) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 5.5e+162) tmp = Float64(a * a); else tmp = Float64(b * Float64(Float64(angle * angle) * Float64(b * Float64(pi * Float64(pi * 3.08641975308642e-5))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 5.5e+162) tmp = a * a; else tmp = b * ((angle * angle) * (b * (pi * (pi * 3.08641975308642e-5)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 5.5e+162], N[(a * a), $MachinePrecision], N[(b * N[(N[(angle * angle), $MachinePrecision] * N[(b * N[(Pi * N[(Pi * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.5 \cdot 10^{+162}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\left(angle \cdot angle\right) \cdot \left(b \cdot \left(\pi \cdot \left(\pi \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\right)\right)\\
\end{array}
\end{array}
if b < 5.49999999999999966e162Initial program 78.2%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6462.6%
Simplified62.6%
if 5.49999999999999966e162 < b Initial program 99.8%
Taylor expanded in angle around 0
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
Simplified67.6%
Taylor expanded in a around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6478.7%
Simplified78.7%
*-commutativeN/A
associate-*l*N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f6478.8%
Applied egg-rr78.8%
Final simplification63.8%
(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 79.7%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6459.6%
Simplified59.6%
herbie shell --seed 2024192
(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)))