
(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 12 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 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 9.5e-53)
(/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 A))))) t_0)
(if (<= B 5.5e+124)
(/
(*
(sqrt (fma B B (* C (* A -4.0))))
(- (sqrt (* 2.0 (* F (+ A (- C (hypot (- A C) B))))))))
(fma B B (* A (* C -4.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) - (4.0 * (A * C));
double tmp;
if (B <= 9.5e-53) {
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else if (B <= 5.5e+124) {
tmp = (sqrt(fma(B, B, (C * (A * -4.0)))) * -sqrt((2.0 * (F * (A + (C - hypot((A - C), B))))))) / fma(B, B, (A * (C * -4.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(4.0 * Float64(A * C))) tmp = 0.0 if (B <= 9.5e-53) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / t_0); elseif (B <= 5.5e+124) tmp = Float64(Float64(sqrt(fma(B, B, Float64(C * Float64(A * -4.0)))) * Float64(-sqrt(Float64(2.0 * Float64(F * Float64(A + Float64(C - hypot(Float64(A - C), B)))))))) / fma(B, B, Float64(A * Float64(C * -4.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[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 9.5e-53], N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 5.5e+124], N[(N[(N[Sqrt[N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(2.0 * N[(F * N[(A + N[(C - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $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[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 - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 9.5 \cdot 10^{-53}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 5.5 \cdot 10^{+124}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)} \cdot \left(-\sqrt{2 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(A - C, B\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(A, B\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 9.5000000000000008e-53Initial program 19.1%
Simplified19.1%
Taylor expanded in A around -inf 19.7%
*-commutative19.7%
Simplified19.7%
if 9.5000000000000008e-53 < B < 5.49999999999999977e124Initial program 27.6%
Simplified35.9%
sqrt-prod45.6%
associate-*r*45.6%
*-commutative45.6%
associate-*l*45.6%
associate--r-45.5%
+-commutative45.5%
Applied egg-rr45.5%
hypot-def37.5%
unpow237.5%
unpow237.5%
+-commutative37.5%
unpow237.5%
unpow237.5%
hypot-def45.5%
Simplified45.5%
if 5.49999999999999977e124 < B Initial program 0.5%
Simplified0.5%
Taylor expanded in C around 0 9.6%
mul-1-neg9.6%
*-commutative9.6%
+-commutative9.6%
unpow29.6%
unpow29.6%
hypot-def47.4%
Simplified47.4%
Final simplification26.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) (* 4.0 (* A C)))))
(if (<= B 6e+20)
(/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 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) - (4.0 * (A * C));
double tmp;
if (B <= 6e+20) {
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else {
tmp = sqrt((F * (A - hypot(A, B)))) * (-sqrt(2.0) / 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) - (4.0 * (A * C));
double tmp;
if (B <= 6e+20) {
tmp = -Math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else {
tmp = Math.sqrt((F * (A - Math.hypot(A, B)))) * (-Math.sqrt(2.0) / 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 <= 6e+20: tmp = -math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0 else: tmp = math.sqrt((F * (A - math.hypot(A, B)))) * (-math.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(4.0 * Float64(A * C))) tmp = 0.0 if (B <= 6e+20) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(A, B)))) * Float64(Float64(-sqrt(2.0)) / 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 <= 6e+20)
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
else
tmp = sqrt((F * (A - hypot(A, B)))) * (-sqrt(2.0) / 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, 6e+20], N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * A), $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 - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 6 \cdot 10^{+20}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 6e20Initial program 19.6%
Simplified19.6%
Taylor expanded in A around -inf 19.1%
*-commutative19.1%
Simplified19.1%
if 6e20 < B Initial program 7.8%
Simplified7.8%
Taylor expanded in C around 0 16.8%
mul-1-neg16.8%
*-commutative16.8%
+-commutative16.8%
unpow216.8%
unpow216.8%
hypot-def44.6%
Simplified44.6%
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 (- (* B B) (* 4.0 (* A C)))) (t_1 (* t_0 F)))
(if (<= C 1.2e+42)
(/ (- (sqrt (* 2.0 (* t_1 (- A (hypot A B)))))) t_0)
(/
(-
(sqrt
(*
2.0
(* t_1 (+ A (fma -0.5 (/ (+ (* B B) (- (* A A) (* 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) - (4.0 * (A * C));
double t_1 = t_0 * F;
double tmp;
if (C <= 1.2e+42) {
tmp = -sqrt((2.0 * (t_1 * (A - hypot(A, B))))) / t_0;
} else {
tmp = -sqrt((2.0 * (t_1 * (A + fma(-0.5, (((B * B) + ((A * A) - (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(4.0 * Float64(A * C))) t_1 = Float64(t_0 * F) tmp = 0.0 if (C <= 1.2e+42) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A - hypot(A, B)))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A + fma(-0.5, Float64(Float64(Float64(B * B) + Float64(Float64(A * A) - 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[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * F), $MachinePrecision]}, If[LessEqual[C, 1.2e+42], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $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[(B * B), $MachinePrecision] + N[(N[(A * A), $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 - 4 \cdot \left(A \cdot C\right)\\
t_1 := t_0 \cdot F\\
\mathbf{if}\;C \leq 1.2 \cdot 10^{+42}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A + \mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - A \cdot A\right)}{C}, A\right)\right)\right)}}{t_0}\\
\end{array}
\end{array}
if C < 1.1999999999999999e42Initial program 21.2%
Simplified21.2%
Taylor expanded in C around 0 14.7%
+-commutative14.7%
unpow214.7%
unpow214.7%
hypot-def18.2%
Simplified18.2%
if 1.1999999999999999e42 < C Initial program 2.7%
Simplified2.7%
Taylor expanded in C around inf 35.0%
associate--l+35.0%
fma-neg35.0%
associate--l+35.0%
unpow235.0%
unpow235.0%
unpow235.0%
mul-1-neg35.0%
mul-1-neg35.0%
sqr-neg35.0%
mul-1-neg35.0%
Simplified35.0%
Final simplification22.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 (+ (* B B) (* (* A C) -4.0))) (t_1 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 5.4e+20)
(/ (- (sqrt (* 2.0 (* (* t_1 F) (* 2.0 A))))) t_1)
(if (<= B 3.2e+117)
(/ (- (sqrt (* 2.0 (* t_0 (* F (- C (hypot 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 <= 5.4e+20) {
tmp = -sqrt((2.0 * ((t_1 * F) * (2.0 * A)))) / t_1;
} else if (B <= 3.2e+117) {
tmp = -sqrt((2.0 * (t_0 * (F * (C - hypot(C, B)))))) / 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 <= 5.4e+20) {
tmp = -Math.sqrt((2.0 * ((t_1 * F) * (2.0 * A)))) / t_1;
} else if (B <= 3.2e+117) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (C - Math.hypot(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 <= 5.4e+20: tmp = -math.sqrt((2.0 * ((t_1 * F) * (2.0 * A)))) / t_1 elif B <= 3.2e+117: tmp = -math.sqrt((2.0 * (t_0 * (F * (C - math.hypot(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 <= 5.4e+20) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_1 * F) * Float64(2.0 * A))))) / t_1); elseif (B <= 3.2e+117) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(C - hypot(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 <= 5.4e+20)
tmp = -sqrt((2.0 * ((t_1 * F) * (2.0 * A)))) / t_1;
elseif (B <= 3.2e+117)
tmp = -sqrt((2.0 * (t_0 * (F * (C - hypot(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, 5.4e+20], N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$1 * F), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B, 3.2e+117], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(C - N[Sqrt[C ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $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 5.4 \cdot 10^{+20}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_1 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_1}\\
\mathbf{elif}\;B \leq 3.2 \cdot 10^{+117}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(C - \mathsf{hypot}\left(C, B\right)\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 5.4e20Initial program 19.6%
Simplified19.6%
Taylor expanded in A around -inf 19.1%
*-commutative19.1%
Simplified19.1%
if 5.4e20 < B < 3.20000000000000005e117Initial program 31.8%
Simplified31.8%
Taylor expanded in A around 0 32.1%
+-commutative32.1%
unpow232.1%
unpow232.1%
hypot-def32.4%
Simplified32.4%
distribute-frac-neg32.4%
associate-*l*32.6%
cancel-sign-sub-inv32.6%
metadata-eval32.6%
cancel-sign-sub-inv32.6%
metadata-eval32.6%
Applied egg-rr32.6%
if 3.20000000000000005e117 < B Initial program 0.6%
Simplified0.6%
Taylor expanded in A around -inf 0.3%
*-commutative0.3%
Simplified0.3%
Taylor expanded in B around inf 4.1%
associate-*r/4.1%
*-rgt-identity4.1%
*-commutative4.1%
Simplified4.1%
Final simplification17.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) (* 4.0 (* A C)))) (t_1 (* t_0 F)))
(if (<= C 1.12e+42)
(/ (- (sqrt (* 2.0 (* t_1 (- A (hypot A B)))))) t_0)
(/ (- (sqrt (* 2.0 (* t_1 (* 2.0 A))))) t_0))))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 t_1 = t_0 * F;
double tmp;
if (C <= 1.12e+42) {
tmp = -sqrt((2.0 * (t_1 * (A - hypot(A, B))))) / t_0;
} else {
tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
}
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) - (4.0 * (A * C));
double t_1 = t_0 * F;
double tmp;
if (C <= 1.12e+42) {
tmp = -Math.sqrt((2.0 * (t_1 * (A - Math.hypot(A, B))))) / t_0;
} else {
tmp = -Math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = t_0 * F tmp = 0 if C <= 1.12e+42: tmp = -math.sqrt((2.0 * (t_1 * (A - math.hypot(A, B))))) / t_0 else: tmp = -math.sqrt((2.0 * (t_1 * (2.0 * 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(4.0 * Float64(A * C))) t_1 = Float64(t_0 * F) tmp = 0.0 if (C <= 1.12e+42) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A - hypot(A, B)))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(2.0 * A))))) / t_0); 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));
t_1 = t_0 * F;
tmp = 0.0;
if (C <= 1.12e+42)
tmp = -sqrt((2.0 * (t_1 * (A - hypot(A, B))))) / t_0;
else
tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
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]}, Block[{t$95$1 = N[(t$95$0 * F), $MachinePrecision]}, If[LessEqual[C, 1.12e+42], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(2.0 * A), $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 - 4 \cdot \left(A \cdot C\right)\\
t_1 := t_0 \cdot F\\
\mathbf{if}\;C \leq 1.12 \cdot 10^{+42}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\end{array}
\end{array}
if C < 1.12e42Initial program 21.2%
Simplified21.2%
Taylor expanded in C around 0 14.7%
+-commutative14.7%
unpow214.7%
unpow214.7%
hypot-def18.2%
Simplified18.2%
if 1.12e42 < C Initial program 2.7%
Simplified2.7%
Taylor expanded in A around -inf 30.8%
*-commutative30.8%
Simplified30.8%
Final simplification21.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 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 7e+20)
(/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 A))))) t_0)
(if (<= B 1.8e+117)
(/ (- (sqrt (* 2.0 (* (- C (hypot C B)) (* (* B B) F))))) 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) - (4.0 * (A * C));
double tmp;
if (B <= 7e+20) {
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else if (B <= 1.8e+117) {
tmp = -sqrt((2.0 * ((C - hypot(C, B)) * ((B * B) * F)))) / 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) - (4.0 * (A * C));
double tmp;
if (B <= 7e+20) {
tmp = -Math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else if (B <= 1.8e+117) {
tmp = -Math.sqrt((2.0 * ((C - Math.hypot(C, B)) * ((B * B) * F)))) / 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) - (4.0 * (A * C)) tmp = 0 if B <= 7e+20: tmp = -math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0 elif B <= 1.8e+117: tmp = -math.sqrt((2.0 * ((C - math.hypot(C, B)) * ((B * B) * F)))) / 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(4.0 * Float64(A * C))) tmp = 0.0 if (B <= 7e+20) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / t_0); elseif (B <= 1.8e+117) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(C - hypot(C, B)) * Float64(Float64(B * B) * F))))) / 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) - (4.0 * (A * C));
tmp = 0.0;
if (B <= 7e+20)
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
elseif (B <= 1.8e+117)
tmp = -sqrt((2.0 * ((C - hypot(C, B)) * ((B * B) * F)))) / 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[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 7e+20], N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 1.8e+117], N[((-N[Sqrt[N[(2.0 * N[(N[(C - N[Sqrt[C ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(B * B), $MachinePrecision] * F), $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 - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 7 \cdot 10^{+20}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 1.8 \cdot 10^{+117}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(C - \mathsf{hypot}\left(C, B\right)\right) \cdot \left(\left(B \cdot B\right) \cdot F\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 7e20Initial program 19.6%
Simplified19.6%
Taylor expanded in A around -inf 19.1%
*-commutative19.1%
Simplified19.1%
if 7e20 < B < 1.80000000000000006e117Initial program 31.8%
Simplified31.8%
Taylor expanded in A around 0 32.1%
+-commutative32.1%
unpow232.1%
unpow232.1%
hypot-def32.4%
Simplified32.4%
Taylor expanded in B around inf 32.1%
unpow232.1%
Simplified32.1%
if 1.80000000000000006e117 < B Initial program 0.6%
Simplified0.6%
Taylor expanded in A around -inf 0.3%
*-commutative0.3%
Simplified0.3%
Taylor expanded in B around inf 4.1%
associate-*r/4.1%
*-rgt-identity4.1%
*-commutative4.1%
Simplified4.1%
Final simplification17.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) (* 4.0 (* A C)))) (t_1 (* t_0 F)))
(if (<= B 8.5e+20)
(/ (- (sqrt (* 2.0 (* t_1 (* 2.0 A))))) t_0)
(if (<= B 1.5e+117)
(/ (- (sqrt (* 2.0 (* t_1 (- (+ 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) - (4.0 * (A * C));
double t_1 = t_0 * F;
double tmp;
if (B <= 8.5e+20) {
tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
} else if (B <= 1.5e+117) {
tmp = -sqrt((2.0 * (t_1 * ((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) - (4.0d0 * (a * c))
t_1 = t_0 * f
if (b <= 8.5d+20) then
tmp = -sqrt((2.0d0 * (t_1 * (2.0d0 * a)))) / t_0
else if (b <= 1.5d+117) then
tmp = -sqrt((2.0d0 * (t_1 * ((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) - (4.0 * (A * C));
double t_1 = t_0 * F;
double tmp;
if (B <= 8.5e+20) {
tmp = -Math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
} else if (B <= 1.5e+117) {
tmp = -Math.sqrt((2.0 * (t_1 * ((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) - (4.0 * (A * C)) t_1 = t_0 * F tmp = 0 if B <= 8.5e+20: tmp = -math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0 elif B <= 1.5e+117: tmp = -math.sqrt((2.0 * (t_1 * ((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(4.0 * Float64(A * C))) t_1 = Float64(t_0 * F) tmp = 0.0 if (B <= 8.5e+20) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(2.0 * A))))) / t_0); elseif (B <= 1.5e+117) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * 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) - (4.0 * (A * C));
t_1 = t_0 * F;
tmp = 0.0;
if (B <= 8.5e+20)
tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
elseif (B <= 1.5e+117)
tmp = -sqrt((2.0 * (t_1 * ((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[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * F), $MachinePrecision]}, If[LessEqual[B, 8.5e+20], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 1.5e+117], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * 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 - 4 \cdot \left(A \cdot C\right)\\
t_1 := t_0 \cdot F\\
\mathbf{if}\;B \leq 8.5 \cdot 10^{+20}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 1.5 \cdot 10^{+117}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \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 < 8.5e20Initial program 19.6%
Simplified19.6%
Taylor expanded in A around -inf 19.1%
*-commutative19.1%
Simplified19.1%
if 8.5e20 < B < 1.5e117Initial program 31.8%
Simplified31.8%
Taylor expanded in B around inf 24.9%
if 1.5e117 < B Initial program 0.6%
Simplified0.6%
Taylor expanded in A around -inf 0.3%
*-commutative0.3%
Simplified0.3%
Taylor expanded in B around inf 4.1%
associate-*r/4.1%
*-rgt-identity4.1%
*-commutative4.1%
Simplified4.1%
Final simplification16.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))))
(if (<= B 2.05e+62)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) 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 tmp;
if (B <= 2.05e+62) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / 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) :: tmp
t_0 = (b * b) + ((a * c) * (-4.0d0))
if (b <= 2.05d+62) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (2.0d0 * a))))) / 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 tmp;
if (B <= 2.05e+62) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / 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) tmp = 0 if B <= 2.05e+62: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / 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)) tmp = 0.0 if (B <= 2.05e+62) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / 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);
tmp = 0.0;
if (B <= 2.05e+62)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / 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]}, If[LessEqual[B, 2.05e+62], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(2.0 * A), $MachinePrecision]), $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\\
\mathbf{if}\;B \leq 2.05 \cdot 10^{+62}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 2.04999999999999992e62Initial program 19.7%
Simplified19.7%
Taylor expanded in A around -inf 19.3%
*-commutative19.3%
Simplified19.3%
distribute-frac-neg19.3%
associate-*l*19.0%
cancel-sign-sub-inv19.0%
metadata-eval19.0%
*-commutative19.0%
cancel-sign-sub-inv19.0%
metadata-eval19.0%
Applied egg-rr19.0%
if 2.04999999999999992e62 < B Initial program 6.4%
Simplified6.4%
Taylor expanded in A around -inf 0.7%
*-commutative0.7%
Simplified0.7%
Taylor expanded in B around inf 3.9%
associate-*r/3.9%
*-rgt-identity3.9%
*-commutative3.9%
Simplified3.9%
Final simplification15.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) (* 4.0 (* A C)))))
(if (<= B 6.5e+61)
(/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 A))))) 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) - (4.0 * (A * C));
double tmp;
if (B <= 6.5e+61) {
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / 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) :: tmp
t_0 = (b * b) - (4.0d0 * (a * c))
if (b <= 6.5d+61) then
tmp = -sqrt((2.0d0 * ((t_0 * f) * (2.0d0 * a)))) / 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) - (4.0 * (A * C));
double tmp;
if (B <= 6.5e+61) {
tmp = -Math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / 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) - (4.0 * (A * C)) tmp = 0 if B <= 6.5e+61: tmp = -math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / 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(4.0 * Float64(A * C))) tmp = 0.0 if (B <= 6.5e+61) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / 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) - (4.0 * (A * C));
tmp = 0.0;
if (B <= 6.5e+61)
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / 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[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 6.5e+61], N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * A), $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 - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 6.5 \cdot 10^{+61}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 6.4999999999999996e61Initial program 19.7%
Simplified19.7%
Taylor expanded in A around -inf 19.3%
*-commutative19.3%
Simplified19.3%
if 6.4999999999999996e61 < B Initial program 6.4%
Simplified6.4%
Taylor expanded in A around -inf 0.7%
*-commutative0.7%
Simplified0.7%
Taylor expanded in B around inf 3.9%
associate-*r/3.9%
*-rgt-identity3.9%
*-commutative3.9%
Simplified3.9%
Final simplification16.2%
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 (* (* 2.0 A) (* (* A -4.0) (* C F)))))) (- (* B B) (* 4.0 (* A C)))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -sqrt((2.0 * ((2.0 * A) * ((A * -4.0) * (C * F))))) / ((B * B) - (4.0 * (A * C)));
}
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 * ((2.0d0 * a) * ((a * (-4.0d0)) * (c * f))))) / ((b * b) - (4.0d0 * (a * c)))
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 * ((2.0 * A) * ((A * -4.0) * (C * F))))) / ((B * B) - (4.0 * (A * C)));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -math.sqrt((2.0 * ((2.0 * A) * ((A * -4.0) * (C * F))))) / ((B * B) - (4.0 * (A * C)))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(Float64(A * -4.0) * Float64(C * F)))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt((2.0 * ((2.0 * A) * ((A * -4.0) * (C * F))))) / ((B * B) - (4.0 * (A * C)));
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[(2.0 * A), $MachinePrecision] * N[(N[(A * -4.0), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(\left(A \cdot -4\right) \cdot \left(C \cdot F\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\end{array}
Initial program 17.0%
Simplified17.0%
Taylor expanded in A around -inf 15.5%
*-commutative15.5%
Simplified15.5%
Taylor expanded in B around 0 11.8%
associate-*r*11.8%
*-commutative11.8%
Simplified11.8%
Final simplification11.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 (/ (- (sqrt (* 2.0 (* (* C F) (* (* A A) -8.0))))) (- (* B B) (* 4.0 (* A C)))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -sqrt((2.0 * ((C * F) * ((A * A) * -8.0)))) / ((B * B) - (4.0 * (A * C)));
}
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 * ((c * f) * ((a * a) * (-8.0d0))))) / ((b * b) - (4.0d0 * (a * c)))
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 * ((C * F) * ((A * A) * -8.0)))) / ((B * B) - (4.0 * (A * C)));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -math.sqrt((2.0 * ((C * F) * ((A * A) * -8.0)))) / ((B * B) - (4.0 * (A * C)))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(C * F) * Float64(Float64(A * A) * -8.0))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt((2.0 * ((C * F) * ((A * A) * -8.0)))) / ((B * B) - (4.0 * (A * C)));
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[(C * F), $MachinePrecision] * N[(N[(A * A), $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{-\sqrt{2 \cdot \left(\left(C \cdot F\right) \cdot \left(\left(A \cdot A\right) \cdot -8\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\end{array}
Initial program 17.0%
Simplified17.0%
Taylor expanded in A around -inf 15.5%
*-commutative15.5%
Simplified15.5%
Taylor expanded in B around 0 9.6%
associate-*r*9.6%
unpow29.6%
*-commutative9.6%
Simplified9.6%
Final simplification9.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)) 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.0%
Simplified17.0%
Taylor expanded in A around -inf 15.5%
*-commutative15.5%
Simplified15.5%
Taylor expanded in B around inf 3.8%
associate-*r/3.8%
*-rgt-identity3.8%
*-commutative3.8%
Simplified3.8%
Final simplification3.8%
herbie shell --seed 2023207
(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))))