| Alternative 1 | |
|---|---|
| Error | 41.8 |
| Cost | 34776 |
(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 (* C (* -4.0 A)))
(t_2 (fma B B t_1))
(t_3 (* -4.0 (* A C)))
(t_4 (+ t_3 (* B B)))
(t_5 (sqrt (+ C (+ A t_0))))
(t_6
(/
(* t_5 (- (sqrt (+ (* (* F 2.0) (* B B)) (* (* F 2.0) t_1)))))
t_4))
(t_7 (sqrt (/ (- F) C))))
(if (<= B -1.45e+60)
(* (/ (* B (sqrt F)) (fma B B t_3)) (sqrt (* 2.0 (+ (+ A C) t_0))))
(if (<= B -2.3e-62)
t_6
(if (<= B -2.1e-111)
t_7
(if (<= B -9.5e-186)
(/ (- (sqrt (* 2.0 (* t_2 (* F (* A 2.0)))))) t_2)
(if (<= B -2.5e-261)
(/ (- (sqrt (* 2.0 (* t_2 (* F (* C 2.0)))))) t_2)
(if (<= B 2.5e-192)
(/ (* t_5 (- (sqrt (* -8.0 (* A (* F C)))))) t_4)
(if (<= B 2.3e-154)
t_7
(if (<= B 2.1e+70)
t_6
(* (/ (- (sqrt 2.0)) B) (sqrt (* F (+ B A))))))))))))))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 = C * (-4.0 * A);
double t_2 = fma(B, B, t_1);
double t_3 = -4.0 * (A * C);
double t_4 = t_3 + (B * B);
double t_5 = sqrt((C + (A + t_0)));
double t_6 = (t_5 * -sqrt((((F * 2.0) * (B * B)) + ((F * 2.0) * t_1)))) / t_4;
double t_7 = sqrt((-F / C));
double tmp;
if (B <= -1.45e+60) {
tmp = ((B * sqrt(F)) / fma(B, B, t_3)) * sqrt((2.0 * ((A + C) + t_0)));
} else if (B <= -2.3e-62) {
tmp = t_6;
} else if (B <= -2.1e-111) {
tmp = t_7;
} else if (B <= -9.5e-186) {
tmp = -sqrt((2.0 * (t_2 * (F * (A * 2.0))))) / t_2;
} else if (B <= -2.5e-261) {
tmp = -sqrt((2.0 * (t_2 * (F * (C * 2.0))))) / t_2;
} else if (B <= 2.5e-192) {
tmp = (t_5 * -sqrt((-8.0 * (A * (F * C))))) / t_4;
} else if (B <= 2.3e-154) {
tmp = t_7;
} else if (B <= 2.1e+70) {
tmp = t_6;
} else {
tmp = (-sqrt(2.0) / B) * sqrt((F * (B + A)));
}
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 = Float64(C * Float64(-4.0 * A)) t_2 = fma(B, B, t_1) t_3 = Float64(-4.0 * Float64(A * C)) t_4 = Float64(t_3 + Float64(B * B)) t_5 = sqrt(Float64(C + Float64(A + t_0))) t_6 = Float64(Float64(t_5 * Float64(-sqrt(Float64(Float64(Float64(F * 2.0) * Float64(B * B)) + Float64(Float64(F * 2.0) * t_1))))) / t_4) t_7 = sqrt(Float64(Float64(-F) / C)) tmp = 0.0 if (B <= -1.45e+60) tmp = Float64(Float64(Float64(B * sqrt(F)) / fma(B, B, t_3)) * sqrt(Float64(2.0 * Float64(Float64(A + C) + t_0)))); elseif (B <= -2.3e-62) tmp = t_6; elseif (B <= -2.1e-111) tmp = t_7; elseif (B <= -9.5e-186) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_2 * Float64(F * Float64(A * 2.0)))))) / t_2); elseif (B <= -2.5e-261) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_2 * Float64(F * Float64(C * 2.0)))))) / t_2); elseif (B <= 2.5e-192) tmp = Float64(Float64(t_5 * Float64(-sqrt(Float64(-8.0 * Float64(A * Float64(F * C)))))) / t_4); elseif (B <= 2.3e-154) tmp = t_7; elseif (B <= 2.1e+70) tmp = t_6; else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B) * sqrt(Float64(F * Float64(B + A)))); 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[(C * N[(-4.0 * A), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(B * B + t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 + N[(B * B), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(C + N[(A + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[(N[(t$95$5 * (-N[Sqrt[N[(N[(N[(F * 2.0), $MachinePrecision] * N[(B * B), $MachinePrecision]), $MachinePrecision] + N[(N[(F * 2.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$4), $MachinePrecision]}, Block[{t$95$7 = N[Sqrt[N[((-F) / C), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[B, -1.45e+60], N[(N[(N[(B * N[Sqrt[F], $MachinePrecision]), $MachinePrecision] / N[(B * B + t$95$3), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 * N[(N[(A + C), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[B, -2.3e-62], t$95$6, If[LessEqual[B, -2.1e-111], t$95$7, If[LessEqual[B, -9.5e-186], N[((-N[Sqrt[N[(2.0 * N[(t$95$2 * N[(F * N[(A * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision], If[LessEqual[B, -2.5e-261], N[((-N[Sqrt[N[(2.0 * N[(t$95$2 * N[(F * N[(C * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision], If[LessEqual[B, 2.5e-192], N[(N[(t$95$5 * (-N[Sqrt[N[(-8.0 * N[(A * N[(F * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$4), $MachinePrecision], If[LessEqual[B, 2.3e-154], t$95$7, If[LessEqual[B, 2.1e+70], t$95$6, N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision] * N[Sqrt[N[(F * N[(B + A), $MachinePrecision]), $MachinePrecision]], $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 := C \cdot \left(-4 \cdot A\right)\\
t_2 := \mathsf{fma}\left(B, B, t_1\right)\\
t_3 := -4 \cdot \left(A \cdot C\right)\\
t_4 := t_3 + B \cdot B\\
t_5 := \sqrt{C + \left(A + t_0\right)}\\
t_6 := \frac{t_5 \cdot \left(-\sqrt{\left(F \cdot 2\right) \cdot \left(B \cdot B\right) + \left(F \cdot 2\right) \cdot t_1}\right)}{t_4}\\
t_7 := \sqrt{\frac{-F}{C}}\\
\mathbf{if}\;B \leq -1.45 \cdot 10^{+60}:\\
\;\;\;\;\frac{B \cdot \sqrt{F}}{\mathsf{fma}\left(B, B, t_3\right)} \cdot \sqrt{2 \cdot \left(\left(A + C\right) + t_0\right)}\\
\mathbf{elif}\;B \leq -2.3 \cdot 10^{-62}:\\
\;\;\;\;t_6\\
\mathbf{elif}\;B \leq -2.1 \cdot 10^{-111}:\\
\;\;\;\;t_7\\
\mathbf{elif}\;B \leq -9.5 \cdot 10^{-186}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_2 \cdot \left(F \cdot \left(A \cdot 2\right)\right)\right)}}{t_2}\\
\mathbf{elif}\;B \leq -2.5 \cdot 10^{-261}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_2 \cdot \left(F \cdot \left(C \cdot 2\right)\right)\right)}}{t_2}\\
\mathbf{elif}\;B \leq 2.5 \cdot 10^{-192}:\\
\;\;\;\;\frac{t_5 \cdot \left(-\sqrt{-8 \cdot \left(A \cdot \left(F \cdot C\right)\right)}\right)}{t_4}\\
\mathbf{elif}\;B \leq 2.3 \cdot 10^{-154}:\\
\;\;\;\;t_7\\
\mathbf{elif}\;B \leq 2.1 \cdot 10^{+70}:\\
\;\;\;\;t_6\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(B + A\right)}\\
\end{array}
if B < -1.45e60Initial program 58.7
Simplified57.9
Taylor expanded in A around 0 58.1
Simplified58.0
Applied egg-rr61.4
Simplified48.3
if -1.45e60 < B < -2.3e-62 or 2.3e-154 < B < 2.10000000000000008e70Initial program 43.6
Simplified43.6
Applied egg-rr39.0
Applied egg-rr33.6
Simplified33.6
Applied egg-rr33.6
if -2.3e-62 < B < -2.0999999999999999e-111 or 2.5e-192 < B < 2.3e-154Initial program 49.3
Simplified49.3
Taylor expanded in A around inf 55.1
Applied egg-rr61.0
Simplified60.9
Taylor expanded in A around inf 53.3
Simplified53.3
if -2.0999999999999999e-111 < B < -9.4999999999999998e-186Initial program 51.6
Simplified46.6
Taylor expanded in A around inf 48.2
if -9.4999999999999998e-186 < B < -2.4999999999999999e-261Initial program 52.3
Simplified47.5
Taylor expanded in A around -inf 48.1
if -2.4999999999999999e-261 < B < 2.5e-192Initial program 52.6
Simplified52.6
Applied egg-rr48.3
Applied egg-rr43.1
Simplified43.0
Taylor expanded in B around 0 45.5
Simplified45.5
if 2.10000000000000008e70 < B Initial program 58.4
Simplified58.4
Taylor expanded in A around 0 58.7
Simplified58.7
Taylor expanded in C around 0 35.4
Simplified35.4
Final simplification41.7
| Alternative 1 | |
|---|---|
| Error | 41.8 |
| Cost | 34776 |
| Alternative 2 | |
|---|---|
| Error | 42.8 |
| Cost | 34648 |
| Alternative 3 | |
|---|---|
| Error | 42.9 |
| Cost | 34648 |
| Alternative 4 | |
|---|---|
| Error | 42.8 |
| Cost | 34648 |
| Alternative 5 | |
|---|---|
| Error | 40.5 |
| Cost | 27140 |
| Alternative 6 | |
|---|---|
| Error | 42.1 |
| Cost | 22624 |
| Alternative 7 | |
|---|---|
| Error | 42.1 |
| Cost | 22368 |
| Alternative 8 | |
|---|---|
| Error | 42.1 |
| Cost | 22368 |
| Alternative 9 | |
|---|---|
| Error | 45.0 |
| Cost | 21592 |
| Alternative 10 | |
|---|---|
| Error | 43.9 |
| Cost | 21592 |
| Alternative 11 | |
|---|---|
| Error | 43.0 |
| Cost | 21328 |
| Alternative 12 | |
|---|---|
| Error | 46.4 |
| Cost | 21264 |
| Alternative 13 | |
|---|---|
| Error | 47.0 |
| Cost | 21264 |
| Alternative 14 | |
|---|---|
| Error | 46.5 |
| Cost | 21016 |
| Alternative 15 | |
|---|---|
| Error | 46.4 |
| Cost | 20884 |
| Alternative 16 | |
|---|---|
| Error | 45.8 |
| Cost | 15704 |
| Alternative 17 | |
|---|---|
| Error | 48.5 |
| Cost | 14276 |
| Alternative 18 | |
|---|---|
| Error | 49.1 |
| Cost | 13968 |
| Alternative 19 | |
|---|---|
| Error | 49.1 |
| Cost | 13968 |
| Alternative 20 | |
|---|---|
| Error | 48.8 |
| Cost | 13712 |
| Alternative 21 | |
|---|---|
| Error | 53.6 |
| Cost | 8848 |
| Alternative 22 | |
|---|---|
| Error | 53.4 |
| Cost | 8584 |
| Alternative 23 | |
|---|---|
| Error | 53.4 |
| Cost | 8456 |
| Alternative 24 | |
|---|---|
| Error | 56.4 |
| Cost | 8324 |
| Alternative 25 | |
|---|---|
| Error | 54.7 |
| Cost | 8324 |
| Alternative 26 | |
|---|---|
| Error | 57.7 |
| Cost | 8204 |
| Alternative 27 | |
|---|---|
| Error | 56.7 |
| Cost | 7112 |
| Alternative 28 | |
|---|---|
| Error | 57.0 |
| Cost | 6980 |
| Alternative 29 | |
|---|---|
| Error | 56.7 |
| Cost | 6656 |
| Alternative 30 | |
|---|---|
| Error | 63.2 |
| Cost | 6592 |
herbie shell --seed 2022340
(FPCore (A B C F)
:name "ABCF->ab-angle a"
: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))))