
(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 11 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 (* angle -0.005555555555555556)))))
(t_1 (* (+ b a) (- a b))))
(if (<= (- (pow b 2.0) (pow a 2.0)) (- INFINITY))
(*
(* 2.0 (sin (* angle (/ (* (cbrt PI) (pow (cbrt PI) 2.0)) -180.0))))
(* (cos (/ (* angle (cbrt (pow PI 3.0))) -180.0)) t_1))
(* (* 2.0 (sin (* angle (/ PI -180.0)))) (* t_1 (* t_0 (pow t_0 2.0)))))))
double code(double a, double b, double angle) {
double t_0 = cbrt(cos((((double) M_PI) * (angle * -0.005555555555555556))));
double t_1 = (b + a) * (a - b);
double tmp;
if ((pow(b, 2.0) - pow(a, 2.0)) <= -((double) INFINITY)) {
tmp = (2.0 * sin((angle * ((cbrt(((double) M_PI)) * pow(cbrt(((double) M_PI)), 2.0)) / -180.0)))) * (cos(((angle * cbrt(pow(((double) M_PI), 3.0))) / -180.0)) * t_1);
} else {
tmp = (2.0 * sin((angle * (((double) M_PI) / -180.0)))) * (t_1 * (t_0 * pow(t_0, 2.0)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = Math.cbrt(Math.cos((Math.PI * (angle * -0.005555555555555556))));
double t_1 = (b + a) * (a - b);
double tmp;
if ((Math.pow(b, 2.0) - Math.pow(a, 2.0)) <= -Double.POSITIVE_INFINITY) {
tmp = (2.0 * Math.sin((angle * ((Math.cbrt(Math.PI) * Math.pow(Math.cbrt(Math.PI), 2.0)) / -180.0)))) * (Math.cos(((angle * Math.cbrt(Math.pow(Math.PI, 3.0))) / -180.0)) * t_1);
} else {
tmp = (2.0 * Math.sin((angle * (Math.PI / -180.0)))) * (t_1 * (t_0 * Math.pow(t_0, 2.0)));
}
return tmp;
}
function code(a, b, angle) t_0 = cbrt(cos(Float64(pi * Float64(angle * -0.005555555555555556)))) t_1 = Float64(Float64(b + a) * Float64(a - b)) tmp = 0.0 if (Float64((b ^ 2.0) - (a ^ 2.0)) <= Float64(-Inf)) tmp = Float64(Float64(2.0 * sin(Float64(angle * Float64(Float64(cbrt(pi) * (cbrt(pi) ^ 2.0)) / -180.0)))) * Float64(cos(Float64(Float64(angle * cbrt((pi ^ 3.0))) / -180.0)) * t_1)); else tmp = Float64(Float64(2.0 * sin(Float64(angle * Float64(pi / -180.0)))) * Float64(t_1 * Float64(t_0 * (t_0 ^ 2.0)))); end return tmp end
code[a_, b_, angle_] := Block[{t$95$0 = N[Power[N[Cos[N[(Pi * N[(angle * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[(b + a), $MachinePrecision] * N[(a - b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[(2.0 * N[Sin[N[(angle * N[(N[(N[Power[Pi, 1/3], $MachinePrecision] * N[Power[N[Power[Pi, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / -180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[N[(N[(angle * N[Power[N[Power[Pi, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] / -180.0), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Sin[N[(angle * N[(Pi / -180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * N[(t$95$0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\cos \left(\pi \cdot \left(angle \cdot -0.005555555555555556\right)\right)}\\
t_1 := \left(b + a\right) \cdot \left(a - b\right)\\
\mathbf{if}\;{b}^{2} - {a}^{2} \leq -\infty:\\
\;\;\;\;\left(2 \cdot \sin \left(angle \cdot \frac{\sqrt[3]{\pi} \cdot {\left(\sqrt[3]{\pi}\right)}^{2}}{-180}\right)\right) \cdot \left(\cos \left(\frac{angle \cdot \sqrt[3]{{\pi}^{3}}}{-180}\right) \cdot t_1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \sin \left(angle \cdot \frac{\pi}{-180}\right)\right) \cdot \left(t_1 \cdot \left(t_0 \cdot {t_0}^{2}\right)\right)\\
\end{array}
\end{array}
if (-.f64 (pow.f64 b 2) (pow.f64 a 2)) < -inf.0Initial program 52.4%
Simplified56.3%
unpow256.3%
unpow256.3%
difference-of-squares56.3%
Applied egg-rr56.3%
associate-*r/56.3%
Applied egg-rr56.3%
add-cbrt-cube54.3%
pow354.3%
Applied egg-rr54.3%
add-cube-cbrt62.2%
pow262.2%
Applied egg-rr62.2%
if -inf.0 < (-.f64 (pow.f64 b 2) (pow.f64 a 2)) Initial program 49.2%
Simplified51.1%
unpow251.1%
unpow251.1%
difference-of-squares56.1%
Applied egg-rr56.1%
associate-*r/57.2%
Applied egg-rr57.2%
add-cube-cbrt57.1%
pow257.1%
div-inv57.1%
metadata-eval57.1%
*-commutative57.1%
associate-*r*57.2%
div-inv56.1%
metadata-eval56.1%
*-commutative56.1%
associate-*r*57.8%
Applied egg-rr57.8%
Final simplification58.7%
(FPCore (a b angle) :precision binary64 (if (<= (- (pow b 2.0) (pow a 2.0)) -2e-286) (* (pow a 2.0) (- (sin (* angle (* PI 0.011111111111111112))))) (* (* (+ b a) (- a b)) (* 2.0 (sin (* angle (/ PI -180.0)))))))
double code(double a, double b, double angle) {
double tmp;
if ((pow(b, 2.0) - pow(a, 2.0)) <= -2e-286) {
tmp = pow(a, 2.0) * -sin((angle * (((double) M_PI) * 0.011111111111111112)));
} else {
tmp = ((b + a) * (a - b)) * (2.0 * sin((angle * (((double) M_PI) / -180.0))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if ((Math.pow(b, 2.0) - Math.pow(a, 2.0)) <= -2e-286) {
tmp = Math.pow(a, 2.0) * -Math.sin((angle * (Math.PI * 0.011111111111111112)));
} else {
tmp = ((b + a) * (a - b)) * (2.0 * Math.sin((angle * (Math.PI / -180.0))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if (math.pow(b, 2.0) - math.pow(a, 2.0)) <= -2e-286: tmp = math.pow(a, 2.0) * -math.sin((angle * (math.pi * 0.011111111111111112))) else: tmp = ((b + a) * (a - b)) * (2.0 * math.sin((angle * (math.pi / -180.0)))) return tmp
function code(a, b, angle) tmp = 0.0 if (Float64((b ^ 2.0) - (a ^ 2.0)) <= -2e-286) tmp = Float64((a ^ 2.0) * Float64(-sin(Float64(angle * Float64(pi * 0.011111111111111112))))); else tmp = Float64(Float64(Float64(b + a) * Float64(a - b)) * Float64(2.0 * sin(Float64(angle * Float64(pi / -180.0))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (((b ^ 2.0) - (a ^ 2.0)) <= -2e-286) tmp = (a ^ 2.0) * -sin((angle * (pi * 0.011111111111111112))); else tmp = ((b + a) * (a - b)) * (2.0 * sin((angle * (pi / -180.0)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision], -2e-286], N[(N[Power[a, 2.0], $MachinePrecision] * (-N[Sin[N[(angle * N[(Pi * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(N[(b + a), $MachinePrecision] * N[(a - b), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[Sin[N[(angle * N[(Pi / -180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{b}^{2} - {a}^{2} \leq -2 \cdot 10^{-286}:\\
\;\;\;\;{a}^{2} \cdot \left(-\sin \left(angle \cdot \left(\pi \cdot 0.011111111111111112\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(b + a\right) \cdot \left(a - b\right)\right) \cdot \left(2 \cdot \sin \left(angle \cdot \frac{\pi}{-180}\right)\right)\\
\end{array}
\end{array}
if (-.f64 (pow.f64 b 2) (pow.f64 a 2)) < -2.0000000000000001e-286Initial program 53.6%
Simplified55.0%
Applied egg-rr6.1%
Simplified15.8%
Taylor expanded in b around 0 53.3%
mul-1-neg53.3%
*-commutative53.3%
associate-*r*54.9%
distribute-rgt-neg-in54.9%
Simplified54.9%
if -2.0000000000000001e-286 < (-.f64 (pow.f64 b 2) (pow.f64 a 2)) Initial program 46.8%
Simplified50.0%
unpow250.0%
unpow250.0%
difference-of-squares57.1%
Applied egg-rr57.1%
Taylor expanded in angle around 0 54.3%
Final simplification54.6%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* -0.005555555555555556 (* angle PI)))) (* 2.0 (* (cos t_0) (* (* (+ b a) (- a b)) (sin t_0))))))
double code(double a, double b, double angle) {
double t_0 = -0.005555555555555556 * (angle * ((double) M_PI));
return 2.0 * (cos(t_0) * (((b + a) * (a - b)) * sin(t_0)));
}
public static double code(double a, double b, double angle) {
double t_0 = -0.005555555555555556 * (angle * Math.PI);
return 2.0 * (Math.cos(t_0) * (((b + a) * (a - b)) * Math.sin(t_0)));
}
def code(a, b, angle): t_0 = -0.005555555555555556 * (angle * math.pi) return 2.0 * (math.cos(t_0) * (((b + a) * (a - b)) * math.sin(t_0)))
function code(a, b, angle) t_0 = Float64(-0.005555555555555556 * Float64(angle * pi)) return Float64(2.0 * Float64(cos(t_0) * Float64(Float64(Float64(b + a) * Float64(a - b)) * sin(t_0)))) end
function tmp = code(a, b, angle) t_0 = -0.005555555555555556 * (angle * pi); tmp = 2.0 * (cos(t_0) * (((b + a) * (a - b)) * sin(t_0))); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(-0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]}, N[(2.0 * N[(N[Cos[t$95$0], $MachinePrecision] * N[(N[(N[(b + a), $MachinePrecision] * N[(a - b), $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\
2 \cdot \left(\cos t_0 \cdot \left(\left(\left(b + a\right) \cdot \left(a - b\right)\right) \cdot \sin t_0\right)\right)
\end{array}
\end{array}
Initial program 49.8%
Simplified52.2%
unpow252.2%
unpow252.2%
difference-of-squares56.1%
Applied egg-rr56.1%
Taylor expanded in angle around inf 55.0%
Final simplification55.0%
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* angle (* PI -0.005555555555555556)))) (* 2.0 (* (sin t_0) (* (- a b) (* (+ b a) (cos t_0)))))))
double code(double a, double b, double angle) {
double t_0 = angle * (((double) M_PI) * -0.005555555555555556);
return 2.0 * (sin(t_0) * ((a - b) * ((b + a) * cos(t_0))));
}
public static double code(double a, double b, double angle) {
double t_0 = angle * (Math.PI * -0.005555555555555556);
return 2.0 * (Math.sin(t_0) * ((a - b) * ((b + a) * Math.cos(t_0))));
}
def code(a, b, angle): t_0 = angle * (math.pi * -0.005555555555555556) return 2.0 * (math.sin(t_0) * ((a - b) * ((b + a) * math.cos(t_0))))
function code(a, b, angle) t_0 = Float64(angle * Float64(pi * -0.005555555555555556)) return Float64(2.0 * Float64(sin(t_0) * Float64(Float64(a - b) * Float64(Float64(b + a) * cos(t_0))))) end
function tmp = code(a, b, angle) t_0 = angle * (pi * -0.005555555555555556); tmp = 2.0 * (sin(t_0) * ((a - b) * ((b + a) * cos(t_0)))); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(angle * N[(Pi * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, N[(2.0 * N[(N[Sin[t$95$0], $MachinePrecision] * N[(N[(a - b), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := angle \cdot \left(\pi \cdot -0.005555555555555556\right)\\
2 \cdot \left(\sin t_0 \cdot \left(\left(a - b\right) \cdot \left(\left(b + a\right) \cdot \cos t_0\right)\right)\right)
\end{array}
\end{array}
Initial program 49.8%
Simplified52.2%
unpow252.2%
unpow252.2%
difference-of-squares56.1%
Applied egg-rr56.1%
Taylor expanded in angle around inf 55.0%
associate-*r*55.0%
*-commutative55.0%
*-commutative55.0%
associate-*r*55.8%
*-commutative55.8%
associate-*r*56.1%
associate-*r*56.1%
associate-*r*56.1%
Simplified56.1%
Final simplification56.1%
(FPCore (a b angle) :precision binary64 (* (* 2.0 (sin (* angle (/ PI -180.0)))) (* (* (+ b a) (- a b)) (cos (/ (* angle PI) -180.0)))))
double code(double a, double b, double angle) {
return (2.0 * sin((angle * (((double) M_PI) / -180.0)))) * (((b + a) * (a - b)) * cos(((angle * ((double) M_PI)) / -180.0)));
}
public static double code(double a, double b, double angle) {
return (2.0 * Math.sin((angle * (Math.PI / -180.0)))) * (((b + a) * (a - b)) * Math.cos(((angle * Math.PI) / -180.0)));
}
def code(a, b, angle): return (2.0 * math.sin((angle * (math.pi / -180.0)))) * (((b + a) * (a - b)) * math.cos(((angle * math.pi) / -180.0)))
function code(a, b, angle) return Float64(Float64(2.0 * sin(Float64(angle * Float64(pi / -180.0)))) * Float64(Float64(Float64(b + a) * Float64(a - b)) * cos(Float64(Float64(angle * pi) / -180.0)))) end
function tmp = code(a, b, angle) tmp = (2.0 * sin((angle * (pi / -180.0)))) * (((b + a) * (a - b)) * cos(((angle * pi) / -180.0))); end
code[a_, b_, angle_] := N[(N[(2.0 * N[Sin[N[(angle * N[(Pi / -180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(b + a), $MachinePrecision] * N[(a - b), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(angle * Pi), $MachinePrecision] / -180.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(2 \cdot \sin \left(angle \cdot \frac{\pi}{-180}\right)\right) \cdot \left(\left(\left(b + a\right) \cdot \left(a - b\right)\right) \cdot \cos \left(\frac{angle \cdot \pi}{-180}\right)\right)
\end{array}
Initial program 49.8%
Simplified52.2%
unpow252.2%
unpow252.2%
difference-of-squares56.1%
Applied egg-rr56.1%
associate-*r/57.0%
Applied egg-rr57.0%
Final simplification57.0%
(FPCore (a b angle)
:precision binary64
(if (<= a 3e+156)
(*
2.0
(*
(/ (- (pow b 2.0) (pow a 2.0)) 2.0)
(sin (* (* angle PI) 0.011111111111111112))))
(if (<= a 1.85e+199)
(* (pow a 2.0) (sin (* PI (* angle 0.011111111111111112))))
(* (pow a 2.0) (- (sin (* angle (* PI 0.011111111111111112))))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 3e+156) {
tmp = 2.0 * (((pow(b, 2.0) - pow(a, 2.0)) / 2.0) * sin(((angle * ((double) M_PI)) * 0.011111111111111112)));
} else if (a <= 1.85e+199) {
tmp = pow(a, 2.0) * sin((((double) M_PI) * (angle * 0.011111111111111112)));
} else {
tmp = pow(a, 2.0) * -sin((angle * (((double) M_PI) * 0.011111111111111112)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 3e+156) {
tmp = 2.0 * (((Math.pow(b, 2.0) - Math.pow(a, 2.0)) / 2.0) * Math.sin(((angle * Math.PI) * 0.011111111111111112)));
} else if (a <= 1.85e+199) {
tmp = Math.pow(a, 2.0) * Math.sin((Math.PI * (angle * 0.011111111111111112)));
} else {
tmp = Math.pow(a, 2.0) * -Math.sin((angle * (Math.PI * 0.011111111111111112)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 3e+156: tmp = 2.0 * (((math.pow(b, 2.0) - math.pow(a, 2.0)) / 2.0) * math.sin(((angle * math.pi) * 0.011111111111111112))) elif a <= 1.85e+199: tmp = math.pow(a, 2.0) * math.sin((math.pi * (angle * 0.011111111111111112))) else: tmp = math.pow(a, 2.0) * -math.sin((angle * (math.pi * 0.011111111111111112))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 3e+156) tmp = Float64(2.0 * Float64(Float64(Float64((b ^ 2.0) - (a ^ 2.0)) / 2.0) * sin(Float64(Float64(angle * pi) * 0.011111111111111112)))); elseif (a <= 1.85e+199) tmp = Float64((a ^ 2.0) * sin(Float64(pi * Float64(angle * 0.011111111111111112)))); else tmp = Float64((a ^ 2.0) * Float64(-sin(Float64(angle * Float64(pi * 0.011111111111111112))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 3e+156) tmp = 2.0 * ((((b ^ 2.0) - (a ^ 2.0)) / 2.0) * sin(((angle * pi) * 0.011111111111111112))); elseif (a <= 1.85e+199) tmp = (a ^ 2.0) * sin((pi * (angle * 0.011111111111111112))); else tmp = (a ^ 2.0) * -sin((angle * (pi * 0.011111111111111112))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 3e+156], N[(2.0 * N[(N[(N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] * N[Sin[N[(N[(angle * Pi), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.85e+199], N[(N[Power[a, 2.0], $MachinePrecision] * N[Sin[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 2.0], $MachinePrecision] * (-N[Sin[N[(angle * N[(Pi * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3 \cdot 10^{+156}:\\
\;\;\;\;2 \cdot \left(\frac{{b}^{2} - {a}^{2}}{2} \cdot \sin \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)\right)\\
\mathbf{elif}\;a \leq 1.85 \cdot 10^{+199}:\\
\;\;\;\;{a}^{2} \cdot \sin \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{2} \cdot \left(-\sin \left(angle \cdot \left(\pi \cdot 0.011111111111111112\right)\right)\right)\\
\end{array}
\end{array}
if a < 3e156Initial program 50.1%
associate-*l*50.1%
associate-*l*50.1%
cos-neg50.1%
distribute-rgt-neg-out50.1%
distribute-frac-neg50.1%
neg-mul-150.1%
associate-/l*50.9%
associate-*r/49.0%
associate-/r/51.2%
associate-/l*51.2%
metadata-eval51.2%
Simplified51.2%
Applied egg-rr51.8%
associate-/l*51.8%
associate-/r/51.8%
+-commutative51.8%
Simplified51.5%
if 3e156 < a < 1.85000000000000011e199Initial program 11.8%
Simplified11.8%
Applied egg-rr0.0%
associate-/l*0.0%
count-20.0%
*-commutative0.0%
*-commutative0.0%
associate-*r*0.0%
*-commutative0.0%
*-commutative0.0%
associate-*r*0.0%
distribute-rgt-out0.0%
metadata-eval0.0%
fma-udef0.0%
unpow20.0%
+-commutative0.0%
unpow20.0%
fma-udef0.0%
Simplified0.0%
Taylor expanded in a around inf 40.1%
associate-*r*50.1%
*-commutative50.1%
*-commutative50.1%
Simplified50.1%
if 1.85000000000000011e199 < a Initial program 64.1%
Simplified64.1%
Applied egg-rr0.0%
Simplified0.0%
Taylor expanded in b around 0 68.7%
mul-1-neg68.7%
*-commutative68.7%
associate-*r*73.2%
distribute-rgt-neg-in73.2%
Simplified73.2%
Final simplification53.4%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (+ b a) (- a b))))
(if (or (<= angle -1.9e+38) (not (<= angle 3e+107)))
(fabs (* angle (* -0.011111111111111112 (* PI t_0))))
(* -0.011111111111111112 (* t_0 (* angle PI))))))
double code(double a, double b, double angle) {
double t_0 = (b + a) * (a - b);
double tmp;
if ((angle <= -1.9e+38) || !(angle <= 3e+107)) {
tmp = fabs((angle * (-0.011111111111111112 * (((double) M_PI) * t_0))));
} else {
tmp = -0.011111111111111112 * (t_0 * (angle * ((double) M_PI)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = (b + a) * (a - b);
double tmp;
if ((angle <= -1.9e+38) || !(angle <= 3e+107)) {
tmp = Math.abs((angle * (-0.011111111111111112 * (Math.PI * t_0))));
} else {
tmp = -0.011111111111111112 * (t_0 * (angle * Math.PI));
}
return tmp;
}
def code(a, b, angle): t_0 = (b + a) * (a - b) tmp = 0 if (angle <= -1.9e+38) or not (angle <= 3e+107): tmp = math.fabs((angle * (-0.011111111111111112 * (math.pi * t_0)))) else: tmp = -0.011111111111111112 * (t_0 * (angle * math.pi)) return tmp
function code(a, b, angle) t_0 = Float64(Float64(b + a) * Float64(a - b)) tmp = 0.0 if ((angle <= -1.9e+38) || !(angle <= 3e+107)) tmp = abs(Float64(angle * Float64(-0.011111111111111112 * Float64(pi * t_0)))); else tmp = Float64(-0.011111111111111112 * Float64(t_0 * Float64(angle * pi))); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = (b + a) * (a - b); tmp = 0.0; if ((angle <= -1.9e+38) || ~((angle <= 3e+107))) tmp = abs((angle * (-0.011111111111111112 * (pi * t_0)))); else tmp = -0.011111111111111112 * (t_0 * (angle * pi)); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(b + a), $MachinePrecision] * N[(a - b), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[angle, -1.9e+38], N[Not[LessEqual[angle, 3e+107]], $MachinePrecision]], N[Abs[N[(angle * N[(-0.011111111111111112 * N[(Pi * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(-0.011111111111111112 * N[(t$95$0 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(b + a\right) \cdot \left(a - b\right)\\
\mathbf{if}\;angle \leq -1.9 \cdot 10^{+38} \lor \neg \left(angle \leq 3 \cdot 10^{+107}\right):\\
\;\;\;\;\left|angle \cdot \left(-0.011111111111111112 \cdot \left(\pi \cdot t_0\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;-0.011111111111111112 \cdot \left(t_0 \cdot \left(angle \cdot \pi\right)\right)\\
\end{array}
\end{array}
if angle < -1.8999999999999999e38 or 3.00000000000000023e107 < angle Initial program 26.2%
Simplified30.2%
unpow230.2%
unpow230.2%
difference-of-squares34.2%
Applied egg-rr34.2%
Taylor expanded in angle around 0 24.6%
add-sqr-sqrt18.9%
sqrt-unprod35.6%
pow235.6%
*-commutative35.6%
associate-*r*35.6%
Applied egg-rr35.6%
unpow235.6%
rem-sqrt-square34.9%
associate-*l*34.9%
*-commutative34.9%
associate-*r*34.9%
Simplified34.9%
if -1.8999999999999999e38 < angle < 3.00000000000000023e107Initial program 64.7%
Simplified66.1%
unpow266.1%
unpow266.1%
difference-of-squares70.0%
Applied egg-rr70.0%
Taylor expanded in angle around 0 65.7%
expm1-log1p-u45.3%
expm1-udef27.6%
associate-*r*27.6%
Applied egg-rr27.6%
expm1-def45.3%
expm1-log1p65.7%
associate-*r*65.7%
associate-*r*65.8%
Simplified65.8%
Final simplification53.8%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (+ b a) (- a b))))
(if (<= angle 4.8e+114)
(* t_0 (* 2.0 (sin (* angle (/ PI -180.0)))))
(fabs (* angle (* -0.011111111111111112 (* PI t_0)))))))
double code(double a, double b, double angle) {
double t_0 = (b + a) * (a - b);
double tmp;
if (angle <= 4.8e+114) {
tmp = t_0 * (2.0 * sin((angle * (((double) M_PI) / -180.0))));
} else {
tmp = fabs((angle * (-0.011111111111111112 * (((double) M_PI) * t_0))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = (b + a) * (a - b);
double tmp;
if (angle <= 4.8e+114) {
tmp = t_0 * (2.0 * Math.sin((angle * (Math.PI / -180.0))));
} else {
tmp = Math.abs((angle * (-0.011111111111111112 * (Math.PI * t_0))));
}
return tmp;
}
def code(a, b, angle): t_0 = (b + a) * (a - b) tmp = 0 if angle <= 4.8e+114: tmp = t_0 * (2.0 * math.sin((angle * (math.pi / -180.0)))) else: tmp = math.fabs((angle * (-0.011111111111111112 * (math.pi * t_0)))) return tmp
function code(a, b, angle) t_0 = Float64(Float64(b + a) * Float64(a - b)) tmp = 0.0 if (angle <= 4.8e+114) tmp = Float64(t_0 * Float64(2.0 * sin(Float64(angle * Float64(pi / -180.0))))); else tmp = abs(Float64(angle * Float64(-0.011111111111111112 * Float64(pi * t_0)))); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = (b + a) * (a - b); tmp = 0.0; if (angle <= 4.8e+114) tmp = t_0 * (2.0 * sin((angle * (pi / -180.0)))); else tmp = abs((angle * (-0.011111111111111112 * (pi * t_0)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(b + a), $MachinePrecision] * N[(a - b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[angle, 4.8e+114], N[(t$95$0 * N[(2.0 * N[Sin[N[(angle * N[(Pi / -180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[N[(angle * N[(-0.011111111111111112 * N[(Pi * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(b + a\right) \cdot \left(a - b\right)\\
\mathbf{if}\;angle \leq 4.8 \cdot 10^{+114}:\\
\;\;\;\;t_0 \cdot \left(2 \cdot \sin \left(angle \cdot \frac{\pi}{-180}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left|angle \cdot \left(-0.011111111111111112 \cdot \left(\pi \cdot t_0\right)\right)\right|\\
\end{array}
\end{array}
if angle < 4.8e114Initial program 56.7%
Simplified58.3%
unpow258.3%
unpow258.3%
difference-of-squares61.7%
Applied egg-rr61.7%
Taylor expanded in angle around 0 58.1%
if 4.8e114 < angle Initial program 19.4%
Simplified25.1%
unpow225.1%
unpow225.1%
difference-of-squares31.5%
Applied egg-rr31.5%
Taylor expanded in angle around 0 22.9%
add-sqr-sqrt20.0%
sqrt-unprod35.5%
pow235.5%
*-commutative35.5%
associate-*r*35.5%
Applied egg-rr35.5%
unpow235.5%
rem-sqrt-square35.5%
associate-*l*35.5%
*-commutative35.5%
associate-*r*35.5%
Simplified35.5%
Final simplification54.0%
(FPCore (a b angle) :precision binary64 (* -0.011111111111111112 (* angle (* PI (* (+ b a) (- a b))))))
double code(double a, double b, double angle) {
return -0.011111111111111112 * (angle * (((double) M_PI) * ((b + a) * (a - b))));
}
public static double code(double a, double b, double angle) {
return -0.011111111111111112 * (angle * (Math.PI * ((b + a) * (a - b))));
}
def code(a, b, angle): return -0.011111111111111112 * (angle * (math.pi * ((b + a) * (a - b))))
function code(a, b, angle) return Float64(-0.011111111111111112 * Float64(angle * Float64(pi * Float64(Float64(b + a) * Float64(a - b))))) end
function tmp = code(a, b, angle) tmp = -0.011111111111111112 * (angle * (pi * ((b + a) * (a - b)))); end
code[a_, b_, angle_] := N[(-0.011111111111111112 * N[(angle * N[(Pi * N[(N[(b + a), $MachinePrecision] * N[(a - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(\left(b + a\right) \cdot \left(a - b\right)\right)\right)\right)
\end{array}
Initial program 49.8%
Simplified52.2%
unpow252.2%
unpow252.2%
difference-of-squares56.1%
Applied egg-rr56.1%
Taylor expanded in angle around 0 49.8%
Final simplification49.8%
(FPCore (a b angle) :precision binary64 (* -0.011111111111111112 (* angle (* (- a b) (* PI (+ b a))))))
double code(double a, double b, double angle) {
return -0.011111111111111112 * (angle * ((a - b) * (((double) M_PI) * (b + a))));
}
public static double code(double a, double b, double angle) {
return -0.011111111111111112 * (angle * ((a - b) * (Math.PI * (b + a))));
}
def code(a, b, angle): return -0.011111111111111112 * (angle * ((a - b) * (math.pi * (b + a))))
function code(a, b, angle) return Float64(-0.011111111111111112 * Float64(angle * Float64(Float64(a - b) * Float64(pi * Float64(b + a))))) end
function tmp = code(a, b, angle) tmp = -0.011111111111111112 * (angle * ((a - b) * (pi * (b + a)))); end
code[a_, b_, angle_] := N[(-0.011111111111111112 * N[(angle * N[(N[(a - b), $MachinePrecision] * N[(Pi * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.011111111111111112 \cdot \left(angle \cdot \left(\left(a - b\right) \cdot \left(\pi \cdot \left(b + a\right)\right)\right)\right)
\end{array}
Initial program 49.8%
Simplified52.2%
unpow252.2%
unpow252.2%
difference-of-squares56.1%
Applied egg-rr56.1%
Taylor expanded in angle around 0 49.8%
expm1-log1p-u32.1%
expm1-udef28.6%
associate-*r*28.6%
Applied egg-rr28.6%
expm1-def32.1%
expm1-log1p-u49.8%
*-commutative49.8%
Applied egg-rr49.8%
Final simplification49.8%
(FPCore (a b angle) :precision binary64 (* -0.011111111111111112 (* (* (+ b a) (- a b)) (* angle PI))))
double code(double a, double b, double angle) {
return -0.011111111111111112 * (((b + a) * (a - b)) * (angle * ((double) M_PI)));
}
public static double code(double a, double b, double angle) {
return -0.011111111111111112 * (((b + a) * (a - b)) * (angle * Math.PI));
}
def code(a, b, angle): return -0.011111111111111112 * (((b + a) * (a - b)) * (angle * math.pi))
function code(a, b, angle) return Float64(-0.011111111111111112 * Float64(Float64(Float64(b + a) * Float64(a - b)) * Float64(angle * pi))) end
function tmp = code(a, b, angle) tmp = -0.011111111111111112 * (((b + a) * (a - b)) * (angle * pi)); end
code[a_, b_, angle_] := N[(-0.011111111111111112 * N[(N[(N[(b + a), $MachinePrecision] * N[(a - b), $MachinePrecision]), $MachinePrecision] * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.011111111111111112 \cdot \left(\left(\left(b + a\right) \cdot \left(a - b\right)\right) \cdot \left(angle \cdot \pi\right)\right)
\end{array}
Initial program 49.8%
Simplified52.2%
unpow252.2%
unpow252.2%
difference-of-squares56.1%
Applied egg-rr56.1%
Taylor expanded in angle around 0 49.8%
expm1-log1p-u32.0%
expm1-udef21.6%
associate-*r*21.6%
Applied egg-rr21.6%
expm1-def32.1%
expm1-log1p49.8%
associate-*r*49.8%
associate-*r*49.9%
Simplified49.9%
Final simplification49.9%
herbie shell --seed 2023320
(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)))))