
(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 (if (<= (pow B 2.0) 2e-34) (/ (* (sqrt (* C (* -4.0 F))) (- (sqrt 2.0))) (/ C (sqrt 0.125))) (* (/ (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 tmp;
if (pow(B, 2.0) <= 2e-34) {
tmp = (sqrt((C * (-4.0 * F))) * -sqrt(2.0)) / (C / sqrt(0.125));
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(A, B))));
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (Math.pow(B, 2.0) <= 2e-34) {
tmp = (Math.sqrt((C * (-4.0 * F))) * -Math.sqrt(2.0)) / (C / Math.sqrt(0.125));
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * (A - Math.hypot(A, B))));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if math.pow(B, 2.0) <= 2e-34: tmp = (math.sqrt((C * (-4.0 * F))) * -math.sqrt(2.0)) / (C / math.sqrt(0.125)) else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * (A - math.hypot(A, B)))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if ((B ^ 2.0) <= 2e-34) tmp = Float64(Float64(sqrt(Float64(C * Float64(-4.0 * F))) * Float64(-sqrt(2.0))) / Float64(C / sqrt(0.125))); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - hypot(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 ^ 2.0) <= 2e-34)
tmp = (sqrt((C * (-4.0 * F))) * -sqrt(2.0)) / (C / sqrt(0.125));
else
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(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[N[Power[B, 2.0], $MachinePrecision], 2e-34], N[(N[(N[Sqrt[N[(C * N[(-4.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision] / N[(C / N[Sqrt[0.125], $MachinePrecision]), $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}
\mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-34}:\\
\;\;\;\;\frac{\sqrt{C \cdot \left(-4 \cdot F\right)} \cdot \left(-\sqrt{2}\right)}{\frac{C}{\sqrt{0.125}}}\\
\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.99999999999999986e-34Initial program 22.7%
Simplified22.7%
flip--6.7%
add-sqr-sqrt6.7%
fma-def6.7%
fma-def6.7%
Applied egg-rr6.7%
rem-square-sqrt6.7%
unpow16.7%
pow-plus6.7%
fma-udef6.7%
unpow26.7%
hypot-def6.7%
metadata-eval6.7%
associate-+l+7.0%
fma-udef7.0%
unpow27.0%
hypot-def7.0%
Simplified7.0%
Taylor expanded in A around -inf 29.6%
mul-1-neg29.6%
associate-/l*29.8%
distribute-rgt-out--29.8%
metadata-eval29.8%
Simplified29.8%
associate-*l/29.8%
associate-*l*29.8%
Applied egg-rr29.8%
if 1.99999999999999986e-34 < (pow.f64 B 2) Initial program 17.2%
Simplified17.2%
Taylor expanded in C around 0 11.0%
mul-1-neg11.0%
distribute-rgt-neg-in11.0%
*-commutative11.0%
+-commutative11.0%
unpow211.0%
unpow211.0%
hypot-def29.1%
Simplified29.1%
Final simplification29.4%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= B 2e-17) (* (* (sqrt 0.125) (/ (sqrt 2.0) C)) (- (sqrt (* F (* C -4.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 tmp;
if (B <= 2e-17) {
tmp = (sqrt(0.125) * (sqrt(2.0) / C)) * -sqrt((F * (C * -4.0)));
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(A, B))));
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= 2e-17) {
tmp = (Math.sqrt(0.125) * (Math.sqrt(2.0) / C)) * -Math.sqrt((F * (C * -4.0)));
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * (A - Math.hypot(A, B))));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= 2e-17: tmp = (math.sqrt(0.125) * (math.sqrt(2.0) / C)) * -math.sqrt((F * (C * -4.0))) else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * (A - math.hypot(A, B)))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 2e-17) tmp = Float64(Float64(sqrt(0.125) * Float64(sqrt(2.0) / C)) * Float64(-sqrt(Float64(F * Float64(C * -4.0))))); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - hypot(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 <= 2e-17)
tmp = (sqrt(0.125) * (sqrt(2.0) / C)) * -sqrt((F * (C * -4.0)));
else
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(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, 2e-17], N[(N[(N[Sqrt[0.125], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision] * (-N[Sqrt[N[(F * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]], $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}
\mathbf{if}\;B \leq 2 \cdot 10^{-17}:\\
\;\;\;\;\left(\sqrt{0.125} \cdot \frac{\sqrt{2}}{C}\right) \cdot \left(-\sqrt{F \cdot \left(C \cdot -4\right)}\right)\\
\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.00000000000000014e-17Initial program 22.8%
Simplified22.8%
flip--9.7%
add-sqr-sqrt9.7%
fma-def9.7%
fma-def9.7%
Applied egg-rr9.7%
rem-square-sqrt9.7%
unpow19.7%
pow-plus9.7%
fma-udef9.7%
unpow29.7%
hypot-def9.7%
metadata-eval9.7%
associate-+l+9.9%
fma-udef9.9%
unpow29.9%
hypot-def9.9%
Simplified9.9%
Taylor expanded in A around -inf 23.1%
mul-1-neg23.1%
associate-/l*23.3%
distribute-rgt-out--23.3%
metadata-eval23.3%
Simplified23.3%
associate-/r/23.2%
Applied egg-rr23.2%
if 2.00000000000000014e-17 < B Initial program 12.0%
Simplified12.0%
Taylor expanded in C around 0 19.8%
mul-1-neg19.8%
distribute-rgt-neg-in19.8%
*-commutative19.8%
+-commutative19.8%
unpow219.8%
unpow219.8%
hypot-def53.3%
Simplified53.3%
Final simplification31.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) (* -4.0 (* C A)))))
(if (<= B 4.1e-16)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A 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 = (B * B) + (-4.0 * (C * A));
double tmp;
if (B <= 4.1e-16) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(A, 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 * (C * A));
double tmp;
if (B <= 4.1e-16) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * (A - Math.hypot(A, B))));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + (-4.0 * (C * A)) tmp = 0 if B <= 4.1e-16: tmp = -math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * (A - math.hypot(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(C * A))) tmp = 0.0 if (B <= 4.1e-16) 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(F * Float64(A - hypot(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 * (C * A));
tmp = 0.0;
if (B <= 4.1e-16)
tmp = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
else
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(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[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 4.1e-16], 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 - 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 := B \cdot B + -4 \cdot \left(C \cdot A\right)\\
\mathbf{if}\;B \leq 4.1 \cdot 10^{-16}:\\
\;\;\;\;\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{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}\right)\\
\end{array}
\end{array}
if B < 4.10000000000000006e-16Initial program 22.8%
Simplified22.8%
Taylor expanded in C around inf 18.6%
cancel-sign-sub-inv18.6%
metadata-eval18.6%
*-lft-identity18.6%
Simplified18.6%
distribute-frac-neg18.6%
associate-*l*20.2%
cancel-sign-sub-inv20.2%
metadata-eval20.2%
cancel-sign-sub-inv20.2%
metadata-eval20.2%
Applied egg-rr20.2%
if 4.10000000000000006e-16 < B Initial program 12.0%
Simplified12.0%
Taylor expanded in C around 0 19.8%
mul-1-neg19.8%
distribute-rgt-neg-in19.8%
*-commutative19.8%
+-commutative19.8%
unpow219.8%
unpow219.8%
hypot-def53.3%
Simplified53.3%
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) (* (* C A) 4.0))) (t_1 (* F t_0)))
(if (<= B 1.36e-45)
(/ (- (sqrt (* 2.0 (* (+ A A) t_1)))) t_0)
(if (<= B 7.8e+27)
(/ (- (sqrt (* 2.0 (* (- A (hypot A B)) t_1)))) t_0)
(* (sqrt (* F (- A B))) (/ (- (sqrt 2.0)) B))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((C * A) * 4.0);
double t_1 = F * t_0;
double tmp;
if (B <= 1.36e-45) {
tmp = -sqrt((2.0 * ((A + A) * t_1))) / t_0;
} else if (B <= 7.8e+27) {
tmp = -sqrt((2.0 * ((A - hypot(A, B)) * t_1))) / t_0;
} else {
tmp = sqrt((F * (A - B))) * (-sqrt(2.0) / B);
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((C * A) * 4.0);
double t_1 = F * t_0;
double tmp;
if (B <= 1.36e-45) {
tmp = -Math.sqrt((2.0 * ((A + A) * t_1))) / t_0;
} else if (B <= 7.8e+27) {
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) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - ((C * A) * 4.0) t_1 = F * t_0 tmp = 0 if B <= 1.36e-45: tmp = -math.sqrt((2.0 * ((A + A) * t_1))) / t_0 elif B <= 7.8e+27: 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) / 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(C * A) * 4.0)) t_1 = Float64(F * t_0) tmp = 0.0 if (B <= 1.36e-45) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(A + A) * t_1)))) / t_0); elseif (B <= 7.8e+27) 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(Float64(-sqrt(2.0)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - ((C * A) * 4.0);
t_1 = F * t_0;
tmp = 0.0;
if (B <= 1.36e-45)
tmp = -sqrt((2.0 * ((A + A) * t_1))) / t_0;
elseif (B <= 7.8e+27)
tmp = -sqrt((2.0 * ((A - hypot(A, B)) * t_1))) / t_0;
else
tmp = sqrt((F * (A - B))) * (-sqrt(2.0) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(N[(C * A), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(F * t$95$0), $MachinePrecision]}, If[LessEqual[B, 1.36e-45], N[((-N[Sqrt[N[(2.0 * N[(N[(A + A), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 7.8e+27], 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]) / B), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - \left(C \cdot A\right) \cdot 4\\
t_1 := F \cdot t_0\\
\mathbf{if}\;B \leq 1.36 \cdot 10^{-45}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(A + A\right) \cdot t_1\right)}}{t_0}\\
\mathbf{elif}\;B \leq 7.8 \cdot 10^{+27}:\\
\;\;\;\;\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 \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 1.35999999999999998e-45Initial program 21.9%
Simplified21.9%
Taylor expanded in C around inf 18.5%
cancel-sign-sub-inv18.5%
metadata-eval18.5%
*-lft-identity18.5%
Simplified18.5%
if 1.35999999999999998e-45 < B < 7.7999999999999997e27Initial program 55.5%
Simplified55.5%
Taylor expanded in C around 0 47.3%
+-commutative47.3%
unpow247.3%
unpow247.3%
hypot-def47.5%
Simplified47.5%
if 7.7999999999999997e27 < B Initial program 8.4%
Simplified11.9%
Taylor expanded in B around inf 8.8%
mul-1-neg8.8%
unsub-neg8.8%
Simplified8.8%
Taylor expanded in C around 0 45.4%
mul-1-neg45.4%
*-commutative45.4%
Simplified45.4%
Final simplification26.9%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* -4.0 (* C A))))
(t_1 (/ (- (sqrt (* 2.0 (* t_0 (* F (+ A A)))))) t_0)))
(if (<= B 1.35e-13)
t_1
(if (<= B 1.7e+16)
(/
(- (sqrt (* 2.0 (* (/ (* B B) (+ C (hypot B C))) (* F (* B (- B)))))))
(- (* B B) (* (* C A) 4.0)))
(if (<= B 7e+26) t_1 (* (sqrt (* F (- A B))) (/ (- (sqrt 2.0)) B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (C * A));
double t_1 = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
double tmp;
if (B <= 1.35e-13) {
tmp = t_1;
} else if (B <= 1.7e+16) {
tmp = -sqrt((2.0 * (((B * B) / (C + hypot(B, C))) * (F * (B * -B))))) / ((B * B) - ((C * A) * 4.0));
} else if (B <= 7e+26) {
tmp = t_1;
} else {
tmp = sqrt((F * (A - B))) * (-sqrt(2.0) / B);
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (C * A));
double t_1 = -Math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
double tmp;
if (B <= 1.35e-13) {
tmp = t_1;
} else if (B <= 1.7e+16) {
tmp = -Math.sqrt((2.0 * (((B * B) / (C + Math.hypot(B, C))) * (F * (B * -B))))) / ((B * B) - ((C * A) * 4.0));
} else if (B <= 7e+26) {
tmp = t_1;
} else {
tmp = Math.sqrt((F * (A - B))) * (-Math.sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + (-4.0 * (C * A)) t_1 = -math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0 tmp = 0 if B <= 1.35e-13: tmp = t_1 elif B <= 1.7e+16: tmp = -math.sqrt((2.0 * (((B * B) / (C + math.hypot(B, C))) * (F * (B * -B))))) / ((B * B) - ((C * A) * 4.0)) elif B <= 7e+26: tmp = t_1 else: tmp = math.sqrt((F * (A - B))) * (-math.sqrt(2.0) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(-4.0 * Float64(C * A))) t_1 = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + A)))))) / t_0) tmp = 0.0 if (B <= 1.35e-13) tmp = t_1; elseif (B <= 1.7e+16) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(Float64(B * B) / Float64(C + hypot(B, C))) * Float64(F * Float64(B * Float64(-B))))))) / Float64(Float64(B * B) - Float64(Float64(C * A) * 4.0))); elseif (B <= 7e+26) tmp = t_1; else tmp = Float64(sqrt(Float64(F * Float64(A - B))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + (-4.0 * (C * A));
t_1 = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
tmp = 0.0;
if (B <= 1.35e-13)
tmp = t_1;
elseif (B <= 1.7e+16)
tmp = -sqrt((2.0 * (((B * B) / (C + hypot(B, C))) * (F * (B * -B))))) / ((B * B) - ((C * A) * 4.0));
elseif (B <= 7e+26)
tmp = t_1;
else
tmp = sqrt((F * (A - B))) * (-sqrt(2.0) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]}, If[LessEqual[B, 1.35e-13], t$95$1, If[LessEqual[B, 1.7e+16], N[((-N[Sqrt[N[(2.0 * N[(N[(N[(B * B), $MachinePrecision] / N[(C + N[Sqrt[B ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(F * N[(B * (-B)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(N[(C * A), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 7e+26], t$95$1, N[(N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + -4 \cdot \left(C \cdot A\right)\\
t_1 := \frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_0}\\
\mathbf{if}\;B \leq 1.35 \cdot 10^{-13}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;B \leq 1.7 \cdot 10^{+16}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\frac{B \cdot B}{C + \mathsf{hypot}\left(B, C\right)} \cdot \left(F \cdot \left(B \cdot \left(-B\right)\right)\right)\right)}}{B \cdot B - \left(C \cdot A\right) \cdot 4}\\
\mathbf{elif}\;B \leq 7 \cdot 10^{+26}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - B\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 1.35000000000000005e-13 or 1.7e16 < B < 6.9999999999999998e26Initial program 23.1%
Simplified23.1%
Taylor expanded in C around inf 18.4%
cancel-sign-sub-inv18.4%
metadata-eval18.4%
*-lft-identity18.4%
Simplified18.4%
distribute-frac-neg18.4%
associate-*l*20.0%
cancel-sign-sub-inv20.0%
metadata-eval20.0%
cancel-sign-sub-inv20.0%
metadata-eval20.0%
Applied egg-rr20.0%
if 1.35000000000000005e-13 < B < 1.7e16Initial program 67.3%
Simplified67.3%
flip--67.3%
add-sqr-sqrt67.3%
fma-def67.3%
fma-def67.3%
Applied egg-rr67.3%
rem-square-sqrt67.3%
unpow167.3%
pow-plus67.3%
fma-udef67.3%
unpow267.3%
hypot-def67.3%
metadata-eval67.3%
associate-+l+67.3%
fma-udef67.3%
unpow267.3%
hypot-def67.3%
Simplified67.3%
Taylor expanded in A around 0 68.9%
associate-*r/68.9%
mul-1-neg68.9%
unpow268.9%
unpow268.9%
unpow268.9%
hypot-def68.9%
Simplified68.9%
Taylor expanded in B around inf 68.4%
unpow268.4%
Simplified68.4%
if 6.9999999999999998e26 < B Initial program 8.4%
Simplified11.9%
Taylor expanded in B around inf 8.8%
mul-1-neg8.8%
unsub-neg8.8%
Simplified8.8%
Taylor expanded in C around 0 45.4%
mul-1-neg45.4%
*-commutative45.4%
Simplified45.4%
Final simplification27.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 (* C A)))))
(if (<= B 9.8e-17)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A A)))))) t_0)
(* (sqrt (* F (- A B))) (/ (- (sqrt 2.0)) B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (C * A));
double tmp;
if (B <= 9.8e-17) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
} else {
tmp = sqrt((F * (A - B))) * (-sqrt(2.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) :: tmp
t_0 = (b * b) + ((-4.0d0) * (c * a))
if (b <= 9.8d-17) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (a + a))))) / t_0
else
tmp = sqrt((f * (a - b))) * (-sqrt(2.0d0) / 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 * (C * A));
double tmp;
if (B <= 9.8e-17) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
} else {
tmp = Math.sqrt((F * (A - B))) * (-Math.sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + (-4.0 * (C * A)) tmp = 0 if B <= 9.8e-17: tmp = -math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0 else: tmp = math.sqrt((F * (A - B))) * (-math.sqrt(2.0) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(-4.0 * Float64(C * A))) tmp = 0.0 if (B <= 9.8e-17) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + A)))))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(A - B))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + (-4.0 * (C * A));
tmp = 0.0;
if (B <= 9.8e-17)
tmp = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
else
tmp = sqrt((F * (A - B))) * (-sqrt(2.0) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 9.8e-17], 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[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + -4 \cdot \left(C \cdot A\right)\\
\mathbf{if}\;B \leq 9.8 \cdot 10^{-17}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - B\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 9.80000000000000024e-17Initial program 22.8%
Simplified22.8%
Taylor expanded in C around inf 18.6%
cancel-sign-sub-inv18.6%
metadata-eval18.6%
*-lft-identity18.6%
Simplified18.6%
distribute-frac-neg18.6%
associate-*l*20.2%
cancel-sign-sub-inv20.2%
metadata-eval20.2%
cancel-sign-sub-inv20.2%
metadata-eval20.2%
Applied egg-rr20.2%
if 9.80000000000000024e-17 < B Initial program 12.0%
Simplified16.9%
Taylor expanded in B around inf 12.6%
mul-1-neg12.6%
unsub-neg12.6%
Simplified12.6%
Taylor expanded in C around 0 46.5%
mul-1-neg46.5%
*-commutative46.5%
Simplified46.5%
Final simplification27.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 (* C A)))))
(if (<= B 7.2e-13)
(/ (- (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 * (C * A));
double tmp;
if (B <= 7.2e-13) {
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) * (c * a))
if (b <= 7.2d-13) 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 * (C * A));
double tmp;
if (B <= 7.2e-13) {
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 * (C * A)) tmp = 0 if B <= 7.2e-13: 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(C * A))) tmp = 0.0 if (B <= 7.2e-13) 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 * (C * A));
tmp = 0.0;
if (B <= 7.2e-13)
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[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 7.2e-13], 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(C \cdot A\right)\\
\mathbf{if}\;B \leq 7.2 \cdot 10^{-13}:\\
\;\;\;\;\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 < 7.1999999999999996e-13Initial program 22.8%
Simplified22.8%
Taylor expanded in C around inf 18.6%
cancel-sign-sub-inv18.6%
metadata-eval18.6%
*-lft-identity18.6%
Simplified18.6%
distribute-frac-neg18.6%
associate-*l*20.2%
cancel-sign-sub-inv20.2%
metadata-eval20.2%
cancel-sign-sub-inv20.2%
metadata-eval20.2%
Applied egg-rr20.2%
if 7.1999999999999996e-13 < B Initial program 12.0%
Simplified12.0%
Taylor expanded in C around 0 19.8%
mul-1-neg19.8%
distribute-rgt-neg-in19.8%
*-commutative19.8%
+-commutative19.8%
unpow219.8%
unpow219.8%
hypot-def53.3%
Simplified53.3%
Taylor expanded in A around 0 45.6%
mul-1-neg45.6%
Simplified45.6%
Final simplification27.4%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (* (* C A) 4.0))
(t_1 (+ (* B B) (* -4.0 (* C A))))
(t_2 (sqrt (* 2.0 (* t_1 (* F (+ A A)))))))
(if (<= B 4.35e-13)
(/ (- t_2) t_1)
(if (<= B 1.45e+69)
(/ (- (sqrt (* 2.0 (* B (* F (- t_0 (* B B))))))) (- (* B B) t_0))
(if (<= B 2.5e+138)
(* t_2 (/ -1.0 t_1))
(* -2.0 (* (pow (* F A) 0.5) (/ 1.0 B))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (C * A) * 4.0;
double t_1 = (B * B) + (-4.0 * (C * A));
double t_2 = sqrt((2.0 * (t_1 * (F * (A + A)))));
double tmp;
if (B <= 4.35e-13) {
tmp = -t_2 / t_1;
} else if (B <= 1.45e+69) {
tmp = -sqrt((2.0 * (B * (F * (t_0 - (B * B)))))) / ((B * B) - t_0);
} else if (B <= 2.5e+138) {
tmp = t_2 * (-1.0 / t_1);
} else {
tmp = -2.0 * (pow((F * A), 0.5) * (1.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) :: tmp
t_0 = (c * a) * 4.0d0
t_1 = (b * b) + ((-4.0d0) * (c * a))
t_2 = sqrt((2.0d0 * (t_1 * (f * (a + a)))))
if (b <= 4.35d-13) then
tmp = -t_2 / t_1
else if (b <= 1.45d+69) then
tmp = -sqrt((2.0d0 * (b * (f * (t_0 - (b * b)))))) / ((b * b) - t_0)
else if (b <= 2.5d+138) then
tmp = t_2 * ((-1.0d0) / t_1)
else
tmp = (-2.0d0) * (((f * a) ** 0.5d0) * (1.0d0 / 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 = (C * A) * 4.0;
double t_1 = (B * B) + (-4.0 * (C * A));
double t_2 = Math.sqrt((2.0 * (t_1 * (F * (A + A)))));
double tmp;
if (B <= 4.35e-13) {
tmp = -t_2 / t_1;
} else if (B <= 1.45e+69) {
tmp = -Math.sqrt((2.0 * (B * (F * (t_0 - (B * B)))))) / ((B * B) - t_0);
} else if (B <= 2.5e+138) {
tmp = t_2 * (-1.0 / t_1);
} else {
tmp = -2.0 * (Math.pow((F * A), 0.5) * (1.0 / B));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (C * A) * 4.0 t_1 = (B * B) + (-4.0 * (C * A)) t_2 = math.sqrt((2.0 * (t_1 * (F * (A + A))))) tmp = 0 if B <= 4.35e-13: tmp = -t_2 / t_1 elif B <= 1.45e+69: tmp = -math.sqrt((2.0 * (B * (F * (t_0 - (B * B)))))) / ((B * B) - t_0) elif B <= 2.5e+138: tmp = t_2 * (-1.0 / t_1) else: tmp = -2.0 * (math.pow((F * A), 0.5) * (1.0 / B)) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(C * A) * 4.0) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(C * A))) t_2 = sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + A))))) tmp = 0.0 if (B <= 4.35e-13) tmp = Float64(Float64(-t_2) / t_1); elseif (B <= 1.45e+69) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(B * Float64(F * Float64(t_0 - Float64(B * B))))))) / Float64(Float64(B * B) - t_0)); elseif (B <= 2.5e+138) tmp = Float64(t_2 * Float64(-1.0 / t_1)); else tmp = Float64(-2.0 * Float64((Float64(F * A) ^ 0.5) * 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 = (C * A) * 4.0;
t_1 = (B * B) + (-4.0 * (C * A));
t_2 = sqrt((2.0 * (t_1 * (F * (A + A)))));
tmp = 0.0;
if (B <= 4.35e-13)
tmp = -t_2 / t_1;
elseif (B <= 1.45e+69)
tmp = -sqrt((2.0 * (B * (F * (t_0 - (B * B)))))) / ((B * B) - t_0);
elseif (B <= 2.5e+138)
tmp = t_2 * (-1.0 / t_1);
else
tmp = -2.0 * (((F * A) ^ 0.5) * (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[(C * A), $MachinePrecision] * 4.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[B, 4.35e-13], N[((-t$95$2) / t$95$1), $MachinePrecision], If[LessEqual[B, 1.45e+69], N[((-N[Sqrt[N[(2.0 * N[(B * N[(F * N[(t$95$0 - N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 2.5e+138], N[(t$95$2 * N[(-1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Power[N[(F * A), $MachinePrecision], 0.5], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \left(C \cdot A\right) \cdot 4\\
t_1 := B \cdot B + -4 \cdot \left(C \cdot A\right)\\
t_2 := \sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + A\right)\right)\right)}\\
\mathbf{if}\;B \leq 4.35 \cdot 10^{-13}:\\
\;\;\;\;\frac{-t_2}{t_1}\\
\mathbf{elif}\;B \leq 1.45 \cdot 10^{+69}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(B \cdot \left(F \cdot \left(t_0 - B \cdot B\right)\right)\right)}}{B \cdot B - t_0}\\
\mathbf{elif}\;B \leq 2.5 \cdot 10^{+138}:\\
\;\;\;\;t_2 \cdot \frac{-1}{t_1}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left({\left(F \cdot A\right)}^{0.5} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if B < 4.35000000000000014e-13Initial program 22.8%
Simplified22.8%
Taylor expanded in C around inf 18.6%
cancel-sign-sub-inv18.6%
metadata-eval18.6%
*-lft-identity18.6%
Simplified18.6%
distribute-frac-neg18.6%
associate-*l*20.2%
cancel-sign-sub-inv20.2%
metadata-eval20.2%
cancel-sign-sub-inv20.2%
metadata-eval20.2%
Applied egg-rr20.2%
if 4.35000000000000014e-13 < B < 1.4499999999999999e69Initial program 36.7%
Simplified36.7%
flip--35.8%
add-sqr-sqrt35.8%
fma-def35.8%
fma-def35.8%
Applied egg-rr35.8%
rem-square-sqrt35.8%
unpow135.8%
pow-plus35.8%
fma-udef35.8%
unpow235.8%
hypot-def35.8%
metadata-eval35.8%
associate-+l+35.8%
fma-udef35.8%
unpow235.8%
hypot-def35.8%
Simplified35.8%
Taylor expanded in A around 0 38.0%
associate-*r/38.0%
mul-1-neg38.0%
unpow238.0%
unpow238.0%
unpow238.0%
hypot-def37.9%
Simplified37.9%
Taylor expanded in B around inf 38.2%
neg-mul-138.2%
Simplified38.2%
if 1.4499999999999999e69 < B < 2.50000000000000008e138Initial program 7.5%
Simplified7.5%
Taylor expanded in C around inf 17.8%
cancel-sign-sub-inv17.8%
metadata-eval17.8%
*-lft-identity17.8%
Simplified17.8%
div-inv17.8%
associate-*l*18.0%
cancel-sign-sub-inv18.0%
metadata-eval18.0%
cancel-sign-sub-inv18.0%
metadata-eval18.0%
Applied egg-rr18.0%
if 2.50000000000000008e138 < B Initial program 2.9%
Simplified2.9%
Taylor expanded in C around inf 0.4%
cancel-sign-sub-inv0.4%
metadata-eval0.4%
*-lft-identity0.4%
Simplified0.4%
Taylor expanded in B around inf 10.7%
pow1/210.9%
*-commutative10.9%
Applied egg-rr10.9%
Final simplification19.9%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (* (* C A) 4.0))
(t_1 (+ (* B B) (* -4.0 (* C A))))
(t_2 (/ (- (sqrt (* 2.0 (* t_1 (* F (+ A A)))))) t_1)))
(if (<= B 6.8e-13)
t_2
(if (<= B 5.5e+69)
(/ (- (sqrt (* 2.0 (* B (* F (- t_0 (* B B))))))) (- (* B B) t_0))
(if (<= B 2.25e+126) t_2 (* -2.0 (* (pow (* F A) 0.5) (/ 1.0 B))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (C * A) * 4.0;
double t_1 = (B * B) + (-4.0 * (C * A));
double t_2 = -sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1;
double tmp;
if (B <= 6.8e-13) {
tmp = t_2;
} else if (B <= 5.5e+69) {
tmp = -sqrt((2.0 * (B * (F * (t_0 - (B * B)))))) / ((B * B) - t_0);
} else if (B <= 2.25e+126) {
tmp = t_2;
} else {
tmp = -2.0 * (pow((F * A), 0.5) * (1.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) :: tmp
t_0 = (c * a) * 4.0d0
t_1 = (b * b) + ((-4.0d0) * (c * a))
t_2 = -sqrt((2.0d0 * (t_1 * (f * (a + a))))) / t_1
if (b <= 6.8d-13) then
tmp = t_2
else if (b <= 5.5d+69) then
tmp = -sqrt((2.0d0 * (b * (f * (t_0 - (b * b)))))) / ((b * b) - t_0)
else if (b <= 2.25d+126) then
tmp = t_2
else
tmp = (-2.0d0) * (((f * a) ** 0.5d0) * (1.0d0 / 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 = (C * A) * 4.0;
double t_1 = (B * B) + (-4.0 * (C * A));
double t_2 = -Math.sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1;
double tmp;
if (B <= 6.8e-13) {
tmp = t_2;
} else if (B <= 5.5e+69) {
tmp = -Math.sqrt((2.0 * (B * (F * (t_0 - (B * B)))))) / ((B * B) - t_0);
} else if (B <= 2.25e+126) {
tmp = t_2;
} else {
tmp = -2.0 * (Math.pow((F * A), 0.5) * (1.0 / B));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (C * A) * 4.0 t_1 = (B * B) + (-4.0 * (C * A)) t_2 = -math.sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1 tmp = 0 if B <= 6.8e-13: tmp = t_2 elif B <= 5.5e+69: tmp = -math.sqrt((2.0 * (B * (F * (t_0 - (B * B)))))) / ((B * B) - t_0) elif B <= 2.25e+126: tmp = t_2 else: tmp = -2.0 * (math.pow((F * A), 0.5) * (1.0 / B)) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(C * A) * 4.0) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(C * A))) t_2 = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + A)))))) / t_1) tmp = 0.0 if (B <= 6.8e-13) tmp = t_2; elseif (B <= 5.5e+69) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(B * Float64(F * Float64(t_0 - Float64(B * B))))))) / Float64(Float64(B * B) - t_0)); elseif (B <= 2.25e+126) tmp = t_2; else tmp = Float64(-2.0 * Float64((Float64(F * A) ^ 0.5) * 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 = (C * A) * 4.0;
t_1 = (B * B) + (-4.0 * (C * A));
t_2 = -sqrt((2.0 * (t_1 * (F * (A + A))))) / t_1;
tmp = 0.0;
if (B <= 6.8e-13)
tmp = t_2;
elseif (B <= 5.5e+69)
tmp = -sqrt((2.0 * (B * (F * (t_0 - (B * B)))))) / ((B * B) - t_0);
elseif (B <= 2.25e+126)
tmp = t_2;
else
tmp = -2.0 * (((F * A) ^ 0.5) * (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[(C * A), $MachinePrecision] * 4.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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, 6.8e-13], t$95$2, If[LessEqual[B, 5.5e+69], N[((-N[Sqrt[N[(2.0 * N[(B * N[(F * N[(t$95$0 - N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 2.25e+126], t$95$2, N[(-2.0 * N[(N[Power[N[(F * A), $MachinePrecision], 0.5], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \left(C \cdot A\right) \cdot 4\\
t_1 := B \cdot B + -4 \cdot \left(C \cdot A\right)\\
t_2 := \frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_1}\\
\mathbf{if}\;B \leq 6.8 \cdot 10^{-13}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;B \leq 5.5 \cdot 10^{+69}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(B \cdot \left(F \cdot \left(t_0 - B \cdot B\right)\right)\right)}}{B \cdot B - t_0}\\
\mathbf{elif}\;B \leq 2.25 \cdot 10^{+126}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left({\left(F \cdot A\right)}^{0.5} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if B < 6.80000000000000031e-13 or 5.50000000000000002e69 < B < 2.24999999999999987e126Initial program 21.4%
Simplified21.4%
Taylor expanded in C around inf 18.4%
cancel-sign-sub-inv18.4%
metadata-eval18.4%
*-lft-identity18.4%
Simplified18.4%
distribute-frac-neg18.4%
associate-*l*19.9%
cancel-sign-sub-inv19.9%
metadata-eval19.9%
cancel-sign-sub-inv19.9%
metadata-eval19.9%
Applied egg-rr19.9%
if 6.80000000000000031e-13 < B < 5.50000000000000002e69Initial program 36.7%
Simplified36.7%
flip--35.8%
add-sqr-sqrt35.8%
fma-def35.8%
fma-def35.8%
Applied egg-rr35.8%
rem-square-sqrt35.8%
unpow135.8%
pow-plus35.8%
fma-udef35.8%
unpow235.8%
hypot-def35.8%
metadata-eval35.8%
associate-+l+35.8%
fma-udef35.8%
unpow235.8%
hypot-def35.8%
Simplified35.8%
Taylor expanded in A around 0 38.0%
associate-*r/38.0%
mul-1-neg38.0%
unpow238.0%
unpow238.0%
unpow238.0%
hypot-def37.9%
Simplified37.9%
Taylor expanded in B around inf 38.2%
neg-mul-138.2%
Simplified38.2%
if 2.24999999999999987e126 < B Initial program 5.1%
Simplified5.1%
Taylor expanded in C around inf 3.0%
cancel-sign-sub-inv3.0%
metadata-eval3.0%
*-lft-identity3.0%
Simplified3.0%
Taylor expanded in B around inf 12.1%
pow1/212.3%
*-commutative12.3%
Applied egg-rr12.3%
Final simplification19.9%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (* (* C A) 4.0)) (t_1 (- (* B B) t_0)))
(if (<= B 6.5e-40)
(/ (- (sqrt (* 2.0 (* (+ A A) (* -4.0 (* A (* C F))))))) t_1)
(if (<= B 1e+70)
(/ (- (sqrt (* 2.0 (* B (* F (- t_0 (* B B))))))) t_1)
(* -2.0 (* (pow (* F A) 0.5) (/ 1.0 B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (C * A) * 4.0;
double t_1 = (B * B) - t_0;
double tmp;
if (B <= 6.5e-40) {
tmp = -sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / t_1;
} else if (B <= 1e+70) {
tmp = -sqrt((2.0 * (B * (F * (t_0 - (B * B)))))) / t_1;
} else {
tmp = -2.0 * (pow((F * A), 0.5) * (1.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) :: tmp
t_0 = (c * a) * 4.0d0
t_1 = (b * b) - t_0
if (b <= 6.5d-40) then
tmp = -sqrt((2.0d0 * ((a + a) * ((-4.0d0) * (a * (c * f)))))) / t_1
else if (b <= 1d+70) then
tmp = -sqrt((2.0d0 * (b * (f * (t_0 - (b * b)))))) / t_1
else
tmp = (-2.0d0) * (((f * a) ** 0.5d0) * (1.0d0 / 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 = (C * A) * 4.0;
double t_1 = (B * B) - t_0;
double tmp;
if (B <= 6.5e-40) {
tmp = -Math.sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / t_1;
} else if (B <= 1e+70) {
tmp = -Math.sqrt((2.0 * (B * (F * (t_0 - (B * B)))))) / t_1;
} else {
tmp = -2.0 * (Math.pow((F * A), 0.5) * (1.0 / B));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (C * A) * 4.0 t_1 = (B * B) - t_0 tmp = 0 if B <= 6.5e-40: tmp = -math.sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / t_1 elif B <= 1e+70: tmp = -math.sqrt((2.0 * (B * (F * (t_0 - (B * B)))))) / t_1 else: tmp = -2.0 * (math.pow((F * A), 0.5) * (1.0 / B)) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(C * A) * 4.0) t_1 = Float64(Float64(B * B) - t_0) tmp = 0.0 if (B <= 6.5e-40) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(A + A) * Float64(-4.0 * Float64(A * Float64(C * F))))))) / t_1); elseif (B <= 1e+70) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(B * Float64(F * Float64(t_0 - Float64(B * B))))))) / t_1); else tmp = Float64(-2.0 * Float64((Float64(F * A) ^ 0.5) * 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 = (C * A) * 4.0;
t_1 = (B * B) - t_0;
tmp = 0.0;
if (B <= 6.5e-40)
tmp = -sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / t_1;
elseif (B <= 1e+70)
tmp = -sqrt((2.0 * (B * (F * (t_0 - (B * B)))))) / t_1;
else
tmp = -2.0 * (((F * A) ^ 0.5) * (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[(C * A), $MachinePrecision] * 4.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[B, 6.5e-40], 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]) / t$95$1), $MachinePrecision], If[LessEqual[B, 1e+70], N[((-N[Sqrt[N[(2.0 * N[(B * N[(F * N[(t$95$0 - N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[(-2.0 * N[(N[Power[N[(F * A), $MachinePrecision], 0.5], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \left(C \cdot A\right) \cdot 4\\
t_1 := B \cdot B - t_0\\
\mathbf{if}\;B \leq 6.5 \cdot 10^{-40}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(A + A\right) \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;B \leq 10^{+70}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(B \cdot \left(F \cdot \left(t_0 - B \cdot B\right)\right)\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left({\left(F \cdot A\right)}^{0.5} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if B < 6.4999999999999999e-40Initial program 22.3%
Simplified22.3%
Taylor expanded in C around inf 19.0%
cancel-sign-sub-inv19.0%
metadata-eval19.0%
*-lft-identity19.0%
Simplified19.0%
Taylor expanded in B around 0 13.6%
if 6.4999999999999999e-40 < B < 1.00000000000000007e70Initial program 37.7%
Simplified37.7%
flip--32.2%
add-sqr-sqrt32.2%
fma-def32.2%
fma-def32.2%
Applied egg-rr32.2%
rem-square-sqrt32.2%
unpow132.2%
pow-plus32.2%
fma-udef32.2%
unpow232.2%
hypot-def32.2%
metadata-eval32.2%
associate-+l+32.3%
fma-udef32.3%
unpow232.3%
hypot-def32.3%
Simplified32.3%
Taylor expanded in A around 0 34.1%
associate-*r/34.1%
mul-1-neg34.1%
unpow234.1%
unpow234.1%
unpow234.1%
hypot-def34.2%
Simplified34.2%
Taylor expanded in B around inf 34.7%
neg-mul-134.7%
Simplified34.7%
if 1.00000000000000007e70 < B Initial program 4.5%
Simplified4.5%
Taylor expanded in C around inf 6.3%
cancel-sign-sub-inv6.3%
metadata-eval6.3%
*-lft-identity6.3%
Simplified6.3%
Taylor expanded in B around inf 9.8%
pow1/29.9%
*-commutative9.9%
Applied egg-rr9.9%
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 9.4e-17)
(/
(- (sqrt (* 2.0 (* (+ A A) (* -4.0 (* A (* C F)))))))
(- (* B B) (* (* C A) 4.0)))
(* -2.0 (* (pow (* F A) 0.5) (/ 1.0 B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 9.4e-17) {
tmp = -sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((C * A) * 4.0));
} else {
tmp = -2.0 * (pow((F * A), 0.5) * (1.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) :: tmp
if (b <= 9.4d-17) then
tmp = -sqrt((2.0d0 * ((a + a) * ((-4.0d0) * (a * (c * f)))))) / ((b * b) - ((c * a) * 4.0d0))
else
tmp = (-2.0d0) * (((f * a) ** 0.5d0) * (1.0d0 / 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 <= 9.4e-17) {
tmp = -Math.sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((C * A) * 4.0));
} else {
tmp = -2.0 * (Math.pow((F * A), 0.5) * (1.0 / B));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= 9.4e-17: tmp = -math.sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((C * A) * 4.0)) else: tmp = -2.0 * (math.pow((F * A), 0.5) * (1.0 / B)) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 9.4e-17) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(A + A) * Float64(-4.0 * Float64(A * Float64(C * F))))))) / Float64(Float64(B * B) - Float64(Float64(C * A) * 4.0))); else tmp = Float64(-2.0 * Float64((Float64(F * A) ^ 0.5) * 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)
tmp = 0.0;
if (B <= 9.4e-17)
tmp = -sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((C * A) * 4.0));
else
tmp = -2.0 * (((F * A) ^ 0.5) * (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_] := If[LessEqual[B, 9.4e-17], N[((-N[Sqrt[N[(2.0 * N[(N[(A + A), $MachinePrecision] * N[(-4.0 * N[(A * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(N[(C * A), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Power[N[(F * A), $MachinePrecision], 0.5], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 9.4 \cdot 10^{-17}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(A + A\right) \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)\right)}}{B \cdot B - \left(C \cdot A\right) \cdot 4}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left({\left(F \cdot A\right)}^{0.5} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if B < 9.3999999999999999e-17Initial program 22.8%
Simplified22.8%
Taylor expanded in C around inf 18.6%
cancel-sign-sub-inv18.6%
metadata-eval18.6%
*-lft-identity18.6%
Simplified18.6%
Taylor expanded in B around 0 13.2%
if 9.3999999999999999e-17 < B Initial program 12.0%
Simplified12.0%
Taylor expanded in C around inf 8.0%
cancel-sign-sub-inv8.0%
metadata-eval8.0%
*-lft-identity8.0%
Simplified8.0%
Taylor expanded in B around inf 10.7%
pow1/211.0%
*-commutative11.0%
Applied egg-rr11.0%
Final simplification12.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 5.9e-40)
(/
(- (sqrt (* 2.0 (* -8.0 (* (* C F) (* A A))))))
(- (* B B) (* (* C A) 4.0)))
(* -2.0 (* (pow (* F A) 0.5) (/ 1.0 B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 5.9e-40) {
tmp = -sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - ((C * A) * 4.0));
} else {
tmp = -2.0 * (pow((F * A), 0.5) * (1.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) :: tmp
if (b <= 5.9d-40) then
tmp = -sqrt((2.0d0 * ((-8.0d0) * ((c * f) * (a * a))))) / ((b * b) - ((c * a) * 4.0d0))
else
tmp = (-2.0d0) * (((f * a) ** 0.5d0) * (1.0d0 / 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 <= 5.9e-40) {
tmp = -Math.sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - ((C * A) * 4.0));
} else {
tmp = -2.0 * (Math.pow((F * A), 0.5) * (1.0 / B));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= 5.9e-40: tmp = -math.sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - ((C * A) * 4.0)) else: tmp = -2.0 * (math.pow((F * A), 0.5) * (1.0 / B)) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 5.9e-40) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-8.0 * Float64(Float64(C * F) * Float64(A * A)))))) / Float64(Float64(B * B) - Float64(Float64(C * A) * 4.0))); else tmp = Float64(-2.0 * Float64((Float64(F * A) ^ 0.5) * 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)
tmp = 0.0;
if (B <= 5.9e-40)
tmp = -sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - ((C * A) * 4.0));
else
tmp = -2.0 * (((F * A) ^ 0.5) * (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_] := If[LessEqual[B, 5.9e-40], 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[(N[(C * A), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Power[N[(F * A), $MachinePrecision], 0.5], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 5.9 \cdot 10^{-40}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-8 \cdot \left(\left(C \cdot F\right) \cdot \left(A \cdot A\right)\right)\right)}}{B \cdot B - \left(C \cdot A\right) \cdot 4}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left({\left(F \cdot A\right)}^{0.5} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if B < 5.89999999999999966e-40Initial program 22.3%
Simplified22.3%
Taylor expanded in C around inf 19.0%
cancel-sign-sub-inv19.0%
metadata-eval19.0%
*-lft-identity19.0%
Simplified19.0%
Taylor expanded in B around 0 12.8%
unpow212.8%
Simplified12.8%
if 5.89999999999999966e-40 < B Initial program 13.8%
Simplified13.8%
Taylor expanded in C around inf 7.6%
cancel-sign-sub-inv7.6%
metadata-eval7.6%
*-lft-identity7.6%
Simplified7.6%
Taylor expanded in B around inf 10.2%
pow1/210.5%
*-commutative10.5%
Applied egg-rr10.5%
Final simplification12.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 (* (pow (* F A) 0.5) (/ 1.0 B))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (pow((F * A), 0.5) * (1.0 / B));
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (-2.0d0) * (((f * a) ** 0.5d0) * (1.0d0 / b))
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return -2.0 * (Math.pow((F * A), 0.5) * (1.0 / B));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.pow((F * A), 0.5) * (1.0 / B))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64((Float64(F * A) ^ 0.5) * Float64(1.0 / B))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (((F * A) ^ 0.5) * (1.0 / B));
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(-2.0 * N[(N[Power[N[(F * A), $MachinePrecision], 0.5], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \left({\left(F \cdot A\right)}^{0.5} \cdot \frac{1}{B}\right)
\end{array}
Initial program 19.7%
Simplified19.7%
Taylor expanded in C around inf 15.5%
cancel-sign-sub-inv15.5%
metadata-eval15.5%
*-lft-identity15.5%
Simplified15.5%
Taylor expanded in B around inf 4.1%
pow1/24.3%
*-commutative4.3%
Applied egg-rr4.3%
Final simplification4.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 (* -2.0 (/ (sqrt (* F A)) B)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (sqrt((F * 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 * 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 * A)) / B);
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.sqrt((F * A)) / B)
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64(sqrt(Float64(F * A)) / B)) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (sqrt((F * 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[(N[Sqrt[N[(F * A), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \frac{\sqrt{F \cdot A}}{B}
\end{array}
Initial program 19.7%
Simplified19.7%
Taylor expanded in C around inf 15.5%
cancel-sign-sub-inv15.5%
metadata-eval15.5%
*-lft-identity15.5%
Simplified15.5%
Taylor expanded in B around inf 4.1%
un-div-inv4.1%
*-commutative4.1%
Applied egg-rr4.1%
Final simplification4.1%
herbie shell --seed 2023274
(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))))