| Alternative 1 | |
|---|---|
| Accuracy | 53.5% |
| Cost | 149196 |

(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 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_1
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_0))
(t_2 (- (* B B) (* 4.0 (* A C)))))
(if (<= t_1 -1e-213)
(/
(*
(sqrt (+ C (+ A (hypot B (- A C)))))
(* (sqrt 2.0) (* (sqrt (fma B B (* A (* C -4.0)))) (- (sqrt F)))))
t_2)
(if (<= t_1 1e+117)
(/
(- (sqrt (* (* 2.0 (* F t_2)) (fma 2.0 C (* -0.5 (/ (* B B) A))))))
t_2)
(if (<= t_1 INFINITY)
(/
(*
(* (sqrt (* F (fma B B (* -4.0 (* A C))))) (- (sqrt 2.0)))
(sqrt (+ C C)))
t_2)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (+ A (hypot 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 = pow(B, 2.0) - ((4.0 * A) * C);
double t_1 = -sqrt(((2.0 * (t_0 * F)) * ((A + C) + sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_0;
double t_2 = (B * B) - (4.0 * (A * C));
double tmp;
if (t_1 <= -1e-213) {
tmp = (sqrt((C + (A + hypot(B, (A - C))))) * (sqrt(2.0) * (sqrt(fma(B, B, (A * (C * -4.0)))) * -sqrt(F)))) / t_2;
} else if (t_1 <= 1e+117) {
tmp = -sqrt(((2.0 * (F * t_2)) * fma(2.0, C, (-0.5 * ((B * B) / A))))) / t_2;
} else if (t_1 <= ((double) INFINITY)) {
tmp = ((sqrt((F * fma(B, B, (-4.0 * (A * C))))) * -sqrt(2.0)) * sqrt((C + C))) / t_2;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A + hypot(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 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_1 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) + sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_0) t_2 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (t_1 <= -1e-213) tmp = Float64(Float64(sqrt(Float64(C + Float64(A + hypot(B, Float64(A - C))))) * Float64(sqrt(2.0) * Float64(sqrt(fma(B, B, Float64(A * Float64(C * -4.0)))) * Float64(-sqrt(F))))) / t_2); elseif (t_1 <= 1e+117) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_2)) * fma(2.0, C, Float64(-0.5 * Float64(Float64(B * B) / A)))))) / t_2); elseif (t_1 <= Inf) tmp = Float64(Float64(Float64(sqrt(Float64(F * fma(B, B, Float64(-4.0 * Float64(A * C))))) * Float64(-sqrt(2.0))) * sqrt(Float64(C + C))) / t_2); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A + hypot(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[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-213], N[(N[(N[Sqrt[N[(C + N[(A + N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sqrt[N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[F], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[t$95$1, 1e+117], N[((-N[Sqrt[N[(N[(2.0 * N[(F * t$95$2), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(N[Sqrt[N[(F * N[(B * B + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision] * N[Sqrt[N[(C + C), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A + N[Sqrt[B ^ 2 + A ^ 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 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_1 := \frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_0}\\
t_2 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{-213}:\\
\;\;\;\;\frac{\sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \left(\sqrt{2} \cdot \left(\sqrt{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \left(-\sqrt{F}\right)\right)\right)}{t_2}\\
\mathbf{elif}\;t_1 \leq 10^{+117}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(F \cdot t_2\right)\right) \cdot \mathsf{fma}\left(2, C, -0.5 \cdot \frac{B \cdot B}{A}\right)}}{t_2}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\frac{\left(\sqrt{F \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)} \cdot \left(-\sqrt{2}\right)\right) \cdot \sqrt{C + C}}{t_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A + \mathsf{hypot}\left(B, A\right)\right)}\right)\\
\end{array}
Herbie found 19 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))) < -9.9999999999999995e-214Initial program 46.6%
Simplified46.6%
[Start]46.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}
\] |
|---|---|
associate-*l* [=>]46.6% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \color{blue}{4 \cdot \left(A \cdot C\right)}\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}
\] |
unpow2 [=>]46.6% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(\color{blue}{B \cdot B} - 4 \cdot \left(A \cdot C\right)\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}
\] |
+-commutative [=>]46.6% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{\color{blue}{{B}^{2} + {\left(A - C\right)}^{2}}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}
\] |
unpow2 [=>]46.6% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{\color{blue}{B \cdot B} + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}
\] |
associate-*l* [=>]46.6% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \color{blue}{4 \cdot \left(A \cdot C\right)}}
\] |
unpow2 [=>]46.6% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}\right)}}{\color{blue}{B \cdot B} - 4 \cdot \left(A \cdot C\right)}
\] |
Applied egg-rr66.6%
[Start]46.6% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
|---|---|
sqrt-prod [=>]52.9% | \[ \frac{-\color{blue}{\sqrt{2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)} \cdot \sqrt{\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
*-commutative [=>]52.9% | \[ \frac{-\sqrt{2 \cdot \color{blue}{\left(F \cdot \left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right)\right)}} \cdot \sqrt{\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
cancel-sign-sub-inv [=>]52.9% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \color{blue}{\left(B \cdot B + \left(-4\right) \cdot \left(A \cdot C\right)\right)}\right)} \cdot \sqrt{\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
fma-def [=>]52.9% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \color{blue}{\mathsf{fma}\left(B, B, \left(-4\right) \cdot \left(A \cdot C\right)\right)}\right)} \cdot \sqrt{\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
metadata-eval [=>]52.9% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, \color{blue}{-4} \cdot \left(A \cdot C\right)\right)\right)} \cdot \sqrt{\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
*-commutative [=>]52.9% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, -4 \cdot \color{blue}{\left(C \cdot A\right)}\right)\right)} \cdot \sqrt{\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
+-commutative [=>]52.9% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(C \cdot A\right)\right)\right)} \cdot \sqrt{\color{blue}{\left(C + A\right)} + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
unpow2 [=>]52.9% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(C \cdot A\right)\right)\right)} \cdot \sqrt{\left(C + A\right) + \sqrt{B \cdot B + \color{blue}{\left(A - C\right) \cdot \left(A - C\right)}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
hypot-udef [<=]65.9% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(C \cdot A\right)\right)\right)} \cdot \sqrt{\left(C + A\right) + \color{blue}{\mathsf{hypot}\left(B, A - C\right)}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
associate-+r+ [<=]66.6% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(C \cdot A\right)\right)\right)} \cdot \sqrt{\color{blue}{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
Applied egg-rr66.5%
[Start]66.6% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(C \cdot A\right)\right)\right)} \cdot \sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
|---|---|
sqrt-prod [=>]66.5% | \[ \frac{-\color{blue}{\left(\sqrt{2} \cdot \sqrt{F \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(C \cdot A\right)\right)}\right)} \cdot \sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
Applied egg-rr77.0%
[Start]66.5% | \[ \frac{-\left(\sqrt{2} \cdot \sqrt{F \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(C \cdot A\right)\right)}\right) \cdot \sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
|---|---|
sqrt-prod [=>]77.0% | \[ \frac{-\left(\sqrt{2} \cdot \color{blue}{\left(\sqrt{F} \cdot \sqrt{\mathsf{fma}\left(B, B, -4 \cdot \left(C \cdot A\right)\right)}\right)}\right) \cdot \sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
Simplified77.0%
[Start]77.0% | \[ \frac{-\left(\sqrt{2} \cdot \left(\sqrt{F} \cdot \sqrt{\mathsf{fma}\left(B, B, -4 \cdot \left(C \cdot A\right)\right)}\right)\right) \cdot \sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
|---|---|
associate-*r* [=>]77.0% | \[ \frac{-\left(\sqrt{2} \cdot \left(\sqrt{F} \cdot \sqrt{\mathsf{fma}\left(B, B, \color{blue}{\left(-4 \cdot C\right) \cdot A}\right)}\right)\right) \cdot \sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
if -9.9999999999999995e-214 < (/.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))) < 1.00000000000000005e117Initial program 16.3%
Simplified16.3%
[Start]16.3% | \[ \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}
\] |
|---|---|
associate-*l* [=>]16.3% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \color{blue}{4 \cdot \left(A \cdot C\right)}\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}
\] |
unpow2 [=>]16.3% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(\color{blue}{B \cdot B} - 4 \cdot \left(A \cdot C\right)\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}
\] |
+-commutative [=>]16.3% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{\color{blue}{{B}^{2} + {\left(A - C\right)}^{2}}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}
\] |
unpow2 [=>]16.3% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{\color{blue}{B \cdot B} + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}
\] |
associate-*l* [=>]16.3% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \color{blue}{4 \cdot \left(A \cdot C\right)}}
\] |
unpow2 [=>]16.3% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}\right)}}{\color{blue}{B \cdot B} - 4 \cdot \left(A \cdot C\right)}
\] |
Taylor expanded in A around -inf 41.7%
Simplified41.7%
[Start]41.7% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \left(2 \cdot C + -0.5 \cdot \frac{{B}^{2}}{A}\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
|---|---|
fma-def [=>]41.7% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \color{blue}{\mathsf{fma}\left(2, C, -0.5 \cdot \frac{{B}^{2}}{A}\right)}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
unpow2 [=>]41.7% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \mathsf{fma}\left(2, C, -0.5 \cdot \frac{\color{blue}{B \cdot B}}{A}\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
if 1.00000000000000005e117 < (/.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 10.5%
Simplified10.5%
[Start]10.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}
\] |
|---|---|
associate-*l* [=>]10.5% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \color{blue}{4 \cdot \left(A \cdot C\right)}\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}
\] |
unpow2 [=>]10.5% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(\color{blue}{B \cdot B} - 4 \cdot \left(A \cdot C\right)\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}
\] |
+-commutative [=>]10.5% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{\color{blue}{{B}^{2} + {\left(A - C\right)}^{2}}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}
\] |
unpow2 [=>]10.5% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{\color{blue}{B \cdot B} + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}
\] |
associate-*l* [=>]10.5% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \color{blue}{4 \cdot \left(A \cdot C\right)}}
\] |
unpow2 [=>]10.5% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}\right)}}{\color{blue}{B \cdot B} - 4 \cdot \left(A \cdot C\right)}
\] |
Applied egg-rr85.3%
[Start]10.5% | \[ \frac{-\sqrt{\left(2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
|---|---|
sqrt-prod [=>]24.2% | \[ \frac{-\color{blue}{\sqrt{2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right)} \cdot \sqrt{\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
*-commutative [=>]24.2% | \[ \frac{-\sqrt{2 \cdot \color{blue}{\left(F \cdot \left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right)\right)}} \cdot \sqrt{\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
cancel-sign-sub-inv [=>]24.2% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \color{blue}{\left(B \cdot B + \left(-4\right) \cdot \left(A \cdot C\right)\right)}\right)} \cdot \sqrt{\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
fma-def [=>]24.2% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \color{blue}{\mathsf{fma}\left(B, B, \left(-4\right) \cdot \left(A \cdot C\right)\right)}\right)} \cdot \sqrt{\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
metadata-eval [=>]24.2% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, \color{blue}{-4} \cdot \left(A \cdot C\right)\right)\right)} \cdot \sqrt{\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
*-commutative [=>]24.2% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, -4 \cdot \color{blue}{\left(C \cdot A\right)}\right)\right)} \cdot \sqrt{\left(A + C\right) + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
+-commutative [=>]24.2% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(C \cdot A\right)\right)\right)} \cdot \sqrt{\color{blue}{\left(C + A\right)} + \sqrt{B \cdot B + {\left(A - C\right)}^{2}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
unpow2 [=>]24.2% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(C \cdot A\right)\right)\right)} \cdot \sqrt{\left(C + A\right) + \sqrt{B \cdot B + \color{blue}{\left(A - C\right) \cdot \left(A - C\right)}}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
hypot-udef [<=]85.3% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(C \cdot A\right)\right)\right)} \cdot \sqrt{\left(C + A\right) + \color{blue}{\mathsf{hypot}\left(B, A - C\right)}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
associate-+r+ [<=]85.3% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(C \cdot A\right)\right)\right)} \cdot \sqrt{\color{blue}{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
Applied egg-rr85.5%
[Start]85.3% | \[ \frac{-\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(C \cdot A\right)\right)\right)} \cdot \sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
|---|---|
sqrt-prod [=>]85.5% | \[ \frac{-\color{blue}{\left(\sqrt{2} \cdot \sqrt{F \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(C \cdot A\right)\right)}\right)} \cdot \sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\] |
Taylor expanded in A around -inf 52.3%
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.8%
[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.8%
[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}}
\] |
distribute-rgt-neg-in [=>]1.8% | \[ \color{blue}{\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{\left(A + \sqrt{{B}^{2} + {A}^{2}}\right) \cdot F}\right)}
\] |
unpow2 [=>]1.8% | \[ \frac{\sqrt{2}}{B} \cdot \left(-\sqrt{\left(A + \sqrt{\color{blue}{B \cdot B} + {A}^{2}}\right) \cdot F}\right)
\] |
unpow2 [=>]1.8% | \[ \frac{\sqrt{2}}{B} \cdot \left(-\sqrt{\left(A + \sqrt{B \cdot B + \color{blue}{A \cdot A}}\right) \cdot F}\right)
\] |
hypot-def [=>]17.8% | \[ \frac{\sqrt{2}}{B} \cdot \left(-\sqrt{\left(A + \color{blue}{\mathsf{hypot}\left(B, A\right)}\right) \cdot F}\right)
\] |
Final simplification47.7%
| Alternative 1 | |
|---|---|
| Accuracy | 53.5% |
| Cost | 149196 |
| Alternative 2 | |
|---|---|
| Accuracy | 48.2% |
| Cost | 40520 |
| Alternative 3 | |
|---|---|
| Accuracy | 47.4% |
| Cost | 33988 |
| Alternative 4 | |
|---|---|
| Accuracy | 47.3% |
| Cost | 27716 |
| Alternative 5 | |
|---|---|
| Accuracy | 45.6% |
| Cost | 27268 |
| Alternative 6 | |
|---|---|
| Accuracy | 43.1% |
| Cost | 21128 |
| Alternative 7 | |
|---|---|
| Accuracy | 43.7% |
| Cost | 21128 |
| Alternative 8 | |
|---|---|
| Accuracy | 43.8% |
| Cost | 20168 |
| Alternative 9 | |
|---|---|
| Accuracy | 41.6% |
| Cost | 15108 |
| Alternative 10 | |
|---|---|
| Accuracy | 38.6% |
| Cost | 14788 |
| Alternative 11 | |
|---|---|
| Accuracy | 34.6% |
| Cost | 14344 |
| Alternative 12 | |
|---|---|
| Accuracy | 34.7% |
| Cost | 14344 |
| Alternative 13 | |
|---|---|
| Accuracy | 34.7% |
| Cost | 14212 |
| Alternative 14 | |
|---|---|
| Accuracy | 34.7% |
| Cost | 8584 |
| Alternative 15 | |
|---|---|
| Accuracy | 32.9% |
| Cost | 8452 |
| Alternative 16 | |
|---|---|
| Accuracy | 30.4% |
| Cost | 8192 |
| Alternative 17 | |
|---|---|
| Accuracy | 8.2% |
| Cost | 7172 |
| Alternative 18 | |
|---|---|
| Accuracy | 8.2% |
| Cost | 6980 |
| Alternative 19 | |
|---|---|
| Accuracy | 5.2% |
| Cost | 6848 |
herbie shell --seed 2023277
(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))))