| Alternative 1 | |
|---|---|
| Error | 31.3 |
| Cost | 34316 |
(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 (sqrt (+ (hypot B (- A C)) (+ C A))))
(t_1 (fma B B (* C (* A -4.0))))
(t_2 (* A (* C -4.0)))
(t_3 (fma B B t_2))
(t_4 (sqrt (/ 1.0 F)))
(t_5 (/ (sqrt 2.0) B)))
(if (<= B -1e+220)
(* (sqrt (* F (+ C (hypot B C)))) t_5)
(if (<= B -3.1e-27)
(/ t_0 (* t_4 (* B (sqrt 0.5))))
(if (<= B 1e-145)
(/ (* (sqrt (* 2.0 (* F t_3))) (- (sqrt (* C 2.0)))) t_3)
(if (<= B 3.15e-24)
(/
(-
(sqrt
(*
2.0
(*
(+ (* F (* B B)) (* F t_2))
(+ C (fma -0.5 (/ (* B B) A) C))))))
t_3)
(if (<= B 2500.0)
(*
(sqrt (* (* 2.0 (* F t_1)) (+ A (+ C (hypot (- A C) B)))))
(/ 1.0 (- t_1)))
(if (<= B 1e+295)
(/ t_0 (* t_4 (* B (- (sqrt 0.5)))))
(* t_5 (- (sqrt (* F (+ A (hypot A 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 = sqrt((hypot(B, (A - C)) + (C + A)));
double t_1 = fma(B, B, (C * (A * -4.0)));
double t_2 = A * (C * -4.0);
double t_3 = fma(B, B, t_2);
double t_4 = sqrt((1.0 / F));
double t_5 = sqrt(2.0) / B;
double tmp;
if (B <= -1e+220) {
tmp = sqrt((F * (C + hypot(B, C)))) * t_5;
} else if (B <= -3.1e-27) {
tmp = t_0 / (t_4 * (B * sqrt(0.5)));
} else if (B <= 1e-145) {
tmp = (sqrt((2.0 * (F * t_3))) * -sqrt((C * 2.0))) / t_3;
} else if (B <= 3.15e-24) {
tmp = -sqrt((2.0 * (((F * (B * B)) + (F * t_2)) * (C + fma(-0.5, ((B * B) / A), C))))) / t_3;
} else if (B <= 2500.0) {
tmp = sqrt(((2.0 * (F * t_1)) * (A + (C + hypot((A - C), B))))) * (1.0 / -t_1);
} else if (B <= 1e+295) {
tmp = t_0 / (t_4 * (B * -sqrt(0.5)));
} else {
tmp = t_5 * -sqrt((F * (A + hypot(A, 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 = sqrt(Float64(hypot(B, Float64(A - C)) + Float64(C + A))) t_1 = fma(B, B, Float64(C * Float64(A * -4.0))) t_2 = Float64(A * Float64(C * -4.0)) t_3 = fma(B, B, t_2) t_4 = sqrt(Float64(1.0 / F)) t_5 = Float64(sqrt(2.0) / B) tmp = 0.0 if (B <= -1e+220) tmp = Float64(sqrt(Float64(F * Float64(C + hypot(B, C)))) * t_5); elseif (B <= -3.1e-27) tmp = Float64(t_0 / Float64(t_4 * Float64(B * sqrt(0.5)))); elseif (B <= 1e-145) tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(F * t_3))) * Float64(-sqrt(Float64(C * 2.0)))) / t_3); elseif (B <= 3.15e-24) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(Float64(F * Float64(B * B)) + Float64(F * t_2)) * Float64(C + fma(-0.5, Float64(Float64(B * B) / A), C)))))) / t_3); elseif (B <= 2500.0) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(F * t_1)) * Float64(A + Float64(C + hypot(Float64(A - C), B))))) * Float64(1.0 / Float64(-t_1))); elseif (B <= 1e+295) tmp = Float64(t_0 / Float64(t_4 * Float64(B * Float64(-sqrt(0.5))))); else tmp = Float64(t_5 * Float64(-sqrt(Float64(F * Float64(A + hypot(A, 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[N[(N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision] + N[(C + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(B * B + t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 / F), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision]}, If[LessEqual[B, -1e+220], N[(N[Sqrt[N[(F * N[(C + N[Sqrt[B ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$5), $MachinePrecision], If[LessEqual[B, -3.1e-27], N[(t$95$0 / N[(t$95$4 * N[(B * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 1e-145], N[(N[(N[Sqrt[N[(2.0 * N[(F * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(C * 2.0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[B, 3.15e-24], N[((-N[Sqrt[N[(2.0 * N[(N[(N[(F * N[(B * B), $MachinePrecision]), $MachinePrecision] + N[(F * t$95$2), $MachinePrecision]), $MachinePrecision] * N[(C + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision] + C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$3), $MachinePrecision], If[LessEqual[B, 2500.0], N[(N[Sqrt[N[(N[(2.0 * N[(F * t$95$1), $MachinePrecision]), $MachinePrecision] * N[(A + N[(C + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 / (-t$95$1)), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 1e+295], N[(t$95$0 / N[(t$95$4 * N[(B * (-N[Sqrt[0.5], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$5 * (-N[Sqrt[N[(F * N[(A + N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $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 := \sqrt{\mathsf{hypot}\left(B, A - C\right) + \left(C + A\right)}\\
t_1 := \mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\\
t_2 := A \cdot \left(C \cdot -4\right)\\
t_3 := \mathsf{fma}\left(B, B, t_2\right)\\
t_4 := \sqrt{\frac{1}{F}}\\
t_5 := \frac{\sqrt{2}}{B}\\
\mathbf{if}\;B \leq -1 \cdot 10^{+220}:\\
\;\;\;\;\sqrt{F \cdot \left(C + \mathsf{hypot}\left(B, C\right)\right)} \cdot t_5\\
\mathbf{elif}\;B \leq -3.1 \cdot 10^{-27}:\\
\;\;\;\;\frac{t_0}{t_4 \cdot \left(B \cdot \sqrt{0.5}\right)}\\
\mathbf{elif}\;B \leq 10^{-145}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot t_3\right)} \cdot \left(-\sqrt{C \cdot 2}\right)}{t_3}\\
\mathbf{elif}\;B \leq 3.15 \cdot 10^{-24}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot \left(B \cdot B\right) + F \cdot t_2\right) \cdot \left(C + \mathsf{fma}\left(-0.5, \frac{B \cdot B}{A}, C\right)\right)\right)}}{t_3}\\
\mathbf{elif}\;B \leq 2500:\\
\;\;\;\;\sqrt{\left(2 \cdot \left(F \cdot t_1\right)\right) \cdot \left(A + \left(C + \mathsf{hypot}\left(A - C, B\right)\right)\right)} \cdot \frac{1}{-t_1}\\
\mathbf{elif}\;B \leq 10^{+295}:\\
\;\;\;\;\frac{t_0}{t_4 \cdot \left(B \cdot \left(-\sqrt{0.5}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t_5 \cdot \left(-\sqrt{F \cdot \left(A + \mathsf{hypot}\left(A, B\right)\right)}\right)\\
\end{array}
if B < -1e220Initial program 64.0
Simplified64.0
Applied egg-rr64.0
Applied egg-rr64.0
Taylor expanded in B around -inf 61.8
Taylor expanded in A around 0 64.0
Simplified31.9
if -1e220 < B < -3.0999999999999998e-27Initial program 49.3
Simplified46.1
Applied egg-rr40.5
Applied egg-rr40.5
Applied egg-rr40.5
Taylor expanded in B around -inf 26.1
if -3.0999999999999998e-27 < B < 9.99999999999999915e-146Initial program 51.5
Simplified44.4
Applied egg-rr42.1
Taylor expanded in A around -inf 36.3
if 9.99999999999999915e-146 < B < 3.1499999999999999e-24Initial program 46.3
Simplified39.6
Taylor expanded in A around -inf 36.9
Simplified36.9
Applied egg-rr36.9
if 3.1499999999999999e-24 < B < 2500Initial program 41.2
Applied egg-rr37.5
if 2500 < B < 9.9999999999999998e294Initial program 54.6
Simplified52.8
Applied egg-rr48.5
Applied egg-rr48.5
Applied egg-rr48.5
Taylor expanded in B around inf 24.9
Simplified24.9
if 9.9999999999999998e294 < B Initial program 64.0
Simplified64.0
Applied egg-rr64.0
Applied egg-rr64.0
Taylor expanded in C around 0 64.0
Simplified32.0
Final simplification31.3
| Alternative 1 | |
|---|---|
| Error | 31.3 |
| Cost | 34316 |
| Alternative 2 | |
|---|---|
| Error | 31.4 |
| Cost | 34064 |
| Alternative 3 | |
|---|---|
| Error | 31.3 |
| Cost | 28116 |
| Alternative 4 | |
|---|---|
| Error | 31.5 |
| Cost | 27532 |
| Alternative 5 | |
|---|---|
| Error | 31.8 |
| Cost | 27216 |
| Alternative 6 | |
|---|---|
| Error | 33.7 |
| Cost | 26888 |
| Alternative 7 | |
|---|---|
| Error | 39.2 |
| Cost | 20744 |
| Alternative 8 | |
|---|---|
| Error | 35.9 |
| Cost | 20680 |
| Alternative 9 | |
|---|---|
| Error | 35.1 |
| Cost | 20680 |
| Alternative 10 | |
|---|---|
| Error | 40.1 |
| Cost | 20168 |
| Alternative 11 | |
|---|---|
| Error | 38.5 |
| Cost | 20168 |
| Alternative 12 | |
|---|---|
| Error | 38.5 |
| Cost | 20168 |
| Alternative 13 | |
|---|---|
| Error | 46.0 |
| Cost | 19972 |
| Alternative 14 | |
|---|---|
| Error | 44.8 |
| Cost | 19972 |
| Alternative 15 | |
|---|---|
| Error | 50.8 |
| Cost | 14856 |
| Alternative 16 | |
|---|---|
| Error | 52.0 |
| Cost | 14800 |
| Alternative 17 | |
|---|---|
| Error | 51.2 |
| Cost | 14472 |
| Alternative 18 | |
|---|---|
| Error | 51.8 |
| Cost | 14212 |
| Alternative 19 | |
|---|---|
| Error | 60.0 |
| Cost | 13952 |
| Alternative 20 | |
|---|---|
| Error | 61.6 |
| Cost | 64 |

herbie shell --seed 2022291
(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))))