| Alternative 1 | |
|---|---|
| Accuracy | 43.5% |
| Cost | 141836 |

(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 (fma B B (* A (* C -4.0))))
(t_1 (* (* 4.0 A) C))
(t_2
(/
(-
(sqrt
(*
(- (sqrt (+ (pow B 2.0) (pow (- A C) 2.0))) (+ A C))
(* 2.0 (* F (- t_1 (pow B 2.0)))))))
(- (pow B 2.0) t_1)))
(t_3 (- (* B B) (* 4.0 (* A C)))))
(if (<= t_2 -1e-191)
(/ (* (sqrt (* F (- A (hypot B A)))) (- (sqrt (* 2.0 t_0)))) t_3)
(if (<= t_2 0.0)
(/
(*
(sqrt
(*
(+ A (- A (* -0.5 (/ (- (- (* A A) (* A A)) (* B B)) C))))
(* 2.0 F)))
(- (sqrt t_0)))
t_0)
(if (<= t_2 INFINITY)
(/
(- (sqrt (* 2.0 (* 2.0 (* A (* F (+ (* B B) (* -4.0 (* A C)))))))))
t_3)
(* (/ (sqrt 2.0) B) (- (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 = fma(B, B, (A * (C * -4.0)));
double t_1 = (4.0 * A) * C;
double t_2 = -sqrt(((sqrt((pow(B, 2.0) + pow((A - C), 2.0))) - (A + C)) * (2.0 * (F * (t_1 - pow(B, 2.0)))))) / (pow(B, 2.0) - t_1);
double t_3 = (B * B) - (4.0 * (A * C));
double tmp;
if (t_2 <= -1e-191) {
tmp = (sqrt((F * (A - hypot(B, A)))) * -sqrt((2.0 * t_0))) / t_3;
} else if (t_2 <= 0.0) {
tmp = (sqrt(((A + (A - (-0.5 * ((((A * A) - (A * A)) - (B * B)) / C)))) * (2.0 * F))) * -sqrt(t_0)) / t_0;
} else if (t_2 <= ((double) INFINITY)) {
tmp = -sqrt((2.0 * (2.0 * (A * (F * ((B * B) + (-4.0 * (A * C)))))))) / t_3;
} else {
tmp = (sqrt(2.0) / B) * -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 = fma(B, B, Float64(A * Float64(C * -4.0))) t_1 = Float64(Float64(4.0 * A) * C) t_2 = Float64(Float64(-sqrt(Float64(Float64(sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))) - Float64(A + C)) * Float64(2.0 * Float64(F * Float64(t_1 - (B ^ 2.0))))))) / Float64((B ^ 2.0) - t_1)) t_3 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (t_2 <= -1e-191) tmp = Float64(Float64(sqrt(Float64(F * Float64(A - hypot(B, A)))) * Float64(-sqrt(Float64(2.0 * t_0)))) / t_3); elseif (t_2 <= 0.0) tmp = Float64(Float64(sqrt(Float64(Float64(A + Float64(A - Float64(-0.5 * Float64(Float64(Float64(Float64(A * A) - Float64(A * A)) - Float64(B * B)) / C)))) * Float64(2.0 * F))) * Float64(-sqrt(t_0))) / t_0); elseif (t_2 <= Inf) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(2.0 * Float64(A * Float64(F * Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))))))))) / t_3); else tmp = Float64(Float64(sqrt(2.0) / B) * 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[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$2 = 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[(t$95$1 - N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[Power[B, 2.0], $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e-191], N[(N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(N[(N[Sqrt[N[(N[(A + N[(A - N[(-0.5 * N[(N[(N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision] - N[(B * B), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[t$95$0], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[((-N[Sqrt[N[(2.0 * N[(2.0 * N[(A * N[(F * N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$3), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-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 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := \left(4 \cdot A\right) \cdot C\\
t_2 := \frac{-\sqrt{\left(\sqrt{{B}^{2} + {\left(A - C\right)}^{2}} - \left(A + C\right)\right) \cdot \left(2 \cdot \left(F \cdot \left(t_1 - {B}^{2}\right)\right)\right)}}{{B}^{2} - t_1}\\
t_3 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;t_2 \leq -1 \cdot 10^{-191}:\\
\;\;\;\;\frac{\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \left(-\sqrt{2 \cdot t_0}\right)}{t_3}\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\frac{\sqrt{\left(A + \left(A - -0.5 \cdot \frac{\left(A \cdot A - A \cdot A\right) - B \cdot B}{C}\right)\right) \cdot \left(2 \cdot F\right)} \cdot \left(-\sqrt{t_0}\right)}{t_0}\\
\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(2 \cdot \left(A \cdot \left(F \cdot \left(B \cdot B + -4 \cdot \left(A \cdot C\right)\right)\right)\right)\right)}}{t_3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}\right)\\
\end{array}
Herbie found 22 alternatives:
| Alternative | Accuracy | Speedup |
|---|
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))) < -1e-191Initial program 43.4%
Simplified43.4%
[Start]43.4% | \[ \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 34.7%
Simplified37.1%
[Start]34.7% | \[ \frac{-\sqrt{2 \cdot \left(\left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right) \cdot \left(A - \sqrt{{B}^{2} + {A}^{2}}\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
|---|---|
+-commutative [=>]34.7% | \[ \frac{-\sqrt{2 \cdot \left(\left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right) \cdot \left(A - \sqrt{\color{blue}{{A}^{2} + {B}^{2}}}\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
unpow2 [=>]34.7% | \[ \frac{-\sqrt{2 \cdot \left(\left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right) \cdot \left(A - \sqrt{\color{blue}{A \cdot A} + {B}^{2}}\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
unpow2 [=>]34.7% | \[ \frac{-\sqrt{2 \cdot \left(\left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right) \cdot \left(A - \sqrt{A \cdot A + \color{blue}{B \cdot B}}\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
hypot-def [=>]37.1% | \[ \frac{-\sqrt{2 \cdot \left(\left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right) \cdot \left(A - \color{blue}{\mathsf{hypot}\left(A, B\right)}\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
Applied egg-rr38.3%
[Start]37.1% | \[ \frac{-\sqrt{2 \cdot \left(\left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right) \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
|---|---|
*-un-lft-identity [=>]37.1% | \[ \frac{-\color{blue}{1 \cdot \sqrt{2 \cdot \left(\left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right) \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
associate-*l* [=>]38.3% | \[ \frac{-1 \cdot \sqrt{2 \cdot \color{blue}{\left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)\right)}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
cancel-sign-sub-inv [=>]38.3% | \[ \frac{-1 \cdot \sqrt{2 \cdot \left(\color{blue}{\left(B \cdot B + \left(-4\right) \cdot \left(A \cdot C\right)\right)} \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
metadata-eval [=>]38.3% | \[ \frac{-1 \cdot \sqrt{2 \cdot \left(\left(B \cdot B + \color{blue}{-4} \cdot \left(A \cdot C\right)\right) \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
Simplified38.3%
[Start]38.3% | \[ \frac{-1 \cdot \sqrt{2 \cdot \left(\left(B \cdot B + -4 \cdot \left(A \cdot C\right)\right) \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
|---|---|
*-lft-identity [=>]38.3% | \[ \frac{-\color{blue}{\sqrt{2 \cdot \left(\left(B \cdot B + -4 \cdot \left(A \cdot C\right)\right) \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)\right)}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
associate-*r* [=>]38.3% | \[ \frac{-\sqrt{\color{blue}{\left(2 \cdot \left(B \cdot B + -4 \cdot \left(A \cdot C\right)\right)\right) \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
fma-def [=>]38.3% | \[ \frac{-\sqrt{\left(2 \cdot \color{blue}{\mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)}\right) \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
*-commutative [=>]38.3% | \[ \frac{-\sqrt{\left(2 \cdot \mathsf{fma}\left(B, B, \color{blue}{\left(A \cdot C\right) \cdot -4}\right)\right) \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
Applied egg-rr47.9%
[Start]38.3% | \[ \frac{-\sqrt{\left(2 \cdot \mathsf{fma}\left(B, B, \left(A \cdot C\right) \cdot -4\right)\right) \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
|---|---|
sqrt-prod [=>]47.9% | \[ \frac{-\color{blue}{\sqrt{2 \cdot \mathsf{fma}\left(B, B, \left(A \cdot C\right) \cdot -4\right)} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
associate-*l* [=>]47.9% | \[ \frac{-\sqrt{2 \cdot \mathsf{fma}\left(B, B, \color{blue}{A \cdot \left(C \cdot -4\right)}\right)} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
Simplified47.9%
[Start]47.9% | \[ \frac{-\sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
|---|---|
*-commutative [=>]47.9% | \[ \frac{-\color{blue}{\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
hypot-def [<=]43.4% | \[ \frac{-\sqrt{F \cdot \left(A - \color{blue}{\sqrt{A \cdot A + B \cdot B}}\right)} \cdot \sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
unpow2 [<=]43.4% | \[ \frac{-\sqrt{F \cdot \left(A - \sqrt{\color{blue}{{A}^{2}} + B \cdot B}\right)} \cdot \sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
unpow2 [<=]43.4% | \[ \frac{-\sqrt{F \cdot \left(A - \sqrt{{A}^{2} + \color{blue}{{B}^{2}}}\right)} \cdot \sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
+-commutative [<=]43.4% | \[ \frac{-\sqrt{F \cdot \left(A - \sqrt{\color{blue}{{B}^{2} + {A}^{2}}}\right)} \cdot \sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
unpow2 [=>]43.4% | \[ \frac{-\sqrt{F \cdot \left(A - \sqrt{\color{blue}{B \cdot B} + {A}^{2}}\right)} \cdot \sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
unpow2 [=>]43.4% | \[ \frac{-\sqrt{F \cdot \left(A - \sqrt{B \cdot B + \color{blue}{A \cdot A}}\right)} \cdot \sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
hypot-def [=>]47.9% | \[ \frac{-\sqrt{F \cdot \left(A - \color{blue}{\mathsf{hypot}\left(B, A\right)}\right)} \cdot \sqrt{2 \cdot \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
if -1e-191 < (/.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))) < -0.0Initial program 3.4%
Simplified4.7%
[Start]3.4% | \[ \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-rr17.2%
[Start]4.7% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right) \cdot \left(\left(2 \cdot F\right) \cdot \left(C - \left(\mathsf{hypot}\left(B, A - C\right) - A\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
|---|---|
sqrt-prod [=>]17.8% | \[ \frac{-\color{blue}{\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)} \cdot \sqrt{\left(2 \cdot F\right) \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 [<=]17.8% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \color{blue}{\left(C \cdot -4\right)}\right)} \cdot \sqrt{\left(2 \cdot F\right) \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)}
\] |
associate--r- [=>]17.2% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(2 \cdot F\right) \cdot \color{blue}{\left(\left(C - \mathsf{hypot}\left(B, A - C\right)\right) + A\right)}}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
+-commutative [<=]17.2% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(2 \cdot F\right) \cdot \color{blue}{\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 [=>]17.2% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, 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(-4 \cdot C\right)\right)}
\] |
Simplified17.2%
[Start]17.2% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\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(-4 \cdot C\right)\right)}
\] |
|---|---|
hypot-def [<=]17.2% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(C - \color{blue}{\sqrt{B \cdot B + \left(A - C\right) \cdot \left(A - C\right)}}\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
unpow2 [<=]17.2% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(C - \sqrt{B \cdot B + \color{blue}{{\left(A - C\right)}^{2}}}\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
unpow2 [<=]17.2% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(C - \sqrt{\color{blue}{{B}^{2}} + {\left(A - C\right)}^{2}}\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
+-commutative [<=]17.2% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(C - \sqrt{\color{blue}{{\left(A - C\right)}^{2} + {B}^{2}}}\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
unpow2 [=>]17.2% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(C - \sqrt{\color{blue}{\left(A - C\right) \cdot \left(A - C\right)} + {B}^{2}}\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
unpow2 [=>]17.2% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(C - \sqrt{\left(A - C\right) \cdot \left(A - C\right) + \color{blue}{B \cdot B}}\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
hypot-def [=>]17.2% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(C - \color{blue}{\mathsf{hypot}\left(A - C, B\right)}\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
Taylor expanded in C around inf 19.2%
Simplified17.1%
[Start]19.2% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(A + -0.5 \cdot \frac{\left({B}^{2} + {A}^{2}\right) - {\left(-1 \cdot A\right)}^{2}}{C}\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
|---|---|
associate--l+ [=>]17.1% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(A + -0.5 \cdot \frac{\color{blue}{{B}^{2} + \left({A}^{2} - {\left(-1 \cdot A\right)}^{2}\right)}}{C}\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
unpow2 [=>]17.1% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(A + -0.5 \cdot \frac{\color{blue}{B \cdot B} + \left({A}^{2} - {\left(-1 \cdot A\right)}^{2}\right)}{C}\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
unpow2 [=>]17.1% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(A + -0.5 \cdot \frac{B \cdot B + \left(\color{blue}{A \cdot A} - {\left(-1 \cdot A\right)}^{2}\right)}{C}\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
unpow2 [=>]17.1% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(A + -0.5 \cdot \frac{B \cdot B + \left(A \cdot A - \color{blue}{\left(-1 \cdot A\right) \cdot \left(-1 \cdot A\right)}\right)}{C}\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
mul-1-neg [=>]17.1% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(A + -0.5 \cdot \frac{B \cdot B + \left(A \cdot A - \color{blue}{\left(-A\right)} \cdot \left(-1 \cdot A\right)\right)}{C}\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
mul-1-neg [=>]17.1% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(A + -0.5 \cdot \frac{B \cdot B + \left(A \cdot A - \left(-A\right) \cdot \color{blue}{\left(-A\right)}\right)}{C}\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
sqr-neg [=>]17.1% | \[ \frac{-\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(A + -0.5 \cdot \frac{B \cdot B + \left(A \cdot A - \color{blue}{A \cdot A}\right)}{C}\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(-4 \cdot C\right)\right)}
\] |
if -0.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))) < +inf.0Initial program 32.6%
Simplified32.6%
[Start]32.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 A around -inf 28.2%
Taylor expanded in F around 0 28.2%
Simplified28.2%
[Start]28.2% | \[ \frac{-\sqrt{2 \cdot \left(2 \cdot \left(A \cdot \left(\left({B}^{2} - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
|---|---|
cancel-sign-sub-inv [=>]28.2% | \[ \frac{-\sqrt{2 \cdot \left(2 \cdot \left(A \cdot \left(\color{blue}{\left({B}^{2} + \left(-4\right) \cdot \left(A \cdot C\right)\right)} \cdot F\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
metadata-eval [=>]28.2% | \[ \frac{-\sqrt{2 \cdot \left(2 \cdot \left(A \cdot \left(\left({B}^{2} + \color{blue}{-4} \cdot \left(A \cdot C\right)\right) \cdot F\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
unpow2 [=>]28.2% | \[ \frac{-\sqrt{2 \cdot \left(2 \cdot \left(A \cdot \left(\left(\color{blue}{B \cdot B} + -4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
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 0.0%
Simplified0.0%
[Start]0.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 1.8%
Simplified17.4%
[Start]1.8% | \[ -1 \cdot \left(\frac{\sqrt{2}}{B} \cdot \sqrt{\left(A - \sqrt{{B}^{2} + {A}^{2}}\right) \cdot F}\right)
\] |
|---|---|
mul-1-neg [=>]1.8% | \[ \color{blue}{-\frac{\sqrt{2}}{B} \cdot \sqrt{\left(A - \sqrt{{B}^{2} + {A}^{2}}\right) \cdot F}}
\] |
+-commutative [=>]1.8% | \[ -\frac{\sqrt{2}}{B} \cdot \sqrt{\left(A - \sqrt{\color{blue}{{A}^{2} + {B}^{2}}}\right) \cdot F}
\] |
unpow2 [=>]1.8% | \[ -\frac{\sqrt{2}}{B} \cdot \sqrt{\left(A - \sqrt{\color{blue}{A \cdot A} + {B}^{2}}\right) \cdot F}
\] |
unpow2 [=>]1.8% | \[ -\frac{\sqrt{2}}{B} \cdot \sqrt{\left(A - \sqrt{A \cdot A + \color{blue}{B \cdot B}}\right) \cdot F}
\] |
hypot-def [=>]17.4% | \[ -\frac{\sqrt{2}}{B} \cdot \sqrt{\left(A - \color{blue}{\mathsf{hypot}\left(A, B\right)}\right) \cdot F}
\] |
Final simplification28.6%
| Alternative 1 | |
|---|---|
| Accuracy | 43.5% |
| Cost | 141836 |
| Alternative 2 | |
|---|---|
| Accuracy | 37.4% |
| Cost | 28624 |
| Alternative 3 | |
|---|---|
| Accuracy | 35.9% |
| Cost | 27724 |
| Alternative 4 | |
|---|---|
| Accuracy | 39.3% |
| Cost | 20740 |
| Alternative 5 | |
|---|---|
| Accuracy | 35.8% |
| Cost | 14788 |
| Alternative 6 | |
|---|---|
| Accuracy | 35.1% |
| Cost | 14404 |
| Alternative 7 | |
|---|---|
| Accuracy | 34.8% |
| Cost | 13960 |
| Alternative 8 | |
|---|---|
| Accuracy | 35.1% |
| Cost | 13960 |
| Alternative 9 | |
|---|---|
| Accuracy | 35.0% |
| Cost | 13960 |
| Alternative 10 | |
|---|---|
| Accuracy | 35.0% |
| Cost | 13960 |
| Alternative 11 | |
|---|---|
| Accuracy | 34.6% |
| Cost | 13636 |
| Alternative 12 | |
|---|---|
| Accuracy | 35.2% |
| Cost | 13508 |
| Alternative 13 | |
|---|---|
| Accuracy | 35.2% |
| Cost | 13508 |
| Alternative 14 | |
|---|---|
| Accuracy | 29.9% |
| Cost | 9348 |
| Alternative 15 | |
|---|---|
| Accuracy | 22.6% |
| Cost | 8200 |
| Alternative 16 | |
|---|---|
| Accuracy | 27.0% |
| Cost | 8192 |
| Alternative 17 | |
|---|---|
| Accuracy | 22.1% |
| Cost | 8068 |
| Alternative 18 | |
|---|---|
| Accuracy | 18.2% |
| Cost | 7940 |
| Alternative 19 | |
|---|---|
| Accuracy | 18.2% |
| Cost | 7812 |
| Alternative 20 | |
|---|---|
| Accuracy | 8.9% |
| Cost | 7108 |
| Alternative 21 | |
|---|---|
| Accuracy | 5.5% |
| Cost | 6912 |
| Alternative 22 | |
|---|---|
| Accuracy | 5.4% |
| Cost | 6848 |
herbie shell --seed 2023263
(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))))