
(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 12 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 (* (cbrt (* PI (* PI PI))) (/ -1.0 (/ -180.0 angle))))) 2.0) (pow b 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin((cbrt((((double) M_PI) * (((double) M_PI) * ((double) M_PI)))) * (-1.0 / (-180.0 / angle))))), 2.0) + pow(b, 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((Math.cbrt((Math.PI * (Math.PI * Math.PI))) * (-1.0 / (-180.0 / angle))))), 2.0) + Math.pow(b, 2.0);
}
function code(a, b, angle) return Float64((Float64(a * sin(Float64(cbrt(Float64(pi * Float64(pi * pi))) * Float64(-1.0 / Float64(-180.0 / angle))))) ^ 2.0) + (b ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[Power[N[(Pi * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[(-1.0 / N[(-180.0 / angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\sqrt[3]{\pi \cdot \left(\pi \cdot \pi\right)} \cdot \frac{-1}{\frac{-180}{angle}}\right)\right)}^{2} + {b}^{2}
\end{array}
Initial program 79.0%
Taylor expanded in angle around 0
Simplified80.2%
clear-numN/A
associate-/r/N/A
frac-2negN/A
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
distribute-neg-fracN/A
/-lowering-/.f64N/A
metadata-evalN/A
neg-sub0N/A
--lowering--.f64N/A
PI-lowering-PI.f6480.1%
Applied egg-rr80.1%
add-cbrt-cubeN/A
associate-*r*N/A
cbrt-lowering-cbrt.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6480.2%
Applied egg-rr80.2%
Final simplification80.2%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (cbrt (* PI (* PI PI))) (/ angle 180.0)))) 2.0) (* b b)))
double code(double a, double b, double angle) {
return pow((a * sin((cbrt((((double) M_PI) * (((double) M_PI) * ((double) M_PI)))) * (angle / 180.0)))), 2.0) + (b * b);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((Math.cbrt((Math.PI * (Math.PI * Math.PI))) * (angle / 180.0)))), 2.0) + (b * b);
}
function code(a, b, angle) return Float64((Float64(a * sin(Float64(cbrt(Float64(pi * Float64(pi * pi))) * Float64(angle / 180.0)))) ^ 2.0) + Float64(b * b)) end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[Power[N[(Pi * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\sqrt[3]{\pi \cdot \left(\pi \cdot \pi\right)} \cdot \frac{angle}{180}\right)\right)}^{2} + b \cdot b
\end{array}
Initial program 79.0%
Taylor expanded in angle around 0
Simplified80.2%
add-cbrt-cubeN/A
cbrt-lowering-cbrt.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6480.2%
Applied egg-rr80.2%
*-rgt-identityN/A
pow2N/A
*-lowering-*.f6480.2%
Applied egg-rr80.2%
Final simplification80.2%
(FPCore (a b angle) :precision binary64 (+ (pow b 2.0) (pow (* a (sin (* 0.005555555555555556 (/ PI (/ 1.0 angle))))) 2.0)))
double code(double a, double b, double angle) {
return pow(b, 2.0) + pow((a * sin((0.005555555555555556 * (((double) M_PI) / (1.0 / angle))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0) + Math.pow((a * Math.sin((0.005555555555555556 * (Math.PI / (1.0 / angle))))), 2.0);
}
def code(a, b, angle): return math.pow(b, 2.0) + math.pow((a * math.sin((0.005555555555555556 * (math.pi / (1.0 / angle))))), 2.0)
function code(a, b, angle) return Float64((b ^ 2.0) + (Float64(a * sin(Float64(0.005555555555555556 * Float64(pi / Float64(1.0 / angle))))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (b ^ 2.0) + ((a * sin((0.005555555555555556 * (pi / (1.0 / angle))))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[b, 2.0], $MachinePrecision] + N[Power[N[(a * N[Sin[N[(0.005555555555555556 * N[(Pi / N[(1.0 / angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{b}^{2} + {\left(a \cdot \sin \left(0.005555555555555556 \cdot \frac{\pi}{\frac{1}{angle}}\right)\right)}^{2}
\end{array}
Initial program 79.0%
Taylor expanded in angle around 0
Simplified80.2%
associate-/r/N/A
clear-numN/A
inv-powN/A
div-invN/A
associate-/l*N/A
unpow-prod-downN/A
metadata-evalN/A
metadata-evalN/A
*-lowering-*.f64N/A
metadata-evalN/A
pow-lowering-pow.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
PI-lowering-PI.f6480.1%
Applied egg-rr80.1%
unpow-1N/A
div-invN/A
associate-/r*N/A
clear-numN/A
/-rgt-identityN/A
/-lowering-/.f64N/A
PI-lowering-PI.f64N/A
/-lowering-/.f6480.2%
Applied egg-rr80.2%
Final simplification80.2%
(FPCore (a b angle) :precision binary64 (+ (* b b) (pow (* a (sin (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return (b * b) + pow((a * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return (b * b) + Math.pow((a * Math.sin((Math.PI * (angle / 180.0)))), 2.0);
}
def code(a, b, angle): return (b * b) + math.pow((a * math.sin((math.pi * (angle / 180.0)))), 2.0)
function code(a, b, angle) return Float64(Float64(b * b) + (Float64(a * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (b * b) + ((a * sin((pi * (angle / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(b * b), $MachinePrecision] + N[Power[N[(a * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot b + {\left(a \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 79.0%
Taylor expanded in angle around 0
Simplified80.2%
*-rgt-identityN/A
pow2N/A
*-lowering-*.f6480.2%
Applied egg-rr80.2%
Final simplification80.2%
(FPCore (a b angle)
:precision binary64
(if (<= angle 0.00067)
(+
(* b b)
(* a (* a (* 3.08641975308642e-5 (* angle (* angle (* PI PI)))))))
(+
(* b b)
(* a (* a (+ 0.5 (* (cos (* 2.0 (/ angle (/ 180.0 PI)))) -0.5)))))))
double code(double a, double b, double angle) {
double tmp;
if (angle <= 0.00067) {
tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * (angle * (((double) M_PI) * ((double) M_PI)))))));
} else {
tmp = (b * b) + (a * (a * (0.5 + (cos((2.0 * (angle / (180.0 / ((double) M_PI))))) * -0.5))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (angle <= 0.00067) {
tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * (angle * (Math.PI * Math.PI))))));
} else {
tmp = (b * b) + (a * (a * (0.5 + (Math.cos((2.0 * (angle / (180.0 / Math.PI)))) * -0.5))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if angle <= 0.00067: tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * (angle * (math.pi * math.pi)))))) else: tmp = (b * b) + (a * (a * (0.5 + (math.cos((2.0 * (angle / (180.0 / math.pi)))) * -0.5)))) return tmp
function code(a, b, angle) tmp = 0.0 if (angle <= 0.00067) tmp = Float64(Float64(b * b) + Float64(a * Float64(a * Float64(3.08641975308642e-5 * Float64(angle * Float64(angle * Float64(pi * pi))))))); else tmp = Float64(Float64(b * b) + Float64(a * Float64(a * Float64(0.5 + Float64(cos(Float64(2.0 * Float64(angle / Float64(180.0 / pi)))) * -0.5))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (angle <= 0.00067) tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * (angle * (pi * pi)))))); else tmp = (b * b) + (a * (a * (0.5 + (cos((2.0 * (angle / (180.0 / pi)))) * -0.5)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[angle, 0.00067], N[(N[(b * b), $MachinePrecision] + N[(a * N[(a * N[(3.08641975308642e-5 * N[(angle * N[(angle * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * b), $MachinePrecision] + N[(a * N[(a * N[(0.5 + N[(N[Cos[N[(2.0 * N[(angle / N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 0.00067:\\
\;\;\;\;b \cdot b + a \cdot \left(a \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot \left(angle \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot b + a \cdot \left(a \cdot \left(0.5 + \cos \left(2 \cdot \frac{angle}{\frac{180}{\pi}}\right) \cdot -0.5\right)\right)\\
\end{array}
\end{array}
if angle < 6.7000000000000002e-4Initial program 86.3%
Taylor expanded in angle around 0
Simplified86.7%
Taylor expanded in angle around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
Simplified71.4%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6477.5%
Applied egg-rr77.5%
if 6.7000000000000002e-4 < angle Initial program 56.9%
Taylor expanded in angle around 0
Simplified60.3%
add-cbrt-cubeN/A
cbrt-lowering-cbrt.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6460.6%
Applied egg-rr60.6%
+-commutativeN/A
+-lowering-+.f64N/A
*-rgt-identityN/A
pow2N/A
*-lowering-*.f64N/A
unpow-prod-downN/A
pow2N/A
associate-*r*N/A
pow2N/A
associate-/r/N/A
Applied egg-rr60.4%
Final simplification73.3%
(FPCore (a b angle)
:precision binary64
(if (<= angle 0.00067)
(+
(* b b)
(* a (* a (* 3.08641975308642e-5 (* angle (* angle (* PI PI)))))))
(+
(* b b)
(* a (* a (+ 0.5 (* -0.5 (cos (* (* angle PI) 0.011111111111111112)))))))))
double code(double a, double b, double angle) {
double tmp;
if (angle <= 0.00067) {
tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * (angle * (((double) M_PI) * ((double) M_PI)))))));
} else {
tmp = (b * b) + (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 <= 0.00067) {
tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * (angle * (Math.PI * Math.PI))))));
} else {
tmp = (b * b) + (a * (a * (0.5 + (-0.5 * Math.cos(((angle * Math.PI) * 0.011111111111111112))))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if angle <= 0.00067: tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * (angle * (math.pi * math.pi)))))) else: tmp = (b * b) + (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 <= 0.00067) tmp = Float64(Float64(b * b) + Float64(a * Float64(a * Float64(3.08641975308642e-5 * Float64(angle * Float64(angle * Float64(pi * pi))))))); else tmp = Float64(Float64(b * b) + Float64(a * Float64(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 <= 0.00067) tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * (angle * (pi * pi)))))); else tmp = (b * b) + (a * (a * (0.5 + (-0.5 * cos(((angle * pi) * 0.011111111111111112)))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[angle, 0.00067], N[(N[(b * b), $MachinePrecision] + N[(a * N[(a * N[(3.08641975308642e-5 * N[(angle * N[(angle * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * b), $MachinePrecision] + N[(a * N[(a * N[(0.5 + N[(-0.5 * N[Cos[N[(N[(angle * Pi), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 0.00067:\\
\;\;\;\;b \cdot b + a \cdot \left(a \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot \left(angle \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot b + a \cdot \left(a \cdot \left(0.5 + -0.5 \cdot \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right)\right)\\
\end{array}
\end{array}
if angle < 6.7000000000000002e-4Initial program 86.3%
Taylor expanded in angle around 0
Simplified86.7%
Taylor expanded in angle around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
Simplified71.4%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6477.5%
Applied egg-rr77.5%
if 6.7000000000000002e-4 < angle Initial program 56.9%
Taylor expanded in angle around 0
Simplified60.3%
+-commutativeN/A
+-lowering-+.f64N/A
*-rgt-identityN/A
pow2N/A
*-lowering-*.f64N/A
unpow-prod-downN/A
unpow2N/A
associate-*r*N/A
pow2N/A
associate-/r/N/A
associate-/r/N/A
sqr-sin-aN/A
*-lowering-*.f64N/A
sqr-sin-aN/A
Applied egg-rr60.2%
Final simplification73.2%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* angle (* PI PI))))
(if (<= a 7.5e+153)
(+ (* b b) (* t_0 (* angle (* a (* a 3.08641975308642e-5)))))
(+ (* b b) (* a (* a (* 3.08641975308642e-5 (* angle t_0))))))))
double code(double a, double b, double angle) {
double t_0 = angle * (((double) M_PI) * ((double) M_PI));
double tmp;
if (a <= 7.5e+153) {
tmp = (b * b) + (t_0 * (angle * (a * (a * 3.08641975308642e-5))));
} else {
tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * t_0))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = angle * (Math.PI * Math.PI);
double tmp;
if (a <= 7.5e+153) {
tmp = (b * b) + (t_0 * (angle * (a * (a * 3.08641975308642e-5))));
} else {
tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * t_0))));
}
return tmp;
}
def code(a, b, angle): t_0 = angle * (math.pi * math.pi) tmp = 0 if a <= 7.5e+153: tmp = (b * b) + (t_0 * (angle * (a * (a * 3.08641975308642e-5)))) else: tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * t_0)))) return tmp
function code(a, b, angle) t_0 = Float64(angle * Float64(pi * pi)) tmp = 0.0 if (a <= 7.5e+153) tmp = Float64(Float64(b * b) + Float64(t_0 * Float64(angle * Float64(a * Float64(a * 3.08641975308642e-5))))); else tmp = Float64(Float64(b * b) + Float64(a * Float64(a * Float64(3.08641975308642e-5 * Float64(angle * t_0))))); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = angle * (pi * pi); tmp = 0.0; if (a <= 7.5e+153) tmp = (b * b) + (t_0 * (angle * (a * (a * 3.08641975308642e-5)))); else tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * t_0)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(angle * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, 7.5e+153], N[(N[(b * b), $MachinePrecision] + N[(t$95$0 * N[(angle * N[(a * N[(a * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * b), $MachinePrecision] + N[(a * N[(a * N[(3.08641975308642e-5 * N[(angle * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := angle \cdot \left(\pi \cdot \pi\right)\\
\mathbf{if}\;a \leq 7.5 \cdot 10^{+153}:\\
\;\;\;\;b \cdot b + t\_0 \cdot \left(angle \cdot \left(a \cdot \left(a \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot b + a \cdot \left(a \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot t\_0\right)\right)\right)\\
\end{array}
\end{array}
if a < 7.50000000000000065e153Initial program 75.3%
Taylor expanded in angle around 0
Simplified76.7%
Taylor expanded in angle around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
Simplified65.1%
pow2N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
pow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6469.7%
Applied egg-rr69.7%
if 7.50000000000000065e153 < a Initial program 99.7%
Taylor expanded in angle around 0
Simplified99.7%
Taylor expanded in angle around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
Simplified67.3%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6487.6%
Applied egg-rr87.6%
Final simplification72.4%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* angle (* PI PI))))
(if (<= a 5.4e+137)
(+ (* b b) (* (* 3.08641975308642e-5 t_0) (* angle (* a a))))
(+ (* b b) (* a (* a (* 3.08641975308642e-5 (* angle t_0))))))))
double code(double a, double b, double angle) {
double t_0 = angle * (((double) M_PI) * ((double) M_PI));
double tmp;
if (a <= 5.4e+137) {
tmp = (b * b) + ((3.08641975308642e-5 * t_0) * (angle * (a * a)));
} else {
tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * t_0))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = angle * (Math.PI * Math.PI);
double tmp;
if (a <= 5.4e+137) {
tmp = (b * b) + ((3.08641975308642e-5 * t_0) * (angle * (a * a)));
} else {
tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * t_0))));
}
return tmp;
}
def code(a, b, angle): t_0 = angle * (math.pi * math.pi) tmp = 0 if a <= 5.4e+137: tmp = (b * b) + ((3.08641975308642e-5 * t_0) * (angle * (a * a))) else: tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * t_0)))) return tmp
function code(a, b, angle) t_0 = Float64(angle * Float64(pi * pi)) tmp = 0.0 if (a <= 5.4e+137) tmp = Float64(Float64(b * b) + Float64(Float64(3.08641975308642e-5 * t_0) * Float64(angle * Float64(a * a)))); else tmp = Float64(Float64(b * b) + Float64(a * Float64(a * Float64(3.08641975308642e-5 * Float64(angle * t_0))))); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = angle * (pi * pi); tmp = 0.0; if (a <= 5.4e+137) tmp = (b * b) + ((3.08641975308642e-5 * t_0) * (angle * (a * a))); else tmp = (b * b) + (a * (a * (3.08641975308642e-5 * (angle * t_0)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(angle * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, 5.4e+137], N[(N[(b * b), $MachinePrecision] + N[(N[(3.08641975308642e-5 * t$95$0), $MachinePrecision] * N[(angle * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * b), $MachinePrecision] + N[(a * N[(a * N[(3.08641975308642e-5 * N[(angle * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := angle \cdot \left(\pi \cdot \pi\right)\\
\mathbf{if}\;a \leq 5.4 \cdot 10^{+137}:\\
\;\;\;\;b \cdot b + \left(3.08641975308642 \cdot 10^{-5} \cdot t\_0\right) \cdot \left(angle \cdot \left(a \cdot a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot b + a \cdot \left(a \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot t\_0\right)\right)\right)\\
\end{array}
\end{array}
if a < 5.40000000000000034e137Initial program 75.4%
Taylor expanded in angle around 0
Simplified76.8%
Taylor expanded in angle around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
Simplified65.3%
pow2N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
pow2N/A
*-lowering-*.f6470.0%
Applied egg-rr70.0%
if 5.40000000000000034e137 < a Initial program 96.9%
Taylor expanded in angle around 0
Simplified96.9%
Taylor expanded in angle around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
Simplified66.1%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6484.5%
Applied egg-rr84.5%
Final simplification72.4%
(FPCore (a b angle) :precision binary64 (if (<= a 1.65e+142) (* b b) (* a (* a (* 3.08641975308642e-5 (* angle (* angle (* PI PI))))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.65e+142) {
tmp = b * b;
} else {
tmp = a * (a * (3.08641975308642e-5 * (angle * (angle * (((double) M_PI) * ((double) M_PI))))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.65e+142) {
tmp = b * b;
} else {
tmp = a * (a * (3.08641975308642e-5 * (angle * (angle * (Math.PI * Math.PI)))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.65e+142: tmp = b * b else: tmp = a * (a * (3.08641975308642e-5 * (angle * (angle * (math.pi * math.pi))))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.65e+142) tmp = Float64(b * b); else tmp = Float64(a * Float64(a * Float64(3.08641975308642e-5 * Float64(angle * Float64(angle * Float64(pi * pi)))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.65e+142) tmp = b * b; else tmp = a * (a * (3.08641975308642e-5 * (angle * (angle * (pi * pi))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.65e+142], N[(b * b), $MachinePrecision], N[(a * N[(a * N[(3.08641975308642e-5 * N[(angle * N[(angle * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.65 \cdot 10^{+142}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(a \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot \left(angle \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.6500000000000001e142Initial program 75.7%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6458.8%
Simplified58.8%
if 1.6500000000000001e142 < a Initial program 96.7%
Taylor expanded in angle around 0
Simplified96.7%
Taylor expanded in angle around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
Simplified64.4%
Taylor expanded in b around 0
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
metadata-evalN/A
metadata-evalN/A
associate-*l*N/A
distribute-rgt-outN/A
associate-*l*N/A
associate-*r*N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
Simplified64.4%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
associate-*l*N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6469.6%
Applied egg-rr69.6%
Final simplification60.5%
(FPCore (a b angle) :precision binary64 (if (<= a 1.5e+142) (* b b) (* (* a a) (* 3.08641975308642e-5 (* PI (* PI (* angle angle)))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.5e+142) {
tmp = b * b;
} else {
tmp = (a * a) * (3.08641975308642e-5 * (((double) M_PI) * (((double) M_PI) * (angle * angle))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.5e+142) {
tmp = b * b;
} else {
tmp = (a * a) * (3.08641975308642e-5 * (Math.PI * (Math.PI * (angle * angle))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.5e+142: tmp = b * b else: tmp = (a * a) * (3.08641975308642e-5 * (math.pi * (math.pi * (angle * angle)))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.5e+142) tmp = Float64(b * b); else tmp = Float64(Float64(a * a) * Float64(3.08641975308642e-5 * Float64(pi * Float64(pi * Float64(angle * angle))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.5e+142) tmp = b * b; else tmp = (a * a) * (3.08641975308642e-5 * (pi * (pi * (angle * angle)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.5e+142], N[(b * b), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * N[(3.08641975308642e-5 * N[(Pi * N[(Pi * N[(angle * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.5 \cdot 10^{+142}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \left(\pi \cdot \left(angle \cdot angle\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.49999999999999987e142Initial program 75.7%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6458.8%
Simplified58.8%
if 1.49999999999999987e142 < a Initial program 96.7%
Taylor expanded in angle around 0
Simplified96.7%
Taylor expanded in angle around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
Simplified64.4%
Taylor expanded in b around 0
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
metadata-evalN/A
metadata-evalN/A
associate-*l*N/A
distribute-rgt-outN/A
associate-*l*N/A
associate-*r*N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
Simplified64.4%
Final simplification59.7%
(FPCore (a b angle) :precision binary64 (+ (* b b) (* (* 3.08641975308642e-5 (* angle (* PI PI))) (* angle (* a a)))))
double code(double a, double b, double angle) {
return (b * b) + ((3.08641975308642e-5 * (angle * (((double) M_PI) * ((double) M_PI)))) * (angle * (a * a)));
}
public static double code(double a, double b, double angle) {
return (b * b) + ((3.08641975308642e-5 * (angle * (Math.PI * Math.PI))) * (angle * (a * a)));
}
def code(a, b, angle): return (b * b) + ((3.08641975308642e-5 * (angle * (math.pi * math.pi))) * (angle * (a * a)))
function code(a, b, angle) return Float64(Float64(b * b) + Float64(Float64(3.08641975308642e-5 * Float64(angle * Float64(pi * pi))) * Float64(angle * Float64(a * a)))) end
function tmp = code(a, b, angle) tmp = (b * b) + ((3.08641975308642e-5 * (angle * (pi * pi))) * (angle * (a * a))); end
code[a_, b_, angle_] := N[(N[(b * b), $MachinePrecision] + N[(N[(3.08641975308642e-5 * N[(angle * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(angle * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
b \cdot b + \left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot \left(\pi \cdot \pi\right)\right)\right) \cdot \left(angle \cdot \left(a \cdot a\right)\right)
\end{array}
Initial program 79.0%
Taylor expanded in angle around 0
Simplified80.2%
Taylor expanded in angle around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
Simplified65.5%
pow2N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
pow2N/A
*-lowering-*.f6469.9%
Applied egg-rr69.9%
(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 79.0%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6455.0%
Simplified55.0%
herbie shell --seed 2024154
(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)))