
(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 (fma B B (* A (* C -4.0)))))
(if (<= (pow B 2.0) 1e-115)
(/
(- (sqrt (* 2.0 (* t_0 (* F (+ A (+ A (/ (* -0.5 (* B B)) (- C A)))))))))
t_0)
(if (<= (pow B 2.0) 1e-9)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A (- C (hypot B (- C A))))))))) t_0)
(if (<= (pow B 2.0) 2.0)
(* (sqrt (* -0.5 (/ (* B B) (/ C F)))) (/ (- (sqrt 2.0)) B))
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A (hypot A B)))))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (pow(B, 2.0) <= 1e-115) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + (A + ((-0.5 * (B * B)) / (C - A)))))))) / t_0;
} else if (pow(B, 2.0) <= 1e-9) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + (C - hypot(B, (C - A)))))))) / t_0;
} else if (pow(B, 2.0) <= 2.0) {
tmp = sqrt((-0.5 * ((B * B) / (C / F)))) * (-sqrt(2.0) / B);
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(A, B))));
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B ^ 2.0) <= 1e-115) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + Float64(A + Float64(Float64(-0.5 * Float64(B * B)) / Float64(C - A))))))))) / t_0); elseif ((B ^ 2.0) <= 1e-9) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + Float64(C - hypot(B, Float64(C - A))))))))) / t_0); elseif ((B ^ 2.0) <= 2.0) tmp = Float64(sqrt(Float64(-0.5 * Float64(Float64(B * B) / Float64(C / F)))) * Float64(Float64(-sqrt(2.0)) / B)); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - hypot(A, B)))))); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 1e-115], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + N[(A + N[(N[(-0.5 * N[(B * B), $MachinePrecision]), $MachinePrecision] / N[(C - A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 1e-9], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(C - A), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2.0], N[(N[Sqrt[N[(-0.5 * N[(N[(B * B), $MachinePrecision] / N[(C / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B}^{2} \leq 10^{-115}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + \left(A + \frac{-0.5 \cdot \left(B \cdot B\right)}{C - A}\right)\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;{B}^{2} \leq 10^{-9}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, C - A\right)\right)\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;{B}^{2} \leq 2:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{B \cdot B}{\frac{C}{F}}} \cdot \frac{-\sqrt{2}}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 1.0000000000000001e-115Initial program 23.3%
Simplified35.4%
Taylor expanded in B around 0 27.7%
associate-*r/27.7%
unpow227.7%
Simplified27.7%
if 1.0000000000000001e-115 < (pow.f64 B 2) < 1.00000000000000006e-9Initial program 55.6%
Simplified62.2%
if 1.00000000000000006e-9 < (pow.f64 B 2) < 2Initial program 31.1%
Simplified31.1%
Taylor expanded in A around 0 4.1%
mul-1-neg4.1%
*-commutative4.1%
distribute-rgt-neg-in4.1%
+-commutative4.1%
unpow24.1%
unpow24.1%
hypot-def4.5%
Simplified4.5%
Taylor expanded in C around inf 30.1%
associate-/l*30.1%
unpow230.1%
Simplified30.1%
if 2 < (pow.f64 B 2) Initial program 19.6%
Simplified19.6%
Taylor expanded in C around 0 17.6%
mul-1-neg17.6%
*-commutative17.6%
distribute-rgt-neg-in17.6%
unpow217.6%
unpow217.6%
hypot-def28.5%
Simplified28.5%
Final simplification31.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
(let* ((t_0 (fma B B (* A (* C -4.0)))))
(if (<= B 210000.0)
(/
(- (sqrt (* 2.0 (* t_0 (* F (+ A (+ A (/ (* -0.5 (* B B)) (- C A)))))))))
t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A (hypot A B)))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (B <= 210000.0) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + (A + ((-0.5 * (B * B)) / (C - A)))))))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(A, B))));
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (B <= 210000.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + Float64(A + Float64(Float64(-0.5 * Float64(B * B)) / Float64(C - A))))))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - hypot(A, B)))))); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 210000.0], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + N[(A + N[(N[(-0.5 * N[(B * B), $MachinePrecision]), $MachinePrecision] / N[(C - A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;B \leq 210000:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + \left(A + \frac{-0.5 \cdot \left(B \cdot B\right)}{C - A}\right)\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}\right)\\
\end{array}
\end{array}
if B < 2.1e5Initial program 25.6%
Simplified33.7%
Taylor expanded in B around 0 19.6%
associate-*r/19.6%
unpow219.6%
Simplified19.6%
if 2.1e5 < B Initial program 20.9%
Simplified20.9%
Taylor expanded in C around 0 33.2%
mul-1-neg33.2%
*-commutative33.2%
distribute-rgt-neg-in33.2%
unpow233.2%
unpow233.2%
hypot-def53.5%
Simplified53.5%
Final simplification28.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 (* F t_0))
(t_2 (- A (hypot A B))))
(if (<= B 7.2e-104)
(/ (- (sqrt (* 2.0 (* t_1 (+ A A))))) t_0)
(if (<= B 0.000145)
(/ (- (sqrt (* 2.0 (* t_2 t_1)))) t_0)
(if (<= B 225.0)
(* (sqrt (* -0.5 (/ (* B B) (/ C F)))) (/ (- (sqrt 2.0)) B))
(* (/ (sqrt 2.0) B) (- (sqrt (* F t_2)))))))))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 = F * t_0;
double t_2 = A - hypot(A, B);
double tmp;
if (B <= 7.2e-104) {
tmp = -sqrt((2.0 * (t_1 * (A + A)))) / t_0;
} else if (B <= 0.000145) {
tmp = -sqrt((2.0 * (t_2 * t_1))) / t_0;
} else if (B <= 225.0) {
tmp = sqrt((-0.5 * ((B * B) / (C / F)))) * (-sqrt(2.0) / B);
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * t_2));
}
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 = F * t_0;
double t_2 = A - Math.hypot(A, B);
double tmp;
if (B <= 7.2e-104) {
tmp = -Math.sqrt((2.0 * (t_1 * (A + A)))) / t_0;
} else if (B <= 0.000145) {
tmp = -Math.sqrt((2.0 * (t_2 * t_1))) / t_0;
} else if (B <= 225.0) {
tmp = Math.sqrt((-0.5 * ((B * B) / (C / F)))) * (-Math.sqrt(2.0) / B);
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * t_2));
}
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 = F * t_0 t_2 = A - math.hypot(A, B) tmp = 0 if B <= 7.2e-104: tmp = -math.sqrt((2.0 * (t_1 * (A + A)))) / t_0 elif B <= 0.000145: tmp = -math.sqrt((2.0 * (t_2 * t_1))) / t_0 elif B <= 225.0: tmp = math.sqrt((-0.5 * ((B * B) / (C / F)))) * (-math.sqrt(2.0) / B) else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * t_2)) 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(F * t_0) t_2 = Float64(A - hypot(A, B)) tmp = 0.0 if (B <= 7.2e-104) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A + A))))) / t_0); elseif (B <= 0.000145) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_2 * t_1)))) / t_0); elseif (B <= 225.0) tmp = Float64(sqrt(Float64(-0.5 * Float64(Float64(B * B) / Float64(C / F)))) * Float64(Float64(-sqrt(2.0)) / B)); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * t_2)))); 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 = F * t_0;
t_2 = A - hypot(A, B);
tmp = 0.0;
if (B <= 7.2e-104)
tmp = -sqrt((2.0 * (t_1 * (A + A)))) / t_0;
elseif (B <= 0.000145)
tmp = -sqrt((2.0 * (t_2 * t_1))) / t_0;
elseif (B <= 225.0)
tmp = sqrt((-0.5 * ((B * B) / (C / F)))) * (-sqrt(2.0) / B);
else
tmp = (sqrt(2.0) / B) * -sqrt((F * t_2));
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[(F * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 7.2e-104], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 0.000145], N[((-N[Sqrt[N[(2.0 * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 225.0], N[(N[Sqrt[N[(-0.5 * N[(N[(B * B), $MachinePrecision] / N[(C / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * t$95$2), $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 := F \cdot t_0\\
t_2 := A - \mathsf{hypot}\left(A, B\right)\\
\mathbf{if}\;B \leq 7.2 \cdot 10^{-104}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 0.000145:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_2 \cdot t_1\right)}}{t_0}\\
\mathbf{elif}\;B \leq 225:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{B \cdot B}{\frac{C}{F}}} \cdot \frac{-\sqrt{2}}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot t_2}\right)\\
\end{array}
\end{array}
if B < 7.1999999999999996e-104Initial program 23.6%
Simplified23.6%
Taylor expanded in C around inf 21.1%
cancel-sign-sub-inv21.1%
metadata-eval21.1%
*-lft-identity21.1%
Simplified21.1%
if 7.1999999999999996e-104 < B < 1.45e-4Initial program 41.2%
Simplified41.2%
Taylor expanded in C around 0 35.2%
unpow235.2%
unpow235.2%
hypot-def35.4%
Simplified35.4%
if 1.45e-4 < B < 225Initial program 3.8%
Simplified3.8%
Taylor expanded in A around 0 7.5%
mul-1-neg7.5%
*-commutative7.5%
distribute-rgt-neg-in7.5%
+-commutative7.5%
unpow27.5%
unpow27.5%
hypot-def7.5%
Simplified7.5%
Taylor expanded in C around inf 68.3%
associate-/l*68.3%
unpow268.3%
Simplified68.3%
if 225 < B Initial program 20.9%
Simplified20.9%
Taylor expanded in C around 0 33.2%
mul-1-neg33.2%
*-commutative33.2%
distribute-rgt-neg-in33.2%
unpow233.2%
unpow233.2%
hypot-def53.5%
Simplified53.5%
Final simplification31.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)))))
(if (<= B 4.5e-61)
(/ (- (sqrt (* 2.0 (* (* F t_0) (+ A A))))) t_0)
(if (<= B 2.25e+101)
(/
(-
(pow
(*
2.0
(*
(* F (+ (* B B) (* -4.0 (* A C))))
(+ A (- C (hypot B (- A C))))))
0.5))
t_0)
(* (sqrt (* F (- A B))) (* (sqrt 2.0) (/ -1.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 <= 4.5e-61) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else if (B <= 2.25e+101) {
tmp = -pow((2.0 * ((F * ((B * B) + (-4.0 * (A * C)))) * (A + (C - hypot(B, (A - C)))))), 0.5) / t_0;
} else {
tmp = sqrt((F * (A - B))) * (sqrt(2.0) * (-1.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 <= 4.5e-61) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else if (B <= 2.25e+101) {
tmp = -Math.pow((2.0 * ((F * ((B * B) + (-4.0 * (A * C)))) * (A + (C - Math.hypot(B, (A - C)))))), 0.5) / t_0;
} else {
tmp = Math.sqrt((F * (A - B))) * (Math.sqrt(2.0) * (-1.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 <= 4.5e-61: tmp = -math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0 elif B <= 2.25e+101: tmp = -math.pow((2.0 * ((F * ((B * B) + (-4.0 * (A * C)))) * (A + (C - math.hypot(B, (A - C)))))), 0.5) / t_0 else: tmp = math.sqrt((F * (A - B))) * (math.sqrt(2.0) * (-1.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 <= 4.5e-61) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + A))))) / t_0); elseif (B <= 2.25e+101) tmp = Float64(Float64(-(Float64(2.0 * Float64(Float64(F * Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C)))) * Float64(A + Float64(C - hypot(B, Float64(A - C)))))) ^ 0.5)) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(A - B))) * Float64(sqrt(2.0) * Float64(-1.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 <= 4.5e-61)
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
elseif (B <= 2.25e+101)
tmp = -((2.0 * ((F * ((B * B) + (-4.0 * (A * C)))) * (A + (C - hypot(B, (A - C)))))) ^ 0.5) / t_0;
else
tmp = sqrt((F * (A - B))) * (sqrt(2.0) * (-1.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, 4.5e-61], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 2.25e+101], N[((-N[Power[N[(2.0 * N[(N[(F * N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(-1.0 / B), $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 4.5 \cdot 10^{-61}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 2.25 \cdot 10^{+101}:\\
\;\;\;\;\frac{-{\left(2 \cdot \left(\left(F \cdot \left(B \cdot B + -4 \cdot \left(A \cdot C\right)\right)\right) \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}^{0.5}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - B\right)} \cdot \left(\sqrt{2} \cdot \frac{-1}{B}\right)\\
\end{array}
\end{array}
if B < 4.5e-61Initial program 23.7%
Simplified23.7%
Taylor expanded in C around inf 19.6%
cancel-sign-sub-inv19.6%
metadata-eval19.6%
*-lft-identity19.6%
Simplified19.6%
if 4.5e-61 < B < 2.2500000000000001e101Initial program 46.2%
Simplified46.2%
add-cbrt-cube39.0%
add-sqr-sqrt39.0%
fma-def39.0%
fma-def39.0%
Applied egg-rr39.0%
rem-square-sqrt39.0%
unpow339.0%
fma-udef39.0%
unpow239.0%
hypot-def39.0%
Simplified39.0%
pow1/239.2%
*-commutative39.2%
cancel-sign-sub-inv39.2%
metadata-eval39.2%
rem-cbrt-cube46.8%
associate--l+47.2%
Applied egg-rr47.2%
if 2.2500000000000001e101 < B Initial program 5.7%
Simplified5.7%
Taylor expanded in C around 0 25.1%
mul-1-neg25.1%
*-commutative25.1%
distribute-rgt-neg-in25.1%
unpow225.1%
unpow225.1%
hypot-def57.9%
Simplified57.9%
Taylor expanded in A around 0 55.8%
mul-1-neg55.8%
unsub-neg55.8%
Simplified55.8%
div-inv55.7%
Applied egg-rr55.7%
metadata-eval55.7%
*-commutative55.7%
metadata-eval55.7%
Simplified55.7%
Final simplification29.6%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))) (t_1 (* F t_0)))
(if (<= B 6.2e-104)
(/ (- (sqrt (* 2.0 (* t_1 (+ A A))))) t_0)
(if (<= B 1.8e+103)
(/ (- (sqrt (* 2.0 (* (- A (hypot A B)) t_1)))) t_0)
(* (sqrt (* F (- A B))) (* (sqrt 2.0) (/ -1.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 t_1 = F * t_0;
double tmp;
if (B <= 6.2e-104) {
tmp = -sqrt((2.0 * (t_1 * (A + A)))) / t_0;
} else if (B <= 1.8e+103) {
tmp = -sqrt((2.0 * ((A - hypot(A, B)) * t_1))) / t_0;
} else {
tmp = sqrt((F * (A - B))) * (sqrt(2.0) * (-1.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 t_1 = F * t_0;
double tmp;
if (B <= 6.2e-104) {
tmp = -Math.sqrt((2.0 * (t_1 * (A + A)))) / t_0;
} else if (B <= 1.8e+103) {
tmp = -Math.sqrt((2.0 * ((A - Math.hypot(A, B)) * t_1))) / t_0;
} else {
tmp = Math.sqrt((F * (A - B))) * (Math.sqrt(2.0) * (-1.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)) t_1 = F * t_0 tmp = 0 if B <= 6.2e-104: tmp = -math.sqrt((2.0 * (t_1 * (A + A)))) / t_0 elif B <= 1.8e+103: tmp = -math.sqrt((2.0 * ((A - math.hypot(A, B)) * t_1))) / t_0 else: tmp = math.sqrt((F * (A - B))) * (math.sqrt(2.0) * (-1.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))) t_1 = Float64(F * t_0) tmp = 0.0 if (B <= 6.2e-104) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A + A))))) / t_0); elseif (B <= 1.8e+103) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(A - hypot(A, B)) * t_1)))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(A - B))) * Float64(sqrt(2.0) * Float64(-1.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));
t_1 = F * t_0;
tmp = 0.0;
if (B <= 6.2e-104)
tmp = -sqrt((2.0 * (t_1 * (A + A)))) / t_0;
elseif (B <= 1.8e+103)
tmp = -sqrt((2.0 * ((A - hypot(A, B)) * t_1))) / t_0;
else
tmp = sqrt((F * (A - B))) * (sqrt(2.0) * (-1.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]}, Block[{t$95$1 = N[(F * t$95$0), $MachinePrecision]}, If[LessEqual[B, 6.2e-104], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 1.8e+103], N[((-N[Sqrt[N[(2.0 * N[(N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(-1.0 / B), $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 := F \cdot t_0\\
\mathbf{if}\;B \leq 6.2 \cdot 10^{-104}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 1.8 \cdot 10^{+103}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(A - \mathsf{hypot}\left(A, B\right)\right) \cdot t_1\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - B\right)} \cdot \left(\sqrt{2} \cdot \frac{-1}{B}\right)\\
\end{array}
\end{array}
if B < 6.19999999999999951e-104Initial program 23.6%
Simplified23.6%
Taylor expanded in C around inf 21.1%
cancel-sign-sub-inv21.1%
metadata-eval21.1%
*-lft-identity21.1%
Simplified21.1%
if 6.19999999999999951e-104 < B < 1.80000000000000008e103Initial program 41.0%
Simplified41.0%
Taylor expanded in C around 0 36.4%
unpow236.4%
unpow236.4%
hypot-def36.7%
Simplified36.7%
if 1.80000000000000008e103 < B Initial program 5.7%
Simplified5.7%
Taylor expanded in C around 0 25.1%
mul-1-neg25.1%
*-commutative25.1%
distribute-rgt-neg-in25.1%
unpow225.1%
unpow225.1%
hypot-def57.9%
Simplified57.9%
Taylor expanded in A around 0 55.8%
mul-1-neg55.8%
unsub-neg55.8%
Simplified55.8%
div-inv55.7%
Applied egg-rr55.7%
metadata-eval55.7%
*-commutative55.7%
metadata-eval55.7%
Simplified55.7%
Final simplification29.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)))))
(if (<= B 2.25e+49)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A A)))))) t_0)
(* (/ (- (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 tmp;
if (B <= 2.25e+49) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
} 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) :: tmp
t_0 = (b * b) + ((-4.0d0) * (a * c))
if (b <= 2.25d+49) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (a + a))))) / t_0
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 tmp;
if (B <= 2.25e+49) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
} 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)) tmp = 0 if B <= 2.25e+49: tmp = -math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0 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))) tmp = 0.0 if (B <= 2.25e+49) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + A)))))) / t_0); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B) * 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));
tmp = 0.0;
if (B <= 2.25e+49)
tmp = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
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]}, If[LessEqual[B, 2.25e+49], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(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)\\
\mathbf{if}\;B \leq 2.25 \cdot 10^{+49}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - B\right)}\\
\end{array}
\end{array}
if B < 2.24999999999999991e49Initial program 26.6%
Simplified26.6%
Taylor expanded in C around inf 19.2%
cancel-sign-sub-inv19.2%
metadata-eval19.2%
*-lft-identity19.2%
Simplified19.2%
distribute-frac-neg19.2%
associate-*l*19.2%
cancel-sign-sub-inv19.2%
metadata-eval19.2%
cancel-sign-sub-inv19.2%
metadata-eval19.2%
Applied egg-rr19.2%
if 2.24999999999999991e49 < B Initial program 15.9%
Simplified15.9%
Taylor expanded in C around 0 31.2%
mul-1-neg31.2%
*-commutative31.2%
distribute-rgt-neg-in31.2%
unpow231.2%
unpow231.2%
hypot-def56.5%
Simplified56.5%
Taylor expanded in A around 0 53.1%
mul-1-neg53.1%
unsub-neg53.1%
Simplified53.1%
Final simplification26.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
(let* ((t_0 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 1.08e+49)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A A)))))) t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* B (- F))))))))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.08e+49) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((B * -F));
}
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.08d+49) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (a + a))))) / t_0
else
tmp = (sqrt(2.0d0) / b) * -sqrt((b * -f))
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.08e+49) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((B * -F));
}
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.08e+49: tmp = -math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((B * -F)) 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.08e+49) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + A)))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(B * Float64(-F))))); 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.08e+49)
tmp = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
else
tmp = (sqrt(2.0) / B) * -sqrt((B * -F));
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.08e+49], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(B * (-F)), $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.08 \cdot 10^{+49}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{B \cdot \left(-F\right)}\right)\\
\end{array}
\end{array}
if B < 1.08000000000000001e49Initial program 26.6%
Simplified26.6%
Taylor expanded in C around inf 19.2%
cancel-sign-sub-inv19.2%
metadata-eval19.2%
*-lft-identity19.2%
Simplified19.2%
distribute-frac-neg19.2%
associate-*l*19.2%
cancel-sign-sub-inv19.2%
metadata-eval19.2%
cancel-sign-sub-inv19.2%
metadata-eval19.2%
Applied egg-rr19.2%
if 1.08000000000000001e49 < B Initial program 15.9%
Simplified15.9%
Taylor expanded in C around 0 31.2%
mul-1-neg31.2%
*-commutative31.2%
distribute-rgt-neg-in31.2%
unpow231.2%
unpow231.2%
hypot-def56.5%
Simplified56.5%
Taylor expanded in A around 0 52.4%
mul-1-neg52.4%
Simplified52.4%
Final simplification25.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)))) (t_1 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 1.62e+49)
(/ (- (sqrt (* 2.0 (* t_1 (* F (+ A A)))))) t_1)
(if (<= B 5.1e+140)
(/ (- (sqrt (* 2.0 (* (* F t_0) (- (+ A C) B))))) t_0)
(* -2.0 (/ (sqrt (* A F)) B))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 1.62e+49) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1;
} else if (B <= 5.1e+140) {
tmp = -sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / t_0;
} else {
tmp = -2.0 * (sqrt((A * F)) / B);
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (a * c))
t_1 = (b * b) + ((-4.0d0) * (a * c))
if (b <= 1.62d+49) then
tmp = -sqrt((2.0d0 * (t_1 * (f * (a + a))))) / t_1
else if (b <= 5.1d+140) then
tmp = -sqrt((2.0d0 * ((f * t_0) * ((a + c) - b)))) / t_0
else
tmp = (-2.0d0) * (sqrt((a * f)) / b)
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 1.62e+49) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1;
} else if (B <= 5.1e+140) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / t_0;
} else {
tmp = -2.0 * (Math.sqrt((A * F)) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 1.62e+49: tmp = -math.sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1 elif B <= 5.1e+140: tmp = -math.sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / t_0 else: tmp = -2.0 * (math.sqrt((A * F)) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 1.62e+49) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + A)))))) / t_1); elseif (B <= 5.1e+140) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(Float64(A + C) - B))))) / t_0); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
t_1 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 1.62e+49)
tmp = -sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1;
elseif (B <= 5.1e+140)
tmp = -sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / t_0;
else
tmp = -2.0 * (sqrt((A * F)) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 1.62e+49], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B, 5.1e+140], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 1.62 \cdot 10^{+49}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;B \leq 5.1 \cdot 10^{+140}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(\left(A + C\right) - B\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 1.62e49Initial program 26.6%
Simplified26.6%
Taylor expanded in C around inf 19.2%
cancel-sign-sub-inv19.2%
metadata-eval19.2%
*-lft-identity19.2%
Simplified19.2%
distribute-frac-neg19.2%
associate-*l*19.2%
cancel-sign-sub-inv19.2%
metadata-eval19.2%
cancel-sign-sub-inv19.2%
metadata-eval19.2%
Applied egg-rr19.2%
if 1.62e49 < B < 5.1e140Initial program 39.0%
Simplified39.0%
Taylor expanded in B around inf 35.2%
if 5.1e140 < B Initial program 0.2%
Simplified0.2%
Taylor expanded in C around inf 0.1%
cancel-sign-sub-inv0.1%
metadata-eval0.1%
*-lft-identity0.1%
Simplified0.1%
Taylor expanded in B around inf 6.6%
associate-*r/6.6%
*-rgt-identity6.6%
*-commutative6.6%
Simplified6.6%
Final simplification19.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 3.6e+72)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A 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 <= 3.6e+72) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + 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 <= 3.6d+72) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (a + 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 <= 3.6e+72) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (A + 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 <= 3.6e+72: tmp = -math.sqrt((2.0 * (t_0 * (F * (A + 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 <= 3.6e+72) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + 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 <= 3.6e+72)
tmp = -sqrt((2.0 * (t_0 * (F * (A + 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, 3.6e+72], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-2.0 * N[(N[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 3.6 \cdot 10^{+72}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 3.60000000000000035e72Initial program 27.2%
Simplified27.2%
Taylor expanded in C around inf 18.7%
cancel-sign-sub-inv18.7%
metadata-eval18.7%
*-lft-identity18.7%
Simplified18.7%
distribute-frac-neg18.7%
associate-*l*18.8%
cancel-sign-sub-inv18.8%
metadata-eval18.8%
cancel-sign-sub-inv18.8%
metadata-eval18.8%
Applied egg-rr18.8%
if 3.60000000000000035e72 < B Initial program 11.5%
Simplified11.5%
Taylor expanded in C around inf 3.1%
cancel-sign-sub-inv3.1%
metadata-eval3.1%
*-lft-identity3.1%
Simplified3.1%
Taylor expanded in B around inf 7.8%
associate-*r/7.8%
*-rgt-identity7.8%
*-commutative7.8%
Simplified7.8%
Final simplification16.8%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 0.00165)
(/
(- (sqrt (* 2.0 (* (+ A A) (* -4.0 (* A (* C F)))))))
(- (* B B) (* 4.0 (* A C))))
(* -2.0 (/ (sqrt (* A F)) B))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 0.00165) {
tmp = -sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C)));
} 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) :: tmp
if (b <= 0.00165d0) then
tmp = -sqrt((2.0d0 * ((a + a) * ((-4.0d0) * (a * (c * f)))))) / ((b * b) - (4.0d0 * (a * c)))
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 tmp;
if (B <= 0.00165) {
tmp = -Math.sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C)));
} 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): tmp = 0 if B <= 0.00165: tmp = -math.sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C))) 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) tmp = 0.0 if (B <= 0.00165) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(A + A) * Float64(-4.0 * Float64(A * Float64(C * F))))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); 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)
tmp = 0.0;
if (B <= 0.00165)
tmp = -sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C)));
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_] := If[LessEqual[B, 0.00165], N[((-N[Sqrt[N[(2.0 * N[(N[(A + A), $MachinePrecision] * N[(-4.0 * N[(A * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}
\mathbf{if}\;B \leq 0.00165:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(A + A\right) \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 0.00165Initial program 25.7%
Simplified25.7%
Taylor expanded in C around inf 19.5%
cancel-sign-sub-inv19.5%
metadata-eval19.5%
*-lft-identity19.5%
Simplified19.5%
Taylor expanded in B around 0 15.3%
*-commutative15.3%
Simplified15.3%
if 0.00165 < B Initial program 20.6%
Simplified20.6%
Taylor expanded in C around inf 5.8%
cancel-sign-sub-inv5.8%
metadata-eval5.8%
*-lft-identity5.8%
Simplified5.8%
Taylor expanded in B around inf 9.0%
associate-*r/9.0%
*-rgt-identity9.0%
*-commutative9.0%
Simplified9.0%
Final simplification13.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
(if (<= B 0.00165)
(/
(- (sqrt (* 2.0 (* -8.0 (* (* C F) (* A A))))))
(- (* B B) (* 4.0 (* A C))))
(* -2.0 (/ (sqrt (* A F)) B))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 0.00165) {
tmp = -sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - (4.0 * (A * C)));
} 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) :: tmp
if (b <= 0.00165d0) then
tmp = -sqrt((2.0d0 * ((-8.0d0) * ((c * f) * (a * a))))) / ((b * b) - (4.0d0 * (a * c)))
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 tmp;
if (B <= 0.00165) {
tmp = -Math.sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - (4.0 * (A * C)));
} 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): tmp = 0 if B <= 0.00165: tmp = -math.sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - (4.0 * (A * C))) 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) tmp = 0.0 if (B <= 0.00165) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-8.0 * Float64(Float64(C * F) * Float64(A * A)))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); 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)
tmp = 0.0;
if (B <= 0.00165)
tmp = -sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - (4.0 * (A * C)));
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_] := If[LessEqual[B, 0.00165], N[((-N[Sqrt[N[(2.0 * N[(-8.0 * N[(N[(C * F), $MachinePrecision] * N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}
\mathbf{if}\;B \leq 0.00165:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-8 \cdot \left(\left(C \cdot F\right) \cdot \left(A \cdot A\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 0.00165Initial program 25.7%
Simplified25.7%
Taylor expanded in C around inf 19.5%
cancel-sign-sub-inv19.5%
metadata-eval19.5%
*-lft-identity19.5%
Simplified19.5%
Taylor expanded in B around 0 11.8%
unpow211.8%
*-commutative11.8%
Simplified11.8%
if 0.00165 < B Initial program 20.6%
Simplified20.6%
Taylor expanded in C around inf 5.8%
cancel-sign-sub-inv5.8%
metadata-eval5.8%
*-lft-identity5.8%
Simplified5.8%
Taylor expanded in B around inf 9.0%
associate-*r/9.0%
*-rgt-identity9.0%
*-commutative9.0%
Simplified9.0%
Final simplification11.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 24.4%
Simplified24.4%
Taylor expanded in C around inf 15.9%
cancel-sign-sub-inv15.9%
metadata-eval15.9%
*-lft-identity15.9%
Simplified15.9%
Taylor expanded in B around inf 3.5%
associate-*r/3.5%
*-rgt-identity3.5%
*-commutative3.5%
Simplified3.5%
Final simplification3.5%
herbie shell --seed 2023293
(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))))