| Alternative 1 | |
|---|---|
| Error | 13.4 |
| Cost | 20429 |
(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 (hypot B (- A C))))
(if (<= A -3.5e+134)
(/ (/ (atan (/ (* B 0.5) A)) 0.005555555555555556) PI)
(if (<= A -9.2e-33)
(* 180.0 (/ (atan (/ (- (- C A) t_0) B)) PI))
(if (<= A -2.15e-103)
(/ (* 180.0 (atan (* 0.5 (+ (/ B A) (/ B (/ A (/ C A))))))) PI)
(* (/ 180.0 PI) (atan (/ (- C (+ A t_0)) B))))))))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 = hypot(B, (A - C));
double tmp;
if (A <= -3.5e+134) {
tmp = (atan(((B * 0.5) / A)) / 0.005555555555555556) / ((double) M_PI);
} else if (A <= -9.2e-33) {
tmp = 180.0 * (atan((((C - A) - t_0) / B)) / ((double) M_PI));
} else if (A <= -2.15e-103) {
tmp = (180.0 * atan((0.5 * ((B / A) + (B / (A / (C / A))))))) / ((double) M_PI);
} else {
tmp = (180.0 / ((double) M_PI)) * atan(((C - (A + t_0)) / B));
}
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 = Math.hypot(B, (A - C));
double tmp;
if (A <= -3.5e+134) {
tmp = (Math.atan(((B * 0.5) / A)) / 0.005555555555555556) / Math.PI;
} else if (A <= -9.2e-33) {
tmp = 180.0 * (Math.atan((((C - A) - t_0) / B)) / Math.PI);
} else if (A <= -2.15e-103) {
tmp = (180.0 * Math.atan((0.5 * ((B / A) + (B / (A / (C / A))))))) / Math.PI;
} else {
tmp = (180.0 / Math.PI) * Math.atan(((C - (A + t_0)) / B));
}
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 = math.hypot(B, (A - C)) tmp = 0 if A <= -3.5e+134: tmp = (math.atan(((B * 0.5) / A)) / 0.005555555555555556) / math.pi elif A <= -9.2e-33: tmp = 180.0 * (math.atan((((C - A) - t_0) / B)) / math.pi) elif A <= -2.15e-103: tmp = (180.0 * math.atan((0.5 * ((B / A) + (B / (A / (C / A))))))) / math.pi else: tmp = (180.0 / math.pi) * math.atan(((C - (A + t_0)) / B)) 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 = hypot(B, Float64(A - C)) tmp = 0.0 if (A <= -3.5e+134) tmp = Float64(Float64(atan(Float64(Float64(B * 0.5) / A)) / 0.005555555555555556) / pi); elseif (A <= -9.2e-33) tmp = Float64(180.0 * Float64(atan(Float64(Float64(Float64(C - A) - t_0) / B)) / pi)); elseif (A <= -2.15e-103) tmp = Float64(Float64(180.0 * atan(Float64(0.5 * Float64(Float64(B / A) + Float64(B / Float64(A / Float64(C / A))))))) / pi); else tmp = Float64(Float64(180.0 / pi) * atan(Float64(Float64(C - Float64(A + t_0)) / B))); 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 = hypot(B, (A - C)); tmp = 0.0; if (A <= -3.5e+134) tmp = (atan(((B * 0.5) / A)) / 0.005555555555555556) / pi; elseif (A <= -9.2e-33) tmp = 180.0 * (atan((((C - A) - t_0) / B)) / pi); elseif (A <= -2.15e-103) tmp = (180.0 * atan((0.5 * ((B / A) + (B / (A / (C / A))))))) / pi; else tmp = (180.0 / pi) * atan(((C - (A + t_0)) / B)); 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[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[A, -3.5e+134], N[(N[(N[ArcTan[N[(N[(B * 0.5), $MachinePrecision] / A), $MachinePrecision]], $MachinePrecision] / 0.005555555555555556), $MachinePrecision] / Pi), $MachinePrecision], If[LessEqual[A, -9.2e-33], N[(180.0 * N[(N[ArcTan[N[(N[(N[(C - A), $MachinePrecision] - t$95$0), $MachinePrecision] / B), $MachinePrecision]], $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, -2.15e-103], N[(N[(180.0 * N[ArcTan[N[(0.5 * N[(N[(B / A), $MachinePrecision] + N[(B / N[(A / N[(C / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision], N[(N[(180.0 / Pi), $MachinePrecision] * N[ArcTan[N[(N[(C - N[(A + t$95$0), $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]], $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 := \mathsf{hypot}\left(B, A - C\right)\\
\mathbf{if}\;A \leq -3.5 \cdot 10^{+134}:\\
\;\;\;\;\frac{\frac{\tan^{-1} \left(\frac{B \cdot 0.5}{A}\right)}{0.005555555555555556}}{\pi}\\
\mathbf{elif}\;A \leq -9.2 \cdot 10^{-33}:\\
\;\;\;\;180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - t_0}{B}\right)}{\pi}\\
\mathbf{elif}\;A \leq -2.15 \cdot 10^{-103}:\\
\;\;\;\;\frac{180 \cdot \tan^{-1} \left(0.5 \cdot \left(\frac{B}{A} + \frac{B}{\frac{A}{\frac{C}{A}}}\right)\right)}{\pi}\\
\mathbf{else}:\\
\;\;\;\;\frac{180}{\pi} \cdot \tan^{-1} \left(\frac{C - \left(A + t_0\right)}{B}\right)\\
\end{array}
Results
if A < -3.50000000000000003e134Initial program 54.6
Simplified47.7
[Start]54.6 | \[ 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}
\] |
|---|---|
associate-*r/ [=>]54.6 | \[ \color{blue}{\frac{180 \cdot \tan^{-1} \left(\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right)}{\pi}}
\] |
associate-*l/ [<=]54.6 | \[ \color{blue}{\frac{180}{\pi} \cdot \tan^{-1} \left(\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right)}
\] |
associate-*l/ [=>]54.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \color{blue}{\left(\frac{1 \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}{B}\right)}
\] |
Applied egg-rr27.8
Taylor expanded in A around -inf 13.7
Simplified13.7
[Start]13.7 | \[ \frac{\frac{\tan^{-1} \left(0.5 \cdot \frac{B}{A}\right)}{0.005555555555555556}}{\pi}
\] |
|---|---|
associate-*r/ [=>]13.7 | \[ \frac{\frac{\tan^{-1} \color{blue}{\left(\frac{0.5 \cdot B}{A}\right)}}{0.005555555555555556}}{\pi}
\] |
*-commutative [=>]13.7 | \[ \frac{\frac{\tan^{-1} \left(\frac{\color{blue}{B \cdot 0.5}}{A}\right)}{0.005555555555555556}}{\pi}
\] |
if -3.50000000000000003e134 < A < -9.19999999999999942e-33Initial program 37.8
Simplified25.1
[Start]37.8 | \[ 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}
\] |
|---|---|
associate-*l/ [=>]37.8 | \[ 180 \cdot \frac{\tan^{-1} \color{blue}{\left(\frac{1 \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}{B}\right)}}{\pi}
\] |
*-lft-identity [=>]37.8 | \[ 180 \cdot \frac{\tan^{-1} \left(\frac{\color{blue}{\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}}}{B}\right)}{\pi}
\] |
+-commutative [=>]37.8 | \[ 180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - \sqrt{\color{blue}{{B}^{2} + {\left(A - C\right)}^{2}}}}{B}\right)}{\pi}
\] |
unpow2 [=>]37.8 | \[ 180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - \sqrt{\color{blue}{B \cdot B} + {\left(A - C\right)}^{2}}}{B}\right)}{\pi}
\] |
unpow2 [=>]37.8 | \[ 180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - \sqrt{B \cdot B + \color{blue}{\left(A - C\right) \cdot \left(A - C\right)}}}{B}\right)}{\pi}
\] |
hypot-def [=>]25.1 | \[ 180 \cdot \frac{\tan^{-1} \left(\frac{\left(C - A\right) - \color{blue}{\mathsf{hypot}\left(B, A - C\right)}}{B}\right)}{\pi}
\] |
if -9.19999999999999942e-33 < A < -2.15000000000000011e-103Initial program 32.4
Simplified32.4
[Start]32.4 | \[ 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}
\] |
|---|---|
associate-*r/ [=>]32.4 | \[ \color{blue}{\frac{180 \cdot \tan^{-1} \left(\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right)}{\pi}}
\] |
sub-neg [=>]32.4 | \[ \frac{180 \cdot \tan^{-1} \left(\frac{1}{B} \cdot \color{blue}{\left(\left(C - A\right) + \left(-\sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right)}\right)}{\pi}
\] |
sub-neg [<=]32.4 | \[ \frac{180 \cdot \tan^{-1} \left(\frac{1}{B} \cdot \color{blue}{\left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}\right)}{\pi}
\] |
unpow2 [=>]32.4 | \[ \frac{180 \cdot \tan^{-1} \left(\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + \color{blue}{B \cdot B}}\right)\right)}{\pi}
\] |
Taylor expanded in A around -inf 40.8
Simplified40.8
[Start]40.8 | \[ \frac{180 \cdot \tan^{-1} \left(0.5 \cdot \frac{C \cdot B}{{A}^{2}} + 0.5 \cdot \frac{B}{A}\right)}{\pi}
\] |
|---|---|
distribute-lft-out [=>]40.8 | \[ \frac{180 \cdot \tan^{-1} \color{blue}{\left(0.5 \cdot \left(\frac{C \cdot B}{{A}^{2}} + \frac{B}{A}\right)\right)}}{\pi}
\] |
+-commutative [=>]40.8 | \[ \frac{180 \cdot \tan^{-1} \left(0.5 \cdot \color{blue}{\left(\frac{B}{A} + \frac{C \cdot B}{{A}^{2}}\right)}\right)}{\pi}
\] |
*-commutative [=>]40.8 | \[ \frac{180 \cdot \tan^{-1} \left(0.5 \cdot \left(\frac{B}{A} + \frac{\color{blue}{B \cdot C}}{{A}^{2}}\right)\right)}{\pi}
\] |
associate-/l* [=>]40.8 | \[ \frac{180 \cdot \tan^{-1} \left(0.5 \cdot \left(\frac{B}{A} + \color{blue}{\frac{B}{\frac{{A}^{2}}{C}}}\right)\right)}{\pi}
\] |
unpow2 [=>]40.8 | \[ \frac{180 \cdot \tan^{-1} \left(0.5 \cdot \left(\frac{B}{A} + \frac{B}{\frac{\color{blue}{A \cdot A}}{C}}\right)\right)}{\pi}
\] |
associate-/l* [=>]40.8 | \[ \frac{180 \cdot \tan^{-1} \left(0.5 \cdot \left(\frac{B}{A} + \frac{B}{\color{blue}{\frac{A}{\frac{C}{A}}}}\right)\right)}{\pi}
\] |
if -2.15000000000000011e-103 < A Initial program 22.3
Simplified8.5
[Start]22.3 | \[ 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}
\] |
|---|---|
associate-*r/ [=>]22.3 | \[ \color{blue}{\frac{180 \cdot \tan^{-1} \left(\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right)}{\pi}}
\] |
associate-*l/ [<=]22.3 | \[ \color{blue}{\frac{180}{\pi} \cdot \tan^{-1} \left(\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right)}
\] |
associate-*l/ [=>]22.3 | \[ \frac{180}{\pi} \cdot \tan^{-1} \color{blue}{\left(\frac{1 \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}{B}\right)}
\] |
Final simplification13.4
| Alternative 1 | |
|---|---|
| Error | 13.4 |
| Cost | 20429 |
| Alternative 2 | |
|---|---|
| Error | 17.0 |
| Cost | 20304 |
| Alternative 3 | |
|---|---|
| Error | 26.2 |
| Cost | 14220 |
| Alternative 4 | |
|---|---|
| Error | 22.8 |
| Cost | 13968 |
| Alternative 5 | |
|---|---|
| Error | 35.3 |
| Cost | 13576 |
| Alternative 6 | |
|---|---|
| Error | 35.3 |
| Cost | 13576 |
| Alternative 7 | |
|---|---|
| Error | 32.7 |
| Cost | 13576 |
| Alternative 8 | |
|---|---|
| Error | 27.6 |
| Cost | 13576 |
| Alternative 9 | |
|---|---|
| Error | 27.6 |
| Cost | 13576 |
| Alternative 10 | |
|---|---|
| Error | 25.4 |
| Cost | 13572 |
| Alternative 11 | |
|---|---|
| Error | 38.5 |
| Cost | 13188 |
| Alternative 12 | |
|---|---|
| Error | 50.8 |
| Cost | 13056 |
herbie shell --seed 2023066
(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)))