
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* -4.0 C)))) (t_1 (+ (* B B) (* -4.0 (* A C)))))
(if (<= (pow B 2.0) 2e-163)
(/ (- (sqrt (* 2.0 (* t_1 (* F (* 2.0 A)))))) t_1)
(if (<= (pow B 2.0) 1e+272)
(/
(* (sqrt (* (+ A (- C (hypot (- A C) B))) (* 2.0 F))) (- (sqrt t_0)))
t_0)
(* (/ (sqrt 2.0) B) (* (sqrt (- F)) (- (sqrt B))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (-4.0 * C)));
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (pow(B, 2.0) <= 2e-163) {
tmp = -sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1;
} else if (pow(B, 2.0) <= 1e+272) {
tmp = (sqrt(((A + (C - hypot((A - C), B))) * (2.0 * F))) * -sqrt(t_0)) / t_0;
} else {
tmp = (sqrt(2.0) / B) * (sqrt(-F) * -sqrt(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(-4.0 * C))) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if ((B ^ 2.0) <= 2e-163) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(2.0 * A)))))) / t_1); elseif ((B ^ 2.0) <= 1e+272) tmp = Float64(Float64(sqrt(Float64(Float64(A + Float64(C - hypot(Float64(A - C), B))) * Float64(2.0 * F))) * Float64(-sqrt(t_0))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(sqrt(Float64(-F)) * Float64(-sqrt(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[(-4.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e-163], 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[N[Power[B, 2.0], $MachinePrecision], 1e+272], N[(N[(N[Sqrt[N[(N[(A + N[(C - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[t$95$0], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * N[(N[Sqrt[(-F)], $MachinePrecision] * (-N[Sqrt[B], $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(-4 \cdot C\right)\right)\\
t_1 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-163}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;{B}^{2} \leq 10^{+272}:\\
\;\;\;\;\frac{\sqrt{\left(A + \left(C - \mathsf{hypot}\left(A - C, B\right)\right)\right) \cdot \left(2 \cdot F\right)} \cdot \left(-\sqrt{t_0}\right)}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(\sqrt{-F} \cdot \left(-\sqrt{B}\right)\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 1.99999999999999985e-163Initial program 14.8%
Simplified14.8%
Taylor expanded in A around -inf 23.3%
distribute-frac-neg23.3%
associate-*l*25.3%
cancel-sign-sub-inv25.3%
metadata-eval25.3%
*-commutative25.3%
cancel-sign-sub-inv25.3%
metadata-eval25.3%
Applied egg-rr25.3%
if 1.99999999999999985e-163 < (pow.f64 B 2) < 1.0000000000000001e272Initial program 34.3%
Simplified39.9%
sqrt-prod53.2%
*-commutative53.2%
associate--r-53.1%
+-commutative53.1%
*-commutative53.1%
Applied egg-rr53.1%
hypot-def44.2%
unpow244.2%
unpow244.2%
+-commutative44.2%
unpow244.2%
unpow244.2%
hypot-def53.1%
Simplified53.1%
if 1.0000000000000001e272 < (pow.f64 B 2) Initial program 1.8%
Simplified1.8%
Taylor expanded in C around 0 1.7%
mul-1-neg1.7%
+-commutative1.7%
unpow21.7%
unpow21.7%
hypot-def24.9%
Simplified24.9%
Taylor expanded in A around 0 21.8%
associate-*r*21.8%
mul-1-neg21.8%
Simplified21.8%
sqrt-prod34.8%
Applied egg-rr34.8%
Final simplification37.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)))))
(if (<= B 3.4e-82)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(if (<= B 7.8e+93)
(/
(* (sqrt (* F (- A (hypot A B)))) (* (sqrt 2.0) (- B)))
(- (* B B) (* (* A C) 4.0)))
(* (/ (sqrt 2.0) B) (* (sqrt (- F)) (- (sqrt 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.4e-82) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else if (B <= 7.8e+93) {
tmp = (sqrt((F * (A - hypot(A, B)))) * (sqrt(2.0) * -B)) / ((B * B) - ((A * C) * 4.0));
} else {
tmp = (sqrt(2.0) / B) * (sqrt(-F) * -sqrt(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 <= 3.4e-82) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else if (B <= 7.8e+93) {
tmp = (Math.sqrt((F * (A - Math.hypot(A, B)))) * (Math.sqrt(2.0) * -B)) / ((B * B) - ((A * C) * 4.0));
} else {
tmp = (Math.sqrt(2.0) / B) * (Math.sqrt(-F) * -Math.sqrt(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.4e-82: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 elif B <= 7.8e+93: tmp = (math.sqrt((F * (A - math.hypot(A, B)))) * (math.sqrt(2.0) * -B)) / ((B * B) - ((A * C) * 4.0)) else: tmp = (math.sqrt(2.0) / B) * (math.sqrt(-F) * -math.sqrt(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.4e-82) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); elseif (B <= 7.8e+93) tmp = Float64(Float64(sqrt(Float64(F * Float64(A - hypot(A, B)))) * Float64(sqrt(2.0) * Float64(-B))) / Float64(Float64(B * B) - Float64(Float64(A * C) * 4.0))); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(sqrt(Float64(-F)) * Float64(-sqrt(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.4e-82)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
elseif (B <= 7.8e+93)
tmp = (sqrt((F * (A - hypot(A, B)))) * (sqrt(2.0) * -B)) / ((B * B) - ((A * C) * 4.0));
else
tmp = (sqrt(2.0) / B) * (sqrt(-F) * -sqrt(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.4e-82], 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], If[LessEqual[B, 7.8e+93], N[(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] / N[(N[(B * B), $MachinePrecision] - N[(N[(A * C), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * N[(N[Sqrt[(-F)], $MachinePrecision] * (-N[Sqrt[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.4 \cdot 10^{-82}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 7.8 \cdot 10^{+93}:\\
\;\;\;\;\frac{\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \left(\sqrt{2} \cdot \left(-B\right)\right)}{B \cdot B - \left(A \cdot C\right) \cdot 4}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(\sqrt{-F} \cdot \left(-\sqrt{B}\right)\right)\\
\end{array}
\end{array}
if B < 3.39999999999999975e-82Initial program 17.2%
Simplified17.2%
Taylor expanded in A around -inf 14.2%
distribute-frac-neg14.2%
associate-*l*15.4%
cancel-sign-sub-inv15.4%
metadata-eval15.4%
*-commutative15.4%
cancel-sign-sub-inv15.4%
metadata-eval15.4%
Applied egg-rr15.4%
if 3.39999999999999975e-82 < B < 7.8000000000000005e93Initial program 37.7%
Simplified37.7%
Taylor expanded in C around 0 36.8%
+-commutative36.8%
unpow236.8%
unpow236.8%
hypot-def39.5%
Simplified39.5%
if 7.8000000000000005e93 < B Initial program 3.1%
Simplified3.1%
Taylor expanded in C around 0 10.4%
mul-1-neg10.4%
+-commutative10.4%
unpow210.4%
unpow210.4%
hypot-def48.5%
Simplified48.5%
Taylor expanded in A around 0 45.9%
associate-*r*45.9%
mul-1-neg45.9%
Simplified45.9%
sqrt-prod68.1%
Applied egg-rr68.1%
Final simplification27.4%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 3.8e-82)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(if (<= B 1.48e+94)
(/ (- (sqrt (* 2.0 (* F (- A (hypot A B)))))) B)
(if (or (<= B 1.85e+236) (not (<= B 1.15e+247)))
(* (* (/ (sqrt 2.0) B) (sqrt (- F))) (- (sqrt B)))
(/ (* (sqrt (* B (- F))) (- (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.8e-82) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else if (B <= 1.48e+94) {
tmp = -sqrt((2.0 * (F * (A - hypot(A, B))))) / B;
} else if ((B <= 1.85e+236) || !(B <= 1.15e+247)) {
tmp = ((sqrt(2.0) / B) * sqrt(-F)) * -sqrt(B);
} else {
tmp = (sqrt((B * -F)) * -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 <= 3.8e-82) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else if (B <= 1.48e+94) {
tmp = -Math.sqrt((2.0 * (F * (A - Math.hypot(A, B))))) / B;
} else if ((B <= 1.85e+236) || !(B <= 1.15e+247)) {
tmp = ((Math.sqrt(2.0) / B) * Math.sqrt(-F)) * -Math.sqrt(B);
} else {
tmp = (Math.sqrt((B * -F)) * -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.8e-82: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 elif B <= 1.48e+94: tmp = -math.sqrt((2.0 * (F * (A - math.hypot(A, B))))) / B elif (B <= 1.85e+236) or not (B <= 1.15e+247): tmp = ((math.sqrt(2.0) / B) * math.sqrt(-F)) * -math.sqrt(B) else: tmp = (math.sqrt((B * -F)) * -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.8e-82) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); elseif (B <= 1.48e+94) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(F * Float64(A - hypot(A, B)))))) / B); elseif ((B <= 1.85e+236) || !(B <= 1.15e+247)) tmp = Float64(Float64(Float64(sqrt(2.0) / B) * sqrt(Float64(-F))) * Float64(-sqrt(B))); else tmp = Float64(Float64(sqrt(Float64(B * Float64(-F))) * 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.8e-82)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
elseif (B <= 1.48e+94)
tmp = -sqrt((2.0 * (F * (A - hypot(A, B))))) / B;
elseif ((B <= 1.85e+236) || ~((B <= 1.15e+247)))
tmp = ((sqrt(2.0) / B) * sqrt(-F)) * -sqrt(B);
else
tmp = (sqrt((B * -F)) * -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.8e-82], 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], If[LessEqual[B, 1.48e+94], N[((-N[Sqrt[N[(2.0 * N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / B), $MachinePrecision], If[Or[LessEqual[B, 1.85e+236], N[Not[LessEqual[B, 1.15e+247]], $MachinePrecision]], N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * N[Sqrt[(-F)], $MachinePrecision]), $MachinePrecision] * (-N[Sqrt[B], $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[N[(B * (-F)), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision] / B), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 3.8 \cdot 10^{-82}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 1.48 \cdot 10^{+94}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{B}\\
\mathbf{elif}\;B \leq 1.85 \cdot 10^{+236} \lor \neg \left(B \leq 1.15 \cdot 10^{+247}\right):\\
\;\;\;\;\left(\frac{\sqrt{2}}{B} \cdot \sqrt{-F}\right) \cdot \left(-\sqrt{B}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{B \cdot \left(-F\right)} \cdot \left(-\sqrt{2}\right)}{B}\\
\end{array}
\end{array}
if B < 3.8000000000000002e-82Initial program 17.2%
Simplified17.2%
Taylor expanded in A around -inf 14.2%
distribute-frac-neg14.2%
associate-*l*15.4%
cancel-sign-sub-inv15.4%
metadata-eval15.4%
*-commutative15.4%
cancel-sign-sub-inv15.4%
metadata-eval15.4%
Applied egg-rr15.4%
if 3.8000000000000002e-82 < B < 1.47999999999999995e94Initial program 37.7%
Simplified37.7%
Taylor expanded in C around 0 37.4%
mul-1-neg37.4%
+-commutative37.4%
unpow237.4%
unpow237.4%
hypot-def40.0%
Simplified40.0%
associate-*l/39.8%
Applied egg-rr39.8%
sqrt-unprod39.9%
Applied egg-rr39.9%
if 1.47999999999999995e94 < B < 1.85000000000000007e236 or 1.14999999999999995e247 < B Initial program 3.3%
Simplified3.3%
Taylor expanded in C around 0 11.1%
mul-1-neg11.1%
+-commutative11.1%
unpow211.1%
unpow211.1%
hypot-def45.7%
Simplified45.7%
associate-*l/45.6%
Applied egg-rr45.6%
Taylor expanded in A around 0 42.7%
associate-*r*42.9%
mul-1-neg42.9%
Simplified42.7%
associate-*l/42.9%
sqrt-prod66.9%
associate-*r*54.9%
Applied egg-rr54.9%
if 1.85000000000000007e236 < B < 1.14999999999999995e247Initial program 0.0%
Simplified0.0%
Taylor expanded in C around 0 1.9%
mul-1-neg1.9%
+-commutative1.9%
unpow21.9%
unpow21.9%
hypot-def82.8%
Simplified82.8%
associate-*l/82.8%
Applied egg-rr82.8%
Taylor expanded in A around 0 82.8%
associate-*r*82.8%
mul-1-neg82.8%
Simplified82.8%
Final simplification25.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 8.2e-84)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(if (<= B 2.55e+94)
(/ (- (sqrt (* 2.0 (* F (- A (hypot A B)))))) B)
(* (/ (sqrt 2.0) B) (* (sqrt (- F)) (- (sqrt 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 <= 8.2e-84) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else if (B <= 2.55e+94) {
tmp = -sqrt((2.0 * (F * (A - hypot(A, B))))) / B;
} else {
tmp = (sqrt(2.0) / B) * (sqrt(-F) * -sqrt(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 <= 8.2e-84) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else if (B <= 2.55e+94) {
tmp = -Math.sqrt((2.0 * (F * (A - Math.hypot(A, B))))) / B;
} else {
tmp = (Math.sqrt(2.0) / B) * (Math.sqrt(-F) * -Math.sqrt(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 <= 8.2e-84: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 elif B <= 2.55e+94: tmp = -math.sqrt((2.0 * (F * (A - math.hypot(A, B))))) / B else: tmp = (math.sqrt(2.0) / B) * (math.sqrt(-F) * -math.sqrt(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 <= 8.2e-84) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); elseif (B <= 2.55e+94) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(F * Float64(A - hypot(A, B)))))) / B); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(sqrt(Float64(-F)) * Float64(-sqrt(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 <= 8.2e-84)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
elseif (B <= 2.55e+94)
tmp = -sqrt((2.0 * (F * (A - hypot(A, B))))) / B;
else
tmp = (sqrt(2.0) / B) * (sqrt(-F) * -sqrt(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, 8.2e-84], 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], If[LessEqual[B, 2.55e+94], N[((-N[Sqrt[N[(2.0 * N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / B), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * N[(N[Sqrt[(-F)], $MachinePrecision] * (-N[Sqrt[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 8.2 \cdot 10^{-84}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 2.55 \cdot 10^{+94}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(\sqrt{-F} \cdot \left(-\sqrt{B}\right)\right)\\
\end{array}
\end{array}
if B < 8.2000000000000001e-84Initial program 17.2%
Simplified17.2%
Taylor expanded in A around -inf 14.2%
distribute-frac-neg14.2%
associate-*l*15.4%
cancel-sign-sub-inv15.4%
metadata-eval15.4%
*-commutative15.4%
cancel-sign-sub-inv15.4%
metadata-eval15.4%
Applied egg-rr15.4%
if 8.2000000000000001e-84 < B < 2.5500000000000002e94Initial program 37.7%
Simplified37.7%
Taylor expanded in C around 0 37.4%
mul-1-neg37.4%
+-commutative37.4%
unpow237.4%
unpow237.4%
hypot-def40.0%
Simplified40.0%
associate-*l/39.8%
Applied egg-rr39.8%
sqrt-unprod39.9%
Applied egg-rr39.9%
if 2.5500000000000002e94 < B Initial program 3.1%
Simplified3.1%
Taylor expanded in C around 0 10.4%
mul-1-neg10.4%
+-commutative10.4%
unpow210.4%
unpow210.4%
hypot-def48.5%
Simplified48.5%
Taylor expanded in A around 0 45.9%
associate-*r*45.9%
mul-1-neg45.9%
Simplified45.9%
sqrt-prod68.1%
Applied egg-rr68.1%
Final simplification27.4%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 2.8e-82)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(/ (- (sqrt (* 2.0 (* 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 <= 2.8e-82) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -sqrt((2.0 * (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 <= 2.8e-82) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -Math.sqrt((2.0 * (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 <= 2.8e-82: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = -math.sqrt((2.0 * (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 <= 2.8e-82) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(2.0 * 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 <= 2.8e-82)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = -sqrt((2.0 * (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, 2.8e-82], 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[(2.0 * 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 2.8 \cdot 10^{-82}:\\
\;\;\;\;\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(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{B}\\
\end{array}
\end{array}
if B < 2.80000000000000024e-82Initial program 17.2%
Simplified17.2%
Taylor expanded in A around -inf 14.2%
distribute-frac-neg14.2%
associate-*l*15.4%
cancel-sign-sub-inv15.4%
metadata-eval15.4%
*-commutative15.4%
cancel-sign-sub-inv15.4%
metadata-eval15.4%
Applied egg-rr15.4%
if 2.80000000000000024e-82 < B Initial program 20.4%
Simplified20.4%
Taylor expanded in C around 0 23.9%
mul-1-neg23.9%
+-commutative23.9%
unpow223.9%
unpow223.9%
hypot-def44.2%
Simplified44.2%
associate-*l/44.1%
Applied egg-rr44.1%
sqrt-unprod44.2%
Applied egg-rr44.2%
Final simplification24.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 3.8e-82)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(/ -1.0 (/ B (sqrt (* 2.0 (* 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 <= 3.8e-82) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -1.0 / (B / sqrt((2.0 * (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 <= 3.8d-82) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (2.0d0 * a))))) / t_0
else
tmp = (-1.0d0) / (b / sqrt((2.0d0 * (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 <= 3.8e-82) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -1.0 / (B / Math.sqrt((2.0 * (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 <= 3.8e-82: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = -1.0 / (B / math.sqrt((2.0 * (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 <= 3.8e-82) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(-1.0 / Float64(B / sqrt(Float64(2.0 * 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 <= 3.8e-82)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = -1.0 / (B / sqrt((2.0 * (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, 3.8e-82], 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[(-1.0 / N[(B / N[Sqrt[N[(2.0 * N[(B * (-F)), $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)\\
\mathbf{if}\;B \leq 3.8 \cdot 10^{-82}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{B}{\sqrt{2 \cdot \left(B \cdot \left(-F\right)\right)}}}\\
\end{array}
\end{array}
if B < 3.8000000000000002e-82Initial program 17.2%
Simplified17.2%
Taylor expanded in A around -inf 14.2%
distribute-frac-neg14.2%
associate-*l*15.4%
cancel-sign-sub-inv15.4%
metadata-eval15.4%
*-commutative15.4%
cancel-sign-sub-inv15.4%
metadata-eval15.4%
Applied egg-rr15.4%
if 3.8000000000000002e-82 < B Initial program 20.4%
Simplified20.4%
Taylor expanded in C around 0 23.9%
mul-1-neg23.9%
+-commutative23.9%
unpow223.9%
unpow223.9%
hypot-def44.2%
Simplified44.2%
Taylor expanded in A around 0 39.5%
associate-*r*39.5%
mul-1-neg39.5%
Simplified39.5%
sqrt-prod50.6%
Applied egg-rr50.6%
sqrt-prod39.5%
associate-*l/39.4%
clear-num39.5%
sqrt-unprod39.5%
Applied egg-rr39.5%
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
(if (<= B 8e-84)
(/
(- (sqrt (* 2.0 (* (* 2.0 A) (* -4.0 (* A (* C F)))))))
(- (* B B) (* (* A C) 4.0)))
(/ -1.0 (/ B (sqrt (* 2.0 (* B (- F))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 8e-84) {
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((A * C) * 4.0));
} else {
tmp = -1.0 / (B / sqrt((2.0 * (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) :: tmp
if (b <= 8d-84) then
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * ((-4.0d0) * (a * (c * f)))))) / ((b * b) - ((a * c) * 4.0d0))
else
tmp = (-1.0d0) / (b / sqrt((2.0d0 * (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 tmp;
if (B <= 8e-84) {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((A * C) * 4.0));
} else {
tmp = -1.0 / (B / Math.sqrt((2.0 * (B * -F))));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= 8e-84: tmp = -math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((A * C) * 4.0)) else: tmp = -1.0 / (B / math.sqrt((2.0 * (B * -F)))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 8e-84) 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(-1.0 / Float64(B / sqrt(Float64(2.0 * 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)
tmp = 0.0;
if (B <= 8e-84)
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - ((A * C) * 4.0));
else
tmp = -1.0 / (B / sqrt((2.0 * (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_] := If[LessEqual[B, 8e-84], 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[(-1.0 / N[(B / N[Sqrt[N[(2.0 * N[(B * (-F)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 8 \cdot 10^{-84}:\\
\;\;\;\;\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}:\\
\;\;\;\;\frac{-1}{\frac{B}{\sqrt{2 \cdot \left(B \cdot \left(-F\right)\right)}}}\\
\end{array}
\end{array}
if B < 8.0000000000000003e-84Initial program 17.2%
Simplified17.2%
Taylor expanded in A around -inf 14.2%
Taylor expanded in B around 0 14.2%
*-commutative14.2%
Simplified14.2%
if 8.0000000000000003e-84 < B Initial program 20.4%
Simplified20.4%
Taylor expanded in C around 0 23.9%
mul-1-neg23.9%
+-commutative23.9%
unpow223.9%
unpow223.9%
hypot-def44.2%
Simplified44.2%
Taylor expanded in A around 0 39.5%
associate-*r*39.5%
mul-1-neg39.5%
Simplified39.5%
sqrt-prod50.6%
Applied egg-rr50.6%
sqrt-prod39.5%
associate-*l/39.4%
clear-num39.5%
sqrt-unprod39.5%
Applied egg-rr39.5%
Final simplification22.1%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 3.8e-82)
(/
(- (sqrt (* 2.0 (* (* -4.0 (* (* A C) F)) (* 2.0 A)))))
(- (* B B) (* (* A C) 4.0)))
(/ -1.0 (/ B (sqrt (* 2.0 (* B (- F))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 3.8e-82) {
tmp = -sqrt((2.0 * ((-4.0 * ((A * C) * F)) * (2.0 * A)))) / ((B * B) - ((A * C) * 4.0));
} else {
tmp = -1.0 / (B / sqrt((2.0 * (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) :: tmp
if (b <= 3.8d-82) then
tmp = -sqrt((2.0d0 * (((-4.0d0) * ((a * c) * f)) * (2.0d0 * a)))) / ((b * b) - ((a * c) * 4.0d0))
else
tmp = (-1.0d0) / (b / sqrt((2.0d0 * (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 tmp;
if (B <= 3.8e-82) {
tmp = -Math.sqrt((2.0 * ((-4.0 * ((A * C) * F)) * (2.0 * A)))) / ((B * B) - ((A * C) * 4.0));
} else {
tmp = -1.0 / (B / Math.sqrt((2.0 * (B * -F))));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= 3.8e-82: tmp = -math.sqrt((2.0 * ((-4.0 * ((A * C) * F)) * (2.0 * A)))) / ((B * B) - ((A * C) * 4.0)) else: tmp = -1.0 / (B / math.sqrt((2.0 * (B * -F)))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 3.8e-82) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(-4.0 * Float64(Float64(A * C) * F)) * Float64(2.0 * A))))) / Float64(Float64(B * B) - Float64(Float64(A * C) * 4.0))); else tmp = Float64(-1.0 / Float64(B / sqrt(Float64(2.0 * 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)
tmp = 0.0;
if (B <= 3.8e-82)
tmp = -sqrt((2.0 * ((-4.0 * ((A * C) * F)) * (2.0 * A)))) / ((B * B) - ((A * C) * 4.0));
else
tmp = -1.0 / (B / sqrt((2.0 * (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_] := If[LessEqual[B, 3.8e-82], N[((-N[Sqrt[N[(2.0 * N[(N[(-4.0 * N[(N[(A * C), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(N[(A * C), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(B / N[Sqrt[N[(2.0 * N[(B * (-F)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 3.8 \cdot 10^{-82}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(-4 \cdot \left(\left(A \cdot C\right) \cdot F\right)\right) \cdot \left(2 \cdot A\right)\right)}}{B \cdot B - \left(A \cdot C\right) \cdot 4}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{B}{\sqrt{2 \cdot \left(B \cdot \left(-F\right)\right)}}}\\
\end{array}
\end{array}
if B < 3.8000000000000002e-82Initial program 17.2%
Simplified17.2%
Taylor expanded in A around -inf 14.2%
Taylor expanded in B around 0 14.2%
associate-*r*14.7%
Simplified14.7%
if 3.8000000000000002e-82 < B Initial program 20.4%
Simplified20.4%
Taylor expanded in C around 0 23.9%
mul-1-neg23.9%
+-commutative23.9%
unpow223.9%
unpow223.9%
hypot-def44.2%
Simplified44.2%
Taylor expanded in A around 0 39.5%
associate-*r*39.5%
mul-1-neg39.5%
Simplified39.5%
sqrt-prod50.6%
Applied egg-rr50.6%
sqrt-prod39.5%
associate-*l/39.4%
clear-num39.5%
sqrt-unprod39.5%
Applied egg-rr39.5%
Final simplification22.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
(if (<= B 1.3e-82)
(/
(- (sqrt (* 2.0 (* (* C F) (* -8.0 (* A A))))))
(- (* B B) (* (* A C) 4.0)))
(/ -1.0 (/ B (sqrt (* 2.0 (* B (- F))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 1.3e-82) {
tmp = -sqrt((2.0 * ((C * F) * (-8.0 * (A * A))))) / ((B * B) - ((A * C) * 4.0));
} else {
tmp = -1.0 / (B / sqrt((2.0 * (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) :: tmp
if (b <= 1.3d-82) then
tmp = -sqrt((2.0d0 * ((c * f) * ((-8.0d0) * (a * a))))) / ((b * b) - ((a * c) * 4.0d0))
else
tmp = (-1.0d0) / (b / sqrt((2.0d0 * (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 tmp;
if (B <= 1.3e-82) {
tmp = -Math.sqrt((2.0 * ((C * F) * (-8.0 * (A * A))))) / ((B * B) - ((A * C) * 4.0));
} else {
tmp = -1.0 / (B / Math.sqrt((2.0 * (B * -F))));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= 1.3e-82: tmp = -math.sqrt((2.0 * ((C * F) * (-8.0 * (A * A))))) / ((B * B) - ((A * C) * 4.0)) else: tmp = -1.0 / (B / math.sqrt((2.0 * (B * -F)))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 1.3e-82) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(C * F) * Float64(-8.0 * Float64(A * A)))))) / Float64(Float64(B * B) - Float64(Float64(A * C) * 4.0))); else tmp = Float64(-1.0 / Float64(B / sqrt(Float64(2.0 * 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)
tmp = 0.0;
if (B <= 1.3e-82)
tmp = -sqrt((2.0 * ((C * F) * (-8.0 * (A * A))))) / ((B * B) - ((A * C) * 4.0));
else
tmp = -1.0 / (B / sqrt((2.0 * (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_] := If[LessEqual[B, 1.3e-82], N[((-N[Sqrt[N[(2.0 * N[(N[(C * F), $MachinePrecision] * N[(-8.0 * N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(N[(A * C), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(B / N[Sqrt[N[(2.0 * N[(B * (-F)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 1.3 \cdot 10^{-82}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(C \cdot F\right) \cdot \left(-8 \cdot \left(A \cdot A\right)\right)\right)}}{B \cdot B - \left(A \cdot C\right) \cdot 4}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{B}{\sqrt{2 \cdot \left(B \cdot \left(-F\right)\right)}}}\\
\end{array}
\end{array}
if B < 1.3e-82Initial program 17.2%
Simplified17.2%
Taylor expanded in A around -inf 14.2%
Taylor expanded in B around 0 8.8%
associate-*r*8.8%
unpow28.8%
*-commutative8.8%
Simplified8.8%
if 1.3e-82 < B Initial program 20.4%
Simplified20.4%
Taylor expanded in C around 0 23.9%
mul-1-neg23.9%
+-commutative23.9%
unpow223.9%
unpow223.9%
hypot-def44.2%
Simplified44.2%
Taylor expanded in A around 0 39.5%
associate-*r*39.5%
mul-1-neg39.5%
Simplified39.5%
sqrt-prod50.6%
Applied egg-rr50.6%
sqrt-prod39.5%
associate-*l/39.4%
clear-num39.5%
sqrt-unprod39.5%
Applied egg-rr39.5%
Final simplification18.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 (/ -1.0 (/ B (sqrt (* 2.0 (* B (- F)))))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -1.0 / (B / sqrt((2.0 * (B * -F))));
}
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 = (-1.0d0) / (b / sqrt((2.0d0 * (b * -f))))
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return -1.0 / (B / Math.sqrt((2.0 * (B * -F))));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -1.0 / (B / math.sqrt((2.0 * (B * -F))))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-1.0 / Float64(B / sqrt(Float64(2.0 * Float64(B * Float64(-F)))))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -1.0 / (B / sqrt((2.0 * (B * -F))));
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[(-1.0 / N[(B / N[Sqrt[N[(2.0 * N[(B * (-F)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{-1}{\frac{B}{\sqrt{2 \cdot \left(B \cdot \left(-F\right)\right)}}}
\end{array}
Initial program 18.2%
Simplified18.2%
Taylor expanded in C around 0 9.5%
mul-1-neg9.5%
+-commutative9.5%
unpow29.5%
unpow29.5%
hypot-def16.7%
Simplified16.7%
Taylor expanded in A around 0 14.6%
associate-*r*14.6%
mul-1-neg14.6%
Simplified14.6%
sqrt-prod17.9%
Applied egg-rr17.9%
sqrt-prod14.6%
associate-*l/14.6%
clear-num14.6%
sqrt-unprod14.7%
Applied egg-rr14.7%
Final simplification14.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 (/ (- (sqrt (* (* B F) -2.0))) B))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -sqrt(((B * F) * -2.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 = -sqrt(((b * f) * (-2.0d0))) / b
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return -Math.sqrt(((B * F) * -2.0)) / B;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -math.sqrt(((B * F) * -2.0)) / B
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(-sqrt(Float64(Float64(B * F) * -2.0))) / B) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt(((B * F) * -2.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[((-N[Sqrt[N[(N[(B * F), $MachinePrecision] * -2.0), $MachinePrecision]], $MachinePrecision]) / B), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{-\sqrt{\left(B \cdot F\right) \cdot -2}}{B}
\end{array}
Initial program 18.2%
Simplified18.2%
Taylor expanded in C around 0 9.5%
mul-1-neg9.5%
+-commutative9.5%
unpow29.5%
unpow29.5%
hypot-def16.7%
Simplified16.7%
Taylor expanded in A around 0 14.6%
associate-*r*14.6%
mul-1-neg14.6%
Simplified14.6%
sqrt-prod17.9%
Applied egg-rr17.9%
sqrt-prod14.6%
associate-*l/14.6%
sqrt-unprod14.6%
Applied egg-rr14.6%
*-commutative14.6%
distribute-lft-neg-out14.6%
mul-1-neg14.6%
*-commutative14.6%
associate-*l*14.6%
metadata-eval14.6%
Simplified14.6%
Final simplification14.6%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* -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.2%
Simplified18.2%
Taylor expanded in A around -inf 11.1%
Taylor expanded in B around inf 3.2%
associate-*r/3.2%
*-rgt-identity3.2%
*-commutative3.2%
Simplified3.2%
Final simplification3.2%
herbie shell --seed 2023242
(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))))