| Alternative 1 | |
|---|---|
| Accuracy | 77.0% |
| Cost | 20304 |
(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)))))))
(if (<= t_0 -0.002)
(* (atan (/ (- (- C A) (hypot B (- C A))) B)) (/ 180.0 PI))
(if (<= t_0 0.0)
(* (/ 180.0 PI) (atan (* B (/ -0.5 (- C A)))))
(/ 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 t_0 = (1.0 / B) * ((C - A) - sqrt((pow((A - C), 2.0) + pow(B, 2.0))));
double tmp;
if (t_0 <= -0.002) {
tmp = atan((((C - A) - hypot(B, (C - A))) / B)) * (180.0 / ((double) M_PI));
} else if (t_0 <= 0.0) {
tmp = (180.0 / ((double) M_PI)) * atan((B * (-0.5 / (C - A))));
} 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 t_0 = (1.0 / B) * ((C - A) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0))));
double tmp;
if (t_0 <= -0.002) {
tmp = Math.atan((((C - A) - Math.hypot(B, (C - A))) / B)) * (180.0 / Math.PI);
} else if (t_0 <= 0.0) {
tmp = (180.0 / Math.PI) * Math.atan((B * (-0.5 / (C - A))));
} 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): t_0 = (1.0 / B) * ((C - A) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))) tmp = 0 if t_0 <= -0.002: tmp = math.atan((((C - A) - math.hypot(B, (C - A))) / B)) * (180.0 / math.pi) elif t_0 <= 0.0: tmp = (180.0 / math.pi) * math.atan((B * (-0.5 / (C - A)))) 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) t_0 = Float64(Float64(1.0 / B) * Float64(Float64(C - A) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))) tmp = 0.0 if (t_0 <= -0.002) tmp = Float64(atan(Float64(Float64(Float64(C - A) - hypot(B, Float64(C - A))) / B)) * Float64(180.0 / pi)); elseif (t_0 <= 0.0) tmp = Float64(Float64(180.0 / pi) * atan(Float64(B * Float64(-0.5 / Float64(C - A))))); else tmp = Float64(180.0 / Float64(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) t_0 = (1.0 / B) * ((C - A) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))); tmp = 0.0; if (t_0 <= -0.002) tmp = atan((((C - A) - hypot(B, (C - A))) / B)) * (180.0 / pi); elseif (t_0 <= 0.0) tmp = (180.0 / pi) * atan((B * (-0.5 / (C - A)))); 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_] := 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]}, If[LessEqual[t$95$0, -0.002], N[(N[ArcTan[N[(N[(N[(C - A), $MachinePrecision] - N[Sqrt[B ^ 2 + N[(C - A), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]], $MachinePrecision] * N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(180.0 / Pi), $MachinePrecision] * N[ArcTan[N[(B * N[(-0.5 / N[(C - A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(180.0 / N[(Pi / N[ArcTan[N[(N[(N[(C - A), $MachinePrecision] - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]], $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 := \frac{1}{B} \cdot \left(\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\\
\mathbf{if}\;t_0 \leq -0.002:\\
\;\;\;\;\tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(B, C - A\right)}{B}\right) \cdot \frac{180}{\pi}\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\frac{180}{\pi} \cdot \tan^{-1} \left(B \cdot \frac{-0.5}{C - A}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{180}{\frac{\pi}{\tan^{-1} \left(\frac{\left(C - A\right) - \mathsf{hypot}\left(B, A - C\right)}{B}\right)}}\\
\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))))) < -2e-3Initial program 59.3%
Simplified88.2%
[Start]59.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/ [=>]59.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/ [<=]59.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)}
\] |
*-commutative [=>]59.3 | \[ \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}}
\] |
if -2e-3 < (*.f64 (/.f64 1 B) (-.f64 (-.f64 C A) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))) < 0.0Initial program 19.2%
Simplified20.0%
[Start]19.2 | \[ 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/ [=>]19.2 | \[ \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/ [<=]19.2 | \[ \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 [=>]19.2 | \[ \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}}
\] |
Taylor expanded in B around 0 98.3%
Simplified98.3%
[Start]98.3 | \[ \tan^{-1} \left(-0.5 \cdot \frac{B}{C - A}\right) \cdot \frac{180}{\pi}
\] |
|---|---|
associate-*r/ [=>]98.3 | \[ \tan^{-1} \color{blue}{\left(\frac{-0.5 \cdot B}{C - A}\right)} \cdot \frac{180}{\pi}
\] |
Applied egg-rr98.2%
[Start]98.3 | \[ \tan^{-1} \left(\frac{-0.5 \cdot B}{C - A}\right) \cdot \frac{180}{\pi}
\] |
|---|---|
associate-/l* [=>]97.2 | \[ \tan^{-1} \color{blue}{\left(\frac{-0.5}{\frac{C - A}{B}}\right)} \cdot \frac{180}{\pi}
\] |
associate-/r/ [=>]98.2 | \[ \tan^{-1} \color{blue}{\left(\frac{-0.5}{C - A} \cdot B\right)} \cdot \frac{180}{\pi}
\] |
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 60.5%
Simplified82.7%
[Start]60.5 | \[ 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/ [=>]60.5 | \[ \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/ [<=]60.5 | \[ \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/ [=>]60.5 | \[ \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)}
\] |
*-lft-identity [=>]60.5 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\frac{\color{blue}{\left(C - A\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}}}{B}\right)
\] |
sub-neg [=>]60.5 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\frac{\color{blue}{\left(C - A\right) + \left(-\sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{B}\right)
\] |
associate-+l- [=>]60.5 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\frac{\color{blue}{C - \left(A - \left(-\sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right)}}{B}\right)
\] |
sub-neg [=>]60.5 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\frac{C - \color{blue}{\left(A + \left(-\left(-\sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)\right)\right)}}{B}\right)
\] |
remove-double-neg [=>]60.5 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\frac{C - \left(A + \color{blue}{\sqrt{{\left(A - C\right)}^{2} + {B}^{2}}}\right)}{B}\right)
\] |
+-commutative [=>]60.5 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\frac{C - \left(A + \sqrt{\color{blue}{{B}^{2} + {\left(A - C\right)}^{2}}}\right)}{B}\right)
\] |
unpow2 [=>]60.5 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\frac{C - \left(A + \sqrt{\color{blue}{B \cdot B} + {\left(A - C\right)}^{2}}\right)}{B}\right)
\] |
unpow2 [=>]60.5 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\frac{C - \left(A + \sqrt{B \cdot B + \color{blue}{\left(A - C\right) \cdot \left(A - C\right)}}\right)}{B}\right)
\] |
hypot-def [=>]82.7 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\frac{C - \left(A + \color{blue}{\mathsf{hypot}\left(B, A - C\right)}\right)}{B}\right)
\] |
Applied egg-rr87.3%
[Start]82.7 | \[ \frac{180}{\pi} \cdot \tan^{-1} \left(\frac{C - \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}{B}\right)
\] |
|---|---|
associate-*l/ [=>]82.7 | \[ \color{blue}{\frac{180 \cdot \tan^{-1} \left(\frac{C - \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}{B}\right)}{\pi}}
\] |
associate-/l* [=>]82.7 | \[ \color{blue}{\frac{180}{\frac{\pi}{\tan^{-1} \left(\frac{C - \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}{B}\right)}}}
\] |
associate--r+ [=>]87.3 | \[ \frac{180}{\frac{\pi}{\tan^{-1} \left(\frac{\color{blue}{\left(C - A\right) - \mathsf{hypot}\left(B, A - C\right)}}{B}\right)}}
\] |
Final simplification89.1%
| Alternative 1 | |
|---|---|
| Accuracy | 77.0% |
| Cost | 20304 |
| Alternative 2 | |
|---|---|
| Accuracy | 80.3% |
| Cost | 20172 |
| Alternative 3 | |
|---|---|
| Accuracy | 77.5% |
| Cost | 20040 |
| Alternative 4 | |
|---|---|
| Accuracy | 53.4% |
| Cost | 14236 |
| Alternative 5 | |
|---|---|
| Accuracy | 52.6% |
| Cost | 14104 |
| Alternative 6 | |
|---|---|
| Accuracy | 57.2% |
| Cost | 13904 |
| Alternative 7 | |
|---|---|
| Accuracy | 46.6% |
| Cost | 13840 |
| Alternative 8 | |
|---|---|
| Accuracy | 46.7% |
| Cost | 13840 |
| Alternative 9 | |
|---|---|
| Accuracy | 51.8% |
| Cost | 13840 |
| Alternative 10 | |
|---|---|
| Accuracy | 49.0% |
| Cost | 13776 |
| Alternative 11 | |
|---|---|
| Accuracy | 49.0% |
| Cost | 13776 |
| Alternative 12 | |
|---|---|
| Accuracy | 59.0% |
| Cost | 13704 |
| Alternative 13 | |
|---|---|
| Accuracy | 59.0% |
| Cost | 13704 |
| Alternative 14 | |
|---|---|
| Accuracy | 61.8% |
| Cost | 13704 |
| Alternative 15 | |
|---|---|
| Accuracy | 63.4% |
| Cost | 13704 |
| Alternative 16 | |
|---|---|
| Accuracy | 47.3% |
| Cost | 13448 |
| Alternative 17 | |
|---|---|
| Accuracy | 45.5% |
| Cost | 13448 |
| Alternative 18 | |
|---|---|
| Accuracy | 40.2% |
| Cost | 13188 |
| Alternative 19 | |
|---|---|
| Accuracy | 20.9% |
| Cost | 13056 |
herbie shell --seed 2023152
(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)))