
(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
(+
(pow
(* (sin (* (* (* (sqrt PI) angle) 0.005555555555555556) (sqrt PI))) b)
2.0)
(pow
(*
(cos
(*
(/ angle 180.0)
(* (pow PI 0.16666666666666666) (pow (pow PI 0.4166666666666667) 2.0))))
a)
2.0)))
double code(double a, double b, double angle) {
return pow((sin((((sqrt(((double) M_PI)) * angle) * 0.005555555555555556) * sqrt(((double) M_PI)))) * b), 2.0) + pow((cos(((angle / 180.0) * (pow(((double) M_PI), 0.16666666666666666) * pow(pow(((double) M_PI), 0.4166666666666667), 2.0)))) * a), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((Math.sin((((Math.sqrt(Math.PI) * angle) * 0.005555555555555556) * Math.sqrt(Math.PI))) * b), 2.0) + Math.pow((Math.cos(((angle / 180.0) * (Math.pow(Math.PI, 0.16666666666666666) * Math.pow(Math.pow(Math.PI, 0.4166666666666667), 2.0)))) * a), 2.0);
}
def code(a, b, angle): return math.pow((math.sin((((math.sqrt(math.pi) * angle) * 0.005555555555555556) * math.sqrt(math.pi))) * b), 2.0) + math.pow((math.cos(((angle / 180.0) * (math.pow(math.pi, 0.16666666666666666) * math.pow(math.pow(math.pi, 0.4166666666666667), 2.0)))) * a), 2.0)
function code(a, b, angle) return Float64((Float64(sin(Float64(Float64(Float64(sqrt(pi) * angle) * 0.005555555555555556) * sqrt(pi))) * b) ^ 2.0) + (Float64(cos(Float64(Float64(angle / 180.0) * Float64((pi ^ 0.16666666666666666) * ((pi ^ 0.4166666666666667) ^ 2.0)))) * a) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((sin((((sqrt(pi) * angle) * 0.005555555555555556) * sqrt(pi))) * b) ^ 2.0) + ((cos(((angle / 180.0) * ((pi ^ 0.16666666666666666) * ((pi ^ 0.4166666666666667) ^ 2.0)))) * a) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(N[Sin[N[(N[(N[(N[Sqrt[Pi], $MachinePrecision] * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision] * N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * b), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(N[Cos[N[(N[(angle / 180.0), $MachinePrecision] * N[(N[Power[Pi, 0.16666666666666666], $MachinePrecision] * N[Power[N[Power[Pi, 0.4166666666666667], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\sin \left(\left(\left(\sqrt{\pi} \cdot angle\right) \cdot 0.005555555555555556\right) \cdot \sqrt{\pi}\right) \cdot b\right)}^{2} + {\left(\cos \left(\frac{angle}{180} \cdot \left({\pi}^{0.16666666666666666} \cdot {\left({\pi}^{0.4166666666666667}\right)}^{2}\right)\right) \cdot a\right)}^{2}
\end{array}
Initial program 79.8%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
div-invN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6479.8
Applied rewrites79.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
frac-timesN/A
lift-/.f64N/A
clear-numN/A
associate-*r/N/A
div-invN/A
times-fracN/A
Applied rewrites79.8%
unpow1N/A
metadata-evalN/A
pow-powN/A
metadata-evalN/A
metadata-evalN/A
pow-prod-upN/A
metadata-evalN/A
pow1/3N/A
lift-PI.f64N/A
metadata-evalN/A
pow-powN/A
lift-pow.f64N/A
pow2N/A
associate-*r*N/A
unpow-prod-downN/A
lift-pow.f64N/A
pow-powN/A
metadata-evalN/A
lift-pow.f64N/A
lower-*.f64N/A
Applied rewrites79.9%
Final simplification79.9%
(FPCore (a b angle)
:precision binary64
(+
(pow (* (sin (* (/ angle 180.0) PI)) b) 2.0)
(pow
(*
(cos
(*
(/ (pow PI 0.16666666666666666) (/ 1.0 angle))
(* (* (cbrt PI) 0.005555555555555556) (sqrt PI))))
a)
2.0)))
double code(double a, double b, double angle) {
return pow((sin(((angle / 180.0) * ((double) M_PI))) * b), 2.0) + pow((cos(((pow(((double) M_PI), 0.16666666666666666) / (1.0 / angle)) * ((cbrt(((double) M_PI)) * 0.005555555555555556) * sqrt(((double) M_PI))))) * a), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((Math.sin(((angle / 180.0) * Math.PI)) * b), 2.0) + Math.pow((Math.cos(((Math.pow(Math.PI, 0.16666666666666666) / (1.0 / angle)) * ((Math.cbrt(Math.PI) * 0.005555555555555556) * Math.sqrt(Math.PI)))) * a), 2.0);
}
function code(a, b, angle) return Float64((Float64(sin(Float64(Float64(angle / 180.0) * pi)) * b) ^ 2.0) + (Float64(cos(Float64(Float64((pi ^ 0.16666666666666666) / Float64(1.0 / angle)) * Float64(Float64(cbrt(pi) * 0.005555555555555556) * sqrt(pi)))) * a) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision] * b), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(N[Cos[N[(N[(N[Power[Pi, 0.16666666666666666], $MachinePrecision] / N[(1.0 / angle), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Power[Pi, 1/3], $MachinePrecision] * 0.005555555555555556), $MachinePrecision] * N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot b\right)}^{2} + {\left(\cos \left(\frac{{\pi}^{0.16666666666666666}}{\frac{1}{angle}} \cdot \left(\left(\sqrt[3]{\pi} \cdot 0.005555555555555556\right) \cdot \sqrt{\pi}\right)\right) \cdot a\right)}^{2}
\end{array}
Initial program 79.8%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lift-PI.f64N/A
add-sqr-sqrtN/A
div-invN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-/.f6479.8
Applied rewrites79.8%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
lift-/.f64N/A
frac-timesN/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-prodN/A
lift-PI.f64N/A
*-un-lft-identityN/A
add-cube-cbrtN/A
sqrt-prodN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
pow1/2N/A
Applied rewrites79.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6479.8
Applied rewrites79.8%
Final simplification79.8%
(FPCore (a b angle) :precision binary64 (+ (pow (* (cos (* (/ 1.0 (/ 1.0 (* (sqrt PI) angle))) (/ (sqrt PI) 180.0))) a) 2.0) (pow (* (sin (* (/ angle 180.0) PI)) b) 2.0)))
double code(double a, double b, double angle) {
return pow((cos(((1.0 / (1.0 / (sqrt(((double) M_PI)) * angle))) * (sqrt(((double) M_PI)) / 180.0))) * a), 2.0) + pow((sin(((angle / 180.0) * ((double) M_PI))) * b), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((Math.cos(((1.0 / (1.0 / (Math.sqrt(Math.PI) * angle))) * (Math.sqrt(Math.PI) / 180.0))) * a), 2.0) + Math.pow((Math.sin(((angle / 180.0) * Math.PI)) * b), 2.0);
}
def code(a, b, angle): return math.pow((math.cos(((1.0 / (1.0 / (math.sqrt(math.pi) * angle))) * (math.sqrt(math.pi) / 180.0))) * a), 2.0) + math.pow((math.sin(((angle / 180.0) * math.pi)) * b), 2.0)
function code(a, b, angle) return Float64((Float64(cos(Float64(Float64(1.0 / Float64(1.0 / Float64(sqrt(pi) * angle))) * Float64(sqrt(pi) / 180.0))) * a) ^ 2.0) + (Float64(sin(Float64(Float64(angle / 180.0) * pi)) * b) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((cos(((1.0 / (1.0 / (sqrt(pi) * angle))) * (sqrt(pi) / 180.0))) * a) ^ 2.0) + ((sin(((angle / 180.0) * pi)) * b) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(N[Cos[N[(N[(1.0 / N[(1.0 / N[(N[Sqrt[Pi], $MachinePrecision] * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[Pi], $MachinePrecision] / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision] * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\cos \left(\frac{1}{\frac{1}{\sqrt{\pi} \cdot angle}} \cdot \frac{\sqrt{\pi}}{180}\right) \cdot a\right)}^{2} + {\left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot b\right)}^{2}
\end{array}
Initial program 79.8%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lift-PI.f64N/A
add-sqr-sqrtN/A
div-invN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-/.f6479.8
Applied rewrites79.8%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
lift-/.f64N/A
lower-/.f6479.8
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
/-rgt-identityN/A
*-commutativeN/A
lower-*.f6479.8
Applied rewrites79.8%
Final simplification79.8%
(FPCore (a b angle) :precision binary64 (+ (pow (* (cos (* (/ angle 180.0) PI)) a) 2.0) (pow (* (sin (* (* (* (sqrt PI) angle) 0.005555555555555556) (sqrt PI))) b) 2.0)))
double code(double a, double b, double angle) {
return pow((cos(((angle / 180.0) * ((double) M_PI))) * a), 2.0) + pow((sin((((sqrt(((double) M_PI)) * angle) * 0.005555555555555556) * sqrt(((double) M_PI)))) * b), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((Math.cos(((angle / 180.0) * Math.PI)) * a), 2.0) + Math.pow((Math.sin((((Math.sqrt(Math.PI) * angle) * 0.005555555555555556) * Math.sqrt(Math.PI))) * b), 2.0);
}
def code(a, b, angle): return math.pow((math.cos(((angle / 180.0) * math.pi)) * a), 2.0) + math.pow((math.sin((((math.sqrt(math.pi) * angle) * 0.005555555555555556) * math.sqrt(math.pi))) * b), 2.0)
function code(a, b, angle) return Float64((Float64(cos(Float64(Float64(angle / 180.0) * pi)) * a) ^ 2.0) + (Float64(sin(Float64(Float64(Float64(sqrt(pi) * angle) * 0.005555555555555556) * sqrt(pi))) * b) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((cos(((angle / 180.0) * pi)) * a) ^ 2.0) + ((sin((((sqrt(pi) * angle) * 0.005555555555555556) * sqrt(pi))) * b) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(N[Cos[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(N[Sin[N[(N[(N[(N[Sqrt[Pi], $MachinePrecision] * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision] * N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\cos \left(\frac{angle}{180} \cdot \pi\right) \cdot a\right)}^{2} + {\left(\sin \left(\left(\left(\sqrt{\pi} \cdot angle\right) \cdot 0.005555555555555556\right) \cdot \sqrt{\pi}\right) \cdot b\right)}^{2}
\end{array}
Initial program 79.8%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
div-invN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6479.8
Applied rewrites79.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
frac-timesN/A
lift-/.f64N/A
clear-numN/A
associate-*r/N/A
div-invN/A
times-fracN/A
Applied rewrites79.8%
Final simplification79.8%
(FPCore (a b angle) :precision binary64 (+ (* a a) (pow (* (sin (* (* (* (sqrt PI) angle) 0.005555555555555556) (sqrt PI))) b) 2.0)))
double code(double a, double b, double angle) {
return (a * a) + pow((sin((((sqrt(((double) M_PI)) * angle) * 0.005555555555555556) * sqrt(((double) M_PI)))) * b), 2.0);
}
public static double code(double a, double b, double angle) {
return (a * a) + Math.pow((Math.sin((((Math.sqrt(Math.PI) * angle) * 0.005555555555555556) * Math.sqrt(Math.PI))) * b), 2.0);
}
def code(a, b, angle): return (a * a) + math.pow((math.sin((((math.sqrt(math.pi) * angle) * 0.005555555555555556) * math.sqrt(math.pi))) * b), 2.0)
function code(a, b, angle) return Float64(Float64(a * a) + (Float64(sin(Float64(Float64(Float64(sqrt(pi) * angle) * 0.005555555555555556) * sqrt(pi))) * b) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a * a) + ((sin((((sqrt(pi) * angle) * 0.005555555555555556) * sqrt(pi))) * b) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(a * a), $MachinePrecision] + N[Power[N[(N[Sin[N[(N[(N[(N[Sqrt[Pi], $MachinePrecision] * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision] * N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a + {\left(\sin \left(\left(\left(\sqrt{\pi} \cdot angle\right) \cdot 0.005555555555555556\right) \cdot \sqrt{\pi}\right) \cdot b\right)}^{2}
\end{array}
Initial program 79.8%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
div-invN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6479.8
Applied rewrites79.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
frac-timesN/A
lift-/.f64N/A
clear-numN/A
associate-*r/N/A
div-invN/A
times-fracN/A
Applied rewrites79.8%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6479.8
Applied rewrites79.8%
Final simplification79.8%
(FPCore (a b angle) :precision binary64 (+ (pow (* (sin (/ (/ PI 180.0) (/ 1.0 angle))) b) 2.0) (* a a)))
double code(double a, double b, double angle) {
return pow((sin(((((double) M_PI) / 180.0) / (1.0 / angle))) * b), 2.0) + (a * a);
}
public static double code(double a, double b, double angle) {
return Math.pow((Math.sin(((Math.PI / 180.0) / (1.0 / angle))) * b), 2.0) + (a * a);
}
def code(a, b, angle): return math.pow((math.sin(((math.pi / 180.0) / (1.0 / angle))) * b), 2.0) + (a * a)
function code(a, b, angle) return Float64((Float64(sin(Float64(Float64(pi / 180.0) / Float64(1.0 / angle))) * b) ^ 2.0) + Float64(a * a)) end
function tmp = code(a, b, angle) tmp = ((sin(((pi / 180.0) / (1.0 / angle))) * b) ^ 2.0) + (a * a); end
code[a_, b_, angle_] := N[(N[Power[N[(N[Sin[N[(N[(Pi / 180.0), $MachinePrecision] / N[(1.0 / angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * b), $MachinePrecision], 2.0], $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\sin \left(\frac{\frac{\pi}{180}}{\frac{1}{angle}}\right) \cdot b\right)}^{2} + a \cdot a
\end{array}
Initial program 79.8%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
div-invN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6479.8
Applied rewrites79.8%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6479.8
Applied rewrites79.8%
Final simplification79.8%
(FPCore (a b angle) :precision binary64 (+ (* a a) (pow (* (sin (* (/ angle 180.0) PI)) b) 2.0)))
double code(double a, double b, double angle) {
return (a * a) + pow((sin(((angle / 180.0) * ((double) M_PI))) * b), 2.0);
}
public static double code(double a, double b, double angle) {
return (a * a) + Math.pow((Math.sin(((angle / 180.0) * Math.PI)) * b), 2.0);
}
def code(a, b, angle): return (a * a) + math.pow((math.sin(((angle / 180.0) * math.pi)) * b), 2.0)
function code(a, b, angle) return Float64(Float64(a * a) + (Float64(sin(Float64(Float64(angle / 180.0) * pi)) * b) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a * a) + ((sin(((angle / 180.0) * pi)) * b) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(a * a), $MachinePrecision] + N[Power[N[(N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision] * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a + {\left(\sin \left(\frac{angle}{180} \cdot \pi\right) \cdot b\right)}^{2}
\end{array}
Initial program 79.8%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6479.7
Applied rewrites79.7%
Final simplification79.7%
(FPCore (a b angle)
:precision binary64
(if (<= b 1.1e-62)
(* a a)
(if (<= b 6.4e+152)
(fma
(* (* (* (* b b) 3.08641975308642e-5) PI) PI)
(* angle angle)
(* a a))
(* (* PI PI) (* (* (* b angle) (* b angle)) 3.08641975308642e-5)))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.1e-62) {
tmp = a * a;
} else if (b <= 6.4e+152) {
tmp = fma(((((b * b) * 3.08641975308642e-5) * ((double) M_PI)) * ((double) M_PI)), (angle * angle), (a * a));
} else {
tmp = (((double) M_PI) * ((double) M_PI)) * (((b * angle) * (b * angle)) * 3.08641975308642e-5);
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (b <= 1.1e-62) tmp = Float64(a * a); elseif (b <= 6.4e+152) tmp = fma(Float64(Float64(Float64(Float64(b * b) * 3.08641975308642e-5) * pi) * pi), Float64(angle * angle), Float64(a * a)); else tmp = Float64(Float64(pi * pi) * Float64(Float64(Float64(b * angle) * Float64(b * angle)) * 3.08641975308642e-5)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[b, 1.1e-62], N[(a * a), $MachinePrecision], If[LessEqual[b, 6.4e+152], N[(N[(N[(N[(N[(b * b), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision] * Pi), $MachinePrecision] * Pi), $MachinePrecision] * N[(angle * angle), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * Pi), $MachinePrecision] * N[(N[(N[(b * angle), $MachinePrecision] * N[(b * angle), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.1 \cdot 10^{-62}:\\
\;\;\;\;a \cdot a\\
\mathbf{elif}\;b \leq 6.4 \cdot 10^{+152}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\left(b \cdot b\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \pi\right) \cdot \pi, angle \cdot angle, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\pi \cdot \pi\right) \cdot \left(\left(\left(b \cdot angle\right) \cdot \left(b \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\\
\end{array}
\end{array}
if b < 1.10000000000000009e-62Initial program 77.5%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6463.2
Applied rewrites63.2%
if 1.10000000000000009e-62 < b < 6.40000000000000011e152Initial program 69.5%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lift-PI.f64N/A
add-sqr-sqrtN/A
div-invN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-/.f6469.3
Applied rewrites69.3%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites36.7%
Taylor expanded in b around inf
Applied rewrites59.7%
if 6.40000000000000011e152 < b Initial program 99.6%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lift-PI.f64N/A
add-sqr-sqrtN/A
div-invN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-/.f6499.6
Applied rewrites99.6%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites41.6%
Taylor expanded in b around inf
Applied rewrites76.2%
Applied rewrites90.5%
Final simplification67.1%
(FPCore (a b angle) :precision binary64 (if (<= b 9.5e+117) (* a a) (* (* PI PI) (* (* (* b angle) (* b angle)) 3.08641975308642e-5))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 9.5e+117) {
tmp = a * a;
} else {
tmp = (((double) M_PI) * ((double) M_PI)) * (((b * angle) * (b * angle)) * 3.08641975308642e-5);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 9.5e+117) {
tmp = a * a;
} else {
tmp = (Math.PI * Math.PI) * (((b * angle) * (b * angle)) * 3.08641975308642e-5);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 9.5e+117: tmp = a * a else: tmp = (math.pi * math.pi) * (((b * angle) * (b * angle)) * 3.08641975308642e-5) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 9.5e+117) tmp = Float64(a * a); else tmp = Float64(Float64(pi * pi) * Float64(Float64(Float64(b * angle) * Float64(b * angle)) * 3.08641975308642e-5)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 9.5e+117) tmp = a * a; else tmp = (pi * pi) * (((b * angle) * (b * angle)) * 3.08641975308642e-5); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 9.5e+117], N[(a * a), $MachinePrecision], N[(N[(Pi * Pi), $MachinePrecision] * N[(N[(N[(b * angle), $MachinePrecision] * N[(b * angle), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.5 \cdot 10^{+117}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\pi \cdot \pi\right) \cdot \left(\left(\left(b \cdot angle\right) \cdot \left(b \cdot angle\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\\
\end{array}
\end{array}
if b < 9.50000000000000041e117Initial program 75.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6460.8
Applied rewrites60.8%
if 9.50000000000000041e117 < b Initial program 96.3%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lift-PI.f64N/A
add-sqr-sqrtN/A
div-invN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-/.f6496.3
Applied rewrites96.3%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites39.0%
Taylor expanded in b around inf
Applied rewrites69.3%
Applied rewrites85.8%
Final simplification65.5%
(FPCore (a b angle) :precision binary64 (if (<= b 9.5e+117) (* a a) (* (* (* (* (* b angle) b) angle) 3.08641975308642e-5) (* PI PI))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 9.5e+117) {
tmp = a * a;
} else {
tmp = ((((b * angle) * b) * angle) * 3.08641975308642e-5) * (((double) M_PI) * ((double) M_PI));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 9.5e+117) {
tmp = a * a;
} else {
tmp = ((((b * angle) * b) * angle) * 3.08641975308642e-5) * (Math.PI * Math.PI);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 9.5e+117: tmp = a * a else: tmp = ((((b * angle) * b) * angle) * 3.08641975308642e-5) * (math.pi * math.pi) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 9.5e+117) tmp = Float64(a * a); else tmp = Float64(Float64(Float64(Float64(Float64(b * angle) * b) * angle) * 3.08641975308642e-5) * Float64(pi * pi)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 9.5e+117) tmp = a * a; else tmp = ((((b * angle) * b) * angle) * 3.08641975308642e-5) * (pi * pi); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 9.5e+117], N[(a * a), $MachinePrecision], N[(N[(N[(N[(N[(b * angle), $MachinePrecision] * b), $MachinePrecision] * angle), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.5 \cdot 10^{+117}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\left(b \cdot angle\right) \cdot b\right) \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \left(\pi \cdot \pi\right)\\
\end{array}
\end{array}
if b < 9.50000000000000041e117Initial program 75.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6460.8
Applied rewrites60.8%
if 9.50000000000000041e117 < b Initial program 96.3%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lift-PI.f64N/A
add-sqr-sqrtN/A
div-invN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-/.f6496.3
Applied rewrites96.3%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites39.0%
Taylor expanded in b around inf
Applied rewrites69.3%
Applied rewrites76.5%
Final simplification63.8%
(FPCore (a b angle) :precision binary64 (if (<= b 9.5e+117) (* a a) (* (* (* (* (* b b) angle) angle) 3.08641975308642e-5) (* PI PI))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 9.5e+117) {
tmp = a * a;
} else {
tmp = ((((b * b) * angle) * angle) * 3.08641975308642e-5) * (((double) M_PI) * ((double) M_PI));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 9.5e+117) {
tmp = a * a;
} else {
tmp = ((((b * b) * angle) * angle) * 3.08641975308642e-5) * (Math.PI * Math.PI);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 9.5e+117: tmp = a * a else: tmp = ((((b * b) * angle) * angle) * 3.08641975308642e-5) * (math.pi * math.pi) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 9.5e+117) tmp = Float64(a * a); else tmp = Float64(Float64(Float64(Float64(Float64(b * b) * angle) * angle) * 3.08641975308642e-5) * Float64(pi * pi)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 9.5e+117) tmp = a * a; else tmp = ((((b * b) * angle) * angle) * 3.08641975308642e-5) * (pi * pi); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 9.5e+117], N[(a * a), $MachinePrecision], N[(N[(N[(N[(N[(b * b), $MachinePrecision] * angle), $MachinePrecision] * angle), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.5 \cdot 10^{+117}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\left(b \cdot b\right) \cdot angle\right) \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \left(\pi \cdot \pi\right)\\
\end{array}
\end{array}
if b < 9.50000000000000041e117Initial program 75.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6460.8
Applied rewrites60.8%
if 9.50000000000000041e117 < b Initial program 96.3%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lift-PI.f64N/A
add-sqr-sqrtN/A
div-invN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lower-/.f6496.3
Applied rewrites96.3%
Taylor expanded in angle around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites39.0%
Taylor expanded in b around inf
Applied rewrites69.3%
Applied rewrites68.6%
Final simplification62.3%
(FPCore (a b angle) :precision binary64 (* a a))
double code(double a, double b, double angle) {
return a * a;
}
real(8) function code(a, b, angle)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = a * a
end function
public static double code(double a, double b, double angle) {
return a * a;
}
def code(a, b, angle): return a * a
function code(a, b, angle) return Float64(a * a) end
function tmp = code(a, b, angle) tmp = a * a; end
code[a_, b_, angle_] := N[(a * a), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a
\end{array}
Initial program 79.8%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6455.7
Applied rewrites55.7%
herbie shell --seed 2024235
(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)))