
(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}
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}
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (/ angle 180.0) PI))) (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * ((double) M_PI);
return pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = (angle / 180.0) * Math.PI;
return Math.pow((a * Math.sin(t_0)), 2.0) + Math.pow((b * Math.cos(t_0)), 2.0);
}
def code(a, b, angle): t_0 = (angle / 180.0) * math.pi return math.pow((a * math.sin(t_0)), 2.0) + math.pow((b * math.cos(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(Float64(angle / 180.0) * pi) return Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = (angle / 180.0) * pi; tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[Power[N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
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}
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (/ (fabs angle) 180.0) PI))) 2.0) (pow (* b (sin (fma (* 0.005555555555555556 PI) (fabs angle) (* 0.5 PI)))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(((fabs(angle) / 180.0) * ((double) M_PI)))), 2.0) + pow((b * sin(fma((0.005555555555555556 * ((double) M_PI)), fabs(angle), (0.5 * ((double) M_PI))))), 2.0);
}
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(abs(angle) / 180.0) * pi))) ^ 2.0) + (Float64(b * sin(fma(Float64(0.005555555555555556 * pi), abs(angle), Float64(0.5 * pi)))) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(N[Abs[angle], $MachinePrecision] / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(N[(0.005555555555555556 * Pi), $MachinePrecision] * N[Abs[angle], $MachinePrecision] + N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
{\left(a \cdot \sin \left(\frac{\left|angle\right|}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{fma}\left(0.005555555555555556 \cdot \pi, \left|angle\right|, 0.5 \cdot \pi\right)\right)\right)}^{2}
Initial program 80.5%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
mult-flipN/A
distribute-lft-outN/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
metadata-eval80.4%
Applied rewrites80.4%
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-inN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
mult-flipN/A
lift-PI.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6480.4%
Applied rewrites80.4%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (/ (fabs angle) 180.0) PI))) 2.0) (pow (* b (sin (* PI (/ (+ 90.0 (fabs angle)) 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(((fabs(angle) / 180.0) * ((double) M_PI)))), 2.0) + pow((b * sin((((double) M_PI) * ((90.0 + fabs(angle)) / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin(((Math.abs(angle) / 180.0) * Math.PI))), 2.0) + Math.pow((b * Math.sin((Math.PI * ((90.0 + Math.abs(angle)) / 180.0)))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin(((math.fabs(angle) / 180.0) * math.pi))), 2.0) + math.pow((b * math.sin((math.pi * ((90.0 + math.fabs(angle)) / 180.0)))), 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(abs(angle) / 180.0) * pi))) ^ 2.0) + (Float64(b * sin(Float64(pi * Float64(Float64(90.0 + abs(angle)) / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin(((abs(angle) / 180.0) * pi))) ^ 2.0) + ((b * sin((pi * ((90.0 + abs(angle)) / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(N[Abs[angle], $MachinePrecision] / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(N[(90.0 + N[Abs[angle], $MachinePrecision]), $MachinePrecision] / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
{\left(a \cdot \sin \left(\frac{\left|angle\right|}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{90 + \left|angle\right|}{180}\right)\right)}^{2}
Initial program 80.5%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
mult-flipN/A
distribute-lft-outN/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
metadata-eval80.4%
Applied rewrites80.4%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
metadata-evalN/A
associate-/r/N/A
div-flip-revN/A
add-to-fractionN/A
lower-/.f64N/A
lower-+.f64N/A
metadata-eval80.4%
Applied rewrites80.4%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (* angle 0.005555555555555556) 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 * 0.005555555555555556) * ((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 * 0.005555555555555556) * 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 * 0.005555555555555556) * 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 * 0.005555555555555556) * 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 * 0.005555555555555556) * 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 * 0.005555555555555556), $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}
t_0 := \left(angle \cdot 0.005555555555555556\right) \cdot \pi\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
Initial program 80.5%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval80.5%
Applied rewrites80.5%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval80.5%
Applied rewrites80.5%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (* 0.005555555555555556 PI) angle))) (+ (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 * ((double) M_PI)) * angle;
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 * Math.PI) * angle;
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 * math.pi) * angle 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(0.005555555555555556 * pi) * angle) 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 * pi) * angle; tmp = ((a * sin(t_0)) ^ 2.0) + ((b * cos(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(0.005555555555555556 * Pi), $MachinePrecision] * angle), $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}
t_0 := \left(0.005555555555555556 \cdot \pi\right) \cdot angle\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
Initial program 80.5%
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval80.5%
Applied rewrites80.5%
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval80.5%
Applied rewrites80.5%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (/ 1.0 (/ 180.0 angle)) PI))) 2.0) (pow (* b 1.0) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(((1.0 / (180.0 / 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(((1.0 / (180.0 / angle)) * Math.PI))), 2.0) + Math.pow((b * 1.0), 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin(((1.0 / (180.0 / angle)) * math.pi))), 2.0) + math.pow((b * 1.0), 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(1.0 / Float64(180.0 / angle)) * pi))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin(((1.0 / (180.0 / angle)) * pi))) ^ 2.0) + ((b * 1.0) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(1.0 / N[(180.0 / angle), $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
{\left(a \cdot \sin \left(\frac{1}{\frac{180}{angle}} \cdot \pi\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}
Initial program 80.5%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6480.4%
Applied rewrites80.4%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6480.4%
Applied rewrites80.4%
Taylor expanded in angle around 0
Applied rewrites80.3%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (/ angle 180.0) PI))) 2.0) (pow b 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(((angle / 180.0) * ((double) M_PI)))), 2.0) + pow(b, 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, 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin(((angle / 180.0) * math.pi))), 2.0) + math.pow(b, 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(angle / 180.0) * pi))) ^ 2.0) + (b ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin(((angle / 180.0) * pi))) ^ 2.0) + (b ^ 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[b, 2.0], $MachinePrecision]), $MachinePrecision]
{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {b}^{2}
Initial program 80.5%
Taylor expanded in angle around 0
lower-pow.f6480.4%
Applied rewrites80.4%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (fabs b) (fabs b))))
(if (<= (fabs b) 1.4e+77)
(fma
(fabs b)
(fabs b)
(*
(*
(fma t_0 -3.08641975308642e-5 (* 3.08641975308642e-5 (* a a)))
(* (* PI PI) (fabs angle)))
(fabs angle)))
(*
t_0
(-
0.5
(*
0.5
(cos
(*
2.0
(* (fma 0.005555555555555556 (fabs angle) 0.5) PI)))))))))double code(double a, double b, double angle) {
double t_0 = fabs(b) * fabs(b);
double tmp;
if (fabs(b) <= 1.4e+77) {
tmp = fma(fabs(b), fabs(b), ((fma(t_0, -3.08641975308642e-5, (3.08641975308642e-5 * (a * a))) * ((((double) M_PI) * ((double) M_PI)) * fabs(angle))) * fabs(angle)));
} else {
tmp = t_0 * (0.5 - (0.5 * cos((2.0 * (fma(0.005555555555555556, fabs(angle), 0.5) * ((double) M_PI))))));
}
return tmp;
}
function code(a, b, angle) t_0 = Float64(abs(b) * abs(b)) tmp = 0.0 if (abs(b) <= 1.4e+77) tmp = fma(abs(b), abs(b), Float64(Float64(fma(t_0, -3.08641975308642e-5, Float64(3.08641975308642e-5 * Float64(a * a))) * Float64(Float64(pi * pi) * abs(angle))) * abs(angle))); else tmp = Float64(t_0 * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(fma(0.005555555555555556, abs(angle), 0.5) * pi)))))); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[Abs[b], $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[b], $MachinePrecision], 1.4e+77], N[(N[Abs[b], $MachinePrecision] * N[Abs[b], $MachinePrecision] + N[(N[(N[(t$95$0 * -3.08641975308642e-5 + N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(N[(0.005555555555555556 * N[Abs[angle], $MachinePrecision] + 0.5), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \left|b\right| \cdot \left|b\right|\\
\mathbf{if}\;\left|b\right| \leq 1.4 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(\left|b\right|, \left|b\right|, \left(\mathsf{fma}\left(t\_0, -3.08641975308642 \cdot 10^{-5}, 3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot \left|angle\right|\right)\right) \cdot \left|angle\right|\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\mathsf{fma}\left(0.005555555555555556, \left|angle\right|, 0.5\right) \cdot \pi\right)\right)\right)\\
\end{array}
if b < 1.4e77Initial program 80.5%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites41.5%
lift-fma.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6441.5%
Applied rewrites41.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6443.9%
Applied rewrites43.9%
if 1.4e77 < b Initial program 80.5%
Taylor expanded in a around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6457.6%
Applied rewrites57.6%
lift-pow.f64N/A
unpow2N/A
lower-*.f6457.6%
Applied rewrites57.6%
Applied rewrites57.6%
(FPCore (a b angle)
:precision binary64
(if (<= (fabs b) 1.4e+77)
(fma
(fabs b)
(fabs b)
(*
(*
(fma
(* (fabs b) (fabs b))
-3.08641975308642e-5
(* 3.08641975308642e-5 (* a a)))
(* (* PI PI) (fabs angle)))
(fabs angle)))
(*
(pow (fabs b) 2.0)
(pow
(sin (* PI (+ 0.5 (* 0.005555555555555556 (fabs angle)))))
2.0))))double code(double a, double b, double angle) {
double tmp;
if (fabs(b) <= 1.4e+77) {
tmp = fma(fabs(b), fabs(b), ((fma((fabs(b) * fabs(b)), -3.08641975308642e-5, (3.08641975308642e-5 * (a * a))) * ((((double) M_PI) * ((double) M_PI)) * fabs(angle))) * fabs(angle)));
} else {
tmp = pow(fabs(b), 2.0) * pow(sin((((double) M_PI) * (0.5 + (0.005555555555555556 * fabs(angle))))), 2.0);
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (abs(b) <= 1.4e+77) tmp = fma(abs(b), abs(b), Float64(Float64(fma(Float64(abs(b) * abs(b)), -3.08641975308642e-5, Float64(3.08641975308642e-5 * Float64(a * a))) * Float64(Float64(pi * pi) * abs(angle))) * abs(angle))); else tmp = Float64((abs(b) ^ 2.0) * (sin(Float64(pi * Float64(0.5 + Float64(0.005555555555555556 * abs(angle))))) ^ 2.0)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[Abs[b], $MachinePrecision], 1.4e+77], N[(N[Abs[b], $MachinePrecision] * N[Abs[b], $MachinePrecision] + N[(N[(N[(N[(N[Abs[b], $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision] * -3.08641975308642e-5 + N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Abs[b], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[N[Sin[N[(Pi * N[(0.5 + N[(0.005555555555555556 * N[Abs[angle], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|b\right| \leq 1.4 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(\left|b\right|, \left|b\right|, \left(\mathsf{fma}\left(\left|b\right| \cdot \left|b\right|, -3.08641975308642 \cdot 10^{-5}, 3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot \left|angle\right|\right)\right) \cdot \left|angle\right|\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\left|b\right|\right)}^{2} \cdot {\sin \left(\pi \cdot \left(0.5 + 0.005555555555555556 \cdot \left|angle\right|\right)\right)}^{2}\\
\end{array}
if b < 1.4e77Initial program 80.5%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites41.5%
lift-fma.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6441.5%
Applied rewrites41.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6443.9%
Applied rewrites43.9%
if 1.4e77 < b Initial program 80.5%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
mult-flipN/A
distribute-lft-outN/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
metadata-eval80.4%
Applied rewrites80.4%
Taylor expanded in a around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-+.f64N/A
lower-*.f6457.6%
Applied rewrites57.6%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (fabs b) (fabs b))))
(if (<= (fabs b) 1.4e+77)
(fma
(fabs b)
(fabs b)
(*
(*
(fma t_0 -3.08641975308642e-5 (* 3.08641975308642e-5 (* a a)))
(* (* PI PI) angle))
angle))
(*
t_0
(+
0.5
(* 0.5 (cos (* 2.0 (* (* PI angle) 0.005555555555555556)))))))))double code(double a, double b, double angle) {
double t_0 = fabs(b) * fabs(b);
double tmp;
if (fabs(b) <= 1.4e+77) {
tmp = fma(fabs(b), fabs(b), ((fma(t_0, -3.08641975308642e-5, (3.08641975308642e-5 * (a * a))) * ((((double) M_PI) * ((double) M_PI)) * angle)) * angle));
} else {
tmp = t_0 * (0.5 + (0.5 * cos((2.0 * ((((double) M_PI) * angle) * 0.005555555555555556)))));
}
return tmp;
}
function code(a, b, angle) t_0 = Float64(abs(b) * abs(b)) tmp = 0.0 if (abs(b) <= 1.4e+77) tmp = fma(abs(b), abs(b), Float64(Float64(fma(t_0, -3.08641975308642e-5, Float64(3.08641975308642e-5 * Float64(a * a))) * Float64(Float64(pi * pi) * angle)) * angle)); else tmp = Float64(t_0 * Float64(0.5 + Float64(0.5 * cos(Float64(2.0 * Float64(Float64(pi * angle) * 0.005555555555555556)))))); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[Abs[b], $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[b], $MachinePrecision], 1.4e+77], N[(N[Abs[b], $MachinePrecision] * N[Abs[b], $MachinePrecision] + N[(N[(N[(t$95$0 * -3.08641975308642e-5 + N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * angle), $MachinePrecision]), $MachinePrecision] * angle), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(0.5 + N[(0.5 * N[Cos[N[(2.0 * N[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \left|b\right| \cdot \left|b\right|\\
\mathbf{if}\;\left|b\right| \leq 1.4 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(\left|b\right|, \left|b\right|, \left(\mathsf{fma}\left(t\_0, -3.08641975308642 \cdot 10^{-5}, 3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot angle\right)\right) \cdot angle\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)\right)\right)\\
\end{array}
if b < 1.4e77Initial program 80.5%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites41.5%
lift-fma.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6441.5%
Applied rewrites41.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6443.9%
Applied rewrites43.9%
if 1.4e77 < b Initial program 80.5%
Taylor expanded in a around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6457.6%
Applied rewrites57.6%
lift-pow.f64N/A
unpow2N/A
lower-*.f6457.6%
Applied rewrites57.6%
Applied rewrites57.6%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (fabs b) (fabs b))))
(if (<= (fabs b) 1.4e+77)
(fma
(fabs b)
(fabs b)
(*
(*
(fma t_0 -3.08641975308642e-5 (* 3.08641975308642e-5 (* a a)))
(* (* PI PI) angle))
angle))
(* t_0 (pow 1.0 2.0)))))double code(double a, double b, double angle) {
double t_0 = fabs(b) * fabs(b);
double tmp;
if (fabs(b) <= 1.4e+77) {
tmp = fma(fabs(b), fabs(b), ((fma(t_0, -3.08641975308642e-5, (3.08641975308642e-5 * (a * a))) * ((((double) M_PI) * ((double) M_PI)) * angle)) * angle));
} else {
tmp = t_0 * pow(1.0, 2.0);
}
return tmp;
}
function code(a, b, angle) t_0 = Float64(abs(b) * abs(b)) tmp = 0.0 if (abs(b) <= 1.4e+77) tmp = fma(abs(b), abs(b), Float64(Float64(fma(t_0, -3.08641975308642e-5, Float64(3.08641975308642e-5 * Float64(a * a))) * Float64(Float64(pi * pi) * angle)) * angle)); else tmp = Float64(t_0 * (1.0 ^ 2.0)); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[Abs[b], $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[b], $MachinePrecision], 1.4e+77], N[(N[Abs[b], $MachinePrecision] * N[Abs[b], $MachinePrecision] + N[(N[(N[(t$95$0 * -3.08641975308642e-5 + N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * angle), $MachinePrecision]), $MachinePrecision] * angle), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Power[1.0, 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \left|b\right| \cdot \left|b\right|\\
\mathbf{if}\;\left|b\right| \leq 1.4 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(\left|b\right|, \left|b\right|, \left(\mathsf{fma}\left(t\_0, -3.08641975308642 \cdot 10^{-5}, 3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot angle\right)\right) \cdot angle\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot {1}^{2}\\
\end{array}
if b < 1.4e77Initial program 80.5%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites41.5%
lift-fma.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6441.5%
Applied rewrites41.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6443.9%
Applied rewrites43.9%
if 1.4e77 < b Initial program 80.5%
Taylor expanded in a around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6457.6%
Applied rewrites57.6%
lift-pow.f64N/A
unpow2N/A
lower-*.f6457.6%
Applied rewrites57.6%
Taylor expanded in angle around 0
Applied rewrites57.7%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (fabs b) (fabs b))))
(if (<= (fabs b) 1.4e+77)
(fma
(*
(*
(fma t_0 -3.08641975308642e-5 (* 3.08641975308642e-5 (* a a)))
angle)
angle)
9.869604401089358
t_0)
(* t_0 (pow 1.0 2.0)))))double code(double a, double b, double angle) {
double t_0 = fabs(b) * fabs(b);
double tmp;
if (fabs(b) <= 1.4e+77) {
tmp = fma(((fma(t_0, -3.08641975308642e-5, (3.08641975308642e-5 * (a * a))) * angle) * angle), 9.869604401089358, t_0);
} else {
tmp = t_0 * pow(1.0, 2.0);
}
return tmp;
}
function code(a, b, angle) t_0 = Float64(abs(b) * abs(b)) tmp = 0.0 if (abs(b) <= 1.4e+77) tmp = fma(Float64(Float64(fma(t_0, -3.08641975308642e-5, Float64(3.08641975308642e-5 * Float64(a * a))) * angle) * angle), 9.869604401089358, t_0); else tmp = Float64(t_0 * (1.0 ^ 2.0)); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[Abs[b], $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[b], $MachinePrecision], 1.4e+77], N[(N[(N[(N[(t$95$0 * -3.08641975308642e-5 + N[(3.08641975308642e-5 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * angle), $MachinePrecision] * angle), $MachinePrecision] * 9.869604401089358 + t$95$0), $MachinePrecision], N[(t$95$0 * N[Power[1.0, 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \left|b\right| \cdot \left|b\right|\\
\mathbf{if}\;\left|b\right| \leq 1.4 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(t\_0, -3.08641975308642 \cdot 10^{-5}, 3.08641975308642 \cdot 10^{-5} \cdot \left(a \cdot a\right)\right) \cdot angle\right) \cdot angle, 9.869604401089358, t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot {1}^{2}\\
\end{array}
if b < 1.4e77Initial program 80.5%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites41.5%
lift-fma.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6441.5%
Applied rewrites41.5%
Evaluated real constant41.5%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites43.9%
if 1.4e77 < b Initial program 80.5%
Taylor expanded in a around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6457.6%
Applied rewrites57.6%
lift-pow.f64N/A
unpow2N/A
lower-*.f6457.6%
Applied rewrites57.6%
Taylor expanded in angle around 0
Applied rewrites57.7%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (fabs b) (fabs b))))
(if (<= (fabs b) 1.4e+77)
(fma
(fabs b)
(fabs b)
(*
(*
(fma
0.00030461741978670857
(* a a)
(* -0.00030461741978670857 t_0))
angle)
angle))
(* t_0 (pow 1.0 2.0)))))double code(double a, double b, double angle) {
double t_0 = fabs(b) * fabs(b);
double tmp;
if (fabs(b) <= 1.4e+77) {
tmp = fma(fabs(b), fabs(b), ((fma(0.00030461741978670857, (a * a), (-0.00030461741978670857 * t_0)) * angle) * angle));
} else {
tmp = t_0 * pow(1.0, 2.0);
}
return tmp;
}
function code(a, b, angle) t_0 = Float64(abs(b) * abs(b)) tmp = 0.0 if (abs(b) <= 1.4e+77) tmp = fma(abs(b), abs(b), Float64(Float64(fma(0.00030461741978670857, Float64(a * a), Float64(-0.00030461741978670857 * t_0)) * angle) * angle)); else tmp = Float64(t_0 * (1.0 ^ 2.0)); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[Abs[b], $MachinePrecision] * N[Abs[b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[b], $MachinePrecision], 1.4e+77], N[(N[Abs[b], $MachinePrecision] * N[Abs[b], $MachinePrecision] + N[(N[(N[(0.00030461741978670857 * N[(a * a), $MachinePrecision] + N[(-0.00030461741978670857 * t$95$0), $MachinePrecision]), $MachinePrecision] * angle), $MachinePrecision] * angle), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Power[1.0, 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \left|b\right| \cdot \left|b\right|\\
\mathbf{if}\;\left|b\right| \leq 1.4 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(\left|b\right|, \left|b\right|, \left(\mathsf{fma}\left(0.00030461741978670857, a \cdot a, -0.00030461741978670857 \cdot t\_0\right) \cdot angle\right) \cdot angle\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot {1}^{2}\\
\end{array}
if b < 1.4e77Initial program 80.5%
Taylor expanded in angle around 0
lower-fma.f64N/A
Applied rewrites41.5%
lift-fma.f64N/A
+-commutativeN/A
lift-pow.f64N/A
unpow2N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6441.5%
Applied rewrites41.5%
Evaluated real constant41.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites43.9%
if 1.4e77 < b Initial program 80.5%
Taylor expanded in a around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6457.6%
Applied rewrites57.6%
lift-pow.f64N/A
unpow2N/A
lower-*.f6457.6%
Applied rewrites57.6%
Taylor expanded in angle around 0
Applied rewrites57.7%
(FPCore (a b angle) :precision binary64 (* (* b b) (pow 1.0 2.0)))
double code(double a, double b, double angle) {
return (b * b) * pow(1.0, 2.0);
}
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) * (1.0d0 ** 2.0d0)
end function
public static double code(double a, double b, double angle) {
return (b * b) * Math.pow(1.0, 2.0);
}
def code(a, b, angle): return (b * b) * math.pow(1.0, 2.0)
function code(a, b, angle) return Float64(Float64(b * b) * (1.0 ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (b * b) * (1.0 ^ 2.0); end
code[a_, b_, angle_] := N[(N[(b * b), $MachinePrecision] * N[Power[1.0, 2.0], $MachinePrecision]), $MachinePrecision]
\left(b \cdot b\right) \cdot {1}^{2}
Initial program 80.5%
Taylor expanded in a around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6457.6%
Applied rewrites57.6%
lift-pow.f64N/A
unpow2N/A
lower-*.f6457.6%
Applied rewrites57.6%
Taylor expanded in angle around 0
Applied rewrites57.7%
herbie shell --seed 2025212
(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)))