
(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 13 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 (* a (cos (* -0.005555555555555556 (* (* angle (sqrt PI)) (sqrt PI))))) 2.0) (pow (* b (sin (* (* 0.005555555555555556 PI) angle))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * cos((-0.005555555555555556 * ((angle * sqrt(((double) M_PI))) * sqrt(((double) M_PI)))))), 2.0) + pow((b * sin(((0.005555555555555556 * ((double) M_PI)) * angle))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.cos((-0.005555555555555556 * ((angle * Math.sqrt(Math.PI)) * Math.sqrt(Math.PI))))), 2.0) + Math.pow((b * Math.sin(((0.005555555555555556 * Math.PI) * angle))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.cos((-0.005555555555555556 * ((angle * math.sqrt(math.pi)) * math.sqrt(math.pi))))), 2.0) + math.pow((b * math.sin(((0.005555555555555556 * math.pi) * angle))), 2.0)
function code(a, b, angle) return Float64((Float64(a * cos(Float64(-0.005555555555555556 * Float64(Float64(angle * sqrt(pi)) * sqrt(pi))))) ^ 2.0) + (Float64(b * sin(Float64(Float64(0.005555555555555556 * pi) * angle))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * cos((-0.005555555555555556 * ((angle * sqrt(pi)) * sqrt(pi))))) ^ 2.0) + ((b * sin(((0.005555555555555556 * pi) * angle))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Cos[N[(-0.005555555555555556 * N[(N[(angle * N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(N[(0.005555555555555556 * Pi), $MachinePrecision] * angle), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \cos \left(-0.005555555555555556 \cdot \left(\left(angle \cdot \sqrt{\pi}\right) \cdot \sqrt{\pi}\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\left(0.005555555555555556 \cdot \pi\right) \cdot angle\right)\right)}^{2}
\end{array}
Initial program 78.0%
Taylor expanded in angle around 0
Applied rewrites78.1%
Taylor expanded in angle around inf
Applied rewrites78.1%
Applied rewrites78.1%
(FPCore (a b angle) :precision binary64 (if (<= b 1.45e-54) (* (* (pow (cos (* -0.005555555555555556 (* PI angle))) 2.0) a) a) (+ (* a a) (pow (* (* (* b PI) angle) 0.005555555555555556) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.45e-54) {
tmp = (pow(cos((-0.005555555555555556 * (((double) M_PI) * angle))), 2.0) * a) * a;
} else {
tmp = (a * a) + pow((((b * ((double) M_PI)) * angle) * 0.005555555555555556), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 1.45e-54) {
tmp = (Math.pow(Math.cos((-0.005555555555555556 * (Math.PI * angle))), 2.0) * a) * a;
} else {
tmp = (a * a) + Math.pow((((b * Math.PI) * angle) * 0.005555555555555556), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 1.45e-54: tmp = (math.pow(math.cos((-0.005555555555555556 * (math.pi * angle))), 2.0) * a) * a else: tmp = (a * a) + math.pow((((b * math.pi) * angle) * 0.005555555555555556), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 1.45e-54) tmp = Float64(Float64((cos(Float64(-0.005555555555555556 * Float64(pi * angle))) ^ 2.0) * a) * a); else tmp = Float64(Float64(a * a) + (Float64(Float64(Float64(b * pi) * angle) * 0.005555555555555556) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 1.45e-54) tmp = ((cos((-0.005555555555555556 * (pi * angle))) ^ 2.0) * a) * a; else tmp = (a * a) + ((((b * pi) * angle) * 0.005555555555555556) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 1.45e-54], N[(N[(N[Power[N[Cos[N[(-0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[Power[N[(N[(N[(b * Pi), $MachinePrecision] * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.45 \cdot 10^{-54}:\\
\;\;\;\;\left({\cos \left(-0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right)}^{2} \cdot a\right) \cdot a\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + {\left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot 0.005555555555555556\right)}^{2}\\
\end{array}
\end{array}
if b < 1.45000000000000007e-54Initial program 73.4%
Taylor expanded in a around inf
Applied rewrites59.9%
Applied rewrites67.9%
Taylor expanded in a around inf
Applied rewrites54.2%
if 1.45000000000000007e-54 < b Initial program 88.1%
Taylor expanded in angle around 0
Applied rewrites88.2%
Taylor expanded in angle around 0
Applied rewrites88.4%
Taylor expanded in angle around 0
Applied rewrites86.0%
Final simplification64.1%
(FPCore (a b angle) :precision binary64 (if (<= b 1.45e-54) (* (pow (cos (* -0.005555555555555556 (* PI angle))) 2.0) (* a a)) (+ (* a a) (pow (* (* (* b PI) angle) 0.005555555555555556) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.45e-54) {
tmp = pow(cos((-0.005555555555555556 * (((double) M_PI) * angle))), 2.0) * (a * a);
} else {
tmp = (a * a) + pow((((b * ((double) M_PI)) * angle) * 0.005555555555555556), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 1.45e-54) {
tmp = Math.pow(Math.cos((-0.005555555555555556 * (Math.PI * angle))), 2.0) * (a * a);
} else {
tmp = (a * a) + Math.pow((((b * Math.PI) * angle) * 0.005555555555555556), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 1.45e-54: tmp = math.pow(math.cos((-0.005555555555555556 * (math.pi * angle))), 2.0) * (a * a) else: tmp = (a * a) + math.pow((((b * math.pi) * angle) * 0.005555555555555556), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 1.45e-54) tmp = Float64((cos(Float64(-0.005555555555555556 * Float64(pi * angle))) ^ 2.0) * Float64(a * a)); else tmp = Float64(Float64(a * a) + (Float64(Float64(Float64(b * pi) * angle) * 0.005555555555555556) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 1.45e-54) tmp = (cos((-0.005555555555555556 * (pi * angle))) ^ 2.0) * (a * a); else tmp = (a * a) + ((((b * pi) * angle) * 0.005555555555555556) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 1.45e-54], N[(N[Power[N[Cos[N[(-0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[Power[N[(N[(N[(b * Pi), $MachinePrecision] * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.45 \cdot 10^{-54}:\\
\;\;\;\;{\cos \left(-0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right)}^{2} \cdot \left(a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + {\left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot 0.005555555555555556\right)}^{2}\\
\end{array}
\end{array}
if b < 1.45000000000000007e-54Initial program 73.4%
Taylor expanded in a around inf
Applied rewrites59.9%
Taylor expanded in a around inf
Applied rewrites54.2%
if 1.45000000000000007e-54 < b Initial program 88.1%
Taylor expanded in angle around 0
Applied rewrites88.2%
Taylor expanded in angle around 0
Applied rewrites88.4%
Taylor expanded in angle around 0
Applied rewrites86.0%
(FPCore (a b angle) :precision binary64 (+ (* a a) (pow (* b (sin (* (* 0.005555555555555556 PI) angle))) 2.0)))
double code(double a, double b, double angle) {
return (a * a) + pow((b * sin(((0.005555555555555556 * ((double) M_PI)) * angle))), 2.0);
}
public static double code(double a, double b, double angle) {
return (a * a) + Math.pow((b * Math.sin(((0.005555555555555556 * Math.PI) * angle))), 2.0);
}
def code(a, b, angle): return (a * a) + math.pow((b * math.sin(((0.005555555555555556 * math.pi) * angle))), 2.0)
function code(a, b, angle) return Float64(Float64(a * a) + (Float64(b * sin(Float64(Float64(0.005555555555555556 * pi) * angle))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (a * a) + ((b * sin(((0.005555555555555556 * pi) * angle))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(a * a), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(N[(0.005555555555555556 * Pi), $MachinePrecision] * angle), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a + {\left(b \cdot \sin \left(\left(0.005555555555555556 \cdot \pi\right) \cdot angle\right)\right)}^{2}
\end{array}
Initial program 78.0%
Taylor expanded in angle around 0
Applied rewrites78.1%
Taylor expanded in angle around 0
Applied rewrites78.1%
(FPCore (a b angle) :precision binary64 (if (<= b 2.15e-55) (* a a) (+ (* a a) (pow (* (* (* b PI) angle) 0.005555555555555556) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 2.15e-55) {
tmp = a * a;
} else {
tmp = (a * a) + pow((((b * ((double) M_PI)) * angle) * 0.005555555555555556), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 2.15e-55) {
tmp = a * a;
} else {
tmp = (a * a) + Math.pow((((b * Math.PI) * angle) * 0.005555555555555556), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 2.15e-55: tmp = a * a else: tmp = (a * a) + math.pow((((b * math.pi) * angle) * 0.005555555555555556), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 2.15e-55) tmp = Float64(a * a); else tmp = Float64(Float64(a * a) + (Float64(Float64(Float64(b * pi) * angle) * 0.005555555555555556) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 2.15e-55) tmp = a * a; else tmp = (a * a) + ((((b * pi) * angle) * 0.005555555555555556) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 2.15e-55], N[(a * a), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[Power[N[(N[(N[(b * Pi), $MachinePrecision] * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.15 \cdot 10^{-55}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + {\left(\left(\left(b \cdot \pi\right) \cdot angle\right) \cdot 0.005555555555555556\right)}^{2}\\
\end{array}
\end{array}
if b < 2.15000000000000005e-55Initial program 73.4%
Taylor expanded in angle around 0
Applied rewrites54.6%
if 2.15000000000000005e-55 < b Initial program 88.1%
Taylor expanded in angle around 0
Applied rewrites88.2%
Taylor expanded in angle around 0
Applied rewrites88.4%
Taylor expanded in angle around 0
Applied rewrites86.0%
(FPCore (a b angle)
:precision binary64
(if (<= a 1.45e-115)
(* (pow (* (* b PI) angle) 2.0) 3.08641975308642e-5)
(if (<= a 1.1e+116)
(fma
(* (* PI PI) (* 3.08641975308642e-5 (* b b)))
(* angle angle)
(* a a))
(* a a))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.45e-115) {
tmp = pow(((b * ((double) M_PI)) * angle), 2.0) * 3.08641975308642e-5;
} else if (a <= 1.1e+116) {
tmp = fma(((((double) M_PI) * ((double) M_PI)) * (3.08641975308642e-5 * (b * b))), (angle * angle), (a * a));
} else {
tmp = a * a;
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 1.45e-115) tmp = Float64((Float64(Float64(b * pi) * angle) ^ 2.0) * 3.08641975308642e-5); elseif (a <= 1.1e+116) tmp = fma(Float64(Float64(pi * pi) * Float64(3.08641975308642e-5 * Float64(b * b))), Float64(angle * angle), Float64(a * a)); else tmp = Float64(a * a); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 1.45e-115], N[(N[Power[N[(N[(b * Pi), $MachinePrecision] * angle), $MachinePrecision], 2.0], $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision], If[LessEqual[a, 1.1e+116], N[(N[(N[(Pi * Pi), $MachinePrecision] * N[(3.08641975308642e-5 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(angle * angle), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(a * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.45 \cdot 10^{-115}:\\
\;\;\;\;{\left(\left(b \cdot \pi\right) \cdot angle\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\
\mathbf{elif}\;a \leq 1.1 \cdot 10^{+116}:\\
\;\;\;\;\mathsf{fma}\left(\left(\pi \cdot \pi\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right)\right), angle \cdot angle, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 1.4499999999999999e-115Initial program 75.6%
Taylor expanded in angle around 0
Applied rewrites41.8%
Taylor expanded in a around 0
Applied rewrites36.5%
Applied rewrites45.3%
if 1.4499999999999999e-115 < a < 1.1e116Initial program 69.8%
Taylor expanded in angle around 0
Applied rewrites61.8%
Taylor expanded in a around 0
Applied rewrites64.4%
if 1.1e116 < a Initial program 98.1%
Taylor expanded in angle around 0
Applied rewrites91.8%
(FPCore (a b angle)
:precision binary64
(if (<= a 1.1e+116)
(fma
(* (* (* PI PI) (* 3.08641975308642e-5 (- (* b b) (* a a)))) angle)
angle
(* a a))
(* a a)))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.1e+116) {
tmp = fma((((((double) M_PI) * ((double) M_PI)) * (3.08641975308642e-5 * ((b * b) - (a * a)))) * angle), angle, (a * a));
} else {
tmp = a * a;
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 1.1e+116) tmp = fma(Float64(Float64(Float64(pi * pi) * Float64(3.08641975308642e-5 * Float64(Float64(b * b) - Float64(a * a)))) * angle), angle, Float64(a * a)); else tmp = Float64(a * a); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 1.1e+116], N[(N[(N[(N[(Pi * Pi), $MachinePrecision] * N[(3.08641975308642e-5 * N[(N[(b * b), $MachinePrecision] - N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * angle), $MachinePrecision] * angle + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(a * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.1 \cdot 10^{+116}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\pi \cdot \pi\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b - a \cdot a\right)\right)\right) \cdot angle, angle, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 1.1e116Initial program 74.1%
Taylor expanded in angle around 0
Applied rewrites47.0%
Applied rewrites49.9%
if 1.1e116 < a Initial program 98.1%
Taylor expanded in angle around 0
Applied rewrites91.8%
(FPCore (a b angle)
:precision binary64
(if (<= angle 2.25e-154)
(* a a)
(fma
(* (* PI PI) (* 3.08641975308642e-5 (* b b)))
(* angle angle)
(* a a))))
double code(double a, double b, double angle) {
double tmp;
if (angle <= 2.25e-154) {
tmp = a * a;
} else {
tmp = fma(((((double) M_PI) * ((double) M_PI)) * (3.08641975308642e-5 * (b * b))), (angle * angle), (a * a));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (angle <= 2.25e-154) tmp = Float64(a * a); else tmp = fma(Float64(Float64(pi * pi) * Float64(3.08641975308642e-5 * Float64(b * b))), Float64(angle * angle), Float64(a * a)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[angle, 2.25e-154], N[(a * a), $MachinePrecision], N[(N[(N[(Pi * Pi), $MachinePrecision] * N[(3.08641975308642e-5 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(angle * angle), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 2.25 \cdot 10^{-154}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\pi \cdot \pi\right) \cdot \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right)\right), angle \cdot angle, a \cdot a\right)\\
\end{array}
\end{array}
if angle < 2.2499999999999999e-154Initial program 84.3%
Taylor expanded in angle around 0
Applied rewrites58.4%
if 2.2499999999999999e-154 < angle Initial program 68.2%
Taylor expanded in angle around 0
Applied rewrites34.0%
Taylor expanded in a around 0
Applied rewrites59.7%
(FPCore (a b angle) :precision binary64 (if (<= b 6.6e+137) (* a a) (* (* (* (* (* (* angle angle) 3.08641975308642e-5) PI) b) PI) b)))
double code(double a, double b, double angle) {
double tmp;
if (b <= 6.6e+137) {
tmp = a * a;
} else {
tmp = (((((angle * angle) * 3.08641975308642e-5) * ((double) M_PI)) * b) * ((double) M_PI)) * b;
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 6.6e+137) {
tmp = a * a;
} else {
tmp = (((((angle * angle) * 3.08641975308642e-5) * Math.PI) * b) * Math.PI) * b;
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 6.6e+137: tmp = a * a else: tmp = (((((angle * angle) * 3.08641975308642e-5) * math.pi) * b) * math.pi) * b return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 6.6e+137) tmp = Float64(a * a); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(angle * angle) * 3.08641975308642e-5) * pi) * b) * pi) * b); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 6.6e+137) tmp = a * a; else tmp = (((((angle * angle) * 3.08641975308642e-5) * pi) * b) * pi) * b; end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 6.6e+137], N[(a * a), $MachinePrecision], N[(N[(N[(N[(N[(N[(angle * angle), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision] * Pi), $MachinePrecision] * b), $MachinePrecision] * Pi), $MachinePrecision] * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.6 \cdot 10^{+137}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \pi\right) \cdot b\right) \cdot \pi\right) \cdot b\\
\end{array}
\end{array}
if b < 6.60000000000000005e137Initial program 74.5%
Taylor expanded in angle around 0
Applied rewrites55.5%
if 6.60000000000000005e137 < b Initial program 99.7%
Taylor expanded in angle around 0
Applied rewrites47.7%
Taylor expanded in a around 0
Applied rewrites70.0%
Applied rewrites70.4%
(FPCore (a b angle) :precision binary64 (if (<= b 6.6e+137) (* a a) (* (* (* (* angle angle) 3.08641975308642e-5) b) (* (* b PI) PI))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 6.6e+137) {
tmp = a * a;
} else {
tmp = (((angle * angle) * 3.08641975308642e-5) * b) * ((b * ((double) M_PI)) * ((double) M_PI));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 6.6e+137) {
tmp = a * a;
} else {
tmp = (((angle * angle) * 3.08641975308642e-5) * b) * ((b * Math.PI) * Math.PI);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 6.6e+137: tmp = a * a else: tmp = (((angle * angle) * 3.08641975308642e-5) * b) * ((b * math.pi) * math.pi) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 6.6e+137) tmp = Float64(a * a); else tmp = Float64(Float64(Float64(Float64(angle * angle) * 3.08641975308642e-5) * b) * Float64(Float64(b * pi) * pi)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 6.6e+137) tmp = a * a; else tmp = (((angle * angle) * 3.08641975308642e-5) * b) * ((b * pi) * pi); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 6.6e+137], N[(a * a), $MachinePrecision], N[(N[(N[(N[(angle * angle), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision] * b), $MachinePrecision] * N[(N[(b * Pi), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.6 \cdot 10^{+137}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot b\right) \cdot \left(\left(b \cdot \pi\right) \cdot \pi\right)\\
\end{array}
\end{array}
if b < 6.60000000000000005e137Initial program 74.5%
Taylor expanded in angle around 0
Applied rewrites55.5%
if 6.60000000000000005e137 < b Initial program 99.7%
Taylor expanded in angle around 0
Applied rewrites47.7%
Taylor expanded in a around 0
Applied rewrites70.0%
Applied rewrites70.3%
(FPCore (a b angle) :precision binary64 (if (<= b 6.6e+137) (* a a) (* (* (* angle angle) 3.08641975308642e-5) (* (* b PI) (* b PI)))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 6.6e+137) {
tmp = a * a;
} else {
tmp = ((angle * angle) * 3.08641975308642e-5) * ((b * ((double) M_PI)) * (b * ((double) M_PI)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 6.6e+137) {
tmp = a * a;
} else {
tmp = ((angle * angle) * 3.08641975308642e-5) * ((b * Math.PI) * (b * Math.PI));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 6.6e+137: tmp = a * a else: tmp = ((angle * angle) * 3.08641975308642e-5) * ((b * math.pi) * (b * math.pi)) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 6.6e+137) tmp = Float64(a * a); else tmp = Float64(Float64(Float64(angle * angle) * 3.08641975308642e-5) * Float64(Float64(b * pi) * Float64(b * pi))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 6.6e+137) tmp = a * a; else tmp = ((angle * angle) * 3.08641975308642e-5) * ((b * pi) * (b * pi)); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 6.6e+137], N[(a * a), $MachinePrecision], N[(N[(N[(angle * angle), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision] * N[(N[(b * Pi), $MachinePrecision] * N[(b * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.6 \cdot 10^{+137}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right) \cdot \left(\left(b \cdot \pi\right) \cdot \left(b \cdot \pi\right)\right)\\
\end{array}
\end{array}
if b < 6.60000000000000005e137Initial program 74.5%
Taylor expanded in angle around 0
Applied rewrites55.5%
if 6.60000000000000005e137 < b Initial program 99.7%
Taylor expanded in angle around 0
Applied rewrites47.7%
Taylor expanded in a around 0
Applied rewrites70.0%
(FPCore (a b angle) :precision binary64 (if (<= b 6.6e+137) (* a a) (* (* b b) (* (* PI PI) (* (* angle angle) 3.08641975308642e-5)))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 6.6e+137) {
tmp = a * a;
} else {
tmp = (b * b) * ((((double) M_PI) * ((double) M_PI)) * ((angle * angle) * 3.08641975308642e-5));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 6.6e+137) {
tmp = a * a;
} else {
tmp = (b * b) * ((Math.PI * Math.PI) * ((angle * angle) * 3.08641975308642e-5));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 6.6e+137: tmp = a * a else: tmp = (b * b) * ((math.pi * math.pi) * ((angle * angle) * 3.08641975308642e-5)) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 6.6e+137) tmp = Float64(a * a); else tmp = Float64(Float64(b * b) * Float64(Float64(pi * pi) * Float64(Float64(angle * angle) * 3.08641975308642e-5))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 6.6e+137) tmp = a * a; else tmp = (b * b) * ((pi * pi) * ((angle * angle) * 3.08641975308642e-5)); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 6.6e+137], N[(a * a), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * N[(N[(angle * angle), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.6 \cdot 10^{+137}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot \left(\left(angle \cdot angle\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\\
\end{array}
\end{array}
if b < 6.60000000000000005e137Initial program 74.5%
Taylor expanded in angle around 0
Applied rewrites55.5%
if 6.60000000000000005e137 < b Initial program 99.7%
Taylor expanded in angle around 0
Applied rewrites47.7%
Taylor expanded in a around 0
Applied rewrites70.0%
Applied rewrites70.0%
(FPCore (a b angle) :precision binary64 (* a a))
double code(double a, double b, double angle) {
return a * a;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, angle)
use fmin_fmax_functions
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 78.0%
Taylor expanded in angle around 0
Applied rewrites53.2%
herbie shell --seed 2025056
(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)))