
(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 10 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}
b_m = (fabs.f64 b)
(FPCore (a b_m angle)
:precision binary64
(if (<= b_m 1.6e+151)
(fma
(* (pow (sin (* (* angle PI) 0.005555555555555556)) 2.0) b_m)
b_m
(* a a))
(+ (* a a) (pow (* (* (* 0.005555555555555556 b_m) PI) angle) 2.0))))b_m = fabs(b);
double code(double a, double b_m, double angle) {
double tmp;
if (b_m <= 1.6e+151) {
tmp = fma((pow(sin(((angle * ((double) M_PI)) * 0.005555555555555556)), 2.0) * b_m), b_m, (a * a));
} else {
tmp = (a * a) + pow((((0.005555555555555556 * b_m) * ((double) M_PI)) * angle), 2.0);
}
return tmp;
}
b_m = abs(b) function code(a, b_m, angle) tmp = 0.0 if (b_m <= 1.6e+151) tmp = fma(Float64((sin(Float64(Float64(angle * pi) * 0.005555555555555556)) ^ 2.0) * b_m), b_m, Float64(a * a)); else tmp = Float64(Float64(a * a) + (Float64(Float64(Float64(0.005555555555555556 * b_m) * pi) * angle) ^ 2.0)); end return tmp end
b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_] := If[LessEqual[b$95$m, 1.6e+151], N[(N[(N[Power[N[Sin[N[(N[(angle * Pi), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * b$95$m), $MachinePrecision] * b$95$m + N[(a * a), $MachinePrecision]), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[Power[N[(N[(N[(0.005555555555555556 * b$95$m), $MachinePrecision] * Pi), $MachinePrecision] * angle), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 1.6 \cdot 10^{+151}:\\
\;\;\;\;\mathsf{fma}\left({\sin \left(\left(angle \cdot \pi\right) \cdot 0.005555555555555556\right)}^{2} \cdot b\_m, b\_m, a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + {\left(\left(\left(0.005555555555555556 \cdot b\_m\right) \cdot \pi\right) \cdot angle\right)}^{2}\\
\end{array}
\end{array}
if b < 1.59999999999999997e151Initial program 72.8%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6472.6
Applied rewrites72.6%
lift-+.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
unpow-prod-downN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
Applied rewrites71.5%
Taylor expanded in angle around inf
lower-pow.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lift-PI.f6471.5
Applied rewrites71.5%
if 1.59999999999999997e151 < b Initial program 97.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6497.9
Applied rewrites97.9%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.3%
Taylor expanded in angle around 0
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-PI.f6497.9
Applied rewrites97.9%
b_m = (fabs.f64 b) (FPCore (a b_m angle) :precision binary64 (+ (* a a) (pow (* b_m (sin (* angle (/ PI 180.0)))) 2.0)))
b_m = fabs(b);
double code(double a, double b_m, double angle) {
return (a * a) + pow((b_m * sin((angle * (((double) M_PI) / 180.0)))), 2.0);
}
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle) {
return (a * a) + Math.pow((b_m * Math.sin((angle * (Math.PI / 180.0)))), 2.0);
}
b_m = math.fabs(b) def code(a, b_m, angle): return (a * a) + math.pow((b_m * math.sin((angle * (math.pi / 180.0)))), 2.0)
b_m = abs(b) function code(a, b_m, angle) return Float64(Float64(a * a) + (Float64(b_m * sin(Float64(angle * Float64(pi / 180.0)))) ^ 2.0)) end
b_m = abs(b); function tmp = code(a, b_m, angle) tmp = (a * a) + ((b_m * sin((angle * (pi / 180.0)))) ^ 2.0); end
b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_] := N[(N[(a * a), $MachinePrecision] + N[Power[N[(b$95$m * N[Sin[N[(angle * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
a \cdot a + {\left(b\_m \cdot \sin \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2}
\end{array}
Initial program 79.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6479.0
Applied rewrites79.0%
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
lift-PI.f6479.0
Applied rewrites79.0%
lift-/.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f6479.0
Applied rewrites79.0%
b_m = (fabs.f64 b)
(FPCore (a b_m angle)
:precision binary64
(if (<= angle 0.00135)
(+ (* a a) (* (* (pow (* angle b_m) 2.0) (* PI PI)) 3.08641975308642e-5))
(fma
(* (- 0.5 (* 0.5 (cos (* 2.0 (* (/ angle 180.0) PI))))) b_m)
b_m
(* a a))))b_m = fabs(b);
double code(double a, double b_m, double angle) {
double tmp;
if (angle <= 0.00135) {
tmp = (a * a) + ((pow((angle * b_m), 2.0) * (((double) M_PI) * ((double) M_PI))) * 3.08641975308642e-5);
} else {
tmp = fma(((0.5 - (0.5 * cos((2.0 * ((angle / 180.0) * ((double) M_PI)))))) * b_m), b_m, (a * a));
}
return tmp;
}
b_m = abs(b) function code(a, b_m, angle) tmp = 0.0 if (angle <= 0.00135) tmp = Float64(Float64(a * a) + Float64(Float64((Float64(angle * b_m) ^ 2.0) * Float64(pi * pi)) * 3.08641975308642e-5)); else tmp = fma(Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(Float64(angle / 180.0) * pi))))) * b_m), b_m, Float64(a * a)); end return tmp end
b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_] := If[LessEqual[angle, 0.00135], N[(N[(a * a), $MachinePrecision] + N[(N[(N[Power[N[(angle * b$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b$95$m), $MachinePrecision] * b$95$m + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 0.00135:\\
\;\;\;\;a \cdot a + \left({\left(angle \cdot b\_m\right)}^{2} \cdot \left(\pi \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\frac{angle}{180} \cdot \pi\right)\right)\right) \cdot b\_m, b\_m, a \cdot a\right)\\
\end{array}
\end{array}
if angle < 0.0013500000000000001Initial program 85.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6485.8
Applied rewrites85.8%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
unpow-prod-downN/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6482.1
Applied rewrites82.1%
lift-pow.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
unpow-prod-downN/A
pow-prod-downN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-PI.f64N/A
lift-PI.f6482.2
Applied rewrites82.2%
if 0.0013500000000000001 < angle Initial program 58.4%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6458.3
Applied rewrites58.3%
lift-+.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
unpow-prod-downN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
Applied rewrites58.3%
lift-pow.f64N/A
lift-sin.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-PI.f6458.3
Applied rewrites58.3%
b_m = (fabs.f64 b) (FPCore (a b_m angle) :precision binary64 (if (<= b_m 7.6e-96) (* a a) (+ (* a a) (* (* (pow (* angle b_m) 2.0) (* PI PI)) 3.08641975308642e-5))))
b_m = fabs(b);
double code(double a, double b_m, double angle) {
double tmp;
if (b_m <= 7.6e-96) {
tmp = a * a;
} else {
tmp = (a * a) + ((pow((angle * b_m), 2.0) * (((double) M_PI) * ((double) M_PI))) * 3.08641975308642e-5);
}
return tmp;
}
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle) {
double tmp;
if (b_m <= 7.6e-96) {
tmp = a * a;
} else {
tmp = (a * a) + ((Math.pow((angle * b_m), 2.0) * (Math.PI * Math.PI)) * 3.08641975308642e-5);
}
return tmp;
}
b_m = math.fabs(b) def code(a, b_m, angle): tmp = 0 if b_m <= 7.6e-96: tmp = a * a else: tmp = (a * a) + ((math.pow((angle * b_m), 2.0) * (math.pi * math.pi)) * 3.08641975308642e-5) return tmp
b_m = abs(b) function code(a, b_m, angle) tmp = 0.0 if (b_m <= 7.6e-96) tmp = Float64(a * a); else tmp = Float64(Float64(a * a) + Float64(Float64((Float64(angle * b_m) ^ 2.0) * Float64(pi * pi)) * 3.08641975308642e-5)); end return tmp end
b_m = abs(b); function tmp_2 = code(a, b_m, angle) tmp = 0.0; if (b_m <= 7.6e-96) tmp = a * a; else tmp = (a * a) + ((((angle * b_m) ^ 2.0) * (pi * pi)) * 3.08641975308642e-5); end tmp_2 = tmp; end
b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_] := If[LessEqual[b$95$m, 7.6e-96], N[(a * a), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[(N[(N[Power[N[(angle * b$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + \left({\left(angle \cdot b\_m\right)}^{2} \cdot \left(\pi \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\\
\end{array}
\end{array}
if b < 7.6000000000000001e-96Initial program 77.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6476.4
Applied rewrites76.4%
if 7.6000000000000001e-96 < b Initial program 79.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6479.9
Applied rewrites79.9%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
unpow-prod-downN/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6476.2
Applied rewrites76.2%
lift-pow.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
unpow-prod-downN/A
pow-prod-downN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-PI.f64N/A
lift-PI.f6476.3
Applied rewrites76.3%
b_m = (fabs.f64 b) (FPCore (a b_m angle) :precision binary64 (if (<= b_m 7.6e-96) (* a a) (+ (* a a) (pow (* (* (* 0.005555555555555556 b_m) PI) angle) 2.0))))
b_m = fabs(b);
double code(double a, double b_m, double angle) {
double tmp;
if (b_m <= 7.6e-96) {
tmp = a * a;
} else {
tmp = (a * a) + pow((((0.005555555555555556 * b_m) * ((double) M_PI)) * angle), 2.0);
}
return tmp;
}
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle) {
double tmp;
if (b_m <= 7.6e-96) {
tmp = a * a;
} else {
tmp = (a * a) + Math.pow((((0.005555555555555556 * b_m) * Math.PI) * angle), 2.0);
}
return tmp;
}
b_m = math.fabs(b) def code(a, b_m, angle): tmp = 0 if b_m <= 7.6e-96: tmp = a * a else: tmp = (a * a) + math.pow((((0.005555555555555556 * b_m) * math.pi) * angle), 2.0) return tmp
b_m = abs(b) function code(a, b_m, angle) tmp = 0.0 if (b_m <= 7.6e-96) tmp = Float64(a * a); else tmp = Float64(Float64(a * a) + (Float64(Float64(Float64(0.005555555555555556 * b_m) * pi) * angle) ^ 2.0)); end return tmp end
b_m = abs(b); function tmp_2 = code(a, b_m, angle) tmp = 0.0; if (b_m <= 7.6e-96) tmp = a * a; else tmp = (a * a) + ((((0.005555555555555556 * b_m) * pi) * angle) ^ 2.0); end tmp_2 = tmp; end
b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_] := If[LessEqual[b$95$m, 7.6e-96], N[(a * a), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[Power[N[(N[(N[(0.005555555555555556 * b$95$m), $MachinePrecision] * Pi), $MachinePrecision] * angle), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + {\left(\left(\left(0.005555555555555556 \cdot b\_m\right) \cdot \pi\right) \cdot angle\right)}^{2}\\
\end{array}
\end{array}
if b < 7.6000000000000001e-96Initial program 77.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6476.4
Applied rewrites76.4%
if 7.6000000000000001e-96 < b Initial program 79.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6479.9
Applied rewrites79.9%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.5%
Taylor expanded in angle around 0
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-PI.f6476.4
Applied rewrites76.4%
b_m = (fabs.f64 b)
(FPCore (a b_m angle)
:precision binary64
(let* ((t_0 (* (* b_m PI) angle)))
(if (<= b_m 7.6e-96)
(* a a)
(+ (* a a) (* (* t_0 t_0) 3.08641975308642e-5)))))b_m = fabs(b);
double code(double a, double b_m, double angle) {
double t_0 = (b_m * ((double) M_PI)) * angle;
double tmp;
if (b_m <= 7.6e-96) {
tmp = a * a;
} else {
tmp = (a * a) + ((t_0 * t_0) * 3.08641975308642e-5);
}
return tmp;
}
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle) {
double t_0 = (b_m * Math.PI) * angle;
double tmp;
if (b_m <= 7.6e-96) {
tmp = a * a;
} else {
tmp = (a * a) + ((t_0 * t_0) * 3.08641975308642e-5);
}
return tmp;
}
b_m = math.fabs(b) def code(a, b_m, angle): t_0 = (b_m * math.pi) * angle tmp = 0 if b_m <= 7.6e-96: tmp = a * a else: tmp = (a * a) + ((t_0 * t_0) * 3.08641975308642e-5) return tmp
b_m = abs(b) function code(a, b_m, angle) t_0 = Float64(Float64(b_m * pi) * angle) tmp = 0.0 if (b_m <= 7.6e-96) tmp = Float64(a * a); else tmp = Float64(Float64(a * a) + Float64(Float64(t_0 * t_0) * 3.08641975308642e-5)); end return tmp end
b_m = abs(b); function tmp_2 = code(a, b_m, angle) t_0 = (b_m * pi) * angle; tmp = 0.0; if (b_m <= 7.6e-96) tmp = a * a; else tmp = (a * a) + ((t_0 * t_0) * 3.08641975308642e-5); end tmp_2 = tmp; end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_, angle_] := Block[{t$95$0 = N[(N[(b$95$m * Pi), $MachinePrecision] * angle), $MachinePrecision]}, If[LessEqual[b$95$m, 7.6e-96], N[(a * a), $MachinePrecision], N[(N[(a * a), $MachinePrecision] + N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
t_0 := \left(b\_m \cdot \pi\right) \cdot angle\\
\mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;a \cdot a + \left(t\_0 \cdot t\_0\right) \cdot 3.08641975308642 \cdot 10^{-5}\\
\end{array}
\end{array}
if b < 7.6000000000000001e-96Initial program 77.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6476.4
Applied rewrites76.4%
if 7.6000000000000001e-96 < b Initial program 79.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6479.9
Applied rewrites79.9%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
unpow-prod-downN/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6476.2
Applied rewrites76.2%
lift-pow.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f6476.2
Applied rewrites76.2%
b_m = (fabs.f64 b)
(FPCore (a b_m angle)
:precision binary64
(if (<= b_m 7.6e-96)
(* a a)
(fma
(* (* (* (* angle angle) b_m) (* PI PI)) 3.08641975308642e-5)
b_m
(* a a))))b_m = fabs(b);
double code(double a, double b_m, double angle) {
double tmp;
if (b_m <= 7.6e-96) {
tmp = a * a;
} else {
tmp = fma(((((angle * angle) * b_m) * (((double) M_PI) * ((double) M_PI))) * 3.08641975308642e-5), b_m, (a * a));
}
return tmp;
}
b_m = abs(b) function code(a, b_m, angle) tmp = 0.0 if (b_m <= 7.6e-96) tmp = Float64(a * a); else tmp = fma(Float64(Float64(Float64(Float64(angle * angle) * b_m) * Float64(pi * pi)) * 3.08641975308642e-5), b_m, Float64(a * a)); end return tmp end
b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_] := If[LessEqual[b$95$m, 7.6e-96], N[(a * a), $MachinePrecision], N[(N[(N[(N[(N[(angle * angle), $MachinePrecision] * b$95$m), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision] * b$95$m + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\left(angle \cdot angle\right) \cdot b\_m\right) \cdot \left(\pi \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}, b\_m, a \cdot a\right)\\
\end{array}
\end{array}
if b < 7.6000000000000001e-96Initial program 77.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6476.4
Applied rewrites76.4%
if 7.6000000000000001e-96 < b Initial program 79.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6479.9
Applied rewrites79.9%
lift-+.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
unpow-prod-downN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
Applied rewrites74.1%
Taylor expanded in angle around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-PI.f64N/A
lift-PI.f6470.5
Applied rewrites70.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*l*N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.6%
b_m = (fabs.f64 b)
(FPCore (a b_m angle)
:precision binary64
(if (<= b_m 7.6e-96)
(* a a)
(fma
(* (* (* PI PI) b_m) (* (* 3.08641975308642e-5 angle) angle))
b_m
(* a a))))b_m = fabs(b);
double code(double a, double b_m, double angle) {
double tmp;
if (b_m <= 7.6e-96) {
tmp = a * a;
} else {
tmp = fma((((((double) M_PI) * ((double) M_PI)) * b_m) * ((3.08641975308642e-5 * angle) * angle)), b_m, (a * a));
}
return tmp;
}
b_m = abs(b) function code(a, b_m, angle) tmp = 0.0 if (b_m <= 7.6e-96) tmp = Float64(a * a); else tmp = fma(Float64(Float64(Float64(pi * pi) * b_m) * Float64(Float64(3.08641975308642e-5 * angle) * angle)), b_m, Float64(a * a)); end return tmp end
b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_] := If[LessEqual[b$95$m, 7.6e-96], N[(a * a), $MachinePrecision], N[(N[(N[(N[(Pi * Pi), $MachinePrecision] * b$95$m), $MachinePrecision] * N[(N[(3.08641975308642e-5 * angle), $MachinePrecision] * angle), $MachinePrecision]), $MachinePrecision] * b$95$m + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\pi \cdot \pi\right) \cdot b\_m\right) \cdot \left(\left(3.08641975308642 \cdot 10^{-5} \cdot angle\right) \cdot angle\right), b\_m, a \cdot a\right)\\
\end{array}
\end{array}
if b < 7.6000000000000001e-96Initial program 77.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6476.4
Applied rewrites76.4%
if 7.6000000000000001e-96 < b Initial program 79.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6479.9
Applied rewrites79.9%
lift-+.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
unpow-prod-downN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
Applied rewrites74.1%
Taylor expanded in angle around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-PI.f64N/A
lift-PI.f6470.5
Applied rewrites70.5%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lift-*.f6470.5
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6470.5
Applied rewrites70.5%
b_m = (fabs.f64 b)
(FPCore (a b_m angle)
:precision binary64
(if (<= b_m 7.6e-96)
(* a a)
(fma
(* (* 3.08641975308642e-5 (* angle angle)) (* (* PI PI) b_m))
b_m
(* a a))))b_m = fabs(b);
double code(double a, double b_m, double angle) {
double tmp;
if (b_m <= 7.6e-96) {
tmp = a * a;
} else {
tmp = fma(((3.08641975308642e-5 * (angle * angle)) * ((((double) M_PI) * ((double) M_PI)) * b_m)), b_m, (a * a));
}
return tmp;
}
b_m = abs(b) function code(a, b_m, angle) tmp = 0.0 if (b_m <= 7.6e-96) tmp = Float64(a * a); else tmp = fma(Float64(Float64(3.08641975308642e-5 * Float64(angle * angle)) * Float64(Float64(pi * pi) * b_m)), b_m, Float64(a * a)); end return tmp end
b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_] := If[LessEqual[b$95$m, 7.6e-96], N[(a * a), $MachinePrecision], N[(N[(N[(3.08641975308642e-5 * N[(angle * angle), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * b$95$m), $MachinePrecision]), $MachinePrecision] * b$95$m + N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|
\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 7.6 \cdot 10^{-96}:\\
\;\;\;\;a \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot angle\right)\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot b\_m\right), b\_m, a \cdot a\right)\\
\end{array}
\end{array}
if b < 7.6000000000000001e-96Initial program 77.6%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6476.4
Applied rewrites76.4%
if 7.6000000000000001e-96 < b Initial program 79.9%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6479.9
Applied rewrites79.9%
lift-+.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
unpow-prod-downN/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
Applied rewrites74.1%
Taylor expanded in angle around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-PI.f64N/A
lift-PI.f6470.5
Applied rewrites70.5%
b_m = (fabs.f64 b) (FPCore (a b_m angle) :precision binary64 (* a a))
b_m = fabs(b);
double code(double a, double b_m, double angle) {
return a * a;
}
b_m = private
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_m, angle)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: angle
code = a * a
end function
b_m = Math.abs(b);
public static double code(double a, double b_m, double angle) {
return a * a;
}
b_m = math.fabs(b) def code(a, b_m, angle): return a * a
b_m = abs(b) function code(a, b_m, angle) return Float64(a * a) end
b_m = abs(b); function tmp = code(a, b_m, angle) tmp = a * a; end
b_m = N[Abs[b], $MachinePrecision] code[a_, b$95$m_, angle_] := N[(a * a), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
a \cdot a
\end{array}
Initial program 79.1%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6457.1
Applied rewrites57.1%
herbie shell --seed 2025089
(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)))