| Alternative 1 | |
|---|---|
| Error | 39.2 |
| Cost | 34516 |
(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 (* A (* C -4.0)))
(t_1 (hypot B (- A C)))
(t_2 (sqrt (* F (- (+ A C) t_1))))
(t_3 (* (- A (- t_1 C)) (* F 2.0)))
(t_4 (fma B B t_0)))
(if (<= B -4.7e+17)
(* t_2 (/ (sqrt 2.0) B))
(if (<= B -4.7e-122)
(/ (- (sqrt (* t_3 t_4))) t_4)
(if (<= B -7.5e-136)
(/ (* (sqrt t_3) (- (hypot B (sqrt t_0)))) t_4)
(if (<= B 5.5e-288)
(sqrt (- (/ F A)))
(if (<= B 2.25e-129)
(* (sqrt (* F (+ A A))) (* (sqrt (* 2.0 t_4)) (/ -1.0 t_4)))
(if (<= B 3.8e-103)
(/ (- (sqrt (* 2.0 (* t_4 (* F (+ C (- A t_1))))))) t_4)
(* t_2 (/ (- (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 = A * (C * -4.0);
double t_1 = hypot(B, (A - C));
double t_2 = sqrt((F * ((A + C) - t_1)));
double t_3 = (A - (t_1 - C)) * (F * 2.0);
double t_4 = fma(B, B, t_0);
double tmp;
if (B <= -4.7e+17) {
tmp = t_2 * (sqrt(2.0) / B);
} else if (B <= -4.7e-122) {
tmp = -sqrt((t_3 * t_4)) / t_4;
} else if (B <= -7.5e-136) {
tmp = (sqrt(t_3) * -hypot(B, sqrt(t_0))) / t_4;
} else if (B <= 5.5e-288) {
tmp = sqrt(-(F / A));
} else if (B <= 2.25e-129) {
tmp = sqrt((F * (A + A))) * (sqrt((2.0 * t_4)) * (-1.0 / t_4));
} else if (B <= 3.8e-103) {
tmp = -sqrt((2.0 * (t_4 * (F * (C + (A - t_1)))))) / t_4;
} else {
tmp = t_2 * (-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 = Float64(A * Float64(C * -4.0)) t_1 = hypot(B, Float64(A - C)) t_2 = sqrt(Float64(F * Float64(Float64(A + C) - t_1))) t_3 = Float64(Float64(A - Float64(t_1 - C)) * Float64(F * 2.0)) t_4 = fma(B, B, t_0) tmp = 0.0 if (B <= -4.7e+17) tmp = Float64(t_2 * Float64(sqrt(2.0) / B)); elseif (B <= -4.7e-122) tmp = Float64(Float64(-sqrt(Float64(t_3 * t_4))) / t_4); elseif (B <= -7.5e-136) tmp = Float64(Float64(sqrt(t_3) * Float64(-hypot(B, sqrt(t_0)))) / t_4); elseif (B <= 5.5e-288) tmp = sqrt(Float64(-Float64(F / A))); elseif (B <= 2.25e-129) tmp = Float64(sqrt(Float64(F * Float64(A + A))) * Float64(sqrt(Float64(2.0 * t_4)) * Float64(-1.0 / t_4))); elseif (B <= 3.8e-103) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_4 * Float64(F * Float64(C + Float64(A - t_1))))))) / t_4); else tmp = Float64(t_2 * 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[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(F * N[(N[(A + C), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(A - N[(t$95$1 - C), $MachinePrecision]), $MachinePrecision] * N[(F * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(B * B + t$95$0), $MachinePrecision]}, If[LessEqual[B, -4.7e+17], N[(t$95$2 * N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, -4.7e-122], N[((-N[Sqrt[N[(t$95$3 * t$95$4), $MachinePrecision]], $MachinePrecision]) / t$95$4), $MachinePrecision], If[LessEqual[B, -7.5e-136], N[(N[(N[Sqrt[t$95$3], $MachinePrecision] * (-N[Sqrt[B ^ 2 + N[Sqrt[t$95$0], $MachinePrecision] ^ 2], $MachinePrecision])), $MachinePrecision] / t$95$4), $MachinePrecision], If[LessEqual[B, 5.5e-288], N[Sqrt[(-N[(F / A), $MachinePrecision])], $MachinePrecision], If[LessEqual[B, 2.25e-129], N[(N[Sqrt[N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(2.0 * t$95$4), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 3.8e-103], N[((-N[Sqrt[N[(2.0 * N[(t$95$4 * N[(F * N[(C + N[(A - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$4), $MachinePrecision], N[(t$95$2 * 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 := A \cdot \left(C \cdot -4\right)\\
t_1 := \mathsf{hypot}\left(B, A - C\right)\\
t_2 := \sqrt{F \cdot \left(\left(A + C\right) - t_1\right)}\\
t_3 := \left(A - \left(t_1 - C\right)\right) \cdot \left(F \cdot 2\right)\\
t_4 := \mathsf{fma}\left(B, B, t_0\right)\\
\mathbf{if}\;B \leq -4.7 \cdot 10^{+17}:\\
\;\;\;\;t_2 \cdot \frac{\sqrt{2}}{B}\\
\mathbf{elif}\;B \leq -4.7 \cdot 10^{-122}:\\
\;\;\;\;\frac{-\sqrt{t_3 \cdot t_4}}{t_4}\\
\mathbf{elif}\;B \leq -7.5 \cdot 10^{-136}:\\
\;\;\;\;\frac{\sqrt{t_3} \cdot \left(-\mathsf{hypot}\left(B, \sqrt{t_0}\right)\right)}{t_4}\\
\mathbf{elif}\;B \leq 5.5 \cdot 10^{-288}:\\
\;\;\;\;\sqrt{-\frac{F}{A}}\\
\mathbf{elif}\;B \leq 2.25 \cdot 10^{-129}:\\
\;\;\;\;\sqrt{F \cdot \left(A + A\right)} \cdot \left(\sqrt{2 \cdot t_4} \cdot \frac{-1}{t_4}\right)\\
\mathbf{elif}\;B \leq 3.8 \cdot 10^{-103}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_4 \cdot \left(F \cdot \left(C + \left(A - t_1\right)\right)\right)\right)}}{t_4}\\
\mathbf{else}:\\
\;\;\;\;t_2 \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
if B < -4.7e17Initial program 55.0
Simplified53.5
[Start]55.0 | \[ \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.7
Simplified47.7
[Start]47.7 | \[ \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.7 | \[ \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.7 | \[ \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.8
Taylor expanded in B around -inf 30.9
if -4.7e17 < B < -4.6999999999999999e-122Initial program 45.5
Simplified39.7
[Start]45.5 | \[ \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 -4.6999999999999999e-122 < B < -7.5000000000000003e-136Initial program 51.1
Simplified45.1
[Start]51.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-rr53.1
Simplified51.9
[Start]53.1 | \[ \frac{-\mathsf{hypot}\left(B, \sqrt{A \cdot \left(C \cdot -4\right)}\right) \cdot \sqrt{\left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}
\] |
|---|---|
associate--l+ [=>]51.9 | \[ \frac{-\mathsf{hypot}\left(B, \sqrt{A \cdot \left(C \cdot -4\right)}\right) \cdot \sqrt{\color{blue}{\left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)} \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}
\] |
if -7.5000000000000003e-136 < B < 5.5e-288Initial program 53.1
Simplified46.6
[Start]53.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-rr58.3
Taylor expanded in B around 0 50.1
Simplified50.1
[Start]50.1 | \[ \sqrt{-1 \cdot \frac{F}{A}}
\] |
|---|---|
mul-1-neg [=>]50.1 | \[ \sqrt{\color{blue}{-\frac{F}{A}}}
\] |
if 5.5e-288 < B < 2.25000000000000015e-129Initial program 52.6
Simplified46.5
[Start]52.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-rr52.0
Simplified52.0
[Start]52.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 [=>]52.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 [=>]52.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-rr53.0
Taylor expanded in C around inf 54.9
Simplified54.9
[Start]54.9 | \[ \sqrt{\left(A - -1 \cdot A\right) \cdot F} \cdot \left(\left(-\sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\right) \cdot \frac{1}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\right)
\] |
|---|---|
*-commutative [=>]54.9 | \[ \sqrt{\color{blue}{F \cdot \left(A - -1 \cdot A\right)}} \cdot \left(\left(-\sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\right) \cdot \frac{1}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\right)
\] |
sub-neg [=>]54.9 | \[ \sqrt{F \cdot \color{blue}{\left(A + \left(--1 \cdot A\right)\right)}} \cdot \left(\left(-\sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\right) \cdot \frac{1}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\right)
\] |
mul-1-neg [=>]54.9 | \[ \sqrt{F \cdot \left(A + \left(-\color{blue}{\left(-A\right)}\right)\right)} \cdot \left(\left(-\sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\right) \cdot \frac{1}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\right)
\] |
remove-double-neg [=>]54.9 | \[ \sqrt{F \cdot \left(A + \color{blue}{A}\right)} \cdot \left(\left(-\sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\right) \cdot \frac{1}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\right)
\] |
if 2.25000000000000015e-129 < B < 3.8000000000000001e-103Initial program 48.5
Simplified43.4
[Start]48.5 | \[ \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 3.8000000000000001e-103 < B Initial program 52.1
Simplified49.4
[Start]52.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-rr46.6
Simplified46.6
[Start]46.6 | \[ \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 [=>]46.6 | \[ \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 [=>]46.6 | \[ \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-rr46.8
Taylor expanded in B around inf 35.3
Simplified35.3
[Start]35.3 | \[ \sqrt{F \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \left(-1 \cdot \frac{\sqrt{2}}{B}\right)
\] |
|---|---|
mul-1-neg [=>]35.3 | \[ \sqrt{F \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \color{blue}{\left(-\frac{\sqrt{2}}{B}\right)}
\] |
distribute-neg-frac [=>]35.3 | \[ \sqrt{F \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \color{blue}{\frac{-\sqrt{2}}{B}}
\] |
Final simplification40.1
| Alternative 1 | |
|---|---|
| Error | 39.2 |
| Cost | 34516 |
| Alternative 2 | |
|---|---|
| Error | 40.6 |
| Cost | 28248 |
| Alternative 3 | |
|---|---|
| Error | 40.3 |
| Cost | 28248 |
| Alternative 4 | |
|---|---|
| Error | 41.3 |
| Cost | 27596 |
| Alternative 5 | |
|---|---|
| Error | 41.3 |
| Cost | 27532 |
| Alternative 6 | |
|---|---|
| Error | 40.8 |
| Cost | 20424 |
| Alternative 7 | |
|---|---|
| Error | 41.8 |
| Cost | 20228 |
| Alternative 8 | |
|---|---|
| Error | 48.0 |
| Cost | 20168 |
| Alternative 9 | |
|---|---|
| Error | 48.9 |
| Cost | 13832 |
| Alternative 10 | |
|---|---|
| Error | 48.9 |
| Cost | 13704 |
| Alternative 11 | |
|---|---|
| Error | 48.8 |
| Cost | 13640 |
| Alternative 12 | |
|---|---|
| Error | 53.6 |
| Cost | 13584 |
| Alternative 13 | |
|---|---|
| Error | 54.4 |
| Cost | 8848 |
| Alternative 14 | |
|---|---|
| Error | 53.6 |
| Cost | 8584 |
| Alternative 15 | |
|---|---|
| Error | 53.6 |
| Cost | 7053 |
| Alternative 16 | |
|---|---|
| Error | 56.3 |
| Cost | 6656 |
| Alternative 17 | |
|---|---|
| Error | 63.3 |
| Cost | 6592 |
herbie shell --seed 2023059
(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))))