
(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 8 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}
NOTE: b should be positive before calling this function
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (pow (sqrt PI) 2.0))
(t_1
(* (- a b) (* (+ b a) (sin (* angle (* PI -0.005555555555555556)))))))
(if (<= (pow b 2.0) 1e+53)
(* t_1 (* 2.0 (fabs (cos (* t_0 (* angle -0.005555555555555556))))))
(* t_1 (* 2.0 (cos (* angle (* -0.005555555555555556 t_0))))))))b = abs(b);
double code(double a, double b, double angle) {
double t_0 = pow(sqrt(((double) M_PI)), 2.0);
double t_1 = (a - b) * ((b + a) * sin((angle * (((double) M_PI) * -0.005555555555555556))));
double tmp;
if (pow(b, 2.0) <= 1e+53) {
tmp = t_1 * (2.0 * fabs(cos((t_0 * (angle * -0.005555555555555556)))));
} else {
tmp = t_1 * (2.0 * cos((angle * (-0.005555555555555556 * t_0))));
}
return tmp;
}
b = Math.abs(b);
public static double code(double a, double b, double angle) {
double t_0 = Math.pow(Math.sqrt(Math.PI), 2.0);
double t_1 = (a - b) * ((b + a) * Math.sin((angle * (Math.PI * -0.005555555555555556))));
double tmp;
if (Math.pow(b, 2.0) <= 1e+53) {
tmp = t_1 * (2.0 * Math.abs(Math.cos((t_0 * (angle * -0.005555555555555556)))));
} else {
tmp = t_1 * (2.0 * Math.cos((angle * (-0.005555555555555556 * t_0))));
}
return tmp;
}
b = abs(b) def code(a, b, angle): t_0 = math.pow(math.sqrt(math.pi), 2.0) t_1 = (a - b) * ((b + a) * math.sin((angle * (math.pi * -0.005555555555555556)))) tmp = 0 if math.pow(b, 2.0) <= 1e+53: tmp = t_1 * (2.0 * math.fabs(math.cos((t_0 * (angle * -0.005555555555555556))))) else: tmp = t_1 * (2.0 * math.cos((angle * (-0.005555555555555556 * t_0)))) return tmp
b = abs(b) function code(a, b, angle) t_0 = sqrt(pi) ^ 2.0 t_1 = Float64(Float64(a - b) * Float64(Float64(b + a) * sin(Float64(angle * Float64(pi * -0.005555555555555556))))) tmp = 0.0 if ((b ^ 2.0) <= 1e+53) tmp = Float64(t_1 * Float64(2.0 * abs(cos(Float64(t_0 * Float64(angle * -0.005555555555555556)))))); else tmp = Float64(t_1 * Float64(2.0 * cos(Float64(angle * Float64(-0.005555555555555556 * t_0))))); end return tmp end
b = abs(b) function tmp_2 = code(a, b, angle) t_0 = sqrt(pi) ^ 2.0; t_1 = (a - b) * ((b + a) * sin((angle * (pi * -0.005555555555555556)))); tmp = 0.0; if ((b ^ 2.0) <= 1e+53) tmp = t_1 * (2.0 * abs(cos((t_0 * (angle * -0.005555555555555556))))); else tmp = t_1 * (2.0 * cos((angle * (-0.005555555555555556 * t_0)))); end tmp_2 = tmp; end
NOTE: b should be positive before calling this function
code[a_, b_, angle_] := Block[{t$95$0 = N[Power[N[Sqrt[Pi], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[(a - b), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[Sin[N[(angle * N[(Pi * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[b, 2.0], $MachinePrecision], 1e+53], N[(t$95$1 * N[(2.0 * N[Abs[N[Cos[N[(t$95$0 * N[(angle * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(2.0 * N[Cos[N[(angle * N[(-0.005555555555555556 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
b = |b|\\
\\
\begin{array}{l}
t_0 := {\left(\sqrt{\pi}\right)}^{2}\\
t_1 := \left(a - b\right) \cdot \left(\left(b + a\right) \cdot \sin \left(angle \cdot \left(\pi \cdot -0.005555555555555556\right)\right)\right)\\
\mathbf{if}\;{b}^{2} \leq 10^{+53}:\\
\;\;\;\;t_1 \cdot \left(2 \cdot \left|\cos \left(t_0 \cdot \left(angle \cdot -0.005555555555555556\right)\right)\right|\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(2 \cdot \cos \left(angle \cdot \left(-0.005555555555555556 \cdot t_0\right)\right)\right)\\
\end{array}
\end{array}
if (pow.f64 b 2) < 9.9999999999999999e52Initial program 56.4%
Simplified57.7%
unpow257.7%
unpow257.7%
difference-of-squares57.7%
Applied egg-rr57.7%
Taylor expanded in angle around inf 57.2%
associate-*r*57.2%
*-commutative57.2%
associate-*r*62.6%
*-commutative62.6%
*-commutative62.6%
*-commutative62.6%
associate-*r*62.2%
*-commutative62.2%
associate-*r*63.1%
Simplified63.1%
add-sqr-sqrt57.0%
sqrt-unprod68.7%
pow268.7%
Applied egg-rr68.7%
unpow268.7%
rem-sqrt-square68.7%
associate-*r*68.7%
*-commutative68.7%
associate-*r*68.6%
*-commutative68.6%
Simplified68.6%
add-sqr-sqrt68.6%
pow268.6%
Applied egg-rr68.6%
if 9.9999999999999999e52 < (pow.f64 b 2) Initial program 39.9%
Simplified41.5%
unpow241.5%
unpow241.5%
difference-of-squares56.5%
Applied egg-rr56.5%
Taylor expanded in angle around inf 55.3%
associate-*r*55.3%
*-commutative55.3%
associate-*r*73.9%
*-commutative73.9%
*-commutative73.9%
*-commutative73.9%
associate-*r*75.7%
*-commutative75.7%
associate-*r*75.1%
Simplified75.1%
add-sqr-sqrt70.3%
pow270.3%
Applied egg-rr76.2%
Final simplification72.2%
NOTE: b should be positive before calling this function
(FPCore (a b angle)
:precision binary64
(let* ((t_0
(* (- a b) (* (+ b a) (sin (* angle (* PI -0.005555555555555556)))))))
(if (<= (pow b 2.0) 1e+53)
(* t_0 (* 2.0 (fabs (cos (* PI (* angle -0.005555555555555556))))))
(*
t_0
(* 2.0 (cos (* angle (* -0.005555555555555556 (pow (sqrt PI) 2.0)))))))))b = abs(b);
double code(double a, double b, double angle) {
double t_0 = (a - b) * ((b + a) * sin((angle * (((double) M_PI) * -0.005555555555555556))));
double tmp;
if (pow(b, 2.0) <= 1e+53) {
tmp = t_0 * (2.0 * fabs(cos((((double) M_PI) * (angle * -0.005555555555555556)))));
} else {
tmp = t_0 * (2.0 * cos((angle * (-0.005555555555555556 * pow(sqrt(((double) M_PI)), 2.0)))));
}
return tmp;
}
b = Math.abs(b);
public static double code(double a, double b, double angle) {
double t_0 = (a - b) * ((b + a) * Math.sin((angle * (Math.PI * -0.005555555555555556))));
double tmp;
if (Math.pow(b, 2.0) <= 1e+53) {
tmp = t_0 * (2.0 * Math.abs(Math.cos((Math.PI * (angle * -0.005555555555555556)))));
} else {
tmp = t_0 * (2.0 * Math.cos((angle * (-0.005555555555555556 * Math.pow(Math.sqrt(Math.PI), 2.0)))));
}
return tmp;
}
b = abs(b) def code(a, b, angle): t_0 = (a - b) * ((b + a) * math.sin((angle * (math.pi * -0.005555555555555556)))) tmp = 0 if math.pow(b, 2.0) <= 1e+53: tmp = t_0 * (2.0 * math.fabs(math.cos((math.pi * (angle * -0.005555555555555556))))) else: tmp = t_0 * (2.0 * math.cos((angle * (-0.005555555555555556 * math.pow(math.sqrt(math.pi), 2.0))))) return tmp
b = abs(b) function code(a, b, angle) t_0 = Float64(Float64(a - b) * Float64(Float64(b + a) * sin(Float64(angle * Float64(pi * -0.005555555555555556))))) tmp = 0.0 if ((b ^ 2.0) <= 1e+53) tmp = Float64(t_0 * Float64(2.0 * abs(cos(Float64(pi * Float64(angle * -0.005555555555555556)))))); else tmp = Float64(t_0 * Float64(2.0 * cos(Float64(angle * Float64(-0.005555555555555556 * (sqrt(pi) ^ 2.0)))))); end return tmp end
b = abs(b) function tmp_2 = code(a, b, angle) t_0 = (a - b) * ((b + a) * sin((angle * (pi * -0.005555555555555556)))); tmp = 0.0; if ((b ^ 2.0) <= 1e+53) tmp = t_0 * (2.0 * abs(cos((pi * (angle * -0.005555555555555556))))); else tmp = t_0 * (2.0 * cos((angle * (-0.005555555555555556 * (sqrt(pi) ^ 2.0))))); end tmp_2 = tmp; end
NOTE: b should be positive before calling this function
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(a - b), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[Sin[N[(angle * N[(Pi * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[b, 2.0], $MachinePrecision], 1e+53], N[(t$95$0 * N[(2.0 * N[Abs[N[Cos[N[(Pi * N[(angle * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(2.0 * N[Cos[N[(angle * N[(-0.005555555555555556 * N[Power[N[Sqrt[Pi], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
b = |b|\\
\\
\begin{array}{l}
t_0 := \left(a - b\right) \cdot \left(\left(b + a\right) \cdot \sin \left(angle \cdot \left(\pi \cdot -0.005555555555555556\right)\right)\right)\\
\mathbf{if}\;{b}^{2} \leq 10^{+53}:\\
\;\;\;\;t_0 \cdot \left(2 \cdot \left|\cos \left(\pi \cdot \left(angle \cdot -0.005555555555555556\right)\right)\right|\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(2 \cdot \cos \left(angle \cdot \left(-0.005555555555555556 \cdot {\left(\sqrt{\pi}\right)}^{2}\right)\right)\right)\\
\end{array}
\end{array}
if (pow.f64 b 2) < 9.9999999999999999e52Initial program 56.4%
Simplified57.7%
unpow257.7%
unpow257.7%
difference-of-squares57.7%
Applied egg-rr57.7%
Taylor expanded in angle around inf 57.2%
associate-*r*57.2%
*-commutative57.2%
associate-*r*62.6%
*-commutative62.6%
*-commutative62.6%
*-commutative62.6%
associate-*r*62.2%
*-commutative62.2%
associate-*r*63.1%
Simplified63.1%
add-sqr-sqrt57.0%
sqrt-unprod68.7%
pow268.7%
Applied egg-rr68.7%
unpow268.7%
rem-sqrt-square68.7%
associate-*r*68.7%
*-commutative68.7%
associate-*r*68.6%
*-commutative68.6%
Simplified68.6%
if 9.9999999999999999e52 < (pow.f64 b 2) Initial program 39.9%
Simplified41.5%
unpow241.5%
unpow241.5%
difference-of-squares56.5%
Applied egg-rr56.5%
Taylor expanded in angle around inf 55.3%
associate-*r*55.3%
*-commutative55.3%
associate-*r*73.9%
*-commutative73.9%
*-commutative73.9%
*-commutative73.9%
associate-*r*75.7%
*-commutative75.7%
associate-*r*75.1%
Simplified75.1%
add-sqr-sqrt70.3%
pow270.3%
Applied egg-rr76.2%
Final simplification72.2%
NOTE: b should be positive before calling this function
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* angle (* PI -0.005555555555555556)))
(t_1 (* (- a b) (* (+ b a) (sin t_0)))))
(if (<= (- (pow b 2.0) (pow a 2.0)) -2e+247)
(* 2.0 t_1)
(* t_1 (* 2.0 (cos t_0))))))b = abs(b);
double code(double a, double b, double angle) {
double t_0 = angle * (((double) M_PI) * -0.005555555555555556);
double t_1 = (a - b) * ((b + a) * sin(t_0));
double tmp;
if ((pow(b, 2.0) - pow(a, 2.0)) <= -2e+247) {
tmp = 2.0 * t_1;
} else {
tmp = t_1 * (2.0 * cos(t_0));
}
return tmp;
}
b = Math.abs(b);
public static double code(double a, double b, double angle) {
double t_0 = angle * (Math.PI * -0.005555555555555556);
double t_1 = (a - b) * ((b + a) * Math.sin(t_0));
double tmp;
if ((Math.pow(b, 2.0) - Math.pow(a, 2.0)) <= -2e+247) {
tmp = 2.0 * t_1;
} else {
tmp = t_1 * (2.0 * Math.cos(t_0));
}
return tmp;
}
b = abs(b) def code(a, b, angle): t_0 = angle * (math.pi * -0.005555555555555556) t_1 = (a - b) * ((b + a) * math.sin(t_0)) tmp = 0 if (math.pow(b, 2.0) - math.pow(a, 2.0)) <= -2e+247: tmp = 2.0 * t_1 else: tmp = t_1 * (2.0 * math.cos(t_0)) return tmp
b = abs(b) function code(a, b, angle) t_0 = Float64(angle * Float64(pi * -0.005555555555555556)) t_1 = Float64(Float64(a - b) * Float64(Float64(b + a) * sin(t_0))) tmp = 0.0 if (Float64((b ^ 2.0) - (a ^ 2.0)) <= -2e+247) tmp = Float64(2.0 * t_1); else tmp = Float64(t_1 * Float64(2.0 * cos(t_0))); end return tmp end
b = abs(b) function tmp_2 = code(a, b, angle) t_0 = angle * (pi * -0.005555555555555556); t_1 = (a - b) * ((b + a) * sin(t_0)); tmp = 0.0; if (((b ^ 2.0) - (a ^ 2.0)) <= -2e+247) tmp = 2.0 * t_1; else tmp = t_1 * (2.0 * cos(t_0)); end tmp_2 = tmp; end
NOTE: b should be positive before calling this function
code[a_, b_, angle_] := Block[{t$95$0 = N[(angle * N[(Pi * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a - b), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision], -2e+247], N[(2.0 * t$95$1), $MachinePrecision], N[(t$95$1 * N[(2.0 * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
b = |b|\\
\\
\begin{array}{l}
t_0 := angle \cdot \left(\pi \cdot -0.005555555555555556\right)\\
t_1 := \left(a - b\right) \cdot \left(\left(b + a\right) \cdot \sin t_0\right)\\
\mathbf{if}\;{b}^{2} - {a}^{2} \leq -2 \cdot 10^{+247}:\\
\;\;\;\;2 \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(2 \cdot \cos t_0\right)\\
\end{array}
\end{array}
if (-.f64 (pow.f64 b 2) (pow.f64 a 2)) < -1.9999999999999999e247Initial program 43.1%
Simplified46.0%
unpow246.0%
unpow246.0%
difference-of-squares46.0%
Applied egg-rr46.0%
Taylor expanded in angle around inf 43.5%
associate-*r*43.5%
*-commutative43.5%
associate-*r*66.3%
*-commutative66.3%
*-commutative66.3%
*-commutative66.3%
associate-*r*67.4%
*-commutative67.4%
associate-*r*68.7%
Simplified68.7%
Taylor expanded in angle around 0 79.7%
if -1.9999999999999999e247 < (-.f64 (pow.f64 b 2) (pow.f64 a 2)) Initial program 50.4%
Simplified51.4%
unpow251.4%
unpow251.4%
difference-of-squares60.6%
Applied egg-rr60.6%
Taylor expanded in angle around inf 60.3%
associate-*r*60.3%
*-commutative60.3%
associate-*r*68.4%
*-commutative68.4%
*-commutative68.4%
*-commutative68.4%
associate-*r*68.9%
*-commutative68.9%
associate-*r*68.7%
Simplified68.7%
Final simplification71.3%
NOTE: b should be positive before calling this function
(FPCore (a b angle)
:precision binary64
(let* ((t_0
(* (- a b) (* (+ b a) (sin (* angle (* PI -0.005555555555555556)))))))
(if (<= (- (pow b 2.0) (pow a 2.0)) -2e+247)
(* 2.0 t_0)
(* t_0 (* 2.0 (cos (* PI (* angle -0.005555555555555556))))))))b = abs(b);
double code(double a, double b, double angle) {
double t_0 = (a - b) * ((b + a) * sin((angle * (((double) M_PI) * -0.005555555555555556))));
double tmp;
if ((pow(b, 2.0) - pow(a, 2.0)) <= -2e+247) {
tmp = 2.0 * t_0;
} else {
tmp = t_0 * (2.0 * cos((((double) M_PI) * (angle * -0.005555555555555556))));
}
return tmp;
}
b = Math.abs(b);
public static double code(double a, double b, double angle) {
double t_0 = (a - b) * ((b + a) * Math.sin((angle * (Math.PI * -0.005555555555555556))));
double tmp;
if ((Math.pow(b, 2.0) - Math.pow(a, 2.0)) <= -2e+247) {
tmp = 2.0 * t_0;
} else {
tmp = t_0 * (2.0 * Math.cos((Math.PI * (angle * -0.005555555555555556))));
}
return tmp;
}
b = abs(b) def code(a, b, angle): t_0 = (a - b) * ((b + a) * math.sin((angle * (math.pi * -0.005555555555555556)))) tmp = 0 if (math.pow(b, 2.0) - math.pow(a, 2.0)) <= -2e+247: tmp = 2.0 * t_0 else: tmp = t_0 * (2.0 * math.cos((math.pi * (angle * -0.005555555555555556)))) return tmp
b = abs(b) function code(a, b, angle) t_0 = Float64(Float64(a - b) * Float64(Float64(b + a) * sin(Float64(angle * Float64(pi * -0.005555555555555556))))) tmp = 0.0 if (Float64((b ^ 2.0) - (a ^ 2.0)) <= -2e+247) tmp = Float64(2.0 * t_0); else tmp = Float64(t_0 * Float64(2.0 * cos(Float64(pi * Float64(angle * -0.005555555555555556))))); end return tmp end
b = abs(b) function tmp_2 = code(a, b, angle) t_0 = (a - b) * ((b + a) * sin((angle * (pi * -0.005555555555555556)))); tmp = 0.0; if (((b ^ 2.0) - (a ^ 2.0)) <= -2e+247) tmp = 2.0 * t_0; else tmp = t_0 * (2.0 * cos((pi * (angle * -0.005555555555555556)))); end tmp_2 = tmp; end
NOTE: b should be positive before calling this function
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(a - b), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[Sin[N[(angle * N[(Pi * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision], -2e+247], N[(2.0 * t$95$0), $MachinePrecision], N[(t$95$0 * N[(2.0 * N[Cos[N[(Pi * N[(angle * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
b = |b|\\
\\
\begin{array}{l}
t_0 := \left(a - b\right) \cdot \left(\left(b + a\right) \cdot \sin \left(angle \cdot \left(\pi \cdot -0.005555555555555556\right)\right)\right)\\
\mathbf{if}\;{b}^{2} - {a}^{2} \leq -2 \cdot 10^{+247}:\\
\;\;\;\;2 \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(2 \cdot \cos \left(\pi \cdot \left(angle \cdot -0.005555555555555556\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (pow.f64 b 2) (pow.f64 a 2)) < -1.9999999999999999e247Initial program 43.1%
Simplified46.0%
unpow246.0%
unpow246.0%
difference-of-squares46.0%
Applied egg-rr46.0%
Taylor expanded in angle around inf 43.5%
associate-*r*43.5%
*-commutative43.5%
associate-*r*66.3%
*-commutative66.3%
*-commutative66.3%
*-commutative66.3%
associate-*r*67.4%
*-commutative67.4%
associate-*r*68.7%
Simplified68.7%
Taylor expanded in angle around 0 79.7%
if -1.9999999999999999e247 < (-.f64 (pow.f64 b 2) (pow.f64 a 2)) Initial program 50.4%
Simplified51.4%
unpow251.4%
unpow251.4%
difference-of-squares60.6%
Applied egg-rr60.6%
Taylor expanded in angle around inf 60.3%
associate-*r*60.3%
*-commutative60.3%
associate-*r*68.4%
*-commutative68.4%
*-commutative68.4%
*-commutative68.4%
associate-*r*68.9%
*-commutative68.9%
associate-*r*68.7%
Simplified68.7%
Taylor expanded in angle around inf 68.9%
associate-*r*68.9%
*-commutative68.9%
Simplified68.9%
Final simplification71.5%
NOTE: b should be positive before calling this function
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (cos (* PI (* angle -0.005555555555555556))))
(t_1
(* (- a b) (* (+ b a) (sin (* angle (* PI -0.005555555555555556)))))))
(if (<= (pow b 2.0) 1e+53) (* t_1 (* 2.0 (fabs t_0))) (* t_1 (* 2.0 t_0)))))b = abs(b);
double code(double a, double b, double angle) {
double t_0 = cos((((double) M_PI) * (angle * -0.005555555555555556)));
double t_1 = (a - b) * ((b + a) * sin((angle * (((double) M_PI) * -0.005555555555555556))));
double tmp;
if (pow(b, 2.0) <= 1e+53) {
tmp = t_1 * (2.0 * fabs(t_0));
} else {
tmp = t_1 * (2.0 * t_0);
}
return tmp;
}
b = Math.abs(b);
public static double code(double a, double b, double angle) {
double t_0 = Math.cos((Math.PI * (angle * -0.005555555555555556)));
double t_1 = (a - b) * ((b + a) * Math.sin((angle * (Math.PI * -0.005555555555555556))));
double tmp;
if (Math.pow(b, 2.0) <= 1e+53) {
tmp = t_1 * (2.0 * Math.abs(t_0));
} else {
tmp = t_1 * (2.0 * t_0);
}
return tmp;
}
b = abs(b) def code(a, b, angle): t_0 = math.cos((math.pi * (angle * -0.005555555555555556))) t_1 = (a - b) * ((b + a) * math.sin((angle * (math.pi * -0.005555555555555556)))) tmp = 0 if math.pow(b, 2.0) <= 1e+53: tmp = t_1 * (2.0 * math.fabs(t_0)) else: tmp = t_1 * (2.0 * t_0) return tmp
b = abs(b) function code(a, b, angle) t_0 = cos(Float64(pi * Float64(angle * -0.005555555555555556))) t_1 = Float64(Float64(a - b) * Float64(Float64(b + a) * sin(Float64(angle * Float64(pi * -0.005555555555555556))))) tmp = 0.0 if ((b ^ 2.0) <= 1e+53) tmp = Float64(t_1 * Float64(2.0 * abs(t_0))); else tmp = Float64(t_1 * Float64(2.0 * t_0)); end return tmp end
b = abs(b) function tmp_2 = code(a, b, angle) t_0 = cos((pi * (angle * -0.005555555555555556))); t_1 = (a - b) * ((b + a) * sin((angle * (pi * -0.005555555555555556)))); tmp = 0.0; if ((b ^ 2.0) <= 1e+53) tmp = t_1 * (2.0 * abs(t_0)); else tmp = t_1 * (2.0 * t_0); end tmp_2 = tmp; end
NOTE: b should be positive before calling this function
code[a_, b_, angle_] := Block[{t$95$0 = N[Cos[N[(Pi * N[(angle * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(a - b), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[Sin[N[(angle * N[(Pi * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[b, 2.0], $MachinePrecision], 1e+53], N[(t$95$1 * N[(2.0 * N[Abs[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
b = |b|\\
\\
\begin{array}{l}
t_0 := \cos \left(\pi \cdot \left(angle \cdot -0.005555555555555556\right)\right)\\
t_1 := \left(a - b\right) \cdot \left(\left(b + a\right) \cdot \sin \left(angle \cdot \left(\pi \cdot -0.005555555555555556\right)\right)\right)\\
\mathbf{if}\;{b}^{2} \leq 10^{+53}:\\
\;\;\;\;t_1 \cdot \left(2 \cdot \left|t_0\right|\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(2 \cdot t_0\right)\\
\end{array}
\end{array}
if (pow.f64 b 2) < 9.9999999999999999e52Initial program 56.4%
Simplified57.7%
unpow257.7%
unpow257.7%
difference-of-squares57.7%
Applied egg-rr57.7%
Taylor expanded in angle around inf 57.2%
associate-*r*57.2%
*-commutative57.2%
associate-*r*62.6%
*-commutative62.6%
*-commutative62.6%
*-commutative62.6%
associate-*r*62.2%
*-commutative62.2%
associate-*r*63.1%
Simplified63.1%
add-sqr-sqrt57.0%
sqrt-unprod68.7%
pow268.7%
Applied egg-rr68.7%
unpow268.7%
rem-sqrt-square68.7%
associate-*r*68.7%
*-commutative68.7%
associate-*r*68.6%
*-commutative68.6%
Simplified68.6%
if 9.9999999999999999e52 < (pow.f64 b 2) Initial program 39.9%
Simplified41.5%
unpow241.5%
unpow241.5%
difference-of-squares56.5%
Applied egg-rr56.5%
Taylor expanded in angle around inf 55.3%
associate-*r*55.3%
*-commutative55.3%
associate-*r*73.9%
*-commutative73.9%
*-commutative73.9%
*-commutative73.9%
associate-*r*75.7%
*-commutative75.7%
associate-*r*75.1%
Simplified75.1%
Taylor expanded in angle around inf 75.7%
associate-*r*75.5%
*-commutative75.5%
Simplified75.5%
Final simplification71.8%
NOTE: b should be positive before calling this function (FPCore (a b angle) :precision binary64 (* (* 2.0 (sin (* angle (/ PI -180.0)))) (* (- a b) (+ b a))))
b = abs(b);
double code(double a, double b, double angle) {
return (2.0 * sin((angle * (((double) M_PI) / -180.0)))) * ((a - b) * (b + a));
}
b = Math.abs(b);
public static double code(double a, double b, double angle) {
return (2.0 * Math.sin((angle * (Math.PI / -180.0)))) * ((a - b) * (b + a));
}
b = abs(b) def code(a, b, angle): return (2.0 * math.sin((angle * (math.pi / -180.0)))) * ((a - b) * (b + a))
b = abs(b) function code(a, b, angle) return Float64(Float64(2.0 * sin(Float64(angle * Float64(pi / -180.0)))) * Float64(Float64(a - b) * Float64(b + a))) end
b = abs(b) function tmp = code(a, b, angle) tmp = (2.0 * sin((angle * (pi / -180.0)))) * ((a - b) * (b + a)); end
NOTE: b should be positive before calling this function code[a_, b_, angle_] := N[(N[(2.0 * N[Sin[N[(angle * N[(Pi / -180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(a - b), $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b = |b|\\
\\
\left(2 \cdot \sin \left(angle \cdot \frac{\pi}{-180}\right)\right) \cdot \left(\left(a - b\right) \cdot \left(b + a\right)\right)
\end{array}
Initial program 48.6%
Simplified50.1%
unpow250.1%
unpow250.1%
difference-of-squares57.1%
Applied egg-rr57.1%
Taylor expanded in angle around 0 57.2%
Final simplification57.2%
NOTE: b should be positive before calling this function (FPCore (a b angle) :precision binary64 (* 2.0 (* (- a b) (* (+ b a) (sin (* angle (* PI -0.005555555555555556)))))))
b = abs(b);
double code(double a, double b, double angle) {
return 2.0 * ((a - b) * ((b + a) * sin((angle * (((double) M_PI) * -0.005555555555555556)))));
}
b = Math.abs(b);
public static double code(double a, double b, double angle) {
return 2.0 * ((a - b) * ((b + a) * Math.sin((angle * (Math.PI * -0.005555555555555556)))));
}
b = abs(b) def code(a, b, angle): return 2.0 * ((a - b) * ((b + a) * math.sin((angle * (math.pi * -0.005555555555555556)))))
b = abs(b) function code(a, b, angle) return Float64(2.0 * Float64(Float64(a - b) * Float64(Float64(b + a) * sin(Float64(angle * Float64(pi * -0.005555555555555556)))))) end
b = abs(b) function tmp = code(a, b, angle) tmp = 2.0 * ((a - b) * ((b + a) * sin((angle * (pi * -0.005555555555555556))))); end
NOTE: b should be positive before calling this function code[a_, b_, angle_] := N[(2.0 * N[(N[(a - b), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[Sin[N[(angle * N[(Pi * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b = |b|\\
\\
2 \cdot \left(\left(a - b\right) \cdot \left(\left(b + a\right) \cdot \sin \left(angle \cdot \left(\pi \cdot -0.005555555555555556\right)\right)\right)\right)
\end{array}
Initial program 48.6%
Simplified50.1%
unpow250.1%
unpow250.1%
difference-of-squares57.1%
Applied egg-rr57.1%
Taylor expanded in angle around inf 56.3%
associate-*r*56.3%
*-commutative56.3%
associate-*r*67.9%
*-commutative67.9%
*-commutative67.9%
*-commutative67.9%
associate-*r*68.5%
*-commutative68.5%
associate-*r*68.7%
Simplified68.7%
Taylor expanded in angle around 0 68.8%
Final simplification68.8%
NOTE: b should be positive before calling this function (FPCore (a b angle) :precision binary64 (* -0.011111111111111112 (* (* (- a b) (+ b a)) (* angle PI))))
b = abs(b);
double code(double a, double b, double angle) {
return -0.011111111111111112 * (((a - b) * (b + a)) * (angle * ((double) M_PI)));
}
b = Math.abs(b);
public static double code(double a, double b, double angle) {
return -0.011111111111111112 * (((a - b) * (b + a)) * (angle * Math.PI));
}
b = abs(b) def code(a, b, angle): return -0.011111111111111112 * (((a - b) * (b + a)) * (angle * math.pi))
b = abs(b) function code(a, b, angle) return Float64(-0.011111111111111112 * Float64(Float64(Float64(a - b) * Float64(b + a)) * Float64(angle * pi))) end
b = abs(b) function tmp = code(a, b, angle) tmp = -0.011111111111111112 * (((a - b) * (b + a)) * (angle * pi)); end
NOTE: b should be positive before calling this function code[a_, b_, angle_] := N[(-0.011111111111111112 * N[(N[(N[(a - b), $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision] * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b = |b|\\
\\
-0.011111111111111112 \cdot \left(\left(\left(a - b\right) \cdot \left(b + a\right)\right) \cdot \left(angle \cdot \pi\right)\right)
\end{array}
Initial program 48.6%
Simplified50.1%
unpow250.1%
unpow250.1%
difference-of-squares57.1%
Applied egg-rr57.1%
Taylor expanded in angle around 0 52.1%
associate-*r*52.1%
*-commutative52.1%
Simplified52.1%
Final simplification52.1%
herbie shell --seed 2023333
(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)))))