
(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 14 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))))
(t_1 (/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 A))))) t_0)))
(if (<= (pow B 2.0) 2e-223)
t_1
(if (<= (pow B 2.0) 2e-129)
(/
(*
(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))))
(if (<= (pow B 2.0) 5e-97)
t_1
(/ (- (sqrt (* F (* 2.0 (- A (hypot A B)))))) 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 = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
double tmp;
if (pow(B, 2.0) <= 2e-223) {
tmp = t_1;
} else if (pow(B, 2.0) <= 2e-129) {
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 if (pow(B, 2.0) <= 5e-97) {
tmp = t_1;
} else {
tmp = -sqrt((F * (2.0 * (A - hypot(A, B))))) / 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(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / t_0) tmp = 0.0 if ((B ^ 2.0) <= 2e-223) tmp = t_1; elseif ((B ^ 2.0) <= 2e-129) 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)))); elseif ((B ^ 2.0) <= 5e-97) tmp = t_1; else tmp = Float64(Float64(-sqrt(Float64(F * Float64(2.0 * Float64(A - hypot(A, B)))))) / 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]}, Block[{t$95$1 = 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[N[Power[B, 2.0], $MachinePrecision], 2e-223], t$95$1, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e-129], 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], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e-97], t$95$1, N[((-N[Sqrt[N[(F * N[(2.0 * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / B), $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 := \frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-223}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;{B}^{2} \leq 2 \cdot 10^{-129}:\\
\;\;\;\;\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{elif}\;{B}^{2} \leq 5 \cdot 10^{-97}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{F \cdot \left(2 \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 1.9999999999999999e-223 or 1.9999999999999999e-129 < (pow.f64 B 2) < 4.9999999999999995e-97Initial program 17.8%
Simplified17.8%
Taylor expanded in A around -inf 27.3%
*-commutative27.3%
Simplified27.3%
if 1.9999999999999999e-223 < (pow.f64 B 2) < 1.9999999999999999e-129Initial program 26.7%
Simplified32.9%
sqrt-prod50.6%
associate-*r*50.6%
*-commutative50.6%
associate-*l*50.6%
associate--r-50.6%
+-commutative50.6%
Applied egg-rr50.6%
hypot-def44.4%
unpow244.4%
unpow244.4%
+-commutative44.4%
unpow244.4%
unpow244.4%
hypot-def50.6%
Simplified50.6%
if 4.9999999999999995e-97 < (pow.f64 B 2) Initial program 13.2%
Simplified13.2%
Taylor expanded in C around 0 12.8%
mul-1-neg12.8%
*-commutative12.8%
+-commutative12.8%
unpow212.8%
unpow212.8%
hypot-def21.5%
Simplified21.5%
associate-*l/21.5%
Applied egg-rr21.5%
expm1-log1p-u20.8%
expm1-udef14.3%
sqrt-unprod14.3%
Applied egg-rr14.3%
expm1-def20.8%
expm1-log1p21.5%
*-commutative21.5%
associate-*l*21.5%
Simplified21.5%
Final simplification25.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
(let* ((t_0 (- (* B B) (* 4.0 (* A C))))
(t_1 (/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 A))))) t_0))
(t_2 (- A (hypot A B))))
(if (<= B 1.8e-104)
t_1
(if (<= B 8.5e-65)
(/ (* (sqrt (* F t_2)) (* B (- (sqrt 2.0)))) t_0)
(if (<= B 7.2e-45) t_1 (/ (- (sqrt (* F (* 2.0 t_2)))) 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 = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
double t_2 = A - hypot(A, B);
double tmp;
if (B <= 1.8e-104) {
tmp = t_1;
} else if (B <= 8.5e-65) {
tmp = (sqrt((F * t_2)) * (B * -sqrt(2.0))) / t_0;
} else if (B <= 7.2e-45) {
tmp = t_1;
} else {
tmp = -sqrt((F * (2.0 * t_2))) / 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 t_1 = -Math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
double t_2 = A - Math.hypot(A, B);
double tmp;
if (B <= 1.8e-104) {
tmp = t_1;
} else if (B <= 8.5e-65) {
tmp = (Math.sqrt((F * t_2)) * (B * -Math.sqrt(2.0))) / t_0;
} else if (B <= 7.2e-45) {
tmp = t_1;
} else {
tmp = -Math.sqrt((F * (2.0 * t_2))) / 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 = -math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0 t_2 = A - math.hypot(A, B) tmp = 0 if B <= 1.8e-104: tmp = t_1 elif B <= 8.5e-65: tmp = (math.sqrt((F * t_2)) * (B * -math.sqrt(2.0))) / t_0 elif B <= 7.2e-45: tmp = t_1 else: tmp = -math.sqrt((F * (2.0 * t_2))) / 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(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / t_0) t_2 = Float64(A - hypot(A, B)) tmp = 0.0 if (B <= 1.8e-104) tmp = t_1; elseif (B <= 8.5e-65) tmp = Float64(Float64(sqrt(Float64(F * t_2)) * Float64(B * Float64(-sqrt(2.0)))) / t_0); elseif (B <= 7.2e-45) tmp = t_1; else tmp = Float64(Float64(-sqrt(Float64(F * Float64(2.0 * t_2)))) / 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 = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
t_2 = A - hypot(A, B);
tmp = 0.0;
if (B <= 1.8e-104)
tmp = t_1;
elseif (B <= 8.5e-65)
tmp = (sqrt((F * t_2)) * (B * -sqrt(2.0))) / t_0;
elseif (B <= 7.2e-45)
tmp = t_1;
else
tmp = -sqrt((F * (2.0 * t_2))) / 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[((-N[Sqrt[N[(2.0 * N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 1.8e-104], t$95$1, If[LessEqual[B, 8.5e-65], N[(N[(N[Sqrt[N[(F * t$95$2), $MachinePrecision]], $MachinePrecision] * N[(B * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[B, 7.2e-45], t$95$1, N[((-N[Sqrt[N[(F * N[(2.0 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / B), $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 := \frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
t_2 := A - \mathsf{hypot}\left(A, B\right)\\
\mathbf{if}\;B \leq 1.8 \cdot 10^{-104}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;B \leq 8.5 \cdot 10^{-65}:\\
\;\;\;\;\frac{\sqrt{F \cdot t_2} \cdot \left(B \cdot \left(-\sqrt{2}\right)\right)}{t_0}\\
\mathbf{elif}\;B \leq 7.2 \cdot 10^{-45}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{F \cdot \left(2 \cdot t_2\right)}}{B}\\
\end{array}
\end{array}
if B < 1.7999999999999999e-104 or 8.5000000000000003e-65 < B < 7.20000000000000001e-45Initial program 15.2%
Simplified15.2%
Taylor expanded in A around -inf 15.2%
*-commutative15.2%
Simplified15.2%
if 1.7999999999999999e-104 < B < 8.5000000000000003e-65Initial program 22.3%
Simplified22.3%
Taylor expanded in C around 0 43.9%
*-commutative43.9%
+-commutative43.9%
unpow243.9%
unpow243.9%
hypot-def44.4%
*-commutative44.4%
Simplified44.4%
if 7.20000000000000001e-45 < B Initial program 15.8%
Simplified15.8%
Taylor expanded in C around 0 25.1%
mul-1-neg25.1%
*-commutative25.1%
+-commutative25.1%
unpow225.1%
unpow225.1%
hypot-def41.8%
Simplified41.8%
associate-*l/41.9%
Applied egg-rr41.9%
expm1-log1p-u40.4%
expm1-udef26.8%
sqrt-unprod26.8%
Applied egg-rr26.8%
expm1-def40.4%
expm1-log1p42.0%
*-commutative42.0%
associate-*l*42.0%
Simplified42.0%
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 (- A (hypot A B)))
(t_1 (- (* B B) (* 4.0 (* A C))))
(t_2 (/ (- (sqrt (* 2.0 (* (* t_1 F) (* 2.0 A))))) t_1)))
(if (<= B 2.2e-104)
t_2
(if (<= B 4.4e-65)
(* (sqrt (* F t_0)) (/ (- (sqrt 2.0)) B))
(if (<= B 5.2e-42) t_2 (/ (- (sqrt (* F (* 2.0 t_0)))) B))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = A - hypot(A, B);
double t_1 = (B * B) - (4.0 * (A * C));
double t_2 = -sqrt((2.0 * ((t_1 * F) * (2.0 * A)))) / t_1;
double tmp;
if (B <= 2.2e-104) {
tmp = t_2;
} else if (B <= 4.4e-65) {
tmp = sqrt((F * t_0)) * (-sqrt(2.0) / B);
} else if (B <= 5.2e-42) {
tmp = t_2;
} else {
tmp = -sqrt((F * (2.0 * t_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 = A - Math.hypot(A, B);
double t_1 = (B * B) - (4.0 * (A * C));
double t_2 = -Math.sqrt((2.0 * ((t_1 * F) * (2.0 * A)))) / t_1;
double tmp;
if (B <= 2.2e-104) {
tmp = t_2;
} else if (B <= 4.4e-65) {
tmp = Math.sqrt((F * t_0)) * (-Math.sqrt(2.0) / B);
} else if (B <= 5.2e-42) {
tmp = t_2;
} else {
tmp = -Math.sqrt((F * (2.0 * t_0))) / B;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = A - math.hypot(A, B) t_1 = (B * B) - (4.0 * (A * C)) t_2 = -math.sqrt((2.0 * ((t_1 * F) * (2.0 * A)))) / t_1 tmp = 0 if B <= 2.2e-104: tmp = t_2 elif B <= 4.4e-65: tmp = math.sqrt((F * t_0)) * (-math.sqrt(2.0) / B) elif B <= 5.2e-42: tmp = t_2 else: tmp = -math.sqrt((F * (2.0 * t_0))) / B return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(A - hypot(A, B)) t_1 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_2 = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_1 * F) * Float64(2.0 * A))))) / t_1) tmp = 0.0 if (B <= 2.2e-104) tmp = t_2; elseif (B <= 4.4e-65) tmp = Float64(sqrt(Float64(F * t_0)) * Float64(Float64(-sqrt(2.0)) / B)); elseif (B <= 5.2e-42) tmp = t_2; else tmp = Float64(Float64(-sqrt(Float64(F * Float64(2.0 * t_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 = A - hypot(A, B);
t_1 = (B * B) - (4.0 * (A * C));
t_2 = -sqrt((2.0 * ((t_1 * F) * (2.0 * A)))) / t_1;
tmp = 0.0;
if (B <= 2.2e-104)
tmp = t_2;
elseif (B <= 4.4e-65)
tmp = sqrt((F * t_0)) * (-sqrt(2.0) / B);
elseif (B <= 5.2e-42)
tmp = t_2;
else
tmp = -sqrt((F * (2.0 * t_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[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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, 2.2e-104], t$95$2, If[LessEqual[B, 4.4e-65], N[(N[Sqrt[N[(F * t$95$0), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 5.2e-42], t$95$2, N[((-N[Sqrt[N[(F * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / B), $MachinePrecision]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := A - \mathsf{hypot}\left(A, B\right)\\
t_1 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_2 := \frac{-\sqrt{2 \cdot \left(\left(t_1 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_1}\\
\mathbf{if}\;B \leq 2.2 \cdot 10^{-104}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;B \leq 4.4 \cdot 10^{-65}:\\
\;\;\;\;\sqrt{F \cdot t_0} \cdot \frac{-\sqrt{2}}{B}\\
\mathbf{elif}\;B \leq 5.2 \cdot 10^{-42}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{F \cdot \left(2 \cdot t_0\right)}}{B}\\
\end{array}
\end{array}
if B < 2.20000000000000012e-104 or 4.40000000000000042e-65 < B < 5.2e-42Initial program 15.2%
Simplified15.2%
Taylor expanded in A around -inf 15.2%
*-commutative15.2%
Simplified15.2%
if 2.20000000000000012e-104 < B < 4.40000000000000042e-65Initial program 22.3%
Simplified22.3%
Taylor expanded in C around 0 44.1%
mul-1-neg44.1%
*-commutative44.1%
+-commutative44.1%
unpow244.1%
unpow244.1%
hypot-def44.6%
Simplified44.6%
if 5.2e-42 < B Initial program 15.8%
Simplified15.8%
Taylor expanded in C around 0 25.1%
mul-1-neg25.1%
*-commutative25.1%
+-commutative25.1%
unpow225.1%
unpow225.1%
hypot-def41.8%
Simplified41.8%
associate-*l/41.9%
Applied egg-rr41.9%
expm1-log1p-u40.4%
expm1-udef26.8%
sqrt-unprod26.8%
Applied egg-rr26.8%
expm1-def40.4%
expm1-log1p42.0%
*-commutative42.0%
associate-*l*42.0%
Simplified42.0%
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 (* (sqrt (* B (- F))) (/ (- (sqrt 2.0)) B)))
(t_1 (- (* B B) (* 4.0 (* A C))))
(t_2 (* t_1 F))
(t_3 (/ (- (sqrt (* 2.0 (* t_2 (* 2.0 A))))) t_1))
(t_4 (+ (* B B) (* (* A C) -4.0))))
(if (<= B 9.4e-104)
t_3
(if (<= B 4.4e-65)
t_0
(if (<= B 4.5e-42)
t_3
(if (<= B 2.6e-23)
t_0
(if (<= B 31000000.0)
(* (sqrt (* 2.0 (* t_4 (* F (* 2.0 A))))) (/ -1.0 t_4))
(if (<= B 5e+47)
(/ (- (sqrt (* 2.0 (* t_2 (- (+ A C) B))))) t_1)
t_0))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt((B * -F)) * (-sqrt(2.0) / B);
double t_1 = (B * B) - (4.0 * (A * C));
double t_2 = t_1 * F;
double t_3 = -sqrt((2.0 * (t_2 * (2.0 * A)))) / t_1;
double t_4 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= 9.4e-104) {
tmp = t_3;
} else if (B <= 4.4e-65) {
tmp = t_0;
} else if (B <= 4.5e-42) {
tmp = t_3;
} else if (B <= 2.6e-23) {
tmp = t_0;
} else if (B <= 31000000.0) {
tmp = sqrt((2.0 * (t_4 * (F * (2.0 * A))))) * (-1.0 / t_4);
} else if (B <= 5e+47) {
tmp = -sqrt((2.0 * (t_2 * ((A + C) - B)))) / t_1;
} else {
tmp = t_0;
}
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) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sqrt((b * -f)) * (-sqrt(2.0d0) / b)
t_1 = (b * b) - (4.0d0 * (a * c))
t_2 = t_1 * f
t_3 = -sqrt((2.0d0 * (t_2 * (2.0d0 * a)))) / t_1
t_4 = (b * b) + ((a * c) * (-4.0d0))
if (b <= 9.4d-104) then
tmp = t_3
else if (b <= 4.4d-65) then
tmp = t_0
else if (b <= 4.5d-42) then
tmp = t_3
else if (b <= 2.6d-23) then
tmp = t_0
else if (b <= 31000000.0d0) then
tmp = sqrt((2.0d0 * (t_4 * (f * (2.0d0 * a))))) * ((-1.0d0) / t_4)
else if (b <= 5d+47) then
tmp = -sqrt((2.0d0 * (t_2 * ((a + c) - b)))) / t_1
else
tmp = t_0
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 = Math.sqrt((B * -F)) * (-Math.sqrt(2.0) / B);
double t_1 = (B * B) - (4.0 * (A * C));
double t_2 = t_1 * F;
double t_3 = -Math.sqrt((2.0 * (t_2 * (2.0 * A)))) / t_1;
double t_4 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= 9.4e-104) {
tmp = t_3;
} else if (B <= 4.4e-65) {
tmp = t_0;
} else if (B <= 4.5e-42) {
tmp = t_3;
} else if (B <= 2.6e-23) {
tmp = t_0;
} else if (B <= 31000000.0) {
tmp = Math.sqrt((2.0 * (t_4 * (F * (2.0 * A))))) * (-1.0 / t_4);
} else if (B <= 5e+47) {
tmp = -Math.sqrt((2.0 * (t_2 * ((A + C) - B)))) / t_1;
} else {
tmp = t_0;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt((B * -F)) * (-math.sqrt(2.0) / B) t_1 = (B * B) - (4.0 * (A * C)) t_2 = t_1 * F t_3 = -math.sqrt((2.0 * (t_2 * (2.0 * A)))) / t_1 t_4 = (B * B) + ((A * C) * -4.0) tmp = 0 if B <= 9.4e-104: tmp = t_3 elif B <= 4.4e-65: tmp = t_0 elif B <= 4.5e-42: tmp = t_3 elif B <= 2.6e-23: tmp = t_0 elif B <= 31000000.0: tmp = math.sqrt((2.0 * (t_4 * (F * (2.0 * A))))) * (-1.0 / t_4) elif B <= 5e+47: tmp = -math.sqrt((2.0 * (t_2 * ((A + C) - B)))) / t_1 else: tmp = t_0 return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(sqrt(Float64(B * Float64(-F))) * Float64(Float64(-sqrt(2.0)) / B)) t_1 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_2 = Float64(t_1 * F) t_3 = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_2 * Float64(2.0 * A))))) / t_1) t_4 = Float64(Float64(B * B) + Float64(Float64(A * C) * -4.0)) tmp = 0.0 if (B <= 9.4e-104) tmp = t_3; elseif (B <= 4.4e-65) tmp = t_0; elseif (B <= 4.5e-42) tmp = t_3; elseif (B <= 2.6e-23) tmp = t_0; elseif (B <= 31000000.0) tmp = Float64(sqrt(Float64(2.0 * Float64(t_4 * Float64(F * Float64(2.0 * A))))) * Float64(-1.0 / t_4)); elseif (B <= 5e+47) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_2 * Float64(Float64(A + C) - B))))) / t_1); else tmp = 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 = sqrt((B * -F)) * (-sqrt(2.0) / B);
t_1 = (B * B) - (4.0 * (A * C));
t_2 = t_1 * F;
t_3 = -sqrt((2.0 * (t_2 * (2.0 * A)))) / t_1;
t_4 = (B * B) + ((A * C) * -4.0);
tmp = 0.0;
if (B <= 9.4e-104)
tmp = t_3;
elseif (B <= 4.4e-65)
tmp = t_0;
elseif (B <= 4.5e-42)
tmp = t_3;
elseif (B <= 2.6e-23)
tmp = t_0;
elseif (B <= 31000000.0)
tmp = sqrt((2.0 * (t_4 * (F * (2.0 * A))))) * (-1.0 / t_4);
elseif (B <= 5e+47)
tmp = -sqrt((2.0 * (t_2 * ((A + C) - B)))) / t_1;
else
tmp = 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[Sqrt[N[(B * (-F)), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * F), $MachinePrecision]}, Block[{t$95$3 = N[((-N[Sqrt[N[(2.0 * N[(t$95$2 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 9.4e-104], t$95$3, If[LessEqual[B, 4.4e-65], t$95$0, If[LessEqual[B, 4.5e-42], t$95$3, If[LessEqual[B, 2.6e-23], t$95$0, If[LessEqual[B, 31000000.0], N[(N[Sqrt[N[(2.0 * N[(t$95$4 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$4), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 5e+47], N[((-N[Sqrt[N[(2.0 * N[(t$95$2 * N[(N[(A + C), $MachinePrecision] - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], t$95$0]]]]]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{B \cdot \left(-F\right)} \cdot \frac{-\sqrt{2}}{B}\\
t_1 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_2 := t_1 \cdot F\\
t_3 := \frac{-\sqrt{2 \cdot \left(t_2 \cdot \left(2 \cdot A\right)\right)}}{t_1}\\
t_4 := B \cdot B + \left(A \cdot C\right) \cdot -4\\
\mathbf{if}\;B \leq 9.4 \cdot 10^{-104}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;B \leq 4.4 \cdot 10^{-65}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;B \leq 4.5 \cdot 10^{-42}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;B \leq 2.6 \cdot 10^{-23}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;B \leq 31000000:\\
\;\;\;\;\sqrt{2 \cdot \left(t_4 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)} \cdot \frac{-1}{t_4}\\
\mathbf{elif}\;B \leq 5 \cdot 10^{+47}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_2 \cdot \left(\left(A + C\right) - B\right)\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if B < 9.4e-104 or 4.40000000000000042e-65 < B < 4.5e-42Initial program 15.7%
Simplified15.7%
Taylor expanded in A around -inf 15.1%
*-commutative15.1%
Simplified15.1%
if 9.4e-104 < B < 4.40000000000000042e-65 or 4.5e-42 < B < 2.6e-23 or 5.00000000000000022e47 < B Initial program 10.9%
Simplified10.9%
Taylor expanded in C around 0 25.2%
mul-1-neg25.2%
*-commutative25.2%
+-commutative25.2%
unpow225.2%
unpow225.2%
hypot-def44.2%
Simplified44.2%
Taylor expanded in A around 0 38.6%
mul-1-neg38.6%
Simplified38.6%
if 2.6e-23 < B < 3.1e7Initial program 16.1%
Simplified16.1%
Taylor expanded in A around -inf 17.6%
*-commutative17.6%
Simplified17.6%
div-inv17.6%
associate-*l*17.6%
cancel-sign-sub-inv17.6%
metadata-eval17.6%
cancel-sign-sub-inv17.6%
metadata-eval17.6%
Applied egg-rr17.6%
if 3.1e7 < B < 5.00000000000000022e47Initial program 38.2%
Simplified38.2%
Taylor expanded in B around inf 40.6%
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 (- (sqrt 2.0)))
(t_1 (sqrt (* B (- F))))
(t_2 (* t_1 (/ t_0 B)))
(t_3 (- (* B B) (* 4.0 (* A C))))
(t_4 (* t_3 F))
(t_5 (/ (- (sqrt (* 2.0 (* t_4 (* 2.0 A))))) t_3))
(t_6 (+ (* B B) (* (* A C) -4.0))))
(if (<= B 9e-104)
t_5
(if (<= B 6.6e-65)
t_2
(if (<= B 2.6e-41)
t_5
(if (<= B 1.7e-24)
t_2
(if (<= B 27000000.0)
(* (sqrt (* 2.0 (* t_6 (* F (* 2.0 A))))) (/ -1.0 t_6))
(if (<= B 5.2e+47)
(/ (- (sqrt (* 2.0 (* t_4 (- (+ A C) B))))) t_3)
(/ (* t_1 t_0) B)))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = -sqrt(2.0);
double t_1 = sqrt((B * -F));
double t_2 = t_1 * (t_0 / B);
double t_3 = (B * B) - (4.0 * (A * C));
double t_4 = t_3 * F;
double t_5 = -sqrt((2.0 * (t_4 * (2.0 * A)))) / t_3;
double t_6 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= 9e-104) {
tmp = t_5;
} else if (B <= 6.6e-65) {
tmp = t_2;
} else if (B <= 2.6e-41) {
tmp = t_5;
} else if (B <= 1.7e-24) {
tmp = t_2;
} else if (B <= 27000000.0) {
tmp = sqrt((2.0 * (t_6 * (F * (2.0 * A))))) * (-1.0 / t_6);
} else if (B <= 5.2e+47) {
tmp = -sqrt((2.0 * (t_4 * ((A + C) - B)))) / t_3;
} else {
tmp = (t_1 * t_0) / 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) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = -sqrt(2.0d0)
t_1 = sqrt((b * -f))
t_2 = t_1 * (t_0 / b)
t_3 = (b * b) - (4.0d0 * (a * c))
t_4 = t_3 * f
t_5 = -sqrt((2.0d0 * (t_4 * (2.0d0 * a)))) / t_3
t_6 = (b * b) + ((a * c) * (-4.0d0))
if (b <= 9d-104) then
tmp = t_5
else if (b <= 6.6d-65) then
tmp = t_2
else if (b <= 2.6d-41) then
tmp = t_5
else if (b <= 1.7d-24) then
tmp = t_2
else if (b <= 27000000.0d0) then
tmp = sqrt((2.0d0 * (t_6 * (f * (2.0d0 * a))))) * ((-1.0d0) / t_6)
else if (b <= 5.2d+47) then
tmp = -sqrt((2.0d0 * (t_4 * ((a + c) - b)))) / t_3
else
tmp = (t_1 * t_0) / 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 = -Math.sqrt(2.0);
double t_1 = Math.sqrt((B * -F));
double t_2 = t_1 * (t_0 / B);
double t_3 = (B * B) - (4.0 * (A * C));
double t_4 = t_3 * F;
double t_5 = -Math.sqrt((2.0 * (t_4 * (2.0 * A)))) / t_3;
double t_6 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= 9e-104) {
tmp = t_5;
} else if (B <= 6.6e-65) {
tmp = t_2;
} else if (B <= 2.6e-41) {
tmp = t_5;
} else if (B <= 1.7e-24) {
tmp = t_2;
} else if (B <= 27000000.0) {
tmp = Math.sqrt((2.0 * (t_6 * (F * (2.0 * A))))) * (-1.0 / t_6);
} else if (B <= 5.2e+47) {
tmp = -Math.sqrt((2.0 * (t_4 * ((A + C) - B)))) / t_3;
} else {
tmp = (t_1 * t_0) / B;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = -math.sqrt(2.0) t_1 = math.sqrt((B * -F)) t_2 = t_1 * (t_0 / B) t_3 = (B * B) - (4.0 * (A * C)) t_4 = t_3 * F t_5 = -math.sqrt((2.0 * (t_4 * (2.0 * A)))) / t_3 t_6 = (B * B) + ((A * C) * -4.0) tmp = 0 if B <= 9e-104: tmp = t_5 elif B <= 6.6e-65: tmp = t_2 elif B <= 2.6e-41: tmp = t_5 elif B <= 1.7e-24: tmp = t_2 elif B <= 27000000.0: tmp = math.sqrt((2.0 * (t_6 * (F * (2.0 * A))))) * (-1.0 / t_6) elif B <= 5.2e+47: tmp = -math.sqrt((2.0 * (t_4 * ((A + C) - B)))) / t_3 else: tmp = (t_1 * t_0) / B return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(-sqrt(2.0)) t_1 = sqrt(Float64(B * Float64(-F))) t_2 = Float64(t_1 * Float64(t_0 / B)) t_3 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_4 = Float64(t_3 * F) t_5 = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_4 * Float64(2.0 * A))))) / t_3) t_6 = Float64(Float64(B * B) + Float64(Float64(A * C) * -4.0)) tmp = 0.0 if (B <= 9e-104) tmp = t_5; elseif (B <= 6.6e-65) tmp = t_2; elseif (B <= 2.6e-41) tmp = t_5; elseif (B <= 1.7e-24) tmp = t_2; elseif (B <= 27000000.0) tmp = Float64(sqrt(Float64(2.0 * Float64(t_6 * Float64(F * Float64(2.0 * A))))) * Float64(-1.0 / t_6)); elseif (B <= 5.2e+47) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_4 * Float64(Float64(A + C) - B))))) / t_3); else tmp = Float64(Float64(t_1 * t_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 = -sqrt(2.0);
t_1 = sqrt((B * -F));
t_2 = t_1 * (t_0 / B);
t_3 = (B * B) - (4.0 * (A * C));
t_4 = t_3 * F;
t_5 = -sqrt((2.0 * (t_4 * (2.0 * A)))) / t_3;
t_6 = (B * B) + ((A * C) * -4.0);
tmp = 0.0;
if (B <= 9e-104)
tmp = t_5;
elseif (B <= 6.6e-65)
tmp = t_2;
elseif (B <= 2.6e-41)
tmp = t_5;
elseif (B <= 1.7e-24)
tmp = t_2;
elseif (B <= 27000000.0)
tmp = sqrt((2.0 * (t_6 * (F * (2.0 * A))))) * (-1.0 / t_6);
elseif (B <= 5.2e+47)
tmp = -sqrt((2.0 * (t_4 * ((A + C) - B)))) / t_3;
else
tmp = (t_1 * t_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[Sqrt[2.0], $MachinePrecision])}, Block[{t$95$1 = N[Sqrt[N[(B * (-F)), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(t$95$0 / B), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * F), $MachinePrecision]}, Block[{t$95$5 = N[((-N[Sqrt[N[(2.0 * N[(t$95$4 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$3), $MachinePrecision]}, Block[{t$95$6 = N[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 9e-104], t$95$5, If[LessEqual[B, 6.6e-65], t$95$2, If[LessEqual[B, 2.6e-41], t$95$5, If[LessEqual[B, 1.7e-24], t$95$2, If[LessEqual[B, 27000000.0], N[(N[Sqrt[N[(2.0 * N[(t$95$6 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$6), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 5.2e+47], N[((-N[Sqrt[N[(2.0 * N[(t$95$4 * N[(N[(A + C), $MachinePrecision] - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$3), $MachinePrecision], N[(N[(t$95$1 * t$95$0), $MachinePrecision] / B), $MachinePrecision]]]]]]]]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := -\sqrt{2}\\
t_1 := \sqrt{B \cdot \left(-F\right)}\\
t_2 := t_1 \cdot \frac{t_0}{B}\\
t_3 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_4 := t_3 \cdot F\\
t_5 := \frac{-\sqrt{2 \cdot \left(t_4 \cdot \left(2 \cdot A\right)\right)}}{t_3}\\
t_6 := B \cdot B + \left(A \cdot C\right) \cdot -4\\
\mathbf{if}\;B \leq 9 \cdot 10^{-104}:\\
\;\;\;\;t_5\\
\mathbf{elif}\;B \leq 6.6 \cdot 10^{-65}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;B \leq 2.6 \cdot 10^{-41}:\\
\;\;\;\;t_5\\
\mathbf{elif}\;B \leq 1.7 \cdot 10^{-24}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;B \leq 27000000:\\
\;\;\;\;\sqrt{2 \cdot \left(t_6 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)} \cdot \frac{-1}{t_6}\\
\mathbf{elif}\;B \leq 5.2 \cdot 10^{+47}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_4 \cdot \left(\left(A + C\right) - B\right)\right)}}{t_3}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1 \cdot t_0}{B}\\
\end{array}
\end{array}
if B < 8.9999999999999995e-104 or 6.6000000000000002e-65 < B < 2.5999999999999999e-41Initial program 15.7%
Simplified15.7%
Taylor expanded in A around -inf 15.1%
*-commutative15.1%
Simplified15.1%
if 8.9999999999999995e-104 < B < 6.6000000000000002e-65 or 2.5999999999999999e-41 < B < 1.69999999999999996e-24Initial program 27.4%
Simplified27.4%
Taylor expanded in C around 0 63.8%
mul-1-neg63.8%
*-commutative63.8%
+-commutative63.8%
unpow263.8%
unpow263.8%
hypot-def64.1%
Simplified64.1%
Taylor expanded in A around 0 64.2%
mul-1-neg64.2%
Simplified64.2%
if 1.69999999999999996e-24 < B < 2.7e7Initial program 16.1%
Simplified16.1%
Taylor expanded in A around -inf 17.6%
*-commutative17.6%
Simplified17.6%
div-inv17.6%
associate-*l*17.6%
cancel-sign-sub-inv17.6%
metadata-eval17.6%
cancel-sign-sub-inv17.6%
metadata-eval17.6%
Applied egg-rr17.6%
if 2.7e7 < B < 5.20000000000000007e47Initial program 38.2%
Simplified38.2%
Taylor expanded in B around inf 40.6%
if 5.20000000000000007e47 < B Initial program 8.5%
Simplified8.5%
Taylor expanded in C around 0 19.5%
mul-1-neg19.5%
*-commutative19.5%
+-commutative19.5%
unpow219.5%
unpow219.5%
hypot-def41.3%
Simplified41.3%
associate-*l/41.3%
Applied egg-rr41.3%
Taylor expanded in A around 0 34.9%
mul-1-neg34.9%
Simplified34.9%
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) (* 4.0 (* A C)))))
(if (or (<= B 2.3e-104) (and (not (<= B 3.2e-64)) (<= B 4.3e-44)))
(/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 A))))) t_0)
(/ (- (sqrt (* F (* 2.0 (- A (hypot A B)))))) 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 <= 2.3e-104) || (!(B <= 3.2e-64) && (B <= 4.3e-44))) {
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else {
tmp = -sqrt((F * (2.0 * (A - hypot(A, B))))) / 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 <= 2.3e-104) || (!(B <= 3.2e-64) && (B <= 4.3e-44))) {
tmp = -Math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else {
tmp = -Math.sqrt((F * (2.0 * (A - Math.hypot(A, B))))) / 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 <= 2.3e-104) or (not (B <= 3.2e-64) and (B <= 4.3e-44)): tmp = -math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0 else: tmp = -math.sqrt((F * (2.0 * (A - math.hypot(A, B))))) / 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 <= 2.3e-104) || (!(B <= 3.2e-64) && (B <= 4.3e-44))) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(F * Float64(2.0 * Float64(A - hypot(A, B)))))) / 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 <= 2.3e-104) || (~((B <= 3.2e-64)) && (B <= 4.3e-44)))
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
else
tmp = -sqrt((F * (2.0 * (A - hypot(A, B))))) / 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[Or[LessEqual[B, 2.3e-104], And[N[Not[LessEqual[B, 3.2e-64]], $MachinePrecision], LessEqual[B, 4.3e-44]]], 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[(2.0 * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / B), $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 2.3 \cdot 10^{-104} \lor \neg \left(B \leq 3.2 \cdot 10^{-64}\right) \land B \leq 4.3 \cdot 10^{-44}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{F \cdot \left(2 \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{B}\\
\end{array}
\end{array}
if B < 2.2999999999999999e-104 or 3.19999999999999975e-64 < B < 4.30000000000000013e-44Initial program 15.2%
Simplified15.2%
Taylor expanded in A around -inf 15.2%
*-commutative15.2%
Simplified15.2%
if 2.2999999999999999e-104 < B < 3.19999999999999975e-64 or 4.30000000000000013e-44 < B Initial program 16.2%
Simplified16.2%
Taylor expanded in C around 0 26.2%
mul-1-neg26.2%
*-commutative26.2%
+-commutative26.2%
unpow226.2%
unpow226.2%
hypot-def42.0%
Simplified42.0%
associate-*l/42.1%
Applied egg-rr42.1%
expm1-log1p-u40.6%
expm1-udef25.6%
sqrt-unprod25.6%
Applied egg-rr25.6%
expm1-def40.6%
expm1-log1p42.1%
*-commutative42.1%
associate-*l*42.1%
Simplified42.1%
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) (* 4.0 (* A C))))
(t_1 (/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 A))))) t_0)))
(if (<= B 9.4e-104)
t_1
(if (<= B 7e-65)
(* (sqrt (* B (- F))) (/ (- (sqrt 2.0)) B))
(if (<= B 8.5e-43)
t_1
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A 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 = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
double tmp;
if (B <= 9.4e-104) {
tmp = t_1;
} else if (B <= 7e-65) {
tmp = sqrt((B * -F)) * (-sqrt(2.0) / B);
} else if (B <= 8.5e-43) {
tmp = t_1;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - 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 = -sqrt((2.0d0 * ((t_0 * f) * (2.0d0 * a)))) / t_0
if (b <= 9.4d-104) then
tmp = t_1
else if (b <= 7d-65) then
tmp = sqrt((b * -f)) * (-sqrt(2.0d0) / b)
else if (b <= 8.5d-43) then
tmp = t_1
else
tmp = (sqrt(2.0d0) / b) * -sqrt((f * (a - 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 = -Math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
double tmp;
if (B <= 9.4e-104) {
tmp = t_1;
} else if (B <= 7e-65) {
tmp = Math.sqrt((B * -F)) * (-Math.sqrt(2.0) / B);
} else if (B <= 8.5e-43) {
tmp = t_1;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * (A - 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 = -math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0 tmp = 0 if B <= 9.4e-104: tmp = t_1 elif B <= 7e-65: tmp = math.sqrt((B * -F)) * (-math.sqrt(2.0) / B) elif B <= 8.5e-43: tmp = t_1 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * (A - 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(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / t_0) tmp = 0.0 if (B <= 9.4e-104) tmp = t_1; elseif (B <= 7e-65) tmp = Float64(sqrt(Float64(B * Float64(-F))) * Float64(Float64(-sqrt(2.0)) / B)); elseif (B <= 8.5e-43) tmp = t_1; else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - 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 = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
tmp = 0.0;
if (B <= 9.4e-104)
tmp = t_1;
elseif (B <= 7e-65)
tmp = sqrt((B * -F)) * (-sqrt(2.0) / B);
elseif (B <= 8.5e-43)
tmp = t_1;
else
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - 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[((-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, 9.4e-104], t$95$1, If[LessEqual[B, 7e-65], N[(N[Sqrt[N[(B * (-F)), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 8.5e-43], t$95$1, N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $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 := \frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{if}\;B \leq 9.4 \cdot 10^{-104}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;B \leq 7 \cdot 10^{-65}:\\
\;\;\;\;\sqrt{B \cdot \left(-F\right)} \cdot \frac{-\sqrt{2}}{B}\\
\mathbf{elif}\;B \leq 8.5 \cdot 10^{-43}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < 9.4e-104 or 7.00000000000000009e-65 < B < 8.50000000000000056e-43Initial program 15.7%
Simplified15.7%
Taylor expanded in A around -inf 15.1%
*-commutative15.1%
Simplified15.1%
if 9.4e-104 < B < 7.00000000000000009e-65Initial program 3.3%
Simplified3.3%
Taylor expanded in C around 0 51.1%
mul-1-neg51.1%
*-commutative51.1%
+-commutative51.1%
unpow251.1%
unpow251.1%
hypot-def51.6%
Simplified51.6%
Taylor expanded in A around 0 51.8%
mul-1-neg51.8%
Simplified51.8%
if 8.50000000000000056e-43 < B Initial program 15.8%
Simplified15.8%
Taylor expanded in C around 0 25.1%
mul-1-neg25.1%
*-commutative25.1%
+-commutative25.1%
unpow225.1%
unpow225.1%
hypot-def41.8%
Simplified41.8%
add-log-exp2.8%
Applied egg-rr2.8%
Taylor expanded in A around 0 35.4%
neg-mul-135.4%
unsub-neg35.4%
Simplified35.4%
Final simplification21.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 (<= B 8e-41)
(/ (- (sqrt (* 2.0 (* t_1 (* 2.0 A))))) t_0)
(if (<= B 8.5e+47)
(/ (- (sqrt (* 2.0 (* t_1 (- (+ A C) B))))) t_0)
(* -2.0 (sqrt (/ F (/ B (/ A 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 <= 8e-41) {
tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
} else if (B <= 8.5e+47) {
tmp = -sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0;
} else {
tmp = -2.0 * sqrt((F / (B / (A / 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 <= 8d-41) then
tmp = -sqrt((2.0d0 * (t_1 * (2.0d0 * a)))) / t_0
else if (b <= 8.5d+47) then
tmp = -sqrt((2.0d0 * (t_1 * ((a + c) - b)))) / t_0
else
tmp = (-2.0d0) * sqrt((f / (b / (a / 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 <= 8e-41) {
tmp = -Math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
} else if (B <= 8.5e+47) {
tmp = -Math.sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0;
} else {
tmp = -2.0 * Math.sqrt((F / (B / (A / 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 <= 8e-41: tmp = -math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0 elif B <= 8.5e+47: tmp = -math.sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0 else: tmp = -2.0 * math.sqrt((F / (B / (A / 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 <= 8e-41) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(2.0 * A))))) / t_0); elseif (B <= 8.5e+47) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(Float64(A + C) - B))))) / t_0); else tmp = Float64(-2.0 * sqrt(Float64(F / Float64(B / Float64(A / 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 <= 8e-41)
tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
elseif (B <= 8.5e+47)
tmp = -sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0;
else
tmp = -2.0 * sqrt((F / (B / (A / 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, 8e-41], 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, 8.5e+47], 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[Sqrt[N[(F / N[(B / N[(A / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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 \cdot 10^{-41}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 8.5 \cdot 10^{+47}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(\left(A + C\right) - B\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \sqrt{\frac{F}{\frac{B}{\frac{A}{B}}}}\\
\end{array}
\end{array}
if B < 8.00000000000000005e-41Initial program 15.4%
Simplified15.4%
Taylor expanded in A around -inf 14.9%
*-commutative14.9%
Simplified14.9%
if 8.00000000000000005e-41 < B < 8.5000000000000008e47Initial program 33.6%
Simplified33.6%
Taylor expanded in B around inf 30.9%
if 8.5000000000000008e47 < B Initial program 8.5%
Simplified8.5%
Taylor expanded in A around -inf 4.7%
*-commutative4.7%
Simplified4.7%
Taylor expanded in B around inf 9.0%
*-commutative9.0%
Simplified9.0%
add-sqr-sqrt9.0%
sqrt-unprod8.5%
un-div-inv8.5%
un-div-inv8.5%
frac-times6.5%
add-sqr-sqrt6.9%
Applied egg-rr6.9%
associate-/l*9.0%
associate-/l*12.6%
Simplified12.6%
Final simplification15.8%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* (* A C) -4.0))))
(if (<= B 1.4e+36)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(* -2.0 (sqrt (/ F (/ B (/ A 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 <= 1.4e+36) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -2.0 * sqrt((F / (B / (A / 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 <= 1.4d+36) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (2.0d0 * a))))) / t_0
else
tmp = (-2.0d0) * sqrt((f / (b / (a / 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 <= 1.4e+36) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -2.0 * Math.sqrt((F / (B / (A / 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 <= 1.4e+36: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = -2.0 * math.sqrt((F / (B / (A / 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 <= 1.4e+36) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(-2.0 * sqrt(Float64(F / Float64(B / Float64(A / 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 <= 1.4e+36)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = -2.0 * sqrt((F / (B / (A / 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, 1.4e+36], 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[Sqrt[N[(F / N[(B / N[(A / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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 1.4 \cdot 10^{+36}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \sqrt{\frac{F}{\frac{B}{\frac{A}{B}}}}\\
\end{array}
\end{array}
if B < 1.4e36Initial program 16.7%
Simplified16.7%
Taylor expanded in A around -inf 14.9%
*-commutative14.9%
Simplified14.9%
distribute-frac-neg14.9%
associate-*l*14.0%
cancel-sign-sub-inv14.0%
metadata-eval14.0%
cancel-sign-sub-inv14.0%
metadata-eval14.0%
Applied egg-rr14.0%
if 1.4e36 < B Initial program 11.5%
Simplified11.5%
Taylor expanded in A around -inf 6.3%
*-commutative6.3%
Simplified6.3%
Taylor expanded in B around inf 10.3%
*-commutative10.3%
Simplified10.3%
add-sqr-sqrt10.3%
sqrt-unprod9.8%
un-div-inv9.8%
un-div-inv9.8%
frac-times7.9%
add-sqr-sqrt8.3%
Applied egg-rr8.3%
associate-/l*10.3%
associate-/l*13.6%
Simplified13.6%
Final simplification13.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 1.5e+36)
(/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 A))))) t_0)
(* -2.0 (sqrt (/ F (/ B (/ A 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.5e+36) {
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else {
tmp = -2.0 * sqrt((F / (B / (A / 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.5d+36) then
tmp = -sqrt((2.0d0 * ((t_0 * f) * (2.0d0 * a)))) / t_0
else
tmp = (-2.0d0) * sqrt((f / (b / (a / 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.5e+36) {
tmp = -Math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else {
tmp = -2.0 * Math.sqrt((F / (B / (A / 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.5e+36: tmp = -math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0 else: tmp = -2.0 * math.sqrt((F / (B / (A / 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.5e+36) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / t_0); else tmp = Float64(-2.0 * sqrt(Float64(F / Float64(B / Float64(A / 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.5e+36)
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
else
tmp = -2.0 * sqrt((F / (B / (A / 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.5e+36], 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[Sqrt[N[(F / N[(B / N[(A / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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.5 \cdot 10^{+36}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \sqrt{\frac{F}{\frac{B}{\frac{A}{B}}}}\\
\end{array}
\end{array}
if B < 1.5e36Initial program 16.7%
Simplified16.7%
Taylor expanded in A around -inf 14.9%
*-commutative14.9%
Simplified14.9%
if 1.5e36 < B Initial program 11.5%
Simplified11.5%
Taylor expanded in A around -inf 6.3%
*-commutative6.3%
Simplified6.3%
Taylor expanded in B around inf 10.3%
*-commutative10.3%
Simplified10.3%
add-sqr-sqrt10.3%
sqrt-unprod9.8%
un-div-inv9.8%
un-div-inv9.8%
frac-times7.9%
add-sqr-sqrt8.3%
Applied egg-rr8.3%
associate-/l*10.3%
associate-/l*13.6%
Simplified13.6%
Final simplification14.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
(if (<= B 7.4e+33)
(/
(- (sqrt (* 2.0 (* -8.0 (* A (* C (* A F)))))))
(- (* B B) (* 4.0 (* A C))))
(* -2.0 (sqrt (/ F (/ B (/ A B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 7.4e+33) {
tmp = -sqrt((2.0 * (-8.0 * (A * (C * (A * F)))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = -2.0 * sqrt((F / (B / (A / 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 <= 7.4d+33) then
tmp = -sqrt((2.0d0 * ((-8.0d0) * (a * (c * (a * f)))))) / ((b * b) - (4.0d0 * (a * c)))
else
tmp = (-2.0d0) * sqrt((f / (b / (a / 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 <= 7.4e+33) {
tmp = -Math.sqrt((2.0 * (-8.0 * (A * (C * (A * F)))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = -2.0 * Math.sqrt((F / (B / (A / B))));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= 7.4e+33: tmp = -math.sqrt((2.0 * (-8.0 * (A * (C * (A * F)))))) / ((B * B) - (4.0 * (A * C))) else: tmp = -2.0 * math.sqrt((F / (B / (A / B)))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 7.4e+33) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-8.0 * Float64(A * Float64(C * Float64(A * F))))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(-2.0 * sqrt(Float64(F / Float64(B / Float64(A / 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 <= 7.4e+33)
tmp = -sqrt((2.0 * (-8.0 * (A * (C * (A * F)))))) / ((B * B) - (4.0 * (A * C)));
else
tmp = -2.0 * sqrt((F / (B / (A / 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, 7.4e+33], N[((-N[Sqrt[N[(2.0 * N[(-8.0 * N[(A * N[(C * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[Sqrt[N[(F / N[(B / N[(A / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 7.4 \cdot 10^{+33}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-8 \cdot \left(A \cdot \left(C \cdot \left(A \cdot F\right)\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \sqrt{\frac{F}{\frac{B}{\frac{A}{B}}}}\\
\end{array}
\end{array}
if B < 7.3999999999999997e33Initial program 16.9%
Simplified16.9%
Taylor expanded in A around -inf 15.0%
*-commutative15.0%
Simplified15.0%
Taylor expanded in B around 0 9.0%
unpow29.0%
*-commutative9.0%
associate-*r*12.1%
associate-*r*13.7%
*-commutative13.7%
Simplified13.7%
if 7.3999999999999997e33 < B Initial program 11.2%
Simplified11.2%
Taylor expanded in A around -inf 6.3%
*-commutative6.3%
Simplified6.3%
Taylor expanded in B around inf 10.2%
*-commutative10.2%
Simplified10.2%
add-sqr-sqrt10.1%
sqrt-unprod9.7%
un-div-inv9.7%
un-div-inv9.7%
frac-times7.8%
add-sqr-sqrt8.2%
Applied egg-rr8.2%
associate-/l*10.1%
associate-/l*13.3%
Simplified13.3%
Final simplification13.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 B) (/ F B)))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * sqrt(((A / B) * (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 / b) * (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 / B) * (F / B)));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * math.sqrt(((A / B) * (F / B)))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * sqrt(Float64(Float64(A / B) * Float64(F / B)))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * sqrt(((A / B) * (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[Sqrt[N[(N[(A / B), $MachinePrecision] * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \sqrt{\frac{A}{B} \cdot \frac{F}{B}}
\end{array}
Initial program 15.5%
Simplified15.5%
Taylor expanded in A around -inf 12.9%
*-commutative12.9%
Simplified12.9%
Taylor expanded in B around inf 4.3%
*-commutative4.3%
Simplified4.3%
add-sqr-sqrt3.9%
sqrt-unprod5.1%
un-div-inv5.1%
un-div-inv5.1%
frac-times3.8%
add-sqr-sqrt4.0%
Applied egg-rr4.0%
times-frac6.8%
Simplified6.8%
Final simplification6.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 (sqrt (/ F (/ B (/ A B))))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * sqrt((F / (B / (A / 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((f / (b / (a / 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((F / (B / (A / B))));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * math.sqrt((F / (B / (A / B))))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * sqrt(Float64(F / Float64(B / Float64(A / B))))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * sqrt((F / (B / (A / 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[Sqrt[N[(F / N[(B / N[(A / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \sqrt{\frac{F}{\frac{B}{\frac{A}{B}}}}
\end{array}
Initial program 15.5%
Simplified15.5%
Taylor expanded in A around -inf 12.9%
*-commutative12.9%
Simplified12.9%
Taylor expanded in B around inf 4.3%
*-commutative4.3%
Simplified4.3%
add-sqr-sqrt3.9%
sqrt-unprod5.1%
un-div-inv5.1%
un-div-inv5.1%
frac-times3.8%
add-sqr-sqrt4.0%
Applied egg-rr4.0%
associate-/l*5.5%
associate-/l*7.1%
Simplified7.1%
Final simplification7.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 15.5%
Simplified15.5%
Taylor expanded in A around -inf 12.9%
*-commutative12.9%
Simplified12.9%
Taylor expanded in B around inf 4.3%
*-commutative4.3%
Simplified4.3%
Taylor expanded in B around 0 4.3%
associate-*r/4.3%
*-commutative4.3%
*-rgt-identity4.3%
Simplified4.3%
Final simplification4.3%
herbie shell --seed 2023229
(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))))