
(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 12 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: a should be positive before calling this function
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* (sin (* PI (* angle 0.005555555555555556))) (+ b a))))
(if (<= (pow b 2.0) 5e-280)
(* 2.0 (* (- b a) t_0))
(* 2.0 (* t_0 (* (- b a) (cos (* angle (* PI 0.005555555555555556)))))))))a = abs(a);
double code(double a, double b, double angle) {
double t_0 = sin((((double) M_PI) * (angle * 0.005555555555555556))) * (b + a);
double tmp;
if (pow(b, 2.0) <= 5e-280) {
tmp = 2.0 * ((b - a) * t_0);
} else {
tmp = 2.0 * (t_0 * ((b - a) * cos((angle * (((double) M_PI) * 0.005555555555555556)))));
}
return tmp;
}
a = Math.abs(a);
public static double code(double a, double b, double angle) {
double t_0 = Math.sin((Math.PI * (angle * 0.005555555555555556))) * (b + a);
double tmp;
if (Math.pow(b, 2.0) <= 5e-280) {
tmp = 2.0 * ((b - a) * t_0);
} else {
tmp = 2.0 * (t_0 * ((b - a) * Math.cos((angle * (Math.PI * 0.005555555555555556)))));
}
return tmp;
}
a = abs(a) def code(a, b, angle): t_0 = math.sin((math.pi * (angle * 0.005555555555555556))) * (b + a) tmp = 0 if math.pow(b, 2.0) <= 5e-280: tmp = 2.0 * ((b - a) * t_0) else: tmp = 2.0 * (t_0 * ((b - a) * math.cos((angle * (math.pi * 0.005555555555555556))))) return tmp
a = abs(a) function code(a, b, angle) t_0 = Float64(sin(Float64(pi * Float64(angle * 0.005555555555555556))) * Float64(b + a)) tmp = 0.0 if ((b ^ 2.0) <= 5e-280) tmp = Float64(2.0 * Float64(Float64(b - a) * t_0)); else tmp = Float64(2.0 * Float64(t_0 * Float64(Float64(b - a) * cos(Float64(angle * Float64(pi * 0.005555555555555556)))))); end return tmp end
a = abs(a) function tmp_2 = code(a, b, angle) t_0 = sin((pi * (angle * 0.005555555555555556))) * (b + a); tmp = 0.0; if ((b ^ 2.0) <= 5e-280) tmp = 2.0 * ((b - a) * t_0); else tmp = 2.0 * (t_0 * ((b - a) * cos((angle * (pi * 0.005555555555555556))))); end tmp_2 = tmp; end
NOTE: a should be positive before calling this function
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[Sin[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[b, 2.0], $MachinePrecision], 5e-280], N[(2.0 * N[(N[(b - a), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t$95$0 * N[(N[(b - a), $MachinePrecision] * N[Cos[N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
a = |a|\\
\\
\begin{array}{l}
t_0 := \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right) \cdot \left(b + a\right)\\
\mathbf{if}\;{b}^{2} \leq 5 \cdot 10^{-280}:\\
\;\;\;\;2 \cdot \left(\left(b - a\right) \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t_0 \cdot \left(\left(b - a\right) \cdot \cos \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)\\
\end{array}
\end{array}
if (pow.f64 b 2) < 5.00000000000000028e-280Initial program 58.5%
associate-*l*58.5%
unpow258.5%
unpow258.5%
difference-of-squares58.5%
Simplified58.5%
Taylor expanded in angle around inf 70.9%
associate-*r*70.9%
*-commutative70.9%
*-commutative70.9%
associate-*r*72.5%
*-commutative72.5%
*-commutative72.5%
*-commutative72.5%
associate-*r*69.6%
*-commutative69.6%
+-commutative69.6%
Simplified69.6%
Taylor expanded in angle around 0 75.8%
if 5.00000000000000028e-280 < (pow.f64 b 2) Initial program 50.0%
associate-*l*50.0%
unpow250.0%
unpow250.0%
difference-of-squares55.5%
Simplified55.5%
Taylor expanded in angle around inf 69.3%
associate-*r*69.3%
*-commutative69.3%
*-commutative69.3%
associate-*r*68.1%
*-commutative68.1%
*-commutative68.1%
*-commutative68.1%
associate-*r*70.4%
*-commutative70.4%
+-commutative70.4%
Simplified70.4%
*-commutative70.4%
*-commutative70.4%
metadata-eval70.4%
div-inv70.1%
associate-/r/72.0%
Applied egg-rr72.0%
Taylor expanded in angle around inf 70.2%
*-commutative70.2%
associate-*l*71.7%
Simplified71.7%
Final simplification72.8%
NOTE: a should be positive before calling this function (FPCore (a b angle) :precision binary64 (let* ((t_0 (* 0.005555555555555556 (* angle PI)))) (* 2.0 (* (* (+ b a) (sin t_0)) (* (- b a) (cos t_0))))))
a = abs(a);
double code(double a, double b, double angle) {
double t_0 = 0.005555555555555556 * (angle * ((double) M_PI));
return 2.0 * (((b + a) * sin(t_0)) * ((b - a) * cos(t_0)));
}
a = Math.abs(a);
public static double code(double a, double b, double angle) {
double t_0 = 0.005555555555555556 * (angle * Math.PI);
return 2.0 * (((b + a) * Math.sin(t_0)) * ((b - a) * Math.cos(t_0)));
}
a = abs(a) def code(a, b, angle): t_0 = 0.005555555555555556 * (angle * math.pi) return 2.0 * (((b + a) * math.sin(t_0)) * ((b - a) * math.cos(t_0)))
a = abs(a) function code(a, b, angle) t_0 = Float64(0.005555555555555556 * Float64(angle * pi)) return Float64(2.0 * Float64(Float64(Float64(b + a) * sin(t_0)) * Float64(Float64(b - a) * cos(t_0)))) end
a = abs(a) function tmp = code(a, b, angle) t_0 = 0.005555555555555556 * (angle * pi); tmp = 2.0 * (((b + a) * sin(t_0)) * ((b - a) * cos(t_0))); end
NOTE: a should be positive before calling this function
code[a_, b_, angle_] := Block[{t$95$0 = N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]}, N[(2.0 * N[(N[(N[(b + a), $MachinePrecision] * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a = |a|\\
\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\
2 \cdot \left(\left(\left(b + a\right) \cdot \sin t_0\right) \cdot \left(\left(b - a\right) \cdot \cos t_0\right)\right)
\end{array}
\end{array}
Initial program 52.2%
associate-*l*52.2%
unpow252.2%
unpow252.2%
difference-of-squares56.3%
Simplified56.3%
Taylor expanded in angle around inf 69.7%
associate-*r*69.7%
*-commutative69.7%
+-commutative69.7%
Simplified69.7%
Final simplification69.7%
NOTE: a should be positive before calling this function (FPCore (a b angle) :precision binary64 (* 2.0 (* (* (- b a) (cos (/ angle (/ 180.0 PI)))) (* (sin (* PI (* angle 0.005555555555555556))) (+ b a)))))
a = abs(a);
double code(double a, double b, double angle) {
return 2.0 * (((b - a) * cos((angle / (180.0 / ((double) M_PI))))) * (sin((((double) M_PI) * (angle * 0.005555555555555556))) * (b + a)));
}
a = Math.abs(a);
public static double code(double a, double b, double angle) {
return 2.0 * (((b - a) * Math.cos((angle / (180.0 / Math.PI)))) * (Math.sin((Math.PI * (angle * 0.005555555555555556))) * (b + a)));
}
a = abs(a) def code(a, b, angle): return 2.0 * (((b - a) * math.cos((angle / (180.0 / math.pi)))) * (math.sin((math.pi * (angle * 0.005555555555555556))) * (b + a)))
a = abs(a) function code(a, b, angle) return Float64(2.0 * Float64(Float64(Float64(b - a) * cos(Float64(angle / Float64(180.0 / pi)))) * Float64(sin(Float64(pi * Float64(angle * 0.005555555555555556))) * Float64(b + a)))) end
a = abs(a) function tmp = code(a, b, angle) tmp = 2.0 * (((b - a) * cos((angle / (180.0 / pi)))) * (sin((pi * (angle * 0.005555555555555556))) * (b + a))); end
NOTE: a should be positive before calling this function code[a_, b_, angle_] := N[(2.0 * N[(N[(N[(b - a), $MachinePrecision] * N[Cos[N[(angle / N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a = |a|\\
\\
2 \cdot \left(\left(\left(b - a\right) \cdot \cos \left(\frac{angle}{\frac{180}{\pi}}\right)\right) \cdot \left(\sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right) \cdot \left(b + a\right)\right)\right)
\end{array}
Initial program 52.2%
associate-*l*52.2%
unpow252.2%
unpow252.2%
difference-of-squares56.3%
Simplified56.3%
Taylor expanded in angle around inf 69.7%
associate-*r*69.7%
*-commutative69.7%
*-commutative69.7%
associate-*r*69.3%
*-commutative69.3%
*-commutative69.3%
*-commutative69.3%
associate-*r*70.2%
*-commutative70.2%
+-commutative70.2%
Simplified70.2%
*-commutative70.2%
*-commutative70.2%
metadata-eval70.2%
div-inv70.0%
associate-/r/71.8%
Applied egg-rr71.8%
Final simplification71.8%
NOTE: a should be positive before calling this function
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) -1e+36)
(* (* 2.0 (* (- b a) (+ b a))) (sin (* PI (/ angle 180.0))))
(if (<= (/ angle 180.0) 0.0005)
(*
2.0
(*
(* (- b a) (cos (* PI (* angle 0.005555555555555556))))
(* (+ b a) (* 0.005555555555555556 (* angle PI)))))
(*
2.0
(*
(pow (+ b a) 2.0)
(* (sin (* PI (* 2.0 (* angle 0.005555555555555556)))) 0.5))))))a = abs(a);
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= -1e+36) {
tmp = (2.0 * ((b - a) * (b + a))) * sin((((double) M_PI) * (angle / 180.0)));
} else if ((angle / 180.0) <= 0.0005) {
tmp = 2.0 * (((b - a) * cos((((double) M_PI) * (angle * 0.005555555555555556)))) * ((b + a) * (0.005555555555555556 * (angle * ((double) M_PI)))));
} else {
tmp = 2.0 * (pow((b + a), 2.0) * (sin((((double) M_PI) * (2.0 * (angle * 0.005555555555555556)))) * 0.5));
}
return tmp;
}
a = Math.abs(a);
public static double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= -1e+36) {
tmp = (2.0 * ((b - a) * (b + a))) * Math.sin((Math.PI * (angle / 180.0)));
} else if ((angle / 180.0) <= 0.0005) {
tmp = 2.0 * (((b - a) * Math.cos((Math.PI * (angle * 0.005555555555555556)))) * ((b + a) * (0.005555555555555556 * (angle * Math.PI))));
} else {
tmp = 2.0 * (Math.pow((b + a), 2.0) * (Math.sin((Math.PI * (2.0 * (angle * 0.005555555555555556)))) * 0.5));
}
return tmp;
}
a = abs(a) def code(a, b, angle): tmp = 0 if (angle / 180.0) <= -1e+36: tmp = (2.0 * ((b - a) * (b + a))) * math.sin((math.pi * (angle / 180.0))) elif (angle / 180.0) <= 0.0005: tmp = 2.0 * (((b - a) * math.cos((math.pi * (angle * 0.005555555555555556)))) * ((b + a) * (0.005555555555555556 * (angle * math.pi)))) else: tmp = 2.0 * (math.pow((b + a), 2.0) * (math.sin((math.pi * (2.0 * (angle * 0.005555555555555556)))) * 0.5)) return tmp
a = abs(a) function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= -1e+36) tmp = Float64(Float64(2.0 * Float64(Float64(b - a) * Float64(b + a))) * sin(Float64(pi * Float64(angle / 180.0)))); elseif (Float64(angle / 180.0) <= 0.0005) tmp = Float64(2.0 * Float64(Float64(Float64(b - a) * cos(Float64(pi * Float64(angle * 0.005555555555555556)))) * Float64(Float64(b + a) * Float64(0.005555555555555556 * Float64(angle * pi))))); else tmp = Float64(2.0 * Float64((Float64(b + a) ^ 2.0) * Float64(sin(Float64(pi * Float64(2.0 * Float64(angle * 0.005555555555555556)))) * 0.5))); end return tmp end
a = abs(a) function tmp_2 = code(a, b, angle) tmp = 0.0; if ((angle / 180.0) <= -1e+36) tmp = (2.0 * ((b - a) * (b + a))) * sin((pi * (angle / 180.0))); elseif ((angle / 180.0) <= 0.0005) tmp = 2.0 * (((b - a) * cos((pi * (angle * 0.005555555555555556)))) * ((b + a) * (0.005555555555555556 * (angle * pi)))); else tmp = 2.0 * (((b + a) ^ 2.0) * (sin((pi * (2.0 * (angle * 0.005555555555555556)))) * 0.5)); end tmp_2 = tmp; end
NOTE: a should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], -1e+36], N[(N[(2.0 * N[(N[(b - a), $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(angle / 180.0), $MachinePrecision], 0.0005], N[(2.0 * N[(N[(N[(b - a), $MachinePrecision] * N[Cos[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Power[N[(b + a), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Sin[N[(Pi * N[(2.0 * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
a = |a|\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq -1 \cdot 10^{+36}:\\
\;\;\;\;\left(2 \cdot \left(\left(b - a\right) \cdot \left(b + a\right)\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\\
\mathbf{elif}\;\frac{angle}{180} \leq 0.0005:\\
\;\;\;\;2 \cdot \left(\left(\left(b - a\right) \cdot \cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right) \cdot \left(\left(b + a\right) \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left({\left(b + a\right)}^{2} \cdot \left(\sin \left(\pi \cdot \left(2 \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right) \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if (/.f64 angle 180) < -1.00000000000000004e36Initial program 30.9%
associate-*l*30.9%
unpow230.9%
unpow230.9%
difference-of-squares32.5%
Simplified32.5%
Taylor expanded in angle around 0 38.3%
if -1.00000000000000004e36 < (/.f64 angle 180) < 5.0000000000000001e-4Initial program 68.5%
associate-*l*68.5%
unpow268.5%
unpow268.5%
difference-of-squares73.9%
Simplified73.9%
Taylor expanded in angle around inf 98.1%
associate-*r*98.1%
*-commutative98.1%
*-commutative98.1%
associate-*r*97.5%
*-commutative97.5%
*-commutative97.5%
*-commutative97.5%
associate-*r*98.2%
*-commutative98.2%
+-commutative98.2%
Simplified98.2%
Taylor expanded in angle around 0 97.7%
if 5.0000000000000001e-4 < (/.f64 angle 180) Initial program 36.4%
*-commutative36.4%
associate-*l*36.4%
unpow236.4%
fma-neg43.6%
unpow243.6%
Simplified43.6%
Applied egg-rr27.8%
expm1-def30.7%
expm1-log1p45.8%
associate-*l*45.8%
sin-045.8%
+-lft-identity45.8%
associate-*l*45.8%
*-commutative45.8%
*-commutative45.8%
Simplified45.8%
Final simplification71.8%
NOTE: a should be positive before calling this function
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) -2e+33)
(* (* 2.0 (* (- b a) (+ b a))) (sin (* PI (/ angle 180.0))))
(if (<= (/ angle 180.0) 4e+47)
(* 0.011111111111111112 (* (* PI (+ b a)) (* (- b a) angle)))
(*
2.0
(*
(pow (+ b a) 2.0)
(* (sin (* PI (* 2.0 (* angle 0.005555555555555556)))) 0.5))))))a = abs(a);
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= -2e+33) {
tmp = (2.0 * ((b - a) * (b + a))) * sin((((double) M_PI) * (angle / 180.0)));
} else if ((angle / 180.0) <= 4e+47) {
tmp = 0.011111111111111112 * ((((double) M_PI) * (b + a)) * ((b - a) * angle));
} else {
tmp = 2.0 * (pow((b + a), 2.0) * (sin((((double) M_PI) * (2.0 * (angle * 0.005555555555555556)))) * 0.5));
}
return tmp;
}
a = Math.abs(a);
public static double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= -2e+33) {
tmp = (2.0 * ((b - a) * (b + a))) * Math.sin((Math.PI * (angle / 180.0)));
} else if ((angle / 180.0) <= 4e+47) {
tmp = 0.011111111111111112 * ((Math.PI * (b + a)) * ((b - a) * angle));
} else {
tmp = 2.0 * (Math.pow((b + a), 2.0) * (Math.sin((Math.PI * (2.0 * (angle * 0.005555555555555556)))) * 0.5));
}
return tmp;
}
a = abs(a) def code(a, b, angle): tmp = 0 if (angle / 180.0) <= -2e+33: tmp = (2.0 * ((b - a) * (b + a))) * math.sin((math.pi * (angle / 180.0))) elif (angle / 180.0) <= 4e+47: tmp = 0.011111111111111112 * ((math.pi * (b + a)) * ((b - a) * angle)) else: tmp = 2.0 * (math.pow((b + a), 2.0) * (math.sin((math.pi * (2.0 * (angle * 0.005555555555555556)))) * 0.5)) return tmp
a = abs(a) function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= -2e+33) tmp = Float64(Float64(2.0 * Float64(Float64(b - a) * Float64(b + a))) * sin(Float64(pi * Float64(angle / 180.0)))); elseif (Float64(angle / 180.0) <= 4e+47) tmp = Float64(0.011111111111111112 * Float64(Float64(pi * Float64(b + a)) * Float64(Float64(b - a) * angle))); else tmp = Float64(2.0 * Float64((Float64(b + a) ^ 2.0) * Float64(sin(Float64(pi * Float64(2.0 * Float64(angle * 0.005555555555555556)))) * 0.5))); end return tmp end
a = abs(a) function tmp_2 = code(a, b, angle) tmp = 0.0; if ((angle / 180.0) <= -2e+33) tmp = (2.0 * ((b - a) * (b + a))) * sin((pi * (angle / 180.0))); elseif ((angle / 180.0) <= 4e+47) tmp = 0.011111111111111112 * ((pi * (b + a)) * ((b - a) * angle)); else tmp = 2.0 * (((b + a) ^ 2.0) * (sin((pi * (2.0 * (angle * 0.005555555555555556)))) * 0.5)); end tmp_2 = tmp; end
NOTE: a should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], -2e+33], N[(N[(2.0 * N[(N[(b - a), $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(angle / 180.0), $MachinePrecision], 4e+47], N[(0.011111111111111112 * N[(N[(Pi * N[(b + a), $MachinePrecision]), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Power[N[(b + a), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Sin[N[(Pi * N[(2.0 * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
a = |a|\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq -2 \cdot 10^{+33}:\\
\;\;\;\;\left(2 \cdot \left(\left(b - a\right) \cdot \left(b + a\right)\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\\
\mathbf{elif}\;\frac{angle}{180} \leq 4 \cdot 10^{+47}:\\
\;\;\;\;0.011111111111111112 \cdot \left(\left(\pi \cdot \left(b + a\right)\right) \cdot \left(\left(b - a\right) \cdot angle\right)\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left({\left(b + a\right)}^{2} \cdot \left(\sin \left(\pi \cdot \left(2 \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right) \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if (/.f64 angle 180) < -1.9999999999999999e33Initial program 30.8%
associate-*l*30.8%
unpow230.8%
unpow230.8%
difference-of-squares32.3%
Simplified32.3%
Taylor expanded in angle around 0 37.7%
if -1.9999999999999999e33 < (/.f64 angle 180) < 4.0000000000000002e47Initial program 67.9%
associate-*l*67.9%
unpow267.9%
unpow267.9%
difference-of-squares73.0%
Simplified73.0%
Taylor expanded in angle around 0 71.9%
associate-*r*94.6%
*-commutative94.6%
+-commutative94.6%
Simplified94.6%
if 4.0000000000000002e47 < (/.f64 angle 180) Initial program 32.3%
*-commutative32.3%
associate-*l*32.3%
unpow232.3%
fma-neg38.8%
unpow238.8%
Simplified38.8%
Applied egg-rr24.9%
expm1-def26.5%
expm1-log1p44.9%
associate-*l*44.9%
sin-044.9%
+-lft-identity44.9%
associate-*l*44.9%
*-commutative44.9%
*-commutative44.9%
Simplified44.9%
Final simplification71.4%
NOTE: a should be positive before calling this function (FPCore (a b angle) :precision binary64 (if (<= b 1.25e-140) (* 2.0 (* (- b a) (* (sin (* PI (* angle 0.005555555555555556))) (+ b a)))) (* 0.011111111111111112 (* (* PI (+ b a)) (* (- b a) angle)))))
a = abs(a);
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.25e-140) {
tmp = 2.0 * ((b - a) * (sin((((double) M_PI) * (angle * 0.005555555555555556))) * (b + a)));
} else {
tmp = 0.011111111111111112 * ((((double) M_PI) * (b + a)) * ((b - a) * angle));
}
return tmp;
}
a = Math.abs(a);
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 1.25e-140) {
tmp = 2.0 * ((b - a) * (Math.sin((Math.PI * (angle * 0.005555555555555556))) * (b + a)));
} else {
tmp = 0.011111111111111112 * ((Math.PI * (b + a)) * ((b - a) * angle));
}
return tmp;
}
a = abs(a) def code(a, b, angle): tmp = 0 if b <= 1.25e-140: tmp = 2.0 * ((b - a) * (math.sin((math.pi * (angle * 0.005555555555555556))) * (b + a))) else: tmp = 0.011111111111111112 * ((math.pi * (b + a)) * ((b - a) * angle)) return tmp
a = abs(a) function code(a, b, angle) tmp = 0.0 if (b <= 1.25e-140) tmp = Float64(2.0 * Float64(Float64(b - a) * Float64(sin(Float64(pi * Float64(angle * 0.005555555555555556))) * Float64(b + a)))); else tmp = Float64(0.011111111111111112 * Float64(Float64(pi * Float64(b + a)) * Float64(Float64(b - a) * angle))); end return tmp end
a = abs(a) function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 1.25e-140) tmp = 2.0 * ((b - a) * (sin((pi * (angle * 0.005555555555555556))) * (b + a))); else tmp = 0.011111111111111112 * ((pi * (b + a)) * ((b - a) * angle)); end tmp_2 = tmp; end
NOTE: a should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[b, 1.25e-140], N[(2.0 * N[(N[(b - a), $MachinePrecision] * N[(N[Sin[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.011111111111111112 * N[(N[(Pi * N[(b + a), $MachinePrecision]), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a = |a|\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.25 \cdot 10^{-140}:\\
\;\;\;\;2 \cdot \left(\left(b - a\right) \cdot \left(\sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right) \cdot \left(b + a\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.011111111111111112 \cdot \left(\left(\pi \cdot \left(b + a\right)\right) \cdot \left(\left(b - a\right) \cdot angle\right)\right)\\
\end{array}
\end{array}
if b < 1.25000000000000004e-140Initial program 54.4%
associate-*l*54.4%
unpow254.4%
unpow254.4%
difference-of-squares58.7%
Simplified58.7%
Taylor expanded in angle around inf 72.2%
associate-*r*72.2%
*-commutative72.2%
*-commutative72.2%
associate-*r*71.9%
*-commutative71.9%
*-commutative71.9%
*-commutative71.9%
associate-*r*72.6%
*-commutative72.6%
+-commutative72.6%
Simplified72.6%
Taylor expanded in angle around 0 68.8%
if 1.25000000000000004e-140 < b Initial program 48.5%
associate-*l*48.5%
unpow248.5%
unpow248.5%
difference-of-squares51.9%
Simplified51.9%
Taylor expanded in angle around 0 50.1%
associate-*r*62.1%
*-commutative62.1%
+-commutative62.1%
Simplified62.1%
Final simplification66.4%
NOTE: a should be positive before calling this function (FPCore (a b angle) :precision binary64 (if (<= a 6.5e-34) (* 0.011111111111111112 (* PI (* angle (* b b)))) (* 0.011111111111111112 (* angle (* (- b a) (* a PI))))))
a = abs(a);
double code(double a, double b, double angle) {
double tmp;
if (a <= 6.5e-34) {
tmp = 0.011111111111111112 * (((double) M_PI) * (angle * (b * b)));
} else {
tmp = 0.011111111111111112 * (angle * ((b - a) * (a * ((double) M_PI))));
}
return tmp;
}
a = Math.abs(a);
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 6.5e-34) {
tmp = 0.011111111111111112 * (Math.PI * (angle * (b * b)));
} else {
tmp = 0.011111111111111112 * (angle * ((b - a) * (a * Math.PI)));
}
return tmp;
}
a = abs(a) def code(a, b, angle): tmp = 0 if a <= 6.5e-34: tmp = 0.011111111111111112 * (math.pi * (angle * (b * b))) else: tmp = 0.011111111111111112 * (angle * ((b - a) * (a * math.pi))) return tmp
a = abs(a) function code(a, b, angle) tmp = 0.0 if (a <= 6.5e-34) tmp = Float64(0.011111111111111112 * Float64(pi * Float64(angle * Float64(b * b)))); else tmp = Float64(0.011111111111111112 * Float64(angle * Float64(Float64(b - a) * Float64(a * pi)))); end return tmp end
a = abs(a) function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 6.5e-34) tmp = 0.011111111111111112 * (pi * (angle * (b * b))); else tmp = 0.011111111111111112 * (angle * ((b - a) * (a * pi))); end tmp_2 = tmp; end
NOTE: a should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[a, 6.5e-34], N[(0.011111111111111112 * N[(Pi * N[(angle * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.011111111111111112 * N[(angle * N[(N[(b - a), $MachinePrecision] * N[(a * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a = |a|\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 6.5 \cdot 10^{-34}:\\
\;\;\;\;0.011111111111111112 \cdot \left(\pi \cdot \left(angle \cdot \left(b \cdot b\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 a < 6.49999999999999985e-34Initial program 54.6%
associate-*l*54.6%
unpow254.6%
unpow254.6%
difference-of-squares58.6%
Simplified58.6%
Taylor expanded in angle around 0 53.3%
Taylor expanded in b around inf 39.0%
*-commutative39.0%
unpow239.0%
Simplified39.0%
Taylor expanded in angle around 0 39.0%
associate-*r*39.1%
*-commutative39.1%
unpow239.1%
Simplified39.1%
if 6.49999999999999985e-34 < a Initial program 46.2%
associate-*l*46.2%
unpow246.2%
unpow246.2%
difference-of-squares50.6%
Simplified50.6%
Taylor expanded in angle around 0 53.4%
Taylor expanded in a around inf 41.1%
*-commutative41.1%
Simplified41.1%
Final simplification39.6%
NOTE: a should be positive before calling this function (FPCore (a b angle) :precision binary64 (* 0.011111111111111112 (* angle (* (- b a) (* PI (+ b a))))))
a = abs(a);
double code(double a, double b, double angle) {
return 0.011111111111111112 * (angle * ((b - a) * (((double) M_PI) * (b + a))));
}
a = Math.abs(a);
public static double code(double a, double b, double angle) {
return 0.011111111111111112 * (angle * ((b - a) * (Math.PI * (b + a))));
}
a = abs(a) def code(a, b, angle): return 0.011111111111111112 * (angle * ((b - a) * (math.pi * (b + a))))
a = abs(a) function code(a, b, angle) return Float64(0.011111111111111112 * Float64(angle * Float64(Float64(b - a) * Float64(pi * Float64(b + a))))) end
a = abs(a) function tmp = code(a, b, angle) tmp = 0.011111111111111112 * (angle * ((b - a) * (pi * (b + a)))); end
NOTE: a should be positive before calling this function code[a_, b_, angle_] := N[(0.011111111111111112 * N[(angle * N[(N[(b - a), $MachinePrecision] * N[(Pi * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a = |a|\\
\\
0.011111111111111112 \cdot \left(angle \cdot \left(\left(b - a\right) \cdot \left(\pi \cdot \left(b + a\right)\right)\right)\right)
\end{array}
Initial program 52.2%
associate-*l*52.2%
unpow252.2%
unpow252.2%
difference-of-squares56.3%
Simplified56.3%
Taylor expanded in angle around 0 53.3%
Final simplification53.3%
NOTE: a should be positive before calling this function (FPCore (a b angle) :precision binary64 (* 0.011111111111111112 (* (* PI (+ b a)) (* (- b a) angle))))
a = abs(a);
double code(double a, double b, double angle) {
return 0.011111111111111112 * ((((double) M_PI) * (b + a)) * ((b - a) * angle));
}
a = Math.abs(a);
public static double code(double a, double b, double angle) {
return 0.011111111111111112 * ((Math.PI * (b + a)) * ((b - a) * angle));
}
a = abs(a) def code(a, b, angle): return 0.011111111111111112 * ((math.pi * (b + a)) * ((b - a) * angle))
a = abs(a) function code(a, b, angle) return Float64(0.011111111111111112 * Float64(Float64(pi * Float64(b + a)) * Float64(Float64(b - a) * angle))) end
a = abs(a) function tmp = code(a, b, angle) tmp = 0.011111111111111112 * ((pi * (b + a)) * ((b - a) * angle)); end
NOTE: a should be positive before calling this function code[a_, b_, angle_] := N[(0.011111111111111112 * N[(N[(Pi * N[(b + a), $MachinePrecision]), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a = |a|\\
\\
0.011111111111111112 \cdot \left(\left(\pi \cdot \left(b + a\right)\right) \cdot \left(\left(b - a\right) \cdot angle\right)\right)
\end{array}
Initial program 52.2%
associate-*l*52.2%
unpow252.2%
unpow252.2%
difference-of-squares56.3%
Simplified56.3%
Taylor expanded in angle around 0 53.3%
associate-*r*65.2%
*-commutative65.2%
+-commutative65.2%
Simplified65.2%
Final simplification65.2%
NOTE: a should be positive before calling this function (FPCore (a b angle) :precision binary64 (if (<= b 1.95e+33) (* (* angle (* PI (* a a))) -0.011111111111111112) (* 0.011111111111111112 (* (* angle PI) (* b b)))))
a = abs(a);
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.95e+33) {
tmp = (angle * (((double) M_PI) * (a * a))) * -0.011111111111111112;
} else {
tmp = 0.011111111111111112 * ((angle * ((double) M_PI)) * (b * b));
}
return tmp;
}
a = Math.abs(a);
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 1.95e+33) {
tmp = (angle * (Math.PI * (a * a))) * -0.011111111111111112;
} else {
tmp = 0.011111111111111112 * ((angle * Math.PI) * (b * b));
}
return tmp;
}
a = abs(a) def code(a, b, angle): tmp = 0 if b <= 1.95e+33: tmp = (angle * (math.pi * (a * a))) * -0.011111111111111112 else: tmp = 0.011111111111111112 * ((angle * math.pi) * (b * b)) return tmp
a = abs(a) function code(a, b, angle) tmp = 0.0 if (b <= 1.95e+33) tmp = Float64(Float64(angle * Float64(pi * Float64(a * a))) * -0.011111111111111112); else tmp = Float64(0.011111111111111112 * Float64(Float64(angle * pi) * Float64(b * b))); end return tmp end
a = abs(a) function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 1.95e+33) tmp = (angle * (pi * (a * a))) * -0.011111111111111112; else tmp = 0.011111111111111112 * ((angle * pi) * (b * b)); end tmp_2 = tmp; end
NOTE: a should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[b, 1.95e+33], N[(N[(angle * N[(Pi * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.011111111111111112), $MachinePrecision], N[(0.011111111111111112 * N[(N[(angle * Pi), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
a = |a|\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.95 \cdot 10^{+33}:\\
\;\;\;\;\left(angle \cdot \left(\pi \cdot \left(a \cdot a\right)\right)\right) \cdot -0.011111111111111112\\
\mathbf{else}:\\
\;\;\;\;0.011111111111111112 \cdot \left(\left(angle \cdot \pi\right) \cdot \left(b \cdot b\right)\right)\\
\end{array}
\end{array}
if b < 1.9500000000000001e33Initial program 55.2%
associate-*l*55.2%
unpow255.2%
unpow255.2%
difference-of-squares58.9%
Simplified58.9%
Taylor expanded in angle around 0 56.4%
Taylor expanded in b around 0 38.8%
*-commutative38.8%
*-commutative38.8%
unpow238.8%
Simplified38.8%
if 1.9500000000000001e33 < b Initial program 43.0%
associate-*l*43.0%
unpow243.0%
unpow243.0%
difference-of-squares48.2%
Simplified48.2%
Taylor expanded in angle around 0 43.8%
Taylor expanded in b around inf 35.9%
*-commutative35.9%
unpow235.9%
Simplified35.9%
Taylor expanded in angle around 0 35.9%
*-commutative35.9%
associate-*r*35.9%
unpow235.9%
Simplified35.9%
Final simplification38.1%
NOTE: a should be positive before calling this function (FPCore (a b angle) :precision binary64 (* 0.011111111111111112 (* angle (* PI (* b b)))))
a = abs(a);
double code(double a, double b, double angle) {
return 0.011111111111111112 * (angle * (((double) M_PI) * (b * b)));
}
a = Math.abs(a);
public static double code(double a, double b, double angle) {
return 0.011111111111111112 * (angle * (Math.PI * (b * b)));
}
a = abs(a) def code(a, b, angle): return 0.011111111111111112 * (angle * (math.pi * (b * b)))
a = abs(a) function code(a, b, angle) return Float64(0.011111111111111112 * Float64(angle * Float64(pi * Float64(b * b)))) end
a = abs(a) function tmp = code(a, b, angle) tmp = 0.011111111111111112 * (angle * (pi * (b * b))); end
NOTE: a should be positive before calling this function code[a_, b_, angle_] := N[(0.011111111111111112 * N[(angle * N[(Pi * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a = |a|\\
\\
0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(b \cdot b\right)\right)\right)
\end{array}
Initial program 52.2%
associate-*l*52.2%
unpow252.2%
unpow252.2%
difference-of-squares56.3%
Simplified56.3%
Taylor expanded in angle around 0 53.3%
Taylor expanded in b around inf 33.5%
*-commutative33.5%
unpow233.5%
Simplified33.5%
Final simplification33.5%
NOTE: a should be positive before calling this function (FPCore (a b angle) :precision binary64 (* 0.011111111111111112 (* PI (* angle (* b b)))))
a = abs(a);
double code(double a, double b, double angle) {
return 0.011111111111111112 * (((double) M_PI) * (angle * (b * b)));
}
a = Math.abs(a);
public static double code(double a, double b, double angle) {
return 0.011111111111111112 * (Math.PI * (angle * (b * b)));
}
a = abs(a) def code(a, b, angle): return 0.011111111111111112 * (math.pi * (angle * (b * b)))
a = abs(a) function code(a, b, angle) return Float64(0.011111111111111112 * Float64(pi * Float64(angle * Float64(b * b)))) end
a = abs(a) function tmp = code(a, b, angle) tmp = 0.011111111111111112 * (pi * (angle * (b * b))); end
NOTE: a should be positive before calling this function code[a_, b_, angle_] := N[(0.011111111111111112 * N[(Pi * N[(angle * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a = |a|\\
\\
0.011111111111111112 \cdot \left(\pi \cdot \left(angle \cdot \left(b \cdot b\right)\right)\right)
\end{array}
Initial program 52.2%
associate-*l*52.2%
unpow252.2%
unpow252.2%
difference-of-squares56.3%
Simplified56.3%
Taylor expanded in angle around 0 53.3%
Taylor expanded in b around inf 33.5%
*-commutative33.5%
unpow233.5%
Simplified33.5%
Taylor expanded in angle around 0 33.5%
associate-*r*33.5%
*-commutative33.5%
unpow233.5%
Simplified33.5%
Final simplification33.5%
herbie shell --seed 2023242
(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)))))