| Alternative 1 | |
|---|---|
| Error | 24.1 |
| Cost | 33548 |
(FPCore (A B C) :precision binary64 (* 180.0 (/ (atan (* (/ 1.0 B) (- (- C A) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))) PI)))
(FPCore (A B C)
:precision binary64
(let* ((t_0 (* 180.0 (/ (atan (- (/ C B) 1.0)) PI))) (t_1 (+ 1.0 (/ C B))))
(if (<= A -1.15e-18)
(* 180.0 (/ (atan (* 0.5 (+ (/ B A) (/ (* B C) (pow A 2.0))))) PI))
(if (<= A -3.5e-263)
(* 180.0 (/ (atan t_1) PI))
(if (<= A 2e-286)
t_0
(if (<= A 9.2e-200)
(*
180.0
(/ (atan (- (/ (+ A (sqrt (+ (pow B 2.0) (pow A 2.0)))) B))) PI))
(if (<= A 5e-173)
t_0
(if (<= A 2.05e-38)
(* 180.0 (/ (atan (- t_1 (/ A B))) PI))
(* 180.0 (/ (atan (- -1.0 (/ A B))) PI))))))))))double code(double A, double B, double C) {
return 180.0 * (atan(((1.0 / B) * ((C - A) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / ((double) M_PI));
}
double code(double A, double B, double C) {
double t_0 = 180.0 * (atan(((C / B) - 1.0)) / ((double) M_PI));
double t_1 = 1.0 + (C / B);
double tmp;
if (A <= -1.15e-18) {
tmp = 180.0 * (atan((0.5 * ((B / A) + ((B * C) / pow(A, 2.0))))) / ((double) M_PI));
} else if (A <= -3.5e-263) {
tmp = 180.0 * (atan(t_1) / ((double) M_PI));
} else if (A <= 2e-286) {
tmp = t_0;
} else if (A <= 9.2e-200) {
tmp = 180.0 * (atan(-((A + sqrt((pow(B, 2.0) + pow(A, 2.0)))) / B)) / ((double) M_PI));
} else if (A <= 5e-173) {
tmp = t_0;
} else if (A <= 2.05e-38) {
tmp = 180.0 * (atan((t_1 - (A / B))) / ((double) M_PI));
} else {
tmp = 180.0 * (atan((-1.0 - (A / B))) / ((double) M_PI));
}
return tmp;
}
public static double code(double A, double B, double C) {
return 180.0 * (Math.atan(((1.0 / B) * ((C - A) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / Math.PI);
}
public static double code(double A, double B, double C) {
double t_0 = 180.0 * (Math.atan(((C / B) - 1.0)) / Math.PI);
double t_1 = 1.0 + (C / B);
double tmp;
if (A <= -1.15e-18) {
tmp = 180.0 * (Math.atan((0.5 * ((B / A) + ((B * C) / Math.pow(A, 2.0))))) / Math.PI);
} else if (A <= -3.5e-263) {
tmp = 180.0 * (Math.atan(t_1) / Math.PI);
} else if (A <= 2e-286) {
tmp = t_0;
} else if (A <= 9.2e-200) {
tmp = 180.0 * (Math.atan(-((A + Math.sqrt((Math.pow(B, 2.0) + Math.pow(A, 2.0)))) / B)) / Math.PI);
} else if (A <= 5e-173) {
tmp = t_0;
} else if (A <= 2.05e-38) {
tmp = 180.0 * (Math.atan((t_1 - (A / B))) / Math.PI);
} else {
tmp = 180.0 * (Math.atan((-1.0 - (A / B))) / Math.PI);
}
return tmp;
}
def code(A, B, C): return 180.0 * (math.atan(((1.0 / B) * ((C - A) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / math.pi)
def code(A, B, C): t_0 = 180.0 * (math.atan(((C / B) - 1.0)) / math.pi) t_1 = 1.0 + (C / B) tmp = 0 if A <= -1.15e-18: tmp = 180.0 * (math.atan((0.5 * ((B / A) + ((B * C) / math.pow(A, 2.0))))) / math.pi) elif A <= -3.5e-263: tmp = 180.0 * (math.atan(t_1) / math.pi) elif A <= 2e-286: tmp = t_0 elif A <= 9.2e-200: tmp = 180.0 * (math.atan(-((A + math.sqrt((math.pow(B, 2.0) + math.pow(A, 2.0)))) / B)) / math.pi) elif A <= 5e-173: tmp = t_0 elif A <= 2.05e-38: tmp = 180.0 * (math.atan((t_1 - (A / B))) / math.pi) else: tmp = 180.0 * (math.atan((-1.0 - (A / B))) / math.pi) return tmp
function code(A, B, C) return Float64(180.0 * Float64(atan(Float64(Float64(1.0 / B) * Float64(Float64(C - A) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0)))))) / pi)) end
function code(A, B, C) t_0 = Float64(180.0 * Float64(atan(Float64(Float64(C / B) - 1.0)) / pi)) t_1 = Float64(1.0 + Float64(C / B)) tmp = 0.0 if (A <= -1.15e-18) tmp = Float64(180.0 * Float64(atan(Float64(0.5 * Float64(Float64(B / A) + Float64(Float64(B * C) / (A ^ 2.0))))) / pi)); elseif (A <= -3.5e-263) tmp = Float64(180.0 * Float64(atan(t_1) / pi)); elseif (A <= 2e-286) tmp = t_0; elseif (A <= 9.2e-200) tmp = Float64(180.0 * Float64(atan(Float64(-Float64(Float64(A + sqrt(Float64((B ^ 2.0) + (A ^ 2.0)))) / B))) / pi)); elseif (A <= 5e-173) tmp = t_0; elseif (A <= 2.05e-38) tmp = Float64(180.0 * Float64(atan(Float64(t_1 - Float64(A / B))) / pi)); else tmp = Float64(180.0 * Float64(atan(Float64(-1.0 - Float64(A / B))) / pi)); end return tmp end
function tmp = code(A, B, C) tmp = 180.0 * (atan(((1.0 / B) * ((C - A) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / pi); end
function tmp_2 = code(A, B, C) t_0 = 180.0 * (atan(((C / B) - 1.0)) / pi); t_1 = 1.0 + (C / B); tmp = 0.0; if (A <= -1.15e-18) tmp = 180.0 * (atan((0.5 * ((B / A) + ((B * C) / (A ^ 2.0))))) / pi); elseif (A <= -3.5e-263) tmp = 180.0 * (atan(t_1) / pi); elseif (A <= 2e-286) tmp = t_0; elseif (A <= 9.2e-200) tmp = 180.0 * (atan(-((A + sqrt(((B ^ 2.0) + (A ^ 2.0)))) / B)) / pi); elseif (A <= 5e-173) tmp = t_0; elseif (A <= 2.05e-38) tmp = 180.0 * (atan((t_1 - (A / B))) / pi); else tmp = 180.0 * (atan((-1.0 - (A / B))) / pi); end tmp_2 = tmp; end
code[A_, B_, C_] := N[(180.0 * N[(N[ArcTan[N[(N[(1.0 / B), $MachinePrecision] * N[(N[(C - A), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]
code[A_, B_, C_] := Block[{t$95$0 = N[(180.0 * N[(N[ArcTan[N[(N[(C / B), $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(C / B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[A, -1.15e-18], N[(180.0 * N[(N[ArcTan[N[(0.5 * N[(N[(B / A), $MachinePrecision] + N[(N[(B * C), $MachinePrecision] / N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, -3.5e-263], N[(180.0 * N[(N[ArcTan[t$95$1], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 2e-286], t$95$0, If[LessEqual[A, 9.2e-200], N[(180.0 * N[(N[ArcTan[(-N[(N[(A + N[Sqrt[N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision])], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 5e-173], t$95$0, If[LessEqual[A, 2.05e-38], N[(180.0 * N[(N[ArcTan[N[(t$95$1 - N[(A / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(180.0 * N[(N[ArcTan[N[(-1.0 - N[(A / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision]]]]]]]]]
180 \cdot \frac{\tan^{-1} \left(\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right)}{\pi}
\begin{array}{l}
t_0 := 180 \cdot \frac{\tan^{-1} \left(\frac{C}{B} - 1\right)}{\pi}\\
t_1 := 1 + \frac{C}{B}\\
\mathbf{if}\;A \leq -1.15 \cdot 10^{-18}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \left(\frac{B}{A} + \frac{B \cdot C}{{A}^{2}}\right)\right)}{\pi}\\
\mathbf{elif}\;A \leq -3.5 \cdot 10^{-263}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} t_1}{\pi}\\
\mathbf{elif}\;A \leq 2 \cdot 10^{-286}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;A \leq 9.2 \cdot 10^{-200}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(-\frac{A + \sqrt{{B}^{2} + {A}^{2}}}{B}\right)}{\pi}\\
\mathbf{elif}\;A \leq 5 \cdot 10^{-173}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;A \leq 2.05 \cdot 10^{-38}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(t_1 - \frac{A}{B}\right)}{\pi}\\
\mathbf{else}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(-1 - \frac{A}{B}\right)}{\pi}\\
\end{array}
Results
if A < -1.15e-18Initial program 47.7
Taylor expanded in A around -inf 24.5
Simplified24.5
[Start]24.5 | \[ 180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \frac{C \cdot B}{{A}^{2}} + 0.5 \cdot \frac{B}{A}\right)}{\pi}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]24.5 | \[ 180 \cdot \frac{\tan^{-1} \color{blue}{\left(0.5 \cdot \frac{B}{A} + 0.5 \cdot \frac{C \cdot B}{{A}^{2}}\right)}}{\pi}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]24.5 | \[ 180 \cdot \frac{\tan^{-1} \left(\color{blue}{\frac{B}{A} \cdot 0.5} + 0.5 \cdot \frac{C \cdot B}{{A}^{2}}\right)}{\pi}
\] |
rational_best_oopsla_all_46_json_45_simplify-23 [=>]24.5 | \[ 180 \cdot \frac{\tan^{-1} \color{blue}{\left(0.5 \cdot \left(\frac{B}{A} + \frac{C \cdot B}{{A}^{2}}\right)\right)}}{\pi}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]24.5 | \[ 180 \cdot \frac{\tan^{-1} \left(0.5 \cdot \left(\frac{B}{A} + \frac{\color{blue}{B \cdot C}}{{A}^{2}}\right)\right)}{\pi}
\] |
if -1.15e-18 < A < -3.49999999999999969e-263Initial program 29.9
Taylor expanded in B around -inf 33.7
Taylor expanded in A around 0 33.6
if -3.49999999999999969e-263 < A < 2.0000000000000001e-286 or 9.2000000000000003e-200 < A < 5.0000000000000002e-173Initial program 26.5
Taylor expanded in B around inf 31.4
Taylor expanded in A around 0 32.1
if 2.0000000000000001e-286 < A < 9.2000000000000003e-200Initial program 28.6
Taylor expanded in C around 0 40.5
Simplified40.5
[Start]40.5 | \[ 180 \cdot \frac{\tan^{-1} \left(-1 \cdot \frac{A + \sqrt{{B}^{2} + {A}^{2}}}{B}\right)}{\pi}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]40.5 | \[ 180 \cdot \frac{\tan^{-1} \color{blue}{\left(\frac{A + \sqrt{{B}^{2} + {A}^{2}}}{B} \cdot -1\right)}}{\pi}
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]40.5 | \[ 180 \cdot \frac{\tan^{-1} \color{blue}{\left(-\frac{A + \sqrt{{B}^{2} + {A}^{2}}}{B}\right)}}{\pi}
\] |
if 5.0000000000000002e-173 < A < 2.0499999999999999e-38Initial program 23.4
Taylor expanded in B around -inf 29.6
if 2.0499999999999999e-38 < A Initial program 16.6
Taylor expanded in B around inf 16.7
Taylor expanded in C around 0 16.9
Simplified16.9
[Start]16.9 | \[ 180 \cdot \frac{\tan^{-1} \left(-1 \cdot \left(1 + \frac{A}{B}\right)\right)}{\pi}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]16.9 | \[ 180 \cdot \frac{\tan^{-1} \left(-1 \cdot \color{blue}{\left(\frac{A}{B} + 1\right)}\right)}{\pi}
\] |
rational_best_oopsla_all_46_json_45_simplify-1 [<=]16.9 | \[ 180 \cdot \frac{\tan^{-1} \left(-1 \cdot \color{blue}{\left(\frac{A}{B} - -1\right)}\right)}{\pi}
\] |
rational_best_oopsla_all_46_json_45_simplify-87 [=>]16.9 | \[ 180 \cdot \frac{\tan^{-1} \color{blue}{\left(\left(--1\right) \cdot \left(-1 - \frac{A}{B}\right)\right)}}{\pi}
\] |
metadata-eval [=>]16.9 | \[ 180 \cdot \frac{\tan^{-1} \left(\color{blue}{1} \cdot \left(-1 - \frac{A}{B}\right)\right)}{\pi}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]16.9 | \[ 180 \cdot \frac{\tan^{-1} \color{blue}{\left(\left(-1 - \frac{A}{B}\right) \cdot 1\right)}}{\pi}
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [=>]16.9 | \[ 180 \cdot \frac{\tan^{-1} \color{blue}{\left(-1 - \frac{A}{B}\right)}}{\pi}
\] |
Final simplification26.5
| Alternative 1 | |
|---|---|
| Error | 24.1 |
| Cost | 33548 |
| Alternative 2 | |
|---|---|
| Error | 25.8 |
| Cost | 20292 |
| Alternative 3 | |
|---|---|
| Error | 25.5 |
| Cost | 14096 |
| Alternative 4 | |
|---|---|
| Error | 33.7 |
| Cost | 13840 |
| Alternative 5 | |
|---|---|
| Error | 28.7 |
| Cost | 13840 |
| Alternative 6 | |
|---|---|
| Error | 26.5 |
| Cost | 13840 |
| Alternative 7 | |
|---|---|
| Error | 33.7 |
| Cost | 13708 |
| Alternative 8 | |
|---|---|
| Error | 25.6 |
| Cost | 13708 |
| Alternative 9 | |
|---|---|
| Error | 34.3 |
| Cost | 13448 |
| Alternative 10 | |
|---|---|
| Error | 38.4 |
| Cost | 13188 |
| Alternative 11 | |
|---|---|
| Error | 50.5 |
| Cost | 13056 |
herbie shell --seed 2023090
(FPCore (A B C)
:name "ABCF->ab-angle angle"
:precision binary64
(* 180.0 (/ (atan (* (/ 1.0 B) (- (- C A) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))) PI)))