| Alternative 1 | |
|---|---|
| Error | 12.9 |
| 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
(if (<= C 4.4e-27)
(/ (* 180.0 (atan (* (/ 1.0 B) (- (- C (hypot (- A C) B)) A)))) PI)
(if (or (<= C 5.5e+43) (not (<= C 2.6e+95)))
(* (/ 180.0 PI) (atan (* (/ B C) -0.5)))
(* (/ 180.0 PI) (atan (/ (- (- C A) (hypot B (- A C))) 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 tmp;
if (C <= 4.4e-27) {
tmp = (180.0 * atan(((1.0 / B) * ((C - hypot((A - C), B)) - A)))) / ((double) M_PI);
} else if ((C <= 5.5e+43) || !(C <= 2.6e+95)) {
tmp = (180.0 / ((double) M_PI)) * atan(((B / C) * -0.5));
} else {
tmp = (180.0 / ((double) M_PI)) * atan((((C - A) - hypot(B, (A - C))) / 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 tmp;
if (C <= 4.4e-27) {
tmp = (180.0 * Math.atan(((1.0 / B) * ((C - Math.hypot((A - C), B)) - A)))) / Math.PI;
} else if ((C <= 5.5e+43) || !(C <= 2.6e+95)) {
tmp = (180.0 / Math.PI) * Math.atan(((B / C) * -0.5));
} else {
tmp = (180.0 / Math.PI) * Math.atan((((C - A) - Math.hypot(B, (A - C))) / 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): tmp = 0 if C <= 4.4e-27: tmp = (180.0 * math.atan(((1.0 / B) * ((C - math.hypot((A - C), B)) - A)))) / math.pi elif (C <= 5.5e+43) or not (C <= 2.6e+95): tmp = (180.0 / math.pi) * math.atan(((B / C) * -0.5)) else: tmp = (180.0 / math.pi) * math.atan((((C - A) - math.hypot(B, (A - C))) / 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) tmp = 0.0 if (C <= 4.4e-27) tmp = Float64(Float64(180.0 * atan(Float64(Float64(1.0 / B) * Float64(Float64(C - hypot(Float64(A - C), B)) - A)))) / pi); elseif ((C <= 5.5e+43) || !(C <= 2.6e+95)) tmp = Float64(Float64(180.0 / pi) * atan(Float64(Float64(B / C) * -0.5))); else tmp = Float64(Float64(180.0 / pi) * atan(Float64(Float64(Float64(C - A) - hypot(B, Float64(A - C))) / 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) tmp = 0.0; if (C <= 4.4e-27) tmp = (180.0 * atan(((1.0 / B) * ((C - hypot((A - C), B)) - A)))) / pi; elseif ((C <= 5.5e+43) || ~((C <= 2.6e+95))) tmp = (180.0 / pi) * atan(((B / C) * -0.5)); else tmp = (180.0 / pi) * atan((((C - A) - hypot(B, (A - C))) / 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_] := If[LessEqual[C, 4.4e-27], N[(N[(180.0 * N[ArcTan[N[(N[(1.0 / B), $MachinePrecision] * N[(N[(C - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision] - A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision], If[Or[LessEqual[C, 5.5e+43], N[Not[LessEqual[C, 2.6e+95]], $MachinePrecision]], N[(N[(180.0 / Pi), $MachinePrecision] * N[ArcTan[N[(N[(B / C), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(180.0 / Pi), $MachinePrecision] * N[ArcTan[N[(N[(N[(C - A), $MachinePrecision] - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $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}
\mathbf{if}\;C \leq 4.4 \cdot 10^{-27}:\\
\;\;\;\;\frac{180 \cdot \tan^{-1} \left(\frac{1}{B} \cdot \left(\left(C - \mathsf{hypot}\left(A - C, B\right)\right) - A\right)\right)}{\pi}\\
\mathbf{elif}\;C \leq 5.5 \cdot 10^{+43} \lor \neg \left(C \leq 2.6 \cdot 10^{+95}\right):\\
\;\;\;\;\frac{180}{\pi} \cdot \tan^{-1} \left(\frac{B}{C} \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{180}{\pi} \cdot \tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(B, A - C\right)}{B}\right)\\
\end{array}
Results
if C < 4.39999999999999974e-27Initial program 23.1
Simplified23.1
[Start]23.1 | \[ 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/ [=>]23.1 | \[ \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 [=>]23.1 | \[ \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 [<=]23.1 | \[ \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 [=>]23.1 | \[ \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}
\] |
Applied egg-rr9.3
if 4.39999999999999974e-27 < C < 5.49999999999999989e43 or 2.5999999999999999e95 < C Initial program 47.7
Simplified28.9
[Start]47.7 | \[ 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/ [=>]47.7 | \[ \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/ [<=]47.7 | \[ \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/ [=>]47.7 | \[ \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)}
\] |
Taylor expanded in C around inf 42.6
Simplified38.6
[Start]42.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(-0.5 \cdot \frac{\left({B}^{2} + {A}^{2}\right) - {\left(-1 \cdot A\right)}^{2}}{C \cdot B} + -1 \cdot \frac{A + -1 \cdot A}{B}\right)
\] |
|---|---|
fma-def [=>]42.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \color{blue}{\left(\mathsf{fma}\left(-0.5, \frac{\left({B}^{2} + {A}^{2}\right) - {\left(-1 \cdot A\right)}^{2}}{C \cdot B}, -1 \cdot \frac{A + -1 \cdot A}{B}\right)\right)}
\] |
associate--l+ [=>]38.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\mathsf{fma}\left(-0.5, \frac{\color{blue}{{B}^{2} + \left({A}^{2} - {\left(-1 \cdot A\right)}^{2}\right)}}{C \cdot B}, -1 \cdot \frac{A + -1 \cdot A}{B}\right)\right)
\] |
unpow2 [=>]38.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\mathsf{fma}\left(-0.5, \frac{\color{blue}{B \cdot B} + \left({A}^{2} - {\left(-1 \cdot A\right)}^{2}\right)}{C \cdot B}, -1 \cdot \frac{A + -1 \cdot A}{B}\right)\right)
\] |
unpow2 [=>]38.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(\color{blue}{A \cdot A} - {\left(-1 \cdot A\right)}^{2}\right)}{C \cdot B}, -1 \cdot \frac{A + -1 \cdot A}{B}\right)\right)
\] |
mul-1-neg [=>]38.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\color{blue}{\left(-A\right)}}^{2}\right)}{C \cdot B}, -1 \cdot \frac{A + -1 \cdot A}{B}\right)\right)
\] |
*-commutative [=>]38.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{\color{blue}{B \cdot C}}, -1 \cdot \frac{A + -1 \cdot A}{B}\right)\right)
\] |
associate-*r/ [=>]38.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{B \cdot C}, \color{blue}{\frac{-1 \cdot \left(A + -1 \cdot A\right)}{B}}\right)\right)
\] |
distribute-rgt1-in [=>]38.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{B \cdot C}, \frac{-1 \cdot \color{blue}{\left(\left(-1 + 1\right) \cdot A\right)}}{B}\right)\right)
\] |
associate-*r* [=>]38.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{B \cdot C}, \frac{\color{blue}{\left(-1 \cdot \left(-1 + 1\right)\right) \cdot A}}{B}\right)\right)
\] |
metadata-eval [=>]38.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{B \cdot C}, \frac{\left(-1 \cdot \color{blue}{0}\right) \cdot A}{B}\right)\right)
\] |
metadata-eval [=>]38.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{B \cdot C}, \frac{\color{blue}{0} \cdot A}{B}\right)\right)
\] |
metadata-eval [<=]38.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{B \cdot C}, \frac{\color{blue}{\left(-1 + 1\right)} \cdot A}{B}\right)\right)
\] |
*-commutative [=>]38.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{B \cdot C}, \frac{\color{blue}{A \cdot \left(-1 + 1\right)}}{B}\right)\right)
\] |
metadata-eval [=>]38.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{B \cdot C}, \frac{A \cdot \color{blue}{0}}{B}\right)\right)
\] |
Taylor expanded in B around 0 22.6
Simplified22.6
[Start]22.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(-0.5 \cdot \frac{B}{C}\right)
\] |
|---|---|
*-commutative [=>]22.6 | \[ \frac{180}{\pi} \cdot \tan^{-1} \color{blue}{\left(\frac{B}{C} \cdot -0.5\right)}
\] |
if 5.49999999999999989e43 < C < 2.5999999999999999e95Initial program 39.4
Simplified25.1
[Start]39.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/ [=>]39.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}}
\] |
associate-*l/ [<=]39.4 | \[ \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)}
\] |
*-commutative [=>]39.4 | \[ \color{blue}{\tan^{-1} \left(\frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right) \cdot \frac{180}{\pi}}
\] |
associate-*l/ [=>]39.4 | \[ \tan^{-1} \color{blue}{\left(\frac{1 \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}{B}\right)} \cdot \frac{180}{\pi}
\] |
*-lft-identity [=>]39.4 | \[ \tan^{-1} \left(\frac{\color{blue}{\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}}}{B}\right) \cdot \frac{180}{\pi}
\] |
+-commutative [=>]39.4 | \[ \tan^{-1} \left(\frac{\left(C - A\right) - \sqrt{\color{blue}{{B}^{2} + {\left(A - C\right)}^{2}}}}{B}\right) \cdot \frac{180}{\pi}
\] |
unpow2 [=>]39.4 | \[ \tan^{-1} \left(\frac{\left(C - A\right) - \sqrt{\color{blue}{B \cdot B} + {\left(A - C\right)}^{2}}}{B}\right) \cdot \frac{180}{\pi}
\] |
unpow2 [=>]39.4 | \[ \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) \cdot \frac{180}{\pi}
\] |
hypot-def [=>]25.1 | \[ \tan^{-1} \left(\frac{\left(C - A\right) - \color{blue}{\mathsf{hypot}\left(B, A - C\right)}}{B}\right) \cdot \frac{180}{\pi}
\] |
Final simplification12.9
| Alternative 1 | |
|---|---|
| Error | 12.9 |
| Cost | 20429 |
| Alternative 2 | |
|---|---|
| Error | 33.1 |
| Cost | 14764 |
| Alternative 3 | |
|---|---|
| Error | 32.9 |
| Cost | 14632 |
| Alternative 4 | |
|---|---|
| Error | 32.9 |
| Cost | 14632 |
| Alternative 5 | |
|---|---|
| Error | 30.7 |
| Cost | 14500 |
| Alternative 6 | |
|---|---|
| Error | 35.9 |
| Cost | 14369 |
| Alternative 7 | |
|---|---|
| Error | 25.6 |
| Cost | 14100 |
| Alternative 8 | |
|---|---|
| Error | 34.5 |
| Cost | 13840 |
| Alternative 9 | |
|---|---|
| Error | 34.5 |
| Cost | 13840 |
| Alternative 10 | |
|---|---|
| Error | 38.5 |
| Cost | 13188 |
| Alternative 11 | |
|---|---|
| Error | 50.5 |
| Cost | 13056 |
herbie shell --seed 2023054
(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)))