| Alternative 1 | |
|---|---|
| Error | 38.4 |
| Cost | 27720 |
(FPCore (A B C F)
:precision binary64
(/
(-
(sqrt
(*
(* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
(- (pow B 2.0) (* (* 4.0 A) C))))(FPCore (A B C F)
:precision binary64
(let* ((t_0 (hypot B (- A C)))
(t_1 (sqrt (* F (- (+ C A) t_0))))
(t_2 (fma B B (* A (* C -4.0)))))
(if (<= B -6e+32)
(* t_1 (/ (sqrt 2.0) B))
(if (<= B 9.2e-32)
(/ (- (sqrt (* (* (+ A (- C t_0)) (* F 2.0)) t_2))) t_2)
(* t_1 (/ (- (sqrt 2.0)) B))))))double code(double A, double B, double C, double F) {
return -sqrt(((2.0 * ((pow(B, 2.0) - ((4.0 * A) * C)) * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / (pow(B, 2.0) - ((4.0 * A) * C));
}
double code(double A, double B, double C, double F) {
double t_0 = hypot(B, (A - C));
double t_1 = sqrt((F * ((C + A) - t_0)));
double t_2 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (B <= -6e+32) {
tmp = t_1 * (sqrt(2.0) / B);
} else if (B <= 9.2e-32) {
tmp = -sqrt((((A + (C - t_0)) * (F * 2.0)) * t_2)) / t_2;
} else {
tmp = t_1 * (-sqrt(2.0) / B);
}
return tmp;
}
function code(A, B, C, F) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C))) end
function code(A, B, C, F) t_0 = hypot(B, Float64(A - C)) t_1 = sqrt(Float64(F * Float64(Float64(C + A) - t_0))) t_2 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (B <= -6e+32) tmp = Float64(t_1 * Float64(sqrt(2.0) / B)); elseif (B <= 9.2e-32) tmp = Float64(Float64(-sqrt(Float64(Float64(Float64(A + Float64(C - t_0)) * Float64(F * 2.0)) * t_2))) / t_2); else tmp = Float64(t_1 * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
code[A_, B_, C_, F_] := N[((-N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[A_, B_, C_, F_] := Block[{t$95$0 = N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(F * N[(N[(C + A), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -6e+32], N[(t$95$1 * N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 9.2e-32], N[((-N[Sqrt[N[(N[(N[(A + N[(C - t$95$0), $MachinePrecision]), $MachinePrecision] * N[(F * 2.0), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision], N[(t$95$1 * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]]]]]
\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}
\begin{array}{l}
t_0 := \mathsf{hypot}\left(B, A - C\right)\\
t_1 := \sqrt{F \cdot \left(\left(C + A\right) - t_0\right)}\\
t_2 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;B \leq -6 \cdot 10^{+32}:\\
\;\;\;\;t_1 \cdot \frac{\sqrt{2}}{B}\\
\mathbf{elif}\;B \leq 9.2 \cdot 10^{-32}:\\
\;\;\;\;\frac{-\sqrt{\left(\left(A + \left(C - t_0\right)\right) \cdot \left(F \cdot 2\right)\right) \cdot t_2}}{t_2}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
if B < -6e32Initial program 57.1
Simplified55.4
[Start]57.1 | \[ \frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}
\] |
|---|
Applied egg-rr50.1
Simplified50.1
[Start]50.1 | \[ \frac{-\sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)} \cdot \sqrt{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
|---|---|
*-commutative [=>]50.1 | \[ \frac{-\color{blue}{\sqrt{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)} \cdot \sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
*-commutative [=>]50.1 | \[ \frac{-\sqrt{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)} \cdot \sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \color{blue}{\left(C \cdot -4\right)}\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
Applied egg-rr50.2
Simplified50.1
[Start]50.2 | \[ \sqrt{F \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \left(\left(-\sqrt{2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}\right) \cdot \frac{1}{\mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}\right)
\] |
|---|---|
+-commutative [=>]50.2 | \[ \sqrt{F \cdot \left(\color{blue}{\left(C + A\right)} - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \left(\left(-\sqrt{2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}\right) \cdot \frac{1}{\mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}\right)
\] |
distribute-lft-neg-out [=>]50.2 | \[ \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \color{blue}{\left(-\sqrt{2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)} \cdot \frac{1}{\mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}\right)}
\] |
associate-*r/ [=>]50.1 | \[ \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \left(-\color{blue}{\frac{\sqrt{2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)} \cdot 1}{\mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}}\right)
\] |
*-rgt-identity [=>]50.1 | \[ \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \left(-\frac{\color{blue}{\sqrt{2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}}}{\mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}\right)
\] |
distribute-frac-neg [<=]50.1 | \[ \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \color{blue}{\frac{-\sqrt{2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}}{\mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}}
\] |
associate-*r* [=>]50.1 | \[ \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \frac{-\sqrt{2 \cdot \mathsf{fma}\left(B, B, \color{blue}{\left(-4 \cdot A\right) \cdot C}\right)}}{\mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}
\] |
associate-*r* [=>]50.1 | \[ \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \frac{-\sqrt{2 \cdot \mathsf{fma}\left(B, B, \left(-4 \cdot A\right) \cdot C\right)}}{\mathsf{fma}\left(B, B, \color{blue}{\left(-4 \cdot A\right) \cdot C}\right)}
\] |
Taylor expanded in B around -inf 32.4
if -6e32 < B < 9.2000000000000002e-32Initial program 50.1
Simplified44.2
[Start]50.1 | \[ \frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}
\] |
|---|
if 9.2000000000000002e-32 < B Initial program 53.6
Simplified51.2
[Start]53.6 | \[ \frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}
\] |
|---|
Applied egg-rr47.0
Simplified47.0
[Start]47.0 | \[ \frac{-\sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)} \cdot \sqrt{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
|---|---|
*-commutative [=>]47.0 | \[ \frac{-\color{blue}{\sqrt{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)} \cdot \sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
*-commutative [=>]47.0 | \[ \frac{-\sqrt{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)} \cdot \sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \color{blue}{\left(C \cdot -4\right)}\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
Applied egg-rr47.2
Simplified47.2
[Start]47.2 | \[ \sqrt{F \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \left(\left(-\sqrt{2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}\right) \cdot \frac{1}{\mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}\right)
\] |
|---|---|
+-commutative [=>]47.2 | \[ \sqrt{F \cdot \left(\color{blue}{\left(C + A\right)} - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \left(\left(-\sqrt{2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}\right) \cdot \frac{1}{\mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}\right)
\] |
distribute-lft-neg-out [=>]47.2 | \[ \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \color{blue}{\left(-\sqrt{2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)} \cdot \frac{1}{\mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}\right)}
\] |
associate-*r/ [=>]47.2 | \[ \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \left(-\color{blue}{\frac{\sqrt{2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)} \cdot 1}{\mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}}\right)
\] |
*-rgt-identity [=>]47.2 | \[ \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \left(-\frac{\color{blue}{\sqrt{2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}}}{\mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}\right)
\] |
distribute-frac-neg [<=]47.2 | \[ \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \color{blue}{\frac{-\sqrt{2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}}{\mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}}
\] |
associate-*r* [=>]47.2 | \[ \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \frac{-\sqrt{2 \cdot \mathsf{fma}\left(B, B, \color{blue}{\left(-4 \cdot A\right) \cdot C}\right)}}{\mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}
\] |
associate-*r* [=>]47.2 | \[ \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \frac{-\sqrt{2 \cdot \mathsf{fma}\left(B, B, \left(-4 \cdot A\right) \cdot C\right)}}{\mathsf{fma}\left(B, B, \color{blue}{\left(-4 \cdot A\right) \cdot C}\right)}
\] |
Taylor expanded in B around inf 33.4
Simplified33.4
[Start]33.4 | \[ \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \left(-1 \cdot \frac{\sqrt{2}}{B}\right)
\] |
|---|---|
associate-*r/ [=>]33.4 | \[ \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \color{blue}{\frac{-1 \cdot \sqrt{2}}{B}}
\] |
mul-1-neg [=>]33.4 | \[ \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \frac{\color{blue}{-\sqrt{2}}}{B}
\] |
Final simplification38.6
| Alternative 1 | |
|---|---|
| Error | 38.4 |
| Cost | 27720 |
| Alternative 2 | |
|---|---|
| Error | 40.6 |
| Cost | 21000 |
| Alternative 3 | |
|---|---|
| Error | 40.8 |
| Cost | 20424 |
| Alternative 4 | |
|---|---|
| Error | 42.4 |
| Cost | 20228 |
| Alternative 5 | |
|---|---|
| Error | 44.1 |
| Cost | 14472 |
| Alternative 6 | |
|---|---|
| Error | 44.1 |
| Cost | 14472 |
| Alternative 7 | |
|---|---|
| Error | 45.6 |
| Cost | 13832 |
| Alternative 8 | |
|---|---|
| Error | 46.3 |
| Cost | 13832 |
| Alternative 9 | |
|---|---|
| Error | 50.2 |
| Cost | 13316 |
| Alternative 10 | |
|---|---|
| Error | 53.1 |
| Cost | 9092 |
| Alternative 11 | |
|---|---|
| Error | 55.6 |
| Cost | 8584 |
| Alternative 12 | |
|---|---|
| Error | 55.3 |
| Cost | 8584 |
| Alternative 13 | |
|---|---|
| Error | 53.2 |
| Cost | 8584 |
| Alternative 14 | |
|---|---|
| Error | 56.2 |
| Cost | 8452 |
| Alternative 15 | |
|---|---|
| Error | 57.8 |
| Cost | 7556 |
| Alternative 16 | |
|---|---|
| Error | 62.1 |
| Cost | 6848 |
herbie shell --seed 2023038
(FPCore (A B C F)
:name "ABCF->ab-angle b"
:precision binary64
(/ (- (sqrt (* (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F)) (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))) (- (pow B 2.0) (* (* 4.0 A) C))))