
(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 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle) :precision binary64 (let* ((t_0 (* PI (/ angle 180.0)))) (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin t_0)) (cos t_0))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle / 180.0);
return ((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin(t_0)) * cos(t_0);
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle / 180.0);
return ((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * Math.sin(t_0)) * Math.cos(t_0);
}
def code(a, b, angle): t_0 = math.pi * (angle / 180.0) return ((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * math.sin(t_0)) * math.cos(t_0)
function code(a, b, angle) t_0 = Float64(pi * Float64(angle / 180.0)) return Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * sin(t_0)) * cos(t_0)) end
function tmp = code(a, b, angle) t_0 = pi * (angle / 180.0); tmp = ((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * sin(t_0)) * cos(t_0); end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin t_0\right) \cdot \cos t_0
\end{array}
\end{array}
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* PI (* angle 0.005555555555555556))))
(if (<= (/ angle 180.0) 5e+38)
(* (+ a b) (* (- b a) (sin (* 2.0 t_0))))
(* (+ a b) (* (- b a) (sin (* 2.0 (pow E (log t_0)))))))))
double code(double a, double b, double angle) {
double t_0 = ((double) M_PI) * (angle * 0.005555555555555556);
double tmp;
if ((angle / 180.0) <= 5e+38) {
tmp = (a + b) * ((b - a) * sin((2.0 * t_0)));
} else {
tmp = (a + b) * ((b - a) * sin((2.0 * pow(((double) M_E), log(t_0)))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = Math.PI * (angle * 0.005555555555555556);
double tmp;
if ((angle / 180.0) <= 5e+38) {
tmp = (a + b) * ((b - a) * Math.sin((2.0 * t_0)));
} else {
tmp = (a + b) * ((b - a) * Math.sin((2.0 * Math.pow(Math.E, Math.log(t_0)))));
}
return tmp;
}
def code(a, b, angle): t_0 = math.pi * (angle * 0.005555555555555556) tmp = 0 if (angle / 180.0) <= 5e+38: tmp = (a + b) * ((b - a) * math.sin((2.0 * t_0))) else: tmp = (a + b) * ((b - a) * math.sin((2.0 * math.pow(math.e, math.log(t_0))))) return tmp
function code(a, b, angle) t_0 = Float64(pi * Float64(angle * 0.005555555555555556)) tmp = 0.0 if (Float64(angle / 180.0) <= 5e+38) tmp = Float64(Float64(a + b) * Float64(Float64(b - a) * sin(Float64(2.0 * t_0)))); else tmp = Float64(Float64(a + b) * Float64(Float64(b - a) * sin(Float64(2.0 * (exp(1) ^ log(t_0)))))); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = pi * (angle * 0.005555555555555556); tmp = 0.0; if ((angle / 180.0) <= 5e+38) tmp = (a + b) * ((b - a) * sin((2.0 * t_0))); else tmp = (a + b) * ((b - a) * sin((2.0 * (2.71828182845904523536 ^ log(t_0))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(angle / 180.0), $MachinePrecision], 5e+38], N[(N[(a + b), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[Sin[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + b), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[Sin[N[(2.0 * N[Power[E, N[Log[t$95$0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(angle \cdot 0.005555555555555556\right)\\
\mathbf{if}\;\frac{angle}{180} \leq 5 \cdot 10^{+38}:\\
\;\;\;\;\left(a + b\right) \cdot \left(\left(b - a\right) \cdot \sin \left(2 \cdot t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + b\right) \cdot \left(\left(b - a\right) \cdot \sin \left(2 \cdot {e}^{\log t_0}\right)\right)\\
\end{array}
\end{array}
if (/.f64 angle 180) < 4.9999999999999997e38Initial program 63.2%
*-commutative63.2%
associate-*l*63.2%
associate-*l*63.2%
unpow263.2%
unpow263.2%
difference-of-squares66.8%
Simplified66.8%
difference-of-squares63.2%
*-commutative63.2%
prod-diff52.2%
fma-neg52.2%
distribute-lft-in52.2%
Applied egg-rr54.9%
*-commutative54.9%
distribute-rgt-out54.9%
*-commutative54.9%
Simplified77.9%
if 4.9999999999999997e38 < (/.f64 angle 180) Initial program 25.1%
*-commutative25.1%
associate-*l*25.1%
associate-*l*25.1%
unpow225.1%
unpow225.1%
difference-of-squares26.8%
Simplified26.8%
difference-of-squares25.1%
*-commutative25.1%
prod-diff16.8%
fma-neg16.8%
distribute-lft-in16.8%
Applied egg-rr15.1%
*-commutative15.1%
distribute-rgt-out15.1%
*-commutative15.1%
Simplified25.1%
add-exp-log24.6%
*-un-lft-identity24.6%
exp-prod36.8%
Applied egg-rr36.8%
Final simplification68.2%
(FPCore (a b angle) :precision binary64 (if (<= (/ angle 180.0) -5e+92) (* (* 2.0 (sin (* (/ angle 180.0) PI))) (* (+ a b) (- b a))) (* (+ a b) (* (- b a) (sin (* 2.0 (/ PI (/ 180.0 angle))))))))
double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= -5e+92) {
tmp = (2.0 * sin(((angle / 180.0) * ((double) M_PI)))) * ((a + b) * (b - a));
} else {
tmp = (a + b) * ((b - a) * sin((2.0 * (((double) M_PI) / (180.0 / angle)))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if ((angle / 180.0) <= -5e+92) {
tmp = (2.0 * Math.sin(((angle / 180.0) * Math.PI))) * ((a + b) * (b - a));
} else {
tmp = (a + b) * ((b - a) * Math.sin((2.0 * (Math.PI / (180.0 / angle)))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if (angle / 180.0) <= -5e+92: tmp = (2.0 * math.sin(((angle / 180.0) * math.pi))) * ((a + b) * (b - a)) else: tmp = (a + b) * ((b - a) * math.sin((2.0 * (math.pi / (180.0 / angle))))) return tmp
function code(a, b, angle) tmp = 0.0 if (Float64(angle / 180.0) <= -5e+92) tmp = Float64(Float64(2.0 * sin(Float64(Float64(angle / 180.0) * pi))) * Float64(Float64(a + b) * Float64(b - a))); else tmp = Float64(Float64(a + b) * Float64(Float64(b - a) * sin(Float64(2.0 * Float64(pi / Float64(180.0 / angle)))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if ((angle / 180.0) <= -5e+92) tmp = (2.0 * sin(((angle / 180.0) * pi))) * ((a + b) * (b - a)); else tmp = (a + b) * ((b - a) * sin((2.0 * (pi / (180.0 / angle))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[N[(angle / 180.0), $MachinePrecision], -5e+92], N[(N[(2.0 * N[Sin[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(a + b), $MachinePrecision] * N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + b), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[Sin[N[(2.0 * N[(Pi / N[(180.0 / angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{angle}{180} \leq -5 \cdot 10^{+92}:\\
\;\;\;\;\left(2 \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right) \cdot \left(\left(a + b\right) \cdot \left(b - a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + b\right) \cdot \left(\left(b - a\right) \cdot \sin \left(2 \cdot \frac{\pi}{\frac{180}{angle}}\right)\right)\\
\end{array}
\end{array}
if (/.f64 angle 180) < -5.00000000000000022e92Initial program 36.4%
*-commutative36.4%
associate-*l*36.4%
associate-*l*36.4%
unpow236.4%
unpow236.4%
difference-of-squares43.2%
Simplified43.2%
Taylor expanded in angle around 0 47.7%
if -5.00000000000000022e92 < (/.f64 angle 180) Initial program 58.0%
*-commutative58.0%
associate-*l*58.0%
associate-*l*58.0%
unpow258.0%
unpow258.0%
difference-of-squares60.4%
Simplified60.4%
difference-of-squares58.0%
*-commutative58.0%
prod-diff48.3%
fma-neg48.3%
distribute-lft-in48.3%
Applied egg-rr49.8%
*-commutative49.8%
distribute-rgt-out49.7%
*-commutative49.7%
Simplified70.1%
associate-*r*68.9%
metadata-eval68.9%
div-inv68.1%
associate-/l*71.7%
Applied egg-rr71.7%
Final simplification67.6%
(FPCore (a b angle) :precision binary64 (if (<= a 3.2e-55) (* (+ a b) (* (+ a b) (sin (* PI (* angle 0.011111111111111112))))) (* (+ a b) (* 0.011111111111111112 (* (- b a) (* angle PI))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 3.2e-55) {
tmp = (a + b) * ((a + b) * sin((((double) M_PI) * (angle * 0.011111111111111112))));
} else {
tmp = (a + b) * (0.011111111111111112 * ((b - a) * (angle * ((double) M_PI))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 3.2e-55) {
tmp = (a + b) * ((a + b) * Math.sin((Math.PI * (angle * 0.011111111111111112))));
} else {
tmp = (a + b) * (0.011111111111111112 * ((b - a) * (angle * Math.PI)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 3.2e-55: tmp = (a + b) * ((a + b) * math.sin((math.pi * (angle * 0.011111111111111112)))) else: tmp = (a + b) * (0.011111111111111112 * ((b - a) * (angle * math.pi))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 3.2e-55) tmp = Float64(Float64(a + b) * Float64(Float64(a + b) * sin(Float64(pi * Float64(angle * 0.011111111111111112))))); else tmp = Float64(Float64(a + b) * Float64(0.011111111111111112 * Float64(Float64(b - a) * Float64(angle * pi)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 3.2e-55) tmp = (a + b) * ((a + b) * sin((pi * (angle * 0.011111111111111112)))); else tmp = (a + b) * (0.011111111111111112 * ((b - a) * (angle * pi))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 3.2e-55], N[(N[(a + b), $MachinePrecision] * N[(N[(a + b), $MachinePrecision] * N[Sin[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + b), $MachinePrecision] * N[(0.011111111111111112 * N[(N[(b - a), $MachinePrecision] * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.2 \cdot 10^{-55}:\\
\;\;\;\;\left(a + b\right) \cdot \left(\left(a + b\right) \cdot \sin \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + b\right) \cdot \left(0.011111111111111112 \cdot \left(\left(b - a\right) \cdot \left(angle \cdot \pi\right)\right)\right)\\
\end{array}
\end{array}
if a < 3.2000000000000001e-55Initial program 56.0%
*-commutative56.0%
associate-*l*56.0%
associate-*l*56.0%
unpow256.0%
unpow256.0%
difference-of-squares56.6%
Simplified56.6%
difference-of-squares56.0%
*-commutative56.0%
prod-diff47.5%
fma-neg47.5%
distribute-lft-in47.5%
Applied egg-rr47.6%
*-commutative47.6%
distribute-rgt-out47.6%
*-commutative47.6%
Simplified64.0%
metadata-eval64.0%
div-inv64.4%
Applied egg-rr64.4%
clear-num64.3%
un-div-inv64.9%
Applied egg-rr64.9%
associate-/r/64.6%
*-commutative64.6%
Simplified64.6%
*-commutative64.6%
sub-neg64.6%
distribute-lft-in64.6%
associate-*r*64.6%
div-inv64.6%
associate-*r*62.4%
metadata-eval62.4%
associate-*r*62.4%
div-inv62.4%
associate-*r*62.4%
metadata-eval62.4%
add-sqr-sqrt44.0%
sqrt-unprod60.0%
sqr-neg60.0%
sqrt-unprod18.7%
add-sqr-sqrt48.5%
Applied egg-rr48.5%
distribute-lft-in48.5%
*-commutative48.5%
associate-*l*48.5%
associate-*r*48.5%
metadata-eval48.5%
associate-*r*50.2%
*-commutative50.2%
+-commutative50.2%
Simplified50.2%
if 3.2000000000000001e-55 < a Initial program 50.2%
*-commutative50.2%
associate-*l*50.2%
associate-*l*50.2%
unpow250.2%
unpow250.2%
difference-of-squares59.3%
Simplified59.3%
difference-of-squares50.2%
*-commutative50.2%
prod-diff35.5%
fma-neg35.5%
distribute-lft-in35.6%
Applied egg-rr40.7%
*-commutative40.7%
distribute-rgt-out40.7%
*-commutative40.7%
Simplified69.1%
metadata-eval69.1%
div-inv69.1%
Applied egg-rr69.1%
Taylor expanded in angle around 0 63.7%
associate-*r*63.8%
Simplified63.8%
Final simplification54.3%
(FPCore (a b angle) :precision binary64 (* (+ a b) (* (- b a) (sin (* 2.0 (* angle (* PI 0.005555555555555556)))))))
double code(double a, double b, double angle) {
return (a + b) * ((b - a) * sin((2.0 * (angle * (((double) M_PI) * 0.005555555555555556)))));
}
public static double code(double a, double b, double angle) {
return (a + b) * ((b - a) * Math.sin((2.0 * (angle * (Math.PI * 0.005555555555555556)))));
}
def code(a, b, angle): return (a + b) * ((b - a) * math.sin((2.0 * (angle * (math.pi * 0.005555555555555556)))))
function code(a, b, angle) return Float64(Float64(a + b) * Float64(Float64(b - a) * sin(Float64(2.0 * Float64(angle * Float64(pi * 0.005555555555555556)))))) end
function tmp = code(a, b, angle) tmp = (a + b) * ((b - a) * sin((2.0 * (angle * (pi * 0.005555555555555556))))); end
code[a_, b_, angle_] := N[(N[(a + b), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[Sin[N[(2.0 * N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + b\right) \cdot \left(\left(b - a\right) \cdot \sin \left(2 \cdot \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)
\end{array}
Initial program 54.3%
*-commutative54.3%
associate-*l*54.3%
associate-*l*54.3%
unpow254.3%
unpow254.3%
difference-of-squares57.4%
Simplified57.4%
difference-of-squares54.3%
*-commutative54.3%
prod-diff43.9%
fma-neg43.9%
distribute-lft-in43.9%
Applied egg-rr45.6%
*-commutative45.6%
distribute-rgt-out45.5%
*-commutative45.5%
Simplified65.5%
Taylor expanded in angle around 0 63.8%
associate-*r*65.5%
*-commutative65.5%
associate-*r*65.6%
*-commutative65.6%
Simplified65.6%
Final simplification65.6%
(FPCore (a b angle) :precision binary64 (* (+ a b) (* (- b a) (sin (* 2.0 (* (/ angle 180.0) PI))))))
double code(double a, double b, double angle) {
return (a + b) * ((b - a) * sin((2.0 * ((angle / 180.0) * ((double) M_PI)))));
}
public static double code(double a, double b, double angle) {
return (a + b) * ((b - a) * Math.sin((2.0 * ((angle / 180.0) * Math.PI))));
}
def code(a, b, angle): return (a + b) * ((b - a) * math.sin((2.0 * ((angle / 180.0) * math.pi))))
function code(a, b, angle) return Float64(Float64(a + b) * Float64(Float64(b - a) * sin(Float64(2.0 * Float64(Float64(angle / 180.0) * pi))))) end
function tmp = code(a, b, angle) tmp = (a + b) * ((b - a) * sin((2.0 * ((angle / 180.0) * pi)))); end
code[a_, b_, angle_] := N[(N[(a + b), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[Sin[N[(2.0 * N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + b\right) \cdot \left(\left(b - a\right) \cdot \sin \left(2 \cdot \left(\frac{angle}{180} \cdot \pi\right)\right)\right)
\end{array}
Initial program 54.3%
*-commutative54.3%
associate-*l*54.3%
associate-*l*54.3%
unpow254.3%
unpow254.3%
difference-of-squares57.4%
Simplified57.4%
difference-of-squares54.3%
*-commutative54.3%
prod-diff43.9%
fma-neg43.9%
distribute-lft-in43.9%
Applied egg-rr45.6%
*-commutative45.6%
distribute-rgt-out45.5%
*-commutative45.5%
Simplified65.5%
metadata-eval65.5%
div-inv65.8%
Applied egg-rr65.8%
Final simplification65.8%
(FPCore (a b angle) :precision binary64 (if (<= a 1.15e-55) (* (+ a b) (* b (sin (* PI (* angle 0.011111111111111112))))) (* (+ a b) (* 0.011111111111111112 (* (- b a) (* angle PI))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.15e-55) {
tmp = (a + b) * (b * sin((((double) M_PI) * (angle * 0.011111111111111112))));
} else {
tmp = (a + b) * (0.011111111111111112 * ((b - a) * (angle * ((double) M_PI))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.15e-55) {
tmp = (a + b) * (b * Math.sin((Math.PI * (angle * 0.011111111111111112))));
} else {
tmp = (a + b) * (0.011111111111111112 * ((b - a) * (angle * Math.PI)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.15e-55: tmp = (a + b) * (b * math.sin((math.pi * (angle * 0.011111111111111112)))) else: tmp = (a + b) * (0.011111111111111112 * ((b - a) * (angle * math.pi))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.15e-55) tmp = Float64(Float64(a + b) * Float64(b * sin(Float64(pi * Float64(angle * 0.011111111111111112))))); else tmp = Float64(Float64(a + b) * Float64(0.011111111111111112 * Float64(Float64(b - a) * Float64(angle * pi)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.15e-55) tmp = (a + b) * (b * sin((pi * (angle * 0.011111111111111112)))); else tmp = (a + b) * (0.011111111111111112 * ((b - a) * (angle * pi))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.15e-55], N[(N[(a + b), $MachinePrecision] * N[(b * N[Sin[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + b), $MachinePrecision] * N[(0.011111111111111112 * N[(N[(b - a), $MachinePrecision] * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.15 \cdot 10^{-55}:\\
\;\;\;\;\left(a + b\right) \cdot \left(b \cdot \sin \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + b\right) \cdot \left(0.011111111111111112 \cdot \left(\left(b - a\right) \cdot \left(angle \cdot \pi\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.15000000000000006e-55Initial program 56.0%
*-commutative56.0%
associate-*l*56.0%
associate-*l*56.0%
unpow256.0%
unpow256.0%
difference-of-squares56.6%
Simplified56.6%
difference-of-squares56.0%
*-commutative56.0%
prod-diff47.5%
fma-neg47.5%
distribute-lft-in47.5%
Applied egg-rr47.6%
*-commutative47.6%
distribute-rgt-out47.6%
*-commutative47.6%
Simplified64.0%
metadata-eval64.0%
div-inv64.4%
Applied egg-rr64.4%
Taylor expanded in b around inf 46.6%
*-commutative46.6%
*-commutative46.6%
metadata-eval46.6%
*-commutative46.6%
associate-*r*46.6%
associate-*r*48.3%
*-commutative48.3%
*-commutative48.3%
*-commutative48.3%
*-commutative48.3%
associate-*r*46.6%
associate-*r*46.6%
metadata-eval46.6%
associate-*r*48.3%
Simplified48.3%
if 1.15000000000000006e-55 < a Initial program 50.2%
*-commutative50.2%
associate-*l*50.2%
associate-*l*50.2%
unpow250.2%
unpow250.2%
difference-of-squares59.3%
Simplified59.3%
difference-of-squares50.2%
*-commutative50.2%
prod-diff35.5%
fma-neg35.5%
distribute-lft-in35.6%
Applied egg-rr40.7%
*-commutative40.7%
distribute-rgt-out40.7%
*-commutative40.7%
Simplified69.1%
metadata-eval69.1%
div-inv69.1%
Applied egg-rr69.1%
Taylor expanded in angle around 0 63.7%
associate-*r*63.8%
Simplified63.8%
Final simplification52.9%
(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 54.3%
*-commutative54.3%
associate-*l*54.3%
associate-*l*54.3%
unpow254.3%
unpow254.3%
difference-of-squares57.4%
Simplified57.4%
difference-of-squares54.3%
*-commutative54.3%
prod-diff43.9%
fma-neg43.9%
distribute-lft-in43.9%
Applied egg-rr45.6%
*-commutative45.6%
distribute-rgt-out45.5%
*-commutative45.5%
Simplified65.5%
Taylor expanded in angle around inf 63.8%
Final simplification63.8%
(FPCore (a b angle) :precision binary64 (if (<= a 1.05e-55) (* b (* b (sin (* PI (* angle 0.011111111111111112))))) (* (+ a b) (* 0.011111111111111112 (* (- b a) (* angle PI))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.05e-55) {
tmp = b * (b * sin((((double) M_PI) * (angle * 0.011111111111111112))));
} else {
tmp = (a + b) * (0.011111111111111112 * ((b - a) * (angle * ((double) M_PI))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.05e-55) {
tmp = b * (b * Math.sin((Math.PI * (angle * 0.011111111111111112))));
} else {
tmp = (a + b) * (0.011111111111111112 * ((b - a) * (angle * Math.PI)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.05e-55: tmp = b * (b * math.sin((math.pi * (angle * 0.011111111111111112)))) else: tmp = (a + b) * (0.011111111111111112 * ((b - a) * (angle * math.pi))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.05e-55) tmp = Float64(b * Float64(b * sin(Float64(pi * Float64(angle * 0.011111111111111112))))); else tmp = Float64(Float64(a + b) * Float64(0.011111111111111112 * Float64(Float64(b - a) * Float64(angle * pi)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.05e-55) tmp = b * (b * sin((pi * (angle * 0.011111111111111112)))); else tmp = (a + b) * (0.011111111111111112 * ((b - a) * (angle * pi))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.05e-55], N[(b * N[(b * N[Sin[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + b), $MachinePrecision] * N[(0.011111111111111112 * N[(N[(b - a), $MachinePrecision] * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.05 \cdot 10^{-55}:\\
\;\;\;\;b \cdot \left(b \cdot \sin \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + b\right) \cdot \left(0.011111111111111112 \cdot \left(\left(b - a\right) \cdot \left(angle \cdot \pi\right)\right)\right)\\
\end{array}
\end{array}
if a < 1.0500000000000001e-55Initial program 56.0%
*-commutative56.0%
associate-*l*56.0%
associate-*l*56.0%
unpow256.0%
unpow256.0%
difference-of-squares56.6%
Simplified56.6%
difference-of-squares56.0%
*-commutative56.0%
prod-diff47.5%
fma-neg47.5%
distribute-lft-in47.5%
Applied egg-rr47.6%
*-commutative47.6%
distribute-rgt-out47.6%
*-commutative47.6%
Simplified64.0%
metadata-eval64.0%
div-inv64.4%
Applied egg-rr64.4%
clear-num64.3%
un-div-inv64.9%
Applied egg-rr64.9%
associate-/r/64.6%
*-commutative64.6%
Simplified64.6%
Taylor expanded in a around 0 40.1%
unpow240.1%
associate-*l*45.8%
associate-*r*47.5%
*-commutative47.5%
Simplified47.5%
if 1.0500000000000001e-55 < a Initial program 50.2%
*-commutative50.2%
associate-*l*50.2%
associate-*l*50.2%
unpow250.2%
unpow250.2%
difference-of-squares59.3%
Simplified59.3%
difference-of-squares50.2%
*-commutative50.2%
prod-diff35.5%
fma-neg35.5%
distribute-lft-in35.6%
Applied egg-rr40.7%
*-commutative40.7%
distribute-rgt-out40.7%
*-commutative40.7%
Simplified69.1%
metadata-eval69.1%
div-inv69.1%
Applied egg-rr69.1%
Taylor expanded in angle around 0 63.7%
associate-*r*63.8%
Simplified63.8%
Final simplification52.4%
(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 54.3%
*-commutative54.3%
associate-*l*54.3%
associate-*l*54.3%
unpow254.3%
unpow254.3%
difference-of-squares57.4%
Simplified57.4%
Taylor expanded in angle around 0 53.2%
Final simplification53.2%
(FPCore (a b angle) :precision binary64 (* (+ a b) (* 0.011111111111111112 (* angle (* (- b a) PI)))))
double code(double a, double b, double angle) {
return (a + b) * (0.011111111111111112 * (angle * ((b - a) * ((double) M_PI))));
}
public static double code(double a, double b, double angle) {
return (a + b) * (0.011111111111111112 * (angle * ((b - a) * Math.PI)));
}
def code(a, b, angle): return (a + b) * (0.011111111111111112 * (angle * ((b - a) * math.pi)))
function code(a, b, angle) return Float64(Float64(a + b) * Float64(0.011111111111111112 * Float64(angle * Float64(Float64(b - a) * pi)))) end
function tmp = code(a, b, angle) tmp = (a + b) * (0.011111111111111112 * (angle * ((b - a) * pi))); end
code[a_, b_, angle_] := N[(N[(a + b), $MachinePrecision] * N[(0.011111111111111112 * N[(angle * N[(N[(b - a), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + b\right) \cdot \left(0.011111111111111112 \cdot \left(angle \cdot \left(\left(b - a\right) \cdot \pi\right)\right)\right)
\end{array}
Initial program 54.3%
*-commutative54.3%
associate-*l*54.3%
associate-*l*54.3%
unpow254.3%
unpow254.3%
difference-of-squares57.4%
Simplified57.4%
difference-of-squares54.3%
*-commutative54.3%
prod-diff43.9%
fma-neg43.9%
distribute-lft-in43.9%
Applied egg-rr45.6%
*-commutative45.6%
distribute-rgt-out45.5%
*-commutative45.5%
Simplified65.5%
metadata-eval65.5%
div-inv65.8%
Applied egg-rr65.8%
Taylor expanded in angle around 0 60.1%
Final simplification60.1%
(FPCore (a b angle) :precision binary64 (* (+ a b) (* 0.011111111111111112 (* (- b a) (* angle PI)))))
double code(double a, double b, double angle) {
return (a + b) * (0.011111111111111112 * ((b - a) * (angle * ((double) M_PI))));
}
public static double code(double a, double b, double angle) {
return (a + b) * (0.011111111111111112 * ((b - a) * (angle * Math.PI)));
}
def code(a, b, angle): return (a + b) * (0.011111111111111112 * ((b - a) * (angle * math.pi)))
function code(a, b, angle) return Float64(Float64(a + b) * Float64(0.011111111111111112 * Float64(Float64(b - a) * Float64(angle * pi)))) end
function tmp = code(a, b, angle) tmp = (a + b) * (0.011111111111111112 * ((b - a) * (angle * pi))); end
code[a_, b_, angle_] := N[(N[(a + b), $MachinePrecision] * N[(0.011111111111111112 * N[(N[(b - a), $MachinePrecision] * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + b\right) \cdot \left(0.011111111111111112 \cdot \left(\left(b - a\right) \cdot \left(angle \cdot \pi\right)\right)\right)
\end{array}
Initial program 54.3%
*-commutative54.3%
associate-*l*54.3%
associate-*l*54.3%
unpow254.3%
unpow254.3%
difference-of-squares57.4%
Simplified57.4%
difference-of-squares54.3%
*-commutative54.3%
prod-diff43.9%
fma-neg43.9%
distribute-lft-in43.9%
Applied egg-rr45.6%
*-commutative45.6%
distribute-rgt-out45.5%
*-commutative45.5%
Simplified65.5%
metadata-eval65.5%
div-inv65.8%
Applied egg-rr65.8%
Taylor expanded in angle around 0 60.1%
associate-*r*60.1%
Simplified60.1%
Final simplification60.1%
(FPCore (a b angle) :precision binary64 (* (+ a b) (* (* angle PI) (* (- b a) 0.011111111111111112))))
double code(double a, double b, double angle) {
return (a + b) * ((angle * ((double) M_PI)) * ((b - a) * 0.011111111111111112));
}
public static double code(double a, double b, double angle) {
return (a + b) * ((angle * Math.PI) * ((b - a) * 0.011111111111111112));
}
def code(a, b, angle): return (a + b) * ((angle * math.pi) * ((b - a) * 0.011111111111111112))
function code(a, b, angle) return Float64(Float64(a + b) * Float64(Float64(angle * pi) * Float64(Float64(b - a) * 0.011111111111111112))) end
function tmp = code(a, b, angle) tmp = (a + b) * ((angle * pi) * ((b - a) * 0.011111111111111112)); end
code[a_, b_, angle_] := N[(N[(a + b), $MachinePrecision] * N[(N[(angle * Pi), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + b\right) \cdot \left(\left(angle \cdot \pi\right) \cdot \left(\left(b - a\right) \cdot 0.011111111111111112\right)\right)
\end{array}
Initial program 54.3%
*-commutative54.3%
associate-*l*54.3%
associate-*l*54.3%
unpow254.3%
unpow254.3%
difference-of-squares57.4%
Simplified57.4%
difference-of-squares54.3%
*-commutative54.3%
prod-diff43.9%
fma-neg43.9%
distribute-lft-in43.9%
Applied egg-rr45.6%
*-commutative45.6%
distribute-rgt-out45.5%
*-commutative45.5%
Simplified65.5%
metadata-eval65.5%
div-inv65.8%
Applied egg-rr65.8%
Taylor expanded in angle around 0 60.1%
*-commutative60.1%
associate-*r*60.1%
associate-*l*60.2%
Simplified60.2%
Final simplification60.2%
(FPCore (a b angle) :precision binary64 (* (+ a b) (* (- b a) (* PI (* angle 0.011111111111111112)))))
double code(double a, double b, double angle) {
return (a + b) * ((b - a) * (((double) M_PI) * (angle * 0.011111111111111112)));
}
public static double code(double a, double b, double angle) {
return (a + b) * ((b - a) * (Math.PI * (angle * 0.011111111111111112)));
}
def code(a, b, angle): return (a + b) * ((b - a) * (math.pi * (angle * 0.011111111111111112)))
function code(a, b, angle) return Float64(Float64(a + b) * Float64(Float64(b - a) * Float64(pi * Float64(angle * 0.011111111111111112)))) end
function tmp = code(a, b, angle) tmp = (a + b) * ((b - a) * (pi * (angle * 0.011111111111111112))); end
code[a_, b_, angle_] := N[(N[(a + b), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + b\right) \cdot \left(\left(b - a\right) \cdot \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)\right)
\end{array}
Initial program 54.3%
*-commutative54.3%
associate-*l*54.3%
associate-*l*54.3%
unpow254.3%
unpow254.3%
difference-of-squares57.4%
Simplified57.4%
difference-of-squares54.3%
*-commutative54.3%
prod-diff43.9%
fma-neg43.9%
distribute-lft-in43.9%
Applied egg-rr45.6%
*-commutative45.6%
distribute-rgt-out45.5%
*-commutative45.5%
Simplified65.5%
metadata-eval65.5%
div-inv65.8%
Applied egg-rr65.8%
Taylor expanded in angle around 0 60.2%
associate-*r*60.2%
Simplified60.2%
Final simplification60.2%
(FPCore (a b angle) :precision binary64 (if (<= b 1.3e+25) (* (* angle PI) (* -0.011111111111111112 (* a a))) (* angle (* (* b PI) (* b 0.011111111111111112)))))
double code(double a, double b, double angle) {
double tmp;
if (b <= 1.3e+25) {
tmp = (angle * ((double) M_PI)) * (-0.011111111111111112 * (a * a));
} else {
tmp = angle * ((b * ((double) M_PI)) * (b * 0.011111111111111112));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (b <= 1.3e+25) {
tmp = (angle * Math.PI) * (-0.011111111111111112 * (a * a));
} else {
tmp = angle * ((b * Math.PI) * (b * 0.011111111111111112));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if b <= 1.3e+25: tmp = (angle * math.pi) * (-0.011111111111111112 * (a * a)) else: tmp = angle * ((b * math.pi) * (b * 0.011111111111111112)) return tmp
function code(a, b, angle) tmp = 0.0 if (b <= 1.3e+25) tmp = Float64(Float64(angle * pi) * Float64(-0.011111111111111112 * Float64(a * a))); else tmp = Float64(angle * Float64(Float64(b * pi) * Float64(b * 0.011111111111111112))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (b <= 1.3e+25) tmp = (angle * pi) * (-0.011111111111111112 * (a * a)); else tmp = angle * ((b * pi) * (b * 0.011111111111111112)); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[b, 1.3e+25], N[(N[(angle * Pi), $MachinePrecision] * N[(-0.011111111111111112 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(angle * N[(N[(b * Pi), $MachinePrecision] * N[(b * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.3 \cdot 10^{+25}:\\
\;\;\;\;\left(angle \cdot \pi\right) \cdot \left(-0.011111111111111112 \cdot \left(a \cdot a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;angle \cdot \left(\left(b \cdot \pi\right) \cdot \left(b \cdot 0.011111111111111112\right)\right)\\
\end{array}
\end{array}
if b < 1.2999999999999999e25Initial program 54.8%
*-commutative54.8%
associate-*l*54.8%
associate-*l*54.8%
unpow254.8%
unpow254.8%
difference-of-squares57.4%
Simplified57.4%
Taylor expanded in angle around 0 54.0%
Taylor expanded in a around inf 42.1%
associate-*r*42.1%
unpow242.1%
Simplified42.1%
if 1.2999999999999999e25 < b Initial program 52.4%
*-commutative52.4%
associate-*l*52.4%
associate-*l*52.4%
unpow252.4%
unpow252.4%
difference-of-squares57.4%
Simplified57.4%
Taylor expanded in angle around 0 50.8%
Taylor expanded in a around 0 42.4%
*-commutative42.4%
unpow242.4%
Simplified42.4%
Taylor expanded in angle around 0 42.4%
*-commutative42.4%
*-commutative42.4%
unpow242.4%
associate-*l*42.4%
unpow242.4%
associate-*l*42.3%
unpow242.3%
Simplified42.3%
Taylor expanded in b around 0 42.4%
*-commutative42.4%
unpow242.4%
*-commutative42.4%
associate-*r*42.3%
associate-*r*42.3%
*-commutative42.3%
Simplified42.3%
Final simplification42.2%
(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 54.3%
*-commutative54.3%
associate-*l*54.3%
associate-*l*54.3%
unpow254.3%
unpow254.3%
difference-of-squares57.4%
Simplified57.4%
Taylor expanded in angle around 0 53.2%
Taylor expanded in a around 0 34.7%
*-commutative34.7%
unpow234.7%
Simplified34.7%
Final simplification34.7%
herbie shell --seed 2023287
(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)))))