
(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}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (/ angle 180.0) PI))) (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * ((double) M_PI);
return pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * Math.PI;
return Math.pow((a * Math.sin(t_0)), 2.0) + Math.pow((b * Math.cos(t_0)), 2.0);
}
def code(a, b, angle): t_0 = (angle / 180.0) * math.pi return math.pow((a * math.sin(t_0)), 2.0) + math.pow((b * math.cos(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(Float64(angle / 180.0) * pi) return Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = (angle / 180.0) * pi; tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[Power[N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (/ angle 180.0) PI))) 2.0) (pow (* b (cos (* 0.005555555555555556 (* angle PI)))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(((angle / 180.0) * ((double) M_PI)))), 2.0) + pow((b * cos((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin(((angle / 180.0) * Math.PI))), 2.0) + Math.pow((b * Math.cos((0.005555555555555556 * (angle * Math.PI)))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin(((angle / 180.0) * math.pi))), 2.0) + math.pow((b * math.cos((0.005555555555555556 * (angle * math.pi)))), 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(angle / 180.0) * pi))) ^ 2.0) + (Float64(b * cos(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin(((angle / 180.0) * pi))) ^ 2.0) + ((b * cos((0.005555555555555556 * (angle * pi)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}
\end{array}
Initial program 79.5%
Taylor expanded in angle around inf
Applied rewrites79.5%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* 0.005555555555555556 (* angle 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 = 0.005555555555555556 * (angle * ((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 = 0.005555555555555556 * (angle * 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 = 0.005555555555555556 * (angle * 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(0.005555555555555556 * Float64(angle * 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 = 0.005555555555555556 * (angle * pi); tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $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 := 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
Initial program 79.5%
Taylor expanded in angle around inf
Applied rewrites79.5%
Taylor expanded in angle around inf
Applied rewrites79.5%
(FPCore (a b angle)
:precision binary64
(if (<= angle 0.00385)
(+
(pow (* a (* 0.005555555555555556 (* angle PI))) 2.0)
(pow (* b 1.0) 2.0))
(+ (* (* a 2.0) a) (pow (* b (cos (* (/ angle 180.0) PI))) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (angle <= 0.00385) {
tmp = pow((a * (0.005555555555555556 * (angle * ((double) M_PI)))), 2.0) + pow((b * 1.0), 2.0);
} else {
tmp = ((a * 2.0) * a) + pow((b * cos(((angle / 180.0) * ((double) M_PI)))), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (angle <= 0.00385) {
tmp = Math.pow((a * (0.005555555555555556 * (angle * Math.PI))), 2.0) + Math.pow((b * 1.0), 2.0);
} else {
tmp = ((a * 2.0) * a) + Math.pow((b * Math.cos(((angle / 180.0) * Math.PI))), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if angle <= 0.00385: tmp = math.pow((a * (0.005555555555555556 * (angle * math.pi))), 2.0) + math.pow((b * 1.0), 2.0) else: tmp = ((a * 2.0) * a) + math.pow((b * math.cos(((angle / 180.0) * math.pi))), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (angle <= 0.00385) tmp = Float64((Float64(a * Float64(0.005555555555555556 * Float64(angle * pi))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0)); else tmp = Float64(Float64(Float64(a * 2.0) * a) + (Float64(b * cos(Float64(Float64(angle / 180.0) * pi))) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (angle <= 0.00385) tmp = ((a * (0.005555555555555556 * (angle * pi))) ^ 2.0) + ((b * 1.0) ^ 2.0); else tmp = ((a * 2.0) * a) + ((b * cos(((angle / 180.0) * pi))) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[angle, 0.00385], N[(N[Power[N[(a * N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * 2.0), $MachinePrecision] * a), $MachinePrecision] + N[Power[N[(b * N[Cos[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 0.00385:\\
\;\;\;\;{\left(a \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot 2\right) \cdot a + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}\\
\end{array}
\end{array}
if angle < 0.0038500000000000001Initial program 79.5%
Taylor expanded in angle around 0
Applied rewrites79.4%
Taylor expanded in angle around 0
Applied rewrites74.2%
if 0.0038500000000000001 < angle Initial program 79.5%
Applied rewrites56.4%
Applied rewrites61.1%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (/ angle 180.0) PI))) 2.0) (pow (* b 1.0) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(((angle / 180.0) * ((double) M_PI)))), 2.0) + pow((b * 1.0), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin(((angle / 180.0) * Math.PI))), 2.0) + Math.pow((b * 1.0), 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin(((angle / 180.0) * math.pi))), 2.0) + math.pow((b * 1.0), 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(angle / 180.0) * pi))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin(((angle / 180.0) * pi))) ^ 2.0) + ((b * 1.0) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}
\end{array}
Initial program 79.5%
Taylor expanded in angle around 0
Applied rewrites79.4%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (* 0.005555555555555556 angle) PI))) 2.0) (pow (* b 1.0) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(((0.005555555555555556 * angle) * ((double) M_PI)))), 2.0) + pow((b * 1.0), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin(((0.005555555555555556 * angle) * Math.PI))), 2.0) + Math.pow((b * 1.0), 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin(((0.005555555555555556 * angle) * math.pi))), 2.0) + math.pow((b * 1.0), 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(0.005555555555555556 * angle) * pi))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin(((0.005555555555555556 * angle) * pi))) ^ 2.0) + ((b * 1.0) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(0.005555555555555556 * angle), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\left(0.005555555555555556 \cdot angle\right) \cdot \pi\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}
\end{array}
Initial program 79.5%
Taylor expanded in angle around 0
Applied rewrites79.4%
Taylor expanded in angle around 0
Applied rewrites79.4%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* 0.005555555555555556 (* angle PI)))) 2.0) (pow (* b 1.0) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0) + pow((b * 1.0), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((0.005555555555555556 * (angle * Math.PI)))), 2.0) + Math.pow((b * 1.0), 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0) + math.pow((b * 1.0), 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0) + ((b * 1.0) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}
\end{array}
Initial program 79.5%
Taylor expanded in angle around inf
Applied rewrites79.5%
Taylor expanded in angle around inf
Applied rewrites79.5%
Taylor expanded in angle around 0
Applied rewrites79.4%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (fma a 2.0 (* b 2.0))))
(if (<= angle 520000000000.0)
(+
(pow (* a (* 0.005555555555555556 (* angle PI))) 2.0)
(pow (* b 1.0) 2.0))
(* t_0 t_0))))
double code(double a, double b, double angle) {
double t_0 = fma(a, 2.0, (b * 2.0));
double tmp;
if (angle <= 520000000000.0) {
tmp = pow((a * (0.005555555555555556 * (angle * ((double) M_PI)))), 2.0) + pow((b * 1.0), 2.0);
} else {
tmp = t_0 * t_0;
}
return tmp;
}
function code(a, b, angle) t_0 = fma(a, 2.0, Float64(b * 2.0)) tmp = 0.0 if (angle <= 520000000000.0) tmp = Float64((Float64(a * Float64(0.005555555555555556 * Float64(angle * pi))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0)); else tmp = Float64(t_0 * t_0); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(a * 2.0 + N[(b * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[angle, 520000000000.0], N[(N[Power[N[(a * N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, 2, b \cdot 2\right)\\
\mathbf{if}\;angle \leq 520000000000:\\
\;\;\;\;{\left(a \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot t\_0\\
\end{array}
\end{array}
if angle < 5.2e11Initial program 79.5%
Taylor expanded in angle around 0
Applied rewrites79.4%
Taylor expanded in angle around 0
Applied rewrites74.2%
if 5.2e11 < angle Initial program 79.5%
Applied rewrites56.4%
Applied rewrites49.7%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) PI)))
(if (<= (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0)) 1e+303)
(* b b)
(fma 0.005555555555555556 (* (pow a 2.0) (* angle PI)) (pow b 2.0)))))
double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * ((double) M_PI);
double tmp;
if ((pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0)) <= 1e+303) {
tmp = b * b;
} else {
tmp = fma(0.005555555555555556, (pow(a, 2.0) * (angle * ((double) M_PI))), pow(b, 2.0));
}
return tmp;
}
function code(a, b, angle) t_0 = Float64(Float64(angle / 180.0) * pi) tmp = 0.0 if (Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) <= 1e+303) tmp = Float64(b * b); else tmp = fma(0.005555555555555556, Float64((a ^ 2.0) * Float64(angle * pi)), (b ^ 2.0)); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, If[LessEqual[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], 1e+303], N[(b * b), $MachinePrecision], N[(0.005555555555555556 * N[(N[Power[a, 2.0], $MachinePrecision] * N[(angle * Pi), $MachinePrecision]), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
\mathbf{if}\;{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2} \leq 10^{+303}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.005555555555555556, {a}^{2} \cdot \left(angle \cdot \pi\right), {b}^{2}\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) < 1e303Initial program 79.5%
Taylor expanded in angle around 0
Applied rewrites57.3%
Applied rewrites3.9%
Applied rewrites57.3%
if 1e303 < (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) Initial program 79.5%
Applied rewrites56.4%
Taylor expanded in angle around 0
Applied rewrites52.9%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (fma a 2.0 (* b 2.0))) (t_1 (* (/ angle 180.0) PI)))
(if (<= (+ (pow (* a (sin t_1)) 2.0) (pow (* b (cos t_1)) 2.0)) 4e+306)
(* b b)
(* t_0 t_0))))
double code(double a, double b, double angle) {
double t_0 = fma(a, 2.0, (b * 2.0));
double t_1 = (angle / 180.0) * ((double) M_PI);
double tmp;
if ((pow((a * sin(t_1)), 2.0) + pow((b * cos(t_1)), 2.0)) <= 4e+306) {
tmp = b * b;
} else {
tmp = t_0 * t_0;
}
return tmp;
}
function code(a, b, angle) t_0 = fma(a, 2.0, Float64(b * 2.0)) t_1 = Float64(Float64(angle / 180.0) * pi) tmp = 0.0 if (Float64((Float64(a * sin(t_1)) ^ 2.0) + (Float64(b * cos(t_1)) ^ 2.0)) <= 4e+306) tmp = Float64(b * b); else tmp = Float64(t_0 * t_0); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(a * 2.0 + N[(b * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(a * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 4e+306], N[(b * b), $MachinePrecision], N[(t$95$0 * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, 2, b \cdot 2\right)\\
t_1 := \frac{angle}{180} \cdot \pi\\
\mathbf{if}\;{\left(a \cdot \sin t\_1\right)}^{2} + {\left(b \cdot \cos t\_1\right)}^{2} \leq 4 \cdot 10^{+306}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot t\_0\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) < 4.00000000000000007e306Initial program 79.5%
Taylor expanded in angle around 0
Applied rewrites57.3%
Applied rewrites3.9%
Applied rewrites57.3%
if 4.00000000000000007e306 < (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) Initial program 79.5%
Applied rewrites56.4%
Applied rewrites49.7%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) PI)))
(if (<= (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0)) 5e+307)
(* b b)
(* (* b b) (* b b)))))
double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * ((double) M_PI);
double tmp;
if ((pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0)) <= 5e+307) {
tmp = b * b;
} else {
tmp = (b * b) * (b * b);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * Math.PI;
double tmp;
if ((Math.pow((a * Math.sin(t_0)), 2.0) + Math.pow((b * Math.cos(t_0)), 2.0)) <= 5e+307) {
tmp = b * b;
} else {
tmp = (b * b) * (b * b);
}
return tmp;
}
def code(a, b, angle): t_0 = (angle / 180.0) * math.pi tmp = 0 if (math.pow((a * math.sin(t_0)), 2.0) + math.pow((b * math.cos(t_0)), 2.0)) <= 5e+307: tmp = b * b else: tmp = (b * b) * (b * b) return tmp
function code(a, b, angle) t_0 = Float64(Float64(angle / 180.0) * pi) tmp = 0.0 if (Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) <= 5e+307) tmp = Float64(b * b); else tmp = Float64(Float64(b * b) * Float64(b * b)); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = (angle / 180.0) * pi; tmp = 0.0; if ((((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0)) <= 5e+307) tmp = b * b; else tmp = (b * b) * (b * b); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, If[LessEqual[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], 5e+307], N[(b * b), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
\mathbf{if}\;{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2} \leq 5 \cdot 10^{+307}:\\
\;\;\;\;b \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) < 5e307Initial program 79.5%
Taylor expanded in angle around 0
Applied rewrites57.3%
Applied rewrites3.9%
Applied rewrites57.3%
if 5e307 < (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) Initial program 79.5%
Taylor expanded in angle around 0
Applied rewrites57.3%
Applied rewrites3.9%
Applied rewrites57.3%
Applied rewrites24.8%
Applied rewrites39.4%
(FPCore (a b angle) :precision binary64 (* b b))
double code(double a, double b, double angle) {
return b * b;
}
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 = b * b
end function
public static double code(double a, double b, double angle) {
return b * b;
}
def code(a, b, angle): return b * b
function code(a, b, angle) return Float64(b * b) end
function tmp = code(a, b, angle) tmp = b * b; end
code[a_, b_, angle_] := N[(b * b), $MachinePrecision]
\begin{array}{l}
\\
b \cdot b
\end{array}
Initial program 79.5%
Taylor expanded in angle around 0
Applied rewrites57.3%
Applied rewrites3.9%
Applied rewrites57.3%
(FPCore (a b angle) :precision binary64 b)
double code(double a, double b, double angle) {
return b;
}
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 = b
end function
public static double code(double a, double b, double angle) {
return b;
}
def code(a, b, angle): return b
function code(a, b, angle) return b end
function tmp = code(a, b, angle) tmp = b; end
code[a_, b_, angle_] := b
\begin{array}{l}
\\
b
\end{array}
Initial program 79.5%
Taylor expanded in angle around 0
Applied rewrites57.3%
Applied rewrites3.9%
herbie shell --seed 2025159
(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)))