| Alternative 1 | |
|---|---|
| Error | 33.2 |
| Cost | 46084 |
(FPCore (a b angle) :precision binary64 (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* PI (/ angle 180.0)))) (cos (* PI (/ angle 180.0)))))
(FPCore (a b angle)
:precision binary64
(let* ((t_0 (* angle (* 0.005555555555555556 PI))) (t_1 (sin t_0)))
(if (<= (- (pow b 2.0) (pow a 2.0)) -1e-175)
(* (pow a 2.0) (* -2.0 (* (cos t_0) t_1)))
(*
2.0
(*
(/ (cos (* PI (* angle 0.005555555555555556))) 1.0)
(* t_1 (pow b 2.0)))))))double code(double a, double b, double angle) {
return ((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin((((double) M_PI) * (angle / 180.0)))) * cos((((double) M_PI) * (angle / 180.0)));
}
double code(double a, double b, double angle) {
double t_0 = angle * (0.005555555555555556 * ((double) M_PI));
double t_1 = sin(t_0);
double tmp;
if ((pow(b, 2.0) - pow(a, 2.0)) <= -1e-175) {
tmp = pow(a, 2.0) * (-2.0 * (cos(t_0) * t_1));
} else {
tmp = 2.0 * ((cos((((double) M_PI) * (angle * 0.005555555555555556))) / 1.0) * (t_1 * pow(b, 2.0)));
}
return tmp;
}
public static double code(double a, double b, double angle) {
return ((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * Math.sin((Math.PI * (angle / 180.0)))) * Math.cos((Math.PI * (angle / 180.0)));
}
public static double code(double a, double b, double angle) {
double t_0 = angle * (0.005555555555555556 * Math.PI);
double t_1 = Math.sin(t_0);
double tmp;
if ((Math.pow(b, 2.0) - Math.pow(a, 2.0)) <= -1e-175) {
tmp = Math.pow(a, 2.0) * (-2.0 * (Math.cos(t_0) * t_1));
} else {
tmp = 2.0 * ((Math.cos((Math.PI * (angle * 0.005555555555555556))) / 1.0) * (t_1 * Math.pow(b, 2.0)));
}
return tmp;
}
def code(a, b, angle): return ((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * math.sin((math.pi * (angle / 180.0)))) * math.cos((math.pi * (angle / 180.0)))
def code(a, b, angle): t_0 = angle * (0.005555555555555556 * math.pi) t_1 = math.sin(t_0) tmp = 0 if (math.pow(b, 2.0) - math.pow(a, 2.0)) <= -1e-175: tmp = math.pow(a, 2.0) * (-2.0 * (math.cos(t_0) * t_1)) else: tmp = 2.0 * ((math.cos((math.pi * (angle * 0.005555555555555556))) / 1.0) * (t_1 * math.pow(b, 2.0))) return tmp
function code(a, b, angle) return Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * sin(Float64(pi * Float64(angle / 180.0)))) * cos(Float64(pi * Float64(angle / 180.0)))) end
function code(a, b, angle) t_0 = Float64(angle * Float64(0.005555555555555556 * pi)) t_1 = sin(t_0) tmp = 0.0 if (Float64((b ^ 2.0) - (a ^ 2.0)) <= -1e-175) tmp = Float64((a ^ 2.0) * Float64(-2.0 * Float64(cos(t_0) * t_1))); else tmp = Float64(2.0 * Float64(Float64(cos(Float64(pi * Float64(angle * 0.005555555555555556))) / 1.0) * Float64(t_1 * (b ^ 2.0)))); end return tmp end
function tmp = code(a, b, angle) tmp = ((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * sin((pi * (angle / 180.0)))) * cos((pi * (angle / 180.0))); end
function tmp_2 = code(a, b, angle) t_0 = angle * (0.005555555555555556 * pi); t_1 = sin(t_0); tmp = 0.0; if (((b ^ 2.0) - (a ^ 2.0)) <= -1e-175) tmp = (a ^ 2.0) * (-2.0 * (cos(t_0) * t_1)); else tmp = 2.0 * ((cos((pi * (angle * 0.005555555555555556))) / 1.0) * (t_1 * (b ^ 2.0))); end tmp_2 = tmp; end
code[a_, b_, angle_] := N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[a_, b_, angle_] := Block[{t$95$0 = N[(angle * N[(0.005555555555555556 * Pi), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[t$95$0], $MachinePrecision]}, If[LessEqual[N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision], -1e-175], N[(N[Power[a, 2.0], $MachinePrecision] * N[(-2.0 * N[(N[Cos[t$95$0], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[(N[Cos[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 1.0), $MachinePrecision] * N[(t$95$1 * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)
\begin{array}{l}
t_0 := angle \cdot \left(0.005555555555555556 \cdot \pi\right)\\
t_1 := \sin t_0\\
\mathbf{if}\;{b}^{2} - {a}^{2} \leq -1 \cdot 10^{-175}:\\
\;\;\;\;{a}^{2} \cdot \left(-2 \cdot \left(\cos t_0 \cdot t_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\frac{\cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)}{1} \cdot \left(t_1 \cdot {b}^{2}\right)\right)\\
\end{array}
Results
if (-.f64 (pow.f64 b 2) (pow.f64 a 2)) < -1e-175Initial program 35.5
Simplified35.5
[Start]35.5 | \[ \left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]35.5 | \[ \color{blue}{\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]35.5 | \[ \color{blue}{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]35.5 | \[ \left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \color{blue}{\left(\sin \left(\pi \cdot \frac{angle}{180}\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}
\] |
Taylor expanded in b around 0 35.8
Simplified35.8
[Start]35.8 | \[ -2 \cdot \left({a}^{2} \cdot \left(\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-7 [=>]35.8 | \[ \color{blue}{{a}^{2} \cdot \left(-2 \cdot \left(\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]35.8 | \[ {a}^{2} \cdot \left(-2 \cdot \left(\cos \color{blue}{\left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right)} \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]35.8 | \[ {a}^{2} \cdot \left(-2 \cdot \left(\cos \left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right) \cdot \sin \color{blue}{\left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right)}\right)\right)
\] |
if -1e-175 < (-.f64 (pow.f64 b 2) (pow.f64 a 2)) Initial program 29.5
Simplified29.5
[Start]29.5 | \[ \left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]29.5 | \[ \color{blue}{\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]29.5 | \[ \color{blue}{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]29.5 | \[ \left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \color{blue}{\left(\sin \left(\pi \cdot \frac{angle}{180}\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}
\] |
Taylor expanded in b around inf 30.3
Simplified30.4
[Start]30.3 | \[ 2 \cdot \left({b}^{2} \cdot \left(\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-7 [=>]30.3 | \[ 2 \cdot \color{blue}{\left(\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \left({b}^{2} \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]30.4 | \[ 2 \cdot \left(\cos \color{blue}{\left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right)} \cdot \left({b}^{2} \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]30.4 | \[ 2 \cdot \left(\cos \left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right) \cdot \color{blue}{\left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot {b}^{2}\right)}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]30.4 | \[ 2 \cdot \left(\cos \left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right) \cdot \left(\sin \color{blue}{\left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right)} \cdot {b}^{2}\right)\right)
\] |
Applied egg-rr30.5
Final simplification32.6
| Alternative 1 | |
|---|---|
| Error | 33.2 |
| Cost | 46084 |
| Alternative 2 | |
|---|---|
| Error | 32.5 |
| Cost | 46084 |
| Alternative 3 | |
|---|---|
| Error | 32.5 |
| Cost | 46084 |
| Alternative 4 | |
|---|---|
| Error | 32.5 |
| Cost | 46084 |
| Alternative 5 | |
|---|---|
| Error | 32.6 |
| Cost | 46084 |
| Alternative 6 | |
|---|---|
| Error | 32.6 |
| Cost | 46084 |
| Alternative 7 | |
|---|---|
| Error | 32.5 |
| Cost | 46084 |
| Alternative 8 | |
|---|---|
| Error | 31.9 |
| Cost | 39488 |
| Alternative 9 | |
|---|---|
| Error | 31.9 |
| Cost | 39488 |
| Alternative 10 | |
|---|---|
| Error | 32.0 |
| Cost | 39488 |
| Alternative 11 | |
|---|---|
| Error | 33.6 |
| Cost | 33092 |
| Alternative 12 | |
|---|---|
| Error | 34.4 |
| Cost | 33028 |
| Alternative 13 | |
|---|---|
| Error | 34.4 |
| Cost | 32964 |
| Alternative 14 | |
|---|---|
| Error | 33.0 |
| Cost | 26496 |
| Alternative 15 | |
|---|---|
| Error | 38.5 |
| Cost | 13576 |
| Alternative 16 | |
|---|---|
| Error | 38.6 |
| Cost | 13512 |
| Alternative 17 | |
|---|---|
| Error | 38.5 |
| Cost | 13512 |
| Alternative 18 | |
|---|---|
| Error | 38.5 |
| Cost | 13512 |
| Alternative 19 | |
|---|---|
| Error | 38.6 |
| Cost | 13512 |
| Alternative 20 | |
|---|---|
| Error | 44.2 |
| Cost | 13248 |
herbie shell --seed 2023090
(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)))))