
(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 10 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
(*
(*
(- b a)
(*
(* 2.0 (sin (* 0.005555555555555556 (* PI angle))))
(cos (* PI (* 0.005555555555555556 angle)))))
(+ b a)))
double code(double a, double b, double angle) {
return ((b - a) * ((2.0 * sin((0.005555555555555556 * (((double) M_PI) * angle)))) * cos((((double) M_PI) * (0.005555555555555556 * angle))))) * (b + a);
}
public static double code(double a, double b, double angle) {
return ((b - a) * ((2.0 * Math.sin((0.005555555555555556 * (Math.PI * angle)))) * Math.cos((Math.PI * (0.005555555555555556 * angle))))) * (b + a);
}
def code(a, b, angle): return ((b - a) * ((2.0 * math.sin((0.005555555555555556 * (math.pi * angle)))) * math.cos((math.pi * (0.005555555555555556 * angle))))) * (b + a)
function code(a, b, angle) return Float64(Float64(Float64(b - a) * Float64(Float64(2.0 * sin(Float64(0.005555555555555556 * Float64(pi * angle)))) * cos(Float64(pi * Float64(0.005555555555555556 * angle))))) * Float64(b + a)) end
function tmp = code(a, b, angle) tmp = ((b - a) * ((2.0 * sin((0.005555555555555556 * (pi * angle)))) * cos((pi * (0.005555555555555556 * angle))))) * (b + a); end
code[a_, b_, angle_] := N[(N[(N[(b - a), $MachinePrecision] * N[(N[(2.0 * N[Sin[N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(Pi * N[(0.005555555555555556 * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(b - a\right) \cdot \left(\left(2 \cdot \sin \left(0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right)\right) \cdot \cos \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)\right) \cdot \left(b + a\right)
\end{array}
Initial program 58.7%
associate-*l*58.7%
*-commutative58.7%
associate-*l*58.7%
Simplified58.7%
unpow258.7%
unpow258.7%
difference-of-squares63.5%
Applied egg-rr63.5%
associate-*r/62.7%
clear-num63.6%
Applied egg-rr63.6%
pow163.6%
associate-*l*74.5%
associate-*r*74.5%
associate-/r/74.9%
metadata-eval74.9%
div-inv76.5%
metadata-eval76.5%
Applied egg-rr76.5%
Final simplification76.5%
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* 0.011111111111111112 (* PI angle))))
(if (<= (pow b 2.0) 2e-158)
(* (- b a) (* a (sin t_0)))
(* (- b a) (* (+ b a) t_0)))))
double code(double a, double b, double angle) {
double t_0 = 0.011111111111111112 * (((double) M_PI) * angle);
double tmp;
if (pow(b, 2.0) <= 2e-158) {
tmp = (b - a) * (a * sin(t_0));
} else {
tmp = (b - a) * ((b + a) * t_0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double t_0 = 0.011111111111111112 * (Math.PI * angle);
double tmp;
if (Math.pow(b, 2.0) <= 2e-158) {
tmp = (b - a) * (a * Math.sin(t_0));
} else {
tmp = (b - a) * ((b + a) * t_0);
}
return tmp;
}
def code(a, b, angle): t_0 = 0.011111111111111112 * (math.pi * angle) tmp = 0 if math.pow(b, 2.0) <= 2e-158: tmp = (b - a) * (a * math.sin(t_0)) else: tmp = (b - a) * ((b + a) * t_0) return tmp
function code(a, b, angle) t_0 = Float64(0.011111111111111112 * Float64(pi * angle)) tmp = 0.0 if ((b ^ 2.0) <= 2e-158) tmp = Float64(Float64(b - a) * Float64(a * sin(t_0))); else tmp = Float64(Float64(b - a) * Float64(Float64(b + a) * t_0)); end return tmp end
function tmp_2 = code(a, b, angle) t_0 = 0.011111111111111112 * (pi * angle); tmp = 0.0; if ((b ^ 2.0) <= 2e-158) tmp = (b - a) * (a * sin(t_0)); else tmp = (b - a) * ((b + a) * t_0); end tmp_2 = tmp; end
code[a_, b_, angle_] := Block[{t$95$0 = N[(0.011111111111111112 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[b, 2.0], $MachinePrecision], 2e-158], N[(N[(b - a), $MachinePrecision] * N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - a), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.011111111111111112 \cdot \left(\pi \cdot angle\right)\\
\mathbf{if}\;{b}^{2} \leq 2 \cdot 10^{-158}:\\
\;\;\;\;\left(b - a\right) \cdot \left(a \cdot \sin t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b - a\right) \cdot \left(\left(b + a\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if (pow.f64 b #s(literal 2 binary64)) < 2.00000000000000013e-158Initial program 63.9%
associate-*l*63.9%
*-commutative63.9%
associate-*l*63.9%
Simplified63.9%
add-cbrt-cube48.4%
pow348.4%
2-sin48.4%
associate-*r*48.4%
div-inv48.4%
metadata-eval48.4%
Applied egg-rr48.4%
rem-cbrt-cube64.0%
unpow264.0%
unpow264.0%
difference-of-squares64.0%
*-commutative64.0%
associate-*l*70.1%
associate-*l*70.1%
metadata-eval70.1%
div-inv70.0%
count-270.0%
div-inv70.1%
metadata-eval70.1%
associate-*r*70.1%
div-inv69.9%
metadata-eval69.9%
associate-*r*70.9%
Applied egg-rr70.9%
Taylor expanded in b around 0 70.6%
if 2.00000000000000013e-158 < (pow.f64 b #s(literal 2 binary64)) Initial program 55.0%
associate-*l*55.0%
*-commutative55.0%
associate-*l*55.0%
Simplified55.0%
add-cbrt-cube42.5%
pow342.6%
2-sin42.6%
associate-*r*42.6%
div-inv43.8%
metadata-eval43.8%
Applied egg-rr43.8%
rem-cbrt-cube56.2%
unpow256.2%
unpow256.2%
difference-of-squares64.3%
*-commutative64.3%
associate-*l*79.2%
associate-*l*79.2%
metadata-eval79.2%
div-inv78.0%
count-278.0%
div-inv79.9%
metadata-eval79.9%
associate-*r*79.3%
div-inv79.2%
metadata-eval79.2%
associate-*r*80.0%
Applied egg-rr80.0%
Taylor expanded in angle around 0 71.6%
Final simplification71.2%
(FPCore (a b angle) :precision binary64 (if (<= (pow b 2.0) 2e-215) (* (- b a) (* a (sin (* PI (* angle 0.011111111111111112))))) (* (- b a) (* (+ b a) (* 0.011111111111111112 (* PI angle))))))
double code(double a, double b, double angle) {
double tmp;
if (pow(b, 2.0) <= 2e-215) {
tmp = (b - a) * (a * sin((((double) M_PI) * (angle * 0.011111111111111112))));
} else {
tmp = (b - a) * ((b + a) * (0.011111111111111112 * (((double) M_PI) * angle)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (Math.pow(b, 2.0) <= 2e-215) {
tmp = (b - a) * (a * Math.sin((Math.PI * (angle * 0.011111111111111112))));
} else {
tmp = (b - a) * ((b + a) * (0.011111111111111112 * (Math.PI * angle)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if math.pow(b, 2.0) <= 2e-215: tmp = (b - a) * (a * math.sin((math.pi * (angle * 0.011111111111111112)))) else: tmp = (b - a) * ((b + a) * (0.011111111111111112 * (math.pi * angle))) return tmp
function code(a, b, angle) tmp = 0.0 if ((b ^ 2.0) <= 2e-215) tmp = Float64(Float64(b - a) * Float64(a * sin(Float64(pi * Float64(angle * 0.011111111111111112))))); else tmp = Float64(Float64(b - a) * Float64(Float64(b + a) * Float64(0.011111111111111112 * Float64(pi * angle)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if ((b ^ 2.0) <= 2e-215) tmp = (b - a) * (a * sin((pi * (angle * 0.011111111111111112)))); else tmp = (b - a) * ((b + a) * (0.011111111111111112 * (pi * angle))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[N[Power[b, 2.0], $MachinePrecision], 2e-215], N[(N[(b - a), $MachinePrecision] * N[(a * N[Sin[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - a), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[(0.011111111111111112 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{b}^{2} \leq 2 \cdot 10^{-215}:\\
\;\;\;\;\left(b - a\right) \cdot \left(a \cdot \sin \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b - a\right) \cdot \left(\left(b + a\right) \cdot \left(0.011111111111111112 \cdot \left(\pi \cdot angle\right)\right)\right)\\
\end{array}
\end{array}
if (pow.f64 b #s(literal 2 binary64)) < 2.00000000000000008e-215Initial program 65.5%
associate-*l*65.5%
*-commutative65.5%
associate-*l*65.5%
Simplified65.5%
add-cbrt-cube49.2%
pow349.2%
2-sin49.2%
associate-*r*49.2%
div-inv49.2%
metadata-eval49.2%
Applied egg-rr49.2%
rem-cbrt-cube65.6%
unpow265.6%
unpow265.6%
difference-of-squares65.6%
*-commutative65.6%
associate-*l*72.0%
associate-*l*72.0%
metadata-eval72.0%
div-inv72.0%
count-272.0%
div-inv72.0%
metadata-eval72.0%
associate-*r*72.0%
div-inv71.8%
metadata-eval71.8%
associate-*r*71.9%
Applied egg-rr71.9%
Taylor expanded in b around 0 71.7%
associate-*r*71.9%
*-commutative71.9%
Simplified71.9%
if 2.00000000000000008e-215 < (pow.f64 b #s(literal 2 binary64)) Initial program 54.3%
associate-*l*54.3%
*-commutative54.3%
associate-*l*54.3%
Simplified54.3%
add-cbrt-cube42.2%
pow342.3%
2-sin42.3%
associate-*r*42.3%
div-inv43.4%
metadata-eval43.4%
Applied egg-rr43.4%
rem-cbrt-cube55.5%
unpow255.5%
unpow255.5%
difference-of-squares63.3%
*-commutative63.3%
associate-*l*77.6%
associate-*l*77.6%
metadata-eval77.6%
div-inv76.4%
count-276.4%
div-inv78.3%
metadata-eval78.3%
associate-*r*77.7%
div-inv77.6%
metadata-eval77.6%
associate-*r*79.0%
Applied egg-rr79.0%
Taylor expanded in angle around 0 70.8%
Final simplification71.2%
(FPCore (a b angle) :precision binary64 (if (<= (pow a 2.0) 2e-287) (* (- b a) (* b (sin (* 0.011111111111111112 (* PI angle))))) (* (- b a) (* 0.011111111111111112 (* angle (* PI (+ b a)))))))
double code(double a, double b, double angle) {
double tmp;
if (pow(a, 2.0) <= 2e-287) {
tmp = (b - a) * (b * sin((0.011111111111111112 * (((double) M_PI) * angle))));
} else {
tmp = (b - a) * (0.011111111111111112 * (angle * (((double) M_PI) * (b + a))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (Math.pow(a, 2.0) <= 2e-287) {
tmp = (b - a) * (b * Math.sin((0.011111111111111112 * (Math.PI * angle))));
} else {
tmp = (b - a) * (0.011111111111111112 * (angle * (Math.PI * (b + a))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if math.pow(a, 2.0) <= 2e-287: tmp = (b - a) * (b * math.sin((0.011111111111111112 * (math.pi * angle)))) else: tmp = (b - a) * (0.011111111111111112 * (angle * (math.pi * (b + a)))) return tmp
function code(a, b, angle) tmp = 0.0 if ((a ^ 2.0) <= 2e-287) tmp = Float64(Float64(b - a) * Float64(b * sin(Float64(0.011111111111111112 * Float64(pi * angle))))); else tmp = Float64(Float64(b - a) * Float64(0.011111111111111112 * Float64(angle * Float64(pi * Float64(b + a))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if ((a ^ 2.0) <= 2e-287) tmp = (b - a) * (b * sin((0.011111111111111112 * (pi * angle)))); else tmp = (b - a) * (0.011111111111111112 * (angle * (pi * (b + a)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[N[Power[a, 2.0], $MachinePrecision], 2e-287], N[(N[(b - a), $MachinePrecision] * N[(b * N[Sin[N[(0.011111111111111112 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - a), $MachinePrecision] * N[(0.011111111111111112 * N[(angle * N[(Pi * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{a}^{2} \leq 2 \cdot 10^{-287}:\\
\;\;\;\;\left(b - a\right) \cdot \left(b \cdot \sin \left(0.011111111111111112 \cdot \left(\pi \cdot angle\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b - a\right) \cdot \left(0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(b + a\right)\right)\right)\right)\\
\end{array}
\end{array}
if (pow.f64 a #s(literal 2 binary64)) < 2.00000000000000004e-287Initial program 71.3%
associate-*l*71.3%
*-commutative71.3%
associate-*l*71.3%
Simplified71.3%
add-cbrt-cube61.5%
pow361.5%
2-sin61.5%
associate-*r*61.5%
div-inv61.3%
metadata-eval61.3%
Applied egg-rr61.3%
rem-cbrt-cube71.0%
unpow271.0%
unpow271.0%
difference-of-squares71.0%
*-commutative71.0%
associate-*l*76.8%
associate-*l*76.8%
metadata-eval76.8%
div-inv77.0%
count-277.0%
div-inv76.8%
metadata-eval76.8%
associate-*r*76.8%
div-inv76.5%
metadata-eval76.5%
associate-*r*76.7%
Applied egg-rr76.7%
Taylor expanded in b around inf 76.2%
if 2.00000000000000004e-287 < (pow.f64 a #s(literal 2 binary64)) Initial program 54.5%
associate-*l*54.5%
*-commutative54.5%
associate-*l*54.5%
Simplified54.5%
add-cbrt-cube39.4%
pow339.4%
2-sin39.4%
associate-*r*39.4%
div-inv40.5%
metadata-eval40.5%
Applied egg-rr40.5%
rem-cbrt-cube55.5%
unpow255.5%
unpow255.5%
difference-of-squares61.9%
*-commutative61.9%
associate-*l*75.0%
associate-*l*75.0%
metadata-eval75.0%
div-inv73.9%
count-273.9%
div-inv75.5%
metadata-eval75.5%
associate-*r*75.1%
div-inv75.0%
metadata-eval75.0%
associate-*r*76.0%
Applied egg-rr76.0%
Taylor expanded in angle around 0 71.9%
Final simplification73.0%
(FPCore (a b angle) :precision binary64 (if (<= (pow a 2.0) 2e-287) (* (- b a) (* b (sin (* PI (* angle 0.011111111111111112))))) (* (- b a) (* 0.011111111111111112 (* angle (* PI (+ b a)))))))
double code(double a, double b, double angle) {
double tmp;
if (pow(a, 2.0) <= 2e-287) {
tmp = (b - a) * (b * sin((((double) M_PI) * (angle * 0.011111111111111112))));
} else {
tmp = (b - a) * (0.011111111111111112 * (angle * (((double) M_PI) * (b + a))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (Math.pow(a, 2.0) <= 2e-287) {
tmp = (b - a) * (b * Math.sin((Math.PI * (angle * 0.011111111111111112))));
} else {
tmp = (b - a) * (0.011111111111111112 * (angle * (Math.PI * (b + a))));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if math.pow(a, 2.0) <= 2e-287: tmp = (b - a) * (b * math.sin((math.pi * (angle * 0.011111111111111112)))) else: tmp = (b - a) * (0.011111111111111112 * (angle * (math.pi * (b + a)))) return tmp
function code(a, b, angle) tmp = 0.0 if ((a ^ 2.0) <= 2e-287) tmp = Float64(Float64(b - a) * Float64(b * sin(Float64(pi * Float64(angle * 0.011111111111111112))))); else tmp = Float64(Float64(b - a) * Float64(0.011111111111111112 * Float64(angle * Float64(pi * Float64(b + a))))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if ((a ^ 2.0) <= 2e-287) tmp = (b - a) * (b * sin((pi * (angle * 0.011111111111111112)))); else tmp = (b - a) * (0.011111111111111112 * (angle * (pi * (b + a)))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[N[Power[a, 2.0], $MachinePrecision], 2e-287], N[(N[(b - a), $MachinePrecision] * N[(b * N[Sin[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - a), $MachinePrecision] * N[(0.011111111111111112 * N[(angle * N[(Pi * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{a}^{2} \leq 2 \cdot 10^{-287}:\\
\;\;\;\;\left(b - a\right) \cdot \left(b \cdot \sin \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b - a\right) \cdot \left(0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(b + a\right)\right)\right)\right)\\
\end{array}
\end{array}
if (pow.f64 a #s(literal 2 binary64)) < 2.00000000000000004e-287Initial program 71.3%
associate-*l*71.3%
*-commutative71.3%
associate-*l*71.3%
Simplified71.3%
add-cbrt-cube61.5%
pow361.5%
2-sin61.5%
associate-*r*61.5%
div-inv61.3%
metadata-eval61.3%
Applied egg-rr61.3%
rem-cbrt-cube71.0%
unpow271.0%
unpow271.0%
difference-of-squares71.0%
*-commutative71.0%
associate-*l*76.8%
associate-*l*76.8%
metadata-eval76.8%
div-inv77.0%
count-277.0%
div-inv76.8%
metadata-eval76.8%
associate-*r*76.8%
div-inv76.5%
metadata-eval76.5%
associate-*r*76.7%
Applied egg-rr76.7%
Taylor expanded in b around inf 76.2%
associate-*r*76.3%
*-commutative76.3%
Simplified76.3%
if 2.00000000000000004e-287 < (pow.f64 a #s(literal 2 binary64)) Initial program 54.5%
associate-*l*54.5%
*-commutative54.5%
associate-*l*54.5%
Simplified54.5%
add-cbrt-cube39.4%
pow339.4%
2-sin39.4%
associate-*r*39.4%
div-inv40.5%
metadata-eval40.5%
Applied egg-rr40.5%
rem-cbrt-cube55.5%
unpow255.5%
unpow255.5%
difference-of-squares61.9%
*-commutative61.9%
associate-*l*75.0%
associate-*l*75.0%
metadata-eval75.0%
div-inv73.9%
count-273.9%
div-inv75.5%
metadata-eval75.5%
associate-*r*75.1%
div-inv75.0%
metadata-eval75.0%
associate-*r*76.0%
Applied egg-rr76.0%
Taylor expanded in angle around 0 71.9%
Final simplification73.0%
(FPCore (a b angle) :precision binary64 (* (- b a) (* (+ b a) (sin (* 0.011111111111111112 (* PI angle))))))
double code(double a, double b, double angle) {
return (b - a) * ((b + a) * sin((0.011111111111111112 * (((double) M_PI) * angle))));
}
public static double code(double a, double b, double angle) {
return (b - a) * ((b + a) * Math.sin((0.011111111111111112 * (Math.PI * angle))));
}
def code(a, b, angle): return (b - a) * ((b + a) * math.sin((0.011111111111111112 * (math.pi * angle))))
function code(a, b, angle) return Float64(Float64(b - a) * Float64(Float64(b + a) * sin(Float64(0.011111111111111112 * Float64(pi * angle))))) end
function tmp = code(a, b, angle) tmp = (b - a) * ((b + a) * sin((0.011111111111111112 * (pi * angle)))); end
code[a_, b_, angle_] := N[(N[(b - a), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[Sin[N[(0.011111111111111112 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(b - a\right) \cdot \left(\left(b + a\right) \cdot \sin \left(0.011111111111111112 \cdot \left(\pi \cdot angle\right)\right)\right)
\end{array}
Initial program 58.7%
associate-*l*58.7%
*-commutative58.7%
associate-*l*58.7%
Simplified58.7%
add-cbrt-cube45.0%
pow345.0%
2-sin45.0%
associate-*r*45.0%
div-inv45.7%
metadata-eval45.7%
Applied egg-rr45.7%
rem-cbrt-cube59.4%
unpow259.4%
unpow259.4%
difference-of-squares64.2%
*-commutative64.2%
associate-*l*75.4%
associate-*l*75.4%
metadata-eval75.4%
div-inv74.7%
count-274.7%
div-inv75.8%
metadata-eval75.8%
associate-*r*75.5%
div-inv75.4%
metadata-eval75.4%
associate-*r*76.2%
Applied egg-rr76.2%
Final simplification76.2%
(FPCore (a b angle) :precision binary64 (if (<= angle 1.75e-44) (* (+ b a) (* (* angle 0.011111111111111112) (* (- b a) PI))) (* 0.011111111111111112 (* (* PI angle) (* (- b a) (+ b a))))))
double code(double a, double b, double angle) {
double tmp;
if (angle <= 1.75e-44) {
tmp = (b + a) * ((angle * 0.011111111111111112) * ((b - a) * ((double) M_PI)));
} else {
tmp = 0.011111111111111112 * ((((double) M_PI) * angle) * ((b - a) * (b + a)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (angle <= 1.75e-44) {
tmp = (b + a) * ((angle * 0.011111111111111112) * ((b - a) * Math.PI));
} else {
tmp = 0.011111111111111112 * ((Math.PI * angle) * ((b - a) * (b + a)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if angle <= 1.75e-44: tmp = (b + a) * ((angle * 0.011111111111111112) * ((b - a) * math.pi)) else: tmp = 0.011111111111111112 * ((math.pi * angle) * ((b - a) * (b + a))) return tmp
function code(a, b, angle) tmp = 0.0 if (angle <= 1.75e-44) tmp = Float64(Float64(b + a) * Float64(Float64(angle * 0.011111111111111112) * Float64(Float64(b - a) * pi))); else tmp = Float64(0.011111111111111112 * Float64(Float64(pi * angle) * Float64(Float64(b - a) * Float64(b + a)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (angle <= 1.75e-44) tmp = (b + a) * ((angle * 0.011111111111111112) * ((b - a) * pi)); else tmp = 0.011111111111111112 * ((pi * angle) * ((b - a) * (b + a))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[angle, 1.75e-44], N[(N[(b + a), $MachinePrecision] * N[(N[(angle * 0.011111111111111112), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.011111111111111112 * N[(N[(Pi * angle), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 1.75 \cdot 10^{-44}:\\
\;\;\;\;\left(b + a\right) \cdot \left(\left(angle \cdot 0.011111111111111112\right) \cdot \left(\left(b - a\right) \cdot \pi\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.011111111111111112 \cdot \left(\left(\pi \cdot angle\right) \cdot \left(\left(b - a\right) \cdot \left(b + a\right)\right)\right)\\
\end{array}
\end{array}
if angle < 1.7499999999999999e-44Initial program 66.0%
associate-*l*66.0%
*-commutative66.0%
associate-*l*66.0%
Simplified66.0%
unpow266.0%
unpow266.0%
difference-of-squares70.3%
Applied egg-rr70.3%
Taylor expanded in angle around 0 65.8%
+-commutative65.8%
*-commutative65.8%
+-commutative65.8%
Simplified65.8%
add-cbrt-cube49.3%
pow1/332.0%
pow332.0%
associate-*r*32.0%
associate-*r*32.0%
+-commutative32.0%
Applied egg-rr32.0%
unpow1/349.3%
rem-cbrt-cube65.8%
associate-*r*78.6%
*-commutative78.6%
+-commutative78.6%
Applied egg-rr78.6%
if 1.7499999999999999e-44 < angle Initial program 35.7%
associate-*l*35.7%
*-commutative35.7%
associate-*l*35.7%
Simplified35.7%
unpow235.7%
unpow235.7%
difference-of-squares42.2%
Applied egg-rr42.2%
Taylor expanded in angle around 0 37.3%
+-commutative37.3%
*-commutative37.3%
+-commutative37.3%
Simplified37.3%
Taylor expanded in angle around 0 37.3%
associate-*r*37.3%
Simplified37.3%
Final simplification68.6%
(FPCore (a b angle) :precision binary64 (if (<= angle 1.5e-44) (* (- b a) (* 0.011111111111111112 (* angle (* PI (+ b a))))) (* 0.011111111111111112 (* (* PI angle) (* (- b a) (+ b a))))))
double code(double a, double b, double angle) {
double tmp;
if (angle <= 1.5e-44) {
tmp = (b - a) * (0.011111111111111112 * (angle * (((double) M_PI) * (b + a))));
} else {
tmp = 0.011111111111111112 * ((((double) M_PI) * angle) * ((b - a) * (b + a)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (angle <= 1.5e-44) {
tmp = (b - a) * (0.011111111111111112 * (angle * (Math.PI * (b + a))));
} else {
tmp = 0.011111111111111112 * ((Math.PI * angle) * ((b - a) * (b + a)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if angle <= 1.5e-44: tmp = (b - a) * (0.011111111111111112 * (angle * (math.pi * (b + a)))) else: tmp = 0.011111111111111112 * ((math.pi * angle) * ((b - a) * (b + a))) return tmp
function code(a, b, angle) tmp = 0.0 if (angle <= 1.5e-44) tmp = Float64(Float64(b - a) * Float64(0.011111111111111112 * Float64(angle * Float64(pi * Float64(b + a))))); else tmp = Float64(0.011111111111111112 * Float64(Float64(pi * angle) * Float64(Float64(b - a) * Float64(b + a)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (angle <= 1.5e-44) tmp = (b - a) * (0.011111111111111112 * (angle * (pi * (b + a)))); else tmp = 0.011111111111111112 * ((pi * angle) * ((b - a) * (b + a))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[angle, 1.5e-44], N[(N[(b - a), $MachinePrecision] * N[(0.011111111111111112 * N[(angle * N[(Pi * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.011111111111111112 * N[(N[(Pi * angle), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;angle \leq 1.5 \cdot 10^{-44}:\\
\;\;\;\;\left(b - a\right) \cdot \left(0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(b + a\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.011111111111111112 \cdot \left(\left(\pi \cdot angle\right) \cdot \left(\left(b - a\right) \cdot \left(b + a\right)\right)\right)\\
\end{array}
\end{array}
if angle < 1.5000000000000001e-44Initial program 66.0%
associate-*l*66.0%
*-commutative66.0%
associate-*l*66.0%
Simplified66.0%
add-cbrt-cube48.5%
pow348.5%
2-sin48.5%
associate-*r*48.5%
div-inv49.0%
metadata-eval49.0%
Applied egg-rr49.0%
rem-cbrt-cube66.4%
unpow266.4%
unpow266.4%
difference-of-squares70.7%
*-commutative70.7%
associate-*l*85.5%
associate-*l*85.5%
metadata-eval85.5%
div-inv85.1%
count-285.1%
div-inv85.6%
metadata-eval85.6%
associate-*r*85.6%
div-inv85.5%
metadata-eval85.5%
associate-*r*87.2%
Applied egg-rr87.2%
Taylor expanded in angle around 0 78.6%
if 1.5000000000000001e-44 < angle Initial program 35.7%
associate-*l*35.7%
*-commutative35.7%
associate-*l*35.7%
Simplified35.7%
unpow235.7%
unpow235.7%
difference-of-squares42.2%
Applied egg-rr42.2%
Taylor expanded in angle around 0 37.3%
+-commutative37.3%
*-commutative37.3%
+-commutative37.3%
Simplified37.3%
Taylor expanded in angle around 0 37.3%
associate-*r*37.3%
Simplified37.3%
Final simplification68.6%
(FPCore (a b angle) :precision binary64 (* 0.011111111111111112 (* angle (* PI (* (- b a) (+ b a))))))
double code(double a, double b, double angle) {
return 0.011111111111111112 * (angle * (((double) M_PI) * ((b - a) * (b + a))));
}
public static double code(double a, double b, double angle) {
return 0.011111111111111112 * (angle * (Math.PI * ((b - a) * (b + a))));
}
def code(a, b, angle): return 0.011111111111111112 * (angle * (math.pi * ((b - a) * (b + a))))
function code(a, b, angle) return Float64(0.011111111111111112 * Float64(angle * Float64(pi * Float64(Float64(b - a) * Float64(b + a))))) end
function tmp = code(a, b, angle) tmp = 0.011111111111111112 * (angle * (pi * ((b - a) * (b + a)))); end
code[a_, b_, angle_] := N[(0.011111111111111112 * N[(angle * N[(Pi * N[(N[(b - a), $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.011111111111111112 \cdot \left(angle \cdot \left(\pi \cdot \left(\left(b - a\right) \cdot \left(b + a\right)\right)\right)\right)
\end{array}
Initial program 58.7%
associate-*l*58.7%
*-commutative58.7%
associate-*l*58.7%
Simplified58.7%
unpow258.7%
unpow258.7%
difference-of-squares63.5%
Applied egg-rr63.5%
Taylor expanded in angle around 0 58.9%
+-commutative58.9%
*-commutative58.9%
+-commutative58.9%
Simplified58.9%
Final simplification58.9%
(FPCore (a b angle) :precision binary64 (* 0.011111111111111112 (* (* PI angle) (* (- b a) (+ b a)))))
double code(double a, double b, double angle) {
return 0.011111111111111112 * ((((double) M_PI) * angle) * ((b - a) * (b + a)));
}
public static double code(double a, double b, double angle) {
return 0.011111111111111112 * ((Math.PI * angle) * ((b - a) * (b + a)));
}
def code(a, b, angle): return 0.011111111111111112 * ((math.pi * angle) * ((b - a) * (b + a)))
function code(a, b, angle) return Float64(0.011111111111111112 * Float64(Float64(pi * angle) * Float64(Float64(b - a) * Float64(b + a)))) end
function tmp = code(a, b, angle) tmp = 0.011111111111111112 * ((pi * angle) * ((b - a) * (b + a))); end
code[a_, b_, angle_] := N[(0.011111111111111112 * N[(N[(Pi * angle), $MachinePrecision] * N[(N[(b - a), $MachinePrecision] * N[(b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.011111111111111112 \cdot \left(\left(\pi \cdot angle\right) \cdot \left(\left(b - a\right) \cdot \left(b + a\right)\right)\right)
\end{array}
Initial program 58.7%
associate-*l*58.7%
*-commutative58.7%
associate-*l*58.7%
Simplified58.7%
unpow258.7%
unpow258.7%
difference-of-squares63.5%
Applied egg-rr63.5%
Taylor expanded in angle around 0 58.9%
+-commutative58.9%
*-commutative58.9%
+-commutative58.9%
Simplified58.9%
Taylor expanded in angle around 0 58.9%
associate-*r*58.9%
Simplified58.9%
Final simplification58.9%
herbie shell --seed 2024060
(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)))))