
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
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]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * 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]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
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]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * 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]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0))))
(t_1 (- (sqrt 2.0)))
(t_2 (fma A (* C -4.0) (pow B 2.0))))
(if (<= B 4.9e-115)
(/ (* (sqrt (* t_2 (* F (* A 2.0)))) t_1) t_2)
(if (<= B 9e+36)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A (- C (hypot B (- A C))))))))) t_0)
(if (<= B 1.28e+64)
(/
(*
(pow (* 2.0 t_0) 0.5)
(-
(sqrt
(*
F
(+
A
(+
A
(*
-0.5
(/ (+ (pow A 2.0) (- (pow B 2.0) (pow A 2.0))) C))))))))
t_0)
(* (sqrt (* F (- A (hypot B A)))) (/ t_1 B)))))))B = abs(B);
assert(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 = -sqrt(2.0);
double t_2 = fma(A, (C * -4.0), pow(B, 2.0));
double tmp;
if (B <= 4.9e-115) {
tmp = (sqrt((t_2 * (F * (A * 2.0)))) * t_1) / t_2;
} else if (B <= 9e+36) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + (C - hypot(B, (A - C)))))))) / t_0;
} else if (B <= 1.28e+64) {
tmp = (pow((2.0 * t_0), 0.5) * -sqrt((F * (A + (A + (-0.5 * ((pow(A, 2.0) + (pow(B, 2.0) - pow(A, 2.0))) / C))))))) / t_0;
} else {
tmp = sqrt((F * (A - hypot(B, A)))) * (t_1 / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) t_1 = Float64(-sqrt(2.0)) t_2 = fma(A, Float64(C * -4.0), (B ^ 2.0)) tmp = 0.0 if (B <= 4.9e-115) tmp = Float64(Float64(sqrt(Float64(t_2 * Float64(F * Float64(A * 2.0)))) * t_1) / t_2); elseif (B <= 9e+36) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C))))))))) / t_0); elseif (B <= 1.28e+64) tmp = Float64(Float64((Float64(2.0 * t_0) ^ 0.5) * Float64(-sqrt(Float64(F * Float64(A + Float64(A + Float64(-0.5 * Float64(Float64((A ^ 2.0) + Float64((B ^ 2.0) - (A ^ 2.0))) / C)))))))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B, A)))) * Float64(t_1 / B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
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[Sqrt[2.0], $MachinePrecision])}, Block[{t$95$2 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 4.9e-115], N[(N[(N[Sqrt[N[(t$95$2 * N[(F * N[(A * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[B, 9e+36], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 1.28e+64], N[(N[(N[Power[N[(2.0 * t$95$0), $MachinePrecision], 0.5], $MachinePrecision] * (-N[Sqrt[N[(F * N[(A + N[(A + N[(-0.5 * N[(N[(N[Power[A, 2.0], $MachinePrecision] + N[(N[Power[B, 2.0], $MachinePrecision] - N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(t$95$1 / B), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := -\sqrt{2}\\
t_2 := \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)\\
\mathbf{if}\;B \leq 4.9 \cdot 10^{-115}:\\
\;\;\;\;\frac{\sqrt{t_2 \cdot \left(F \cdot \left(A \cdot 2\right)\right)} \cdot t_1}{t_2}\\
\mathbf{elif}\;B \leq 9 \cdot 10^{+36}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 1.28 \cdot 10^{+64}:\\
\;\;\;\;\frac{{\left(2 \cdot t_0\right)}^{0.5} \cdot \left(-\sqrt{F \cdot \left(A + \left(A + -0.5 \cdot \frac{{A}^{2} + \left({B}^{2} - {A}^{2}\right)}{C}\right)\right)}\right)}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \frac{t_1}{B}\\
\end{array}
\end{array}
if B < 4.89999999999999989e-115Initial program 14.9%
Simplified20.9%
Taylor expanded in C around inf 14.3%
sub-neg14.3%
mul-1-neg14.3%
remove-double-neg14.3%
Simplified14.3%
pow1/214.5%
*-commutative14.5%
unpow-prod-down14.5%
pow1/214.3%
associate-*l*14.8%
count-214.8%
pow1/214.8%
Applied egg-rr14.8%
if 4.89999999999999989e-115 < B < 8.99999999999999994e36Initial program 38.7%
Simplified45.7%
associate--l+46.0%
Applied egg-rr46.0%
if 8.99999999999999994e36 < B < 1.28000000000000004e64Initial program 34.9%
Simplified35.4%
pow1/235.4%
associate-*r*35.4%
unpow-prod-down67.3%
pow1/267.3%
associate--l+67.3%
Applied egg-rr67.3%
Taylor expanded in C around inf 66.1%
associate--l+66.1%
unpow266.1%
mul-1-neg66.1%
mul-1-neg66.1%
sqr-neg66.1%
unpow266.1%
Simplified66.1%
if 1.28000000000000004e64 < B Initial program 9.1%
Simplified9.2%
Taylor expanded in C around 0 12.9%
mul-1-neg12.9%
*-commutative12.9%
distribute-rgt-neg-in12.9%
+-commutative12.9%
unpow212.9%
unpow212.9%
hypot-def44.1%
Simplified44.1%
Final simplification24.7%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0))))
(t_1 (- (sqrt 2.0)))
(t_2 (fma B B (* -4.0 (* A C))))
(t_3 (fma A (* C -4.0) (pow B 2.0))))
(if (<= B 4.9e-115)
(/ (* (sqrt (* t_3 (* F (* A 2.0)))) t_1) t_3)
(if (<= B 1.02e+23)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A (- C (hypot B (- A C))))))))) t_0)
(if (<= B 1.2e+67)
(*
(sqrt
(*
(+
A
(+ A (* -0.5 (/ (+ (pow A 2.0) (- (pow B 2.0) (pow A 2.0))) C))))
(* 2.0 (* F t_2))))
(/ -1.0 t_2))
(* (sqrt (* F (- A (hypot B A)))) (/ t_1 B)))))))B = abs(B);
assert(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 = -sqrt(2.0);
double t_2 = fma(B, B, (-4.0 * (A * C)));
double t_3 = fma(A, (C * -4.0), pow(B, 2.0));
double tmp;
if (B <= 4.9e-115) {
tmp = (sqrt((t_3 * (F * (A * 2.0)))) * t_1) / t_3;
} else if (B <= 1.02e+23) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + (C - hypot(B, (A - C)))))))) / t_0;
} else if (B <= 1.2e+67) {
tmp = sqrt(((A + (A + (-0.5 * ((pow(A, 2.0) + (pow(B, 2.0) - pow(A, 2.0))) / C)))) * (2.0 * (F * t_2)))) * (-1.0 / t_2);
} else {
tmp = sqrt((F * (A - hypot(B, A)))) * (t_1 / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) t_1 = Float64(-sqrt(2.0)) t_2 = fma(B, B, Float64(-4.0 * Float64(A * C))) t_3 = fma(A, Float64(C * -4.0), (B ^ 2.0)) tmp = 0.0 if (B <= 4.9e-115) tmp = Float64(Float64(sqrt(Float64(t_3 * Float64(F * Float64(A * 2.0)))) * t_1) / t_3); elseif (B <= 1.02e+23) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C))))))))) / t_0); elseif (B <= 1.2e+67) tmp = Float64(sqrt(Float64(Float64(A + Float64(A + Float64(-0.5 * Float64(Float64((A ^ 2.0) + Float64((B ^ 2.0) - (A ^ 2.0))) / C)))) * Float64(2.0 * Float64(F * t_2)))) * Float64(-1.0 / t_2)); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B, A)))) * Float64(t_1 / B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
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[Sqrt[2.0], $MachinePrecision])}, Block[{t$95$2 = N[(B * B + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 4.9e-115], N[(N[(N[Sqrt[N[(t$95$3 * N[(F * N[(A * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[B, 1.02e+23], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 1.2e+67], N[(N[Sqrt[N[(N[(A + N[(A + N[(-0.5 * N[(N[(N[Power[A, 2.0], $MachinePrecision] + N[(N[Power[B, 2.0], $MachinePrecision] - N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(F * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$2), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(t$95$1 / B), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := -\sqrt{2}\\
t_2 := \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)\\
t_3 := \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)\\
\mathbf{if}\;B \leq 4.9 \cdot 10^{-115}:\\
\;\;\;\;\frac{\sqrt{t_3 \cdot \left(F \cdot \left(A \cdot 2\right)\right)} \cdot t_1}{t_3}\\
\mathbf{elif}\;B \leq 1.02 \cdot 10^{+23}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 1.2 \cdot 10^{+67}:\\
\;\;\;\;\sqrt{\left(A + \left(A + -0.5 \cdot \frac{{A}^{2} + \left({B}^{2} - {A}^{2}\right)}{C}\right)\right) \cdot \left(2 \cdot \left(F \cdot t_2\right)\right)} \cdot \frac{-1}{t_2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \frac{t_1}{B}\\
\end{array}
\end{array}
if B < 4.89999999999999989e-115Initial program 14.9%
Simplified20.9%
Taylor expanded in C around inf 14.3%
sub-neg14.3%
mul-1-neg14.3%
remove-double-neg14.3%
Simplified14.3%
pow1/214.5%
*-commutative14.5%
unpow-prod-down14.5%
pow1/214.3%
associate-*l*14.8%
count-214.8%
pow1/214.8%
Applied egg-rr14.8%
if 4.89999999999999989e-115 < B < 1.02e23Initial program 40.0%
Simplified46.8%
associate--l+47.2%
Applied egg-rr47.2%
if 1.02e23 < B < 1.20000000000000001e67Initial program 21.7%
Simplified21.7%
div-inv21.7%
Applied egg-rr25.8%
Taylor expanded in C around inf 40.7%
associate--l+39.7%
unpow239.7%
mul-1-neg39.7%
mul-1-neg39.7%
sqr-neg39.7%
unpow239.7%
Simplified40.7%
if 1.20000000000000001e67 < B Initial program 9.2%
Simplified9.4%
Taylor expanded in C around 0 13.2%
mul-1-neg13.2%
*-commutative13.2%
distribute-rgt-neg-in13.2%
+-commutative13.2%
unpow213.2%
unpow213.2%
hypot-def45.0%
Simplified45.0%
Final simplification24.6%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0))))
(t_1 (- (sqrt 2.0)))
(t_2 (fma A (* C -4.0) (pow B 2.0))))
(if (<= B 4.9e-115)
(/ (* (sqrt (* t_2 (* F (* A 2.0)))) t_1) t_2)
(if (<= B 5.2e+44)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A (- C (hypot B (- A C))))))))) t_0)
(* (sqrt (* F (- A (hypot B A)))) (/ t_1 B))))))B = abs(B);
assert(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 = -sqrt(2.0);
double t_2 = fma(A, (C * -4.0), pow(B, 2.0));
double tmp;
if (B <= 4.9e-115) {
tmp = (sqrt((t_2 * (F * (A * 2.0)))) * t_1) / t_2;
} else if (B <= 5.2e+44) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + (C - hypot(B, (A - C)))))))) / t_0;
} else {
tmp = sqrt((F * (A - hypot(B, A)))) * (t_1 / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) t_1 = Float64(-sqrt(2.0)) t_2 = fma(A, Float64(C * -4.0), (B ^ 2.0)) tmp = 0.0 if (B <= 4.9e-115) tmp = Float64(Float64(sqrt(Float64(t_2 * Float64(F * Float64(A * 2.0)))) * t_1) / t_2); elseif (B <= 5.2e+44) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C))))))))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B, A)))) * Float64(t_1 / B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
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[Sqrt[2.0], $MachinePrecision])}, Block[{t$95$2 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 4.9e-115], N[(N[(N[Sqrt[N[(t$95$2 * N[(F * N[(A * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[B, 5.2e+44], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(t$95$1 / B), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := -\sqrt{2}\\
t_2 := \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)\\
\mathbf{if}\;B \leq 4.9 \cdot 10^{-115}:\\
\;\;\;\;\frac{\sqrt{t_2 \cdot \left(F \cdot \left(A \cdot 2\right)\right)} \cdot t_1}{t_2}\\
\mathbf{elif}\;B \leq 5.2 \cdot 10^{+44}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \frac{t_1}{B}\\
\end{array}
\end{array}
if B < 4.89999999999999989e-115Initial program 14.9%
Simplified20.9%
Taylor expanded in C around inf 14.3%
sub-neg14.3%
mul-1-neg14.3%
remove-double-neg14.3%
Simplified14.3%
pow1/214.5%
*-commutative14.5%
unpow-prod-down14.5%
pow1/214.3%
associate-*l*14.8%
count-214.8%
pow1/214.8%
Applied egg-rr14.8%
if 4.89999999999999989e-115 < B < 5.1999999999999998e44Initial program 38.7%
Simplified45.7%
associate--l+46.0%
Applied egg-rr46.0%
if 5.1999999999999998e44 < B Initial program 10.7%
Simplified10.8%
Taylor expanded in C around 0 14.3%
mul-1-neg14.3%
*-commutative14.3%
distribute-rgt-neg-in14.3%
+-commutative14.3%
unpow214.3%
unpow214.3%
hypot-def43.6%
Simplified43.6%
Final simplification24.3%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= (pow B 2.0) 2e-8)
(-
(/
(sqrt (* 2.0 (* (* F (+ (pow B 2.0) (* -4.0 (* A C)))) (+ A A))))
(fma A (* C -4.0) (pow B 2.0))))
(* (sqrt (* F (- A (hypot B A)))) (/ (- (sqrt 2.0)) B))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (pow(B, 2.0) <= 2e-8) {
tmp = -(sqrt((2.0 * ((F * (pow(B, 2.0) + (-4.0 * (A * C)))) * (A + A)))) / fma(A, (C * -4.0), pow(B, 2.0)));
} else {
tmp = sqrt((F * (A - hypot(B, A)))) * (-sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if ((B ^ 2.0) <= 2e-8) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(F * Float64((B ^ 2.0) + Float64(-4.0 * Float64(A * C)))) * Float64(A + A)))) / fma(A, Float64(C * -4.0), (B ^ 2.0)))); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B, A)))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e-8], (-N[(N[Sqrt[N[(2.0 * N[(N[(F * N[(N[Power[B, 2.0], $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]), $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]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(F \cdot \left({B}^{2} + -4 \cdot \left(A \cdot C\right)\right)\right) \cdot \left(A + A\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 2e-8Initial program 23.0%
Simplified31.4%
Taylor expanded in C around inf 20.2%
sub-neg20.2%
mul-1-neg20.2%
remove-double-neg20.2%
Simplified20.2%
Taylor expanded in F around 0 20.2%
if 2e-8 < (pow.f64 B 2) Initial program 10.9%
Simplified12.1%
Taylor expanded in C around 0 7.1%
mul-1-neg7.1%
*-commutative7.1%
distribute-rgt-neg-in7.1%
+-commutative7.1%
unpow27.1%
unpow27.1%
hypot-def19.4%
Simplified19.4%
Final simplification19.8%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0)))) (t_1 (fma A (* C -4.0) (pow B 2.0))))
(if (<= B 4.9e-115)
(/ -1.0 (/ t_1 (sqrt (* 2.0 (* t_1 (* F (* A 2.0)))))))
(if (<= B 8.5e+44)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A (- C (hypot B (- A C))))))))) t_0)
(* (sqrt (* F (- A (hypot B A)))) (/ (- (sqrt 2.0)) B))))))B = abs(B);
assert(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 = fma(A, (C * -4.0), pow(B, 2.0));
double tmp;
if (B <= 4.9e-115) {
tmp = -1.0 / (t_1 / sqrt((2.0 * (t_1 * (F * (A * 2.0))))));
} else if (B <= 8.5e+44) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + (C - hypot(B, (A - C)))))))) / t_0;
} else {
tmp = sqrt((F * (A - hypot(B, A)))) * (-sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) t_1 = fma(A, Float64(C * -4.0), (B ^ 2.0)) tmp = 0.0 if (B <= 4.9e-115) tmp = Float64(-1.0 / Float64(t_1 / sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A * 2.0))))))); elseif (B <= 8.5e+44) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C))))))))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B, A)))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
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[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 4.9e-115], N[(-1.0 / N[(t$95$1 / N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 8.5e+44], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $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]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)\\
\mathbf{if}\;B \leq 4.9 \cdot 10^{-115}:\\
\;\;\;\;\frac{-1}{\frac{t_1}{\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A \cdot 2\right)\right)\right)}}}\\
\mathbf{elif}\;B \leq 8.5 \cdot 10^{+44}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 4.89999999999999989e-115Initial program 14.9%
Simplified20.9%
Taylor expanded in C around inf 14.3%
sub-neg14.3%
mul-1-neg14.3%
remove-double-neg14.3%
Simplified14.3%
clear-num14.3%
inv-pow14.3%
associate-*l*14.7%
count-214.7%
Applied egg-rr14.7%
unpow-114.7%
*-commutative14.7%
*-commutative14.7%
*-commutative14.7%
Simplified14.7%
if 4.89999999999999989e-115 < B < 8.5e44Initial program 38.7%
Simplified45.7%
associate--l+46.0%
Applied egg-rr46.0%
if 8.5e44 < B Initial program 10.7%
Simplified10.8%
Taylor expanded in C around 0 14.3%
mul-1-neg14.3%
*-commutative14.3%
distribute-rgt-neg-in14.3%
+-commutative14.3%
unpow214.3%
unpow214.3%
hypot-def43.6%
Simplified43.6%
Final simplification24.3%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (* -4.0 (* A C))) (t_1 (fma B B t_0)))
(if (<= B 4.9e-115)
(-
(/
(sqrt (* 2.0 (* (* F (+ (pow B 2.0) t_0)) (+ A A))))
(fma A (* C -4.0) (pow B 2.0))))
(if (<= B 3.3e+44)
(/ (- (sqrt (* (+ A (- C (hypot B (- A C)))) (* 2.0 (* F t_1))))) t_1)
(* (sqrt (* F (- A (hypot B A)))) (/ (- (sqrt 2.0)) B))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = -4.0 * (A * C);
double t_1 = fma(B, B, t_0);
double tmp;
if (B <= 4.9e-115) {
tmp = -(sqrt((2.0 * ((F * (pow(B, 2.0) + t_0)) * (A + A)))) / fma(A, (C * -4.0), pow(B, 2.0)));
} else if (B <= 3.3e+44) {
tmp = -sqrt(((A + (C - hypot(B, (A - C)))) * (2.0 * (F * t_1)))) / t_1;
} else {
tmp = sqrt((F * (A - hypot(B, A)))) * (-sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(-4.0 * Float64(A * C)) t_1 = fma(B, B, t_0) tmp = 0.0 if (B <= 4.9e-115) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(F * Float64((B ^ 2.0) + t_0)) * Float64(A + A)))) / fma(A, Float64(C * -4.0), (B ^ 2.0)))); elseif (B <= 3.3e+44) tmp = Float64(Float64(-sqrt(Float64(Float64(A + Float64(C - hypot(B, Float64(A - C)))) * Float64(2.0 * Float64(F * t_1))))) / t_1); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B, A)))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(B * B + t$95$0), $MachinePrecision]}, If[LessEqual[B, 4.9e-115], (-N[(N[Sqrt[N[(2.0 * N[(N[(F * N[(N[Power[B, 2.0], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), If[LessEqual[B, 3.3e+44], N[((-N[Sqrt[N[(N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(F * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $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]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := -4 \cdot \left(A \cdot C\right)\\
t_1 := \mathsf{fma}\left(B, B, t_0\right)\\
\mathbf{if}\;B \leq 4.9 \cdot 10^{-115}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(F \cdot \left({B}^{2} + t_0\right)\right) \cdot \left(A + A\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\\
\mathbf{elif}\;B \leq 3.3 \cdot 10^{+44}:\\
\;\;\;\;\frac{-\sqrt{\left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right) \cdot \left(2 \cdot \left(F \cdot t_1\right)\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 4.89999999999999989e-115Initial program 14.9%
Simplified20.9%
Taylor expanded in C around inf 14.3%
sub-neg14.3%
mul-1-neg14.3%
remove-double-neg14.3%
Simplified14.3%
Taylor expanded in F around 0 14.3%
if 4.89999999999999989e-115 < B < 3.30000000000000013e44Initial program 38.7%
Simplified38.7%
distribute-frac-neg38.7%
Applied egg-rr43.2%
if 3.30000000000000013e44 < B Initial program 10.7%
Simplified10.8%
Taylor expanded in C around 0 14.3%
mul-1-neg14.3%
*-commutative14.3%
distribute-rgt-neg-in14.3%
+-commutative14.3%
unpow214.3%
unpow214.3%
hypot-def43.6%
Simplified43.6%
Final simplification23.6%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0)))))
(if (<= B 4.9e-115)
(-
(/
(sqrt (* 2.0 (* (* F (+ (pow B 2.0) (* -4.0 (* A C)))) (+ A A))))
(fma A (* C -4.0) (pow B 2.0))))
(if (<= B 7.6e+44)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A (- C (hypot B (- A C))))))))) t_0)
(* (sqrt (* F (- A (hypot B A)))) (/ (- (sqrt 2.0)) B))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (B <= 4.9e-115) {
tmp = -(sqrt((2.0 * ((F * (pow(B, 2.0) + (-4.0 * (A * C)))) * (A + A)))) / fma(A, (C * -4.0), pow(B, 2.0)));
} else if (B <= 7.6e+44) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + (C - hypot(B, (A - C)))))))) / t_0;
} else {
tmp = sqrt((F * (A - hypot(B, A)))) * (-sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (B <= 4.9e-115) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(F * Float64((B ^ 2.0) + Float64(-4.0 * Float64(A * C)))) * Float64(A + A)))) / fma(A, Float64(C * -4.0), (B ^ 2.0)))); elseif (B <= 7.6e+44) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C))))))))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B, A)))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 4.9e-115], (-N[(N[Sqrt[N[(2.0 * N[(N[(F * N[(N[Power[B, 2.0], $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), If[LessEqual[B, 7.6e+44], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $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]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;B \leq 4.9 \cdot 10^{-115}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(F \cdot \left({B}^{2} + -4 \cdot \left(A \cdot C\right)\right)\right) \cdot \left(A + A\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\\
\mathbf{elif}\;B \leq 7.6 \cdot 10^{+44}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 4.89999999999999989e-115Initial program 14.9%
Simplified20.9%
Taylor expanded in C around inf 14.3%
sub-neg14.3%
mul-1-neg14.3%
remove-double-neg14.3%
Simplified14.3%
Taylor expanded in F around 0 14.3%
if 4.89999999999999989e-115 < B < 7.6000000000000004e44Initial program 38.7%
Simplified45.7%
associate--l+46.0%
Applied egg-rr46.0%
if 7.6000000000000004e44 < B Initial program 10.7%
Simplified10.8%
Taylor expanded in C around 0 14.3%
mul-1-neg14.3%
*-commutative14.3%
distribute-rgt-neg-in14.3%
+-commutative14.3%
unpow214.3%
unpow214.3%
hypot-def43.6%
Simplified43.6%
Final simplification24.0%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* -4.0 (* A C)))))
(if (<= (pow B 2.0) 2e-8)
(* (sqrt (* (* 2.0 (* F t_0)) (+ A A))) (/ -1.0 t_0))
(* (sqrt (* F (- A (hypot B A)))) (/ (- (sqrt 2.0)) B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (-4.0 * (A * C)));
double tmp;
if (pow(B, 2.0) <= 2e-8) {
tmp = sqrt(((2.0 * (F * t_0)) * (A + A))) * (-1.0 / t_0);
} else {
tmp = sqrt((F * (A - hypot(B, A)))) * (-sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(-4.0 * Float64(A * C))) tmp = 0.0 if ((B ^ 2.0) <= 2e-8) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * Float64(A + A))) * Float64(-1.0 / t_0)); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B, A)))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e-8], N[(N[Sqrt[N[(N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $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]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)\\
\mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\sqrt{\left(2 \cdot \left(F \cdot t_0\right)\right) \cdot \left(A + A\right)} \cdot \frac{-1}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 2e-8Initial program 23.0%
Simplified23.0%
div-inv23.0%
Applied egg-rr30.8%
Taylor expanded in C around inf 20.1%
if 2e-8 < (pow.f64 B 2) Initial program 10.9%
Simplified12.1%
Taylor expanded in C around 0 7.1%
mul-1-neg7.1%
*-commutative7.1%
distribute-rgt-neg-in7.1%
+-commutative7.1%
unpow27.1%
unpow27.1%
hypot-def19.4%
Simplified19.4%
Final simplification19.8%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= (pow B 2.0) 3e-217)
(/
(- (sqrt (* 2.0 (* -4.0 (* A (* C (* F (+ A A))))))))
(fma B B (* A (* C -4.0))))
(* (sqrt (* F (- A (hypot B A)))) (/ (- (sqrt 2.0)) B))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (pow(B, 2.0) <= 3e-217) {
tmp = -sqrt((2.0 * (-4.0 * (A * (C * (F * (A + A))))))) / fma(B, B, (A * (C * -4.0)));
} else {
tmp = sqrt((F * (A - hypot(B, A)))) * (-sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if ((B ^ 2.0) <= 3e-217) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-4.0 * Float64(A * Float64(C * Float64(F * Float64(A + A)))))))) / fma(B, B, Float64(A * Float64(C * -4.0)))); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B, A)))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 3e-217], N[((-N[Sqrt[N[(2.0 * N[(-4.0 * N[(A * N[(C * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 3 \cdot 10^{-217}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 3.00000000000000004e-217Initial program 14.4%
Simplified23.7%
Taylor expanded in B around 0 22.0%
*-commutative22.0%
associate-*r*22.0%
Simplified22.0%
Taylor expanded in C around inf 21.4%
mul-1-neg21.4%
Simplified21.4%
if 3.00000000000000004e-217 < (pow.f64 B 2) Initial program 18.4%
Simplified20.5%
Taylor expanded in C around 0 8.9%
mul-1-neg8.9%
*-commutative8.9%
distribute-rgt-neg-in8.9%
+-commutative8.9%
unpow28.9%
unpow28.9%
hypot-def18.3%
Simplified18.3%
Final simplification19.4%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 4.6e+55)
(/
(- (sqrt (* 2.0 (* -4.0 (* A (* C (* F (+ A A))))))))
(fma B B (* A (* C -4.0))))
(* 2.0 (* (sqrt (* A F)) (/ -1.0 B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 4.6e+55) {
tmp = -sqrt((2.0 * (-4.0 * (A * (C * (F * (A + A))))))) / fma(B, B, (A * (C * -4.0)));
} else {
tmp = 2.0 * (sqrt((A * F)) * (-1.0 / B));
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 4.6e+55) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-4.0 * Float64(A * Float64(C * Float64(F * Float64(A + A)))))))) / fma(B, B, Float64(A * Float64(C * -4.0)))); else tmp = Float64(2.0 * Float64(sqrt(Float64(A * F)) * Float64(-1.0 / B))); end return tmp end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 4.6e+55], N[((-N[Sqrt[N[(2.0 * N[(-4.0 * N[(A * N[(C * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 4.6 \cdot 10^{+55}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{-1}{B}\right)\\
\end{array}
\end{array}
if B < 4.59999999999999975e55Initial program 18.5%
Simplified24.2%
Taylor expanded in B around 0 14.7%
*-commutative14.7%
associate-*r*14.7%
Simplified14.7%
Taylor expanded in C around inf 12.8%
mul-1-neg12.8%
Simplified12.8%
if 4.59999999999999975e55 < B Initial program 10.8%
Simplified11.0%
Taylor expanded in C around inf 3.2%
sub-neg3.2%
mul-1-neg3.2%
remove-double-neg3.2%
Simplified3.2%
Taylor expanded in C around 0 6.5%
Final simplification11.6%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* 2.0 (* (sqrt (* A F)) (/ -1.0 B))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return 2.0 * (sqrt((A * F)) * (-1.0 / B));
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = 2.0d0 * (sqrt((a * f)) * ((-1.0d0) / b))
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return 2.0 * (Math.sqrt((A * F)) * (-1.0 / B));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return 2.0 * (math.sqrt((A * F)) * (-1.0 / B))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(2.0 * Float64(sqrt(Float64(A * F)) * Float64(-1.0 / B))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = 2.0 * (sqrt((A * F)) * (-1.0 / B));
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{-1}{B}\right)
\end{array}
Initial program 17.0%
Simplified21.9%
Taylor expanded in C around inf 11.8%
sub-neg11.8%
mul-1-neg11.8%
remove-double-neg11.8%
Simplified11.8%
Taylor expanded in C around 0 2.7%
Final simplification2.7%
herbie shell --seed 2023311
(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))))