
(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 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}
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 (let* ((t_0 (* (/ 0.005555555555555556 (/ 1.0 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 / (1.0 / 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 / (1.0 / 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 / (1.0 / 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(Float64(0.005555555555555556 / Float64(1.0 / 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 / (1.0 / 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[(N[(0.005555555555555556 / N[(1.0 / angle), $MachinePrecision]), $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{0.005555555555555556}{\frac{1}{angle}} \cdot \pi\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
Initial program 80.2%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval80.2%
Applied rewrites80.2%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval80.2%
Applied rewrites80.2%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
associate-/r/N/A
mult-flipN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6480.2%
Applied rewrites80.2%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
associate-/r/N/A
mult-flipN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6480.2%
Applied rewrites80.2%
(FPCore (a b angle)
:precision binary64
(+
(pow
(*
a
(sin
(*
(/
0.005555555555555556
(+ (/ 0.6666666666666666 angle) (/ 0.3333333333333333 angle)))
PI)))
2.0)
(*
(*
(-
0.5
(*
0.5
(cos (* 2.0 (* PI (+ (* angle 0.005555555555555556) 0.5))))))
b)
b)))double code(double a, double b, double angle) {
return pow((a * sin(((0.005555555555555556 / ((0.6666666666666666 / angle) + (0.3333333333333333 / angle))) * ((double) M_PI)))), 2.0) + (((0.5 - (0.5 * cos((2.0 * (((double) M_PI) * ((angle * 0.005555555555555556) + 0.5)))))) * b) * b);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin(((0.005555555555555556 / ((0.6666666666666666 / angle) + (0.3333333333333333 / angle))) * Math.PI))), 2.0) + (((0.5 - (0.5 * Math.cos((2.0 * (Math.PI * ((angle * 0.005555555555555556) + 0.5)))))) * b) * b);
}
def code(a, b, angle): return math.pow((a * math.sin(((0.005555555555555556 / ((0.6666666666666666 / angle) + (0.3333333333333333 / angle))) * math.pi))), 2.0) + (((0.5 - (0.5 * math.cos((2.0 * (math.pi * ((angle * 0.005555555555555556) + 0.5)))))) * b) * b)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(0.005555555555555556 / Float64(Float64(0.6666666666666666 / angle) + Float64(0.3333333333333333 / angle))) * pi))) ^ 2.0) + Float64(Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(pi * Float64(Float64(angle * 0.005555555555555556) + 0.5)))))) * b) * b)) end
function tmp = code(a, b, angle) tmp = ((a * sin(((0.005555555555555556 / ((0.6666666666666666 / angle) + (0.3333333333333333 / angle))) * pi))) ^ 2.0) + (((0.5 - (0.5 * cos((2.0 * (pi * ((angle * 0.005555555555555556) + 0.5)))))) * b) * b); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(0.005555555555555556 / N[(N[(0.6666666666666666 / angle), $MachinePrecision] + N[(0.3333333333333333 / angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(Pi * N[(N[(angle * 0.005555555555555556), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
{\left(a \cdot \sin \left(\frac{0.005555555555555556}{\frac{0.6666666666666666}{angle} + \frac{0.3333333333333333}{angle}} \cdot \pi\right)\right)}^{2} + \left(\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot \left(angle \cdot 0.005555555555555556 + 0.5\right)\right)\right)\right) \cdot b\right) \cdot b
Initial program 80.2%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval80.2%
Applied rewrites80.2%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval80.2%
Applied rewrites80.2%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
associate-/r/N/A
mult-flipN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6480.2%
Applied rewrites80.2%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
associate-/r/N/A
mult-flipN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6480.2%
Applied rewrites80.2%
lift-/.f64N/A
metadata-evalN/A
div-addN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6480.2%
Applied rewrites80.2%
lift-/.f64N/A
metadata-evalN/A
div-addN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6480.2%
Applied rewrites80.2%
Applied rewrites80.2%
(FPCore (a b angle) :precision binary64 (+ (* (* (+ 0.5 (* 0.5 (cos (* (* PI angle) 0.011111111111111112)))) b) b) (* (- (* (sin (* (* -0.005555555555555556 angle) PI)) a)) (* (sin (* PI (* 0.005555555555555556 angle))) a))))
double code(double a, double b, double angle) {
return (((0.5 + (0.5 * cos(((((double) M_PI) * angle) * 0.011111111111111112)))) * b) * b) + (-(sin(((-0.005555555555555556 * angle) * ((double) M_PI))) * a) * (sin((((double) M_PI) * (0.005555555555555556 * angle))) * a));
}
public static double code(double a, double b, double angle) {
return (((0.5 + (0.5 * Math.cos(((Math.PI * angle) * 0.011111111111111112)))) * b) * b) + (-(Math.sin(((-0.005555555555555556 * angle) * Math.PI)) * a) * (Math.sin((Math.PI * (0.005555555555555556 * angle))) * a));
}
def code(a, b, angle): return (((0.5 + (0.5 * math.cos(((math.pi * angle) * 0.011111111111111112)))) * b) * b) + (-(math.sin(((-0.005555555555555556 * angle) * math.pi)) * a) * (math.sin((math.pi * (0.005555555555555556 * angle))) * a))
function code(a, b, angle) return Float64(Float64(Float64(Float64(0.5 + Float64(0.5 * cos(Float64(Float64(pi * angle) * 0.011111111111111112)))) * b) * b) + Float64(Float64(-Float64(sin(Float64(Float64(-0.005555555555555556 * angle) * pi)) * a)) * Float64(sin(Float64(pi * Float64(0.005555555555555556 * angle))) * a))) end
function tmp = code(a, b, angle) tmp = (((0.5 + (0.5 * cos(((pi * angle) * 0.011111111111111112)))) * b) * b) + (-(sin(((-0.005555555555555556 * angle) * pi)) * a) * (sin((pi * (0.005555555555555556 * angle))) * a)); end
code[a_, b_, angle_] := N[(N[(N[(N[(0.5 + N[(0.5 * N[Cos[N[(N[(Pi * angle), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision] + N[((-N[(N[Sin[N[(N[(-0.005555555555555556 * angle), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision]) * N[(N[Sin[N[(Pi * N[(0.005555555555555556 * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(0.5 + 0.5 \cdot \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)\right) \cdot b\right) \cdot b + \left(-\sin \left(\left(-0.005555555555555556 \cdot angle\right) \cdot \pi\right) \cdot a\right) \cdot \left(\sin \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right) \cdot a\right)
Initial program 80.2%
Applied rewrites80.2%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (/ angle 180.0) PI))) 2.0) (* (+ 0.5 (* 0.5 (cos (* (* PI angle) 0.011111111111111112)))) (* b b))))
double code(double a, double b, double angle) {
return pow((a * sin(((angle / 180.0) * ((double) M_PI)))), 2.0) + ((0.5 + (0.5 * cos(((((double) M_PI) * angle) * 0.011111111111111112)))) * (b * b));
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin(((angle / 180.0) * Math.PI))), 2.0) + ((0.5 + (0.5 * Math.cos(((Math.PI * angle) * 0.011111111111111112)))) * (b * b));
}
def code(a, b, angle): return math.pow((a * math.sin(((angle / 180.0) * math.pi))), 2.0) + ((0.5 + (0.5 * math.cos(((math.pi * angle) * 0.011111111111111112)))) * (b * b))
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(angle / 180.0) * pi))) ^ 2.0) + Float64(Float64(0.5 + Float64(0.5 * cos(Float64(Float64(pi * angle) * 0.011111111111111112)))) * Float64(b * b))) end
function tmp = code(a, b, angle) tmp = ((a * sin(((angle / 180.0) * pi))) ^ 2.0) + ((0.5 + (0.5 * cos(((pi * angle) * 0.011111111111111112)))) * (b * b)); 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[(N[(0.5 + N[(0.5 * N[Cos[N[(N[(Pi * angle), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + \left(0.5 + 0.5 \cdot \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)\right) \cdot \left(b \cdot b\right)
Initial program 80.2%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-*.f64N/A
swap-sqrN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites80.2%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (/ 0.005555555555555556 (/ 1.0 angle)) PI))) 2.0) (pow (* b 1.0) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(((0.005555555555555556 / (1.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(((0.005555555555555556 / (1.0 / 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 / (1.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(0.005555555555555556 / Float64(1.0 / angle)) * pi))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin(((0.005555555555555556 / (1.0 / 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 / N[(1.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{0.005555555555555556}{\frac{1}{angle}} \cdot \pi\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}
Initial program 80.2%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval80.2%
Applied rewrites80.2%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval80.2%
Applied rewrites80.2%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
associate-/r/N/A
mult-flipN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6480.2%
Applied rewrites80.2%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
associate-/r/N/A
mult-flipN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6480.2%
Applied rewrites80.2%
Taylor expanded in angle around 0
Applied rewrites80.1%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* (sin (* (* PI 0.005555555555555556) angle)) a))) (- (* b b) (* (- t_0) t_0))))
double code(double a, double b, double angle) {
double t_0 = sin(((((double) M_PI) * 0.005555555555555556) * angle)) * a;
return (b * b) - (-t_0 * t_0);
}
public static double code(double a, double b, double angle) {
double t_0 = Math.sin(((Math.PI * 0.005555555555555556) * angle)) * a;
return (b * b) - (-t_0 * t_0);
}
def code(a, b, angle): t_0 = math.sin(((math.pi * 0.005555555555555556) * angle)) * a return (b * b) - (-t_0 * t_0)
function code(a, b, angle) t_0 = Float64(sin(Float64(Float64(pi * 0.005555555555555556) * angle)) * a) return Float64(Float64(b * b) - Float64(Float64(-t_0) * t_0)) end
function tmp = code(a, b, angle) t_0 = sin(((pi * 0.005555555555555556) * angle)) * a; tmp = (b * b) - (-t_0 * t_0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[Sin[N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * angle), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision]}, N[(N[(b * b), $MachinePrecision] - N[((-t$95$0) * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \sin \left(\left(\pi \cdot 0.005555555555555556\right) \cdot angle\right) \cdot a\\
b \cdot b - \left(-t\_0\right) \cdot t\_0
\end{array}
Initial program 80.2%
Taylor expanded in angle around 0
lower-pow.f6480.1%
Applied rewrites80.1%
lift-+.f64N/A
+-commutativeN/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
metadata-evalN/A
associate-/r/N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
unpow2N/A
Applied rewrites80.1%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* (/ angle 180.0) PI))) 2.0) (* b b)))
double code(double a, double b, double angle) {
return pow((a * sin(((angle / 180.0) * ((double) M_PI)))), 2.0) + (b * b);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin(((angle / 180.0) * Math.PI))), 2.0) + (b * b);
}
def code(a, b, angle): return math.pow((a * math.sin(((angle / 180.0) * math.pi))), 2.0) + (b * b)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(angle / 180.0) * pi))) ^ 2.0) + Float64(b * b)) end
function tmp = code(a, b, angle) tmp = ((a * sin(((angle / 180.0) * pi))) ^ 2.0) + (b * b); 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[(b * b), $MachinePrecision]), $MachinePrecision]
{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + b \cdot b
Initial program 80.2%
Taylor expanded in angle around 0
lower-pow.f6480.1%
Applied rewrites80.1%
lift-pow.f64N/A
unpow2N/A
lower-*.f6480.1%
Applied rewrites80.1%
(FPCore (a b angle)
:precision binary64
(if (<= (fabs angle) 0.00076)
(+
(*
(*
(*
(-
(*
(* -3.175328964080679e-10 (* (* (fabs angle) (fabs angle)) a))
(pow PI 4.0))
(* -3.08641975308642e-5 (* (* PI PI) a)))
(fabs angle))
(fabs angle))
a)
(* (* (+ 0.5 0.5) b) b))
(+
(*
(-
0.5
(*
0.5
(cos (* 2.0 (* (* PI 0.005555555555555556) (fabs angle))))))
(* a a))
(* b b))))double code(double a, double b, double angle) {
double tmp;
if (fabs(angle) <= 0.00076) {
tmp = ((((((-3.175328964080679e-10 * ((fabs(angle) * fabs(angle)) * a)) * pow(((double) M_PI), 4.0)) - (-3.08641975308642e-5 * ((((double) M_PI) * ((double) M_PI)) * a))) * fabs(angle)) * fabs(angle)) * a) + (((0.5 + 0.5) * b) * b);
} else {
tmp = ((0.5 - (0.5 * cos((2.0 * ((((double) M_PI) * 0.005555555555555556) * fabs(angle)))))) * (a * a)) + (b * b);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (Math.abs(angle) <= 0.00076) {
tmp = ((((((-3.175328964080679e-10 * ((Math.abs(angle) * Math.abs(angle)) * a)) * Math.pow(Math.PI, 4.0)) - (-3.08641975308642e-5 * ((Math.PI * Math.PI) * a))) * Math.abs(angle)) * Math.abs(angle)) * a) + (((0.5 + 0.5) * b) * b);
} else {
tmp = ((0.5 - (0.5 * Math.cos((2.0 * ((Math.PI * 0.005555555555555556) * Math.abs(angle)))))) * (a * a)) + (b * b);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if math.fabs(angle) <= 0.00076: tmp = ((((((-3.175328964080679e-10 * ((math.fabs(angle) * math.fabs(angle)) * a)) * math.pow(math.pi, 4.0)) - (-3.08641975308642e-5 * ((math.pi * math.pi) * a))) * math.fabs(angle)) * math.fabs(angle)) * a) + (((0.5 + 0.5) * b) * b) else: tmp = ((0.5 - (0.5 * math.cos((2.0 * ((math.pi * 0.005555555555555556) * math.fabs(angle)))))) * (a * a)) + (b * b) return tmp
function code(a, b, angle) tmp = 0.0 if (abs(angle) <= 0.00076) tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(-3.175328964080679e-10 * Float64(Float64(abs(angle) * abs(angle)) * a)) * (pi ^ 4.0)) - Float64(-3.08641975308642e-5 * Float64(Float64(pi * pi) * a))) * abs(angle)) * abs(angle)) * a) + Float64(Float64(Float64(0.5 + 0.5) * b) * b)); else tmp = Float64(Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(Float64(pi * 0.005555555555555556) * abs(angle)))))) * Float64(a * a)) + Float64(b * b)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (abs(angle) <= 0.00076) tmp = ((((((-3.175328964080679e-10 * ((abs(angle) * abs(angle)) * a)) * (pi ^ 4.0)) - (-3.08641975308642e-5 * ((pi * pi) * a))) * abs(angle)) * abs(angle)) * a) + (((0.5 + 0.5) * b) * b); else tmp = ((0.5 - (0.5 * cos((2.0 * ((pi * 0.005555555555555556) * abs(angle)))))) * (a * a)) + (b * b); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[N[Abs[angle], $MachinePrecision], 0.00076], N[(N[(N[(N[(N[(N[(N[(-3.175328964080679e-10 * N[(N[(N[Abs[angle], $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] * N[Power[Pi, 4.0], $MachinePrecision]), $MachinePrecision] - N[(-3.08641975308642e-5 * N[(N[(Pi * Pi), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] + N[(N[(N[(0.5 + 0.5), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|angle\right| \leq 0.00076:\\
\;\;\;\;\left(\left(\left(\left(-3.175328964080679 \cdot 10^{-10} \cdot \left(\left(\left|angle\right| \cdot \left|angle\right|\right) \cdot a\right)\right) \cdot {\pi}^{4} - -3.08641975308642 \cdot 10^{-5} \cdot \left(\left(\pi \cdot \pi\right) \cdot a\right)\right) \cdot \left|angle\right|\right) \cdot \left|angle\right|\right) \cdot a + \left(\left(0.5 + 0.5\right) \cdot b\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\left(\pi \cdot 0.005555555555555556\right) \cdot \left|angle\right|\right)\right)\right) \cdot \left(a \cdot a\right) + b \cdot b\\
\end{array}
if angle < 7.6000000000000004e-4Initial program 80.2%
Applied rewrites68.3%
Taylor expanded in angle around 0
Applied rewrites57.3%
Taylor expanded in angle around 0
Applied rewrites57.4%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-PI.f6450.9%
Applied rewrites50.9%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites53.8%
if 7.6000000000000004e-4 < angle Initial program 80.2%
Taylor expanded in angle around 0
lower-pow.f6480.1%
Applied rewrites80.1%
Applied rewrites62.8%
(FPCore (a b angle)
:precision binary64
(if (<= (fabs angle) 3.15e-8)
(+ (* (* (- 0.5 0.5) a) a) (* (* (+ 0.5 0.5) b) b))
(+
(*
(-
0.5
(*
0.5
(cos (* 2.0 (* (* PI 0.005555555555555556) (fabs angle))))))
(* a a))
(* b b))))double code(double a, double b, double angle) {
double tmp;
if (fabs(angle) <= 3.15e-8) {
tmp = (((0.5 - 0.5) * a) * a) + (((0.5 + 0.5) * b) * b);
} else {
tmp = ((0.5 - (0.5 * cos((2.0 * ((((double) M_PI) * 0.005555555555555556) * fabs(angle)))))) * (a * a)) + (b * b);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (Math.abs(angle) <= 3.15e-8) {
tmp = (((0.5 - 0.5) * a) * a) + (((0.5 + 0.5) * b) * b);
} else {
tmp = ((0.5 - (0.5 * Math.cos((2.0 * ((Math.PI * 0.005555555555555556) * Math.abs(angle)))))) * (a * a)) + (b * b);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if math.fabs(angle) <= 3.15e-8: tmp = (((0.5 - 0.5) * a) * a) + (((0.5 + 0.5) * b) * b) else: tmp = ((0.5 - (0.5 * math.cos((2.0 * ((math.pi * 0.005555555555555556) * math.fabs(angle)))))) * (a * a)) + (b * b) return tmp
function code(a, b, angle) tmp = 0.0 if (abs(angle) <= 3.15e-8) tmp = Float64(Float64(Float64(Float64(0.5 - 0.5) * a) * a) + Float64(Float64(Float64(0.5 + 0.5) * b) * b)); else tmp = Float64(Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(Float64(pi * 0.005555555555555556) * abs(angle)))))) * Float64(a * a)) + Float64(b * b)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (abs(angle) <= 3.15e-8) tmp = (((0.5 - 0.5) * a) * a) + (((0.5 + 0.5) * b) * b); else tmp = ((0.5 - (0.5 * cos((2.0 * ((pi * 0.005555555555555556) * abs(angle)))))) * (a * a)) + (b * b); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[N[Abs[angle], $MachinePrecision], 3.15e-8], N[(N[(N[(N[(0.5 - 0.5), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision] + N[(N[(N[(0.5 + 0.5), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(N[(Pi * 0.005555555555555556), $MachinePrecision] * N[Abs[angle], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|angle\right| \leq 3.15 \cdot 10^{-8}:\\
\;\;\;\;\left(\left(0.5 - 0.5\right) \cdot a\right) \cdot a + \left(\left(0.5 + 0.5\right) \cdot b\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\left(\pi \cdot 0.005555555555555556\right) \cdot \left|angle\right|\right)\right)\right) \cdot \left(a \cdot a\right) + b \cdot b\\
\end{array}
if angle < 3.1499999999999998e-8Initial program 80.2%
Applied rewrites68.3%
Taylor expanded in angle around 0
Applied rewrites57.3%
Taylor expanded in angle around 0
Applied rewrites57.4%
if 3.1499999999999998e-8 < angle Initial program 80.2%
Taylor expanded in angle around 0
lower-pow.f6480.1%
Applied rewrites80.1%
Applied rewrites62.8%
(FPCore (a b angle) :precision binary64 (+ (* (* (- 0.5 (* 0.5 (cos (* 0.011111111111111112 (* angle PI))))) a) a) (* (* (+ 0.5 0.5) b) b)))
double code(double a, double b, double angle) {
return (((0.5 - (0.5 * cos((0.011111111111111112 * (angle * ((double) M_PI)))))) * a) * a) + (((0.5 + 0.5) * b) * b);
}
public static double code(double a, double b, double angle) {
return (((0.5 - (0.5 * Math.cos((0.011111111111111112 * (angle * Math.PI))))) * a) * a) + (((0.5 + 0.5) * b) * b);
}
def code(a, b, angle): return (((0.5 - (0.5 * math.cos((0.011111111111111112 * (angle * math.pi))))) * a) * a) + (((0.5 + 0.5) * b) * b)
function code(a, b, angle) return Float64(Float64(Float64(Float64(0.5 - Float64(0.5 * cos(Float64(0.011111111111111112 * Float64(angle * pi))))) * a) * a) + Float64(Float64(Float64(0.5 + 0.5) * b) * b)) end
function tmp = code(a, b, angle) tmp = (((0.5 - (0.5 * cos((0.011111111111111112 * (angle * pi))))) * a) * a) + (((0.5 + 0.5) * b) * b); end
code[a_, b_, angle_] := N[(N[(N[(N[(0.5 - N[(0.5 * N[Cos[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision] + N[(N[(N[(0.5 + 0.5), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\left(\left(0.5 - 0.5 \cdot \cos \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right) \cdot a\right) \cdot a + \left(\left(0.5 + 0.5\right) \cdot b\right) \cdot b
Initial program 80.2%
Applied rewrites68.3%
Taylor expanded in angle around 0
Applied rewrites57.3%
Taylor expanded in angle around 0
Applied rewrites57.4%
Taylor expanded in angle around inf
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f6468.2%
Applied rewrites68.2%
(FPCore (a b angle) :precision binary64 (* 1.0 (* (* (+ 0.5 (* 0.5 (cos (* (* PI angle) 0.011111111111111112)))) b) b)))
double code(double a, double b, double angle) {
return 1.0 * (((0.5 + (0.5 * cos(((((double) M_PI) * angle) * 0.011111111111111112)))) * b) * b);
}
public static double code(double a, double b, double angle) {
return 1.0 * (((0.5 + (0.5 * Math.cos(((Math.PI * angle) * 0.011111111111111112)))) * b) * b);
}
def code(a, b, angle): return 1.0 * (((0.5 + (0.5 * math.cos(((math.pi * angle) * 0.011111111111111112)))) * b) * b)
function code(a, b, angle) return Float64(1.0 * Float64(Float64(Float64(0.5 + Float64(0.5 * cos(Float64(Float64(pi * angle) * 0.011111111111111112)))) * b) * b)) end
function tmp = code(a, b, angle) tmp = 1.0 * (((0.5 + (0.5 * cos(((pi * angle) * 0.011111111111111112)))) * b) * b); end
code[a_, b_, angle_] := N[(1.0 * N[(N[(N[(0.5 + N[(0.5 * N[Cos[N[(N[(Pi * angle), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
1 \cdot \left(\left(\left(0.5 + 0.5 \cdot \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)\right) \cdot b\right) \cdot b\right)
Initial program 80.2%
Applied rewrites51.0%
Taylor expanded in a around 0
Applied rewrites57.3%
(FPCore (a b angle) :precision binary64 (+ (* (* (- 0.5 0.5) a) a) (* (* (+ 0.5 0.5) b) b)))
double code(double a, double b, double angle) {
return (((0.5 - 0.5) * a) * a) + (((0.5 + 0.5) * 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 = (((0.5d0 - 0.5d0) * a) * a) + (((0.5d0 + 0.5d0) * b) * b)
end function
public static double code(double a, double b, double angle) {
return (((0.5 - 0.5) * a) * a) + (((0.5 + 0.5) * b) * b);
}
def code(a, b, angle): return (((0.5 - 0.5) * a) * a) + (((0.5 + 0.5) * b) * b)
function code(a, b, angle) return Float64(Float64(Float64(Float64(0.5 - 0.5) * a) * a) + Float64(Float64(Float64(0.5 + 0.5) * b) * b)) end
function tmp = code(a, b, angle) tmp = (((0.5 - 0.5) * a) * a) + (((0.5 + 0.5) * b) * b); end
code[a_, b_, angle_] := N[(N[(N[(N[(0.5 - 0.5), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision] + N[(N[(N[(0.5 + 0.5), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\left(\left(0.5 - 0.5\right) \cdot a\right) \cdot a + \left(\left(0.5 + 0.5\right) \cdot b\right) \cdot b
Initial program 80.2%
Applied rewrites68.3%
Taylor expanded in angle around 0
Applied rewrites57.3%
Taylor expanded in angle around 0
Applied rewrites57.4%
herbie shell --seed 2025258
(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)))