
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 20500000000.0)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(/ (* (sqrt 2.0) (- (sqrt (* F (- A (hypot A B)))))) B))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 20500000000.0) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = (sqrt(2.0) * -sqrt((F * (A - hypot(A, B))))) / B;
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 20500000000.0) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = (Math.sqrt(2.0) * -Math.sqrt((F * (A - Math.hypot(A, B))))) / B;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 20500000000.0: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = (math.sqrt(2.0) * -math.sqrt((F * (A - math.hypot(A, B))))) / B return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 20500000000.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(A - hypot(A, B)))))) / B); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 20500000000.0)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = (sqrt(2.0) * -sqrt((F * (A - hypot(A, B))))) / B;
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 20500000000.0], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / B), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 20500000000:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}\right)}{B}\\
\end{array}
\end{array}
if B < 2.05e10Initial program 17.3%
Simplified17.3%
Taylor expanded in A around -inf 15.1%
*-commutative15.1%
Simplified15.1%
distribute-frac-neg15.1%
associate-*l*14.6%
cancel-sign-sub-inv14.6%
metadata-eval14.6%
cancel-sign-sub-inv14.6%
metadata-eval14.6%
Applied egg-rr14.6%
if 2.05e10 < B Initial program 20.4%
Simplified20.4%
Taylor expanded in C around 0 23.9%
mul-1-neg23.9%
*-commutative23.9%
+-commutative23.9%
unpow223.9%
unpow223.9%
hypot-def50.6%
Simplified50.6%
associate-*l/50.7%
Applied egg-rr50.7%
Final simplification22.4%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 30500000000.0)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(* (sqrt (* F (- A (hypot A B)))) (/ (- (sqrt 2.0)) B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 30500000000.0) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = sqrt((F * (A - hypot(A, B)))) * (-sqrt(2.0) / B);
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 30500000000.0) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = Math.sqrt((F * (A - Math.hypot(A, B)))) * (-Math.sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 30500000000.0: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = math.sqrt((F * (A - math.hypot(A, B)))) * (-math.sqrt(2.0) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 30500000000.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(A, B)))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 30500000000.0)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = sqrt((F * (A - hypot(A, B)))) * (-sqrt(2.0) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 30500000000.0], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 30500000000:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 3.05e10Initial program 17.3%
Simplified17.3%
Taylor expanded in A around -inf 15.1%
*-commutative15.1%
Simplified15.1%
distribute-frac-neg15.1%
associate-*l*14.6%
cancel-sign-sub-inv14.6%
metadata-eval14.6%
cancel-sign-sub-inv14.6%
metadata-eval14.6%
Applied egg-rr14.6%
if 3.05e10 < B Initial program 20.4%
Simplified20.4%
Taylor expanded in C around 0 23.9%
mul-1-neg23.9%
*-commutative23.9%
+-commutative23.9%
unpow223.9%
unpow223.9%
hypot-def50.6%
Simplified50.6%
Final simplification22.3%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 3.5e+40)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(* (sqrt (* F (- A B))) (/ (- (sqrt 2.0)) B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 3.5e+40) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = sqrt((F * (A - B))) * (-sqrt(2.0) / B);
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = (b * b) + ((-4.0d0) * (a * c))
if (b <= 3.5d+40) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (2.0d0 * a))))) / t_0
else
tmp = sqrt((f * (a - b))) * (-sqrt(2.0d0) / b)
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 3.5e+40) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = Math.sqrt((F * (A - B))) * (-Math.sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 3.5e+40: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = math.sqrt((F * (A - B))) * (-math.sqrt(2.0) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 3.5e+40) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(A - B))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 3.5e+40)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = sqrt((F * (A - B))) * (-sqrt(2.0) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 3.5e+40], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 3.5 \cdot 10^{+40}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - B\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 3.4999999999999999e40Initial program 17.4%
Simplified17.4%
Taylor expanded in A around -inf 15.3%
*-commutative15.3%
Simplified15.3%
distribute-frac-neg15.3%
associate-*l*14.8%
cancel-sign-sub-inv14.8%
metadata-eval14.8%
cancel-sign-sub-inv14.8%
metadata-eval14.8%
Applied egg-rr14.8%
if 3.4999999999999999e40 < B Initial program 20.1%
Simplified20.1%
Taylor expanded in C around 0 23.6%
mul-1-neg23.6%
*-commutative23.6%
+-commutative23.6%
unpow223.6%
unpow223.6%
hypot-def52.3%
Simplified52.3%
Taylor expanded in A around 0 50.4%
mul-1-neg50.4%
unsub-neg50.4%
Simplified50.4%
Final simplification21.9%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 1.15e+41)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) 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 * (A * C));
double tmp;
if (B <= 1.15e+41) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / 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) :: tmp
t_0 = (b * b) + ((-4.0d0) * (a * c))
if (b <= 1.15d+41) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (2.0d0 * a))))) / 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 * (A * C));
double tmp;
if (B <= 1.15e+41) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / 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 * (A * C)) tmp = 0 if B <= 1.15e+41: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / 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(A * C))) tmp = 0.0 if (B <= 1.15e+41) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / 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 * (A * C));
tmp = 0.0;
if (B <= 1.15e+41)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / 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[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 1.15e+41], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(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(A \cdot C\right)\\
\mathbf{if}\;B \leq 1.15 \cdot 10^{+41}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(-B\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 1.1499999999999999e41Initial program 17.4%
Simplified17.4%
Taylor expanded in A around -inf 15.3%
*-commutative15.3%
Simplified15.3%
distribute-frac-neg15.3%
associate-*l*14.8%
cancel-sign-sub-inv14.8%
metadata-eval14.8%
cancel-sign-sub-inv14.8%
metadata-eval14.8%
Applied egg-rr14.8%
if 1.1499999999999999e41 < B Initial program 20.1%
Simplified20.1%
Taylor expanded in C around 0 23.6%
mul-1-neg23.6%
*-commutative23.6%
+-commutative23.6%
unpow223.6%
unpow223.6%
hypot-def52.3%
Simplified52.3%
Taylor expanded in A around 0 50.6%
mul-1-neg50.6%
Simplified50.6%
Final simplification21.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) (* (* A C) 4.0))) (t_1 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 3.9e+43)
(/ (- (sqrt (* 2.0 (* t_1 (* F (* 2.0 A)))))) t_1)
(if (<= B 3.9e+144)
(-
(/
(sqrt (* 2.0 (* (* F t_0) (+ C (- (* -0.5 (/ (* C C) B)) B)))))
t_0))
(* -2.0 (* (sqrt (* A F)) (/ 1.0 B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((A * C) * 4.0);
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 3.9e+43) {
tmp = -sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1;
} else if (B <= 3.9e+144) {
tmp = -(sqrt((2.0 * ((F * t_0) * (C + ((-0.5 * ((C * C) / B)) - B))))) / t_0);
} else {
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (b * b) - ((a * c) * 4.0d0)
t_1 = (b * b) + ((-4.0d0) * (a * c))
if (b <= 3.9d+43) then
tmp = -sqrt((2.0d0 * (t_1 * (f * (2.0d0 * a))))) / t_1
else if (b <= 3.9d+144) then
tmp = -(sqrt((2.0d0 * ((f * t_0) * (c + (((-0.5d0) * ((c * c) / b)) - b))))) / t_0)
else
tmp = (-2.0d0) * (sqrt((a * f)) * (1.0d0 / b))
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((A * C) * 4.0);
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 3.9e+43) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1;
} else if (B <= 3.9e+144) {
tmp = -(Math.sqrt((2.0 * ((F * t_0) * (C + ((-0.5 * ((C * C) / B)) - B))))) / t_0);
} else {
tmp = -2.0 * (Math.sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - ((A * C) * 4.0) t_1 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 3.9e+43: tmp = -math.sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1 elif B <= 3.9e+144: tmp = -(math.sqrt((2.0 * ((F * t_0) * (C + ((-0.5 * ((C * C) / B)) - B))))) / t_0) else: tmp = -2.0 * (math.sqrt((A * F)) * (1.0 / B)) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(Float64(A * C) * 4.0)) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 3.9e+43) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(2.0 * A)))))) / t_1); elseif (B <= 3.9e+144) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(C + Float64(Float64(-0.5 * Float64(Float64(C * C) / B)) - B))))) / t_0)); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - ((A * C) * 4.0);
t_1 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 3.9e+43)
tmp = -sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1;
elseif (B <= 3.9e+144)
tmp = -(sqrt((2.0 * ((F * t_0) * (C + ((-0.5 * ((C * C) / B)) - B))))) / t_0);
else
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(N[(A * C), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 3.9e+43], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B, 3.9e+144], (-N[(N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(C + N[(N[(-0.5 * N[(N[(C * C), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision] - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - \left(A \cdot C\right) \cdot 4\\
t_1 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 3.9 \cdot 10^{+43}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;B \leq 3.9 \cdot 10^{+144}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(C + \left(-0.5 \cdot \frac{C \cdot C}{B} - B\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if B < 3.9000000000000001e43Initial program 17.4%
Simplified17.4%
Taylor expanded in A around -inf 15.3%
*-commutative15.3%
Simplified15.3%
distribute-frac-neg15.3%
associate-*l*14.8%
cancel-sign-sub-inv14.8%
metadata-eval14.8%
cancel-sign-sub-inv14.8%
metadata-eval14.8%
Applied egg-rr14.8%
if 3.9000000000000001e43 < B < 3.90000000000000018e144Initial program 53.8%
Simplified53.8%
Taylor expanded in A around 0 53.8%
+-commutative53.8%
unpow253.8%
unpow253.8%
hypot-def53.6%
Simplified53.6%
Taylor expanded in C around 0 49.2%
mul-1-neg49.2%
unsub-neg49.2%
unpow249.2%
Simplified49.2%
if 3.90000000000000018e144 < B Initial program 0.1%
Simplified0.1%
Taylor expanded in A around -inf 0.0%
*-commutative0.0%
Simplified0.0%
Taylor expanded in B around inf 5.6%
*-commutative5.6%
Simplified5.6%
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) (* (* A C) 4.0))) (t_1 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 9.5e+42)
(/ (- (sqrt (* 2.0 (* t_1 (* F (* 2.0 A)))))) t_1)
(if (<= B 1.25e+146)
(/ (- (sqrt (* 2.0 (* (* F t_0) (- (+ A C) B))))) t_0)
(* -2.0 (* (sqrt (* A F)) (/ 1.0 B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((A * C) * 4.0);
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 9.5e+42) {
tmp = -sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1;
} else if (B <= 1.25e+146) {
tmp = -sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / t_0;
} else {
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (b * b) - ((a * c) * 4.0d0)
t_1 = (b * b) + ((-4.0d0) * (a * c))
if (b <= 9.5d+42) then
tmp = -sqrt((2.0d0 * (t_1 * (f * (2.0d0 * a))))) / t_1
else if (b <= 1.25d+146) then
tmp = -sqrt((2.0d0 * ((f * t_0) * ((a + c) - b)))) / t_0
else
tmp = (-2.0d0) * (sqrt((a * f)) * (1.0d0 / b))
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((A * C) * 4.0);
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 9.5e+42) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1;
} else if (B <= 1.25e+146) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / t_0;
} else {
tmp = -2.0 * (Math.sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - ((A * C) * 4.0) t_1 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 9.5e+42: tmp = -math.sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1 elif B <= 1.25e+146: tmp = -math.sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / t_0 else: tmp = -2.0 * (math.sqrt((A * F)) * (1.0 / B)) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(Float64(A * C) * 4.0)) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 9.5e+42) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(2.0 * A)))))) / t_1); elseif (B <= 1.25e+146) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(Float64(A + C) - B))))) / t_0); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - ((A * C) * 4.0);
t_1 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 9.5e+42)
tmp = -sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1;
elseif (B <= 1.25e+146)
tmp = -sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / t_0;
else
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(N[(A * C), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 9.5e+42], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B, 1.25e+146], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - \left(A \cdot C\right) \cdot 4\\
t_1 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 9.5 \cdot 10^{+42}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;B \leq 1.25 \cdot 10^{+146}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(\left(A + C\right) - B\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if B < 9.50000000000000019e42Initial program 17.4%
Simplified17.4%
Taylor expanded in A around -inf 15.3%
*-commutative15.3%
Simplified15.3%
distribute-frac-neg15.3%
associate-*l*14.8%
cancel-sign-sub-inv14.8%
metadata-eval14.8%
cancel-sign-sub-inv14.8%
metadata-eval14.8%
Applied egg-rr14.8%
if 9.50000000000000019e42 < B < 1.25e146Initial program 53.8%
Simplified53.8%
Taylor expanded in B around inf 49.0%
if 1.25e146 < B Initial program 0.1%
Simplified0.1%
Taylor expanded in A around -inf 0.0%
*-commutative0.0%
Simplified0.0%
Taylor expanded in B around inf 5.6%
*-commutative5.6%
Simplified5.6%
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) (* (* A C) 4.0))) (t_1 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 9.5e+42)
(/ (- (sqrt (* 2.0 (* t_1 (* F (* 2.0 A)))))) t_1)
(if (<= B 1.1e+146)
(- (/ (sqrt (* 2.0 (* (* F t_0) (- C B)))) t_0))
(* -2.0 (* (sqrt (* A F)) (/ 1.0 B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((A * C) * 4.0);
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 9.5e+42) {
tmp = -sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1;
} else if (B <= 1.1e+146) {
tmp = -(sqrt((2.0 * ((F * t_0) * (C - B)))) / t_0);
} else {
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (b * b) - ((a * c) * 4.0d0)
t_1 = (b * b) + ((-4.0d0) * (a * c))
if (b <= 9.5d+42) then
tmp = -sqrt((2.0d0 * (t_1 * (f * (2.0d0 * a))))) / t_1
else if (b <= 1.1d+146) then
tmp = -(sqrt((2.0d0 * ((f * t_0) * (c - b)))) / t_0)
else
tmp = (-2.0d0) * (sqrt((a * f)) * (1.0d0 / b))
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((A * C) * 4.0);
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 9.5e+42) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1;
} else if (B <= 1.1e+146) {
tmp = -(Math.sqrt((2.0 * ((F * t_0) * (C - B)))) / t_0);
} else {
tmp = -2.0 * (Math.sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - ((A * C) * 4.0) t_1 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 9.5e+42: tmp = -math.sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1 elif B <= 1.1e+146: tmp = -(math.sqrt((2.0 * ((F * t_0) * (C - B)))) / t_0) else: tmp = -2.0 * (math.sqrt((A * F)) * (1.0 / B)) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(Float64(A * C) * 4.0)) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 9.5e+42) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(2.0 * A)))))) / t_1); elseif (B <= 1.1e+146) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(C - B)))) / t_0)); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - ((A * C) * 4.0);
t_1 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 9.5e+42)
tmp = -sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1;
elseif (B <= 1.1e+146)
tmp = -(sqrt((2.0 * ((F * t_0) * (C - B)))) / t_0);
else
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(N[(A * C), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 9.5e+42], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B, 1.1e+146], (-N[(N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(C - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - \left(A \cdot C\right) \cdot 4\\
t_1 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 9.5 \cdot 10^{+42}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;B \leq 1.1 \cdot 10^{+146}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(C - B\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if B < 9.50000000000000019e42Initial program 17.4%
Simplified17.4%
Taylor expanded in A around -inf 15.3%
*-commutative15.3%
Simplified15.3%
distribute-frac-neg15.3%
associate-*l*14.8%
cancel-sign-sub-inv14.8%
metadata-eval14.8%
cancel-sign-sub-inv14.8%
metadata-eval14.8%
Applied egg-rr14.8%
if 9.50000000000000019e42 < B < 1.0999999999999999e146Initial program 53.8%
Simplified53.8%
Taylor expanded in A around 0 53.8%
+-commutative53.8%
unpow253.8%
unpow253.8%
hypot-def53.6%
Simplified53.6%
Taylor expanded in C around 0 49.4%
mul-1-neg49.4%
unsub-neg49.4%
Simplified49.4%
if 1.0999999999999999e146 < B Initial program 0.1%
Simplified0.1%
Taylor expanded in A around -inf 0.0%
*-commutative0.0%
Simplified0.0%
Taylor expanded in B around inf 5.6%
*-commutative5.6%
Simplified5.6%
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 (* A C)))))
(if (<= B 3.2e+43)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(* -2.0 (* (sqrt (* A F)) (/ 1.0 B))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 3.2e+43) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = (b * b) + ((-4.0d0) * (a * c))
if (b <= 3.2d+43) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (2.0d0 * a))))) / t_0
else
tmp = (-2.0d0) * (sqrt((a * f)) * (1.0d0 / b))
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 3.2e+43) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -2.0 * (Math.sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 3.2e+43: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = -2.0 * (math.sqrt((A * F)) * (1.0 / B)) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 3.2e+43) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 3.2e+43)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 3.2e+43], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 3.2 \cdot 10^{+43}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if B < 3.20000000000000014e43Initial program 17.4%
Simplified17.4%
Taylor expanded in A around -inf 15.3%
*-commutative15.3%
Simplified15.3%
distribute-frac-neg15.3%
associate-*l*14.8%
cancel-sign-sub-inv14.8%
metadata-eval14.8%
cancel-sign-sub-inv14.8%
metadata-eval14.8%
Applied egg-rr14.8%
if 3.20000000000000014e43 < B Initial program 20.1%
Simplified20.1%
Taylor expanded in A around -inf 1.0%
*-commutative1.0%
Simplified1.0%
Taylor expanded in B around inf 4.6%
*-commutative4.6%
Simplified4.6%
Final simplification12.8%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 1.1e+58)
(/
(- (sqrt (* 2.0 (* (* 2.0 A) (* -4.0 (* A (* C F)))))))
(- (* B B) (* (* A C) 4.0)))
(* -2.0 (* (sqrt (* A F)) (/ 1.0 B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 1.1e+58) {
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((A * C) * 4.0));
} else {
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (b <= 1.1d+58) then
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * ((-4.0d0) * (a * (c * f)))))) / ((b * b) - ((a * c) * 4.0d0))
else
tmp = (-2.0d0) * (sqrt((a * f)) * (1.0d0 / b))
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= 1.1e+58) {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((A * C) * 4.0));
} else {
tmp = -2.0 * (Math.sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= 1.1e+58: tmp = -math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((A * C) * 4.0)) else: tmp = -2.0 * (math.sqrt((A * F)) * (1.0 / B)) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 1.1e+58) 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(Float64(A * C) * 4.0))); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (B <= 1.1e+58)
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((A * C) * 4.0));
else
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 1.1e+58], 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[(N[(A * C), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 1.1 \cdot 10^{+58}:\\
\;\;\;\;\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 - \left(A \cdot C\right) \cdot 4}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if B < 1.1e58Initial program 18.1%
Simplified18.1%
Taylor expanded in A around -inf 15.1%
*-commutative15.1%
Simplified15.1%
Taylor expanded in B around 0 11.7%
*-commutative11.7%
Simplified11.7%
if 1.1e58 < B Initial program 17.1%
Simplified17.1%
Taylor expanded in A around -inf 0.9%
*-commutative0.9%
Simplified0.9%
Taylor expanded in B around inf 4.8%
*-commutative4.8%
Simplified4.8%
Final simplification10.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 (<= A -3.3e+153)
(* -2.0 (* (sqrt (* A F)) (/ 1.0 B)))
(-
(/
(sqrt (* 2.0 (* -8.0 (* (* C F) (* A A)))))
(- (* B B) (* (* A C) 4.0))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (A <= -3.3e+153) {
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
} else {
tmp = -(sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - ((A * C) * 4.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) :: tmp
if (a <= (-3.3d+153)) then
tmp = (-2.0d0) * (sqrt((a * f)) * (1.0d0 / b))
else
tmp = -(sqrt((2.0d0 * ((-8.0d0) * ((c * f) * (a * a))))) / ((b * b) - ((a * c) * 4.0d0)))
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 <= -3.3e+153) {
tmp = -2.0 * (Math.sqrt((A * F)) * (1.0 / B));
} else {
tmp = -(Math.sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - ((A * C) * 4.0)));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if A <= -3.3e+153: tmp = -2.0 * (math.sqrt((A * F)) * (1.0 / B)) else: tmp = -(math.sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - ((A * C) * 4.0))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (A <= -3.3e+153) tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); else tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(-8.0 * Float64(Float64(C * F) * Float64(A * A))))) / Float64(Float64(B * B) - Float64(Float64(A * C) * 4.0)))); 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 <= -3.3e+153)
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
else
tmp = -(sqrt((2.0 * (-8.0 * ((C * F) * (A * A))))) / ((B * B) - ((A * C) * 4.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_] := If[LessEqual[A, -3.3e+153], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(N[Sqrt[N[(2.0 * N[(-8.0 * N[(N[(C * F), $MachinePrecision] * N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(B * B), $MachinePrecision] - N[(N[(A * C), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;A \leq -3.3 \cdot 10^{+153}:\\
\;\;\;\;-2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\mathbf{else}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(-8 \cdot \left(\left(C \cdot F\right) \cdot \left(A \cdot A\right)\right)\right)}}{B \cdot B - \left(A \cdot C\right) \cdot 4}\\
\end{array}
\end{array}
if A < -3.29999999999999994e153Initial program 0.9%
Simplified0.9%
Taylor expanded in A around -inf 10.9%
*-commutative10.9%
Simplified10.9%
Taylor expanded in B around inf 5.0%
*-commutative5.0%
Simplified5.0%
if -3.29999999999999994e153 < A Initial program 20.1%
Simplified20.1%
Taylor expanded in A around -inf 12.6%
*-commutative12.6%
Simplified12.6%
Taylor expanded in B around 0 9.9%
unpow29.9%
*-commutative9.9%
Simplified9.9%
Final simplification9.3%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* -2.0 (* (sqrt (* A F)) (/ 1.0 B))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (sqrt((A * F)) * (1.0 / B));
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (-2.0d0) * (sqrt((a * f)) * (1.0d0 / b))
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return -2.0 * (Math.sqrt((A * F)) * (1.0 / B));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.sqrt((A * F)) * (1.0 / B))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)
\end{array}
Initial program 18.0%
Simplified18.0%
Taylor expanded in A around -inf 12.4%
*-commutative12.4%
Simplified12.4%
Taylor expanded in B around inf 2.4%
*-commutative2.4%
Simplified2.4%
Final simplification2.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 (* -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 18.0%
Simplified18.0%
Taylor expanded in A around -inf 12.4%
*-commutative12.4%
Simplified12.4%
Taylor expanded in B around inf 2.4%
associate-*r/2.4%
*-rgt-identity2.4%
*-commutative2.4%
Simplified2.4%
Final simplification2.4%
herbie shell --seed 2023230
(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))))