| Alternative 1 | |
|---|---|
| Error | 42.9 |
| Cost | 34252 |
(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 (hypot B (- A C)))))
(t_1
(-
(/
(sqrt
(*
(- (sqrt (+ (pow B 2.0) (pow (- A C) 2.0))) (+ A C))
(* 2.0 (* F (- (* (* 4.0 A) C) (pow B 2.0))))))
(+ (pow B 2.0) (* C (* A -4.0))))))
(t_2 (fma B B (* A (* C -4.0)))))
(if (<= t_1 -5e-201)
(/ (* (sqrt (* F t_0)) (- (sqrt (* 2.0 t_2)))) t_2)
(if (<= t_1 1e-55)
(-
(/
(sqrt
(* 2.0 (* t_2 (* F (- C (fma -1.0 C (* 0.5 (/ B (/ (- A C) B)))))))))
t_2))
(if (<= t_1 INFINITY)
(/ (* (sqrt (* t_2 t_0)) (- (sqrt (* 2.0 F)))) t_2)
(* (sqrt (* F (- A (hypot B A)))) (/ (- (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 - hypot(B, (A - C)));
double t_1 = -(sqrt(((sqrt((pow(B, 2.0) + pow((A - C), 2.0))) - (A + C)) * (2.0 * (F * (((4.0 * A) * C) - pow(B, 2.0)))))) / (pow(B, 2.0) + (C * (A * -4.0))));
double t_2 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (t_1 <= -5e-201) {
tmp = (sqrt((F * t_0)) * -sqrt((2.0 * t_2))) / t_2;
} else if (t_1 <= 1e-55) {
tmp = -(sqrt((2.0 * (t_2 * (F * (C - fma(-1.0, C, (0.5 * (B / ((A - C) / B))))))))) / t_2);
} else if (t_1 <= ((double) INFINITY)) {
tmp = (sqrt((t_2 * t_0)) * -sqrt((2.0 * F))) / t_2;
} else {
tmp = sqrt((F * (A - hypot(B, A)))) * (-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 - hypot(B, Float64(A - C)))) t_1 = Float64(-Float64(sqrt(Float64(Float64(sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))) - Float64(A + C)) * Float64(2.0 * Float64(F * Float64(Float64(Float64(4.0 * A) * C) - (B ^ 2.0)))))) / Float64((B ^ 2.0) + Float64(C * Float64(A * -4.0))))) t_2 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (t_1 <= -5e-201) tmp = Float64(Float64(sqrt(Float64(F * t_0)) * Float64(-sqrt(Float64(2.0 * t_2)))) / t_2); elseif (t_1 <= 1e-55) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(t_2 * Float64(F * Float64(C - fma(-1.0, C, Float64(0.5 * Float64(B / Float64(Float64(A - C) / B))))))))) / t_2)); elseif (t_1 <= Inf) tmp = Float64(Float64(sqrt(Float64(t_2 * t_0)) * Float64(-sqrt(Float64(2.0 * F)))) / t_2); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B, A)))) * 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 - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = (-N[(N[Sqrt[N[(N[(N[Sqrt[N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(A + C), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(F * N[(N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision] - N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[Power[B, 2.0], $MachinePrecision] + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])}, Block[{t$95$2 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-201], N[(N[(N[Sqrt[N[(F * t$95$0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(2.0 * t$95$2), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[t$95$1, 1e-55], (-N[(N[Sqrt[N[(2.0 * N[(t$95$2 * N[(F * N[(C - N[(-1.0 * C + N[(0.5 * N[(B / N[(N[(A - C), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision]), If[LessEqual[t$95$1, Infinity], N[(N[(N[Sqrt[N[(t$95$2 * t$95$0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(2.0 * F), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$2), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 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 + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\\
t_1 := -\frac{\sqrt{\left(\sqrt{{B}^{2} + {\left(A - C\right)}^{2}} - \left(A + C\right)\right) \cdot \left(2 \cdot \left(F \cdot \left(\left(4 \cdot A\right) \cdot C - {B}^{2}\right)\right)\right)}}{{B}^{2} + C \cdot \left(A \cdot -4\right)}\\
t_2 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{-201}:\\
\;\;\;\;\frac{\sqrt{F \cdot t_0} \cdot \left(-\sqrt{2 \cdot t_2}\right)}{t_2}\\
\mathbf{elif}\;t_1 \leq 10^{-55}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(t_2 \cdot \left(F \cdot \left(C - \mathsf{fma}\left(-1, C, 0.5 \cdot \frac{B}{\frac{A - C}{B}}\right)\right)\right)\right)}}{t_2}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\frac{\sqrt{t_2 \cdot t_0} \cdot \left(-\sqrt{2 \cdot F}\right)}{t_2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -4.9999999999999999e-201Initial program 38.1
Simplified32.0
[Start]38.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-rr21.5
Simplified21.6
[Start]21.5 | \[ \frac{-\sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)} \cdot \sqrt{F \cdot \left(C - \left(\mathsf{hypot}\left(B, A - C\right) - A\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
|---|---|
*-commutative [=>]21.5 | \[ \frac{-\color{blue}{\sqrt{F \cdot \left(C - \left(\mathsf{hypot}\left(B, A - C\right) - A\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)}
\] |
associate--r- [=>]21.6 | \[ \frac{-\sqrt{F \cdot \color{blue}{\left(\left(C - \mathsf{hypot}\left(B, A - C\right)\right) + A\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 [=>]21.6 | \[ \frac{-\sqrt{F \cdot \left(\left(C - \mathsf{hypot}\left(B, A - C\right)\right) + A\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)}
\] |
if -4.9999999999999999e-201 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < 9.99999999999999995e-56Initial program 57.6
Simplified54.5
[Start]57.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}
\] |
|---|
Taylor expanded in B around 0 43.5
Simplified43.5
[Start]43.5 | \[ \frac{-\sqrt{2 \cdot \left(\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right) \cdot \left(F \cdot \left(C - \left(-1 \cdot C + 0.5 \cdot \frac{{B}^{2}}{A - C}\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
|---|---|
fma-def [=>]43.5 | \[ \frac{-\sqrt{2 \cdot \left(\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right) \cdot \left(F \cdot \left(C - \color{blue}{\mathsf{fma}\left(-1, C, 0.5 \cdot \frac{{B}^{2}}{A - C}\right)}\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
unpow2 [=>]43.5 | \[ \frac{-\sqrt{2 \cdot \left(\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right) \cdot \left(F \cdot \left(C - \mathsf{fma}\left(-1, C, 0.5 \cdot \frac{\color{blue}{B \cdot B}}{A - C}\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
associate-/l* [=>]43.5 | \[ \frac{-\sqrt{2 \cdot \left(\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right) \cdot \left(F \cdot \left(C - \mathsf{fma}\left(-1, C, 0.5 \cdot \color{blue}{\frac{B}{\frac{A - C}{B}}}\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
if 9.99999999999999995e-56 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < +inf.0Initial program 42.7
Simplified30.3
[Start]42.7 | \[ \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-rr30.1
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) Initial program 64.0
Simplified64.0
[Start]64.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}
\] |
|---|
Taylor expanded in C around 0 63.7
Simplified63.7
[Start]63.7 | \[ \frac{-\sqrt{\left(A - \sqrt{{B}^{2} + {A}^{2}}\right) \cdot F} \cdot \left(\sqrt{2} \cdot B\right)}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
|---|---|
*-commutative [=>]63.7 | \[ \frac{-\sqrt{\color{blue}{F \cdot \left(A - \sqrt{{B}^{2} + {A}^{2}}\right)}} \cdot \left(\sqrt{2} \cdot B\right)}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
unpow2 [=>]63.7 | \[ \frac{-\sqrt{F \cdot \left(A - \sqrt{\color{blue}{B \cdot B} + {A}^{2}}\right)} \cdot \left(\sqrt{2} \cdot B\right)}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
unpow2 [=>]63.7 | \[ \frac{-\sqrt{F \cdot \left(A - \sqrt{B \cdot B + \color{blue}{A \cdot A}}\right)} \cdot \left(\sqrt{2} \cdot B\right)}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
*-commutative [=>]63.7 | \[ \frac{-\sqrt{F \cdot \left(A - \sqrt{B \cdot B + A \cdot A}\right)} \cdot \color{blue}{\left(B \cdot \sqrt{2}\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
Taylor expanded in C around 0 63.6
Simplified52.7
[Start]63.6 | \[ -1 \cdot \left(\sqrt{\left(A - \sqrt{{B}^{2} + {A}^{2}}\right) \cdot F} \cdot \frac{\sqrt{2}}{B}\right)
\] |
|---|---|
associate-*r* [=>]63.6 | \[ \color{blue}{\left(-1 \cdot \sqrt{\left(A - \sqrt{{B}^{2} + {A}^{2}}\right) \cdot F}\right) \cdot \frac{\sqrt{2}}{B}}
\] |
*-commutative [=>]63.6 | \[ \left(-1 \cdot \sqrt{\color{blue}{F \cdot \left(A - \sqrt{{B}^{2} + {A}^{2}}\right)}}\right) \cdot \frac{\sqrt{2}}{B}
\] |
unpow2 [=>]63.6 | \[ \left(-1 \cdot \sqrt{F \cdot \left(A - \sqrt{\color{blue}{B \cdot B} + {A}^{2}}\right)}\right) \cdot \frac{\sqrt{2}}{B}
\] |
unpow2 [=>]63.6 | \[ \left(-1 \cdot \sqrt{F \cdot \left(A - \sqrt{B \cdot B + \color{blue}{A \cdot A}}\right)}\right) \cdot \frac{\sqrt{2}}{B}
\] |
neg-mul-1 [<=]63.6 | \[ \color{blue}{\left(-\sqrt{F \cdot \left(A - \sqrt{B \cdot B + A \cdot A}\right)}\right)} \cdot \frac{\sqrt{2}}{B}
\] |
*-commutative [=>]63.6 | \[ \color{blue}{\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \sqrt{B \cdot B + A \cdot A}\right)}\right)}
\] |
unpow2 [<=]63.6 | \[ \frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \sqrt{\color{blue}{{B}^{2}} + A \cdot A}\right)}\right)
\] |
unpow2 [<=]63.6 | \[ \frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \sqrt{{B}^{2} + \color{blue}{{A}^{2}}}\right)}\right)
\] |
Final simplification38.9
| Alternative 1 | |
|---|---|
| Error | 42.9 |
| Cost | 34252 |
| Alternative 2 | |
|---|---|
| Error | 45.2 |
| Cost | 28556 |
| Alternative 3 | |
|---|---|
| Error | 43.2 |
| Cost | 28112 |
| Alternative 4 | |
|---|---|
| Error | 43.2 |
| Cost | 27984 |
| Alternative 5 | |
|---|---|
| Error | 43.2 |
| Cost | 27984 |
| Alternative 6 | |
|---|---|
| Error | 43.2 |
| Cost | 27984 |
| Alternative 7 | |
|---|---|
| Error | 48.3 |
| Cost | 27268 |
| Alternative 8 | |
|---|---|
| Error | 45.5 |
| Cost | 21000 |
| Alternative 9 | |
|---|---|
| Error | 45.6 |
| Cost | 20612 |
| Alternative 10 | |
|---|---|
| Error | 45.6 |
| Cost | 20168 |
| Alternative 11 | |
|---|---|
| Error | 45.7 |
| Cost | 20168 |
| Alternative 12 | |
|---|---|
| Error | 46.3 |
| Cost | 15500 |
| Alternative 13 | |
|---|---|
| Error | 46.7 |
| Cost | 14984 |
| Alternative 14 | |
|---|---|
| Error | 46.6 |
| Cost | 14472 |
| Alternative 15 | |
|---|---|
| Error | 47.5 |
| Cost | 14344 |
| Alternative 16 | |
|---|---|
| Error | 48.0 |
| Cost | 14216 |
| Alternative 17 | |
|---|---|
| Error | 47.5 |
| Cost | 14216 |
| Alternative 18 | |
|---|---|
| Error | 50.8 |
| Cost | 14088 |
| Alternative 19 | |
|---|---|
| Error | 48.8 |
| Cost | 14020 |
| Alternative 20 | |
|---|---|
| Error | 50.1 |
| Cost | 13704 |
| Alternative 21 | |
|---|---|
| Error | 55.0 |
| Cost | 8584 |
| Alternative 22 | |
|---|---|
| Error | 56.1 |
| Cost | 8452 |
| Alternative 23 | |
|---|---|
| Error | 59.3 |
| Cost | 8320 |
| Alternative 24 | |
|---|---|
| Error | 61.8 |
| Cost | 7808 |
| Alternative 25 | |
|---|---|
| Error | 62.6 |
| Cost | 7680 |
| Alternative 26 | |
|---|---|
| Error | 63.0 |
| Cost | 7296 |
herbie shell --seed 2023187
(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))))