
(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 7 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}
angle_m = (fabs.f64 angle)
angle_s = (copysign.f64 1 angle)
(FPCore (angle_s a b angle_m)
:precision binary64
(let* ((t_0 (* PI (/ angle_m 180.0)))
(t_1 (cos t_0))
(t_2 (* 2.0 (- (pow b 2.0) (pow a 2.0))))
(t_3 (cbrt (log PI)))
(t_4 (* (/ angle_m 180.0) (* (cbrt PI) (pow (cbrt PI) 2.0)))))
(*
angle_s
(if (<= (* (* t_2 (sin t_0)) t_1) 2e+174)
(* (* t_2 (sin t_4)) (cos t_4))
(*
t_1
(*
t_2
(sin
(*
(/ angle_m 180.0)
(* (cbrt PI) (pow (cbrt (pow (exp (pow t_3 2.0)) t_3)) 2.0))))))))))angle_m = fabs(angle);
angle_s = copysign(1.0, angle);
double code(double angle_s, double a, double b, double angle_m) {
double t_0 = ((double) M_PI) * (angle_m / 180.0);
double t_1 = cos(t_0);
double t_2 = 2.0 * (pow(b, 2.0) - pow(a, 2.0));
double t_3 = cbrt(log(((double) M_PI)));
double t_4 = (angle_m / 180.0) * (cbrt(((double) M_PI)) * pow(cbrt(((double) M_PI)), 2.0));
double tmp;
if (((t_2 * sin(t_0)) * t_1) <= 2e+174) {
tmp = (t_2 * sin(t_4)) * cos(t_4);
} else {
tmp = t_1 * (t_2 * sin(((angle_m / 180.0) * (cbrt(((double) M_PI)) * pow(cbrt(pow(exp(pow(t_3, 2.0)), t_3)), 2.0)))));
}
return angle_s * tmp;
}
angle_m = Math.abs(angle);
angle_s = Math.copySign(1.0, angle);
public static double code(double angle_s, double a, double b, double angle_m) {
double t_0 = Math.PI * (angle_m / 180.0);
double t_1 = Math.cos(t_0);
double t_2 = 2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0));
double t_3 = Math.cbrt(Math.log(Math.PI));
double t_4 = (angle_m / 180.0) * (Math.cbrt(Math.PI) * Math.pow(Math.cbrt(Math.PI), 2.0));
double tmp;
if (((t_2 * Math.sin(t_0)) * t_1) <= 2e+174) {
tmp = (t_2 * Math.sin(t_4)) * Math.cos(t_4);
} else {
tmp = t_1 * (t_2 * Math.sin(((angle_m / 180.0) * (Math.cbrt(Math.PI) * Math.pow(Math.cbrt(Math.pow(Math.exp(Math.pow(t_3, 2.0)), t_3)), 2.0)))));
}
return angle_s * tmp;
}
angle_m = abs(angle) angle_s = copysign(1.0, angle) function code(angle_s, a, b, angle_m) t_0 = Float64(pi * Float64(angle_m / 180.0)) t_1 = cos(t_0) t_2 = Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) t_3 = cbrt(log(pi)) t_4 = Float64(Float64(angle_m / 180.0) * Float64(cbrt(pi) * (cbrt(pi) ^ 2.0))) tmp = 0.0 if (Float64(Float64(t_2 * sin(t_0)) * t_1) <= 2e+174) tmp = Float64(Float64(t_2 * sin(t_4)) * cos(t_4)); else tmp = Float64(t_1 * Float64(t_2 * sin(Float64(Float64(angle_m / 180.0) * Float64(cbrt(pi) * (cbrt((exp((t_3 ^ 2.0)) ^ t_3)) ^ 2.0)))))); end return Float64(angle_s * tmp) end
angle_m = N[Abs[angle], $MachinePrecision]
angle_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[angle]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[angle$95$s_, a_, b_, angle$95$m_] := Block[{t$95$0 = N[(Pi * N[(angle$95$m / 180.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Log[Pi], $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$4 = N[(N[(angle$95$m / 180.0), $MachinePrecision] * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[Power[N[Power[Pi, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(angle$95$s * If[LessEqual[N[(N[(t$95$2 * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], 2e+174], N[(N[(t$95$2 * N[Sin[t$95$4], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$4], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(t$95$2 * N[Sin[N[(N[(angle$95$m / 180.0), $MachinePrecision] * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[Power[N[Power[N[Power[N[Exp[N[Power[t$95$3, 2.0], $MachinePrecision]], $MachinePrecision], t$95$3], $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]]]]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
angle_s = \mathsf{copysign}\left(1, angle\right)
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle\_m}{180}\\
t_1 := \cos t\_0\\
t_2 := 2 \cdot \left({b}^{2} - {a}^{2}\right)\\
t_3 := \sqrt[3]{\log \pi}\\
t_4 := \frac{angle\_m}{180} \cdot \left(\sqrt[3]{\pi} \cdot {\left(\sqrt[3]{\pi}\right)}^{2}\right)\\
angle\_s \cdot \begin{array}{l}
\mathbf{if}\;\left(t\_2 \cdot \sin t\_0\right) \cdot t\_1 \leq 2 \cdot 10^{+174}:\\
\;\;\;\;\left(t\_2 \cdot \sin t\_4\right) \cdot \cos t\_4\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(t\_2 \cdot \sin \left(\frac{angle\_m}{180} \cdot \left(\sqrt[3]{\pi} \cdot {\left(\sqrt[3]{{\left(e^{{t\_3}^{2}}\right)}^{t\_3}}\right)}^{2}\right)\right)\right)\\
\end{array}
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 2 (-.f64 (pow.f64 b 2) (pow.f64 a 2))) (sin.f64 (*.f64 (PI.f64) (/.f64 angle 180)))) (cos.f64 (*.f64 (PI.f64) (/.f64 angle 180)))) < 2.00000000000000014e174Initial program 58.6%
add-cube-cbrt60.0%
pow260.0%
Applied egg-rr60.0%
add-cube-cbrt60.0%
pow260.0%
Applied egg-rr58.9%
if 2.00000000000000014e174 < (*.f64 (*.f64 (*.f64 2 (-.f64 (pow.f64 b 2) (pow.f64 a 2))) (sin.f64 (*.f64 (PI.f64) (/.f64 angle 180)))) (cos.f64 (*.f64 (PI.f64) (/.f64 angle 180)))) Initial program 37.1%
add-cube-cbrt39.2%
pow239.2%
Applied egg-rr33.5%
add-exp-log33.5%
add-cube-cbrt37.0%
exp-prod38.3%
pow238.3%
Applied egg-rr38.3%
Final simplification53.5%
angle_m = (fabs.f64 angle)
angle_s = (copysign.f64 1 angle)
(FPCore (angle_s a b angle_m)
:precision binary64
(let* ((t_0 (* PI (/ angle_m 180.0)))
(t_1 (* (/ angle_m 180.0) (cbrt (pow PI 3.0))))
(t_2 (* 2.0 (- (pow b 2.0) (pow a 2.0))))
(t_3 (* (/ angle_m 180.0) (* (cbrt PI) (pow (cbrt PI) 2.0)))))
(*
angle_s
(if (<= (* (* t_2 (sin t_0)) (cos t_0)) -2e-42)
(* (* t_2 (sin t_3)) (cos t_3))
(* (* t_2 (sin t_1)) (cos t_1))))))angle_m = fabs(angle);
angle_s = copysign(1.0, angle);
double code(double angle_s, double a, double b, double angle_m) {
double t_0 = ((double) M_PI) * (angle_m / 180.0);
double t_1 = (angle_m / 180.0) * cbrt(pow(((double) M_PI), 3.0));
double t_2 = 2.0 * (pow(b, 2.0) - pow(a, 2.0));
double t_3 = (angle_m / 180.0) * (cbrt(((double) M_PI)) * pow(cbrt(((double) M_PI)), 2.0));
double tmp;
if (((t_2 * sin(t_0)) * cos(t_0)) <= -2e-42) {
tmp = (t_2 * sin(t_3)) * cos(t_3);
} else {
tmp = (t_2 * sin(t_1)) * cos(t_1);
}
return angle_s * tmp;
}
angle_m = Math.abs(angle);
angle_s = Math.copySign(1.0, angle);
public static double code(double angle_s, double a, double b, double angle_m) {
double t_0 = Math.PI * (angle_m / 180.0);
double t_1 = (angle_m / 180.0) * Math.cbrt(Math.pow(Math.PI, 3.0));
double t_2 = 2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0));
double t_3 = (angle_m / 180.0) * (Math.cbrt(Math.PI) * Math.pow(Math.cbrt(Math.PI), 2.0));
double tmp;
if (((t_2 * Math.sin(t_0)) * Math.cos(t_0)) <= -2e-42) {
tmp = (t_2 * Math.sin(t_3)) * Math.cos(t_3);
} else {
tmp = (t_2 * Math.sin(t_1)) * Math.cos(t_1);
}
return angle_s * tmp;
}
angle_m = abs(angle) angle_s = copysign(1.0, angle) function code(angle_s, a, b, angle_m) t_0 = Float64(pi * Float64(angle_m / 180.0)) t_1 = Float64(Float64(angle_m / 180.0) * cbrt((pi ^ 3.0))) t_2 = Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) t_3 = Float64(Float64(angle_m / 180.0) * Float64(cbrt(pi) * (cbrt(pi) ^ 2.0))) tmp = 0.0 if (Float64(Float64(t_2 * sin(t_0)) * cos(t_0)) <= -2e-42) tmp = Float64(Float64(t_2 * sin(t_3)) * cos(t_3)); else tmp = Float64(Float64(t_2 * sin(t_1)) * cos(t_1)); end return Float64(angle_s * tmp) end
angle_m = N[Abs[angle], $MachinePrecision]
angle_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[angle]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[angle$95$s_, a_, b_, angle$95$m_] := Block[{t$95$0 = N[(Pi * N[(angle$95$m / 180.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(angle$95$m / 180.0), $MachinePrecision] * N[Power[N[Power[Pi, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(angle$95$m / 180.0), $MachinePrecision] * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[Power[N[Power[Pi, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(angle$95$s * If[LessEqual[N[(N[(t$95$2 * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], -2e-42], N[(N[(t$95$2 * N[Sin[t$95$3], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$3], $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]]]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
angle_s = \mathsf{copysign}\left(1, angle\right)
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle\_m}{180}\\
t_1 := \frac{angle\_m}{180} \cdot \sqrt[3]{{\pi}^{3}}\\
t_2 := 2 \cdot \left({b}^{2} - {a}^{2}\right)\\
t_3 := \frac{angle\_m}{180} \cdot \left(\sqrt[3]{\pi} \cdot {\left(\sqrt[3]{\pi}\right)}^{2}\right)\\
angle\_s \cdot \begin{array}{l}
\mathbf{if}\;\left(t\_2 \cdot \sin t\_0\right) \cdot \cos t\_0 \leq -2 \cdot 10^{-42}:\\
\;\;\;\;\left(t\_2 \cdot \sin t\_3\right) \cdot \cos t\_3\\
\mathbf{else}:\\
\;\;\;\;\left(t\_2 \cdot \sin t\_1\right) \cdot \cos t\_1\\
\end{array}
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 2 (-.f64 (pow.f64 b 2) (pow.f64 a 2))) (sin.f64 (*.f64 (PI.f64) (/.f64 angle 180)))) (cos.f64 (*.f64 (PI.f64) (/.f64 angle 180)))) < -2.00000000000000008e-42Initial program 46.2%
add-cube-cbrt48.3%
pow248.3%
Applied egg-rr48.3%
add-cube-cbrt48.3%
pow248.3%
Applied egg-rr47.0%
if -2.00000000000000008e-42 < (*.f64 (*.f64 (*.f64 2 (-.f64 (pow.f64 b 2) (pow.f64 a 2))) (sin.f64 (*.f64 (PI.f64) (/.f64 angle 180)))) (cos.f64 (*.f64 (PI.f64) (/.f64 angle 180)))) Initial program 56.7%
rem-cbrt-cube54.8%
Applied egg-rr54.8%
rem-cbrt-cube54.8%
Applied egg-rr58.0%
Final simplification54.1%
angle_m = (fabs.f64 angle)
angle_s = (copysign.f64 1 angle)
(FPCore (angle_s a b angle_m)
:precision binary64
(let* ((t_0 (cbrt (log PI)))
(t_1 (* (/ angle_m 180.0) (* (cbrt PI) (pow (cbrt PI) 2.0))))
(t_2 (* 2.0 (- (pow b 2.0) (pow a 2.0)))))
(*
angle_s
(if (<= (/ angle_m 180.0) 1.4e+180)
(* (* t_2 (sin t_1)) (cos t_1))
(*
(* t_2 (sin (* (/ angle_m 180.0) (pow (exp (pow t_0 2.0)) t_0))))
(cos (* (/ angle_m 180.0) (pow (sqrt PI) 2.0))))))))angle_m = fabs(angle);
angle_s = copysign(1.0, angle);
double code(double angle_s, double a, double b, double angle_m) {
double t_0 = cbrt(log(((double) M_PI)));
double t_1 = (angle_m / 180.0) * (cbrt(((double) M_PI)) * pow(cbrt(((double) M_PI)), 2.0));
double t_2 = 2.0 * (pow(b, 2.0) - pow(a, 2.0));
double tmp;
if ((angle_m / 180.0) <= 1.4e+180) {
tmp = (t_2 * sin(t_1)) * cos(t_1);
} else {
tmp = (t_2 * sin(((angle_m / 180.0) * pow(exp(pow(t_0, 2.0)), t_0)))) * cos(((angle_m / 180.0) * pow(sqrt(((double) M_PI)), 2.0)));
}
return angle_s * tmp;
}
angle_m = Math.abs(angle);
angle_s = Math.copySign(1.0, angle);
public static double code(double angle_s, double a, double b, double angle_m) {
double t_0 = Math.cbrt(Math.log(Math.PI));
double t_1 = (angle_m / 180.0) * (Math.cbrt(Math.PI) * Math.pow(Math.cbrt(Math.PI), 2.0));
double t_2 = 2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0));
double tmp;
if ((angle_m / 180.0) <= 1.4e+180) {
tmp = (t_2 * Math.sin(t_1)) * Math.cos(t_1);
} else {
tmp = (t_2 * Math.sin(((angle_m / 180.0) * Math.pow(Math.exp(Math.pow(t_0, 2.0)), t_0)))) * Math.cos(((angle_m / 180.0) * Math.pow(Math.sqrt(Math.PI), 2.0)));
}
return angle_s * tmp;
}
angle_m = abs(angle) angle_s = copysign(1.0, angle) function code(angle_s, a, b, angle_m) t_0 = cbrt(log(pi)) t_1 = Float64(Float64(angle_m / 180.0) * Float64(cbrt(pi) * (cbrt(pi) ^ 2.0))) t_2 = Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) tmp = 0.0 if (Float64(angle_m / 180.0) <= 1.4e+180) tmp = Float64(Float64(t_2 * sin(t_1)) * cos(t_1)); else tmp = Float64(Float64(t_2 * sin(Float64(Float64(angle_m / 180.0) * (exp((t_0 ^ 2.0)) ^ t_0)))) * cos(Float64(Float64(angle_m / 180.0) * (sqrt(pi) ^ 2.0)))); end return Float64(angle_s * tmp) end
angle_m = N[Abs[angle], $MachinePrecision]
angle_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[angle]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[angle$95$s_, a_, b_, angle$95$m_] := Block[{t$95$0 = N[Power[N[Log[Pi], $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[(angle$95$m / 180.0), $MachinePrecision] * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[Power[N[Power[Pi, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(angle$95$s * If[LessEqual[N[(angle$95$m / 180.0), $MachinePrecision], 1.4e+180], N[(N[(t$95$2 * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 * N[Sin[N[(N[(angle$95$m / 180.0), $MachinePrecision] * N[Power[N[Exp[N[Power[t$95$0, 2.0], $MachinePrecision]], $MachinePrecision], t$95$0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(angle$95$m / 180.0), $MachinePrecision] * N[Power[N[Sqrt[Pi], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
angle_s = \mathsf{copysign}\left(1, angle\right)
\\
\begin{array}{l}
t_0 := \sqrt[3]{\log \pi}\\
t_1 := \frac{angle\_m}{180} \cdot \left(\sqrt[3]{\pi} \cdot {\left(\sqrt[3]{\pi}\right)}^{2}\right)\\
t_2 := 2 \cdot \left({b}^{2} - {a}^{2}\right)\\
angle\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{angle\_m}{180} \leq 1.4 \cdot 10^{+180}:\\
\;\;\;\;\left(t\_2 \cdot \sin t\_1\right) \cdot \cos t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(t\_2 \cdot \sin \left(\frac{angle\_m}{180} \cdot {\left(e^{{t\_0}^{2}}\right)}^{t\_0}\right)\right) \cdot \cos \left(\frac{angle\_m}{180} \cdot {\left(\sqrt{\pi}\right)}^{2}\right)\\
\end{array}
\end{array}
\end{array}
if (/.f64 angle 180) < 1.40000000000000006e180Initial program 55.9%
add-cube-cbrt56.1%
pow256.1%
Applied egg-rr56.1%
add-cube-cbrt56.1%
pow256.1%
Applied egg-rr56.9%
if 1.40000000000000006e180 < (/.f64 angle 180) Initial program 22.6%
add-exp-log37.7%
add-cube-cbrt27.7%
exp-prod40.0%
pow240.0%
Applied egg-rr32.2%
add-sqr-sqrt33.6%
pow233.6%
Applied egg-rr41.2%
Final simplification55.6%
angle_m = (fabs.f64 angle)
angle_s = (copysign.f64 1 angle)
(FPCore (angle_s a b angle_m)
:precision binary64
(let* ((t_0 (* (/ angle_m 180.0) (cbrt (pow PI 3.0)))))
(*
angle_s
(* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin t_0)) (cos t_0)))))angle_m = fabs(angle);
angle_s = copysign(1.0, angle);
double code(double angle_s, double a, double b, double angle_m) {
double t_0 = (angle_m / 180.0) * cbrt(pow(((double) M_PI), 3.0));
return angle_s * (((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin(t_0)) * cos(t_0));
}
angle_m = Math.abs(angle);
angle_s = Math.copySign(1.0, angle);
public static double code(double angle_s, double a, double b, double angle_m) {
double t_0 = (angle_m / 180.0) * Math.cbrt(Math.pow(Math.PI, 3.0));
return angle_s * (((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * Math.sin(t_0)) * Math.cos(t_0));
}
angle_m = abs(angle) angle_s = copysign(1.0, angle) function code(angle_s, a, b, angle_m) t_0 = Float64(Float64(angle_m / 180.0) * cbrt((pi ^ 3.0))) return Float64(angle_s * Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * sin(t_0)) * cos(t_0))) end
angle_m = N[Abs[angle], $MachinePrecision]
angle_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[angle]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[angle$95$s_, a_, b_, angle$95$m_] := Block[{t$95$0 = N[(N[(angle$95$m / 180.0), $MachinePrecision] * N[Power[N[Power[Pi, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, N[(angle$95$s * 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]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
angle_s = \mathsf{copysign}\left(1, angle\right)
\\
\begin{array}{l}
t_0 := \frac{angle\_m}{180} \cdot \sqrt[3]{{\pi}^{3}}\\
angle\_s \cdot \left(\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin t\_0\right) \cdot \cos t\_0\right)
\end{array}
\end{array}
Initial program 53.0%
rem-cbrt-cube51.9%
Applied egg-rr51.9%
rem-cbrt-cube51.9%
Applied egg-rr55.4%
Final simplification55.4%
angle_m = (fabs.f64 angle) angle_s = (copysign.f64 1 angle) (FPCore (angle_s a b angle_m) :precision binary64 (* angle_s (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* PI (/ angle_m 180.0)))) (cos (* (/ angle_m 180.0) (* (cbrt PI) (pow (cbrt PI) 2.0)))))))
angle_m = fabs(angle);
angle_s = copysign(1.0, angle);
double code(double angle_s, double a, double b, double angle_m) {
return angle_s * (((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin((((double) M_PI) * (angle_m / 180.0)))) * cos(((angle_m / 180.0) * (cbrt(((double) M_PI)) * pow(cbrt(((double) M_PI)), 2.0)))));
}
angle_m = Math.abs(angle);
angle_s = Math.copySign(1.0, angle);
public static double code(double angle_s, double a, double b, double angle_m) {
return angle_s * (((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * Math.sin((Math.PI * (angle_m / 180.0)))) * Math.cos(((angle_m / 180.0) * (Math.cbrt(Math.PI) * Math.pow(Math.cbrt(Math.PI), 2.0)))));
}
angle_m = abs(angle) angle_s = copysign(1.0, angle) function code(angle_s, a, b, angle_m) return Float64(angle_s * Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * sin(Float64(pi * Float64(angle_m / 180.0)))) * cos(Float64(Float64(angle_m / 180.0) * Float64(cbrt(pi) * (cbrt(pi) ^ 2.0)))))) end
angle_m = N[Abs[angle], $MachinePrecision]
angle_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[angle]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[angle$95$s_, a_, b_, angle$95$m_] := N[(angle$95$s * N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(Pi * N[(angle$95$m / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(angle$95$m / 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}
angle_m = \left|angle\right|
\\
angle_s = \mathsf{copysign}\left(1, angle\right)
\\
angle\_s \cdot \left(\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle\_m}{180}\right)\right) \cdot \cos \left(\frac{angle\_m}{180} \cdot \left(\sqrt[3]{\pi} \cdot {\left(\sqrt[3]{\pi}\right)}^{2}\right)\right)\right)
\end{array}
Initial program 53.0%
add-cube-cbrt54.6%
pow254.6%
Applied egg-rr54.6%
Final simplification54.6%
angle_m = (fabs.f64 angle) angle_s = (copysign.f64 1 angle) (FPCore (angle_s a b angle_m) :precision binary64 (* angle_s (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* PI (/ angle_m 180.0)))) (cos (* (/ angle_m 180.0) (pow (sqrt PI) 2.0))))))
angle_m = fabs(angle);
angle_s = copysign(1.0, angle);
double code(double angle_s, double a, double b, double angle_m) {
return angle_s * (((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin((((double) M_PI) * (angle_m / 180.0)))) * cos(((angle_m / 180.0) * pow(sqrt(((double) M_PI)), 2.0))));
}
angle_m = Math.abs(angle);
angle_s = Math.copySign(1.0, angle);
public static double code(double angle_s, double a, double b, double angle_m) {
return angle_s * (((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * Math.sin((Math.PI * (angle_m / 180.0)))) * Math.cos(((angle_m / 180.0) * Math.pow(Math.sqrt(Math.PI), 2.0))));
}
angle_m = math.fabs(angle) angle_s = math.copysign(1.0, angle) def code(angle_s, a, b, angle_m): return angle_s * (((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * math.sin((math.pi * (angle_m / 180.0)))) * math.cos(((angle_m / 180.0) * math.pow(math.sqrt(math.pi), 2.0))))
angle_m = abs(angle) angle_s = copysign(1.0, angle) function code(angle_s, a, b, angle_m) return Float64(angle_s * Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * sin(Float64(pi * Float64(angle_m / 180.0)))) * cos(Float64(Float64(angle_m / 180.0) * (sqrt(pi) ^ 2.0))))) end
angle_m = abs(angle); angle_s = sign(angle) * abs(1.0); function tmp = code(angle_s, a, b, angle_m) tmp = angle_s * (((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * sin((pi * (angle_m / 180.0)))) * cos(((angle_m / 180.0) * (sqrt(pi) ^ 2.0)))); end
angle_m = N[Abs[angle], $MachinePrecision]
angle_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[angle]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[angle$95$s_, a_, b_, angle$95$m_] := N[(angle$95$s * N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(Pi * N[(angle$95$m / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(angle$95$m / 180.0), $MachinePrecision] * N[Power[N[Sqrt[Pi], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
angle_s = \mathsf{copysign}\left(1, angle\right)
\\
angle\_s \cdot \left(\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle\_m}{180}\right)\right) \cdot \cos \left(\frac{angle\_m}{180} \cdot {\left(\sqrt{\pi}\right)}^{2}\right)\right)
\end{array}
Initial program 53.0%
add-sqr-sqrt54.3%
pow254.3%
Applied egg-rr54.3%
Final simplification54.3%
angle_m = (fabs.f64 angle)
angle_s = (copysign.f64 1 angle)
(FPCore (angle_s a b angle_m)
:precision binary64
(let* ((t_0 (* PI (/ angle_m 180.0))))
(*
angle_s
(* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin t_0)) (cos t_0)))))angle_m = fabs(angle);
angle_s = copysign(1.0, angle);
double code(double angle_s, double a, double b, double angle_m) {
double t_0 = ((double) M_PI) * (angle_m / 180.0);
return angle_s * (((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin(t_0)) * cos(t_0));
}
angle_m = Math.abs(angle);
angle_s = Math.copySign(1.0, angle);
public static double code(double angle_s, double a, double b, double angle_m) {
double t_0 = Math.PI * (angle_m / 180.0);
return angle_s * (((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * Math.sin(t_0)) * Math.cos(t_0));
}
angle_m = math.fabs(angle) angle_s = math.copysign(1.0, angle) def code(angle_s, a, b, angle_m): t_0 = math.pi * (angle_m / 180.0) return angle_s * (((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * math.sin(t_0)) * math.cos(t_0))
angle_m = abs(angle) angle_s = copysign(1.0, angle) function code(angle_s, a, b, angle_m) t_0 = Float64(pi * Float64(angle_m / 180.0)) return Float64(angle_s * Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * sin(t_0)) * cos(t_0))) end
angle_m = abs(angle); angle_s = sign(angle) * abs(1.0); function tmp = code(angle_s, a, b, angle_m) t_0 = pi * (angle_m / 180.0); tmp = angle_s * (((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * sin(t_0)) * cos(t_0)); end
angle_m = N[Abs[angle], $MachinePrecision]
angle_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[angle]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[angle$95$s_, a_, b_, angle$95$m_] := Block[{t$95$0 = N[(Pi * N[(angle$95$m / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(angle$95$s * 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]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
angle_s = \mathsf{copysign}\left(1, angle\right)
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle\_m}{180}\\
angle\_s \cdot \left(\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin t\_0\right) \cdot \cos t\_0\right)
\end{array}
\end{array}
Initial program 53.0%
Final simplification53.0%
herbie shell --seed 2024034
(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)))))