
(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)))))
(if (<= (pow B 2.0) 2e+107)
(/
(- (sqrt (* 2.0 (* t_0 (* F (+ A (+ A (* -0.5 (* B (/ B (- C A)))))))))))
t_0)
(* (sqrt (* F (- A (hypot A B)))) (- (/ (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 (pow(B, 2.0) <= 2e+107) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + (A + (-0.5 * (B * (B / (C - A)))))))))) / t_0;
} else {
tmp = sqrt((F * (A - hypot(A, B)))) * -(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 ^ 2.0) <= 2e+107) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + Float64(A + Float64(-0.5 * Float64(B * Float64(B / Float64(C - A))))))))))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(A, B)))) * 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[N[Power[B, 2.0], $MachinePrecision], 2e+107], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + N[(A + N[(-0.5 * N[(B * N[(B / N[(C - A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 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}^{2} \leq 2 \cdot 10^{+107}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + \left(A + -0.5 \cdot \left(B \cdot \frac{B}{C - A}\right)\right)\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B}\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 1.9999999999999999e107Initial program 20.5%
Simplified34.3%
Taylor expanded in B around 0 29.3%
unpow229.3%
Simplified29.3%
*-un-lft-identity29.3%
associate-/l*29.3%
Applied egg-rr29.3%
*-lft-identity29.3%
associate-/r/29.3%
Simplified29.3%
if 1.9999999999999999e107 < (pow.f64 B 2) Initial program 12.0%
Simplified12.0%
Taylor expanded in C around 0 9.1%
mul-1-neg9.1%
distribute-rgt-neg-in9.1%
unpow29.1%
unpow29.1%
hypot-def26.6%
Simplified26.6%
Final simplification28.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 (- (* B B) (* (* A C) 4.0)))
(t_1 (fma B B (* A (* C -4.0))))
(t_2 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 1.65e-25)
(/ (- (sqrt (* 2.0 (* t_2 (* F (+ A A)))))) t_2)
(if (<= B 1.5e+16)
(/
(-
(sqrt
(*
2.0
(*
(* F t_0)
(+ A (fma -0.5 (/ (+ (* A A) (- (* B B) (* A A))) C) A))))))
t_0)
(if (<= B 1.02e+55)
(/
(- (sqrt (* 2.0 (* t_1 (* F (+ A (+ A (* -0.5 (/ (* B B) C)))))))))
t_1)
(* (sqrt (* F (- A (hypot A B)))) (- (/ (sqrt 2.0) B))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((A * C) * 4.0);
double t_1 = fma(B, B, (A * (C * -4.0)));
double t_2 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 1.65e-25) {
tmp = -sqrt((2.0 * (t_2 * (F * (A + A))))) / t_2;
} else if (B <= 1.5e+16) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + fma(-0.5, (((A * A) + ((B * B) - (A * A))) / C), A))))) / t_0;
} else if (B <= 1.02e+55) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + (A + (-0.5 * ((B * B) / C)))))))) / t_1;
} else {
tmp = sqrt((F * (A - hypot(A, B)))) * -(sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(Float64(A * C) * 4.0)) t_1 = fma(B, B, Float64(A * Float64(C * -4.0))) t_2 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 1.65e-25) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_2 * Float64(F * Float64(A + A)))))) / t_2); elseif (B <= 1.5e+16) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + fma(-0.5, Float64(Float64(Float64(A * A) + Float64(Float64(B * B) - Float64(A * A))) / C), A)))))) / t_0); elseif (B <= 1.02e+55) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + Float64(A + Float64(-0.5 * Float64(Float64(B * B) / C))))))))) / t_1); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(A, B)))) * 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[(N[(B * B), $MachinePrecision] - N[(N[(A * C), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 1.65e-25], N[((-N[Sqrt[N[(2.0 * N[(t$95$2 * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision], If[LessEqual[B, 1.5e+16], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + N[(-0.5 * N[(N[(N[(A * A), $MachinePrecision] + N[(N[(B * B), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision] + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 1.02e+55], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + N[(A + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 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 := B \cdot B - \left(A \cdot C\right) \cdot 4\\
t_1 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 1.65 \cdot 10^{-25}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_2 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_2}\\
\mathbf{elif}\;B \leq 1.5 \cdot 10^{+16}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + \mathsf{fma}\left(-0.5, \frac{A \cdot A + \left(B \cdot B - A \cdot A\right)}{C}, A\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 1.02 \cdot 10^{+55}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + \left(A + -0.5 \cdot \frac{B \cdot B}{C}\right)\right)\right)\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B}\right)\\
\end{array}
\end{array}
if B < 1.6499999999999999e-25Initial program 17.7%
Simplified17.7%
Taylor expanded in C around inf 17.4%
cancel-sign-sub-inv17.4%
metadata-eval17.4%
*-lft-identity17.4%
Simplified17.4%
distribute-frac-neg17.4%
associate-*l*18.8%
cancel-sign-sub-inv18.8%
metadata-eval18.8%
cancel-sign-sub-inv18.8%
metadata-eval18.8%
Applied egg-rr18.8%
if 1.6499999999999999e-25 < B < 1.5e16Initial program 30.3%
Simplified30.4%
Taylor expanded in C around inf 42.9%
associate--l+42.9%
fma-neg42.9%
associate--l+42.9%
unpow242.9%
unpow242.9%
unpow242.9%
mul-1-neg42.9%
mul-1-neg42.9%
sqr-neg42.9%
mul-1-neg42.9%
remove-double-neg42.9%
Simplified42.9%
if 1.5e16 < B < 1.02000000000000002e55Initial program 1.4%
Simplified6.4%
Taylor expanded in B around 0 24.6%
unpow224.6%
Simplified24.6%
Taylor expanded in C around inf 25.6%
unpow225.6%
Simplified25.6%
if 1.02000000000000002e55 < B Initial program 13.0%
Simplified13.0%
Taylor expanded in C around 0 17.7%
mul-1-neg17.7%
distribute-rgt-neg-in17.7%
unpow217.7%
unpow217.7%
hypot-def52.7%
Simplified52.7%
Final simplification26.5%
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 (- (* B B) (* (* A C) 4.0))) (t_1 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 1.25e-24)
(/ (- (sqrt (* 2.0 (* t_1 (* F (+ A A)))))) t_1)
(if (<= B 0.6)
(/
(-
(sqrt
(*
2.0
(*
(* F t_0)
(+ A (fma -0.5 (/ (+ (* A A) (- (* B B) (* A A))) C) A))))))
t_0)
(* (sqrt (* F (- A (hypot A B)))) (- (/ (sqrt 2.0) B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((A * C) * 4.0);
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 1.25e-24) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1;
} else if (B <= 0.6) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + fma(-0.5, (((A * A) + ((B * B) - (A * A))) / C), A))))) / t_0;
} else {
tmp = sqrt((F * (A - hypot(A, B)))) * -(sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(Float64(A * C) * 4.0)) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 1.25e-24) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + A)))))) / t_1); elseif (B <= 0.6) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + fma(-0.5, Float64(Float64(Float64(A * A) + Float64(Float64(B * B) - Float64(A * A))) / C), A)))))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(A, B)))) * 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[(N[(B * B), $MachinePrecision] - N[(N[(A * C), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 1.25e-24], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B, 0.6], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + N[(-0.5 * N[(N[(N[(A * A), $MachinePrecision] + N[(N[(B * B), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision] + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 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 := B \cdot B - \left(A \cdot C\right) \cdot 4\\
t_1 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 1.25 \cdot 10^{-24}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;B \leq 0.6:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + \mathsf{fma}\left(-0.5, \frac{A \cdot A + \left(B \cdot B - A \cdot A\right)}{C}, A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B}\right)\\
\end{array}
\end{array}
if B < 1.24999999999999995e-24Initial program 17.7%
Simplified17.7%
Taylor expanded in C around inf 17.4%
cancel-sign-sub-inv17.4%
metadata-eval17.4%
*-lft-identity17.4%
Simplified17.4%
distribute-frac-neg17.4%
associate-*l*18.8%
cancel-sign-sub-inv18.8%
metadata-eval18.8%
cancel-sign-sub-inv18.8%
metadata-eval18.8%
Applied egg-rr18.8%
if 1.24999999999999995e-24 < B < 0.599999999999999978Initial program 3.2%
Simplified3.2%
Taylor expanded in C around inf 44.7%
associate--l+44.7%
fma-neg44.7%
associate--l+44.7%
unpow244.7%
unpow244.7%
unpow244.7%
mul-1-neg44.7%
mul-1-neg44.7%
sqr-neg44.7%
mul-1-neg44.7%
remove-double-neg44.7%
Simplified44.7%
if 0.599999999999999978 < B Initial program 18.1%
Simplified18.1%
Taylor expanded in C around 0 20.6%
mul-1-neg20.6%
distribute-rgt-neg-in20.6%
unpow220.6%
unpow220.6%
hypot-def50.0%
Simplified50.0%
Final simplification26.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 (- (* B B) (* (* A C) 4.0))) (t_1 (* F t_0)))
(if (<= C 1.4e-25)
(/ (- (sqrt (* 2.0 (* (- A (hypot A B)) t_1)))) t_0)
(/
(-
(sqrt
(*
2.0
(* t_1 (+ A (fma -0.5 (/ (+ (* A A) (- (* B B) (* A A))) C) A))))))
t_0))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((A * C) * 4.0);
double t_1 = F * t_0;
double tmp;
if (C <= 1.4e-25) {
tmp = -sqrt((2.0 * ((A - hypot(A, B)) * t_1))) / t_0;
} else {
tmp = -sqrt((2.0 * (t_1 * (A + fma(-0.5, (((A * A) + ((B * B) - (A * A))) / C), A))))) / t_0;
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(Float64(A * C) * 4.0)) t_1 = Float64(F * t_0) tmp = 0.0 if (C <= 1.4e-25) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(A - hypot(A, B)) * t_1)))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A + fma(-0.5, Float64(Float64(Float64(A * A) + Float64(Float64(B * B) - Float64(A * A))) / C), A)))))) / t_0); 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[(N[(B * B), $MachinePrecision] - N[(N[(A * C), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(F * t$95$0), $MachinePrecision]}, If[LessEqual[C, 1.4e-25], N[((-N[Sqrt[N[(2.0 * N[(N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A + N[(-0.5 * N[(N[(N[(A * A), $MachinePrecision] + N[(N[(B * B), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision] + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - \left(A \cdot C\right) \cdot 4\\
t_1 := F \cdot t_0\\
\mathbf{if}\;C \leq 1.4 \cdot 10^{-25}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(A - \mathsf{hypot}\left(A, B\right)\right) \cdot t_1\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A + \mathsf{fma}\left(-0.5, \frac{A \cdot A + \left(B \cdot B - A \cdot A\right)}{C}, A\right)\right)\right)}}{t_0}\\
\end{array}
\end{array}
if C < 1.39999999999999994e-25Initial program 21.7%
Simplified21.7%
Taylor expanded in C around 0 16.5%
unpow216.5%
unpow216.5%
hypot-def21.3%
Simplified21.3%
if 1.39999999999999994e-25 < C Initial program 3.9%
Simplified3.9%
Taylor expanded in C around inf 30.7%
associate--l+30.7%
fma-neg30.7%
associate--l+30.7%
unpow230.7%
unpow230.7%
unpow230.7%
mul-1-neg30.7%
mul-1-neg30.7%
sqr-neg30.7%
mul-1-neg30.7%
remove-double-neg30.7%
Simplified30.7%
Final simplification23.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 (- (* B B) (* (* A C) 4.0))) (t_1 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 0.0027)
(/ (- (sqrt (* 2.0 (* t_1 (* F (+ A A)))))) t_1)
(if (<= B 1.65e+153)
(/ (- (sqrt (* 2.0 (* (- A (hypot A B)) (* F t_0))))) t_0)
(* -2.0 (/ (sqrt (* A F)) B))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((A * C) * 4.0);
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 0.0027) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1;
} else if (B <= 1.65e+153) {
tmp = -sqrt((2.0 * ((A - hypot(A, B)) * (F * t_0)))) / t_0;
} else {
tmp = -2.0 * (sqrt((A * F)) / B);
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((A * C) * 4.0);
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 0.0027) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1;
} else if (B <= 1.65e+153) {
tmp = -Math.sqrt((2.0 * ((A - Math.hypot(A, B)) * (F * t_0)))) / t_0;
} else {
tmp = -2.0 * (Math.sqrt((A * F)) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - ((A * C) * 4.0) t_1 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 0.0027: tmp = -math.sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1 elif B <= 1.65e+153: tmp = -math.sqrt((2.0 * ((A - math.hypot(A, B)) * (F * t_0)))) / t_0 else: tmp = -2.0 * (math.sqrt((A * F)) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(Float64(A * C) * 4.0)) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 0.0027) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + A)))))) / t_1); elseif (B <= 1.65e+153) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(A - hypot(A, B)) * Float64(F * t_0))))) / t_0); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - ((A * C) * 4.0);
t_1 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 0.0027)
tmp = -sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1;
elseif (B <= 1.65e+153)
tmp = -sqrt((2.0 * ((A - hypot(A, B)) * (F * t_0)))) / t_0;
else
tmp = -2.0 * (sqrt((A * F)) / B);
end
tmp_2 = 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[(N[(B * B), $MachinePrecision] - N[(N[(A * C), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 0.0027], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B, 1.65e+153], N[((-N[Sqrt[N[(2.0 * N[(N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision] * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - \left(A \cdot C\right) \cdot 4\\
t_1 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 0.0027:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;B \leq 1.65 \cdot 10^{+153}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(A - \mathsf{hypot}\left(A, B\right)\right) \cdot \left(F \cdot t_0\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 0.0027000000000000001Initial program 17.0%
Simplified17.0%
Taylor expanded in C around inf 18.2%
cancel-sign-sub-inv18.2%
metadata-eval18.2%
*-lft-identity18.2%
Simplified18.2%
distribute-frac-neg18.2%
associate-*l*19.6%
cancel-sign-sub-inv19.6%
metadata-eval19.6%
cancel-sign-sub-inv19.6%
metadata-eval19.6%
Applied egg-rr19.6%
if 0.0027000000000000001 < B < 1.64999999999999997e153Initial program 40.5%
Simplified40.5%
Taylor expanded in C around 0 34.3%
unpow234.3%
unpow234.3%
hypot-def34.3%
Simplified34.3%
if 1.64999999999999997e153 < B Initial program 0.0%
Simplified0.0%
Taylor expanded in C around inf 0.0%
cancel-sign-sub-inv0.0%
metadata-eval0.0%
*-lft-identity0.0%
Simplified0.0%
Taylor expanded in B around inf 10.6%
associate-*r/10.6%
*-rgt-identity10.6%
Simplified10.6%
Final simplification19.9%
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 (- (* B B) (* (* A C) 4.0))) (t_1 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 7.2e+15)
(/ (- (sqrt (* 2.0 (* t_1 (* F (+ A A)))))) t_1)
(if (<= B 7.2e+153)
(/ (- (sqrt (* 2.0 (* (* F t_0) (- (+ A C) B))))) t_0)
(* -2.0 (/ (sqrt (* A F)) B))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((A * C) * 4.0);
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 7.2e+15) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1;
} else if (B <= 7.2e+153) {
tmp = -sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / t_0;
} else {
tmp = -2.0 * (sqrt((A * F)) / B);
}
return tmp;
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (b * b) - ((a * c) * 4.0d0)
t_1 = (b * b) + ((-4.0d0) * (a * c))
if (b <= 7.2d+15) then
tmp = -sqrt((2.0d0 * (t_1 * (f * (a + a))))) / t_1
else if (b <= 7.2d+153) then
tmp = -sqrt((2.0d0 * ((f * t_0) * ((a + c) - b)))) / t_0
else
tmp = (-2.0d0) * (sqrt((a * f)) / b)
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((A * C) * 4.0);
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 7.2e+15) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1;
} else if (B <= 7.2e+153) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / t_0;
} else {
tmp = -2.0 * (Math.sqrt((A * F)) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - ((A * C) * 4.0) t_1 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 7.2e+15: tmp = -math.sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1 elif B <= 7.2e+153: tmp = -math.sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / t_0 else: tmp = -2.0 * (math.sqrt((A * F)) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(Float64(A * C) * 4.0)) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 7.2e+15) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + A)))))) / t_1); elseif (B <= 7.2e+153) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(Float64(A + C) - B))))) / t_0); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - ((A * C) * 4.0);
t_1 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 7.2e+15)
tmp = -sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1;
elseif (B <= 7.2e+153)
tmp = -sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / t_0;
else
tmp = -2.0 * (sqrt((A * F)) / B);
end
tmp_2 = 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[(N[(B * B), $MachinePrecision] - N[(N[(A * C), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 7.2e+15], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B, 7.2e+153], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - \left(A \cdot C\right) \cdot 4\\
t_1 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 7.2 \cdot 10^{+15}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;B \leq 7.2 \cdot 10^{+153}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(\left(A + C\right) - B\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 7.2e15Initial program 18.5%
Simplified18.5%
Taylor expanded in C around inf 18.7%
cancel-sign-sub-inv18.7%
metadata-eval18.7%
*-lft-identity18.7%
Simplified18.7%
distribute-frac-neg18.7%
associate-*l*20.1%
cancel-sign-sub-inv20.1%
metadata-eval20.1%
cancel-sign-sub-inv20.1%
metadata-eval20.1%
Applied egg-rr20.1%
if 7.2e15 < B < 7.2000000000000001e153Initial program 30.8%
Simplified30.8%
Taylor expanded in B around inf 27.7%
if 7.2000000000000001e153 < B Initial program 0.0%
Simplified0.0%
Taylor expanded in C around inf 0.0%
cancel-sign-sub-inv0.0%
metadata-eval0.0%
*-lft-identity0.0%
Simplified0.0%
Taylor expanded in B around inf 10.6%
associate-*r/10.6%
*-rgt-identity10.6%
Simplified10.6%
Final simplification19.5%
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 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 1.22e+98)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A A)))))) t_0)
(* -2.0 (/ (pow (* A F) 0.5) B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 1.22e+98) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
} else {
tmp = -2.0 * (pow((A * F), 0.5) / B);
}
return tmp;
}
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
real(8) :: t_0
real(8) :: tmp
t_0 = (b * b) + ((-4.0d0) * (a * c))
if (b <= 1.22d+98) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (a + a))))) / t_0
else
tmp = (-2.0d0) * (((a * f) ** 0.5d0) / b)
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 1.22e+98) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
} else {
tmp = -2.0 * (Math.pow((A * F), 0.5) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 1.22e+98: tmp = -math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0 else: tmp = -2.0 * (math.pow((A * F), 0.5) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 1.22e+98) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + A)))))) / t_0); else tmp = Float64(-2.0 * Float64((Float64(A * F) ^ 0.5) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 1.22e+98)
tmp = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
else
tmp = -2.0 * (((A * F) ^ 0.5) / B);
end
tmp_2 = 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[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 1.22e+98], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-2.0 * N[(N[Power[N[(A * F), $MachinePrecision], 0.5], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 1.22 \cdot 10^{+98}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{{\left(A \cdot F\right)}^{0.5}}{B}\\
\end{array}
\end{array}
if B < 1.22e98Initial program 19.1%
Simplified19.1%
Taylor expanded in C around inf 18.2%
cancel-sign-sub-inv18.2%
metadata-eval18.2%
*-lft-identity18.2%
Simplified18.2%
distribute-frac-neg18.2%
associate-*l*19.5%
cancel-sign-sub-inv19.5%
metadata-eval19.5%
cancel-sign-sub-inv19.5%
metadata-eval19.5%
Applied egg-rr19.5%
if 1.22e98 < B Initial program 7.4%
Simplified7.4%
Taylor expanded in C around inf 0.2%
cancel-sign-sub-inv0.2%
metadata-eval0.2%
*-lft-identity0.2%
Simplified0.2%
Taylor expanded in B around inf 8.2%
associate-*r/8.3%
*-rgt-identity8.3%
Simplified8.3%
pow1/28.6%
Applied egg-rr8.6%
Final simplification17.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 (<= B 320000.0)
(/
(- (sqrt (* 2.0 (* (+ A A) (* -4.0 (* A (* C F)))))))
(- (* B B) (* (* A C) 4.0)))
(* -2.0 (/ (pow (* A F) 0.5) B))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 320000.0) {
tmp = -sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((A * C) * 4.0));
} else {
tmp = -2.0 * (pow((A * F), 0.5) / B);
}
return tmp;
}
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
real(8) :: tmp
if (b <= 320000.0d0) then
tmp = -sqrt((2.0d0 * ((a + a) * ((-4.0d0) * (a * (c * f)))))) / ((b * b) - ((a * c) * 4.0d0))
else
tmp = (-2.0d0) * (((a * f) ** 0.5d0) / b)
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= 320000.0) {
tmp = -Math.sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((A * C) * 4.0));
} else {
tmp = -2.0 * (Math.pow((A * F), 0.5) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= 320000.0: tmp = -math.sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((A * C) * 4.0)) else: tmp = -2.0 * (math.pow((A * F), 0.5) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 320000.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(A + A) * Float64(-4.0 * Float64(A * Float64(C * F))))))) / Float64(Float64(B * B) - Float64(Float64(A * C) * 4.0))); else tmp = Float64(-2.0 * Float64((Float64(A * F) ^ 0.5) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (B <= 320000.0)
tmp = -sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((A * C) * 4.0));
else
tmp = -2.0 * (((A * F) ^ 0.5) / B);
end
tmp_2 = 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, 320000.0], N[((-N[Sqrt[N[(2.0 * N[(N[(A + A), $MachinePrecision] * N[(-4.0 * N[(A * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(N[(A * C), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Power[N[(A * F), $MachinePrecision], 0.5], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 320000:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(A + A\right) \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)\right)}}{B \cdot B - \left(A \cdot C\right) \cdot 4}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{{\left(A \cdot F\right)}^{0.5}}{B}\\
\end{array}
\end{array}
if B < 3.2e5Initial program 17.0%
Simplified17.0%
Taylor expanded in C around inf 18.2%
cancel-sign-sub-inv18.2%
metadata-eval18.2%
*-lft-identity18.2%
Simplified18.2%
Taylor expanded in B around 0 13.7%
if 3.2e5 < B Initial program 18.1%
Simplified18.1%
Taylor expanded in C around inf 5.2%
cancel-sign-sub-inv5.2%
metadata-eval5.2%
*-lft-identity5.2%
Simplified5.2%
Taylor expanded in B around inf 10.2%
associate-*r/10.2%
*-rgt-identity10.2%
Simplified10.2%
pow1/210.7%
Applied egg-rr10.7%
Final simplification13.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 (/ (- (sqrt (* 2.0 (* (+ A A) (* F (* C (* A -4.0))))))) (- (* B B) (* (* A C) 4.0))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -sqrt((2.0 * ((A + A) * (F * (C * (A * -4.0)))))) / ((B * B) - ((A * C) * 4.0));
}
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 = -sqrt((2.0d0 * ((a + a) * (f * (c * (a * (-4.0d0))))))) / ((b * b) - ((a * c) * 4.0d0))
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return -Math.sqrt((2.0 * ((A + A) * (F * (C * (A * -4.0)))))) / ((B * B) - ((A * C) * 4.0));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -math.sqrt((2.0 * ((A + A) * (F * (C * (A * -4.0)))))) / ((B * B) - ((A * C) * 4.0))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(A + A) * Float64(F * Float64(C * Float64(A * -4.0))))))) / Float64(Float64(B * B) - Float64(Float64(A * C) * 4.0))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt((2.0 * ((A + A) * (F * (C * (A * -4.0)))))) / ((B * B) - ((A * C) * 4.0));
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[((-N[Sqrt[N[(2.0 * N[(N[(A + A), $MachinePrecision] * N[(F * N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(N[(A * C), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{-\sqrt{2 \cdot \left(\left(A + A\right) \cdot \left(F \cdot \left(C \cdot \left(A \cdot -4\right)\right)\right)\right)}}{B \cdot B - \left(A \cdot C\right) \cdot 4}
\end{array}
Initial program 17.2%
Simplified17.3%
Taylor expanded in C around inf 15.4%
cancel-sign-sub-inv15.4%
metadata-eval15.4%
*-lft-identity15.4%
Simplified15.4%
Taylor expanded in B around 0 14.8%
associate-*r*14.8%
Simplified14.8%
Final simplification14.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 (* -2.0 (/ (pow (* A F) 0.5) B)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (pow((A * F), 0.5) / 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) * (((a * f) ** 0.5d0) / 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.pow((A * F), 0.5) / B);
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.pow((A * F), 0.5) / B)
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64((Float64(A * F) ^ 0.5) / B)) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (((A * F) ^ 0.5) / 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[Power[N[(A * F), $MachinePrecision], 0.5], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \frac{{\left(A \cdot F\right)}^{0.5}}{B}
\end{array}
Initial program 17.2%
Simplified17.3%
Taylor expanded in C around inf 15.4%
cancel-sign-sub-inv15.4%
metadata-eval15.4%
*-lft-identity15.4%
Simplified15.4%
Taylor expanded in B around inf 3.9%
associate-*r/3.9%
*-rgt-identity3.9%
Simplified3.9%
pow1/24.1%
Applied egg-rr4.1%
Final simplification4.1%
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)) B)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (sqrt((A * F)) / 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)) / 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)) / B);
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.sqrt((A * F)) / B)
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (sqrt((A * F)) / 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] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \frac{\sqrt{A \cdot F}}{B}
\end{array}
Initial program 17.2%
Simplified17.3%
Taylor expanded in C around inf 15.4%
cancel-sign-sub-inv15.4%
metadata-eval15.4%
*-lft-identity15.4%
Simplified15.4%
Taylor expanded in B around inf 3.9%
associate-*r/3.9%
*-rgt-identity3.9%
Simplified3.9%
Final simplification3.9%
herbie shell --seed 2023275
(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))))