
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (/ angle 180.0)))) (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin t_0)) (cos t_0))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle / 180.0);
return ((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin(t_0)) * cos(t_0);
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle / 180.0);
return ((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * Math.sin(t_0)) * Math.cos(t_0);
}
def code(a, b, angle): t_0 = math.pi * (angle / 180.0) return ((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * math.sin(t_0)) * math.cos(t_0)
function code(a, b, angle) t_0 = Float64(pi * Float64(angle / 180.0)) return Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * sin(t_0)) * cos(t_0)) end
function tmp = code(a, b, angle) t_0 = pi * (angle / 180.0); tmp = ((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * sin(t_0)) * cos(t_0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin t_0\right) \cdot \cos t_0
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (/ angle 180.0)))) (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin t_0)) (cos t_0))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle / 180.0);
return ((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin(t_0)) * cos(t_0);
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle / 180.0);
return ((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * Math.sin(t_0)) * Math.cos(t_0);
}
def code(a, b, angle): t_0 = math.pi * (angle / 180.0) return ((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * math.sin(t_0)) * math.cos(t_0)
function code(a, b, angle) t_0 = Float64(pi * Float64(angle / 180.0)) return Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * sin(t_0)) * cos(t_0)) end
function tmp = code(a, b, angle) t_0 = pi * (angle / 180.0); tmp = ((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * sin(t_0)) * cos(t_0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin t_0\right) \cdot \cos t_0
\end{array}
\end{array}
a_m = (fabs.f64 a)
(FPCore (a_m b angle)
:precision binary64
(let* ((t_0 (* PI (/ angle 180.0))) (t_1 (* 2.0 (* (+ a_m b) (- b a_m)))))
(if (<= a_m 2.7e+25)
(* (cos t_0) (* t_1 (sin (* PI (* angle 0.005555555555555556)))))
(if (<= a_m 1.2e+193)
(*
(* t_1 (sin t_0))
(cos (* (/ angle 180.0) (pow (cbrt (pow PI 1.5)) 2.0))))
(*
t_1
(+
(* -2.8577960676726107e-8 (* (pow angle 3.0) (pow PI 3.0)))
(* 0.005555555555555556 (* PI angle))))))))a_m = fabs(a);
double code(double a_m, double b, double angle) {
double t_0 = ((double) M_PI) * (angle / 180.0);
double t_1 = 2.0 * ((a_m + b) * (b - a_m));
double tmp;
if (a_m <= 2.7e+25) {
tmp = cos(t_0) * (t_1 * sin((((double) M_PI) * (angle * 0.005555555555555556))));
} else if (a_m <= 1.2e+193) {
tmp = (t_1 * sin(t_0)) * cos(((angle / 180.0) * pow(cbrt(pow(((double) M_PI), 1.5)), 2.0)));
} else {
tmp = t_1 * ((-2.8577960676726107e-8 * (pow(angle, 3.0) * pow(((double) M_PI), 3.0))) + (0.005555555555555556 * (((double) M_PI) * angle)));
}
return tmp;
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
double t_0 = Math.PI * (angle / 180.0);
double t_1 = 2.0 * ((a_m + b) * (b - a_m));
double tmp;
if (a_m <= 2.7e+25) {
tmp = Math.cos(t_0) * (t_1 * Math.sin((Math.PI * (angle * 0.005555555555555556))));
} else if (a_m <= 1.2e+193) {
tmp = (t_1 * Math.sin(t_0)) * Math.cos(((angle / 180.0) * Math.pow(Math.cbrt(Math.pow(Math.PI, 1.5)), 2.0)));
} else {
tmp = t_1 * ((-2.8577960676726107e-8 * (Math.pow(angle, 3.0) * Math.pow(Math.PI, 3.0))) + (0.005555555555555556 * (Math.PI * angle)));
}
return tmp;
}
a_m = abs(a) function code(a_m, b, angle) t_0 = Float64(pi * Float64(angle / 180.0)) t_1 = Float64(2.0 * Float64(Float64(a_m + b) * Float64(b - a_m))) tmp = 0.0 if (a_m <= 2.7e+25) tmp = Float64(cos(t_0) * Float64(t_1 * sin(Float64(pi * Float64(angle * 0.005555555555555556))))); elseif (a_m <= 1.2e+193) tmp = Float64(Float64(t_1 * sin(t_0)) * cos(Float64(Float64(angle / 180.0) * (cbrt((pi ^ 1.5)) ^ 2.0)))); else tmp = Float64(t_1 * Float64(Float64(-2.8577960676726107e-8 * Float64((angle ^ 3.0) * (pi ^ 3.0))) + Float64(0.005555555555555556 * Float64(pi * angle)))); end return tmp end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a$95$m, 2.7e+25], N[(N[Cos[t$95$0], $MachinePrecision] * N[(t$95$1 * N[Sin[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a$95$m, 1.2e+193], N[(N[(t$95$1 * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(angle / 180.0), $MachinePrecision] * N[Power[N[Power[N[Power[Pi, 1.5], $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(N[(-2.8577960676726107e-8 * N[(N[Power[angle, 3.0], $MachinePrecision] * N[Power[Pi, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
t_1 := 2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\\
\mathbf{if}\;a_m \leq 2.7 \cdot 10^{+25}:\\
\;\;\;\;\cos t_0 \cdot \left(t_1 \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)\\
\mathbf{elif}\;a_m \leq 1.2 \cdot 10^{+193}:\\
\;\;\;\;\left(t_1 \cdot \sin t_0\right) \cdot \cos \left(\frac{angle}{180} \cdot {\left(\sqrt[3]{{\pi}^{1.5}}\right)}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(-2.8577960676726107 \cdot 10^{-8} \cdot \left({angle}^{3} \cdot {\pi}^{3}\right) + 0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right)\\
\end{array}
\end{array}
if a < 2.7e25Initial program 56.1%
unpow256.1%
unpow256.1%
difference-of-squares59.6%
Applied egg-rr59.6%
add-sqr-sqrt28.6%
sqrt-unprod37.7%
pow237.7%
div-inv37.7%
metadata-eval37.7%
Applied egg-rr37.7%
sqrt-pow160.8%
metadata-eval60.8%
pow160.8%
Applied egg-rr60.8%
if 2.7e25 < a < 1.2e193Initial program 56.6%
unpow256.6%
unpow256.6%
difference-of-squares59.0%
Applied egg-rr59.0%
add-sqr-sqrt60.8%
pow260.8%
Applied egg-rr60.8%
add-cbrt-cube60.8%
sqrt-unprod60.8%
sqrt-prod67.3%
unpow367.3%
sqrt-pow167.3%
pow1/360.8%
metadata-eval60.8%
Applied egg-rr60.8%
unpow1/367.3%
Simplified67.3%
if 1.2e193 < a Initial program 41.7%
unpow241.7%
unpow241.7%
difference-of-squares42.5%
Applied egg-rr42.5%
Taylor expanded in angle around 0 42.5%
Taylor expanded in angle around 0 62.5%
Final simplification62.0%
a_m = (fabs.f64 a)
(FPCore (a_m b angle)
:precision binary64
(let* ((t_0 (cos (* PI (/ angle 180.0))))
(t_1 (* 2.0 (* (+ a_m b) (- b a_m)))))
(if (<= a_m 2e+173)
(* t_0 (* t_1 (sin (* PI (* angle 0.005555555555555556)))))
(*
t_0
(* t_1 (sin (* (/ angle 180.0) (* (cbrt PI) (pow (cbrt PI) 2.0)))))))))a_m = fabs(a);
double code(double a_m, double b, double angle) {
double t_0 = cos((((double) M_PI) * (angle / 180.0)));
double t_1 = 2.0 * ((a_m + b) * (b - a_m));
double tmp;
if (a_m <= 2e+173) {
tmp = t_0 * (t_1 * sin((((double) M_PI) * (angle * 0.005555555555555556))));
} else {
tmp = t_0 * (t_1 * sin(((angle / 180.0) * (cbrt(((double) M_PI)) * pow(cbrt(((double) M_PI)), 2.0)))));
}
return tmp;
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
double t_0 = Math.cos((Math.PI * (angle / 180.0)));
double t_1 = 2.0 * ((a_m + b) * (b - a_m));
double tmp;
if (a_m <= 2e+173) {
tmp = t_0 * (t_1 * Math.sin((Math.PI * (angle * 0.005555555555555556))));
} else {
tmp = t_0 * (t_1 * Math.sin(((angle / 180.0) * (Math.cbrt(Math.PI) * Math.pow(Math.cbrt(Math.PI), 2.0)))));
}
return tmp;
}
a_m = abs(a) function code(a_m, b, angle) t_0 = cos(Float64(pi * Float64(angle / 180.0))) t_1 = Float64(2.0 * Float64(Float64(a_m + b) * Float64(b - a_m))) tmp = 0.0 if (a_m <= 2e+173) tmp = Float64(t_0 * Float64(t_1 * sin(Float64(pi * Float64(angle * 0.005555555555555556))))); else tmp = Float64(t_0 * Float64(t_1 * sin(Float64(Float64(angle / 180.0) * Float64(cbrt(pi) * (cbrt(pi) ^ 2.0)))))); end return tmp end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_] := Block[{t$95$0 = N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a$95$m, 2e+173], N[(t$95$0 * N[(t$95$1 * N[Sin[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(t$95$1 * N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[Power[N[Power[Pi, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := \cos \left(\pi \cdot \frac{angle}{180}\right)\\
t_1 := 2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\\
\mathbf{if}\;a_m \leq 2 \cdot 10^{+173}:\\
\;\;\;\;t_0 \cdot \left(t_1 \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(t_1 \cdot \sin \left(\frac{angle}{180} \cdot \left(\sqrt[3]{\pi} \cdot {\left(\sqrt[3]{\pi}\right)}^{2}\right)\right)\right)\\
\end{array}
\end{array}
if a < 2e173Initial program 57.0%
unpow257.0%
unpow257.0%
difference-of-squares60.5%
Applied egg-rr60.5%
add-sqr-sqrt28.8%
sqrt-unprod34.8%
pow234.8%
div-inv34.8%
metadata-eval34.8%
Applied egg-rr34.8%
sqrt-pow161.4%
metadata-eval61.4%
pow161.4%
Applied egg-rr61.4%
if 2e173 < a Initial program 33.8%
unpow233.8%
unpow233.8%
difference-of-squares34.4%
Applied egg-rr34.4%
add-cube-cbrt66.0%
pow266.0%
Applied egg-rr66.0%
Final simplification61.8%
a_m = (fabs.f64 a)
(FPCore (a_m b angle)
:precision binary64
(let* ((t_0 (cos (* PI (* angle 0.005555555555555556))))
(t_1 (* 2.0 (* (+ a_m b) (- b a_m)))))
(if (<= a_m 2.6e+14)
(* (* t_1 (sin (/ PI (/ 180.0 angle)))) t_0)
(*
(* t_1 (sin (* (/ angle 180.0) (* (cbrt PI) (pow (cbrt PI) 2.0)))))
t_0))))a_m = fabs(a);
double code(double a_m, double b, double angle) {
double t_0 = cos((((double) M_PI) * (angle * 0.005555555555555556)));
double t_1 = 2.0 * ((a_m + b) * (b - a_m));
double tmp;
if (a_m <= 2.6e+14) {
tmp = (t_1 * sin((((double) M_PI) / (180.0 / angle)))) * t_0;
} else {
tmp = (t_1 * sin(((angle / 180.0) * (cbrt(((double) M_PI)) * pow(cbrt(((double) M_PI)), 2.0))))) * t_0;
}
return tmp;
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
double t_0 = Math.cos((Math.PI * (angle * 0.005555555555555556)));
double t_1 = 2.0 * ((a_m + b) * (b - a_m));
double tmp;
if (a_m <= 2.6e+14) {
tmp = (t_1 * Math.sin((Math.PI / (180.0 / angle)))) * t_0;
} else {
tmp = (t_1 * Math.sin(((angle / 180.0) * (Math.cbrt(Math.PI) * Math.pow(Math.cbrt(Math.PI), 2.0))))) * t_0;
}
return tmp;
}
a_m = abs(a) function code(a_m, b, angle) t_0 = cos(Float64(pi * Float64(angle * 0.005555555555555556))) t_1 = Float64(2.0 * Float64(Float64(a_m + b) * Float64(b - a_m))) tmp = 0.0 if (a_m <= 2.6e+14) tmp = Float64(Float64(t_1 * sin(Float64(pi / Float64(180.0 / angle)))) * t_0); else tmp = Float64(Float64(t_1 * sin(Float64(Float64(angle / 180.0) * Float64(cbrt(pi) * (cbrt(pi) ^ 2.0))))) * t_0); end return tmp end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_] := Block[{t$95$0 = N[Cos[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a$95$m, 2.6e+14], N[(N[(t$95$1 * N[Sin[N[(Pi / N[(180.0 / angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(t$95$1 * N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[Power[N[Power[Pi, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := \cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\\
t_1 := 2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\\
\mathbf{if}\;a_m \leq 2.6 \cdot 10^{+14}:\\
\;\;\;\;\left(t_1 \cdot \sin \left(\frac{\pi}{\frac{180}{angle}}\right)\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\left(t_1 \cdot \sin \left(\frac{angle}{180} \cdot \left(\sqrt[3]{\pi} \cdot {\left(\sqrt[3]{\pi}\right)}^{2}\right)\right)\right) \cdot t_0\\
\end{array}
\end{array}
if a < 2.6e14Initial program 56.8%
unpow256.8%
unpow256.8%
difference-of-squares60.5%
Applied egg-rr60.5%
Taylor expanded in angle around inf 60.3%
associate-*r*60.6%
*-commutative60.6%
*-commutative60.6%
*-commutative60.6%
Simplified60.6%
clear-num60.9%
un-div-inv60.8%
Applied egg-rr60.8%
if 2.6e14 < a Initial program 50.7%
unpow250.7%
unpow250.7%
difference-of-squares52.5%
Applied egg-rr52.5%
Taylor expanded in angle around inf 53.5%
associate-*r*53.7%
*-commutative53.7%
*-commutative53.7%
*-commutative53.7%
Simplified53.7%
add-cube-cbrt62.7%
pow262.7%
Applied egg-rr61.3%
Final simplification60.9%
a_m = (fabs.f64 a)
(FPCore (a_m b angle)
:precision binary64
(let* ((t_0 (* PI (* angle 0.005555555555555556)))
(t_1 (* 2.0 (* (+ a_m b) (- b a_m)))))
(if (<= (- (pow b 2.0) (pow a_m 2.0)) (- INFINITY))
(* t_1 (sin (* 0.005555555555555556 (* PI angle))))
(* (cos t_0) (* t_1 (sin t_0))))))a_m = fabs(a);
double code(double a_m, double b, double angle) {
double t_0 = ((double) M_PI) * (angle * 0.005555555555555556);
double t_1 = 2.0 * ((a_m + b) * (b - a_m));
double tmp;
if ((pow(b, 2.0) - pow(a_m, 2.0)) <= -((double) INFINITY)) {
tmp = t_1 * sin((0.005555555555555556 * (((double) M_PI) * angle)));
} else {
tmp = cos(t_0) * (t_1 * sin(t_0));
}
return tmp;
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
double t_0 = Math.PI * (angle * 0.005555555555555556);
double t_1 = 2.0 * ((a_m + b) * (b - a_m));
double tmp;
if ((Math.pow(b, 2.0) - Math.pow(a_m, 2.0)) <= -Double.POSITIVE_INFINITY) {
tmp = t_1 * Math.sin((0.005555555555555556 * (Math.PI * angle)));
} else {
tmp = Math.cos(t_0) * (t_1 * Math.sin(t_0));
}
return tmp;
}
a_m = math.fabs(a) def code(a_m, b, angle): t_0 = math.pi * (angle * 0.005555555555555556) t_1 = 2.0 * ((a_m + b) * (b - a_m)) tmp = 0 if (math.pow(b, 2.0) - math.pow(a_m, 2.0)) <= -math.inf: tmp = t_1 * math.sin((0.005555555555555556 * (math.pi * angle))) else: tmp = math.cos(t_0) * (t_1 * math.sin(t_0)) return tmp
a_m = abs(a) function code(a_m, b, angle) t_0 = Float64(pi * Float64(angle * 0.005555555555555556)) t_1 = Float64(2.0 * Float64(Float64(a_m + b) * Float64(b - a_m))) tmp = 0.0 if (Float64((b ^ 2.0) - (a_m ^ 2.0)) <= Float64(-Inf)) tmp = Float64(t_1 * sin(Float64(0.005555555555555556 * Float64(pi * angle)))); else tmp = Float64(cos(t_0) * Float64(t_1 * sin(t_0))); end return tmp end
a_m = abs(a); function tmp_2 = code(a_m, b, angle) t_0 = pi * (angle * 0.005555555555555556); t_1 = 2.0 * ((a_m + b) * (b - a_m)); tmp = 0.0; if (((b ^ 2.0) - (a_m ^ 2.0)) <= -Inf) tmp = t_1 * sin((0.005555555555555556 * (pi * angle))); else tmp = cos(t_0) * (t_1 * sin(t_0)); end tmp_2 = tmp; end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a$95$m, 2.0], $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(t$95$1 * N[Sin[N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[t$95$0], $MachinePrecision] * N[(t$95$1 * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := \pi \cdot \left(angle \cdot 0.005555555555555556\right)\\
t_1 := 2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\\
\mathbf{if}\;{b}^{2} - {a_m}^{2} \leq -\infty:\\
\;\;\;\;t_1 \cdot \sin \left(0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos t_0 \cdot \left(t_1 \cdot \sin t_0\right)\\
\end{array}
\end{array}
if (-.f64 (pow.f64 b 2) (pow.f64 a 2)) < -inf.0Initial program 38.7%
unpow238.7%
unpow238.7%
difference-of-squares38.7%
Applied egg-rr38.7%
Taylor expanded in angle around 0 38.7%
Taylor expanded in angle around inf 45.6%
if -inf.0 < (-.f64 (pow.f64 b 2) (pow.f64 a 2)) Initial program 58.8%
unpow258.8%
unpow258.8%
difference-of-squares62.6%
Applied egg-rr62.6%
Taylor expanded in angle around inf 61.8%
associate-*r*63.1%
*-commutative63.1%
*-commutative63.1%
*-commutative63.1%
Simplified63.1%
Taylor expanded in angle around inf 62.5%
associate-*r*63.5%
*-commutative63.5%
*-commutative63.5%
*-commutative63.5%
Simplified63.5%
Final simplification60.4%
a_m = (fabs.f64 a)
(FPCore (a_m b angle)
:precision binary64
(let* ((t_0 (* 2.0 (* (+ a_m b) (- b a_m)))))
(if (<= a_m 1e+164)
(*
(* t_0 (sin (/ PI (/ 180.0 angle))))
(cos (* PI (* angle 0.005555555555555556))))
(*
(cos (* PI (/ angle 180.0)))
(* t_0 (sin (* (/ angle 180.0) (cbrt (pow PI 3.0)))))))))a_m = fabs(a);
double code(double a_m, double b, double angle) {
double t_0 = 2.0 * ((a_m + b) * (b - a_m));
double tmp;
if (a_m <= 1e+164) {
tmp = (t_0 * sin((((double) M_PI) / (180.0 / angle)))) * cos((((double) M_PI) * (angle * 0.005555555555555556)));
} else {
tmp = cos((((double) M_PI) * (angle / 180.0))) * (t_0 * sin(((angle / 180.0) * cbrt(pow(((double) M_PI), 3.0)))));
}
return tmp;
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
double t_0 = 2.0 * ((a_m + b) * (b - a_m));
double tmp;
if (a_m <= 1e+164) {
tmp = (t_0 * Math.sin((Math.PI / (180.0 / angle)))) * Math.cos((Math.PI * (angle * 0.005555555555555556)));
} else {
tmp = Math.cos((Math.PI * (angle / 180.0))) * (t_0 * Math.sin(((angle / 180.0) * Math.cbrt(Math.pow(Math.PI, 3.0)))));
}
return tmp;
}
a_m = abs(a) function code(a_m, b, angle) t_0 = Float64(2.0 * Float64(Float64(a_m + b) * Float64(b - a_m))) tmp = 0.0 if (a_m <= 1e+164) tmp = Float64(Float64(t_0 * sin(Float64(pi / Float64(180.0 / angle)))) * cos(Float64(pi * Float64(angle * 0.005555555555555556)))); else tmp = Float64(cos(Float64(pi * Float64(angle / 180.0))) * Float64(t_0 * sin(Float64(Float64(angle / 180.0) * cbrt((pi ^ 3.0)))))); end return tmp end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_] := Block[{t$95$0 = N[(2.0 * N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a$95$m, 1e+164], N[(N[(t$95$0 * N[Sin[N[(Pi / N[(180.0 / angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * N[Power[N[Power[Pi, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := 2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\\
\mathbf{if}\;a_m \leq 10^{+164}:\\
\;\;\;\;\left(t_0 \cdot \sin \left(\frac{\pi}{\frac{180}{angle}}\right)\right) \cdot \cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(t_0 \cdot \sin \left(\frac{angle}{180} \cdot \sqrt[3]{{\pi}^{3}}\right)\right)\\
\end{array}
\end{array}
if a < 1e164Initial program 58.0%
unpow258.0%
unpow258.0%
difference-of-squares61.0%
Applied egg-rr61.0%
Taylor expanded in angle around inf 60.7%
associate-*r*61.0%
*-commutative61.0%
*-commutative61.0%
*-commutative61.0%
Simplified61.0%
clear-num61.3%
un-div-inv61.2%
Applied egg-rr61.2%
if 1e164 < a Initial program 28.3%
unpow228.3%
unpow228.3%
difference-of-squares33.2%
Applied egg-rr33.2%
add-cbrt-cube50.6%
pow350.6%
Applied egg-rr50.6%
Final simplification60.2%
a_m = (fabs.f64 a)
(FPCore (a_m b angle)
:precision binary64
(let* ((t_0 (* 2.0 (* (+ a_m b) (- b a_m)))))
(if (<= a_m 2e+175)
(*
(cos (* PI (/ angle 180.0)))
(* t_0 (sin (* PI (* angle 0.005555555555555556)))))
(*
t_0
(+
(* -2.8577960676726107e-8 (* (pow angle 3.0) (pow PI 3.0)))
(* 0.005555555555555556 (* PI angle)))))))a_m = fabs(a);
double code(double a_m, double b, double angle) {
double t_0 = 2.0 * ((a_m + b) * (b - a_m));
double tmp;
if (a_m <= 2e+175) {
tmp = cos((((double) M_PI) * (angle / 180.0))) * (t_0 * sin((((double) M_PI) * (angle * 0.005555555555555556))));
} else {
tmp = t_0 * ((-2.8577960676726107e-8 * (pow(angle, 3.0) * pow(((double) M_PI), 3.0))) + (0.005555555555555556 * (((double) M_PI) * angle)));
}
return tmp;
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
double t_0 = 2.0 * ((a_m + b) * (b - a_m));
double tmp;
if (a_m <= 2e+175) {
tmp = Math.cos((Math.PI * (angle / 180.0))) * (t_0 * Math.sin((Math.PI * (angle * 0.005555555555555556))));
} else {
tmp = t_0 * ((-2.8577960676726107e-8 * (Math.pow(angle, 3.0) * Math.pow(Math.PI, 3.0))) + (0.005555555555555556 * (Math.PI * angle)));
}
return tmp;
}
a_m = math.fabs(a) def code(a_m, b, angle): t_0 = 2.0 * ((a_m + b) * (b - a_m)) tmp = 0 if a_m <= 2e+175: tmp = math.cos((math.pi * (angle / 180.0))) * (t_0 * math.sin((math.pi * (angle * 0.005555555555555556)))) else: tmp = t_0 * ((-2.8577960676726107e-8 * (math.pow(angle, 3.0) * math.pow(math.pi, 3.0))) + (0.005555555555555556 * (math.pi * angle))) return tmp
a_m = abs(a) function code(a_m, b, angle) t_0 = Float64(2.0 * Float64(Float64(a_m + b) * Float64(b - a_m))) tmp = 0.0 if (a_m <= 2e+175) tmp = Float64(cos(Float64(pi * Float64(angle / 180.0))) * Float64(t_0 * sin(Float64(pi * Float64(angle * 0.005555555555555556))))); else tmp = Float64(t_0 * Float64(Float64(-2.8577960676726107e-8 * Float64((angle ^ 3.0) * (pi ^ 3.0))) + Float64(0.005555555555555556 * Float64(pi * angle)))); end return tmp end
a_m = abs(a); function tmp_2 = code(a_m, b, angle) t_0 = 2.0 * ((a_m + b) * (b - a_m)); tmp = 0.0; if (a_m <= 2e+175) tmp = cos((pi * (angle / 180.0))) * (t_0 * sin((pi * (angle * 0.005555555555555556)))); else tmp = t_0 * ((-2.8577960676726107e-8 * ((angle ^ 3.0) * (pi ^ 3.0))) + (0.005555555555555556 * (pi * angle))); end tmp_2 = tmp; end
a_m = N[Abs[a], $MachinePrecision]
code[a$95$m_, b_, angle_] := Block[{t$95$0 = N[(2.0 * N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a$95$m, 2e+175], N[(N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * N[Sin[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(-2.8577960676726107e-8 * N[(N[Power[angle, 3.0], $MachinePrecision] * N[Power[Pi, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
a_m = \left|a\right|
\\
\begin{array}{l}
t_0 := 2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\\
\mathbf{if}\;a_m \leq 2 \cdot 10^{+175}:\\
\;\;\;\;\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(t_0 \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(-2.8577960676726107 \cdot 10^{-8} \cdot \left({angle}^{3} \cdot {\pi}^{3}\right) + 0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right)\\
\end{array}
\end{array}
if a < 1.9999999999999999e175Initial program 56.8%
unpow256.8%
unpow256.8%
difference-of-squares60.2%
Applied egg-rr60.2%
add-sqr-sqrt28.7%
sqrt-unprod34.7%
pow234.7%
div-inv34.7%
metadata-eval34.7%
Applied egg-rr34.7%
sqrt-pow161.2%
metadata-eval61.2%
pow161.2%
Applied egg-rr61.2%
if 1.9999999999999999e175 < a Initial program 35.4%
unpow235.4%
unpow235.4%
difference-of-squares36.1%
Applied egg-rr36.1%
Taylor expanded in angle around 0 41.7%
Taylor expanded in angle around 0 52.8%
Final simplification60.6%
a_m = (fabs.f64 a) (FPCore (a_m b angle) :precision binary64 (* (cos (* PI (/ angle 180.0))) (* (* 2.0 (* (+ a_m b) (- b a_m))) (sin (* 0.005555555555555556 (* PI angle))))))
a_m = fabs(a);
double code(double a_m, double b, double angle) {
return cos((((double) M_PI) * (angle / 180.0))) * ((2.0 * ((a_m + b) * (b - a_m))) * sin((0.005555555555555556 * (((double) M_PI) * angle))));
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
return Math.cos((Math.PI * (angle / 180.0))) * ((2.0 * ((a_m + b) * (b - a_m))) * Math.sin((0.005555555555555556 * (Math.PI * angle))));
}
a_m = math.fabs(a) def code(a_m, b, angle): return math.cos((math.pi * (angle / 180.0))) * ((2.0 * ((a_m + b) * (b - a_m))) * math.sin((0.005555555555555556 * (math.pi * angle))))
a_m = abs(a) function code(a_m, b, angle) return Float64(cos(Float64(pi * Float64(angle / 180.0))) * Float64(Float64(2.0 * Float64(Float64(a_m + b) * Float64(b - a_m))) * sin(Float64(0.005555555555555556 * Float64(pi * angle))))) end
a_m = abs(a); function tmp = code(a_m, b, angle) tmp = cos((pi * (angle / 180.0))) * ((2.0 * ((a_m + b) * (b - a_m))) * sin((0.005555555555555556 * (pi * angle)))); end
a_m = N[Abs[a], $MachinePrecision] code[a$95$m_, b_, angle_] := N[(N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(2.0 * N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(\left(2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\right) \cdot \sin \left(0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right)\right)
\end{array}
Initial program 55.3%
unpow255.3%
unpow255.3%
difference-of-squares58.5%
Applied egg-rr58.5%
Taylor expanded in angle around inf 58.5%
Final simplification58.5%
a_m = (fabs.f64 a) (FPCore (a_m b angle) :precision binary64 (* (cos (* PI (/ angle 180.0))) (* (* 2.0 (* (+ a_m b) (- b a_m))) (sin (* PI (* angle 0.005555555555555556))))))
a_m = fabs(a);
double code(double a_m, double b, double angle) {
return cos((((double) M_PI) * (angle / 180.0))) * ((2.0 * ((a_m + b) * (b - a_m))) * sin((((double) M_PI) * (angle * 0.005555555555555556))));
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
return Math.cos((Math.PI * (angle / 180.0))) * ((2.0 * ((a_m + b) * (b - a_m))) * Math.sin((Math.PI * (angle * 0.005555555555555556))));
}
a_m = math.fabs(a) def code(a_m, b, angle): return math.cos((math.pi * (angle / 180.0))) * ((2.0 * ((a_m + b) * (b - a_m))) * math.sin((math.pi * (angle * 0.005555555555555556))))
a_m = abs(a) function code(a_m, b, angle) return Float64(cos(Float64(pi * Float64(angle / 180.0))) * Float64(Float64(2.0 * Float64(Float64(a_m + b) * Float64(b - a_m))) * sin(Float64(pi * Float64(angle * 0.005555555555555556))))) end
a_m = abs(a); function tmp = code(a_m, b, angle) tmp = cos((pi * (angle / 180.0))) * ((2.0 * ((a_m + b) * (b - a_m))) * sin((pi * (angle * 0.005555555555555556)))); end
a_m = N[Abs[a], $MachinePrecision] code[a$95$m_, b_, angle_] := N[(N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(2.0 * N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(\left(2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\right) \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)
\end{array}
Initial program 55.3%
unpow255.3%
unpow255.3%
difference-of-squares58.5%
Applied egg-rr58.5%
add-sqr-sqrt28.0%
sqrt-unprod34.2%
pow234.2%
div-inv34.2%
metadata-eval34.2%
Applied egg-rr34.2%
sqrt-pow159.8%
metadata-eval59.8%
pow159.8%
Applied egg-rr59.8%
Final simplification59.8%
a_m = (fabs.f64 a) (FPCore (a_m b angle) :precision binary64 (* (* 2.0 (* (+ a_m b) (- b a_m))) (sin (* 0.005555555555555556 (* PI angle)))))
a_m = fabs(a);
double code(double a_m, double b, double angle) {
return (2.0 * ((a_m + b) * (b - a_m))) * sin((0.005555555555555556 * (((double) M_PI) * angle)));
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
return (2.0 * ((a_m + b) * (b - a_m))) * Math.sin((0.005555555555555556 * (Math.PI * angle)));
}
a_m = math.fabs(a) def code(a_m, b, angle): return (2.0 * ((a_m + b) * (b - a_m))) * math.sin((0.005555555555555556 * (math.pi * angle)))
a_m = abs(a) function code(a_m, b, angle) return Float64(Float64(2.0 * Float64(Float64(a_m + b) * Float64(b - a_m))) * sin(Float64(0.005555555555555556 * Float64(pi * angle)))) end
a_m = abs(a); function tmp = code(a_m, b, angle) tmp = (2.0 * ((a_m + b) * (b - a_m))) * sin((0.005555555555555556 * (pi * angle))); end
a_m = N[Abs[a], $MachinePrecision] code[a$95$m_, b_, angle_] := N[(N[(2.0 * N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
\left(2 \cdot \left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right)\right) \cdot \sin \left(0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right)
\end{array}
Initial program 55.3%
unpow255.3%
unpow255.3%
difference-of-squares58.5%
Applied egg-rr58.5%
Taylor expanded in angle around 0 55.4%
Taylor expanded in angle around inf 57.8%
Final simplification57.8%
a_m = (fabs.f64 a) (FPCore (a_m b angle) :precision binary64 (* 0.011111111111111112 (* angle (* (* (+ a_m b) (- b a_m)) PI))))
a_m = fabs(a);
double code(double a_m, double b, double angle) {
return 0.011111111111111112 * (angle * (((a_m + b) * (b - a_m)) * ((double) M_PI)));
}
a_m = Math.abs(a);
public static double code(double a_m, double b, double angle) {
return 0.011111111111111112 * (angle * (((a_m + b) * (b - a_m)) * Math.PI));
}
a_m = math.fabs(a) def code(a_m, b, angle): return 0.011111111111111112 * (angle * (((a_m + b) * (b - a_m)) * math.pi))
a_m = abs(a) function code(a_m, b, angle) return Float64(0.011111111111111112 * Float64(angle * Float64(Float64(Float64(a_m + b) * Float64(b - a_m)) * pi))) end
a_m = abs(a); function tmp = code(a_m, b, angle) tmp = 0.011111111111111112 * (angle * (((a_m + b) * (b - a_m)) * pi)); end
a_m = N[Abs[a], $MachinePrecision] code[a$95$m_, b_, angle_] := N[(0.011111111111111112 * N[(angle * N[(N[(N[(a$95$m + b), $MachinePrecision] * N[(b - a$95$m), $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
0.011111111111111112 \cdot \left(angle \cdot \left(\left(\left(a_m + b\right) \cdot \left(b - a_m\right)\right) \cdot \pi\right)\right)
\end{array}
Initial program 55.3%
unpow255.3%
unpow255.3%
difference-of-squares58.5%
Applied egg-rr58.5%
Taylor expanded in angle around 0 55.4%
Taylor expanded in angle around 0 54.9%
Final simplification54.9%
herbie shell --seed 2024019
(FPCore (a b angle)
:name "ab-angle->ABCF B"
:precision binary64
(* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* PI (/ angle 180.0)))) (cos (* PI (/ angle 180.0)))))