
(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}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (/ angle 180.0)))) (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle / 180.0);
return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle / 180.0);
return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle): t_0 = math.pi * (angle / 180.0) return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(pi * Float64(angle / 180.0)) return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = pi * (angle / 180.0); tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
\end{array}
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (/ angle 180.0)))) (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle / 180.0);
return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle / 180.0);
return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle): t_0 = math.pi * (angle / 180.0) return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle) t_0 = Float64(pi * Float64(angle / 180.0)) return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0)) end
function tmp = code(a, b, angle) t_0 = pi * (angle / 180.0); tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
\end{array}
Initial program 80.8%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (cos (* PI (/ angle 180.0)))) 2.0) (pow (* b (sin (* (* PI angle) 0.005555555555555556))) 2.0)))
double code(double a, double b, double angle) {
return pow((a * cos((((double) M_PI) * (angle / 180.0)))), 2.0) + pow((b * sin(((((double) M_PI) * angle) * 0.005555555555555556))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.cos((Math.PI * (angle / 180.0)))), 2.0) + Math.pow((b * Math.sin(((Math.PI * angle) * 0.005555555555555556))), 2.0);
}
def code(a, b, angle): return math.pow((a * math.cos((math.pi * (angle / 180.0)))), 2.0) + math.pow((b * math.sin(((math.pi * angle) * 0.005555555555555556))), 2.0)
function code(a, b, angle) return Float64((Float64(a * cos(Float64(pi * Float64(angle / 180.0)))) ^ 2.0) + (Float64(b * sin(Float64(Float64(pi * angle) * 0.005555555555555556))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * cos((pi * (angle / 180.0)))) ^ 2.0) + ((b * sin(((pi * angle) * 0.005555555555555556))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)\right)}^{2}
\end{array}
Initial program 80.8%
Taylor expanded in angle around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6480.7
Applied rewrites80.7%
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* angle (fma 0.005555555555555556 PI (* 0.5 (/ PI angle)))))) 2.0) (pow (/ 1.0 (pow (* (sin (* PI (/ angle 180.0))) b) -1.0)) 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin((angle * fma(0.005555555555555556, ((double) M_PI), (0.5 * (((double) M_PI) / angle)))))), 2.0) + pow((1.0 / pow((sin((((double) M_PI) * (angle / 180.0))) * b), -1.0)), 2.0);
}
function code(a, b, angle) return Float64((Float64(a * sin(Float64(angle * fma(0.005555555555555556, pi, Float64(0.5 * Float64(pi / angle)))))) ^ 2.0) + (Float64(1.0 / (Float64(sin(Float64(pi * Float64(angle / 180.0))) * b) ^ -1.0)) ^ 2.0)) end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(angle * N[(0.005555555555555556 * Pi + N[(0.5 * N[(Pi / angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(1.0 / N[Power[N[(N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * b), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(angle \cdot \mathsf{fma}\left(0.005555555555555556, \pi, 0.5 \cdot \frac{\pi}{angle}\right)\right)\right)}^{2} + {\left(\frac{1}{{\left(\sin \left(\pi \cdot \frac{angle}{180}\right) \cdot b\right)}^{-1}}\right)}^{2}
\end{array}
Initial program 80.8%
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6480.8
Applied rewrites80.8%
lift-*.f64N/A
lift-sin.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*r/N/A
unpow1N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-sin.f6480.8
Applied rewrites80.8%
Taylor expanded in angle around inf
associate-*r/N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
associate-*r*N/A
lift-/.f64N/A
lift-PI.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-PI.f6480.6
Applied rewrites80.6%
Taylor expanded in angle around inf
lower-*.f64N/A
lower-fma.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f6480.6
Applied rewrites80.6%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* 0.005555555555555556 (* PI angle))) (t_1 (* (sin t_0) b))) (fma (pow (sin (fma 0.5 PI t_0)) 2.0) (* a a) (* t_1 t_1))))
double code(double a, double b, double angle) {
double t_0 = 0.005555555555555556 * (((double) M_PI) * angle);
double t_1 = sin(t_0) * b;
return fma(pow(sin(fma(0.5, ((double) M_PI), t_0)), 2.0), (a * a), (t_1 * t_1));
}
function code(a, b, angle) t_0 = Float64(0.005555555555555556 * Float64(pi * angle)) t_1 = Float64(sin(t_0) * b) return fma((sin(fma(0.5, pi, t_0)) ^ 2.0), Float64(a * a), Float64(t_1 * t_1)) end
code[a_, b_, angle_] := Block[{t$95$0 = N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[t$95$0], $MachinePrecision] * b), $MachinePrecision]}, N[(N[Power[N[Sin[N[(0.5 * Pi + t$95$0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * N[(a * a), $MachinePrecision] + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(\pi \cdot angle\right)\\
t_1 := \sin t\_0 \cdot b\\
\mathsf{fma}\left({\sin \left(\mathsf{fma}\left(0.5, \pi, t\_0\right)\right)}^{2}, a \cdot a, t\_1 \cdot t\_1\right)
\end{array}
\end{array}
Initial program 80.8%
lift-pow.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow-to-expN/A
exp-prodN/A
lower-pow.f64N/A
Applied rewrites33.8%
Taylor expanded in a around 0
Applied rewrites80.6%
Final simplification80.6%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* 0.005555555555555556 (* PI angle)))
(t_1 (* (sin t_0) b))
(t_2 (* (* (pow (/ -1.0 a) -1.0) (sin (fma 0.5 PI t_0))) -1.0)))
(fma t_1 t_1 (* t_2 t_2))))
double code(double a, double b, double angle) {
double t_0 = 0.005555555555555556 * (((double) M_PI) * angle);
double t_1 = sin(t_0) * b;
double t_2 = (pow((-1.0 / a), -1.0) * sin(fma(0.5, ((double) M_PI), t_0))) * -1.0;
return fma(t_1, t_1, (t_2 * t_2));
}
function code(a, b, angle) t_0 = Float64(0.005555555555555556 * Float64(pi * angle)) t_1 = Float64(sin(t_0) * b) t_2 = Float64(Float64((Float64(-1.0 / a) ^ -1.0) * sin(fma(0.5, pi, t_0))) * -1.0) return fma(t_1, t_1, Float64(t_2 * t_2)) end
code[a_, b_, angle_] := Block[{t$95$0 = N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[t$95$0], $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Power[N[(-1.0 / a), $MachinePrecision], -1.0], $MachinePrecision] * N[Sin[N[(0.5 * Pi + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -1.0), $MachinePrecision]}, N[(t$95$1 * t$95$1 + N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(\pi \cdot angle\right)\\
t_1 := \sin t\_0 \cdot b\\
t_2 := \left({\left(\frac{-1}{a}\right)}^{-1} \cdot \sin \left(\mathsf{fma}\left(0.5, \pi, t\_0\right)\right)\right) \cdot -1\\
\mathsf{fma}\left(t\_1, t\_1, t\_2 \cdot t\_2\right)
\end{array}
\end{array}
Initial program 80.8%
lift-pow.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow-to-expN/A
exp-prodN/A
lower-pow.f64N/A
Applied rewrites33.8%
Taylor expanded in a around -inf
Applied rewrites80.5%
Final simplification80.5%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* 0.005555555555555556 (* PI angle))) (t_1 (* (sin t_0) b)))
(if (<= a 1.4e+153)
(fma
t_1
t_1
(*
(* (* (pow (/ -1.0 a) -1.0) (sin (fma 0.5 PI t_0))) -1.0)
(* (* (* -1.0 a) (sin (* 0.5 PI))) -1.0)))
(exp (* (log a) 2.0)))))
double code(double a, double b, double angle) {
double t_0 = 0.005555555555555556 * (((double) M_PI) * angle);
double t_1 = sin(t_0) * b;
double tmp;
if (a <= 1.4e+153) {
tmp = fma(t_1, t_1, (((pow((-1.0 / a), -1.0) * sin(fma(0.5, ((double) M_PI), t_0))) * -1.0) * (((-1.0 * a) * sin((0.5 * ((double) M_PI)))) * -1.0)));
} else {
tmp = exp((log(a) * 2.0));
}
return tmp;
}
function code(a, b, angle) t_0 = Float64(0.005555555555555556 * Float64(pi * angle)) t_1 = Float64(sin(t_0) * b) tmp = 0.0 if (a <= 1.4e+153) tmp = fma(t_1, t_1, Float64(Float64(Float64((Float64(-1.0 / a) ^ -1.0) * sin(fma(0.5, pi, t_0))) * -1.0) * Float64(Float64(Float64(-1.0 * a) * sin(Float64(0.5 * pi))) * -1.0))); else tmp = exp(Float64(log(a) * 2.0)); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[t$95$0], $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[a, 1.4e+153], N[(t$95$1 * t$95$1 + N[(N[(N[(N[Power[N[(-1.0 / a), $MachinePrecision], -1.0], $MachinePrecision] * N[Sin[N[(0.5 * Pi + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -1.0), $MachinePrecision] * N[(N[(N[(-1.0 * a), $MachinePrecision] * N[Sin[N[(0.5 * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[Log[a], $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(\pi \cdot angle\right)\\
t_1 := \sin t\_0 \cdot b\\
\mathbf{if}\;a \leq 1.4 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, t\_1, \left(\left({\left(\frac{-1}{a}\right)}^{-1} \cdot \sin \left(\mathsf{fma}\left(0.5, \pi, t\_0\right)\right)\right) \cdot -1\right) \cdot \left(\left(\left(-1 \cdot a\right) \cdot \sin \left(0.5 \cdot \pi\right)\right) \cdot -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\log a \cdot 2}\\
\end{array}
\end{array}
if a < 1.39999999999999993e153Initial program 77.5%
lift-pow.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow-to-expN/A
exp-prodN/A
lower-pow.f64N/A
Applied rewrites24.5%
Taylor expanded in a around -inf
Applied rewrites77.2%
Taylor expanded in angle around 0
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lift-PI.f6471.0
Applied rewrites71.0%
if 1.39999999999999993e153 < a Initial program 100.0%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lift-log.f64100.0
Applied rewrites100.0%
Final simplification75.2%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (sin (* (* PI angle) 0.005555555555555556)))
(t_1 (sin (* 0.5 PI)))
(t_2 (* t_1 t_1))
(t_3 (* (sin (fma (* 0.005555555555555556 angle) PI (/ PI 2.0))) a))
(t_4 (* (sin (* 0.005555555555555556 (* PI angle))) b))
(t_5 (sin (fma 0.5 PI (/ PI 2.0)))))
(if (<= a 1.35e-121)
(fma
t_4
t_4
(fma
angle
(+
(* (* 0.011111111111111112 (* a a)) (* (* PI t_5) t_1))
(*
angle
(fma
(* (* a a) angle)
(* (* (* (* (* PI PI) PI) t_5) t_1) -2.2862368541380886e-7)
(*
(* a a)
(fma
(* -3.08641975308642e-5 (* PI PI))
t_2
(* (* 3.08641975308642e-5 (* PI PI)) (* t_5 t_5)))))))
(* (* a a) t_2)))
(if (<= a 6.2e+142)
(fma (* (/ (* t_0 t_0) a) (/ (* b b) a)) (* a a) (* t_3 t_3))
(* a a)))))
double code(double a, double b, double angle) {
double t_0 = sin(((((double) M_PI) * angle) * 0.005555555555555556));
double t_1 = sin((0.5 * ((double) M_PI)));
double t_2 = t_1 * t_1;
double t_3 = sin(fma((0.005555555555555556 * angle), ((double) M_PI), (((double) M_PI) / 2.0))) * a;
double t_4 = sin((0.005555555555555556 * (((double) M_PI) * angle))) * b;
double t_5 = sin(fma(0.5, ((double) M_PI), (((double) M_PI) / 2.0)));
double tmp;
if (a <= 1.35e-121) {
tmp = fma(t_4, t_4, fma(angle, (((0.011111111111111112 * (a * a)) * ((((double) M_PI) * t_5) * t_1)) + (angle * fma(((a * a) * angle), (((((((double) M_PI) * ((double) M_PI)) * ((double) M_PI)) * t_5) * t_1) * -2.2862368541380886e-7), ((a * a) * fma((-3.08641975308642e-5 * (((double) M_PI) * ((double) M_PI))), t_2, ((3.08641975308642e-5 * (((double) M_PI) * ((double) M_PI))) * (t_5 * t_5))))))), ((a * a) * t_2)));
} else if (a <= 6.2e+142) {
tmp = fma((((t_0 * t_0) / a) * ((b * b) / a)), (a * a), (t_3 * t_3));
} else {
tmp = a * a;
}
return tmp;
}
function code(a, b, angle) t_0 = sin(Float64(Float64(pi * angle) * 0.005555555555555556)) t_1 = sin(Float64(0.5 * pi)) t_2 = Float64(t_1 * t_1) t_3 = Float64(sin(fma(Float64(0.005555555555555556 * angle), pi, Float64(pi / 2.0))) * a) t_4 = Float64(sin(Float64(0.005555555555555556 * Float64(pi * angle))) * b) t_5 = sin(fma(0.5, pi, Float64(pi / 2.0))) tmp = 0.0 if (a <= 1.35e-121) tmp = fma(t_4, t_4, fma(angle, Float64(Float64(Float64(0.011111111111111112 * Float64(a * a)) * Float64(Float64(pi * t_5) * t_1)) + Float64(angle * fma(Float64(Float64(a * a) * angle), Float64(Float64(Float64(Float64(Float64(pi * pi) * pi) * t_5) * t_1) * -2.2862368541380886e-7), Float64(Float64(a * a) * fma(Float64(-3.08641975308642e-5 * Float64(pi * pi)), t_2, Float64(Float64(3.08641975308642e-5 * Float64(pi * pi)) * Float64(t_5 * t_5))))))), Float64(Float64(a * a) * t_2))); elseif (a <= 6.2e+142) tmp = fma(Float64(Float64(Float64(t_0 * t_0) / a) * Float64(Float64(b * b) / a)), Float64(a * a), Float64(t_3 * t_3)); else tmp = Float64(a * a); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[Sin[N[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(0.5 * Pi), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[N[(N[(0.005555555555555556 * angle), $MachinePrecision] * Pi + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sin[N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$5 = N[Sin[N[(0.5 * Pi + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[a, 1.35e-121], N[(t$95$4 * t$95$4 + N[(angle * N[(N[(N[(0.011111111111111112 * N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * t$95$5), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(angle * N[(N[(N[(a * a), $MachinePrecision] * angle), $MachinePrecision] * N[(N[(N[(N[(N[(Pi * Pi), $MachinePrecision] * Pi), $MachinePrecision] * t$95$5), $MachinePrecision] * t$95$1), $MachinePrecision] * -2.2862368541380886e-7), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(N[(-3.08641975308642e-5 * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * t$95$2 + N[(N[(3.08641975308642e-5 * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * N[(t$95$5 * t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 6.2e+142], N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] / a), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision] + N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision], N[(a * a), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)\\
t_1 := \sin \left(0.5 \cdot \pi\right)\\
t_2 := t\_1 \cdot t\_1\\
t_3 := \sin \left(\mathsf{fma}\left(0.005555555555555556 \cdot angle, \pi, \frac{\pi}{2}\right)\right) \cdot a\\
t_4 := \sin \left(0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right) \cdot b\\
t_5 := \sin \left(\mathsf{fma}\left(0.5, \pi, \frac{\pi}{2}\right)\right)\\
\mathbf{if}\;a \leq 1.35 \cdot 10^{-121}:\\
\;\;\;\;\mathsf{fma}\left(t\_4, t\_4, \mathsf{fma}\left(angle, \left(0.011111111111111112 \cdot \left(a \cdot a\right)\right) \cdot \left(\left(\pi \cdot t\_5\right) \cdot t\_1\right) + angle \cdot \mathsf{fma}\left(\left(a \cdot a\right) \cdot angle, \left(\left(\left(\left(\pi \cdot \pi\right) \cdot \pi\right) \cdot t\_5\right) \cdot t\_1\right) \cdot -2.2862368541380886 \cdot 10^{-7}, \left(a \cdot a\right) \cdot \mathsf{fma}\left(-3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \pi\right), t\_2, \left(3.08641975308642 \cdot 10^{-5} \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(t\_5 \cdot t\_5\right)\right)\right), \left(a \cdot a\right) \cdot t\_2\right)\right)\\
\mathbf{elif}\;a \leq 6.2 \cdot 10^{+142}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t\_0 \cdot t\_0}{a} \cdot \frac{b \cdot b}{a}, a \cdot a, t\_3 \cdot t\_3\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 1.3500000000000001e-121Initial program 78.6%
lift-pow.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow-to-expN/A
exp-prodN/A
lower-pow.f64N/A
Applied rewrites13.6%
Taylor expanded in a around -inf
Applied rewrites78.6%
Taylor expanded in angle around 0
Applied rewrites55.7%
if 1.3500000000000001e-121 < a < 6.1999999999999998e142Initial program 71.9%
Taylor expanded in a around inf
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites59.3%
if 6.1999999999999998e142 < a Initial program 100.0%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Final simplification63.7%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (sin (* (* PI angle) 0.005555555555555556)))
(t_1 (* (sin (fma (* 0.005555555555555556 angle) PI (/ PI 2.0))) a))
(t_2 (* 0.005555555555555556 (* PI angle)))
(t_3 (* (* (pow (/ -1.0 a) -1.0) (sin (fma 0.5 PI t_2))) -1.0)))
(if (<= angle 1.85e+55)
(fma
(* (sin t_2) b)
(* 0.005555555555555556 (* angle (* b PI)))
(* t_3 t_3))
(fma (* (/ (* t_0 t_0) a) (/ (* b b) a)) (* a a) (* t_1 t_1)))))
double code(double a, double b, double angle) {
double t_0 = sin(((((double) M_PI) * angle) * 0.005555555555555556));
double t_1 = sin(fma((0.005555555555555556 * angle), ((double) M_PI), (((double) M_PI) / 2.0))) * a;
double t_2 = 0.005555555555555556 * (((double) M_PI) * angle);
double t_3 = (pow((-1.0 / a), -1.0) * sin(fma(0.5, ((double) M_PI), t_2))) * -1.0;
double tmp;
if (angle <= 1.85e+55) {
tmp = fma((sin(t_2) * b), (0.005555555555555556 * (angle * (b * ((double) M_PI)))), (t_3 * t_3));
} else {
tmp = fma((((t_0 * t_0) / a) * ((b * b) / a)), (a * a), (t_1 * t_1));
}
return tmp;
}
function code(a, b, angle) t_0 = sin(Float64(Float64(pi * angle) * 0.005555555555555556)) t_1 = Float64(sin(fma(Float64(0.005555555555555556 * angle), pi, Float64(pi / 2.0))) * a) t_2 = Float64(0.005555555555555556 * Float64(pi * angle)) t_3 = Float64(Float64((Float64(-1.0 / a) ^ -1.0) * sin(fma(0.5, pi, t_2))) * -1.0) tmp = 0.0 if (angle <= 1.85e+55) tmp = fma(Float64(sin(t_2) * b), Float64(0.005555555555555556 * Float64(angle * Float64(b * pi))), Float64(t_3 * t_3)); else tmp = fma(Float64(Float64(Float64(t_0 * t_0) / a) * Float64(Float64(b * b) / a)), Float64(a * a), Float64(t_1 * t_1)); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[Sin[N[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(N[(0.005555555555555556 * angle), $MachinePrecision] * Pi + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision]}, Block[{t$95$2 = N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Power[N[(-1.0 / a), $MachinePrecision], -1.0], $MachinePrecision] * N[Sin[N[(0.5 * Pi + t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -1.0), $MachinePrecision]}, If[LessEqual[angle, 1.85e+55], N[(N[(N[Sin[t$95$2], $MachinePrecision] * b), $MachinePrecision] * N[(0.005555555555555556 * N[(angle * N[(b * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] / a), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision] + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)\\
t_1 := \sin \left(\mathsf{fma}\left(0.005555555555555556 \cdot angle, \pi, \frac{\pi}{2}\right)\right) \cdot a\\
t_2 := 0.005555555555555556 \cdot \left(\pi \cdot angle\right)\\
t_3 := \left({\left(\frac{-1}{a}\right)}^{-1} \cdot \sin \left(\mathsf{fma}\left(0.5, \pi, t\_2\right)\right)\right) \cdot -1\\
\mathbf{if}\;angle \leq 1.85 \cdot 10^{+55}:\\
\;\;\;\;\mathsf{fma}\left(\sin t\_2 \cdot b, 0.005555555555555556 \cdot \left(angle \cdot \left(b \cdot \pi\right)\right), t\_3 \cdot t\_3\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t\_0 \cdot t\_0}{a} \cdot \frac{b \cdot b}{a}, a \cdot a, t\_1 \cdot t\_1\right)\\
\end{array}
\end{array}
if angle < 1.8500000000000001e55Initial program 86.4%
lift-pow.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow-to-expN/A
exp-prodN/A
lower-pow.f64N/A
Applied rewrites39.0%
Taylor expanded in a around -inf
Applied rewrites86.2%
Taylor expanded in angle around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-PI.f6475.3
Applied rewrites75.3%
if 1.8500000000000001e55 < angle Initial program 63.3%
Taylor expanded in a around inf
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites38.7%
Final simplification66.4%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (sin (fma (* 0.005555555555555556 angle) PI (/ PI 2.0))) a))
(t_1 (sin (* (* PI angle) 0.005555555555555556))))
(if (<= a 6.2e+142)
(fma (* (/ (* t_1 t_1) a) (/ (* b b) a)) (* a a) (* t_0 t_0))
(* a a))))
double code(double a, double b, double angle) {
double t_0 = sin(fma((0.005555555555555556 * angle), ((double) M_PI), (((double) M_PI) / 2.0))) * a;
double t_1 = sin(((((double) M_PI) * angle) * 0.005555555555555556));
double tmp;
if (a <= 6.2e+142) {
tmp = fma((((t_1 * t_1) / a) * ((b * b) / a)), (a * a), (t_0 * t_0));
} else {
tmp = a * a;
}
return tmp;
}
function code(a, b, angle) t_0 = Float64(sin(fma(Float64(0.005555555555555556 * angle), pi, Float64(pi / 2.0))) * a) t_1 = sin(Float64(Float64(pi * angle) * 0.005555555555555556)) tmp = 0.0 if (a <= 6.2e+142) tmp = fma(Float64(Float64(Float64(t_1 * t_1) / a) * Float64(Float64(b * b) / a)), Float64(a * a), Float64(t_0 * t_0)); else tmp = Float64(a * a); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[Sin[N[(N[(0.005555555555555556 * angle), $MachinePrecision] * Pi + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * a), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(Pi * angle), $MachinePrecision] * 0.005555555555555556), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[a, 6.2e+142], N[(N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] / a), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision] + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(a * a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\mathsf{fma}\left(0.005555555555555556 \cdot angle, \pi, \frac{\pi}{2}\right)\right) \cdot a\\
t_1 := \sin \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)\\
\mathbf{if}\;a \leq 6.2 \cdot 10^{+142}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t\_1 \cdot t\_1}{a} \cdot \frac{b \cdot b}{a}, a \cdot a, t\_0 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot a\\
\end{array}
\end{array}
if a < 6.1999999999999998e142Initial program 77.0%
Taylor expanded in a around inf
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites47.6%
if 6.1999999999999998e142 < a Initial program 100.0%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
(FPCore (a b angle) :precision binary64 (* a a))
double code(double a, double b, double angle) {
return a * a;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, angle)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = a * a
end function
public static double code(double a, double b, double angle) {
return a * a;
}
def code(a, b, angle): return a * a
function code(a, b, angle) return Float64(a * a) end
function tmp = code(a, b, angle) tmp = a * a; end
code[a_, b_, angle_] := N[(a * a), $MachinePrecision]
\begin{array}{l}
\\
a \cdot a
\end{array}
Initial program 80.8%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6455.0
Applied rewrites55.0%
(FPCore (a b angle) :precision binary64 (exp (* (log a) 2.0)))
double code(double a, double b, double angle) {
return exp((log(a) * 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 = exp((log(a) * 2.0d0))
end function
public static double code(double a, double b, double angle) {
return Math.exp((Math.log(a) * 2.0));
}
def code(a, b, angle): return math.exp((math.log(a) * 2.0))
function code(a, b, angle) return exp(Float64(log(a) * 2.0)) end
function tmp = code(a, b, angle) tmp = exp((log(a) * 2.0)); end
code[a_, b_, angle_] := N[Exp[N[(N[Log[a], $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\log a \cdot 2}
\end{array}
Initial program 80.8%
Taylor expanded in angle around 0
unpow2N/A
lower-*.f6455.0
Applied rewrites55.0%
lift-*.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lift-log.f6429.8
Applied rewrites29.8%
herbie shell --seed 2025065
(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)))