
(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 15 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 (- A (hypot A B))) (t_1 (- (* B B) (* 4.0 (* C A)))))
(if (<= (pow B 2.0) 2e-285)
(/
(* (sqrt 2.0) (- (sqrt (* (fma B B (* C (* A -4.0))) (* F (* 2.0 A))))))
t_1)
(if (<= (pow B 2.0) 1e+30)
(/ (- (sqrt (* 2.0 (* (* F t_1) t_0)))) t_1)
(/ (* (sqrt (* F t_0)) (- (sqrt 2.0))) B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = A - hypot(A, B);
double t_1 = (B * B) - (4.0 * (C * A));
double tmp;
if (pow(B, 2.0) <= 2e-285) {
tmp = (sqrt(2.0) * -sqrt((fma(B, B, (C * (A * -4.0))) * (F * (2.0 * A))))) / t_1;
} else if (pow(B, 2.0) <= 1e+30) {
tmp = -sqrt((2.0 * ((F * t_1) * t_0))) / t_1;
} else {
tmp = (sqrt((F * t_0)) * -sqrt(2.0)) / B;
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(A - hypot(A, B)) t_1 = Float64(Float64(B * B) - Float64(4.0 * Float64(C * A))) tmp = 0.0 if ((B ^ 2.0) <= 2e-285) tmp = Float64(Float64(sqrt(2.0) * Float64(-sqrt(Float64(fma(B, B, Float64(C * Float64(A * -4.0))) * Float64(F * Float64(2.0 * A)))))) / t_1); elseif ((B ^ 2.0) <= 1e+30) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_1) * t_0)))) / t_1); else tmp = Float64(Float64(sqrt(Float64(F * t_0)) * Float64(-sqrt(2.0))) / B); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e-285], N[(N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 1e+30], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[(N[(N[Sqrt[N[(F * t$95$0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision] / B), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := A - \mathsf{hypot}\left(A, B\right)\\
t_1 := B \cdot B - 4 \cdot \left(C \cdot A\right)\\
\mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-285}:\\
\;\;\;\;\frac{\sqrt{2} \cdot \left(-\sqrt{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(F \cdot \left(2 \cdot A\right)\right)}\right)}{t_1}\\
\mathbf{elif}\;{B}^{2} \leq 10^{+30}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_1\right) \cdot t_0\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{F \cdot t_0} \cdot \left(-\sqrt{2}\right)}{B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 2.00000000000000015e-285Initial program 16.4%
Simplified16.4%
Taylor expanded in A around -inf 20.3%
*-commutative20.3%
Simplified20.3%
sqrt-prod20.2%
associate-*l*24.8%
cancel-sign-sub-inv24.8%
metadata-eval24.8%
associate-*r*24.8%
*-commutative24.8%
*-commutative24.8%
fma-udef24.8%
Applied egg-rr24.8%
if 2.00000000000000015e-285 < (pow.f64 B 2) < 1e30Initial program 42.9%
Simplified42.9%
Taylor expanded in C around 0 35.0%
+-commutative35.0%
unpow235.0%
unpow235.0%
hypot-def39.1%
Simplified39.1%
if 1e30 < (pow.f64 B 2) Initial program 10.9%
Simplified10.9%
Taylor expanded in C around 0 7.1%
mul-1-neg7.1%
*-commutative7.1%
+-commutative7.1%
unpow27.1%
unpow27.1%
hypot-def22.8%
Simplified22.8%
associate-*l/22.8%
Applied egg-rr22.8%
Final simplification28.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 (* C A))))
(t_1 (- A (hypot A B)))
(t_2 (+ (* B B) (* -4.0 (* C A)))))
(if (<= B 1.15e-142)
(/ (- (sqrt (* 2.0 (* t_2 (* F (+ A (+ A (* 0.5 (/ (* B B) A))))))))) t_2)
(if (<= B 1.9e+16)
(/ (- (sqrt (* 2.0 (* (* F t_0) t_1)))) t_0)
(* (sqrt (* F t_1)) (/ (- (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 = A - hypot(A, B);
double t_2 = (B * B) + (-4.0 * (C * A));
double tmp;
if (B <= 1.15e-142) {
tmp = -sqrt((2.0 * (t_2 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_2;
} else if (B <= 1.9e+16) {
tmp = -sqrt((2.0 * ((F * t_0) * t_1))) / t_0;
} else {
tmp = sqrt((F * t_1)) * (-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 = A - Math.hypot(A, B);
double t_2 = (B * B) + (-4.0 * (C * A));
double tmp;
if (B <= 1.15e-142) {
tmp = -Math.sqrt((2.0 * (t_2 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_2;
} else if (B <= 1.9e+16) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * t_1))) / t_0;
} else {
tmp = Math.sqrt((F * t_1)) * (-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 = A - math.hypot(A, B) t_2 = (B * B) + (-4.0 * (C * A)) tmp = 0 if B <= 1.15e-142: tmp = -math.sqrt((2.0 * (t_2 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_2 elif B <= 1.9e+16: tmp = -math.sqrt((2.0 * ((F * t_0) * t_1))) / t_0 else: tmp = math.sqrt((F * t_1)) * (-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(A - hypot(A, B)) t_2 = Float64(Float64(B * B) + Float64(-4.0 * Float64(C * A))) tmp = 0.0 if (B <= 1.15e-142) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_2 * Float64(F * Float64(A + Float64(A + Float64(0.5 * Float64(Float64(B * B) / A))))))))) / t_2); elseif (B <= 1.9e+16) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * t_1)))) / t_0); else tmp = Float64(sqrt(Float64(F * t_1)) * 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 = A - hypot(A, B);
t_2 = (B * B) + (-4.0 * (C * A));
tmp = 0.0;
if (B <= 1.15e-142)
tmp = -sqrt((2.0 * (t_2 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_2;
elseif (B <= 1.9e+16)
tmp = -sqrt((2.0 * ((F * t_0) * t_1))) / t_0;
else
tmp = sqrt((F * t_1)) * (-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[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 1.15e-142], N[((-N[Sqrt[N[(2.0 * N[(t$95$2 * N[(F * N[(A + N[(A + N[(0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision], If[LessEqual[B, 1.9e+16], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * t$95$1), $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 := A - \mathsf{hypot}\left(A, B\right)\\
t_2 := B \cdot B + -4 \cdot \left(C \cdot A\right)\\
\mathbf{if}\;B \leq 1.15 \cdot 10^{-142}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_2 \cdot \left(F \cdot \left(A + \left(A + 0.5 \cdot \frac{B \cdot B}{A}\right)\right)\right)\right)}}{t_2}\\
\mathbf{elif}\;B \leq 1.9 \cdot 10^{+16}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot t_1\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot t_1} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 1.15000000000000001e-142Initial program 22.4%
Simplified22.4%
distribute-frac-neg22.4%
Applied egg-rr31.7%
Taylor expanded in A around -inf 16.8%
unpow216.8%
Simplified16.8%
if 1.15000000000000001e-142 < B < 1.9e16Initial program 39.6%
Simplified39.6%
Taylor expanded in C around 0 31.2%
+-commutative31.2%
unpow231.2%
unpow231.2%
hypot-def31.6%
Simplified31.6%
if 1.9e16 < B Initial program 7.9%
Simplified7.9%
Taylor expanded in C around 0 13.2%
mul-1-neg13.2%
*-commutative13.2%
+-commutative13.2%
unpow213.2%
unpow213.2%
hypot-def43.4%
Simplified43.4%
Final simplification25.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 (* C A))))
(t_1 (- A (hypot A B)))
(t_2 (+ (* B B) (* -4.0 (* C A)))))
(if (<= B 1.15e-142)
(/ (- (sqrt (* 2.0 (* t_2 (* F (+ A (+ A (* 0.5 (/ (* B B) A))))))))) t_2)
(if (<= B 1.5e+16)
(/ (- (sqrt (* 2.0 (* (* F t_0) t_1)))) t_0)
(/ (* (sqrt (* F t_1)) (- (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 = A - hypot(A, B);
double t_2 = (B * B) + (-4.0 * (C * A));
double tmp;
if (B <= 1.15e-142) {
tmp = -sqrt((2.0 * (t_2 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_2;
} else if (B <= 1.5e+16) {
tmp = -sqrt((2.0 * ((F * t_0) * t_1))) / t_0;
} else {
tmp = (sqrt((F * t_1)) * -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 = A - Math.hypot(A, B);
double t_2 = (B * B) + (-4.0 * (C * A));
double tmp;
if (B <= 1.15e-142) {
tmp = -Math.sqrt((2.0 * (t_2 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_2;
} else if (B <= 1.5e+16) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * t_1))) / t_0;
} else {
tmp = (Math.sqrt((F * t_1)) * -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 = A - math.hypot(A, B) t_2 = (B * B) + (-4.0 * (C * A)) tmp = 0 if B <= 1.15e-142: tmp = -math.sqrt((2.0 * (t_2 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_2 elif B <= 1.5e+16: tmp = -math.sqrt((2.0 * ((F * t_0) * t_1))) / t_0 else: tmp = (math.sqrt((F * t_1)) * -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(A - hypot(A, B)) t_2 = Float64(Float64(B * B) + Float64(-4.0 * Float64(C * A))) tmp = 0.0 if (B <= 1.15e-142) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_2 * Float64(F * Float64(A + Float64(A + Float64(0.5 * Float64(Float64(B * B) / A))))))))) / t_2); elseif (B <= 1.5e+16) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * t_1)))) / t_0); else tmp = Float64(Float64(sqrt(Float64(F * t_1)) * 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 = A - hypot(A, B);
t_2 = (B * B) + (-4.0 * (C * A));
tmp = 0.0;
if (B <= 1.15e-142)
tmp = -sqrt((2.0 * (t_2 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_2;
elseif (B <= 1.5e+16)
tmp = -sqrt((2.0 * ((F * t_0) * t_1))) / t_0;
else
tmp = (sqrt((F * t_1)) * -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[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 1.15e-142], N[((-N[Sqrt[N[(2.0 * N[(t$95$2 * N[(F * N[(A + N[(A + N[(0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision], If[LessEqual[B, 1.5e+16], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[N[(F * t$95$1), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision] / B), $MachinePrecision]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(C \cdot A\right)\\
t_1 := A - \mathsf{hypot}\left(A, B\right)\\
t_2 := B \cdot B + -4 \cdot \left(C \cdot A\right)\\
\mathbf{if}\;B \leq 1.15 \cdot 10^{-142}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_2 \cdot \left(F \cdot \left(A + \left(A + 0.5 \cdot \frac{B \cdot B}{A}\right)\right)\right)\right)}}{t_2}\\
\mathbf{elif}\;B \leq 1.5 \cdot 10^{+16}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot t_1\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{F \cdot t_1} \cdot \left(-\sqrt{2}\right)}{B}\\
\end{array}
\end{array}
if B < 1.15000000000000001e-142Initial program 22.4%
Simplified22.4%
distribute-frac-neg22.4%
Applied egg-rr31.7%
Taylor expanded in A around -inf 16.8%
unpow216.8%
Simplified16.8%
if 1.15000000000000001e-142 < B < 1.5e16Initial program 39.6%
Simplified39.6%
Taylor expanded in C around 0 31.2%
+-commutative31.2%
unpow231.2%
unpow231.2%
hypot-def31.6%
Simplified31.6%
if 1.5e16 < B Initial program 7.9%
Simplified7.9%
Taylor expanded in C around 0 13.2%
mul-1-neg13.2%
*-commutative13.2%
+-commutative13.2%
unpow213.2%
unpow213.2%
hypot-def43.4%
Simplified43.4%
associate-*l/43.6%
Applied egg-rr43.6%
Final simplification25.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 (* C A)))) (t_1 (+ (* B B) (* -4.0 (* C A)))))
(if (<= B 7.2e-143)
(/ (- (sqrt (* 2.0 (* t_1 (* F (+ A (+ A (* 0.5 (/ (* B B) A))))))))) t_1)
(if (<= B 1.3e+32)
(/ (- (sqrt (* 2.0 (* (* F t_0) (- A (hypot A B)))))) 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 * (C * A));
double t_1 = (B * B) + (-4.0 * (C * A));
double tmp;
if (B <= 7.2e-143) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
} else if (B <= 1.3e+32) {
tmp = -sqrt((2.0 * ((F * t_0) * (A - hypot(A, B))))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (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 t_1 = (B * B) + (-4.0 * (C * A));
double tmp;
if (B <= 7.2e-143) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
} else if (B <= 1.3e+32) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (A - Math.hypot(A, B))))) / 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 * (C * A)) t_1 = (B * B) + (-4.0 * (C * A)) tmp = 0 if B <= 7.2e-143: tmp = -math.sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1 elif B <= 1.3e+32: tmp = -math.sqrt((2.0 * ((F * t_0) * (A - math.hypot(A, B))))) / 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(C * A))) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(C * A))) tmp = 0.0 if (B <= 7.2e-143) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + Float64(A + Float64(0.5 * Float64(Float64(B * B) / A))))))))) / t_1); elseif (B <= 1.3e+32) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A - hypot(A, B)))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - B))))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (C * A));
t_1 = (B * B) + (-4.0 * (C * A));
tmp = 0.0;
if (B <= 7.2e-143)
tmp = -sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
elseif (B <= 1.3e+32)
tmp = -sqrt((2.0 * ((F * t_0) * (A - hypot(A, B))))) / 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[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 7.2e-143], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + N[(A + N[(0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B, 1.3e+32], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $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(C \cdot A\right)\\
t_1 := B \cdot B + -4 \cdot \left(C \cdot A\right)\\
\mathbf{if}\;B \leq 7.2 \cdot 10^{-143}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + \left(A + 0.5 \cdot \frac{B \cdot B}{A}\right)\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;B \leq 1.3 \cdot 10^{+32}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < 7.1999999999999996e-143Initial program 22.4%
Simplified22.4%
distribute-frac-neg22.4%
Applied egg-rr31.7%
Taylor expanded in A around -inf 16.8%
unpow216.8%
Simplified16.8%
if 7.1999999999999996e-143 < B < 1.3000000000000001e32Initial program 37.5%
Simplified37.5%
Taylor expanded in C around 0 29.5%
+-commutative29.5%
unpow229.5%
unpow229.5%
hypot-def29.9%
Simplified29.9%
if 1.3000000000000001e32 < B Initial program 8.2%
Simplified8.2%
Taylor expanded in C around 0 13.5%
mul-1-neg13.5%
*-commutative13.5%
+-commutative13.5%
unpow213.5%
unpow213.5%
hypot-def44.8%
Simplified44.8%
Taylor expanded in A around 0 41.2%
mul-1-neg41.2%
unsub-neg41.2%
Simplified41.2%
Final simplification24.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 (* C A)))) (t_1 (+ (* B B) (* -4.0 (* C A)))))
(if (<= B 6e-107)
(/ (- (sqrt (* 2.0 (* t_1 (* F (+ A (+ A (* 0.5 (/ (* B B) A))))))))) t_1)
(if (<= B 1.75e+16)
(/ (- (sqrt (* 2.0 (* (* 2.0 A) (* F t_0))))) 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 * (C * A));
double t_1 = (B * B) + (-4.0 * (C * A));
double tmp;
if (B <= 6e-107) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
} else if (B <= 1.75e+16) {
tmp = -sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / 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) :: t_1
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (c * a))
t_1 = (b * b) + ((-4.0d0) * (c * a))
if (b <= 6d-107) then
tmp = -sqrt((2.0d0 * (t_1 * (f * (a + (a + (0.5d0 * ((b * b) / a)))))))) / t_1
else if (b <= 1.75d+16) then
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * (f * t_0)))) / 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 * (C * A));
double t_1 = (B * B) + (-4.0 * (C * A));
double tmp;
if (B <= 6e-107) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
} else if (B <= 1.75e+16) {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / 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 * (C * A)) t_1 = (B * B) + (-4.0 * (C * A)) tmp = 0 if B <= 6e-107: tmp = -math.sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1 elif B <= 1.75e+16: tmp = -math.sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / 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(C * A))) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(C * A))) tmp = 0.0 if (B <= 6e-107) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + Float64(A + Float64(0.5 * Float64(Float64(B * B) / A))))))))) / t_1); elseif (B <= 1.75e+16) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(F * t_0))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - B))))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (C * A));
t_1 = (B * B) + (-4.0 * (C * A));
tmp = 0.0;
if (B <= 6e-107)
tmp = -sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
elseif (B <= 1.75e+16)
tmp = -sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / 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[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 6e-107], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + N[(A + N[(0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B, 1.75e+16], N[((-N[Sqrt[N[(2.0 * N[(N[(2.0 * A), $MachinePrecision] * N[(F * t$95$0), $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(C \cdot A\right)\\
t_1 := B \cdot B + -4 \cdot \left(C \cdot A\right)\\
\mathbf{if}\;B \leq 6 \cdot 10^{-107}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + \left(A + 0.5 \cdot \frac{B \cdot B}{A}\right)\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;B \leq 1.75 \cdot 10^{+16}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(F \cdot t_0\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < 5.9999999999999994e-107Initial program 24.5%
Simplified24.5%
distribute-frac-neg24.5%
Applied egg-rr33.2%
Taylor expanded in A around -inf 17.0%
unpow217.0%
Simplified17.0%
if 5.9999999999999994e-107 < B < 1.75e16Initial program 32.8%
Simplified32.8%
Taylor expanded in A around -inf 14.2%
*-commutative14.2%
Simplified14.2%
if 1.75e16 < B Initial program 7.9%
Simplified7.9%
Taylor expanded in C around 0 13.2%
mul-1-neg13.2%
*-commutative13.2%
+-commutative13.2%
unpow213.2%
unpow213.2%
hypot-def43.4%
Simplified43.4%
Taylor expanded in A around 0 39.9%
mul-1-neg39.9%
unsub-neg39.9%
Simplified39.9%
Final simplification22.0%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* C A)))) (t_1 (+ (* B B) (* -4.0 (* C A)))))
(if (<= B 2.9e-109)
(/ (- (sqrt (* 2.0 (* t_1 (* F (+ A (+ A (* 0.5 (/ (* B B) A))))))))) t_1)
(if (<= B 2e+16)
(/ (- (sqrt (* 2.0 (* (* 2.0 A) (* F t_0))))) t_0)
(* (sqrt (* F (- 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 = (B * B) + (-4.0 * (C * A));
double tmp;
if (B <= 2.9e-109) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
} else if (B <= 2e+16) {
tmp = -sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / t_0;
} else {
tmp = sqrt((F * -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) :: t_1
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (c * a))
t_1 = (b * b) + ((-4.0d0) * (c * a))
if (b <= 2.9d-109) then
tmp = -sqrt((2.0d0 * (t_1 * (f * (a + (a + (0.5d0 * ((b * b) / a)))))))) / t_1
else if (b <= 2d+16) then
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * (f * t_0)))) / t_0
else
tmp = sqrt((f * -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 t_1 = (B * B) + (-4.0 * (C * A));
double tmp;
if (B <= 2.9e-109) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
} else if (B <= 2e+16) {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / t_0;
} else {
tmp = Math.sqrt((F * -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 = (B * B) + (-4.0 * (C * A)) tmp = 0 if B <= 2.9e-109: tmp = -math.sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1 elif B <= 2e+16: tmp = -math.sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / t_0 else: tmp = math.sqrt((F * -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(B * B) + Float64(-4.0 * Float64(C * A))) tmp = 0.0 if (B <= 2.9e-109) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + Float64(A + Float64(0.5 * Float64(Float64(B * B) / A))))))))) / t_1); elseif (B <= 2e+16) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(F * t_0))))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(-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 = (B * B) + (-4.0 * (C * A));
tmp = 0.0;
if (B <= 2.9e-109)
tmp = -sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
elseif (B <= 2e+16)
tmp = -sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / t_0;
else
tmp = sqrt((F * -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[(B * B), $MachinePrecision] + N[(-4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 2.9e-109], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + N[(A + N[(0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B, 2e+16], N[((-N[Sqrt[N[(2.0 * N[(N[(2.0 * A), $MachinePrecision] * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * (-B)), $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 := B \cdot B + -4 \cdot \left(C \cdot A\right)\\
\mathbf{if}\;B \leq 2.9 \cdot 10^{-109}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + \left(A + 0.5 \cdot \frac{B \cdot B}{A}\right)\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;B \leq 2 \cdot 10^{+16}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(F \cdot t_0\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(-B\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 2.9e-109Initial program 24.5%
Simplified24.5%
distribute-frac-neg24.5%
Applied egg-rr33.2%
Taylor expanded in A around -inf 17.0%
unpow217.0%
Simplified17.0%
if 2.9e-109 < B < 2e16Initial program 32.8%
Simplified32.8%
Taylor expanded in A around -inf 14.2%
*-commutative14.2%
Simplified14.2%
if 2e16 < B Initial program 7.9%
Simplified7.9%
Taylor expanded in C around 0 13.2%
mul-1-neg13.2%
*-commutative13.2%
+-commutative13.2%
unpow213.2%
unpow213.2%
hypot-def43.4%
Simplified43.4%
Taylor expanded in A around 0 40.4%
mul-1-neg40.4%
Simplified40.4%
Final simplification22.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 (* C A)))) (t_1 (+ (* B B) (* -4.0 (* C A)))))
(if (<= B 1.72e-109)
(/ (- (sqrt (* 2.0 (* t_1 (* F (+ A (+ A (* 0.5 (/ (* B B) A))))))))) t_1)
(if (<= B 3.1e+16)
(/ (- (sqrt (* 2.0 (* (* 2.0 A) (* F t_0))))) t_0)
(/ (* (sqrt (* F (- 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 = (B * B) + (-4.0 * (C * A));
double tmp;
if (B <= 1.72e-109) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
} else if (B <= 3.1e+16) {
tmp = -sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / t_0;
} else {
tmp = (sqrt((F * -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) :: t_1
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (c * a))
t_1 = (b * b) + ((-4.0d0) * (c * a))
if (b <= 1.72d-109) then
tmp = -sqrt((2.0d0 * (t_1 * (f * (a + (a + (0.5d0 * ((b * b) / a)))))))) / t_1
else if (b <= 3.1d+16) then
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * (f * t_0)))) / t_0
else
tmp = (sqrt((f * -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 t_1 = (B * B) + (-4.0 * (C * A));
double tmp;
if (B <= 1.72e-109) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
} else if (B <= 3.1e+16) {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / t_0;
} else {
tmp = (Math.sqrt((F * -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 = (B * B) + (-4.0 * (C * A)) tmp = 0 if B <= 1.72e-109: tmp = -math.sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1 elif B <= 3.1e+16: tmp = -math.sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / t_0 else: tmp = (math.sqrt((F * -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(B * B) + Float64(-4.0 * Float64(C * A))) tmp = 0.0 if (B <= 1.72e-109) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + Float64(A + Float64(0.5 * Float64(Float64(B * B) / A))))))))) / t_1); elseif (B <= 3.1e+16) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(F * t_0))))) / t_0); else tmp = Float64(Float64(sqrt(Float64(F * Float64(-B))) * 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 = (B * B) + (-4.0 * (C * A));
tmp = 0.0;
if (B <= 1.72e-109)
tmp = -sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
elseif (B <= 3.1e+16)
tmp = -sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / t_0;
else
tmp = (sqrt((F * -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[(B * B), $MachinePrecision] + N[(-4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 1.72e-109], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + N[(A + N[(0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B, 3.1e+16], N[((-N[Sqrt[N[(2.0 * N[(N[(2.0 * A), $MachinePrecision] * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[N[(F * (-B)), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision] / B), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(C \cdot A\right)\\
t_1 := B \cdot B + -4 \cdot \left(C \cdot A\right)\\
\mathbf{if}\;B \leq 1.72 \cdot 10^{-109}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + \left(A + 0.5 \cdot \frac{B \cdot B}{A}\right)\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;B \leq 3.1 \cdot 10^{+16}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(F \cdot t_0\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{F \cdot \left(-B\right)} \cdot \left(-\sqrt{2}\right)}{B}\\
\end{array}
\end{array}
if B < 1.7200000000000001e-109Initial program 24.5%
Simplified24.5%
distribute-frac-neg24.5%
Applied egg-rr33.2%
Taylor expanded in A around -inf 17.0%
unpow217.0%
Simplified17.0%
if 1.7200000000000001e-109 < B < 3.1e16Initial program 32.8%
Simplified32.8%
Taylor expanded in A around -inf 14.2%
*-commutative14.2%
Simplified14.2%
if 3.1e16 < B Initial program 7.9%
Simplified7.9%
Taylor expanded in C around 0 13.2%
mul-1-neg13.2%
*-commutative13.2%
+-commutative13.2%
unpow213.2%
unpow213.2%
hypot-def43.4%
Simplified43.4%
Taylor expanded in A around 0 40.4%
mul-1-neg40.4%
Simplified40.4%
associate-*l/40.4%
Applied egg-rr40.4%
Final simplification22.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 (* C A)))) (t_1 (+ (* B B) (* -4.0 (* C A)))))
(if (<= A -4e-90)
(/ (- (sqrt (* 2.0 (* t_1 (* F (+ A (+ A (* 0.5 (/ (* B B) A))))))))) t_1)
(if (<= A 2.75e-237)
(/ (- (sqrt (* 2.0 (* (* F t_0) (- (+ C A) B))))) t_0)
(/
(-
(sqrt
(*
2.0
(*
t_1
(*
F
(+ A (+ A (* -0.5 (/ (+ (* B B) (- (* A A) (* A A))) C)))))))))
t_1)))))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 = (B * B) + (-4.0 * (C * A));
double tmp;
if (A <= -4e-90) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
} else if (A <= 2.75e-237) {
tmp = -sqrt((2.0 * ((F * t_0) * ((C + A) - B)))) / t_0;
} else {
tmp = -sqrt((2.0 * (t_1 * (F * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C)))))))) / t_1;
}
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 * (c * a))
t_1 = (b * b) + ((-4.0d0) * (c * a))
if (a <= (-4d-90)) then
tmp = -sqrt((2.0d0 * (t_1 * (f * (a + (a + (0.5d0 * ((b * b) / a)))))))) / t_1
else if (a <= 2.75d-237) then
tmp = -sqrt((2.0d0 * ((f * t_0) * ((c + a) - b)))) / t_0
else
tmp = -sqrt((2.0d0 * (t_1 * (f * (a + (a + ((-0.5d0) * (((b * b) + ((a * a) - (a * a))) / c)))))))) / t_1
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 t_1 = (B * B) + (-4.0 * (C * A));
double tmp;
if (A <= -4e-90) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
} else if (A <= 2.75e-237) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * ((C + A) - B)))) / t_0;
} else {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C)))))))) / t_1;
}
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 = (B * B) + (-4.0 * (C * A)) tmp = 0 if A <= -4e-90: tmp = -math.sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1 elif A <= 2.75e-237: tmp = -math.sqrt((2.0 * ((F * t_0) * ((C + A) - B)))) / t_0 else: tmp = -math.sqrt((2.0 * (t_1 * (F * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C)))))))) / t_1 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(B * B) + Float64(-4.0 * Float64(C * A))) tmp = 0.0 if (A <= -4e-90) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + Float64(A + Float64(0.5 * Float64(Float64(B * B) / A))))))))) / t_1); elseif (A <= 2.75e-237) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(Float64(C + A) - B))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + Float64(A + Float64(-0.5 * Float64(Float64(Float64(B * B) + Float64(Float64(A * A) - Float64(A * A))) / C))))))))) / t_1); 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 = (B * B) + (-4.0 * (C * A));
tmp = 0.0;
if (A <= -4e-90)
tmp = -sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
elseif (A <= 2.75e-237)
tmp = -sqrt((2.0 * ((F * t_0) * ((C + A) - B)))) / t_0;
else
tmp = -sqrt((2.0 * (t_1 * (F * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C)))))))) / t_1;
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[(B * B), $MachinePrecision] + N[(-4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[A, -4e-90], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + N[(A + N[(0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[A, 2.75e-237], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(N[(C + A), $MachinePrecision] - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + N[(A + N[(-0.5 * N[(N[(N[(B * B), $MachinePrecision] + N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $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 := B \cdot B + -4 \cdot \left(C \cdot A\right)\\
\mathbf{if}\;A \leq -4 \cdot 10^{-90}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + \left(A + 0.5 \cdot \frac{B \cdot B}{A}\right)\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;A \leq 2.75 \cdot 10^{-237}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(\left(C + A\right) - B\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + \left(A + -0.5 \cdot \frac{B \cdot B + \left(A \cdot A - A \cdot A\right)}{C}\right)\right)\right)\right)}}{t_1}\\
\end{array}
\end{array}
if A < -3.99999999999999998e-90Initial program 21.0%
Simplified21.0%
distribute-frac-neg21.0%
Applied egg-rr33.5%
Taylor expanded in A around -inf 30.6%
unpow230.6%
Simplified30.6%
if -3.99999999999999998e-90 < A < 2.74999999999999991e-237Initial program 43.3%
Simplified43.3%
Taylor expanded in B around inf 14.9%
if 2.74999999999999991e-237 < A Initial program 10.3%
Simplified10.3%
distribute-frac-neg10.3%
Applied egg-rr12.2%
Taylor expanded in C around inf 7.6%
associate--l+7.7%
unpow27.7%
unpow27.7%
unpow27.7%
mul-1-neg7.7%
mul-1-neg7.7%
sqr-neg7.7%
Simplified7.7%
Final simplification17.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 (* C A)))) (t_1 (+ (* B B) (* -4.0 (* C A)))))
(if (<= A -4e-90)
(/ (- (sqrt (* 2.0 (* t_1 (* F (+ A (+ A (* 0.5 (/ (* B B) A))))))))) t_1)
(if (<= A 1.1e-232)
(/ (- (sqrt (* 2.0 (* (* F t_0) (- (+ C A) B))))) t_0)
(/ (- (sqrt (* 2.0 (* (* 2.0 A) (* -4.0 (* F (* C A))))))) t_0)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (C * A));
double t_1 = (B * B) + (-4.0 * (C * A));
double tmp;
if (A <= -4e-90) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
} else if (A <= 1.1e-232) {
tmp = -sqrt((2.0 * ((F * t_0) * ((C + A) - B)))) / t_0;
} else {
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (C * A)))))) / t_0;
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (c * a))
t_1 = (b * b) + ((-4.0d0) * (c * a))
if (a <= (-4d-90)) then
tmp = -sqrt((2.0d0 * (t_1 * (f * (a + (a + (0.5d0 * ((b * b) / a)))))))) / t_1
else if (a <= 1.1d-232) then
tmp = -sqrt((2.0d0 * ((f * t_0) * ((c + a) - b)))) / t_0
else
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * ((-4.0d0) * (f * (c * a)))))) / t_0
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (C * A));
double t_1 = (B * B) + (-4.0 * (C * A));
double tmp;
if (A <= -4e-90) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
} else if (A <= 1.1e-232) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * ((C + A) - B)))) / t_0;
} else {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (C * A)))))) / t_0;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (C * A)) t_1 = (B * B) + (-4.0 * (C * A)) tmp = 0 if A <= -4e-90: tmp = -math.sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1 elif A <= 1.1e-232: tmp = -math.sqrt((2.0 * ((F * t_0) * ((C + A) - B)))) / t_0 else: tmp = -math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (C * A)))))) / t_0 return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(C * A))) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(C * A))) tmp = 0.0 if (A <= -4e-90) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + Float64(A + Float64(0.5 * Float64(Float64(B * B) / A))))))))) / t_1); elseif (A <= 1.1e-232) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(Float64(C + A) - B))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(-4.0 * Float64(F * Float64(C * A))))))) / t_0); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (C * A));
t_1 = (B * B) + (-4.0 * (C * A));
tmp = 0.0;
if (A <= -4e-90)
tmp = -sqrt((2.0 * (t_1 * (F * (A + (A + (0.5 * ((B * B) / A)))))))) / t_1;
elseif (A <= 1.1e-232)
tmp = -sqrt((2.0 * ((F * t_0) * ((C + A) - B)))) / t_0;
else
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (C * A)))))) / t_0;
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[A, -4e-90], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + N[(A + N[(0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[A, 1.1e-232], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(N[(C + A), $MachinePrecision] - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(N[(2.0 * A), $MachinePrecision] * N[(-4.0 * N[(F * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(C \cdot A\right)\\
t_1 := B \cdot B + -4 \cdot \left(C \cdot A\right)\\
\mathbf{if}\;A \leq -4 \cdot 10^{-90}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + \left(A + 0.5 \cdot \frac{B \cdot B}{A}\right)\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;A \leq 1.1 \cdot 10^{-232}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(\left(C + A\right) - B\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(-4 \cdot \left(F \cdot \left(C \cdot A\right)\right)\right)\right)}}{t_0}\\
\end{array}
\end{array}
if A < -3.99999999999999998e-90Initial program 21.0%
Simplified21.0%
distribute-frac-neg21.0%
Applied egg-rr33.5%
Taylor expanded in A around -inf 30.6%
unpow230.6%
Simplified30.6%
if -3.99999999999999998e-90 < A < 1.10000000000000001e-232Initial program 43.3%
Simplified43.3%
Taylor expanded in B around inf 14.9%
if 1.10000000000000001e-232 < A Initial program 10.3%
Simplified10.3%
Taylor expanded in A around -inf 3.9%
*-commutative3.9%
Simplified3.9%
Taylor expanded in B around 0 5.9%
associate-*r*5.7%
*-commutative5.7%
Simplified5.7%
Final simplification16.2%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* C A)))) (t_1 (* F t_0)))
(if (<= A -4.2e-90)
(/ (- (sqrt (* 2.0 (* (* 2.0 A) t_1)))) t_0)
(if (<= A 1.32e-235)
(/ (- (sqrt (* 2.0 (* t_1 (- (+ C A) B))))) t_0)
(/ (- (sqrt (* 2.0 (* (* 2.0 A) (* -4.0 (* F (* C A))))))) t_0)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (C * A));
double t_1 = F * t_0;
double tmp;
if (A <= -4.2e-90) {
tmp = -sqrt((2.0 * ((2.0 * A) * t_1))) / t_0;
} else if (A <= 1.32e-235) {
tmp = -sqrt((2.0 * (t_1 * ((C + A) - B)))) / t_0;
} else {
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (C * A)))))) / t_0;
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (c * a))
t_1 = f * t_0
if (a <= (-4.2d-90)) then
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * t_1))) / t_0
else if (a <= 1.32d-235) then
tmp = -sqrt((2.0d0 * (t_1 * ((c + a) - b)))) / t_0
else
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * ((-4.0d0) * (f * (c * a)))))) / t_0
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (C * A));
double t_1 = F * t_0;
double tmp;
if (A <= -4.2e-90) {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * t_1))) / t_0;
} else if (A <= 1.32e-235) {
tmp = -Math.sqrt((2.0 * (t_1 * ((C + A) - B)))) / t_0;
} else {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (C * A)))))) / t_0;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (C * A)) t_1 = F * t_0 tmp = 0 if A <= -4.2e-90: tmp = -math.sqrt((2.0 * ((2.0 * A) * t_1))) / t_0 elif A <= 1.32e-235: tmp = -math.sqrt((2.0 * (t_1 * ((C + A) - B)))) / t_0 else: tmp = -math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (C * A)))))) / t_0 return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(C * A))) t_1 = Float64(F * t_0) tmp = 0.0 if (A <= -4.2e-90) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * t_1)))) / t_0); elseif (A <= 1.32e-235) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(Float64(C + A) - B))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(-4.0 * Float64(F * Float64(C * A))))))) / t_0); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (C * A));
t_1 = F * t_0;
tmp = 0.0;
if (A <= -4.2e-90)
tmp = -sqrt((2.0 * ((2.0 * A) * t_1))) / t_0;
elseif (A <= 1.32e-235)
tmp = -sqrt((2.0 * (t_1 * ((C + A) - B)))) / t_0;
else
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (C * A)))))) / t_0;
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(F * t$95$0), $MachinePrecision]}, If[LessEqual[A, -4.2e-90], N[((-N[Sqrt[N[(2.0 * N[(N[(2.0 * A), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[A, 1.32e-235], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(N[(C + A), $MachinePrecision] - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(N[(2.0 * A), $MachinePrecision] * N[(-4.0 * N[(F * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(C \cdot A\right)\\
t_1 := F \cdot t_0\\
\mathbf{if}\;A \leq -4.2 \cdot 10^{-90}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot t_1\right)}}{t_0}\\
\mathbf{elif}\;A \leq 1.32 \cdot 10^{-235}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(\left(C + A\right) - B\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(-4 \cdot \left(F \cdot \left(C \cdot A\right)\right)\right)\right)}}{t_0}\\
\end{array}
\end{array}
if A < -4.1999999999999998e-90Initial program 21.0%
Simplified21.0%
Taylor expanded in A around -inf 29.4%
*-commutative29.4%
Simplified29.4%
if -4.1999999999999998e-90 < A < 1.32e-235Initial program 43.3%
Simplified43.3%
Taylor expanded in B around inf 14.9%
if 1.32e-235 < A Initial program 10.3%
Simplified10.3%
Taylor expanded in A around -inf 3.9%
*-commutative3.9%
Simplified3.9%
Taylor expanded in B around 0 5.9%
associate-*r*5.7%
*-commutative5.7%
Simplified5.7%
Final simplification15.8%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* C A)))))
(if (<= B 2.8e+116)
(/ (- (sqrt (* 2.0 (* (* 2.0 A) (* F t_0))))) t_0)
(* -2.0 (/ (sqrt (* A F)) B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (C * A));
double tmp;
if (B <= 2.8e+116) {
tmp = -sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / 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 * (c * a))
if (b <= 2.8d+116) then
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * (f * t_0)))) / 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 * (C * A));
double tmp;
if (B <= 2.8e+116) {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / t_0;
} else {
tmp = -2.0 * (Math.sqrt((A * F)) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (C * A)) tmp = 0 if B <= 2.8e+116: tmp = -math.sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / t_0 else: tmp = -2.0 * (math.sqrt((A * F)) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(C * A))) tmp = 0.0 if (B <= 2.8e+116) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(F * t_0))))) / t_0); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (C * A));
tmp = 0.0;
if (B <= 2.8e+116)
tmp = -sqrt((2.0 * ((2.0 * A) * (F * t_0)))) / t_0;
else
tmp = -2.0 * (sqrt((A * F)) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 2.8e+116], N[((-N[Sqrt[N[(2.0 * N[(N[(2.0 * A), $MachinePrecision] * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(C \cdot A\right)\\
\mathbf{if}\;B \leq 2.8 \cdot 10^{+116}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(F \cdot t_0\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 2.80000000000000004e116Initial program 24.6%
Simplified24.6%
Taylor expanded in A around -inf 15.5%
*-commutative15.5%
Simplified15.5%
if 2.80000000000000004e116 < B Initial program 3.2%
Simplified3.2%
Taylor expanded in A around -inf 0.7%
*-commutative0.7%
Simplified0.7%
Taylor expanded in B around inf 2.8%
Taylor expanded in B around inf 6.4%
associate-*r/6.4%
*-commutative6.4%
*-rgt-identity6.4%
Simplified6.4%
Final simplification14.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
(if (<= B 4.3e-14)
(/
(- (sqrt (* 2.0 (* (* 2.0 A) (* -4.0 (* A (* C F)))))))
(- (* B B) (* 4.0 (* C A))))
(* -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 <= 4.3e-14) {
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (C * A)));
} 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 <= 4.3d-14) then
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * ((-4.0d0) * (a * (c * f)))))) / ((b * b) - (4.0d0 * (c * a)))
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 <= 4.3e-14) {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (C * A)));
} 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 <= 4.3e-14: tmp = -math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (C * A))) 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 <= 4.3e-14) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(-4.0 * Float64(A * Float64(C * F))))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(C * A)))); 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 <= 4.3e-14)
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (C * A)));
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, 4.3e-14], N[((-N[Sqrt[N[(2.0 * N[(N[(2.0 * 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[(C * A), $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 4.3 \cdot 10^{-14}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)\right)}}{B \cdot B - 4 \cdot \left(C \cdot A\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 4.29999999999999998e-14Initial program 25.3%
Simplified25.3%
Taylor expanded in A around -inf 15.0%
*-commutative15.0%
Simplified15.0%
Taylor expanded in B around 0 11.0%
if 4.29999999999999998e-14 < B Initial program 10.3%
Simplified10.3%
Taylor expanded in A around -inf 8.5%
*-commutative8.5%
Simplified8.5%
Taylor expanded in B around inf 5.7%
Taylor expanded in B around inf 7.7%
associate-*r/7.7%
*-commutative7.7%
*-rgt-identity7.7%
Simplified7.7%
Final simplification10.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
(if (<= B 210000000.0)
(/
(- (sqrt (* 2.0 (* (* 2.0 A) (* -4.0 (* F (* C A)))))))
(- (* B B) (* 4.0 (* C A))))
(* -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 <= 210000000.0) {
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (C * A)))))) / ((B * B) - (4.0 * (C * A)));
} 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 <= 210000000.0d0) then
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * ((-4.0d0) * (f * (c * a)))))) / ((b * b) - (4.0d0 * (c * a)))
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 <= 210000000.0) {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (C * A)))))) / ((B * B) - (4.0 * (C * A)));
} 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 <= 210000000.0: tmp = -math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (C * A)))))) / ((B * B) - (4.0 * (C * A))) 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 <= 210000000.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(-4.0 * Float64(F * Float64(C * A))))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(C * A)))); 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 <= 210000000.0)
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (F * (C * A)))))) / ((B * B) - (4.0 * (C * A)));
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, 210000000.0], N[((-N[Sqrt[N[(2.0 * N[(N[(2.0 * A), $MachinePrecision] * N[(-4.0 * N[(F * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(C * A), $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 210000000:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(-4 \cdot \left(F \cdot \left(C \cdot A\right)\right)\right)\right)}}{B \cdot B - 4 \cdot \left(C \cdot A\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 2.1e8Initial program 25.3%
Simplified25.3%
Taylor expanded in A around -inf 15.7%
*-commutative15.7%
Simplified15.7%
Taylor expanded in B around 0 11.2%
associate-*r*13.6%
*-commutative13.6%
Simplified13.6%
if 2.1e8 < B Initial program 9.4%
Simplified9.4%
Taylor expanded in A around -inf 5.8%
*-commutative5.8%
Simplified5.8%
Taylor expanded in B around inf 5.7%
Taylor expanded in B around inf 7.9%
associate-*r/7.9%
*-commutative7.9%
*-rgt-identity7.9%
Simplified7.9%
Final simplification12.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
(if (<= A -1.12e+111)
(* -2.0 (/ (sqrt (* A F)) B))
(/
(- (sqrt (* 2.0 (* (* C F) (* (* A A) -8.0)))))
(- (* B B) (* 4.0 (* C A))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (A <= -1.12e+111) {
tmp = -2.0 * (sqrt((A * F)) / B);
} else {
tmp = -sqrt((2.0 * ((C * F) * ((A * A) * -8.0)))) / ((B * B) - (4.0 * (C * A)));
}
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 (a <= (-1.12d+111)) then
tmp = (-2.0d0) * (sqrt((a * f)) / b)
else
tmp = -sqrt((2.0d0 * ((c * f) * ((a * a) * (-8.0d0))))) / ((b * b) - (4.0d0 * (c * a)))
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 (A <= -1.12e+111) {
tmp = -2.0 * (Math.sqrt((A * F)) / B);
} else {
tmp = -Math.sqrt((2.0 * ((C * F) * ((A * A) * -8.0)))) / ((B * B) - (4.0 * (C * A)));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if A <= -1.12e+111: tmp = -2.0 * (math.sqrt((A * F)) / B) else: tmp = -math.sqrt((2.0 * ((C * F) * ((A * A) * -8.0)))) / ((B * B) - (4.0 * (C * A))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (A <= -1.12e+111) tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(C * F) * Float64(Float64(A * A) * -8.0))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(C * A)))); 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 (A <= -1.12e+111)
tmp = -2.0 * (sqrt((A * F)) / B);
else
tmp = -sqrt((2.0 * ((C * F) * ((A * A) * -8.0)))) / ((B * B) - (4.0 * (C * A)));
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[A, -1.12e+111], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(N[(C * F), $MachinePrecision] * N[(N[(A * A), $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;A \leq -1.12 \cdot 10^{+111}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(C \cdot F\right) \cdot \left(\left(A \cdot A\right) \cdot -8\right)\right)}}{B \cdot B - 4 \cdot \left(C \cdot A\right)}\\
\end{array}
\end{array}
if A < -1.11999999999999995e111Initial program 10.9%
Simplified10.9%
Taylor expanded in A around -inf 31.1%
*-commutative31.1%
Simplified31.1%
Taylor expanded in B around inf 6.2%
Taylor expanded in B around inf 9.0%
associate-*r/9.0%
*-commutative9.0%
*-rgt-identity9.0%
Simplified9.0%
if -1.11999999999999995e111 < A Initial program 23.6%
Simplified23.6%
Taylor expanded in A around -inf 9.8%
*-commutative9.8%
Simplified9.8%
Taylor expanded in B around 0 6.5%
associate-*r*6.4%
unpow26.4%
*-commutative6.4%
Simplified6.4%
Final simplification6.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 (* -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 21.5%
Simplified21.5%
Taylor expanded in A around -inf 13.4%
*-commutative13.4%
Simplified13.4%
Taylor expanded in B around inf 2.4%
Taylor expanded in B around inf 2.9%
associate-*r/2.9%
*-commutative2.9%
*-rgt-identity2.9%
Simplified2.9%
Final simplification2.9%
herbie shell --seed 2023240
(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))))