
(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 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C))))
(t_1 (/ (sqrt 2.0) B))
(t_2 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 3.5e-97)
(/ (- (sqrt (* 2.0 (* (* F t_0) (+ A A))))) t_0)
(if (<= B 3.6e-55)
(* t_1 (- (sqrt (* -0.5 (/ (* (pow B 2.0) F) C)))))
(if (<= B 7.5e-12)
(/ (- (sqrt (* 2.0 (* t_2 (* F (+ A A)))))) t_2)
(* t_1 (- (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 * (A * C));
double t_1 = sqrt(2.0) / B;
double t_2 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 3.5e-97) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else if (B <= 3.6e-55) {
tmp = t_1 * -sqrt((-0.5 * ((pow(B, 2.0) * F) / C)));
} else if (B <= 7.5e-12) {
tmp = -sqrt((2.0 * (t_2 * (F * (A + A))))) / t_2;
} else {
tmp = t_1 * -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 * (A * C));
double t_1 = Math.sqrt(2.0) / B;
double t_2 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 3.5e-97) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else if (B <= 3.6e-55) {
tmp = t_1 * -Math.sqrt((-0.5 * ((Math.pow(B, 2.0) * F) / C)));
} else if (B <= 7.5e-12) {
tmp = -Math.sqrt((2.0 * (t_2 * (F * (A + A))))) / t_2;
} else {
tmp = t_1 * -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 * (A * C)) t_1 = math.sqrt(2.0) / B t_2 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 3.5e-97: tmp = -math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0 elif B <= 3.6e-55: tmp = t_1 * -math.sqrt((-0.5 * ((math.pow(B, 2.0) * F) / C))) elif B <= 7.5e-12: tmp = -math.sqrt((2.0 * (t_2 * (F * (A + A))))) / t_2 else: tmp = t_1 * -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(A * C))) t_1 = Float64(sqrt(2.0) / B) t_2 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 3.5e-97) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + A))))) / t_0); elseif (B <= 3.6e-55) tmp = Float64(t_1 * Float64(-sqrt(Float64(-0.5 * Float64(Float64((B ^ 2.0) * F) / C))))); elseif (B <= 7.5e-12) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_2 * Float64(F * Float64(A + A)))))) / t_2); else tmp = Float64(t_1 * 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 * (A * C));
t_1 = sqrt(2.0) / B;
t_2 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 3.5e-97)
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
elseif (B <= 3.6e-55)
tmp = t_1 * -sqrt((-0.5 * (((B ^ 2.0) * F) / C)));
elseif (B <= 7.5e-12)
tmp = -sqrt((2.0 * (t_2 * (F * (A + A))))) / t_2;
else
tmp = t_1 * -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[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision]}, Block[{t$95$2 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 3.5e-97], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 3.6e-55], N[(t$95$1 * (-N[Sqrt[N[(-0.5 * N[(N[(N[Power[B, 2.0], $MachinePrecision] * F), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[B, 7.5e-12], N[((-N[Sqrt[N[(2.0 * N[(t$95$2 * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision], N[(t$95$1 * (-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(A \cdot C\right)\\
t_1 := \frac{\sqrt{2}}{B}\\
t_2 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 3.5 \cdot 10^{-97}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 3.6 \cdot 10^{-55}:\\
\;\;\;\;t_1 \cdot \left(-\sqrt{-0.5 \cdot \frac{{B}^{2} \cdot F}{C}}\right)\\
\mathbf{elif}\;B \leq 7.5 \cdot 10^{-12}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_2 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_2}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}\right)\\
\end{array}
\end{array}
if B < 3.50000000000000019e-97Initial program 16.3%
Simplified16.3%
Taylor expanded in C around inf 17.0%
cancel-sign-sub-inv17.0%
metadata-eval17.0%
*-lft-identity17.0%
Simplified17.0%
if 3.50000000000000019e-97 < B < 3.6000000000000001e-55Initial program 16.1%
Simplified16.1%
Taylor expanded in A around 0 3.5%
mul-1-neg3.5%
distribute-rgt-neg-in3.5%
+-commutative3.5%
unpow23.5%
unpow23.5%
hypot-def4.0%
Simplified4.0%
Taylor expanded in C around inf 59.5%
if 3.6000000000000001e-55 < B < 7.5e-12Initial program 31.1%
Simplified31.1%
Taylor expanded in C around inf 45.0%
cancel-sign-sub-inv45.0%
metadata-eval45.0%
*-lft-identity45.0%
Simplified45.0%
distribute-frac-neg45.0%
associate-*l*45.0%
cancel-sign-sub-inv45.0%
metadata-eval45.0%
cancel-sign-sub-inv45.0%
metadata-eval45.0%
Applied egg-rr45.0%
if 7.5e-12 < B Initial program 18.0%
Simplified18.0%
Taylor expanded in C around 0 25.4%
mul-1-neg25.4%
distribute-rgt-neg-in25.4%
unpow225.4%
unpow225.4%
hypot-def46.1%
Simplified46.1%
Final simplification24.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 (fma B B (* A (* C -4.0)))))
(if (<= (pow B 2.0) 5e-23)
(/
(- (sqrt (* 2.0 (* t_0 (* F (+ A (+ A (* -0.5 (/ (* B B) (- C A))))))))))
t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A (hypot A B)))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (pow(B, 2.0) <= 5e-23) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + (A + (-0.5 * ((B * B) / (C - A))))))))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(A, B))));
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B ^ 2.0) <= 5e-23) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + Float64(A + Float64(-0.5 * Float64(Float64(B * B) / Float64(C - A)))))))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - hypot(A, B)))))); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e-23], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + N[(A + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / N[(C - A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{-23}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + \left(A + -0.5 \cdot \frac{B \cdot B}{C - A}\right)\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 5.0000000000000002e-23Initial program 17.1%
Simplified27.5%
Taylor expanded in B around 0 24.6%
unpow224.6%
Simplified24.6%
if 5.0000000000000002e-23 < (pow.f64 B 2) Initial program 17.0%
Simplified17.0%
Taylor expanded in C around 0 12.4%
mul-1-neg12.4%
distribute-rgt-neg-in12.4%
unpow212.4%
unpow212.4%
hypot-def22.3%
Simplified22.3%
Final simplification23.6%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C))))
(t_1 (/ (sqrt 2.0) B))
(t_2 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 7.5e-97)
(/ (- (sqrt (* 2.0 (* (* F t_0) (+ A A))))) t_0)
(if (<= B 4.8e-55)
(* t_1 (- (sqrt (* F (* -0.5 (/ (* B B) C))))))
(if (<= B 7e-12)
(/ (- (sqrt (* 2.0 (* t_2 (* F (+ A A)))))) t_2)
(* t_1 (- (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 * (A * C));
double t_1 = sqrt(2.0) / B;
double t_2 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 7.5e-97) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else if (B <= 4.8e-55) {
tmp = t_1 * -sqrt((F * (-0.5 * ((B * B) / C))));
} else if (B <= 7e-12) {
tmp = -sqrt((2.0 * (t_2 * (F * (A + A))))) / t_2;
} else {
tmp = t_1 * -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 * (A * C));
double t_1 = Math.sqrt(2.0) / B;
double t_2 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 7.5e-97) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else if (B <= 4.8e-55) {
tmp = t_1 * -Math.sqrt((F * (-0.5 * ((B * B) / C))));
} else if (B <= 7e-12) {
tmp = -Math.sqrt((2.0 * (t_2 * (F * (A + A))))) / t_2;
} else {
tmp = t_1 * -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 * (A * C)) t_1 = math.sqrt(2.0) / B t_2 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 7.5e-97: tmp = -math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0 elif B <= 4.8e-55: tmp = t_1 * -math.sqrt((F * (-0.5 * ((B * B) / C)))) elif B <= 7e-12: tmp = -math.sqrt((2.0 * (t_2 * (F * (A + A))))) / t_2 else: tmp = t_1 * -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(A * C))) t_1 = Float64(sqrt(2.0) / B) t_2 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 7.5e-97) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + A))))) / t_0); elseif (B <= 4.8e-55) tmp = Float64(t_1 * Float64(-sqrt(Float64(F * Float64(-0.5 * Float64(Float64(B * B) / C)))))); elseif (B <= 7e-12) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_2 * Float64(F * Float64(A + A)))))) / t_2); else tmp = Float64(t_1 * 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 * (A * C));
t_1 = sqrt(2.0) / B;
t_2 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 7.5e-97)
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
elseif (B <= 4.8e-55)
tmp = t_1 * -sqrt((F * (-0.5 * ((B * B) / C))));
elseif (B <= 7e-12)
tmp = -sqrt((2.0 * (t_2 * (F * (A + A))))) / t_2;
else
tmp = t_1 * -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[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision]}, Block[{t$95$2 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 7.5e-97], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 4.8e-55], N[(t$95$1 * (-N[Sqrt[N[(F * N[(-0.5 * N[(N[(B * B), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[B, 7e-12], N[((-N[Sqrt[N[(2.0 * N[(t$95$2 * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision], N[(t$95$1 * (-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(A \cdot C\right)\\
t_1 := \frac{\sqrt{2}}{B}\\
t_2 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 7.5 \cdot 10^{-97}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 4.8 \cdot 10^{-55}:\\
\;\;\;\;t_1 \cdot \left(-\sqrt{F \cdot \left(-0.5 \cdot \frac{B \cdot B}{C}\right)}\right)\\
\mathbf{elif}\;B \leq 7 \cdot 10^{-12}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_2 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_2}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}\right)\\
\end{array}
\end{array}
if B < 7.5e-97Initial program 16.3%
Simplified16.3%
Taylor expanded in C around inf 17.0%
cancel-sign-sub-inv17.0%
metadata-eval17.0%
*-lft-identity17.0%
Simplified17.0%
if 7.5e-97 < B < 4.79999999999999983e-55Initial program 16.1%
Simplified16.1%
Taylor expanded in A around 0 3.5%
mul-1-neg3.5%
distribute-rgt-neg-in3.5%
+-commutative3.5%
unpow23.5%
unpow23.5%
hypot-def4.0%
Simplified4.0%
Taylor expanded in C around inf 59.0%
unpow259.0%
Simplified59.0%
if 4.79999999999999983e-55 < B < 7.0000000000000001e-12Initial program 31.1%
Simplified31.1%
Taylor expanded in C around inf 45.0%
cancel-sign-sub-inv45.0%
metadata-eval45.0%
*-lft-identity45.0%
Simplified45.0%
distribute-frac-neg45.0%
associate-*l*45.0%
cancel-sign-sub-inv45.0%
metadata-eval45.0%
cancel-sign-sub-inv45.0%
metadata-eval45.0%
Applied egg-rr45.0%
if 7.0000000000000001e-12 < B Initial program 18.0%
Simplified18.0%
Taylor expanded in C around 0 25.4%
mul-1-neg25.4%
distribute-rgt-neg-in25.4%
unpow225.4%
unpow225.4%
hypot-def46.1%
Simplified46.1%
Final simplification24.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 (* A C))))
(t_1 (/ (sqrt 2.0) B))
(t_2 (* t_1 (- (sqrt (* F (* -0.5 (/ (* B B) C)))))))
(t_3 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 5.5e-97)
(/ (- (sqrt (* 2.0 (* (* F t_0) (+ A A))))) t_0)
(if (<= B 3.8e-55)
t_2
(if (<= B 4.8e+26)
(/ (- (sqrt (* 2.0 (* t_3 (* F (+ A (- C (hypot B (- A C))))))))) t_3)
(if (<= B 4.8e+122) t_2 (* t_1 (- (sqrt (* F (- C B)))))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = sqrt(2.0) / B;
double t_2 = t_1 * -sqrt((F * (-0.5 * ((B * B) / C))));
double t_3 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 5.5e-97) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else if (B <= 3.8e-55) {
tmp = t_2;
} else if (B <= 4.8e+26) {
tmp = -sqrt((2.0 * (t_3 * (F * (A + (C - hypot(B, (A - C)))))))) / t_3;
} else if (B <= 4.8e+122) {
tmp = t_2;
} else {
tmp = t_1 * -sqrt((F * (C - B)));
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = Math.sqrt(2.0) / B;
double t_2 = t_1 * -Math.sqrt((F * (-0.5 * ((B * B) / C))));
double t_3 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 5.5e-97) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else if (B <= 3.8e-55) {
tmp = t_2;
} else if (B <= 4.8e+26) {
tmp = -Math.sqrt((2.0 * (t_3 * (F * (A + (C - Math.hypot(B, (A - C)))))))) / t_3;
} else if (B <= 4.8e+122) {
tmp = t_2;
} else {
tmp = t_1 * -Math.sqrt((F * (C - B)));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = math.sqrt(2.0) / B t_2 = t_1 * -math.sqrt((F * (-0.5 * ((B * B) / C)))) t_3 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 5.5e-97: tmp = -math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0 elif B <= 3.8e-55: tmp = t_2 elif B <= 4.8e+26: tmp = -math.sqrt((2.0 * (t_3 * (F * (A + (C - math.hypot(B, (A - C)))))))) / t_3 elif B <= 4.8e+122: tmp = t_2 else: tmp = t_1 * -math.sqrt((F * (C - B))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64(sqrt(2.0) / B) t_2 = Float64(t_1 * Float64(-sqrt(Float64(F * Float64(-0.5 * Float64(Float64(B * B) / C)))))) t_3 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 5.5e-97) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + A))))) / t_0); elseif (B <= 3.8e-55) tmp = t_2; elseif (B <= 4.8e+26) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_3 * Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C))))))))) / t_3); elseif (B <= 4.8e+122) tmp = t_2; else tmp = Float64(t_1 * Float64(-sqrt(Float64(F * Float64(C - B))))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
t_1 = sqrt(2.0) / B;
t_2 = t_1 * -sqrt((F * (-0.5 * ((B * B) / C))));
t_3 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 5.5e-97)
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
elseif (B <= 3.8e-55)
tmp = t_2;
elseif (B <= 4.8e+26)
tmp = -sqrt((2.0 * (t_3 * (F * (A + (C - hypot(B, (A - C)))))))) / t_3;
elseif (B <= 4.8e+122)
tmp = t_2;
else
tmp = t_1 * -sqrt((F * (C - B)));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * (-N[Sqrt[N[(F * N[(-0.5 * N[(N[(B * B), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]}, Block[{t$95$3 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 5.5e-97], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 3.8e-55], t$95$2, If[LessEqual[B, 4.8e+26], N[((-N[Sqrt[N[(2.0 * N[(t$95$3 * N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$3), $MachinePrecision], If[LessEqual[B, 4.8e+122], t$95$2, N[(t$95$1 * (-N[Sqrt[N[(F * N[(C - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := \frac{\sqrt{2}}{B}\\
t_2 := t_1 \cdot \left(-\sqrt{F \cdot \left(-0.5 \cdot \frac{B \cdot B}{C}\right)}\right)\\
t_3 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 5.5 \cdot 10^{-97}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 3.8 \cdot 10^{-55}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;B \leq 4.8 \cdot 10^{+26}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_3 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}}{t_3}\\
\mathbf{elif}\;B \leq 4.8 \cdot 10^{+122}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(-\sqrt{F \cdot \left(C - B\right)}\right)\\
\end{array}
\end{array}
if B < 5.49999999999999948e-97Initial program 16.3%
Simplified16.3%
Taylor expanded in C around inf 17.0%
cancel-sign-sub-inv17.0%
metadata-eval17.0%
*-lft-identity17.0%
Simplified17.0%
if 5.49999999999999948e-97 < B < 3.7999999999999997e-55 or 4.80000000000000009e26 < B < 4.8000000000000004e122Initial program 25.3%
Simplified25.3%
Taylor expanded in A around 0 26.9%
mul-1-neg26.9%
distribute-rgt-neg-in26.9%
+-commutative26.9%
unpow226.9%
unpow226.9%
hypot-def27.3%
Simplified27.3%
Taylor expanded in C around inf 25.2%
unpow225.2%
Simplified25.2%
if 3.7999999999999997e-55 < B < 4.80000000000000009e26Initial program 35.0%
Simplified35.0%
add-cbrt-cube34.3%
add-sqr-sqrt34.3%
fma-def34.3%
fma-def34.3%
Applied egg-rr34.3%
rem-square-sqrt34.3%
unpow334.3%
fma-udef34.3%
unpow234.3%
hypot-def34.3%
Simplified34.3%
distribute-frac-neg34.3%
Applied egg-rr44.7%
if 4.8000000000000004e122 < B Initial program 7.4%
Simplified7.4%
Taylor expanded in A around 0 26.0%
mul-1-neg26.0%
distribute-rgt-neg-in26.0%
+-commutative26.0%
unpow226.0%
unpow226.0%
hypot-def56.3%
Simplified56.3%
Taylor expanded in C around 0 56.0%
mul-1-neg56.0%
unsub-neg56.0%
Simplified56.0%
Final simplification23.5%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C))))
(t_1 (/ (sqrt 2.0) B))
(t_2 (* t_1 (- (sqrt (* F (* -0.5 (/ (* B B) C)))))))
(t_3 (* F t_0)))
(if (<= B 6.6e-97)
(/ (- (sqrt (* 2.0 (* t_3 (+ A A))))) t_0)
(if (<= B 3.6e-55)
t_2
(if (<= B 8.2e+26)
(/ (- (sqrt (* 2.0 (* (- A (hypot A B)) t_3)))) t_0)
(if (<= B 4.5e+122) t_2 (* t_1 (- (sqrt (* F (- C B)))))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = sqrt(2.0) / B;
double t_2 = t_1 * -sqrt((F * (-0.5 * ((B * B) / C))));
double t_3 = F * t_0;
double tmp;
if (B <= 6.6e-97) {
tmp = -sqrt((2.0 * (t_3 * (A + A)))) / t_0;
} else if (B <= 3.6e-55) {
tmp = t_2;
} else if (B <= 8.2e+26) {
tmp = -sqrt((2.0 * ((A - hypot(A, B)) * t_3))) / t_0;
} else if (B <= 4.5e+122) {
tmp = t_2;
} else {
tmp = t_1 * -sqrt((F * (C - B)));
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = Math.sqrt(2.0) / B;
double t_2 = t_1 * -Math.sqrt((F * (-0.5 * ((B * B) / C))));
double t_3 = F * t_0;
double tmp;
if (B <= 6.6e-97) {
tmp = -Math.sqrt((2.0 * (t_3 * (A + A)))) / t_0;
} else if (B <= 3.6e-55) {
tmp = t_2;
} else if (B <= 8.2e+26) {
tmp = -Math.sqrt((2.0 * ((A - Math.hypot(A, B)) * t_3))) / t_0;
} else if (B <= 4.5e+122) {
tmp = t_2;
} else {
tmp = t_1 * -Math.sqrt((F * (C - B)));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = math.sqrt(2.0) / B t_2 = t_1 * -math.sqrt((F * (-0.5 * ((B * B) / C)))) t_3 = F * t_0 tmp = 0 if B <= 6.6e-97: tmp = -math.sqrt((2.0 * (t_3 * (A + A)))) / t_0 elif B <= 3.6e-55: tmp = t_2 elif B <= 8.2e+26: tmp = -math.sqrt((2.0 * ((A - math.hypot(A, B)) * t_3))) / t_0 elif B <= 4.5e+122: tmp = t_2 else: tmp = t_1 * -math.sqrt((F * (C - B))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64(sqrt(2.0) / B) t_2 = Float64(t_1 * Float64(-sqrt(Float64(F * Float64(-0.5 * Float64(Float64(B * B) / C)))))) t_3 = Float64(F * t_0) tmp = 0.0 if (B <= 6.6e-97) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_3 * Float64(A + A))))) / t_0); elseif (B <= 3.6e-55) tmp = t_2; elseif (B <= 8.2e+26) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(A - hypot(A, B)) * t_3)))) / t_0); elseif (B <= 4.5e+122) tmp = t_2; else tmp = Float64(t_1 * Float64(-sqrt(Float64(F * Float64(C - B))))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
t_1 = sqrt(2.0) / B;
t_2 = t_1 * -sqrt((F * (-0.5 * ((B * B) / C))));
t_3 = F * t_0;
tmp = 0.0;
if (B <= 6.6e-97)
tmp = -sqrt((2.0 * (t_3 * (A + A)))) / t_0;
elseif (B <= 3.6e-55)
tmp = t_2;
elseif (B <= 8.2e+26)
tmp = -sqrt((2.0 * ((A - hypot(A, B)) * t_3))) / t_0;
elseif (B <= 4.5e+122)
tmp = t_2;
else
tmp = t_1 * -sqrt((F * (C - B)));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * (-N[Sqrt[N[(F * N[(-0.5 * N[(N[(B * B), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]}, Block[{t$95$3 = N[(F * t$95$0), $MachinePrecision]}, If[LessEqual[B, 6.6e-97], N[((-N[Sqrt[N[(2.0 * N[(t$95$3 * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 3.6e-55], t$95$2, If[LessEqual[B, 8.2e+26], N[((-N[Sqrt[N[(2.0 * N[(N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 4.5e+122], t$95$2, N[(t$95$1 * (-N[Sqrt[N[(F * N[(C - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := \frac{\sqrt{2}}{B}\\
t_2 := t_1 \cdot \left(-\sqrt{F \cdot \left(-0.5 \cdot \frac{B \cdot B}{C}\right)}\right)\\
t_3 := F \cdot t_0\\
\mathbf{if}\;B \leq 6.6 \cdot 10^{-97}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_3 \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 3.6 \cdot 10^{-55}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;B \leq 8.2 \cdot 10^{+26}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(A - \mathsf{hypot}\left(A, B\right)\right) \cdot t_3\right)}}{t_0}\\
\mathbf{elif}\;B \leq 4.5 \cdot 10^{+122}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(-\sqrt{F \cdot \left(C - B\right)}\right)\\
\end{array}
\end{array}
if B < 6.6000000000000002e-97Initial program 16.3%
Simplified16.3%
Taylor expanded in C around inf 17.0%
cancel-sign-sub-inv17.0%
metadata-eval17.0%
*-lft-identity17.0%
Simplified17.0%
if 6.6000000000000002e-97 < B < 3.6000000000000001e-55 or 8.19999999999999967e26 < B < 4.49999999999999997e122Initial program 25.3%
Simplified25.3%
Taylor expanded in A around 0 26.9%
mul-1-neg26.9%
distribute-rgt-neg-in26.9%
+-commutative26.9%
unpow226.9%
unpow226.9%
hypot-def27.3%
Simplified27.3%
Taylor expanded in C around inf 25.2%
unpow225.2%
Simplified25.2%
if 3.6000000000000001e-55 < B < 8.19999999999999967e26Initial program 35.0%
Simplified35.0%
Taylor expanded in C around 0 28.2%
unpow228.2%
unpow228.2%
hypot-def36.5%
Simplified36.5%
if 4.49999999999999997e122 < B Initial program 7.4%
Simplified7.4%
Taylor expanded in A around 0 26.0%
mul-1-neg26.0%
distribute-rgt-neg-in26.0%
+-commutative26.0%
unpow226.0%
unpow226.0%
hypot-def56.3%
Simplified56.3%
Taylor expanded in C around 0 56.0%
mul-1-neg56.0%
unsub-neg56.0%
Simplified56.0%
Final simplification23.2%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C))))
(t_1 (/ (- (sqrt (* 2.0 (* (* F t_0) (+ A A))))) t_0))
(t_2 (/ (sqrt 2.0) B))
(t_3 (* t_2 (- (sqrt (* F (* -0.5 (/ (* B B) C))))))))
(if (<= B 2.5e-97)
t_1
(if (<= B 5e-55)
t_3
(if (<= B 1.48e+26)
t_1
(if (<= B 4.5e+122) t_3 (* t_2 (- (sqrt (* F (- C B)))))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
double t_2 = sqrt(2.0) / B;
double t_3 = t_2 * -sqrt((F * (-0.5 * ((B * B) / C))));
double tmp;
if (B <= 2.5e-97) {
tmp = t_1;
} else if (B <= 5e-55) {
tmp = t_3;
} else if (B <= 1.48e+26) {
tmp = t_1;
} else if (B <= 4.5e+122) {
tmp = t_3;
} else {
tmp = t_2 * -sqrt((F * (C - B)));
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (a * c))
t_1 = -sqrt((2.0d0 * ((f * t_0) * (a + a)))) / t_0
t_2 = sqrt(2.0d0) / b
t_3 = t_2 * -sqrt((f * ((-0.5d0) * ((b * b) / c))))
if (b <= 2.5d-97) then
tmp = t_1
else if (b <= 5d-55) then
tmp = t_3
else if (b <= 1.48d+26) then
tmp = t_1
else if (b <= 4.5d+122) then
tmp = t_3
else
tmp = t_2 * -sqrt((f * (c - b)))
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = -Math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
double t_2 = Math.sqrt(2.0) / B;
double t_3 = t_2 * -Math.sqrt((F * (-0.5 * ((B * B) / C))));
double tmp;
if (B <= 2.5e-97) {
tmp = t_1;
} else if (B <= 5e-55) {
tmp = t_3;
} else if (B <= 1.48e+26) {
tmp = t_1;
} else if (B <= 4.5e+122) {
tmp = t_3;
} else {
tmp = t_2 * -Math.sqrt((F * (C - B)));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = -math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0 t_2 = math.sqrt(2.0) / B t_3 = t_2 * -math.sqrt((F * (-0.5 * ((B * B) / C)))) tmp = 0 if B <= 2.5e-97: tmp = t_1 elif B <= 5e-55: tmp = t_3 elif B <= 1.48e+26: tmp = t_1 elif B <= 4.5e+122: tmp = t_3 else: tmp = t_2 * -math.sqrt((F * (C - B))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + A))))) / t_0) t_2 = Float64(sqrt(2.0) / B) t_3 = Float64(t_2 * Float64(-sqrt(Float64(F * Float64(-0.5 * Float64(Float64(B * B) / C)))))) tmp = 0.0 if (B <= 2.5e-97) tmp = t_1; elseif (B <= 5e-55) tmp = t_3; elseif (B <= 1.48e+26) tmp = t_1; elseif (B <= 4.5e+122) tmp = t_3; else tmp = Float64(t_2 * Float64(-sqrt(Float64(F * Float64(C - B))))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
t_1 = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
t_2 = sqrt(2.0) / B;
t_3 = t_2 * -sqrt((F * (-0.5 * ((B * B) / C))));
tmp = 0.0;
if (B <= 2.5e-97)
tmp = t_1;
elseif (B <= 5e-55)
tmp = t_3;
elseif (B <= 1.48e+26)
tmp = t_1;
elseif (B <= 4.5e+122)
tmp = t_3;
else
tmp = t_2 * -sqrt((F * (C - B)));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * (-N[Sqrt[N[(F * N[(-0.5 * N[(N[(B * B), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[B, 2.5e-97], t$95$1, If[LessEqual[B, 5e-55], t$95$3, If[LessEqual[B, 1.48e+26], t$95$1, If[LessEqual[B, 4.5e+122], t$95$3, N[(t$95$2 * (-N[Sqrt[N[(F * N[(C - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := \frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + A\right)\right)}}{t_0}\\
t_2 := \frac{\sqrt{2}}{B}\\
t_3 := t_2 \cdot \left(-\sqrt{F \cdot \left(-0.5 \cdot \frac{B \cdot B}{C}\right)}\right)\\
\mathbf{if}\;B \leq 2.5 \cdot 10^{-97}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;B \leq 5 \cdot 10^{-55}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;B \leq 1.48 \cdot 10^{+26}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;B \leq 4.5 \cdot 10^{+122}:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;t_2 \cdot \left(-\sqrt{F \cdot \left(C - B\right)}\right)\\
\end{array}
\end{array}
if B < 2.4999999999999998e-97 or 5.0000000000000002e-55 < B < 1.48e26Initial program 17.4%
Simplified17.4%
Taylor expanded in C around inf 18.1%
cancel-sign-sub-inv18.1%
metadata-eval18.1%
*-lft-identity18.1%
Simplified18.1%
if 2.4999999999999998e-97 < B < 5.0000000000000002e-55 or 1.48e26 < B < 4.49999999999999997e122Initial program 25.3%
Simplified25.3%
Taylor expanded in A around 0 26.9%
mul-1-neg26.9%
distribute-rgt-neg-in26.9%
+-commutative26.9%
unpow226.9%
unpow226.9%
hypot-def27.3%
Simplified27.3%
Taylor expanded in C around inf 25.2%
unpow225.2%
Simplified25.2%
if 4.49999999999999997e122 < B Initial program 7.4%
Simplified7.4%
Taylor expanded in A around 0 26.0%
mul-1-neg26.0%
distribute-rgt-neg-in26.0%
+-commutative26.0%
unpow226.0%
unpow226.0%
hypot-def56.3%
Simplified56.3%
Taylor expanded in C around 0 56.0%
mul-1-neg56.0%
unsub-neg56.0%
Simplified56.0%
Final simplification23.1%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))) (t_1 (/ (sqrt 2.0) B)))
(if (<= B 3.1e+25)
(/ (- (sqrt (* 2.0 (* (* F t_0) (+ A A))))) t_0)
(if (<= B 1.05e+52)
(* t_1 (- (sqrt (* -0.5 (/ (* B B) (/ C F))))))
(* t_1 (- (sqrt (* B (- F)))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = sqrt(2.0) / B;
double tmp;
if (B <= 3.1e+25) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else if (B <= 1.05e+52) {
tmp = t_1 * -sqrt((-0.5 * ((B * B) / (C / F))));
} else {
tmp = t_1 * -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) :: t_1
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (a * c))
t_1 = sqrt(2.0d0) / b
if (b <= 3.1d+25) then
tmp = -sqrt((2.0d0 * ((f * t_0) * (a + a)))) / t_0
else if (b <= 1.05d+52) then
tmp = t_1 * -sqrt(((-0.5d0) * ((b * b) / (c / f))))
else
tmp = t_1 * -sqrt((b * -f))
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = Math.sqrt(2.0) / B;
double tmp;
if (B <= 3.1e+25) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else if (B <= 1.05e+52) {
tmp = t_1 * -Math.sqrt((-0.5 * ((B * B) / (C / F))));
} else {
tmp = t_1 * -Math.sqrt((B * -F));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = math.sqrt(2.0) / B tmp = 0 if B <= 3.1e+25: tmp = -math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0 elif B <= 1.05e+52: tmp = t_1 * -math.sqrt((-0.5 * ((B * B) / (C / F)))) else: tmp = t_1 * -math.sqrt((B * -F)) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64(sqrt(2.0) / B) tmp = 0.0 if (B <= 3.1e+25) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + A))))) / t_0); elseif (B <= 1.05e+52) tmp = Float64(t_1 * Float64(-sqrt(Float64(-0.5 * Float64(Float64(B * B) / Float64(C / F)))))); else tmp = Float64(t_1 * Float64(-sqrt(Float64(B * Float64(-F))))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
t_1 = sqrt(2.0) / B;
tmp = 0.0;
if (B <= 3.1e+25)
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
elseif (B <= 1.05e+52)
tmp = t_1 * -sqrt((-0.5 * ((B * B) / (C / F))));
else
tmp = t_1 * -sqrt((B * -F));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision]}, If[LessEqual[B, 3.1e+25], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 1.05e+52], N[(t$95$1 * (-N[Sqrt[N[(-0.5 * N[(N[(B * B), $MachinePrecision] / N[(C / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(t$95$1 * (-N[Sqrt[N[(B * (-F)), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := \frac{\sqrt{2}}{B}\\
\mathbf{if}\;B \leq 3.1 \cdot 10^{+25}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 1.05 \cdot 10^{+52}:\\
\;\;\;\;t_1 \cdot \left(-\sqrt{-0.5 \cdot \frac{B \cdot B}{\frac{C}{F}}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(-\sqrt{B \cdot \left(-F\right)}\right)\\
\end{array}
\end{array}
if B < 3.0999999999999998e25Initial program 17.4%
Simplified17.4%
Taylor expanded in C around inf 18.0%
cancel-sign-sub-inv18.0%
metadata-eval18.0%
*-lft-identity18.0%
Simplified18.0%
if 3.0999999999999998e25 < B < 1.05e52Initial program 0.0%
Simplified0.0%
Taylor expanded in A around 0 2.8%
mul-1-neg2.8%
distribute-rgt-neg-in2.8%
+-commutative2.8%
unpow22.8%
unpow22.8%
hypot-def3.5%
Simplified3.5%
Taylor expanded in C around inf 2.8%
associate-/l*100.0%
unpow2100.0%
Simplified100.0%
if 1.05e52 < B Initial program 16.0%
Simplified16.0%
Taylor expanded in A around 0 30.4%
mul-1-neg30.4%
distribute-rgt-neg-in30.4%
+-commutative30.4%
unpow230.4%
unpow230.4%
hypot-def49.6%
Simplified49.6%
Taylor expanded in C around 0 45.3%
associate-*r*45.3%
mul-1-neg45.3%
Simplified45.3%
Final simplification23.2%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 7e-12)
(/ (- (sqrt (* 2.0 (* (* F t_0) (+ A A))))) t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* B (- F))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 7e-12) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((B * -F));
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (a * c))
if (b <= 7d-12) then
tmp = -sqrt((2.0d0 * ((f * t_0) * (a + a)))) / t_0
else
tmp = (sqrt(2.0d0) / b) * -sqrt((b * -f))
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 7e-12) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((B * -F));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) tmp = 0 if B <= 7e-12: tmp = -math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((B * -F)) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= 7e-12) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + A))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(B * Float64(-F))))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
tmp = 0.0;
if (B <= 7e-12)
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
else
tmp = (sqrt(2.0) / B) * -sqrt((B * -F));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 7e-12], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(B * (-F)), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 7 \cdot 10^{-12}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + A\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.0000000000000001e-12Initial program 16.8%
Simplified16.8%
Taylor expanded in C around inf 17.9%
cancel-sign-sub-inv17.9%
metadata-eval17.9%
*-lft-identity17.9%
Simplified17.9%
if 7.0000000000000001e-12 < B Initial program 18.0%
Simplified18.0%
Taylor expanded in A around 0 31.0%
mul-1-neg31.0%
distribute-rgt-neg-in31.0%
+-commutative31.0%
unpow231.0%
unpow231.0%
hypot-def48.1%
Simplified48.1%
Taylor expanded in C around 0 42.6%
associate-*r*42.6%
mul-1-neg42.6%
Simplified42.6%
Final simplification22.9%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 3.5e+99)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A A)))))) t_0)
(* -2.0 (/ (pow (* A F) 0.5) B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 3.5e+99) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
} else {
tmp = -2.0 * (pow((A * F), 0.5) / B);
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = (b * b) + ((-4.0d0) * (a * c))
if (b <= 3.5d+99) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (a + a))))) / t_0
else
tmp = (-2.0d0) * (((a * f) ** 0.5d0) / b)
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 3.5e+99) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
} else {
tmp = -2.0 * (Math.pow((A * F), 0.5) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 3.5e+99: tmp = -math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0 else: tmp = -2.0 * (math.pow((A * F), 0.5) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 3.5e+99) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + A)))))) / t_0); else tmp = Float64(-2.0 * Float64((Float64(A * F) ^ 0.5) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 3.5e+99)
tmp = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
else
tmp = -2.0 * (((A * F) ^ 0.5) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 3.5e+99], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-2.0 * N[(N[Power[N[(A * F), $MachinePrecision], 0.5], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 3.5 \cdot 10^{+99}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{{\left(A \cdot F\right)}^{0.5}}{B}\\
\end{array}
\end{array}
if B < 3.4999999999999998e99Initial program 17.8%
Simplified17.8%
Taylor expanded in C around inf 17.4%
cancel-sign-sub-inv17.4%
metadata-eval17.4%
*-lft-identity17.4%
Simplified17.4%
distribute-frac-neg17.4%
associate-*l*16.7%
cancel-sign-sub-inv16.7%
metadata-eval16.7%
cancel-sign-sub-inv16.7%
metadata-eval16.7%
Applied egg-rr16.7%
if 3.4999999999999998e99 < B Initial program 12.3%
Simplified12.3%
Taylor expanded in C around inf 0.8%
cancel-sign-sub-inv0.8%
metadata-eval0.8%
*-lft-identity0.8%
Simplified0.8%
Taylor expanded in B around inf 9.2%
associate-*r/9.2%
*-rgt-identity9.2%
Simplified9.2%
pow1/29.3%
Applied egg-rr9.3%
Final simplification15.7%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 2.2e+99)
(/ (- (sqrt (* 2.0 (* (* F t_0) (+ A A))))) t_0)
(* -2.0 (/ (pow (* A F) 0.5) B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 2.2e+99) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else {
tmp = -2.0 * (pow((A * F), 0.5) / B);
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (a * c))
if (b <= 2.2d+99) then
tmp = -sqrt((2.0d0 * ((f * t_0) * (a + a)))) / t_0
else
tmp = (-2.0d0) * (((a * f) ** 0.5d0) / b)
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 2.2e+99) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else {
tmp = -2.0 * (Math.pow((A * F), 0.5) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) tmp = 0 if B <= 2.2e+99: tmp = -math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0 else: tmp = -2.0 * (math.pow((A * F), 0.5) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= 2.2e+99) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + A))))) / t_0); else tmp = Float64(-2.0 * Float64((Float64(A * F) ^ 0.5) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
tmp = 0.0;
if (B <= 2.2e+99)
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
else
tmp = -2.0 * (((A * F) ^ 0.5) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 2.2e+99], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-2.0 * N[(N[Power[N[(A * F), $MachinePrecision], 0.5], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 2.2 \cdot 10^{+99}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{{\left(A \cdot F\right)}^{0.5}}{B}\\
\end{array}
\end{array}
if B < 2.19999999999999978e99Initial program 17.8%
Simplified17.8%
Taylor expanded in C around inf 17.4%
cancel-sign-sub-inv17.4%
metadata-eval17.4%
*-lft-identity17.4%
Simplified17.4%
if 2.19999999999999978e99 < B Initial program 12.3%
Simplified12.3%
Taylor expanded in C around inf 0.8%
cancel-sign-sub-inv0.8%
metadata-eval0.8%
*-lft-identity0.8%
Simplified0.8%
Taylor expanded in B around inf 9.2%
associate-*r/9.2%
*-rgt-identity9.2%
Simplified9.2%
pow1/29.3%
Applied egg-rr9.3%
Final simplification16.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 3.5e+16)
(/
(- (sqrt (* 2.0 (* (+ A A) (* -4.0 (* A (* C F)))))))
(- (* B B) (* 4.0 (* A C))))
(* -2.0 (/ (pow (* A F) 0.5) B))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 3.5e+16) {
tmp = -sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = -2.0 * (pow((A * F), 0.5) / 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 <= 3.5d+16) then
tmp = -sqrt((2.0d0 * ((a + a) * ((-4.0d0) * (a * (c * f)))))) / ((b * b) - (4.0d0 * (a * c)))
else
tmp = (-2.0d0) * (((a * f) ** 0.5d0) / 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 <= 3.5e+16) {
tmp = -Math.sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = -2.0 * (Math.pow((A * F), 0.5) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= 3.5e+16: tmp = -math.sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C))) else: tmp = -2.0 * (math.pow((A * F), 0.5) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 3.5e+16) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(A + A) * Float64(-4.0 * Float64(A * Float64(C * F))))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(-2.0 * Float64((Float64(A * F) ^ 0.5) / 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 <= 3.5e+16)
tmp = -sqrt((2.0 * ((A + A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C)));
else
tmp = -2.0 * (((A * F) ^ 0.5) / 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, 3.5e+16], N[((-N[Sqrt[N[(2.0 * N[(N[(A + A), $MachinePrecision] * N[(-4.0 * N[(A * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Power[N[(A * F), $MachinePrecision], 0.5], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 3.5 \cdot 10^{+16}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(A + A\right) \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{{\left(A \cdot F\right)}^{0.5}}{B}\\
\end{array}
\end{array}
if B < 3.5e16Initial program 16.6%
Simplified16.6%
Taylor expanded in C around inf 18.1%
cancel-sign-sub-inv18.1%
metadata-eval18.1%
*-lft-identity18.1%
Simplified18.1%
Taylor expanded in B around 0 13.0%
if 3.5e16 < B Initial program 19.1%
Simplified19.1%
Taylor expanded in C around inf 2.9%
cancel-sign-sub-inv2.9%
metadata-eval2.9%
*-lft-identity2.9%
Simplified2.9%
Taylor expanded in B around inf 7.0%
associate-*r/7.0%
*-rgt-identity7.0%
Simplified7.0%
pow1/27.3%
Applied egg-rr7.3%
Final simplification11.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 (/ (pow (* A F) 0.5) B)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (pow((A * F), 0.5) / 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) * (((a * f) ** 0.5d0) / 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((A * F), 0.5) / B);
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.pow((A * F), 0.5) / B)
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64((Float64(A * F) ^ 0.5) / B)) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (((A * F) ^ 0.5) / 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[(A * F), $MachinePrecision], 0.5], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \frac{{\left(A \cdot F\right)}^{0.5}}{B}
\end{array}
Initial program 17.0%
Simplified17.1%
Taylor expanded in C around inf 15.2%
cancel-sign-sub-inv15.2%
metadata-eval15.2%
*-lft-identity15.2%
Simplified15.2%
Taylor expanded in B around inf 2.8%
associate-*r/2.8%
*-rgt-identity2.8%
Simplified2.8%
pow1/23.0%
Applied egg-rr3.0%
Final simplification3.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 (* -2.0 (/ (sqrt (* A F)) B)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (sqrt((A * F)) / B);
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (-2.0d0) * (sqrt((a * f)) / b)
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return -2.0 * (Math.sqrt((A * F)) / B);
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.sqrt((A * F)) / B)
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (sqrt((A * F)) / B);
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \frac{\sqrt{A \cdot F}}{B}
\end{array}
Initial program 17.0%
Simplified17.1%
Taylor expanded in C around inf 15.2%
cancel-sign-sub-inv15.2%
metadata-eval15.2%
*-lft-identity15.2%
Simplified15.2%
Taylor expanded in B around inf 2.8%
associate-*r/2.8%
*-rgt-identity2.8%
Simplified2.8%
Final simplification2.8%
herbie shell --seed 2023299
(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))))