
(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 14 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 (* (/ 1.0 (/ 1.0 angle)) (* PI 0.005555555555555556)))) 2.0) (* b b)))
double code(double a, double b, double angle) {
return pow((a * sin(((1.0 / (1.0 / angle)) * (((double) M_PI) * 0.005555555555555556)))), 2.0) + (b * b);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin(((1.0 / (1.0 / angle)) * (Math.PI * 0.005555555555555556)))), 2.0) + (b * b);
}
def code(a, b, angle): return math.pow((a * math.sin(((1.0 / (1.0 / angle)) * (math.pi * 0.005555555555555556)))), 2.0) + (b * b)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(1.0 / Float64(1.0 / angle)) * Float64(pi * 0.005555555555555556)))) ^ 2.0) + Float64(b * b)) end
function tmp = code(a, b, angle) tmp = ((a * sin(((1.0 / (1.0 / angle)) * (pi * 0.005555555555555556)))) ^ 2.0) + (b * b); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(1.0 / N[(1.0 / angle), $MachinePrecision]), $MachinePrecision] * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\frac{1}{\frac{1}{angle}} \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2} + b \cdot b
\end{array}
Initial program 75.3%
Taylor expanded in angle around 0
Simplified75.6%
clear-numN/A
associate-*l/N/A
div-invN/A
*-commutativeN/A
times-fracN/A
div-invN/A
metadata-evalN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6475.6
Applied egg-rr75.6%
*-rgt-identityN/A
pow2N/A
*-lowering-*.f6475.6
Applied egg-rr75.6%
Final simplification75.6%
(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 75.3%
Taylor expanded in angle around 0
Simplified75.6%
*-rgt-identityN/A
pow2N/A
*-lowering-*.f6475.6
Applied egg-rr75.6%
Final simplification75.6%
(FPCore (a b angle)
:precision binary64
(if (<= angle 0.003)
(+ (* b b) (pow (* a (* angle (* PI 0.005555555555555556))) 2.0))
(fma
a
(* a (* (- 1.0 (cos (* 0.011111111111111112 (* PI angle)))) 0.5))
(* b b))))
double code(double a, double b, double angle) {
double tmp;
if (angle <= 0.003) {
tmp = (b * b) + pow((a * (angle * (((double) M_PI) * 0.005555555555555556))), 2.0);
} else {
tmp = fma(a, (a * ((1.0 - cos((0.011111111111111112 * (((double) M_PI) * angle)))) * 0.5)), (b * b));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (angle <= 0.003) tmp = Float64(Float64(b * b) + (Float64(a * Float64(angle * Float64(pi * 0.005555555555555556))) ^ 2.0)); else tmp = fma(a, Float64(a * Float64(Float64(1.0 - cos(Float64(0.011111111111111112 * Float64(pi * angle)))) * 0.5)), Float64(b * b)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[angle, 0.003], N[(N[(b * b), $MachinePrecision] + N[Power[N[(a * N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(a * N[(a * N[(N[(1.0 - N[Cos[N[(0.011111111111111112 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 0.003:\\
\;\;\;\;b \cdot b + {\left(a \cdot \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, a \cdot \left(\left(1 - \cos \left(0.011111111111111112 \cdot \left(\pi \cdot angle\right)\right)\right) \cdot 0.5\right), b \cdot b\right)\\
\end{array}
\end{array}
if angle < 0.0030000000000000001Initial program 83.4%
Taylor expanded in angle around 0
Simplified83.3%
clear-numN/A
associate-*l/N/A
div-invN/A
*-commutativeN/A
times-fracN/A
div-invN/A
metadata-evalN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6483.4
Applied egg-rr83.4%
*-rgt-identityN/A
pow2N/A
*-lowering-*.f6483.4
Applied egg-rr83.4%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6480.6
Simplified80.6%
if 0.0030000000000000001 < angle Initial program 54.1%
Taylor expanded in angle around 0
Simplified55.4%
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sin-multN/A
sqrt-divN/A
/-lowering-/.f64N/A
Applied egg-rr55.3%
unpow-prod-downN/A
pow2N/A
associate-*l*N/A
*-rgt-identityN/A
pow2N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr55.4%
Final simplification73.6%
(FPCore (a b angle)
:precision binary64
(if (<= angle 0.00044)
(+ (* b b) (pow (* a (* angle (* PI 0.005555555555555556))) 2.0))
(fma
(fma (cos (* PI (* angle 0.011111111111111112))) -0.5 0.5)
(* a a)
(* b b))))
double code(double a, double b, double angle) {
double tmp;
if (angle <= 0.00044) {
tmp = (b * b) + pow((a * (angle * (((double) M_PI) * 0.005555555555555556))), 2.0);
} else {
tmp = fma(fma(cos((((double) M_PI) * (angle * 0.011111111111111112))), -0.5, 0.5), (a * a), (b * b));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (angle <= 0.00044) tmp = Float64(Float64(b * b) + (Float64(a * Float64(angle * Float64(pi * 0.005555555555555556))) ^ 2.0)); else tmp = fma(fma(cos(Float64(pi * Float64(angle * 0.011111111111111112))), -0.5, 0.5), Float64(a * a), Float64(b * b)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[angle, 0.00044], N[(N[(b * b), $MachinePrecision] + N[Power[N[(a * N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision] * N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 0.00044:\\
\;\;\;\;b \cdot b + {\left(a \cdot \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\cos \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right), -0.5, 0.5\right), a \cdot a, b \cdot b\right)\\
\end{array}
\end{array}
if angle < 4.40000000000000016e-4Initial program 83.3%
Taylor expanded in angle around 0
Simplified83.4%
clear-numN/A
associate-*l/N/A
div-invN/A
*-commutativeN/A
times-fracN/A
div-invN/A
metadata-evalN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6483.5
Applied egg-rr83.5%
*-rgt-identityN/A
pow2N/A
*-lowering-*.f6483.5
Applied egg-rr83.5%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6480.7
Simplified80.7%
if 4.40000000000000016e-4 < angle Initial program 54.8%
Taylor expanded in angle around 0
Simplified55.6%
pow-prod-downN/A
pow2N/A
sqr-sin-aN/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
Applied egg-rr55.5%
Final simplification73.6%
(FPCore (a b angle)
:precision binary64
(if (<= angle 0.003)
(+ (* b b) (pow (* a (* angle (* PI 0.005555555555555556))) 2.0))
(fma
(* a (fma (cos (* PI (* angle 0.011111111111111112))) -0.5 0.5))
a
(* b b))))
double code(double a, double b, double angle) {
double tmp;
if (angle <= 0.003) {
tmp = (b * b) + pow((a * (angle * (((double) M_PI) * 0.005555555555555556))), 2.0);
} else {
tmp = fma((a * fma(cos((((double) M_PI) * (angle * 0.011111111111111112))), -0.5, 0.5)), a, (b * b));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (angle <= 0.003) tmp = Float64(Float64(b * b) + (Float64(a * Float64(angle * Float64(pi * 0.005555555555555556))) ^ 2.0)); else tmp = fma(Float64(a * fma(cos(Float64(pi * Float64(angle * 0.011111111111111112))), -0.5, 0.5)), a, Float64(b * b)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[angle, 0.003], N[(N[(b * b), $MachinePrecision] + N[Power[N[(a * N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(a * N[(N[Cos[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 0.003:\\
\;\;\;\;b \cdot b + {\left(a \cdot \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot \mathsf{fma}\left(\cos \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right), -0.5, 0.5\right), a, b \cdot b\right)\\
\end{array}
\end{array}
if angle < 0.0030000000000000001Initial program 83.4%
Taylor expanded in angle around 0
Simplified83.3%
clear-numN/A
associate-*l/N/A
div-invN/A
*-commutativeN/A
times-fracN/A
div-invN/A
metadata-evalN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6483.4
Applied egg-rr83.4%
*-rgt-identityN/A
pow2N/A
*-lowering-*.f6483.4
Applied egg-rr83.4%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6480.6
Simplified80.6%
if 0.0030000000000000001 < angle Initial program 54.1%
Taylor expanded in angle around 0
Simplified55.4%
Applied egg-rr55.3%
Final simplification73.6%
(FPCore (a b angle) :precision binary64 (if (<= a 1.32e+20) (* b b) (+ (* b b) (pow (* a (* angle (* PI 0.005555555555555556))) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.32e+20) {
tmp = b * b;
} else {
tmp = (b * b) + pow((a * (angle * (((double) M_PI) * 0.005555555555555556))), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.32e+20) {
tmp = b * b;
} else {
tmp = (b * b) + Math.pow((a * (angle * (Math.PI * 0.005555555555555556))), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.32e+20: tmp = b * b else: tmp = (b * b) + math.pow((a * (angle * (math.pi * 0.005555555555555556))), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.32e+20) tmp = Float64(b * b); else tmp = Float64(Float64(b * b) + (Float64(a * Float64(angle * Float64(pi * 0.005555555555555556))) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.32e+20) tmp = b * b; else tmp = (b * b) + ((a * (angle * (pi * 0.005555555555555556))) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.32e+20], N[(b * b), $MachinePrecision], N[(N[(b * b), $MachinePrecision] + N[Power[N[(a * N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.32 \cdot 10^{+20}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;b \cdot b + {\left(a \cdot \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 1.32e20Initial program 70.8%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6457.6
Simplified57.6%
if 1.32e20 < a Initial program 86.9%
Taylor expanded in angle around 0
Simplified86.9%
clear-numN/A
associate-*l/N/A
div-invN/A
*-commutativeN/A
times-fracN/A
div-invN/A
metadata-evalN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6487.1
Applied egg-rr87.1%
*-rgt-identityN/A
pow2N/A
*-lowering-*.f6487.1
Applied egg-rr87.1%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f6484.1
Simplified84.1%
Final simplification65.0%
(FPCore (a b angle)
:precision binary64
(if (<= a 8e+18)
(* b b)
(fma
(* (* a angle) (* (* angle 3.08641975308642e-5) (* PI PI)))
a
(* b b))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 8e+18) {
tmp = b * b;
} else {
tmp = fma(((a * angle) * ((angle * 3.08641975308642e-5) * (((double) M_PI) * ((double) M_PI)))), a, (b * b));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 8e+18) tmp = Float64(b * b); else tmp = fma(Float64(Float64(a * angle) * Float64(Float64(angle * 3.08641975308642e-5) * Float64(pi * pi))), a, Float64(b * b)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 8e+18], N[(b * b), $MachinePrecision], N[(N[(N[(a * angle), $MachinePrecision] * N[(N[(angle * 3.08641975308642e-5), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 8 \cdot 10^{+18}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(a \cdot angle\right) \cdot \left(\left(angle \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \left(\pi \cdot \pi\right)\right), a, b \cdot b\right)\\
\end{array}
\end{array}
if a < 8e18Initial program 70.8%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6457.6
Simplified57.6%
if 8e18 < a Initial program 86.9%
Taylor expanded in angle around 0
Simplified86.9%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
Simplified57.4%
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
associate-*l*N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f6480.2
Applied egg-rr80.2%
(FPCore (a b angle)
:precision binary64
(if (<= a 1.02e+19)
(* b b)
(fma
(* PI (* PI 3.08641975308642e-5))
(* a (* a (* angle angle)))
(* b b))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.02e+19) {
tmp = b * b;
} else {
tmp = fma((((double) M_PI) * (((double) M_PI) * 3.08641975308642e-5)), (a * (a * (angle * angle))), (b * b));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 1.02e+19) tmp = Float64(b * b); else tmp = fma(Float64(pi * Float64(pi * 3.08641975308642e-5)), Float64(a * Float64(a * Float64(angle * angle))), Float64(b * b)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 1.02e+19], N[(b * b), $MachinePrecision], N[(N[(Pi * N[(Pi * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision] * N[(a * N[(a * N[(angle * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.02 \cdot 10^{+19}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\pi \cdot \left(\pi \cdot 3.08641975308642 \cdot 10^{-5}\right), a \cdot \left(a \cdot \left(angle \cdot angle\right)\right), b \cdot b\right)\\
\end{array}
\end{array}
if a < 1.02e19Initial program 70.8%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6457.6
Simplified57.6%
if 1.02e19 < a Initial program 86.9%
Taylor expanded in angle around 0
Simplified86.9%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
Simplified57.4%
associate-*r*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6473.9
Applied egg-rr73.9%
(FPCore (a b angle) :precision binary64 (if (<= a 1.8e+174) (fma angle (* (* a a) (* (* angle 3.08641975308642e-5) (* PI PI))) (* b b)) (* a (* (* a angle) (* 3.08641975308642e-5 (* angle (* PI PI)))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.8e+174) {
tmp = fma(angle, ((a * a) * ((angle * 3.08641975308642e-5) * (((double) M_PI) * ((double) M_PI)))), (b * b));
} else {
tmp = a * ((a * angle) * (3.08641975308642e-5 * (angle * (((double) M_PI) * ((double) M_PI)))));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 1.8e+174) tmp = fma(angle, Float64(Float64(a * a) * Float64(Float64(angle * 3.08641975308642e-5) * Float64(pi * pi))), Float64(b * b)); else tmp = Float64(a * Float64(Float64(a * angle) * Float64(3.08641975308642e-5 * Float64(angle * Float64(pi * pi))))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 1.8e+174], N[(angle * N[(N[(a * a), $MachinePrecision] * N[(N[(angle * 3.08641975308642e-5), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], N[(a * N[(N[(a * angle), $MachinePrecision] * N[(3.08641975308642e-5 * N[(angle * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.8 \cdot 10^{+174}:\\
\;\;\;\;\mathsf{fma}\left(angle, \left(a \cdot a\right) \cdot \left(\left(angle \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \left(\pi \cdot \pi\right)\right), b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(\left(a \cdot angle\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.8000000000000001e174Initial program 71.6%
Taylor expanded in angle around 0
Simplified71.9%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
Simplified56.5%
*-commutativeN/A
associate-*l*N/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6463.9
Applied egg-rr63.9%
if 1.8000000000000001e174 < a Initial program 99.6%
Taylor expanded in angle around 0
Simplified99.6%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
Simplified51.0%
Taylor expanded in a around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6451.0
Simplified51.0%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6472.0
Applied egg-rr72.0%
Final simplification65.0%
(FPCore (a b angle) :precision binary64 (if (<= a 1.5e+181) (* b b) (* a (* (* a angle) (* 3.08641975308642e-5 (* angle (* PI PI)))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.5e+181) {
tmp = b * b;
} else {
tmp = a * ((a * angle) * (3.08641975308642e-5 * (angle * (((double) M_PI) * ((double) M_PI)))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.5e+181) {
tmp = b * b;
} else {
tmp = a * ((a * angle) * (3.08641975308642e-5 * (angle * (Math.PI * Math.PI))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.5e+181: tmp = b * b else: tmp = a * ((a * angle) * (3.08641975308642e-5 * (angle * (math.pi * math.pi)))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.5e+181) tmp = Float64(b * b); else tmp = Float64(a * Float64(Float64(a * angle) * Float64(3.08641975308642e-5 * Float64(angle * Float64(pi * pi))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.5e+181) tmp = b * b; else tmp = a * ((a * angle) * (3.08641975308642e-5 * (angle * (pi * pi)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.5e+181], N[(b * b), $MachinePrecision], N[(a * N[(N[(a * angle), $MachinePrecision] * N[(3.08641975308642e-5 * N[(angle * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.5 \cdot 10^{+181}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(\left(a \cdot angle\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.50000000000000006e181Initial program 71.7%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6456.3
Simplified56.3%
if 1.50000000000000006e181 < a Initial program 99.6%
Taylor expanded in angle around 0
Simplified99.6%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
Simplified52.6%
Taylor expanded in a around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6452.6
Simplified52.6%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6474.0
Applied egg-rr74.0%
Final simplification58.6%
(FPCore (a b angle) :precision binary64 (if (<= a 1.5e+181) (* b b) (* (* a (* a (* angle angle))) (* 3.08641975308642e-5 (* PI PI)))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.5e+181) {
tmp = b * b;
} else {
tmp = (a * (a * (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 (a <= 1.5e+181) {
tmp = b * b;
} else {
tmp = (a * (a * (angle * angle))) * (3.08641975308642e-5 * (Math.PI * Math.PI));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.5e+181: tmp = b * b else: tmp = (a * (a * (angle * angle))) * (3.08641975308642e-5 * (math.pi * math.pi)) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.5e+181) tmp = Float64(b * b); else tmp = Float64(Float64(a * Float64(a * Float64(angle * angle))) * Float64(3.08641975308642e-5 * Float64(pi * pi))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.5e+181) tmp = b * b; else tmp = (a * (a * (angle * angle))) * (3.08641975308642e-5 * (pi * pi)); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.5e+181], N[(b * b), $MachinePrecision], N[(N[(a * N[(a * N[(angle * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(3.08641975308642e-5 * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.5 \cdot 10^{+181}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot \left(a \cdot \left(angle \cdot angle\right)\right)\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \pi\right)\right)\\
\end{array}
\end{array}
if a < 1.50000000000000006e181Initial program 71.7%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6456.3
Simplified56.3%
if 1.50000000000000006e181 < a Initial program 99.6%
Taylor expanded in angle around 0
Simplified99.6%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
Simplified52.6%
Taylor expanded in a around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6452.6
Simplified52.6%
Taylor expanded in a around 0
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-lowering-*.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6460.8
Simplified60.8%
Final simplification56.9%
(FPCore (a b angle) :precision binary64 (if (<= a 1.25e+115) (* b b) (* (* a a) (* angle (* (* angle 3.08641975308642e-5) (* PI PI))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.25e+115) {
tmp = b * b;
} else {
tmp = (a * a) * (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 (a <= 1.25e+115) {
tmp = b * b;
} else {
tmp = (a * a) * (angle * ((angle * 3.08641975308642e-5) * (Math.PI * Math.PI)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.25e+115: tmp = b * b else: tmp = (a * a) * (angle * ((angle * 3.08641975308642e-5) * (math.pi * math.pi))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.25e+115) tmp = Float64(b * b); else tmp = Float64(Float64(a * a) * Float64(angle * Float64(Float64(angle * 3.08641975308642e-5) * Float64(pi * pi)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.25e+115) tmp = b * b; else tmp = (a * a) * (angle * ((angle * 3.08641975308642e-5) * (pi * pi))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.25e+115], N[(b * b), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * N[(angle * N[(N[(angle * 3.08641975308642e-5), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.25 \cdot 10^{+115}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(angle \cdot \left(\left(angle \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.25000000000000002e115Initial program 70.8%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6456.9
Simplified56.9%
if 1.25000000000000002e115 < a Initial program 94.6%
Taylor expanded in angle around 0
Simplified94.6%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
Simplified55.4%
Taylor expanded in a around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6453.3
Simplified53.3%
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f6453.4
Applied egg-rr53.4%
Final simplification56.2%
(FPCore (a b angle) :precision binary64 (if (<= a 1.22e+117) (* b b) (* (* a a) (* angle (* angle (* 3.08641975308642e-5 (* PI PI)))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.22e+117) {
tmp = b * b;
} else {
tmp = (a * a) * (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 (a <= 1.22e+117) {
tmp = b * b;
} else {
tmp = (a * a) * (angle * (angle * (3.08641975308642e-5 * (Math.PI * Math.PI))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.22e+117: tmp = b * b else: tmp = (a * a) * (angle * (angle * (3.08641975308642e-5 * (math.pi * math.pi)))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.22e+117) tmp = Float64(b * b); else tmp = Float64(Float64(a * a) * Float64(angle * Float64(angle * Float64(3.08641975308642e-5 * Float64(pi * pi))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.22e+117) tmp = b * b; else tmp = (a * a) * (angle * (angle * (3.08641975308642e-5 * (pi * pi)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.22e+117], N[(b * b), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * N[(angle * N[(angle * N[(3.08641975308642e-5 * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.22 \cdot 10^{+117}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(angle \cdot \left(angle \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \pi\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.22000000000000004e117Initial program 70.8%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6456.9
Simplified56.9%
if 1.22000000000000004e117 < a Initial program 94.6%
Taylor expanded in angle around 0
Simplified94.6%
Taylor expanded in angle around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
Simplified55.4%
Taylor expanded in a around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
PI-lowering-PI.f6453.3
Simplified53.3%
(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 75.3%
Taylor expanded in angle around 0
unpow2N/A
*-lowering-*.f6452.9
Simplified52.9%
herbie shell --seed 2024197
(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)))