
(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 13 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
(if (<= (/ angle 180.0) -1e+182)
(/
(*
(* (+ a b) (pow (- b a) 2.0))
(sin
(*
(* 2.0 (* (cbrt PI) (pow (cbrt PI) 2.0)))
(* angle 0.005555555555555556))))
(- b a))
(* (+ a b) (* (- b a) (sin (* 0.011111111111111112 (* angle PI)))))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= -1e+182) {
tmp = (((a + b) * pow((b - a), 2.0)) * sin(((2.0 * (cbrt(((double) M_PI)) * pow(cbrt(((double) M_PI)), 2.0))) * (angle * 0.005555555555555556)))) / (b - a);
} else {
tmp = (a + b) * ((b - a) * sin((0.011111111111111112 * (angle * ((double) M_PI)))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= -1e+182) {
tmp = (((a + b) * Math.pow((b - a), 2.0)) * Math.sin(((2.0 * (Math.cbrt(Math.PI) * Math.pow(Math.cbrt(Math.PI), 2.0))) * (angle * 0.005555555555555556)))) / (b - a);
} else {
tmp = (a + b) * ((b - a) * Math.sin((0.011111111111111112 * (angle * Math.PI))));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= -1e+182) tmp = Float64(Float64(Float64(Float64(a + b) * (Float64(b - a) ^ 2.0)) * sin(Float64(Float64(2.0 * Float64(cbrt(pi) * (cbrt(pi) ^ 2.0))) * Float64(angle * 0.005555555555555556)))) / Float64(b - a)); else tmp = Float64(Float64(a + b) * Float64(Float64(b - a) * sin(Float64(0.011111111111111112 * Float64(angle * pi))))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], -1e+182], N[(N[(N[(N[(a + b), $MachinePrecision] * N[Power[N[(b - a), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(2.0 * N[(N[Power[Pi, 1/3], $MachinePrecision] * N[Power[N[Power[Pi, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(b - a), $MachinePrecision]), $MachinePrecision], N[(N[(a + b), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[Sin[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq -1 \cdot 10^{+182}:\\
\;\;\;\;\frac{\left(\left(a + b\right) \cdot {\left(b - a\right)}^{2}\right) \cdot \sin \left(\left(2 \cdot \left(\sqrt[3]{\pi} \cdot {\left(\sqrt[3]{\pi}\right)}^{2}\right)\right) \cdot \left(angle \cdot 0.005555555555555556\right)\right)}{b - a}\\
\mathbf{else}:\\
\;\;\;\;\left(a + b\right) \cdot \left(\left(b - a\right) \cdot \sin \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right)\\
\end{array}
\end{array}
if (/.f64 angle 180) < -1.0000000000000001e182Initial program 38.0%
*-commutative38.0%
associate-*l*38.0%
associate-*l*38.0%
unpow238.0%
unpow238.0%
difference-of-squares38.0%
Simplified38.0%
associate-*l*38.0%
flip-+38.0%
associate-*l/36.9%
difference-of-squares36.9%
associate-*l*36.9%
2-sin36.9%
div-inv33.3%
metadata-eval33.3%
Applied egg-rr33.3%
associate-*r*33.3%
associate-*l*33.3%
+-commutative33.3%
unpow233.3%
associate-*r*33.3%
*-commutative33.3%
Simplified33.3%
add-cube-cbrt60.7%
pow260.7%
Applied egg-rr60.7%
if -1.0000000000000001e182 < (/.f64 angle 180) Initial program 59.8%
*-commutative59.8%
associate-*l*59.8%
associate-*l*59.8%
unpow259.8%
unpow259.8%
difference-of-squares62.1%
Simplified62.1%
difference-of-squares59.8%
*-commutative59.8%
prod-diff51.5%
fma-neg51.5%
distribute-lft-in51.5%
Applied egg-rr52.6%
*-commutative52.6%
distribute-lft-in52.6%
*-commutative52.6%
Simplified74.3%
Taylor expanded in angle around inf 76.1%
Final simplification74.6%
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) -2e+81)
(*
(+ a b)
(*
(- b a)
(sin (* 2.0 (pow (cbrt (* 0.005555555555555556 (* angle PI))) 3.0)))))
(* (+ a b) (* (- b a) (sin (* 0.011111111111111112 (* angle PI)))))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= -2e+81) {
tmp = (a + b) * ((b - a) * sin((2.0 * pow(cbrt((0.005555555555555556 * (angle * ((double) M_PI)))), 3.0))));
} else {
tmp = (a + b) * ((b - a) * sin((0.011111111111111112 * (angle * ((double) M_PI)))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= -2e+81) {
tmp = (a + b) * ((b - a) * Math.sin((2.0 * Math.pow(Math.cbrt((0.005555555555555556 * (angle * Math.PI))), 3.0))));
} else {
tmp = (a + b) * ((b - a) * Math.sin((0.011111111111111112 * (angle * Math.PI))));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= -2e+81) tmp = Float64(Float64(a + b) * Float64(Float64(b - a) * sin(Float64(2.0 * (cbrt(Float64(0.005555555555555556 * Float64(angle * pi))) ^ 3.0))))); else tmp = Float64(Float64(a + b) * Float64(Float64(b - a) * sin(Float64(0.011111111111111112 * Float64(angle * pi))))); end return tmp end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], -2e+81], N[(N[(a + b), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[Sin[N[(2.0 * N[Power[N[Power[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + b), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[Sin[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq -2 \cdot 10^{+81}:\\
\;\;\;\;\left(a + b\right) \cdot \left(\left(b - a\right) \cdot \sin \left(2 \cdot {\left(\sqrt[3]{0.005555555555555556 \cdot \left(angle \cdot \pi\right)}\right)}^{3}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + b\right) \cdot \left(\left(b - a\right) \cdot \sin \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right)\\
\end{array}
\end{array}
if (/.f64 angle 180) < -1.99999999999999984e81Initial program 34.3%
*-commutative34.3%
associate-*l*34.3%
associate-*l*34.3%
unpow234.3%
unpow234.3%
difference-of-squares34.3%
Simplified34.3%
difference-of-squares34.3%
*-commutative34.3%
prod-diff24.5%
fma-neg24.5%
distribute-lft-in24.5%
Applied egg-rr22.5%
*-commutative22.5%
distribute-lft-in22.5%
*-commutative22.5%
Simplified32.2%
*-commutative32.2%
associate-*r*30.6%
add-cube-cbrt44.3%
pow347.6%
*-commutative47.6%
Applied egg-rr47.6%
if -1.99999999999999984e81 < (/.f64 angle 180) Initial program 62.1%
*-commutative62.1%
associate-*l*62.1%
associate-*l*62.1%
unpow262.1%
unpow262.1%
difference-of-squares64.6%
Simplified64.6%
difference-of-squares62.1%
*-commutative62.1%
prod-diff53.7%
fma-neg53.7%
distribute-lft-in53.7%
Applied egg-rr54.8%
*-commutative54.8%
distribute-lft-in54.8%
*-commutative54.8%
Simplified77.6%
Taylor expanded in angle around inf 79.5%
Final simplification74.4%
(FPCore (a b angle)
:precision binary64
(if (<= (/ angle 180.0) -1e+182)
(*
(+ a b)
(* (- b a) (sin (* 0.011111111111111112 (* angle (pow (sqrt PI) 2.0))))))
(* (+ a b) (* (- b a) (sin (* 0.011111111111111112 (* angle PI)))))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= -1e+182) {
tmp = (a + b) * ((b - a) * sin((0.011111111111111112 * (angle * pow(sqrt(((double) M_PI)), 2.0)))));
} else {
tmp = (a + b) * ((b - a) * sin((0.011111111111111112 * (angle * ((double) M_PI)))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= -1e+182) {
tmp = (a + b) * ((b - a) * Math.sin((0.011111111111111112 * (angle * Math.pow(Math.sqrt(Math.PI), 2.0)))));
} else {
tmp = (a + b) * ((b - a) * Math.sin((0.011111111111111112 * (angle * Math.PI))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if (angle / 180.0) <= -1e+182: tmp = (a + b) * ((b - a) * math.sin((0.011111111111111112 * (angle * math.pow(math.sqrt(math.pi), 2.0))))) else: tmp = (a + b) * ((b - a) * math.sin((0.011111111111111112 * (angle * math.pi)))) return tmp
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= -1e+182) tmp = Float64(Float64(a + b) * Float64(Float64(b - a) * sin(Float64(0.011111111111111112 * Float64(angle * (sqrt(pi) ^ 2.0)))))); else tmp = Float64(Float64(a + b) * Float64(Float64(b - a) * sin(Float64(0.011111111111111112 * Float64(angle * pi))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if ((angle / 180.0) <= -1e+182) tmp = (a + b) * ((b - a) * sin((0.011111111111111112 * (angle * (sqrt(pi) ^ 2.0))))); else tmp = (a + b) * ((b - a) * sin((0.011111111111111112 * (angle * pi)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], -1e+182], N[(N[(a + b), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[Sin[N[(0.011111111111111112 * N[(angle * N[Power[N[Sqrt[Pi], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + b), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[Sin[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq -1 \cdot 10^{+182}:\\
\;\;\;\;\left(a + b\right) \cdot \left(\left(b - a\right) \cdot \sin \left(0.011111111111111112 \cdot \left(angle \cdot {\left(\sqrt{\pi}\right)}^{2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + b\right) \cdot \left(\left(b - a\right) \cdot \sin \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right)\\
\end{array}
\end{array}
if (/.f64 angle 180) < -1.0000000000000001e182Initial program 38.0%
*-commutative38.0%
associate-*l*38.0%
associate-*l*38.0%
unpow238.0%
unpow238.0%
difference-of-squares38.0%
Simplified38.0%
difference-of-squares38.0%
*-commutative38.0%
prod-diff26.0%
fma-neg26.0%
distribute-lft-in26.0%
Applied egg-rr21.9%
*-commutative21.9%
distribute-lft-in21.9%
*-commutative21.9%
Simplified33.9%
Taylor expanded in angle around inf 30.4%
add-sqr-sqrt48.5%
pow248.5%
Applied egg-rr48.5%
if -1.0000000000000001e182 < (/.f64 angle 180) Initial program 59.8%
*-commutative59.8%
associate-*l*59.8%
associate-*l*59.8%
unpow259.8%
unpow259.8%
difference-of-squares62.1%
Simplified62.1%
difference-of-squares59.8%
*-commutative59.8%
prod-diff51.5%
fma-neg51.5%
distribute-lft-in51.5%
Applied egg-rr52.6%
*-commutative52.6%
distribute-lft-in52.6%
*-commutative52.6%
Simplified74.3%
Taylor expanded in angle around inf 76.1%
Final simplification73.4%
(FPCore (a b angle)
:precision binary64
(if (<= b 3.4e-129)
(* (* a (sin (* PI (* angle 0.011111111111111112)))) (- (+ a b)))
(if (<= b 2e+230)
(* (+ a b) (* 0.011111111111111112 (* PI (* angle (- b a)))))
(* (+ a b) (* b (sin (* 0.011111111111111112 (* angle PI))))))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 3.4e-129) {
tmp = (a * sin((((double) M_PI) * (angle * 0.011111111111111112)))) * -(a + b);
} else if (b <= 2e+230) {
tmp = (a + b) * (0.011111111111111112 * (((double) M_PI) * (angle * (b - a))));
} else {
tmp = (a + b) * (b * sin((0.011111111111111112 * (angle * ((double) M_PI)))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 3.4e-129) {
tmp = (a * Math.sin((Math.PI * (angle * 0.011111111111111112)))) * -(a + b);
} else if (b <= 2e+230) {
tmp = (a + b) * (0.011111111111111112 * (Math.PI * (angle * (b - a))));
} else {
tmp = (a + b) * (b * Math.sin((0.011111111111111112 * (angle * Math.PI))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 3.4e-129: tmp = (a * math.sin((math.pi * (angle * 0.011111111111111112)))) * -(a + b) elif b <= 2e+230: tmp = (a + b) * (0.011111111111111112 * (math.pi * (angle * (b - a)))) else: tmp = (a + b) * (b * math.sin((0.011111111111111112 * (angle * math.pi)))) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 3.4e-129) tmp = Float64(Float64(a * sin(Float64(pi * Float64(angle * 0.011111111111111112)))) * Float64(-Float64(a + b))); elseif (b <= 2e+230) tmp = Float64(Float64(a + b) * Float64(0.011111111111111112 * Float64(pi * Float64(angle * Float64(b - a))))); else tmp = Float64(Float64(a + b) * Float64(b * sin(Float64(0.011111111111111112 * Float64(angle * pi))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 3.4e-129) tmp = (a * sin((pi * (angle * 0.011111111111111112)))) * -(a + b); elseif (b <= 2e+230) tmp = (a + b) * (0.011111111111111112 * (pi * (angle * (b - a)))); else tmp = (a + b) * (b * sin((0.011111111111111112 * (angle * pi)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 3.4e-129], N[(N[(a * N[Sin[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * (-N[(a + b), $MachinePrecision])), $MachinePrecision], If[LessEqual[b, 2e+230], N[(N[(a + b), $MachinePrecision] * N[(0.011111111111111112 * N[(Pi * N[(angle * N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + b), $MachinePrecision] * N[(b * N[Sin[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.4 \cdot 10^{-129}:\\
\;\;\;\;\left(a \cdot \sin \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)\right) \cdot \left(-\left(a + b\right)\right)\\
\mathbf{elif}\;b \leq 2 \cdot 10^{+230}:\\
\;\;\;\;\left(a + b\right) \cdot \left(0.011111111111111112 \cdot \left(\pi \cdot \left(angle \cdot \left(b - a\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + b\right) \cdot \left(b \cdot \sin \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right)\\
\end{array}
\end{array}
if b < 3.40000000000000013e-129Initial program 61.0%
*-commutative61.0%
associate-*l*61.0%
associate-*l*61.0%
unpow261.0%
unpow261.0%
difference-of-squares62.7%
Simplified62.7%
difference-of-squares61.0%
*-commutative61.0%
prod-diff49.8%
fma-neg49.8%
distribute-lft-in49.8%
Applied egg-rr49.5%
*-commutative49.5%
distribute-lft-in49.5%
*-commutative49.5%
Simplified70.9%
Taylor expanded in b around 0 51.4%
associate-*r*51.4%
mul-1-neg51.4%
associate-*r*50.5%
Simplified50.5%
if 3.40000000000000013e-129 < b < 2.0000000000000002e230Initial program 48.6%
*-commutative48.6%
associate-*l*48.6%
associate-*l*48.6%
unpow248.6%
unpow248.6%
difference-of-squares48.9%
Simplified48.9%
difference-of-squares48.6%
*-commutative48.6%
prod-diff46.3%
fma-neg46.3%
distribute-lft-in46.3%
Applied egg-rr46.2%
*-commutative46.2%
distribute-lft-in46.2%
*-commutative46.2%
Simplified68.1%
Taylor expanded in angle around 0 64.6%
associate-*r*64.5%
*-commutative64.5%
associate-*l*64.6%
Simplified64.6%
if 2.0000000000000002e230 < b Initial program 50.6%
*-commutative50.6%
associate-*l*50.6%
associate-*l*50.6%
unpow250.6%
unpow250.6%
difference-of-squares64.8%
Simplified64.8%
difference-of-squares50.6%
*-commutative50.6%
prod-diff50.6%
fma-neg50.6%
distribute-lft-in50.6%
Applied egg-rr64.8%
*-commutative64.8%
distribute-lft-in64.8%
*-commutative64.8%
Simplified71.4%
Taylor expanded in b around inf 78.6%
Final simplification55.2%
(FPCore (a b angle) :precision binary64 (if (<= a 1.1e-84) (* (+ a b) (* b (sin (* 0.011111111111111112 (* angle PI))))) (* (+ a b) (* 0.011111111111111112 (* PI (* angle (- b a)))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.1e-84) {
tmp = (a + b) * (b * sin((0.011111111111111112 * (angle * ((double) M_PI)))));
} else {
tmp = (a + b) * (0.011111111111111112 * (((double) M_PI) * (angle * (b - a))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.1e-84) {
tmp = (a + b) * (b * Math.sin((0.011111111111111112 * (angle * Math.PI))));
} else {
tmp = (a + b) * (0.011111111111111112 * (Math.PI * (angle * (b - a))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.1e-84: tmp = (a + b) * (b * math.sin((0.011111111111111112 * (angle * math.pi)))) else: tmp = (a + b) * (0.011111111111111112 * (math.pi * (angle * (b - a)))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.1e-84) tmp = Float64(Float64(a + b) * Float64(b * sin(Float64(0.011111111111111112 * Float64(angle * pi))))); else tmp = Float64(Float64(a + b) * Float64(0.011111111111111112 * Float64(pi * Float64(angle * Float64(b - a))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.1e-84) tmp = (a + b) * (b * sin((0.011111111111111112 * (angle * pi)))); else tmp = (a + b) * (0.011111111111111112 * (pi * (angle * (b - a)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.1e-84], N[(N[(a + b), $MachinePrecision] * N[(b * N[Sin[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + b), $MachinePrecision] * N[(0.011111111111111112 * N[(Pi * N[(angle * N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.1 \cdot 10^{-84}:\\
\;\;\;\;\left(a + b\right) \cdot \left(b \cdot \sin \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + b\right) \cdot \left(0.011111111111111112 \cdot \left(\pi \cdot \left(angle \cdot \left(b - a\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.0999999999999999e-84Initial program 62.2%
*-commutative62.2%
associate-*l*62.2%
associate-*l*62.2%
unpow262.2%
unpow262.2%
difference-of-squares63.4%
Simplified63.4%
difference-of-squares62.2%
*-commutative62.2%
prod-diff56.1%
fma-neg56.1%
distribute-lft-in56.1%
Applied egg-rr56.9%
*-commutative56.9%
distribute-lft-in56.9%
*-commutative56.9%
Simplified72.2%
Taylor expanded in b around inf 53.6%
if 1.0999999999999999e-84 < a Initial program 48.2%
*-commutative48.2%
associate-*l*48.2%
associate-*l*48.3%
unpow248.3%
unpow248.3%
difference-of-squares52.0%
Simplified52.0%
difference-of-squares48.3%
*-commutative48.3%
prod-diff34.3%
fma-neg34.3%
distribute-lft-in34.3%
Applied egg-rr34.3%
*-commutative34.3%
distribute-lft-in34.3%
*-commutative34.3%
Simplified66.4%
Taylor expanded in angle around 0 62.7%
associate-*r*62.8%
*-commutative62.8%
associate-*l*62.8%
Simplified62.8%
Final simplification56.5%
(FPCore (a b angle) :precision binary64 (* (+ a b) (* (- b a) (sin (* 0.011111111111111112 (* angle PI))))))
double code(double a, double b, double angle) {
return (a + b) * ((b - a) * sin((0.011111111111111112 * (angle * ((double) M_PI)))));
}
public static double code(double a, double b, double angle) {
return (a + b) * ((b - a) * Math.sin((0.011111111111111112 * (angle * Math.PI))));
}
def code(a, b, angle): return (a + b) * ((b - a) * math.sin((0.011111111111111112 * (angle * math.pi))))
function code(a, b, angle) return Float64(Float64(a + b) * Float64(Float64(b - a) * sin(Float64(0.011111111111111112 * Float64(angle * pi))))) end
function tmp = code(a, b, angle) tmp = (a + b) * ((b - a) * sin((0.011111111111111112 * (angle * pi)))); end
code[a_, b_, angle_] := N[(N[(a + b), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[Sin[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + b\right) \cdot \left(\left(b - a\right) \cdot \sin \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right)
\end{array}
Initial program 57.7%
*-commutative57.7%
associate-*l*57.7%
associate-*l*57.7%
unpow257.7%
unpow257.7%
difference-of-squares59.7%
Simplified59.7%
difference-of-squares57.7%
*-commutative57.7%
prod-diff49.0%
fma-neg49.0%
distribute-lft-in49.0%
Applied egg-rr49.6%
*-commutative49.6%
distribute-lft-in49.6%
*-commutative49.6%
Simplified70.3%
Taylor expanded in angle around inf 71.7%
Final simplification71.7%
(FPCore (a b angle) :precision binary64 (if (<= a 1.3e-138) (* (sin (* 0.011111111111111112 (* angle PI))) (* b b)) (* (+ a b) (* 0.011111111111111112 (* PI (* angle (- b a)))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.3e-138) {
tmp = sin((0.011111111111111112 * (angle * ((double) M_PI)))) * (b * b);
} else {
tmp = (a + b) * (0.011111111111111112 * (((double) M_PI) * (angle * (b - a))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.3e-138) {
tmp = Math.sin((0.011111111111111112 * (angle * Math.PI))) * (b * b);
} else {
tmp = (a + b) * (0.011111111111111112 * (Math.PI * (angle * (b - a))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.3e-138: tmp = math.sin((0.011111111111111112 * (angle * math.pi))) * (b * b) else: tmp = (a + b) * (0.011111111111111112 * (math.pi * (angle * (b - a)))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.3e-138) tmp = Float64(sin(Float64(0.011111111111111112 * Float64(angle * pi))) * Float64(b * b)); else tmp = Float64(Float64(a + b) * Float64(0.011111111111111112 * Float64(pi * Float64(angle * Float64(b - a))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.3e-138) tmp = sin((0.011111111111111112 * (angle * pi))) * (b * b); else tmp = (a + b) * (0.011111111111111112 * (pi * (angle * (b - a)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.3e-138], N[(N[Sin[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision], N[(N[(a + b), $MachinePrecision] * N[(0.011111111111111112 * N[(Pi * N[(angle * N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.3 \cdot 10^{-138}:\\
\;\;\;\;\sin \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right) \cdot \left(b \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + b\right) \cdot \left(0.011111111111111112 \cdot \left(\pi \cdot \left(angle \cdot \left(b - a\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.3e-138Initial program 62.3%
*-commutative62.3%
associate-*l*62.3%
associate-*l*62.3%
unpow262.3%
unpow262.3%
difference-of-squares63.6%
Simplified63.6%
associate-*l*72.0%
flip-+62.3%
associate-*l/57.6%
difference-of-squares58.9%
associate-*l*58.9%
2-sin58.9%
div-inv58.6%
metadata-eval58.6%
Applied egg-rr58.6%
associate-*r*53.5%
associate-*l*53.5%
+-commutative53.5%
unpow253.5%
associate-*r*53.5%
*-commutative53.5%
Simplified53.5%
Taylor expanded in a around 0 49.1%
*-commutative49.1%
unpow249.1%
Simplified49.1%
if 1.3e-138 < a Initial program 49.1%
*-commutative49.1%
associate-*l*49.1%
associate-*l*49.2%
unpow249.2%
unpow249.2%
difference-of-squares52.6%
Simplified52.6%
difference-of-squares49.2%
*-commutative49.2%
prod-diff36.3%
fma-neg36.3%
distribute-lft-in36.3%
Applied egg-rr36.3%
*-commutative36.3%
distribute-lft-in36.3%
*-commutative36.3%
Simplified67.9%
Taylor expanded in angle around 0 64.5%
associate-*r*64.5%
*-commutative64.5%
associate-*l*64.5%
Simplified64.5%
Final simplification54.5%
(FPCore (a b angle) :precision binary64 (* 0.011111111111111112 (* angle (* PI (* (+ a b) (- b a))))))
double code(double a, double b, double angle) {
return 0.011111111111111112 * (angle * (((double) M_PI) * ((a + b) * (b - a))));
}
public static double code(double a, double b, double angle) {
return 0.011111111111111112 * (angle * (Math.PI * ((a + b) * (b - a))));
}
def code(a, b, angle): return 0.011111111111111112 * (angle * (math.pi * ((a + b) * (b - a))))
function code(a, b, angle) return Float64(0.011111111111111112 * Float64(angle * Float64(pi * Float64(Float64(a + b) * Float64(b - a))))) end
function tmp = code(a, b, angle) tmp = 0.011111111111111112 * (angle * (pi * ((a + b) * (b - a)))); end
code[a_, b_, angle_] := N[(0.011111111111111112 * N[(angle * N[(Pi * N[(N[(a + b), $MachinePrecision] * N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(\left(a + b\right) \cdot \left(b - a\right)\right)\right)\right)
\end{array}
Initial program 57.7%
*-commutative57.7%
associate-*l*57.7%
associate-*l*57.7%
unpow257.7%
unpow257.7%
difference-of-squares59.7%
Simplified59.7%
Taylor expanded in angle around 0 54.1%
Final simplification54.1%
(FPCore (a b angle) :precision binary64 (* (+ a b) (* 0.011111111111111112 (* PI (* angle (- b a))))))
double code(double a, double b, double angle) {
return (a + b) * (0.011111111111111112 * (((double) M_PI) * (angle * (b - a))));
}
public static double code(double a, double b, double angle) {
return (a + b) * (0.011111111111111112 * (Math.PI * (angle * (b - a))));
}
def code(a, b, angle): return (a + b) * (0.011111111111111112 * (math.pi * (angle * (b - a))))
function code(a, b, angle) return Float64(Float64(a + b) * Float64(0.011111111111111112 * Float64(pi * Float64(angle * Float64(b - a))))) end
function tmp = code(a, b, angle) tmp = (a + b) * (0.011111111111111112 * (pi * (angle * (b - a)))); end
code[a_, b_, angle_] := N[(N[(a + b), $MachinePrecision] * N[(0.011111111111111112 * N[(Pi * N[(angle * N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + b\right) \cdot \left(0.011111111111111112 \cdot \left(\pi \cdot \left(angle \cdot \left(b - a\right)\right)\right)\right)
\end{array}
Initial program 57.7%
*-commutative57.7%
associate-*l*57.7%
associate-*l*57.7%
unpow257.7%
unpow257.7%
difference-of-squares59.7%
Simplified59.7%
difference-of-squares57.7%
*-commutative57.7%
prod-diff49.0%
fma-neg49.0%
distribute-lft-in49.0%
Applied egg-rr49.6%
*-commutative49.6%
distribute-lft-in49.6%
*-commutative49.6%
Simplified70.3%
Taylor expanded in angle around 0 62.8%
associate-*r*62.8%
*-commutative62.8%
associate-*l*62.8%
Simplified62.8%
Final simplification62.8%
(FPCore (a b angle) :precision binary64 (if (<= a 1.65e-78) (* 0.011111111111111112 (* angle (* PI (* b b)))) (* -0.011111111111111112 (* angle (* PI (* a a))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.65e-78) {
tmp = 0.011111111111111112 * (angle * (((double) M_PI) * (b * b)));
} else {
tmp = -0.011111111111111112 * (angle * (((double) M_PI) * (a * a)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.65e-78) {
tmp = 0.011111111111111112 * (angle * (Math.PI * (b * b)));
} else {
tmp = -0.011111111111111112 * (angle * (Math.PI * (a * a)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.65e-78: tmp = 0.011111111111111112 * (angle * (math.pi * (b * b))) else: tmp = -0.011111111111111112 * (angle * (math.pi * (a * a))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.65e-78) tmp = Float64(0.011111111111111112 * Float64(angle * Float64(pi * Float64(b * b)))); else tmp = Float64(-0.011111111111111112 * Float64(angle * Float64(pi * Float64(a * a)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.65e-78) tmp = 0.011111111111111112 * (angle * (pi * (b * b))); else tmp = -0.011111111111111112 * (angle * (pi * (a * a))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.65e-78], N[(0.011111111111111112 * N[(angle * N[(Pi * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.011111111111111112 * N[(angle * N[(Pi * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.65 \cdot 10^{-78}:\\
\;\;\;\;0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(b \cdot b\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(a \cdot a\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.64999999999999991e-78Initial program 61.8%
*-commutative61.8%
associate-*l*61.8%
associate-*l*61.8%
unpow261.8%
unpow261.8%
difference-of-squares63.0%
Simplified63.0%
Taylor expanded in angle around 0 56.0%
Taylor expanded in a around 0 45.7%
*-commutative45.7%
unpow245.7%
Simplified45.7%
if 1.64999999999999991e-78 < a Initial program 48.6%
*-commutative48.6%
associate-*l*48.6%
associate-*l*48.6%
unpow248.6%
unpow248.6%
difference-of-squares52.5%
Simplified52.5%
Taylor expanded in angle around 0 49.9%
Taylor expanded in a around inf 41.6%
*-commutative41.6%
*-commutative41.6%
associate-*l*41.5%
unpow241.5%
Simplified41.5%
Final simplification44.4%
(FPCore (a b angle) :precision binary64 (if (<= a 1.45e-78) (* 0.011111111111111112 (* angle (* PI (* b b)))) (* (* PI (* angle (* a a))) -0.011111111111111112)))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.45e-78) {
tmp = 0.011111111111111112 * (angle * (((double) M_PI) * (b * b)));
} else {
tmp = (((double) M_PI) * (angle * (a * a))) * -0.011111111111111112;
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.45e-78) {
tmp = 0.011111111111111112 * (angle * (Math.PI * (b * b)));
} else {
tmp = (Math.PI * (angle * (a * a))) * -0.011111111111111112;
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.45e-78: tmp = 0.011111111111111112 * (angle * (math.pi * (b * b))) else: tmp = (math.pi * (angle * (a * a))) * -0.011111111111111112 return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.45e-78) tmp = Float64(0.011111111111111112 * Float64(angle * Float64(pi * Float64(b * b)))); else tmp = Float64(Float64(pi * Float64(angle * Float64(a * a))) * -0.011111111111111112); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.45e-78) tmp = 0.011111111111111112 * (angle * (pi * (b * b))); else tmp = (pi * (angle * (a * a))) * -0.011111111111111112; end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.45e-78], N[(0.011111111111111112 * N[(angle * N[(Pi * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * N[(angle * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.011111111111111112), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.45 \cdot 10^{-78}:\\
\;\;\;\;0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(b \cdot b\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\pi \cdot \left(angle \cdot \left(a \cdot a\right)\right)\right) \cdot -0.011111111111111112\\
\end{array}
\end{array}
if a < 1.45e-78Initial program 61.8%
*-commutative61.8%
associate-*l*61.8%
associate-*l*61.8%
unpow261.8%
unpow261.8%
difference-of-squares63.0%
Simplified63.0%
Taylor expanded in angle around 0 56.0%
Taylor expanded in a around 0 45.7%
*-commutative45.7%
unpow245.7%
Simplified45.7%
if 1.45e-78 < a Initial program 48.6%
*-commutative48.6%
associate-*l*48.6%
associate-*l*48.6%
unpow248.6%
unpow248.6%
difference-of-squares52.5%
Simplified52.5%
Taylor expanded in angle around 0 49.9%
Taylor expanded in a around inf 41.6%
*-commutative41.6%
associate-*r*41.6%
unpow241.6%
Simplified41.6%
Final simplification44.4%
(FPCore (a b angle) :precision binary64 (* 0.011111111111111112 (* angle (* PI (* b b)))))
double code(double a, double b, double angle) {
return 0.011111111111111112 * (angle * (((double) M_PI) * (b * b)));
}
public static double code(double a, double b, double angle) {
return 0.011111111111111112 * (angle * (Math.PI * (b * b)));
}
def code(a, b, angle): return 0.011111111111111112 * (angle * (math.pi * (b * b)))
function code(a, b, angle) return Float64(0.011111111111111112 * Float64(angle * Float64(pi * Float64(b * b)))) end
function tmp = code(a, b, angle) tmp = 0.011111111111111112 * (angle * (pi * (b * b))); end
code[a_, b_, angle_] := N[(0.011111111111111112 * N[(angle * N[(Pi * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(b \cdot b\right)\right)\right)
\end{array}
Initial program 57.7%
*-commutative57.7%
associate-*l*57.7%
associate-*l*57.7%
unpow257.7%
unpow257.7%
difference-of-squares59.7%
Simplified59.7%
Taylor expanded in angle around 0 54.1%
Taylor expanded in a around 0 36.0%
*-commutative36.0%
unpow236.0%
Simplified36.0%
Final simplification36.0%
(FPCore (a b angle) :precision binary64 (* 0.011111111111111112 (* PI (* angle (* b b)))))
double code(double a, double b, double angle) {
return 0.011111111111111112 * (((double) M_PI) * (angle * (b * b)));
}
public static double code(double a, double b, double angle) {
return 0.011111111111111112 * (Math.PI * (angle * (b * b)));
}
def code(a, b, angle): return 0.011111111111111112 * (math.pi * (angle * (b * b)))
function code(a, b, angle) return Float64(0.011111111111111112 * Float64(pi * Float64(angle * Float64(b * b)))) end
function tmp = code(a, b, angle) tmp = 0.011111111111111112 * (pi * (angle * (b * b))); end
code[a_, b_, angle_] := N[(0.011111111111111112 * N[(Pi * N[(angle * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.011111111111111112 \cdot \left(\pi \cdot \left(angle \cdot \left(b \cdot b\right)\right)\right)
\end{array}
Initial program 57.7%
*-commutative57.7%
associate-*l*57.7%
associate-*l*57.7%
unpow257.7%
unpow257.7%
difference-of-squares59.7%
Simplified59.7%
Taylor expanded in angle around 0 54.1%
Taylor expanded in a around 0 36.0%
associate-*r*36.0%
unpow236.0%
Simplified36.0%
Final simplification36.0%
herbie shell --seed 2023271
(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)))))