| Alternative 1 | |
|---|---|
| Error | 11.7 |
| Cost | 20164 |
(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
(* (/ 1.0 B) (- (- C A) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))
(t_1 (atan (/ (- (- C A) (hypot B (- A C))) B))))
(if (<= t_0 -0.5)
(* t_1 (/ 180.0 PI))
(if (<= t_0 0.0)
(* (/ 180.0 PI) (atan (* -0.5 (/ B C))))
(/ (/ t_1 0.005555555555555556) 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 = (1.0 / B) * ((C - A) - sqrt((pow((A - C), 2.0) + pow(B, 2.0))));
double t_1 = atan((((C - A) - hypot(B, (A - C))) / B));
double tmp;
if (t_0 <= -0.5) {
tmp = t_1 * (180.0 / ((double) M_PI));
} else if (t_0 <= 0.0) {
tmp = (180.0 / ((double) M_PI)) * atan((-0.5 * (B / C)));
} else {
tmp = (t_1 / 0.005555555555555556) / ((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 = (1.0 / B) * ((C - A) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0))));
double t_1 = Math.atan((((C - A) - Math.hypot(B, (A - C))) / B));
double tmp;
if (t_0 <= -0.5) {
tmp = t_1 * (180.0 / Math.PI);
} else if (t_0 <= 0.0) {
tmp = (180.0 / Math.PI) * Math.atan((-0.5 * (B / C)));
} else {
tmp = (t_1 / 0.005555555555555556) / 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 = (1.0 / B) * ((C - A) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))) t_1 = math.atan((((C - A) - math.hypot(B, (A - C))) / B)) tmp = 0 if t_0 <= -0.5: tmp = t_1 * (180.0 / math.pi) elif t_0 <= 0.0: tmp = (180.0 / math.pi) * math.atan((-0.5 * (B / C))) else: tmp = (t_1 / 0.005555555555555556) / 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(Float64(1.0 / B) * Float64(Float64(C - A) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))) t_1 = atan(Float64(Float64(Float64(C - A) - hypot(B, Float64(A - C))) / B)) tmp = 0.0 if (t_0 <= -0.5) tmp = Float64(t_1 * Float64(180.0 / pi)); elseif (t_0 <= 0.0) tmp = Float64(Float64(180.0 / pi) * atan(Float64(-0.5 * Float64(B / C)))); else tmp = Float64(Float64(t_1 / 0.005555555555555556) / 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 = (1.0 / B) * ((C - A) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))); t_1 = atan((((C - A) - hypot(B, (A - C))) / B)); tmp = 0.0; if (t_0 <= -0.5) tmp = t_1 * (180.0 / pi); elseif (t_0 <= 0.0) tmp = (180.0 / pi) * atan((-0.5 * (B / C))); else tmp = (t_1 / 0.005555555555555556) / 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[(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]}, Block[{t$95$1 = N[ArcTan[N[(N[(N[(C - A), $MachinePrecision] - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -0.5], N[(t$95$1 * N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(180.0 / Pi), $MachinePrecision] * N[ArcTan[N[(-0.5 * N[(B / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / 0.005555555555555556), $MachinePrecision] / Pi), $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 := \frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\\
t_1 := \tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(B, A - C\right)}{B}\right)\\
\mathbf{if}\;t_0 \leq -0.5:\\
\;\;\;\;t_1 \cdot \frac{180}{\pi}\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\frac{180}{\pi} \cdot \tan^{-1} \left(-0.5 \cdot \frac{B}{C}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_1}{0.005555555555555556}}{\pi}\\
\end{array}
Results
if (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))) < -0.5Initial program 25.7
Simplified8.5
[Start]25.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/ [=>]25.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/ [<=]25.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)}
\] |
*-commutative [=>]25.7 | \[ \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/ [=>]25.7 | \[ \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 [=>]25.7 | \[ \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 [=>]25.7 | \[ \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 [=>]25.7 | \[ \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 [=>]25.7 | \[ \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 [=>]8.5 | \[ \tan^{-1} \left(\frac{\left(C - A\right) - \color{blue}{\mathsf{hypot}\left(B, A - C\right)}}{B}\right) \cdot \frac{180}{\pi}
\] |
if -0.5 < (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))) < -0.0Initial program 52.0
Simplified51.0
[Start]52.0 | \[ 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/ [=>]52.0 | \[ \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/ [<=]52.0 | \[ \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 [=>]52.0 | \[ \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/ [=>]52.0 | \[ \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 [=>]52.0 | \[ \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 [=>]52.0 | \[ \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 [=>]52.0 | \[ \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 [=>]52.0 | \[ \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 [=>]51.0 | \[ \tan^{-1} \left(\frac{\left(C - A\right) - \color{blue}{\mathsf{hypot}\left(B, A - C\right)}}{B}\right) \cdot \frac{180}{\pi}
\] |
Taylor expanded in C around inf 42.1
Simplified38.9
[Start]42.1 | \[ \tan^{-1} \left(\frac{-0.5 \cdot \frac{\left({B}^{2} + {A}^{2}\right) - {\left(-1 \cdot A\right)}^{2}}{C} + -1 \cdot \left(A + -1 \cdot A\right)}{B}\right) \cdot \frac{180}{\pi}
\] |
|---|---|
fma-def [=>]42.1 | \[ \tan^{-1} \left(\frac{\color{blue}{\mathsf{fma}\left(-0.5, \frac{\left({B}^{2} + {A}^{2}\right) - {\left(-1 \cdot A\right)}^{2}}{C}, -1 \cdot \left(A + -1 \cdot A\right)\right)}}{B}\right) \cdot \frac{180}{\pi}
\] |
associate--l+ [=>]38.8 | \[ \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.5, \frac{\color{blue}{{B}^{2} + \left({A}^{2} - {\left(-1 \cdot A\right)}^{2}\right)}}{C}, -1 \cdot \left(A + -1 \cdot A\right)\right)}{B}\right) \cdot \frac{180}{\pi}
\] |
unpow2 [=>]38.8 | \[ \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.5, \frac{\color{blue}{B \cdot B} + \left({A}^{2} - {\left(-1 \cdot A\right)}^{2}\right)}{C}, -1 \cdot \left(A + -1 \cdot A\right)\right)}{B}\right) \cdot \frac{180}{\pi}
\] |
unpow2 [=>]38.9 | \[ \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(\color{blue}{A \cdot A} - {\left(-1 \cdot A\right)}^{2}\right)}{C}, -1 \cdot \left(A + -1 \cdot A\right)\right)}{B}\right) \cdot \frac{180}{\pi}
\] |
mul-1-neg [=>]38.9 | \[ \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\color{blue}{\left(-A\right)}}^{2}\right)}{C}, -1 \cdot \left(A + -1 \cdot A\right)\right)}{B}\right) \cdot \frac{180}{\pi}
\] |
distribute-rgt1-in [=>]38.9 | \[ \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{C}, -1 \cdot \color{blue}{\left(\left(-1 + 1\right) \cdot A\right)}\right)}{B}\right) \cdot \frac{180}{\pi}
\] |
associate-*r* [=>]38.9 | \[ \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{C}, \color{blue}{\left(-1 \cdot \left(-1 + 1\right)\right) \cdot A}\right)}{B}\right) \cdot \frac{180}{\pi}
\] |
metadata-eval [=>]38.9 | \[ \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{C}, \left(-1 \cdot \color{blue}{0}\right) \cdot A\right)}{B}\right) \cdot \frac{180}{\pi}
\] |
metadata-eval [=>]38.9 | \[ \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{C}, \color{blue}{0} \cdot A\right)}{B}\right) \cdot \frac{180}{\pi}
\] |
metadata-eval [<=]38.9 | \[ \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{C}, \color{blue}{\left(-1 + 1\right)} \cdot A\right)}{B}\right) \cdot \frac{180}{\pi}
\] |
*-commutative [=>]38.9 | \[ \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{C}, \color{blue}{A \cdot \left(-1 + 1\right)}\right)}{B}\right) \cdot \frac{180}{\pi}
\] |
metadata-eval [=>]38.9 | \[ \tan^{-1} \left(\frac{\mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - {\left(-A\right)}^{2}\right)}{C}, A \cdot \color{blue}{0}\right)}{B}\right) \cdot \frac{180}{\pi}
\] |
Taylor expanded in B around 0 31.5
if -0.0 < (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))) Initial program 25.4
Simplified7.8
[Start]25.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/ [=>]25.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/ [<=]25.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 [=>]25.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/ [=>]25.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 [=>]25.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 [=>]25.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 [=>]25.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 [=>]25.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 [=>]7.8 | \[ \tan^{-1} \left(\frac{\left(C - A\right) - \color{blue}{\mathsf{hypot}\left(B, A - C\right)}}{B}\right) \cdot \frac{180}{\pi}
\] |
Applied egg-rr7.8
Final simplification11.2
| Alternative 1 | |
|---|---|
| Error | 11.7 |
| Cost | 20164 |
| Alternative 2 | |
|---|---|
| Error | 33.5 |
| Cost | 15160 |
| Alternative 3 | |
|---|---|
| Error | 33.5 |
| Cost | 14500 |
| Alternative 4 | |
|---|---|
| Error | 29.9 |
| Cost | 14236 |
| Alternative 5 | |
|---|---|
| Error | 35.7 |
| Cost | 13841 |
| Alternative 6 | |
|---|---|
| Error | 35.7 |
| Cost | 13841 |
| Alternative 7 | |
|---|---|
| Error | 35.7 |
| Cost | 13841 |
| Alternative 8 | |
|---|---|
| Error | 27.9 |
| Cost | 13841 |
| Alternative 9 | |
|---|---|
| Error | 27.9 |
| Cost | 13841 |
| Alternative 10 | |
|---|---|
| Error | 24.2 |
| Cost | 13837 |
| Alternative 11 | |
|---|---|
| Error | 21.2 |
| Cost | 13700 |
| Alternative 12 | |
|---|---|
| Error | 35.1 |
| Cost | 13576 |
| Alternative 13 | |
|---|---|
| Error | 38.6 |
| Cost | 13188 |
| Alternative 14 | |
|---|---|
| Error | 50.8 |
| Cost | 13056 |
herbie shell --seed 2023011
(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)))