
(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}
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(let* ((t_0 (* PI (* angle_m 0.005555555555555556))))
(+
(pow (* a (cos (pow (exp 2.0) (* 0.5 (log t_0))))) 2.0)
(pow (* b (sin t_0)) 2.0))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double t_0 = ((double) M_PI) * (angle_m * 0.005555555555555556);
return pow((a * cos(pow(exp(2.0), (0.5 * log(t_0))))), 2.0) + pow((b * sin(t_0)), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double t_0 = Math.PI * (angle_m * 0.005555555555555556);
return Math.pow((a * Math.cos(Math.pow(Math.exp(2.0), (0.5 * Math.log(t_0))))), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): t_0 = math.pi * (angle_m * 0.005555555555555556) return math.pow((a * math.cos(math.pow(math.exp(2.0), (0.5 * math.log(t_0))))), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
angle_m = abs(angle) function code(a, b, angle_m) t_0 = Float64(pi * Float64(angle_m * 0.005555555555555556)) return Float64((Float64(a * cos((exp(2.0) ^ Float64(0.5 * log(t_0))))) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) t_0 = pi * (angle_m * 0.005555555555555556); tmp = ((a * cos((exp(2.0) ^ (0.5 * log(t_0))))) ^ 2.0) + ((b * sin(t_0)) ^ 2.0); end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := Block[{t$95$0 = N[(Pi * N[(angle$95$m * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[N[Power[N[Exp[2.0], $MachinePrecision], N[(0.5 * N[Log[t$95$0], $MachinePrecision]), $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}
angle_m = \left|angle\right|
\\
\begin{array}{l}
t_0 := \pi \cdot \left(angle\_m \cdot 0.005555555555555556\right)\\
{\left(a \cdot \cos \left({\left(e^{2}\right)}^{\left(0.5 \cdot \log t\_0\right)}\right)\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
\end{array}
Initial program 80.7%
lift-PI.f64N/A
associate-*r/N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6480.6
Applied rewrites80.6%
div-invN/A
metadata-evalN/A
lift-*.f6480.6
Applied rewrites80.6%
lift-PI.f64N/A
lift-*.f64N/A
clear-numN/A
div-invN/A
lift-*.f64N/A
metadata-evalN/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f6480.7
unpow1N/A
metadata-evalN/A
pow-powN/A
pow-to-expN/A
pow-expN/A
*-commutativeN/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6441.0
Applied rewrites41.0%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (+ (pow (* b (sin (* PI (* angle_m 0.005555555555555556)))) 2.0) (pow (* a (cos (* PI (exp (log (* angle_m 0.005555555555555556)))))) 2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow((b * sin((((double) M_PI) * (angle_m * 0.005555555555555556)))), 2.0) + pow((a * cos((((double) M_PI) * exp(log((angle_m * 0.005555555555555556)))))), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow((b * Math.sin((Math.PI * (angle_m * 0.005555555555555556)))), 2.0) + Math.pow((a * Math.cos((Math.PI * Math.exp(Math.log((angle_m * 0.005555555555555556)))))), 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow((b * math.sin((math.pi * (angle_m * 0.005555555555555556)))), 2.0) + math.pow((a * math.cos((math.pi * math.exp(math.log((angle_m * 0.005555555555555556)))))), 2.0)
angle_m = abs(angle) function code(a, b, angle_m) return Float64((Float64(b * sin(Float64(pi * Float64(angle_m * 0.005555555555555556)))) ^ 2.0) + (Float64(a * cos(Float64(pi * exp(log(Float64(angle_m * 0.005555555555555556)))))) ^ 2.0)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = ((b * sin((pi * (angle_m * 0.005555555555555556)))) ^ 2.0) + ((a * cos((pi * exp(log((angle_m * 0.005555555555555556)))))) ^ 2.0); end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[N[(b * N[Sin[N[(Pi * N[(angle$95$m * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(a * N[Cos[N[(Pi * N[Exp[N[Log[N[(angle$95$m * 0.005555555555555556), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{\left(b \cdot \sin \left(\pi \cdot \left(angle\_m \cdot 0.005555555555555556\right)\right)\right)}^{2} + {\left(a \cdot \cos \left(\pi \cdot e^{\log \left(angle\_m \cdot 0.005555555555555556\right)}\right)\right)}^{2}
\end{array}
Initial program 80.7%
lift-PI.f64N/A
associate-*r/N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6480.6
Applied rewrites80.6%
div-invN/A
metadata-evalN/A
lift-*.f6480.6
Applied rewrites80.6%
lift-PI.f64N/A
lift-*.f64N/A
clear-numN/A
div-invN/A
lift-*.f64N/A
metadata-evalN/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f6480.7
rem-exp-logN/A
lift-*.f64N/A
*-commutativeN/A
log-prodN/A
lift-PI.f64N/A
exp-sumN/A
add-exp-logN/A
lift-PI.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-log.f6440.9
Applied rewrites40.9%
Final simplification40.9%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (+ (pow (* a (cos (pow (* (sqrt (* angle_m 0.005555555555555556)) (sqrt PI)) 2.0))) 2.0) (pow (* b (sin (* PI (/ angle_m 180.0)))) 2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow((a * cos(pow((sqrt((angle_m * 0.005555555555555556)) * sqrt(((double) M_PI))), 2.0))), 2.0) + pow((b * sin((((double) M_PI) * (angle_m / 180.0)))), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow((a * Math.cos(Math.pow((Math.sqrt((angle_m * 0.005555555555555556)) * Math.sqrt(Math.PI)), 2.0))), 2.0) + Math.pow((b * Math.sin((Math.PI * (angle_m / 180.0)))), 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow((a * math.cos(math.pow((math.sqrt((angle_m * 0.005555555555555556)) * math.sqrt(math.pi)), 2.0))), 2.0) + math.pow((b * math.sin((math.pi * (angle_m / 180.0)))), 2.0)
angle_m = abs(angle) function code(a, b, angle_m) return Float64((Float64(a * cos((Float64(sqrt(Float64(angle_m * 0.005555555555555556)) * sqrt(pi)) ^ 2.0))) ^ 2.0) + (Float64(b * sin(Float64(pi * Float64(angle_m / 180.0)))) ^ 2.0)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = ((a * cos(((sqrt((angle_m * 0.005555555555555556)) * sqrt(pi)) ^ 2.0))) ^ 2.0) + ((b * sin((pi * (angle_m / 180.0)))) ^ 2.0); end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[N[(a * N[Cos[N[Power[N[(N[Sqrt[N[(angle$95$m * 0.005555555555555556), $MachinePrecision]], $MachinePrecision] * N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle$95$m / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{\left(a \cdot \cos \left({\left(\sqrt{angle\_m \cdot 0.005555555555555556} \cdot \sqrt{\pi}\right)}^{2}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle\_m}{180}\right)\right)}^{2}
\end{array}
Initial program 80.7%
lift-PI.f64N/A
associate-*r/N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6480.6
Applied rewrites80.6%
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
/-rgt-identityN/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
Applied rewrites40.9%
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unpow1N/A
metadata-evalN/A
pow-powN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lift-*.f64N/A
*-commutativeN/A
unpow-prod-downN/A
lower-*.f64N/A
unpow1/2N/A
lower-sqrt.f64N/A
pow1/2N/A
lower-sqrt.f6440.9
Applied rewrites40.9%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (let* ((t_0 (* PI (* angle_m 0.005555555555555556))) (t_1 (sqrt t_0))) (+ (pow (* b (sin t_0)) 2.0) (pow (* a (cos (* t_1 t_1))) 2.0))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double t_0 = ((double) M_PI) * (angle_m * 0.005555555555555556);
double t_1 = sqrt(t_0);
return pow((b * sin(t_0)), 2.0) + pow((a * cos((t_1 * t_1))), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double t_0 = Math.PI * (angle_m * 0.005555555555555556);
double t_1 = Math.sqrt(t_0);
return Math.pow((b * Math.sin(t_0)), 2.0) + Math.pow((a * Math.cos((t_1 * t_1))), 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): t_0 = math.pi * (angle_m * 0.005555555555555556) t_1 = math.sqrt(t_0) return math.pow((b * math.sin(t_0)), 2.0) + math.pow((a * math.cos((t_1 * t_1))), 2.0)
angle_m = abs(angle) function code(a, b, angle_m) t_0 = Float64(pi * Float64(angle_m * 0.005555555555555556)) t_1 = sqrt(t_0) return Float64((Float64(b * sin(t_0)) ^ 2.0) + (Float64(a * cos(Float64(t_1 * t_1))) ^ 2.0)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) t_0 = pi * (angle_m * 0.005555555555555556); t_1 = sqrt(t_0); tmp = ((b * sin(t_0)) ^ 2.0) + ((a * cos((t_1 * t_1))) ^ 2.0); end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := Block[{t$95$0 = N[(Pi * N[(angle$95$m * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, N[(N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(a * N[Cos[N[(t$95$1 * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
t_0 := \pi \cdot \left(angle\_m \cdot 0.005555555555555556\right)\\
t_1 := \sqrt{t\_0}\\
{\left(b \cdot \sin t\_0\right)}^{2} + {\left(a \cdot \cos \left(t\_1 \cdot t\_1\right)\right)}^{2}
\end{array}
\end{array}
Initial program 80.7%
lift-PI.f64N/A
associate-*r/N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6480.6
Applied rewrites80.6%
div-invN/A
metadata-evalN/A
lift-*.f6480.6
Applied rewrites80.6%
lift-PI.f64N/A
lift-*.f64N/A
clear-numN/A
div-invN/A
lift-*.f64N/A
metadata-evalN/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f6480.7
unpow1N/A
metadata-evalN/A
pow-powN/A
lift-pow.f64N/A
unpow2N/A
lower-*.f6440.9
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6440.9
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6440.9
Applied rewrites40.9%
Final simplification40.9%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (let* ((t_0 (* PI (/ angle_m 180.0)))) (+ (pow (* b (sin t_0)) 2.0) (pow (* a (cos t_0)) 2.0))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double t_0 = ((double) M_PI) * (angle_m / 180.0);
return pow((b * sin(t_0)), 2.0) + pow((a * cos(t_0)), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double t_0 = Math.PI * (angle_m / 180.0);
return Math.pow((b * Math.sin(t_0)), 2.0) + Math.pow((a * Math.cos(t_0)), 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): t_0 = math.pi * (angle_m / 180.0) return math.pow((b * math.sin(t_0)), 2.0) + math.pow((a * math.cos(t_0)), 2.0)
angle_m = abs(angle) function code(a, b, angle_m) t_0 = Float64(pi * Float64(angle_m / 180.0)) return Float64((Float64(b * sin(t_0)) ^ 2.0) + (Float64(a * cos(t_0)) ^ 2.0)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) t_0 = pi * (angle_m / 180.0); tmp = ((b * sin(t_0)) ^ 2.0) + ((a * cos(t_0)) ^ 2.0); end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := Block[{t$95$0 = N[(Pi * N[(angle$95$m / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle\_m}{180}\\
{\left(b \cdot \sin t\_0\right)}^{2} + {\left(a \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
Initial program 80.7%
Final simplification80.7%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (+ (pow (* b (sin (* PI (/ angle_m 180.0)))) 2.0) (* a a)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow((b * sin((((double) M_PI) * (angle_m / 180.0)))), 2.0) + (a * a);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow((b * Math.sin((Math.PI * (angle_m / 180.0)))), 2.0) + (a * a);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow((b * math.sin((math.pi * (angle_m / 180.0)))), 2.0) + (a * a)
angle_m = abs(angle) function code(a, b, angle_m) return Float64((Float64(b * sin(Float64(pi * Float64(angle_m / 180.0)))) ^ 2.0) + Float64(a * a)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = ((b * sin((pi * (angle_m / 180.0)))) ^ 2.0) + (a * a); end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[N[(b * N[Sin[N[(Pi * N[(angle$95$m / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{\left(b \cdot \sin \left(\pi \cdot \frac{angle\_m}{180}\right)\right)}^{2} + a \cdot a
\end{array}
Initial program 80.7%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6480.6
Applied rewrites80.6%
Final simplification80.6%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (+ (pow (* b (sin (* PI (* angle_m 0.005555555555555556)))) 2.0) (* a a)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow((b * sin((((double) M_PI) * (angle_m * 0.005555555555555556)))), 2.0) + (a * a);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow((b * Math.sin((Math.PI * (angle_m * 0.005555555555555556)))), 2.0) + (a * a);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow((b * math.sin((math.pi * (angle_m * 0.005555555555555556)))), 2.0) + (a * a)
angle_m = abs(angle) function code(a, b, angle_m) return Float64((Float64(b * sin(Float64(pi * Float64(angle_m * 0.005555555555555556)))) ^ 2.0) + Float64(a * a)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = ((b * sin((pi * (angle_m * 0.005555555555555556)))) ^ 2.0) + (a * a); end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[N[(b * N[Sin[N[(Pi * N[(angle$95$m * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{\left(b \cdot \sin \left(\pi \cdot \left(angle\_m \cdot 0.005555555555555556\right)\right)\right)}^{2} + a \cdot a
\end{array}
Initial program 80.7%
lift-PI.f64N/A
associate-*r/N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6480.6
Applied rewrites80.6%
div-invN/A
metadata-evalN/A
lift-*.f6480.6
Applied rewrites80.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6480.6
Applied rewrites80.6%
Final simplification80.6%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= b 1.55e-28)
(* a a)
(if (<= b 1.55e+169)
(fma
(* angle_m angle_m)
(* PI (* PI (* (* b b) 3.08641975308642e-5)))
(* a a))
(* angle_m (* (* angle_m b) (* 3.08641975308642e-5 (* b (* PI PI))))))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (b <= 1.55e-28) {
tmp = a * a;
} else if (b <= 1.55e+169) {
tmp = fma((angle_m * angle_m), (((double) M_PI) * (((double) M_PI) * ((b * b) * 3.08641975308642e-5))), (a * a));
} else {
tmp = angle_m * ((angle_m * b) * (3.08641975308642e-5 * (b * (((double) M_PI) * ((double) M_PI)))));
}
return tmp;
}
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (b <= 1.55e-28) tmp = Float64(a * a); elseif (b <= 1.55e+169) tmp = fma(Float64(angle_m * angle_m), Float64(pi * Float64(pi * Float64(Float64(b * b) * 3.08641975308642e-5))), Float64(a * a)); else tmp = Float64(angle_m * Float64(Float64(angle_m * b) * Float64(3.08641975308642e-5 * Float64(b * Float64(pi * pi))))); end return tmp end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[b, 1.55e-28], N[(a * a), $MachinePrecision], If[LessEqual[b, 1.55e+169], N[(N[(angle$95$m * angle$95$m), $MachinePrecision] * N[(Pi * N[(Pi * N[(N[(b * b), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(angle$95$m * N[(N[(angle$95$m * b), $MachinePrecision] * N[(3.08641975308642e-5 * N[(b * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.55 \cdot 10^{-28}:\\
\;\;\;\;a \cdot a\\
\mathbf{elif}\;b \leq 1.55 \cdot 10^{+169}:\\
\;\;\;\;\mathsf{fma}\left(angle\_m \cdot angle\_m, \pi \cdot \left(\pi \cdot \left(\left(b \cdot b\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right), a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;angle\_m \cdot \left(\left(angle\_m \cdot b\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\
\end{array}
\end{array}
if b < 1.54999999999999996e-28Initial program 80.3%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6463.7
Applied rewrites63.7%
if 1.54999999999999996e-28 < b < 1.55e169Initial program 69.7%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites36.0%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6461.8
Applied rewrites61.8%
if 1.55e169 < b Initial program 99.8%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites59.6%
Taylor expanded in b around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f6474.5
Applied rewrites74.5%
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.3%
Final simplification66.1%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (if (<= b 1.05e+170) (* a a) (* angle_m (* (* angle_m b) (* 3.08641975308642e-5 (* b (* PI PI)))))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (b <= 1.05e+170) {
tmp = a * a;
} else {
tmp = angle_m * ((angle_m * b) * (3.08641975308642e-5 * (b * (((double) M_PI) * ((double) M_PI)))));
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (b <= 1.05e+170) {
tmp = a * a;
} else {
tmp = angle_m * ((angle_m * b) * (3.08641975308642e-5 * (b * (Math.PI * Math.PI))));
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if b <= 1.05e+170: tmp = a * a else: tmp = angle_m * ((angle_m * b) * (3.08641975308642e-5 * (b * (math.pi * math.pi)))) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (b <= 1.05e+170) tmp = Float64(a * a); else tmp = Float64(angle_m * Float64(Float64(angle_m * b) * Float64(3.08641975308642e-5 * Float64(b * Float64(pi * pi))))); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (b <= 1.05e+170) tmp = a * a; else tmp = angle_m * ((angle_m * b) * (3.08641975308642e-5 * (b * (pi * pi)))); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[b, 1.05e+170], N[(a * a), $MachinePrecision], N[(angle$95$m * N[(N[(angle$95$m * b), $MachinePrecision] * N[(3.08641975308642e-5 * N[(b * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.05 \cdot 10^{+170}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;angle\_m \cdot \left(\left(angle\_m \cdot b\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\
\end{array}
\end{array}
if b < 1.04999999999999999e170Initial program 78.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6461.1
Applied rewrites61.1%
if 1.04999999999999999e170 < b Initial program 99.8%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites59.6%
Taylor expanded in b around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f6474.5
Applied rewrites74.5%
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.3%
Final simplification64.1%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (if (<= b 1.16e+170) (* a a) (* b (* (* angle_m angle_m) (* 3.08641975308642e-5 (* b (* PI PI)))))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (b <= 1.16e+170) {
tmp = a * a;
} else {
tmp = b * ((angle_m * angle_m) * (3.08641975308642e-5 * (b * (((double) M_PI) * ((double) M_PI)))));
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (b <= 1.16e+170) {
tmp = a * a;
} else {
tmp = b * ((angle_m * angle_m) * (3.08641975308642e-5 * (b * (Math.PI * Math.PI))));
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if b <= 1.16e+170: tmp = a * a else: tmp = b * ((angle_m * angle_m) * (3.08641975308642e-5 * (b * (math.pi * math.pi)))) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (b <= 1.16e+170) tmp = Float64(a * a); else tmp = Float64(b * Float64(Float64(angle_m * angle_m) * Float64(3.08641975308642e-5 * Float64(b * Float64(pi * pi))))); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (b <= 1.16e+170) tmp = a * a; else tmp = b * ((angle_m * angle_m) * (3.08641975308642e-5 * (b * (pi * pi)))); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[b, 1.16e+170], N[(a * a), $MachinePrecision], N[(b * N[(N[(angle$95$m * angle$95$m), $MachinePrecision] * N[(3.08641975308642e-5 * N[(b * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.16 \cdot 10^{+170}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\left(angle\_m \cdot angle\_m\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\
\end{array}
\end{array}
if b < 1.16e170Initial program 78.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6461.1
Applied rewrites61.1%
if 1.16e170 < b Initial program 99.8%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites59.6%
Taylor expanded in b around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-PI.f6474.5
Applied rewrites74.5%
lift-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites82.1%
Final simplification63.3%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (* a a))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return a * a;
}
angle_m = abs(angle)
real(8) function code(a, b, angle_m)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle_m
code = a * a
end function
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return a * a;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return a * a
angle_m = abs(angle) function code(a, b, angle_m) return Float64(a * a) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = a * a; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(a * a), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
a \cdot a
\end{array}
Initial program 80.7%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.0
Applied rewrites57.0%
herbie shell --seed 2024220
(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)))