
(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}
Herbie found 14 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 (let* ((t_0 (* PI (/ angle 180.0)))) (+ (pow (* a (sin (+ (- t_0) (/ PI 2.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 * sin((-t_0 + (((double) M_PI) / 2.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.sin((-t_0 + (Math.PI / 2.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.sin((-t_0 + (math.pi / 2.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 * sin(Float64(Float64(-t_0) + Float64(pi / 2.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 * sin((-t_0 + (pi / 2.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[Sin[N[((-t$95$0) + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
{\left(a \cdot \sin \left(\left(-t\_0\right) + \frac{\pi}{2}\right)\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
\end{array}
Initial program 79.1%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lift-PI.f6479.1
Applied rewrites79.1%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (fma PI (/ angle 180.0) (/ PI 2.0)))) 2.0) (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(fma(((double) M_PI), (angle / 180.0), (((double) M_PI) / 2.0)))), 2.0) + pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
function code(a, b, angle) return Float64((Float64(a * sin(fma(pi, Float64(angle / 180.0), Float64(pi / 2.0)))) ^ 2.0) + (Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision] + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\mathsf{fma}\left(\pi, \frac{angle}{180}, \frac{\pi}{2}\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 79.1%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-PI.f64N/A
lower-/.f64N/A
lift-PI.f6479.1
Applied rewrites79.1%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (fma PI (* 0.005555555555555556 angle) (/ PI 2.0)))) 2.0) (pow (* b (sin (* PI (* 0.005555555555555556 angle)))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(fma(((double) M_PI), (0.005555555555555556 * angle), (((double) M_PI) / 2.0)))), 2.0) + pow((b * sin((((double) M_PI) * (0.005555555555555556 * angle)))), 2.0);
}
function code(a, b, angle) return Float64((Float64(a * sin(fma(pi, Float64(0.005555555555555556 * angle), Float64(pi / 2.0)))) ^ 2.0) + (Float64(b * sin(Float64(pi * Float64(0.005555555555555556 * angle)))) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(Pi * N[(0.005555555555555556 * angle), $MachinePrecision] + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(0.005555555555555556 * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\mathsf{fma}\left(\pi, 0.005555555555555556 \cdot angle, \frac{\pi}{2}\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)}^{2}
\end{array}
Initial program 79.1%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lift-PI.f6479.1
Applied rewrites79.1%
Taylor expanded in angle around 0
lower-*.f6479.1
Applied rewrites79.1%
Taylor expanded in angle around 0
lower-*.f6479.1
Applied rewrites79.1%
lift-sin.f64N/A
lift-+.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
sin-+PI/2N/A
lift-neg.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lower-fma.f64N/A
lift-PI.f6479.1
Applied rewrites79.1%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (fma -0.005555555555555556 (* PI angle) (* 0.5 PI)))) 2.0) (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(fma(-0.005555555555555556, (((double) M_PI) * angle), (0.5 * ((double) M_PI))))), 2.0) + pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
function code(a, b, angle) return Float64((Float64(a * sin(fma(-0.005555555555555556, Float64(pi * angle), Float64(0.5 * pi)))) ^ 2.0) + (Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(-0.005555555555555556 * N[(Pi * angle), $MachinePrecision] + N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\mathsf{fma}\left(-0.005555555555555556, \pi \cdot angle, 0.5 \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 79.1%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lift-PI.f6479.1
Applied rewrites79.1%
Taylor expanded in angle around 0
lower-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
lift-PI.f6479.0
Applied rewrites79.0%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (/ angle 180.0)))) (fma (pow (cos t_0) 2.0) (* a a) (pow (* (sin t_0) b) 2.0))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle / 180.0);
return fma(pow(cos(t_0), 2.0), (a * a), pow((sin(t_0) * b), 2.0));
}
function code(a, b, angle) t_0 = Float64(pi * Float64(angle / 180.0)) return fma((cos(t_0) ^ 2.0), Float64(a * a), (Float64(sin(t_0) * b) ^ 2.0)) end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[Cos[t$95$0], $MachinePrecision], 2.0], $MachinePrecision] * N[(a * a), $MachinePrecision] + N[Power[N[(N[Sin[t$95$0], $MachinePrecision] * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
\mathsf{fma}\left({\cos t\_0}^{2}, a \cdot a, {\left(\sin t\_0 \cdot b\right)}^{2}\right)
\end{array}
\end{array}
Initial program 79.1%
lift-+.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
unpow-prod-downN/A
lift-pow.f64N/A
Applied rewrites79.1%
(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}
Initial program 79.1%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (* 0.005555555555555556 angle)))) (+ (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) * (0.005555555555555556 * angle);
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 * (0.005555555555555556 * angle);
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 * (0.005555555555555556 * angle) 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(0.005555555555555556 * angle)) 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 * (0.005555555555555556 * angle); 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[(0.005555555555555556 * angle), $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 \left(0.005555555555555556 \cdot angle\right)\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
\end{array}
Initial program 79.1%
Taylor expanded in angle around 0
lower-*.f6479.1
Applied rewrites79.1%
Taylor expanded in angle around 0
lower-*.f6479.1
Applied rewrites79.1%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (* PI angle) 0.005555555555555556))) (+ (pow (* (sin t_0) b) 2.0) (pow (* (cos t_0) a) 2.0))))
double code(double a, double b, double angle) {
double t_0 = (((double) M_PI) * angle) * 0.005555555555555556;
return pow((sin(t_0) * b), 2.0) + pow((cos(t_0) * a), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = (Math.PI * angle) * 0.005555555555555556;
return Math.pow((Math.sin(t_0) * b), 2.0) + Math.pow((Math.cos(t_0) * a), 2.0);
}
def code(a, b, angle): t_0 = (math.pi * angle) * 0.005555555555555556 return math.pow((math.sin(t_0) * b), 2.0) + math.pow((math.cos(t_0) * a), 2.0)
function code(a, b, angle) t_0 = Float64(Float64(pi * angle) * 0.005555555555555556) return Float64((Float64(sin(t_0) * b) ^ 2.0) + (Float64(cos(t_0) * a) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = (pi * angle) * 0.005555555555555556; tmp = ((sin(t_0) * b) ^ 2.0) + ((cos(t_0) * a) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]}, N[(N[Power[N[(N[Sin[t$95$0], $MachinePrecision] * b), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(N[Cos[t$95$0], $MachinePrecision] * a), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\pi \cdot angle\right) \cdot 0.005555555555555556\\
{\left(\sin t\_0 \cdot b\right)}^{2} + {\left(\cos t\_0 \cdot a\right)}^{2}
\end{array}
\end{array}
Initial program 79.1%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6479.1
Applied rewrites79.1%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6479.1
Applied rewrites79.1%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6479.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.1
Applied rewrites79.1%
(FPCore (a b angle) :precision binary64 (+ (* (* 1.0 1.0) (* a a)) (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return ((1.0 * 1.0) * (a * a)) + pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return ((1.0 * 1.0) * (a * a)) + Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0);
}
def code(a, b, angle): return ((1.0 * 1.0) * (a * a)) + math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0)
function code(a, b, angle) return Float64(Float64(Float64(1.0 * 1.0) * Float64(a * a)) + (Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((1.0 * 1.0) * (a * a)) + ((b * sin((pi * (angle / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[(N[(1.0 * 1.0), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 \cdot 1\right) \cdot \left(a \cdot a\right) + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}
Initial program 79.1%
Taylor expanded in angle around 0
Applied rewrites79.1%
lift-pow.f64N/A
lift-*.f64N/A
*-commutativeN/A
unpow-prod-downN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.1
Applied rewrites79.1%
(FPCore (a b angle)
:precision binary64
(if (<= a 2.5e-33)
(fma
a
a
(*
(* angle angle)
(fma
(* (* 3.08641975308642e-5 b) b)
(* PI PI)
(* (* PI PI) (* (* -3.08641975308642e-5 a) a)))))
(fma
(* (- 0.5 (* (cos (* (* (/ angle 180.0) PI) 2.0)) 0.5)) b)
b
(* (* 1.0 a) (* 1.0 a)))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 2.5e-33) {
tmp = fma(a, a, ((angle * angle) * fma(((3.08641975308642e-5 * b) * b), (((double) M_PI) * ((double) M_PI)), ((((double) M_PI) * ((double) M_PI)) * ((-3.08641975308642e-5 * a) * a)))));
} else {
tmp = fma(((0.5 - (cos((((angle / 180.0) * ((double) M_PI)) * 2.0)) * 0.5)) * b), b, ((1.0 * a) * (1.0 * a)));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 2.5e-33) tmp = fma(a, a, Float64(Float64(angle * angle) * fma(Float64(Float64(3.08641975308642e-5 * b) * b), Float64(pi * pi), Float64(Float64(pi * pi) * Float64(Float64(-3.08641975308642e-5 * a) * a))))); else tmp = fma(Float64(Float64(0.5 - Float64(cos(Float64(Float64(Float64(angle / 180.0) * pi) * 2.0)) * 0.5)) * b), b, Float64(Float64(1.0 * a) * Float64(1.0 * a))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 2.5e-33], N[(a * a + N[(N[(angle * angle), $MachinePrecision] * N[(N[(N[(3.08641975308642e-5 * b), $MachinePrecision] * b), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision] + N[(N[(Pi * Pi), $MachinePrecision] * N[(N[(-3.08641975308642e-5 * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 - N[(N[Cos[N[(N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b + N[(N[(1.0 * a), $MachinePrecision] * N[(1.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.5 \cdot 10^{-33}:\\
\;\;\;\;\mathsf{fma}\left(a, a, \left(angle \cdot angle\right) \cdot \mathsf{fma}\left(\left(3.08641975308642 \cdot 10^{-5} \cdot b\right) \cdot b, \pi \cdot \pi, \left(\pi \cdot \pi\right) \cdot \left(\left(-3.08641975308642 \cdot 10^{-5} \cdot a\right) \cdot a\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(0.5 - \cos \left(\left(\frac{angle}{180} \cdot \pi\right) \cdot 2\right) \cdot 0.5\right) \cdot b, b, \left(1 \cdot a\right) \cdot \left(1 \cdot a\right)\right)\\
\end{array}
\end{array}
if a < 2.50000000000000014e-33Initial program 79.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.4
Applied rewrites57.4%
Taylor expanded in angle around 0
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
Applied rewrites40.9%
if 2.50000000000000014e-33 < a Initial program 79.1%
Taylor expanded in angle around 0
Applied rewrites79.1%
Applied rewrites67.4%
(FPCore (a b angle)
:precision binary64
(if (<= a 1.42e-14)
(fma
a
a
(*
(* angle angle)
(fma
(* (* 3.08641975308642e-5 b) b)
(* PI PI)
(* (* PI PI) (* (* -3.08641975308642e-5 a) a)))))
(*
(fma
(fma
(* 3.175328964080679e-10 (* angle angle))
(* (* (* PI PI) PI) PI)
(* (* PI PI) -3.08641975308642e-5))
(* angle angle)
1.0)
(* a a))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.42e-14) {
tmp = fma(a, a, ((angle * angle) * fma(((3.08641975308642e-5 * b) * b), (((double) M_PI) * ((double) M_PI)), ((((double) M_PI) * ((double) M_PI)) * ((-3.08641975308642e-5 * a) * a)))));
} else {
tmp = fma(fma((3.175328964080679e-10 * (angle * angle)), (((((double) M_PI) * ((double) M_PI)) * ((double) M_PI)) * ((double) M_PI)), ((((double) M_PI) * ((double) M_PI)) * -3.08641975308642e-5)), (angle * angle), 1.0) * (a * a);
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 1.42e-14) tmp = fma(a, a, Float64(Float64(angle * angle) * fma(Float64(Float64(3.08641975308642e-5 * b) * b), Float64(pi * pi), Float64(Float64(pi * pi) * Float64(Float64(-3.08641975308642e-5 * a) * a))))); else tmp = Float64(fma(fma(Float64(3.175328964080679e-10 * Float64(angle * angle)), Float64(Float64(Float64(pi * pi) * pi) * pi), Float64(Float64(pi * pi) * -3.08641975308642e-5)), Float64(angle * angle), 1.0) * Float64(a * a)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 1.42e-14], N[(a * a + N[(N[(angle * angle), $MachinePrecision] * N[(N[(N[(3.08641975308642e-5 * b), $MachinePrecision] * b), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision] + N[(N[(Pi * Pi), $MachinePrecision] * N[(N[(-3.08641975308642e-5 * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(3.175328964080679e-10 * N[(angle * angle), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(Pi * Pi), $MachinePrecision] * Pi), $MachinePrecision] * Pi), $MachinePrecision] + N[(N[(Pi * Pi), $MachinePrecision] * -3.08641975308642e-5), $MachinePrecision]), $MachinePrecision] * N[(angle * angle), $MachinePrecision] + 1.0), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.42 \cdot 10^{-14}:\\
\;\;\;\;\mathsf{fma}\left(a, a, \left(angle \cdot angle\right) \cdot \mathsf{fma}\left(\left(3.08641975308642 \cdot 10^{-5} \cdot b\right) \cdot b, \pi \cdot \pi, \left(\pi \cdot \pi\right) \cdot \left(\left(-3.08641975308642 \cdot 10^{-5} \cdot a\right) \cdot a\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(3.175328964080679 \cdot 10^{-10} \cdot \left(angle \cdot angle\right), \left(\left(\pi \cdot \pi\right) \cdot \pi\right) \cdot \pi, \left(\pi \cdot \pi\right) \cdot -3.08641975308642 \cdot 10^{-5}\right), angle \cdot angle, 1\right) \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if a < 1.42000000000000004e-14Initial program 79.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.4
Applied rewrites57.4%
Taylor expanded in angle around 0
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
Applied rewrites40.9%
if 1.42000000000000004e-14 < a Initial program 79.1%
Taylor expanded in angle around 0
Applied rewrites30.2%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites57.1%
(FPCore (a b angle)
:precision binary64
(if (<= a 3600000.0)
(fma
a
a
(*
(* angle angle)
(fma
(* (* 3.08641975308642e-5 b) b)
(* PI PI)
(* (* PI PI) (* (* -3.08641975308642e-5 a) a)))))
(* a a)))
double code(double a, double b, double angle) {
double tmp;
if (a <= 3600000.0) {
tmp = fma(a, a, ((angle * angle) * fma(((3.08641975308642e-5 * b) * b), (((double) M_PI) * ((double) M_PI)), ((((double) M_PI) * ((double) M_PI)) * ((-3.08641975308642e-5 * a) * a)))));
} else {
tmp = a * a;
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 3600000.0) tmp = fma(a, a, Float64(Float64(angle * angle) * fma(Float64(Float64(3.08641975308642e-5 * b) * b), Float64(pi * pi), Float64(Float64(pi * pi) * Float64(Float64(-3.08641975308642e-5 * a) * a))))); else tmp = Float64(a * a); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 3600000.0], N[(a * a + N[(N[(angle * angle), $MachinePrecision] * N[(N[(N[(3.08641975308642e-5 * b), $MachinePrecision] * b), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision] + N[(N[(Pi * Pi), $MachinePrecision] * N[(N[(-3.08641975308642e-5 * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3600000:\\
\;\;\;\;\mathsf{fma}\left(a, a, \left(angle \cdot angle\right) \cdot \mathsf{fma}\left(\left(3.08641975308642 \cdot 10^{-5} \cdot b\right) \cdot b, \pi \cdot \pi, \left(\pi \cdot \pi\right) \cdot \left(\left(-3.08641975308642 \cdot 10^{-5} \cdot a\right) \cdot a\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 3.6e6Initial program 79.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.4
Applied rewrites57.4%
Taylor expanded in angle around 0
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
Applied rewrites40.9%
if 3.6e6 < a Initial program 79.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.4
Applied rewrites57.4%
(FPCore (a b angle)
:precision binary64
(if (<= a 3600000.0)
(fma
a
a
(*
(* angle angle)
(fma
(* -3.08641975308642e-5 (* a a))
(* PI PI)
(* (* 3.08641975308642e-5 (* b b)) (* PI PI)))))
(* a a)))
double code(double a, double b, double angle) {
double tmp;
if (a <= 3600000.0) {
tmp = fma(a, a, ((angle * angle) * fma((-3.08641975308642e-5 * (a * a)), (((double) M_PI) * ((double) M_PI)), ((3.08641975308642e-5 * (b * b)) * (((double) M_PI) * ((double) M_PI))))));
} else {
tmp = a * a;
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 3600000.0) tmp = fma(a, a, Float64(Float64(angle * angle) * fma(Float64(-3.08641975308642e-5 * Float64(a * a)), Float64(pi * pi), Float64(Float64(3.08641975308642e-5 * Float64(b * b)) * Float64(pi * pi))))); else tmp = Float64(a * a); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 3600000.0], N[(a * a + N[(N[(angle * angle), $MachinePrecision] * N[(N[(-3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision] + N[(N[(3.08641975308642e-5 * N[(b * b), $MachinePrecision]), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3600000:\\
\;\;\;\;\mathsf{fma}\left(a, a, \left(angle \cdot angle\right) \cdot \mathsf{fma}\left(-3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right), \pi \cdot \pi, \left(3.08641975308642 \cdot 10^{-5} \cdot \left(b \cdot b\right)\right) \cdot \left(\pi \cdot \pi\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 3.6e6Initial program 79.1%
Taylor expanded in angle around 0
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites40.7%
if 3.6e6 < a Initial program 79.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.4
Applied rewrites57.4%
(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 79.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.4
Applied rewrites57.4%
herbie shell --seed 2025131
(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)))