
(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 14 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}
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (cbrt (cos (* PI (* 0.005555555555555556 angle))))))
(*
2.0
(*
(- b a)
(*
(* t_0 (* t_0 t_0))
(*
(sin
(*
0.005555555555555556
(* angle (* (cbrt PI) (* (cbrt PI) (cbrt PI))))))
(+ b a)))))))
double code(double a, double b, double angle) {
double t_0 = cbrt(cos((((double) M_PI) * (0.005555555555555556 * angle))));
return 2.0 * ((b - a) * ((t_0 * (t_0 * t_0)) * (sin((0.005555555555555556 * (angle * (cbrt(((double) M_PI)) * (cbrt(((double) M_PI)) * cbrt(((double) M_PI))))))) * (b + a))));
}
public static double code(double a, double b, double angle) {
double t_0 = Math.cbrt(Math.cos((Math.PI * (0.005555555555555556 * angle))));
return 2.0 * ((b - a) * ((t_0 * (t_0 * t_0)) * (Math.sin((0.005555555555555556 * (angle * (Math.cbrt(Math.PI) * (Math.cbrt(Math.PI) * Math.cbrt(Math.PI)))))) * (b + a))));
}
function code(a, b, angle) t_0 = cbrt(cos(Float64(pi * Float64(0.005555555555555556 * angle)))) return Float64(2.0 * Float64(Float64(b - a) * Float64(Float64(t_0 * Float64(t_0 * t_0)) * Float64(sin(Float64(0.005555555555555556 * Float64(angle * Float64(cbrt(pi) * Float64(cbrt(pi) * cbrt(pi)))))) * Float64(b + a))))) end
code[a_, b_, angle_] := Block[{t$95$0 = N[Power[N[Cos[N[(Pi * N[(0.005555555555555556 * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, N[(2.0 * N[(N[(b - a), $MachinePrecision] * N[(N[(t$95$0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[N[(0.005555555555555556 * N[(angle * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[Power[Pi, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\cos \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)}\\
2 \cdot \left(\left(b - a\right) \cdot \left(\left(t_0 \cdot \left(t_0 \cdot t_0\right)\right) \cdot \left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \left(\sqrt[3]{\pi} \cdot \left(\sqrt[3]{\pi} \cdot \sqrt[3]{\pi}\right)\right)\right)\right) \cdot \left(b + a\right)\right)\right)\right)
\end{array}
\end{array}
Initial program 53.6%
associate-*l*53.6%
unpow253.6%
unpow253.6%
difference-of-squares56.9%
Simplified56.9%
Taylor expanded in angle around inf 66.6%
add-cube-cbrt66.8%
Applied egg-rr66.8%
associate-*r*67.7%
*-commutative67.7%
metadata-eval67.7%
div-inv67.8%
*-commutative67.8%
div-inv67.7%
metadata-eval67.7%
*-commutative67.7%
add-cube-cbrt67.7%
Applied egg-rr67.7%
Final simplification67.7%
(FPCore (a b angle)
:precision binary64
(*
2.0
(*
(- b a)
(*
(*
(sin
(* 0.005555555555555556 (* angle (* (cbrt PI) (* (cbrt PI) (cbrt PI))))))
(+ b a))
(log (exp (cos (* PI (* 0.005555555555555556 angle)))))))))
double code(double a, double b, double angle) {
return 2.0 * ((b - a) * ((sin((0.005555555555555556 * (angle * (cbrt(((double) M_PI)) * (cbrt(((double) M_PI)) * cbrt(((double) M_PI))))))) * (b + a)) * log(exp(cos((((double) M_PI) * (0.005555555555555556 * angle)))))));
}
public static double code(double a, double b, double angle) {
return 2.0 * ((b - a) * ((Math.sin((0.005555555555555556 * (angle * (Math.cbrt(Math.PI) * (Math.cbrt(Math.PI) * Math.cbrt(Math.PI)))))) * (b + a)) * Math.log(Math.exp(Math.cos((Math.PI * (0.005555555555555556 * angle)))))));
}
function code(a, b, angle) return Float64(2.0 * Float64(Float64(b - a) * Float64(Float64(sin(Float64(0.005555555555555556 * Float64(angle * Float64(cbrt(pi) * Float64(cbrt(pi) * cbrt(pi)))))) * Float64(b + a)) * log(exp(cos(Float64(pi * Float64(0.005555555555555556 * angle)))))))) end
code[a_, b_, angle_] := N[(2.0 * N[(N[(b - a), $MachinePrecision] * N[(N[(N[Sin[N[(0.005555555555555556 * N[(angle * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[Power[Pi, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision] * N[Log[N[Exp[N[Cos[N[(Pi * N[(0.005555555555555556 * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\left(b - a\right) \cdot \left(\left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \left(\sqrt[3]{\pi} \cdot \left(\sqrt[3]{\pi} \cdot \sqrt[3]{\pi}\right)\right)\right)\right) \cdot \left(b + a\right)\right) \cdot \log \left(e^{\cos \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)}\right)\right)\right)
\end{array}
Initial program 53.6%
associate-*l*53.6%
unpow253.6%
unpow253.6%
difference-of-squares56.9%
Simplified56.9%
Taylor expanded in angle around inf 66.6%
add-cube-cbrt66.8%
Applied egg-rr66.8%
associate-*r*67.7%
*-commutative67.7%
metadata-eval67.7%
div-inv67.8%
*-commutative67.8%
div-inv67.7%
metadata-eval67.7%
*-commutative67.7%
add-log-exp67.7%
Applied egg-rr67.7%
Final simplification67.7%
(FPCore (a b angle)
:precision binary64
(*
2.0
(*
(- b a)
(*
(*
(sin
(* 0.005555555555555556 (* angle (* (cbrt PI) (* (cbrt PI) (cbrt PI))))))
(+ b a))
(log1p (expm1 (cos (* PI (* 0.005555555555555556 angle)))))))))
double code(double a, double b, double angle) {
return 2.0 * ((b - a) * ((sin((0.005555555555555556 * (angle * (cbrt(((double) M_PI)) * (cbrt(((double) M_PI)) * cbrt(((double) M_PI))))))) * (b + a)) * log1p(expm1(cos((((double) M_PI) * (0.005555555555555556 * angle)))))));
}
public static double code(double a, double b, double angle) {
return 2.0 * ((b - a) * ((Math.sin((0.005555555555555556 * (angle * (Math.cbrt(Math.PI) * (Math.cbrt(Math.PI) * Math.cbrt(Math.PI)))))) * (b + a)) * Math.log1p(Math.expm1(Math.cos((Math.PI * (0.005555555555555556 * angle)))))));
}
function code(a, b, angle) return Float64(2.0 * Float64(Float64(b - a) * Float64(Float64(sin(Float64(0.005555555555555556 * Float64(angle * Float64(cbrt(pi) * Float64(cbrt(pi) * cbrt(pi)))))) * Float64(b + a)) * log1p(expm1(cos(Float64(pi * Float64(0.005555555555555556 * angle)))))))) end
code[a_, b_, angle_] := N[(2.0 * N[(N[(b - a), $MachinePrecision] * N[(N[(N[Sin[N[(0.005555555555555556 * N[(angle * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[Power[Pi, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision] * N[Log[1 + N[(Exp[N[Cos[N[(Pi * N[(0.005555555555555556 * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\left(b - a\right) \cdot \left(\left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \left(\sqrt[3]{\pi} \cdot \left(\sqrt[3]{\pi} \cdot \sqrt[3]{\pi}\right)\right)\right)\right) \cdot \left(b + a\right)\right) \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right)\right)\right)
\end{array}
Initial program 53.6%
associate-*l*53.6%
unpow253.6%
unpow253.6%
difference-of-squares56.9%
Simplified56.9%
Taylor expanded in angle around inf 66.6%
add-cube-cbrt66.8%
Applied egg-rr66.8%
associate-*r*67.7%
*-commutative67.7%
metadata-eval67.7%
div-inv67.8%
*-commutative67.8%
div-inv67.7%
metadata-eval67.7%
*-commutative67.7%
log1p-expm1-u67.7%
Applied egg-rr67.7%
Final simplification67.7%
(FPCore (a b angle)
:precision binary64
(*
2.0
(*
(- b a)
(*
(*
(sin
(* 0.005555555555555556 (* angle (* (cbrt PI) (* (cbrt PI) (cbrt PI))))))
(+ b a))
(cos (* 0.005555555555555556 (* PI angle)))))))
double code(double a, double b, double angle) {
return 2.0 * ((b - a) * ((sin((0.005555555555555556 * (angle * (cbrt(((double) M_PI)) * (cbrt(((double) M_PI)) * cbrt(((double) M_PI))))))) * (b + a)) * cos((0.005555555555555556 * (((double) M_PI) * angle)))));
}
public static double code(double a, double b, double angle) {
return 2.0 * ((b - a) * ((Math.sin((0.005555555555555556 * (angle * (Math.cbrt(Math.PI) * (Math.cbrt(Math.PI) * Math.cbrt(Math.PI)))))) * (b + a)) * Math.cos((0.005555555555555556 * (Math.PI * angle)))));
}
function code(a, b, angle) return Float64(2.0 * Float64(Float64(b - a) * Float64(Float64(sin(Float64(0.005555555555555556 * Float64(angle * Float64(cbrt(pi) * Float64(cbrt(pi) * cbrt(pi)))))) * Float64(b + a)) * cos(Float64(0.005555555555555556 * Float64(pi * angle)))))) end
code[a_, b_, angle_] := N[(2.0 * N[(N[(b - a), $MachinePrecision] * N[(N[(N[Sin[N[(0.005555555555555556 * N[(angle * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[Power[Pi, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\left(b - a\right) \cdot \left(\left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \left(\sqrt[3]{\pi} \cdot \left(\sqrt[3]{\pi} \cdot \sqrt[3]{\pi}\right)\right)\right)\right) \cdot \left(b + a\right)\right) \cdot \cos \left(0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right)\right)\right)
\end{array}
Initial program 53.6%
associate-*l*53.6%
unpow253.6%
unpow253.6%
difference-of-squares56.9%
Simplified56.9%
Taylor expanded in angle around inf 66.6%
add-cube-cbrt66.8%
Applied egg-rr66.8%
Final simplification66.8%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* 0.005555555555555556 (* PI angle))))
(if (<= a -1.3e+111)
(* 2.0 (* (- b a) (* (+ b a) (sin t_0))))
(*
2.0
(*
(* (- b a) (cos t_0))
(* (+ b a) (sin (* PI (* 0.005555555555555556 angle)))))))))
double code(double a, double b, double angle) {
double t_0 = 0.005555555555555556 * (((double) M_PI) * angle);
double tmp;
if (a <= -1.3e+111) {
tmp = 2.0 * ((b - a) * ((b + a) * sin(t_0)));
} else {
tmp = 2.0 * (((b - a) * cos(t_0)) * ((b + a) * sin((((double) M_PI) * (0.005555555555555556 * angle)))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = 0.005555555555555556 * (Math.PI * angle);
double tmp;
if (a <= -1.3e+111) {
tmp = 2.0 * ((b - a) * ((b + a) * Math.sin(t_0)));
} else {
tmp = 2.0 * (((b - a) * Math.cos(t_0)) * ((b + a) * Math.sin((Math.PI * (0.005555555555555556 * angle)))));
}
return tmp;
}
def code(a, b, angle): t_0 = 0.005555555555555556 * (math.pi * angle) tmp = 0 if a <= -1.3e+111: tmp = 2.0 * ((b - a) * ((b + a) * math.sin(t_0))) else: tmp = 2.0 * (((b - a) * math.cos(t_0)) * ((b + a) * math.sin((math.pi * (0.005555555555555556 * angle))))) return tmp
function code(a, b, angle) t_0 = Float64(0.005555555555555556 * Float64(pi * angle)) tmp = 0.0 if (a <= -1.3e+111) tmp = Float64(2.0 * Float64(Float64(b - a) * Float64(Float64(b + a) * sin(t_0)))); else tmp = Float64(2.0 * Float64(Float64(Float64(b - a) * cos(t_0)) * Float64(Float64(b + a) * sin(Float64(pi * Float64(0.005555555555555556 * angle)))))); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = 0.005555555555555556 * (pi * angle); tmp = 0.0; if (a <= -1.3e+111) tmp = 2.0 * ((b - a) * ((b + a) * sin(t_0))); else tmp = 2.0 * (((b - a) * cos(t_0)) * ((b + a) * sin((pi * (0.005555555555555556 * angle))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -1.3e+111], N[(2.0 * N[(N[(b - a), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[(N[(b - a), $MachinePrecision] * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[Sin[N[(Pi * N[(0.005555555555555556 * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(\pi \cdot angle\right)\\
\mathbf{if}\;a \leq -1.3 \cdot 10^{+111}:\\
\;\;\;\;2 \cdot \left(\left(b - a\right) \cdot \left(\left(b + a\right) \cdot \sin t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\left(\left(b - a\right) \cdot \cos t_0\right) \cdot \left(\left(b + a\right) \cdot \sin \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < -1.2999999999999999e111Initial program 25.5%
associate-*l*25.5%
unpow225.5%
unpow225.5%
difference-of-squares41.9%
Simplified41.9%
Taylor expanded in angle around inf 70.8%
Taylor expanded in angle around 0 77.0%
if -1.2999999999999999e111 < a Initial program 58.5%
associate-*l*58.5%
unpow258.5%
unpow258.5%
difference-of-squares59.5%
Simplified59.5%
Taylor expanded in angle around inf 65.9%
associate-*r*65.9%
*-commutative65.9%
*-commutative65.9%
associate-*r*64.5%
*-commutative64.5%
*-commutative64.5%
*-commutative64.5%
associate-*r*65.5%
*-commutative65.5%
+-commutative65.5%
Simplified65.5%
Taylor expanded in angle around inf 66.1%
Final simplification67.7%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* 0.005555555555555556 (* PI angle)))) (* 2.0 (* (- b a) (* (cos t_0) (* (+ b a) (sin t_0)))))))
double code(double a, double b, double angle) {
double t_0 = 0.005555555555555556 * (((double) M_PI) * angle);
return 2.0 * ((b - a) * (cos(t_0) * ((b + a) * sin(t_0))));
}
public static double code(double a, double b, double angle) {
double t_0 = 0.005555555555555556 * (Math.PI * angle);
return 2.0 * ((b - a) * (Math.cos(t_0) * ((b + a) * Math.sin(t_0))));
}
def code(a, b, angle): t_0 = 0.005555555555555556 * (math.pi * angle) return 2.0 * ((b - a) * (math.cos(t_0) * ((b + a) * math.sin(t_0))))
function code(a, b, angle) t_0 = Float64(0.005555555555555556 * Float64(pi * angle)) return Float64(2.0 * Float64(Float64(b - a) * Float64(cos(t_0) * Float64(Float64(b + a) * sin(t_0))))) end
function tmp = code(a, b, angle) t_0 = 0.005555555555555556 * (pi * angle); tmp = 2.0 * ((b - a) * (cos(t_0) * ((b + a) * sin(t_0)))); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]}, N[(2.0 * N[(N[(b - a), $MachinePrecision] * N[(N[Cos[t$95$0], $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(\pi \cdot angle\right)\\
2 \cdot \left(\left(b - a\right) \cdot \left(\cos t_0 \cdot \left(\left(b + a\right) \cdot \sin t_0\right)\right)\right)
\end{array}
\end{array}
Initial program 53.6%
associate-*l*53.6%
unpow253.6%
unpow253.6%
difference-of-squares56.9%
Simplified56.9%
Taylor expanded in angle around inf 66.6%
Final simplification66.6%
(FPCore (a b angle)
:precision binary64
(*
2.0
(*
(- b a)
(*
(cos (/ (* PI angle) 180.0))
(* (+ b a) (sin (* 0.005555555555555556 (* PI angle))))))))
double code(double a, double b, double angle) {
return 2.0 * ((b - a) * (cos(((((double) M_PI) * angle) / 180.0)) * ((b + a) * sin((0.005555555555555556 * (((double) M_PI) * angle))))));
}
public static double code(double a, double b, double angle) {
return 2.0 * ((b - a) * (Math.cos(((Math.PI * angle) / 180.0)) * ((b + a) * Math.sin((0.005555555555555556 * (Math.PI * angle))))));
}
def code(a, b, angle): return 2.0 * ((b - a) * (math.cos(((math.pi * angle) / 180.0)) * ((b + a) * math.sin((0.005555555555555556 * (math.pi * angle))))))
function code(a, b, angle) return Float64(2.0 * Float64(Float64(b - a) * Float64(cos(Float64(Float64(pi * angle) / 180.0)) * Float64(Float64(b + a) * sin(Float64(0.005555555555555556 * Float64(pi * angle))))))) end
function tmp = code(a, b, angle) tmp = 2.0 * ((b - a) * (cos(((pi * angle) / 180.0)) * ((b + a) * sin((0.005555555555555556 * (pi * angle)))))); end
code[a_, b_, angle_] := N[(2.0 * N[(N[(b - a), $MachinePrecision] * N[(N[Cos[N[(N[(Pi * angle), $MachinePrecision] / 180.0), $MachinePrecision]], $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[Sin[N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\left(b - a\right) \cdot \left(\cos \left(\frac{\pi \cdot angle}{180}\right) \cdot \left(\left(b + a\right) \cdot \sin \left(0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right)\right)\right)\right)
\end{array}
Initial program 53.6%
associate-*l*53.6%
unpow253.6%
unpow253.6%
difference-of-squares56.9%
Simplified56.9%
Taylor expanded in angle around inf 66.6%
associate-*r*65.1%
*-commutative65.1%
metadata-eval65.1%
div-inv65.2%
*-commutative65.2%
associate-*r/66.6%
Applied egg-rr66.6%
Final simplification66.6%
(FPCore (a b angle) :precision binary64 (* 2.0 (* (- b a) (* (+ b a) (sin (* 0.005555555555555556 (* PI angle)))))))
double code(double a, double b, double angle) {
return 2.0 * ((b - a) * ((b + a) * sin((0.005555555555555556 * (((double) M_PI) * angle)))));
}
public static double code(double a, double b, double angle) {
return 2.0 * ((b - a) * ((b + a) * Math.sin((0.005555555555555556 * (Math.PI * angle)))));
}
def code(a, b, angle): return 2.0 * ((b - a) * ((b + a) * math.sin((0.005555555555555556 * (math.pi * angle)))))
function code(a, b, angle) return Float64(2.0 * Float64(Float64(b - a) * Float64(Float64(b + a) * sin(Float64(0.005555555555555556 * Float64(pi * angle)))))) end
function tmp = code(a, b, angle) tmp = 2.0 * ((b - a) * ((b + a) * sin((0.005555555555555556 * (pi * angle))))); end
code[a_, b_, angle_] := N[(2.0 * N[(N[(b - a), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[Sin[N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\left(b - a\right) \cdot \left(\left(b + a\right) \cdot \sin \left(0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right)\right)\right)
\end{array}
Initial program 53.6%
associate-*l*53.6%
unpow253.6%
unpow253.6%
difference-of-squares56.9%
Simplified56.9%
Taylor expanded in angle around inf 66.6%
Taylor expanded in angle around 0 65.1%
Final simplification65.1%
(FPCore (a b angle) :precision binary64 (if (or (<= b -2.9e-77) (not (<= b 2.2e+31))) (* 0.011111111111111112 (* PI (* b (* b angle)))) (* 0.011111111111111112 (* angle (* (- b a) (* a PI))))))
double code(double a, double b, double angle) {
double tmp;
if ((b <= -2.9e-77) || !(b <= 2.2e+31)) {
tmp = 0.011111111111111112 * (((double) M_PI) * (b * (b * angle)));
} else {
tmp = 0.011111111111111112 * (angle * ((b - a) * (a * ((double) M_PI))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if ((b <= -2.9e-77) || !(b <= 2.2e+31)) {
tmp = 0.011111111111111112 * (Math.PI * (b * (b * angle)));
} else {
tmp = 0.011111111111111112 * (angle * ((b - a) * (a * Math.PI)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if (b <= -2.9e-77) or not (b <= 2.2e+31): tmp = 0.011111111111111112 * (math.pi * (b * (b * angle))) else: tmp = 0.011111111111111112 * (angle * ((b - a) * (a * math.pi))) return tmp
function code(a, b, angle) tmp = 0.0 if ((b <= -2.9e-77) || !(b <= 2.2e+31)) tmp = Float64(0.011111111111111112 * Float64(pi * Float64(b * Float64(b * angle)))); else tmp = Float64(0.011111111111111112 * Float64(angle * Float64(Float64(b - a) * Float64(a * pi)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if ((b <= -2.9e-77) || ~((b <= 2.2e+31))) tmp = 0.011111111111111112 * (pi * (b * (b * angle))); else tmp = 0.011111111111111112 * (angle * ((b - a) * (a * pi))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[Or[LessEqual[b, -2.9e-77], N[Not[LessEqual[b, 2.2e+31]], $MachinePrecision]], N[(0.011111111111111112 * N[(Pi * N[(b * N[(b * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.011111111111111112 * N[(angle * N[(N[(b - a), $MachinePrecision] * N[(a * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.9 \cdot 10^{-77} \lor \neg \left(b \leq 2.2 \cdot 10^{+31}\right):\\
\;\;\;\;0.011111111111111112 \cdot \left(\pi \cdot \left(b \cdot \left(b \cdot angle\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.011111111111111112 \cdot \left(angle \cdot \left(\left(b - a\right) \cdot \left(a \cdot \pi\right)\right)\right)\\
\end{array}
\end{array}
if b < -2.8999999999999999e-77 or 2.2000000000000001e31 < b Initial program 53.0%
associate-*l*53.0%
unpow253.0%
unpow253.0%
difference-of-squares59.8%
Simplified59.8%
Taylor expanded in angle around 0 56.5%
Taylor expanded in b around inf 48.9%
*-commutative48.9%
unpow248.9%
Simplified48.9%
Taylor expanded in angle around 0 48.9%
*-commutative48.9%
associate-*l*48.9%
unpow248.9%
Simplified48.9%
Taylor expanded in angle around 0 48.9%
unpow248.9%
associate-*r*48.8%
*-commutative48.8%
associate-*r*56.5%
Simplified56.5%
if -2.8999999999999999e-77 < b < 2.2000000000000001e31Initial program 54.2%
associate-*l*54.2%
unpow254.2%
unpow254.2%
difference-of-squares54.2%
Simplified54.2%
Taylor expanded in angle around 0 51.7%
Taylor expanded in a around inf 47.1%
*-commutative47.1%
Simplified47.1%
Final simplification51.6%
(FPCore (a b angle) :precision binary64 (if (<= b 3.8e+171) (* 0.011111111111111112 (* angle (* (- b a) (* PI (+ b a))))) (* 0.011111111111111112 (* PI (* b (* b angle))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 3.8e+171) {
tmp = 0.011111111111111112 * (angle * ((b - a) * (((double) M_PI) * (b + a))));
} else {
tmp = 0.011111111111111112 * (((double) M_PI) * (b * (b * angle)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 3.8e+171) {
tmp = 0.011111111111111112 * (angle * ((b - a) * (Math.PI * (b + a))));
} else {
tmp = 0.011111111111111112 * (Math.PI * (b * (b * angle)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 3.8e+171: tmp = 0.011111111111111112 * (angle * ((b - a) * (math.pi * (b + a)))) else: tmp = 0.011111111111111112 * (math.pi * (b * (b * angle))) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 3.8e+171) tmp = Float64(0.011111111111111112 * Float64(angle * Float64(Float64(b - a) * Float64(pi * Float64(b + a))))); else tmp = Float64(0.011111111111111112 * Float64(pi * Float64(b * Float64(b * angle)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 3.8e+171) tmp = 0.011111111111111112 * (angle * ((b - a) * (pi * (b + a)))); else tmp = 0.011111111111111112 * (pi * (b * (b * angle))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 3.8e+171], N[(0.011111111111111112 * N[(angle * N[(N[(b - a), $MachinePrecision] * N[(Pi * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.011111111111111112 * N[(Pi * N[(b * N[(b * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.8 \cdot 10^{+171}:\\
\;\;\;\;0.011111111111111112 \cdot \left(angle \cdot \left(\left(b - a\right) \cdot \left(\pi \cdot \left(b + a\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.011111111111111112 \cdot \left(\pi \cdot \left(b \cdot \left(b \cdot angle\right)\right)\right)\\
\end{array}
\end{array}
if b < 3.8000000000000002e171Initial program 57.2%
associate-*l*57.2%
unpow257.2%
unpow257.2%
difference-of-squares58.1%
Simplified58.1%
Taylor expanded in angle around 0 53.6%
if 3.8000000000000002e171 < b Initial program 23.3%
associate-*l*23.3%
unpow223.3%
unpow223.3%
difference-of-squares46.3%
Simplified46.3%
Taylor expanded in angle around 0 57.4%
Taylor expanded in b around inf 57.1%
*-commutative57.1%
unpow257.1%
Simplified57.1%
Taylor expanded in angle around 0 57.1%
*-commutative57.1%
associate-*l*57.1%
unpow257.1%
Simplified57.1%
Taylor expanded in angle around 0 57.1%
unpow257.1%
associate-*r*57.1%
*-commutative57.1%
associate-*r*81.3%
Simplified81.3%
Final simplification56.5%
(FPCore (a b angle) :precision binary64 (if (<= angle 9.5e+142) (* 0.011111111111111112 (* (* (- b a) angle) (* PI (+ b a)))) (* 0.011111111111111112 (* angle (* (- b a) (* b PI))))))
double code(double a, double b, double angle) {
double tmp;
if (angle <= 9.5e+142) {
tmp = 0.011111111111111112 * (((b - a) * angle) * (((double) M_PI) * (b + a)));
} else {
tmp = 0.011111111111111112 * (angle * ((b - a) * (b * ((double) M_PI))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (angle <= 9.5e+142) {
tmp = 0.011111111111111112 * (((b - a) * angle) * (Math.PI * (b + a)));
} else {
tmp = 0.011111111111111112 * (angle * ((b - a) * (b * Math.PI)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if angle <= 9.5e+142: tmp = 0.011111111111111112 * (((b - a) * angle) * (math.pi * (b + a))) else: tmp = 0.011111111111111112 * (angle * ((b - a) * (b * math.pi))) return tmp
function code(a, b, angle) tmp = 0.0 if (angle <= 9.5e+142) tmp = Float64(0.011111111111111112 * Float64(Float64(Float64(b - a) * angle) * Float64(pi * Float64(b + a)))); else tmp = Float64(0.011111111111111112 * Float64(angle * Float64(Float64(b - a) * Float64(b * pi)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (angle <= 9.5e+142) tmp = 0.011111111111111112 * (((b - a) * angle) * (pi * (b + a))); else tmp = 0.011111111111111112 * (angle * ((b - a) * (b * pi))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[angle, 9.5e+142], N[(0.011111111111111112 * N[(N[(N[(b - a), $MachinePrecision] * angle), $MachinePrecision] * N[(Pi * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.011111111111111112 * N[(angle * N[(N[(b - a), $MachinePrecision] * N[(b * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 9.5 \cdot 10^{+142}:\\
\;\;\;\;0.011111111111111112 \cdot \left(\left(\left(b - a\right) \cdot angle\right) \cdot \left(\pi \cdot \left(b + a\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.011111111111111112 \cdot \left(angle \cdot \left(\left(b - a\right) \cdot \left(b \cdot \pi\right)\right)\right)\\
\end{array}
\end{array}
if angle < 9.50000000000000001e142Initial program 57.2%
associate-*l*57.2%
unpow257.2%
unpow257.2%
difference-of-squares60.5%
Simplified60.5%
Taylor expanded in angle around 0 58.3%
associate-*r*66.5%
*-commutative66.5%
+-commutative66.5%
Simplified66.5%
if 9.50000000000000001e142 < angle Initial program 28.2%
associate-*l*28.2%
unpow228.2%
unpow228.2%
difference-of-squares31.4%
Simplified31.4%
Taylor expanded in angle around 0 23.8%
Taylor expanded in a around 0 27.4%
*-commutative27.4%
Simplified27.4%
Final simplification61.6%
(FPCore (a b angle) :precision binary64 (if (or (<= b -9.2e-136) (not (<= b 4.5e+51))) (* 0.011111111111111112 (* PI (* b (* b angle)))) (* 0.011111111111111112 (* angle (* PI (* a (- a)))))))
double code(double a, double b, double angle) {
double tmp;
if ((b <= -9.2e-136) || !(b <= 4.5e+51)) {
tmp = 0.011111111111111112 * (((double) M_PI) * (b * (b * angle)));
} else {
tmp = 0.011111111111111112 * (angle * (((double) M_PI) * (a * -a)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if ((b <= -9.2e-136) || !(b <= 4.5e+51)) {
tmp = 0.011111111111111112 * (Math.PI * (b * (b * angle)));
} else {
tmp = 0.011111111111111112 * (angle * (Math.PI * (a * -a)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if (b <= -9.2e-136) or not (b <= 4.5e+51): tmp = 0.011111111111111112 * (math.pi * (b * (b * angle))) else: tmp = 0.011111111111111112 * (angle * (math.pi * (a * -a))) return tmp
function code(a, b, angle) tmp = 0.0 if ((b <= -9.2e-136) || !(b <= 4.5e+51)) tmp = Float64(0.011111111111111112 * Float64(pi * Float64(b * Float64(b * angle)))); else tmp = Float64(0.011111111111111112 * Float64(angle * Float64(pi * Float64(a * Float64(-a))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if ((b <= -9.2e-136) || ~((b <= 4.5e+51))) tmp = 0.011111111111111112 * (pi * (b * (b * angle))); else tmp = 0.011111111111111112 * (angle * (pi * (a * -a))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[Or[LessEqual[b, -9.2e-136], N[Not[LessEqual[b, 4.5e+51]], $MachinePrecision]], N[(0.011111111111111112 * N[(Pi * N[(b * N[(b * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.011111111111111112 * N[(angle * N[(Pi * N[(a * (-a)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.2 \cdot 10^{-136} \lor \neg \left(b \leq 4.5 \cdot 10^{+51}\right):\\
\;\;\;\;0.011111111111111112 \cdot \left(\pi \cdot \left(b \cdot \left(b \cdot angle\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(a \cdot \left(-a\right)\right)\right)\right)\\
\end{array}
\end{array}
if b < -9.19999999999999994e-136 or 4.5e51 < b Initial program 51.8%
associate-*l*51.8%
unpow251.8%
unpow251.8%
difference-of-squares57.9%
Simplified57.9%
Taylor expanded in angle around 0 53.8%
Taylor expanded in b around inf 47.1%
*-commutative47.1%
unpow247.1%
Simplified47.1%
Taylor expanded in angle around 0 47.1%
*-commutative47.1%
associate-*l*47.1%
unpow247.1%
Simplified47.1%
Taylor expanded in angle around 0 47.1%
unpow247.1%
associate-*r*47.1%
*-commutative47.1%
associate-*r*54.0%
Simplified54.0%
if -9.19999999999999994e-136 < b < 4.5e51Initial program 55.6%
associate-*l*55.6%
unpow255.6%
unpow255.6%
difference-of-squares55.6%
Simplified55.6%
Taylor expanded in angle around 0 54.2%
Taylor expanded in b around 0 48.8%
mul-1-neg48.8%
distribute-rgt-neg-in48.8%
*-commutative48.8%
distribute-rgt-neg-in48.8%
unpow248.8%
Simplified48.8%
Final simplification51.5%
(FPCore (a b angle) :precision binary64 (* 0.011111111111111112 (* angle (* PI (* b b)))))
double code(double a, double b, double angle) {
return 0.011111111111111112 * (angle * (((double) M_PI) * (b * b)));
}
public static double code(double a, double b, double angle) {
return 0.011111111111111112 * (angle * (Math.PI * (b * b)));
}
def code(a, b, angle): return 0.011111111111111112 * (angle * (math.pi * (b * b)))
function code(a, b, angle) return Float64(0.011111111111111112 * Float64(angle * Float64(pi * Float64(b * b)))) end
function tmp = code(a, b, angle) tmp = 0.011111111111111112 * (angle * (pi * (b * b))); end
code[a_, b_, angle_] := N[(0.011111111111111112 * N[(angle * N[(Pi * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(b \cdot b\right)\right)\right)
\end{array}
Initial program 53.6%
associate-*l*53.6%
unpow253.6%
unpow253.6%
difference-of-squares56.9%
Simplified56.9%
Taylor expanded in angle around 0 54.0%
Taylor expanded in b around inf 37.9%
*-commutative37.9%
unpow237.9%
Simplified37.9%
Final simplification37.9%
(FPCore (a b angle) :precision binary64 (* 0.011111111111111112 (* PI (* b (* b angle)))))
double code(double a, double b, double angle) {
return 0.011111111111111112 * (((double) M_PI) * (b * (b * angle)));
}
public static double code(double a, double b, double angle) {
return 0.011111111111111112 * (Math.PI * (b * (b * angle)));
}
def code(a, b, angle): return 0.011111111111111112 * (math.pi * (b * (b * angle)))
function code(a, b, angle) return Float64(0.011111111111111112 * Float64(pi * Float64(b * Float64(b * angle)))) end
function tmp = code(a, b, angle) tmp = 0.011111111111111112 * (pi * (b * (b * angle))); end
code[a_, b_, angle_] := N[(0.011111111111111112 * N[(Pi * N[(b * N[(b * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.011111111111111112 \cdot \left(\pi \cdot \left(b \cdot \left(b \cdot angle\right)\right)\right)
\end{array}
Initial program 53.6%
associate-*l*53.6%
unpow253.6%
unpow253.6%
difference-of-squares56.9%
Simplified56.9%
Taylor expanded in angle around 0 54.0%
Taylor expanded in b around inf 37.9%
*-commutative37.9%
unpow237.9%
Simplified37.9%
Taylor expanded in angle around 0 37.9%
*-commutative37.9%
associate-*l*37.9%
unpow237.9%
Simplified37.9%
Taylor expanded in angle around 0 37.9%
unpow237.9%
associate-*r*37.9%
*-commutative37.9%
associate-*r*40.4%
Simplified40.4%
Final simplification40.4%
herbie shell --seed 2023178
(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)))))