
(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 10 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}
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(if (<= (pow B_m 2.0) 4e-143)
(/
(sqrt (* -8.0 (* (* C A) (* F (+ A A)))))
(- (fma C (* A -4.0) (pow B_m 2.0))))
(if (<= (pow B_m 2.0) 5e+37)
(* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C)))))
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A)))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (pow(B_m, 2.0) <= 4e-143) {
tmp = sqrt((-8.0 * ((C * A) * (F * (A + A))))) / -fma(C, (A * -4.0), pow(B_m, 2.0));
} else if (pow(B_m, 2.0) <= 5e+37) {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
} else {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if ((B_m ^ 2.0) <= 4e-143) tmp = Float64(sqrt(Float64(-8.0 * Float64(Float64(C * A) * Float64(F * Float64(A + A))))) / Float64(-fma(C, Float64(A * -4.0), (B_m ^ 2.0)))); elseif ((B_m ^ 2.0) <= 5e+37) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); end return tmp end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e-143], N[(N[Sqrt[N[(-8.0 * N[(N[(C * A), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(C * N[(A * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision])), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+37], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;{B\_m}^{2} \leq 4 \cdot 10^{-143}:\\
\;\;\;\;\frac{\sqrt{-8 \cdot \left(\left(C \cdot A\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{-\mathsf{fma}\left(C, A \cdot -4, {B\_m}^{2}\right)}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+37}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)}\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 3.9999999999999998e-143Initial program 26.0%
Simplified29.1%
Taylor expanded in C around inf 27.4%
associate-*r*29.1%
*-commutative29.1%
mul-1-neg29.1%
Simplified29.1%
if 3.9999999999999998e-143 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999989e37Initial program 27.9%
Taylor expanded in F around 0 25.2%
mul-1-neg25.2%
*-commutative25.2%
associate-/l*25.1%
associate--l+26.1%
unpow226.1%
unpow226.1%
hypot-undefine36.9%
cancel-sign-sub-inv36.9%
Simplified36.9%
Taylor expanded in A around -inf 25.5%
if 4.99999999999999989e37 < (pow.f64 B #s(literal 2 binary64)) Initial program 11.7%
Taylor expanded in C around 0 10.6%
mul-1-neg10.6%
+-commutative10.6%
unpow210.6%
unpow210.6%
hypot-define24.6%
Simplified24.6%
Final simplification26.6%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(if (<= (pow B_m 2.0) 4e-151)
(/
(sqrt (* -8.0 (* C (* (* A F) (+ A A)))))
(- (fma C (* A -4.0) (pow B_m 2.0))))
(if (<= (pow B_m 2.0) 5e+37)
(* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C)))))
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A)))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (pow(B_m, 2.0) <= 4e-151) {
tmp = sqrt((-8.0 * (C * ((A * F) * (A + A))))) / -fma(C, (A * -4.0), pow(B_m, 2.0));
} else if (pow(B_m, 2.0) <= 5e+37) {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
} else {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if ((B_m ^ 2.0) <= 4e-151) tmp = Float64(sqrt(Float64(-8.0 * Float64(C * Float64(Float64(A * F) * Float64(A + A))))) / Float64(-fma(C, Float64(A * -4.0), (B_m ^ 2.0)))); elseif ((B_m ^ 2.0) <= 5e+37) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); end return tmp end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e-151], N[(N[Sqrt[N[(-8.0 * N[(C * N[(N[(A * F), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(C * N[(A * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision])), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+37], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;{B\_m}^{2} \leq 4 \cdot 10^{-151}:\\
\;\;\;\;\frac{\sqrt{-8 \cdot \left(C \cdot \left(\left(A \cdot F\right) \cdot \left(A + A\right)\right)\right)}}{-\mathsf{fma}\left(C, A \cdot -4, {B\_m}^{2}\right)}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+37}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)}\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 3.9999999999999998e-151Initial program 25.5%
Simplified28.6%
Taylor expanded in C around inf 27.9%
associate-*r*29.6%
*-commutative29.6%
mul-1-neg29.6%
Simplified29.6%
*-un-lft-identity29.6%
associate-*r*29.7%
Applied egg-rr29.7%
*-lft-identity29.7%
associate-*l*29.6%
associate-*r*25.1%
associate-*r*25.1%
sub-neg25.1%
remove-double-neg25.1%
Simplified25.1%
if 3.9999999999999998e-151 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999989e37Initial program 29.2%
Taylor expanded in F around 0 26.6%
mul-1-neg26.6%
*-commutative26.6%
associate-/l*26.6%
associate--l+27.5%
unpow227.5%
unpow227.5%
hypot-undefine37.8%
cancel-sign-sub-inv37.8%
Simplified37.8%
Taylor expanded in A around -inf 24.1%
if 4.99999999999999989e37 < (pow.f64 B #s(literal 2 binary64)) Initial program 11.7%
Taylor expanded in C around 0 10.6%
mul-1-neg10.6%
+-commutative10.6%
unpow210.6%
unpow210.6%
hypot-define24.6%
Simplified24.6%
Final simplification24.7%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(if (<= B_m 9.2e+18)
(* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C)))))
(if (<= B_m 7.6e+244)
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A))))))
(if (<= B_m 1.05e+301)
(* (sqrt 2.0) (- (sqrt (* F (/ (+ (+ (/ A B_m) (/ C B_m)) -1.0) B_m)))))
(/ (sqrt (* (* 2.0 F) (- C (hypot B_m C)))) (- B_m))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 9.2e+18) {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
} else if (B_m <= 7.6e+244) {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
} else if (B_m <= 1.05e+301) {
tmp = sqrt(2.0) * -sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m)));
} else {
tmp = sqrt(((2.0 * F) * (C - hypot(B_m, C)))) / -B_m;
}
return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 9.2e+18) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
} else if (B_m <= 7.6e+244) {
tmp = (Math.sqrt(2.0) / B_m) * -Math.sqrt((F * (A - Math.hypot(B_m, A))));
} else if (B_m <= 1.05e+301) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m)));
} else {
tmp = Math.sqrt(((2.0 * F) * (C - Math.hypot(B_m, C)))) / -B_m;
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if B_m <= 9.2e+18: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) elif B_m <= 7.6e+244: tmp = (math.sqrt(2.0) / B_m) * -math.sqrt((F * (A - math.hypot(B_m, A)))) elif B_m <= 1.05e+301: tmp = math.sqrt(2.0) * -math.sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m))) else: tmp = math.sqrt(((2.0 * F) * (C - math.hypot(B_m, C)))) / -B_m return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (B_m <= 9.2e+18) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); elseif (B_m <= 7.6e+244) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); elseif (B_m <= 1.05e+301) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(Float64(Float64(Float64(A / B_m) + Float64(C / B_m)) + -1.0) / B_m))))); else tmp = Float64(sqrt(Float64(Float64(2.0 * F) * Float64(C - hypot(B_m, C)))) / Float64(-B_m)); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (B_m <= 9.2e+18)
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
elseif (B_m <= 7.6e+244)
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
elseif (B_m <= 1.05e+301)
tmp = sqrt(2.0) * -sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m)));
else
tmp = sqrt(((2.0 * F) * (C - hypot(B_m, C)))) / -B_m;
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 9.2e+18], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[B$95$m, 7.6e+244], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[B$95$m, 1.05e+301], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(N[(N[(N[(A / B$95$m), $MachinePrecision] + N[(C / B$95$m), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * N[(C - N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 9.2 \cdot 10^{+18}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\mathbf{elif}\;B\_m \leq 7.6 \cdot 10^{+244}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)}\right)\\
\mathbf{elif}\;B\_m \leq 1.05 \cdot 10^{+301}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{\left(\frac{A}{B\_m} + \frac{C}{B\_m}\right) + -1}{B\_m}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot F\right) \cdot \left(C - \mathsf{hypot}\left(B\_m, C\right)\right)}}{-B\_m}\\
\end{array}
\end{array}
if B < 9.2e18Initial program 22.1%
Taylor expanded in F around 0 18.4%
mul-1-neg18.4%
*-commutative18.4%
associate-/l*19.4%
associate--l+19.9%
unpow219.9%
unpow219.9%
hypot-undefine26.6%
cancel-sign-sub-inv26.6%
Simplified26.6%
Taylor expanded in A around -inf 15.6%
if 9.2e18 < B < 7.59999999999999966e244Initial program 16.1%
Taylor expanded in C around 0 24.5%
mul-1-neg24.5%
+-commutative24.5%
unpow224.5%
unpow224.5%
hypot-define47.9%
Simplified47.9%
if 7.59999999999999966e244 < B < 1.05e301Initial program 0.0%
Taylor expanded in F around 0 0.0%
mul-1-neg0.0%
*-commutative0.0%
associate-/l*0.0%
associate--l+0.0%
unpow20.0%
unpow20.0%
hypot-undefine3.5%
cancel-sign-sub-inv3.5%
Simplified3.5%
Taylor expanded in B around inf 85.6%
if 1.05e301 < B Initial program 0.0%
Taylor expanded in A around 0 1.9%
mul-1-neg1.9%
unpow21.9%
unpow21.9%
hypot-define99.2%
Simplified99.2%
associate-*l/98.0%
pow1/298.0%
pow1/298.0%
pow-prod-down99.2%
Applied egg-rr99.2%
unpow1/299.2%
associate-*r*99.2%
Simplified99.2%
Final simplification25.6%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(if (<= B_m 1.1e+19)
(* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C)))))
(if (or (<= B_m 2.1e+189) (not (<= B_m 1.35e+301)))
(/ (sqrt (* (* 2.0 F) (- C (hypot B_m C)))) (- B_m))
(*
(sqrt 2.0)
(- (sqrt (* F (/ (+ (+ (/ A B_m) (/ C B_m)) -1.0) B_m))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 1.1e+19) {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
} else if ((B_m <= 2.1e+189) || !(B_m <= 1.35e+301)) {
tmp = sqrt(((2.0 * F) * (C - hypot(B_m, C)))) / -B_m;
} else {
tmp = sqrt(2.0) * -sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m)));
}
return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 1.1e+19) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
} else if ((B_m <= 2.1e+189) || !(B_m <= 1.35e+301)) {
tmp = Math.sqrt(((2.0 * F) * (C - Math.hypot(B_m, C)))) / -B_m;
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m)));
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if B_m <= 1.1e+19: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) elif (B_m <= 2.1e+189) or not (B_m <= 1.35e+301): tmp = math.sqrt(((2.0 * F) * (C - math.hypot(B_m, C)))) / -B_m else: tmp = math.sqrt(2.0) * -math.sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m))) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (B_m <= 1.1e+19) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); elseif ((B_m <= 2.1e+189) || !(B_m <= 1.35e+301)) tmp = Float64(sqrt(Float64(Float64(2.0 * F) * Float64(C - hypot(B_m, C)))) / Float64(-B_m)); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(Float64(Float64(Float64(A / B_m) + Float64(C / B_m)) + -1.0) / B_m))))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (B_m <= 1.1e+19)
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
elseif ((B_m <= 2.1e+189) || ~((B_m <= 1.35e+301)))
tmp = sqrt(((2.0 * F) * (C - hypot(B_m, C)))) / -B_m;
else
tmp = sqrt(2.0) * -sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m)));
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 1.1e+19], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[Or[LessEqual[B$95$m, 2.1e+189], N[Not[LessEqual[B$95$m, 1.35e+301]], $MachinePrecision]], N[(N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * N[(C - N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(N[(N[(N[(A / B$95$m), $MachinePrecision] + N[(C / B$95$m), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 1.1 \cdot 10^{+19}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\mathbf{elif}\;B\_m \leq 2.1 \cdot 10^{+189} \lor \neg \left(B\_m \leq 1.35 \cdot 10^{+301}\right):\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot F\right) \cdot \left(C - \mathsf{hypot}\left(B\_m, C\right)\right)}}{-B\_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{\left(\frac{A}{B\_m} + \frac{C}{B\_m}\right) + -1}{B\_m}}\right)\\
\end{array}
\end{array}
if B < 1.1e19Initial program 22.1%
Taylor expanded in F around 0 18.4%
mul-1-neg18.4%
*-commutative18.4%
associate-/l*19.4%
associate--l+19.9%
unpow219.9%
unpow219.9%
hypot-undefine26.6%
cancel-sign-sub-inv26.6%
Simplified26.6%
Taylor expanded in A around -inf 15.6%
if 1.1e19 < B < 2.09999999999999992e189 or 1.34999999999999992e301 < B Initial program 23.1%
Taylor expanded in A around 0 31.6%
mul-1-neg31.6%
unpow231.6%
unpow231.6%
hypot-define59.4%
Simplified59.4%
associate-*l/59.4%
pow1/259.4%
pow1/259.4%
pow-prod-down59.6%
Applied egg-rr59.6%
unpow1/259.6%
associate-*r*59.6%
Simplified59.6%
if 2.09999999999999992e189 < B < 1.34999999999999992e301Initial program 0.0%
Taylor expanded in F around 0 0.0%
mul-1-neg0.0%
*-commutative0.0%
associate-/l*0.0%
associate--l+0.0%
unpow20.0%
unpow20.0%
hypot-undefine3.8%
cancel-sign-sub-inv3.8%
Simplified3.8%
Taylor expanded in B around inf 65.7%
Final simplification26.8%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(if (<= B_m 9e+18)
(* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C)))))
(if (or (<= B_m 4.9e+244) (not (<= B_m 1.35e+301)))
(/ (sqrt (* (* 2.0 F) (- C (hypot B_m C)))) (- B_m))
(* (sqrt 2.0) (- (sqrt (* F (/ -1.0 B_m))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 9e+18) {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
} else if ((B_m <= 4.9e+244) || !(B_m <= 1.35e+301)) {
tmp = sqrt(((2.0 * F) * (C - hypot(B_m, C)))) / -B_m;
} else {
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
}
return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 9e+18) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
} else if ((B_m <= 4.9e+244) || !(B_m <= 1.35e+301)) {
tmp = Math.sqrt(((2.0 * F) * (C - Math.hypot(B_m, C)))) / -B_m;
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-1.0 / B_m)));
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if B_m <= 9e+18: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) elif (B_m <= 4.9e+244) or not (B_m <= 1.35e+301): tmp = math.sqrt(((2.0 * F) * (C - math.hypot(B_m, C)))) / -B_m else: tmp = math.sqrt(2.0) * -math.sqrt((F * (-1.0 / B_m))) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (B_m <= 9e+18) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); elseif ((B_m <= 4.9e+244) || !(B_m <= 1.35e+301)) tmp = Float64(sqrt(Float64(Float64(2.0 * F) * Float64(C - hypot(B_m, C)))) / Float64(-B_m)); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-1.0 / B_m))))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (B_m <= 9e+18)
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
elseif ((B_m <= 4.9e+244) || ~((B_m <= 1.35e+301)))
tmp = sqrt(((2.0 * F) * (C - hypot(B_m, C)))) / -B_m;
else
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 9e+18], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[Or[LessEqual[B$95$m, 4.9e+244], N[Not[LessEqual[B$95$m, 1.35e+301]], $MachinePrecision]], N[(N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * N[(C - N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 9 \cdot 10^{+18}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\mathbf{elif}\;B\_m \leq 4.9 \cdot 10^{+244} \lor \neg \left(B\_m \leq 1.35 \cdot 10^{+301}\right):\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot F\right) \cdot \left(C - \mathsf{hypot}\left(B\_m, C\right)\right)}}{-B\_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-1}{B\_m}}\right)\\
\end{array}
\end{array}
if B < 9e18Initial program 22.1%
Taylor expanded in F around 0 18.4%
mul-1-neg18.4%
*-commutative18.4%
associate-/l*19.4%
associate--l+19.9%
unpow219.9%
unpow219.9%
hypot-undefine26.6%
cancel-sign-sub-inv26.6%
Simplified26.6%
Taylor expanded in A around -inf 15.6%
if 9e18 < B < 4.9e244 or 1.34999999999999992e301 < B Initial program 15.4%
Taylor expanded in A around 0 22.0%
mul-1-neg22.0%
unpow222.0%
unpow222.0%
hypot-define56.9%
Simplified56.9%
associate-*l/56.8%
pow1/256.8%
pow1/256.8%
pow-prod-down57.0%
Applied egg-rr57.0%
unpow1/257.0%
associate-*r*57.0%
Simplified57.0%
if 4.9e244 < B < 1.34999999999999992e301Initial program 0.0%
Taylor expanded in F around 0 0.0%
mul-1-neg0.0%
*-commutative0.0%
associate-/l*0.0%
associate--l+0.0%
unpow20.0%
unpow20.0%
hypot-undefine3.5%
cancel-sign-sub-inv3.5%
Simplified3.5%
Taylor expanded in B around inf 83.2%
Final simplification26.8%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(if (<= B_m 9e+18)
(* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C)))))
(if (<= B_m 1.65e+244)
(* (/ (sqrt 2.0) B_m) (- (sqrt (* B_m (- F)))))
(if (<= B_m 1.35e+301)
(* (sqrt 2.0) (- (sqrt (* F (/ -1.0 B_m)))))
(* (sqrt (* F (- C B_m))) (/ (sqrt 2.0) (- B_m)))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 9e+18) {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
} else if (B_m <= 1.65e+244) {
tmp = (sqrt(2.0) / B_m) * -sqrt((B_m * -F));
} else if (B_m <= 1.35e+301) {
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
} else {
tmp = sqrt((F * (C - B_m))) * (sqrt(2.0) / -B_m);
}
return tmp;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (b_m <= 9d+18) then
tmp = sqrt(2.0d0) * -sqrt((f * ((-0.5d0) / c)))
else if (b_m <= 1.65d+244) then
tmp = (sqrt(2.0d0) / b_m) * -sqrt((b_m * -f))
else if (b_m <= 1.35d+301) then
tmp = sqrt(2.0d0) * -sqrt((f * ((-1.0d0) / b_m)))
else
tmp = sqrt((f * (c - b_m))) * (sqrt(2.0d0) / -b_m)
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 9e+18) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
} else if (B_m <= 1.65e+244) {
tmp = (Math.sqrt(2.0) / B_m) * -Math.sqrt((B_m * -F));
} else if (B_m <= 1.35e+301) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-1.0 / B_m)));
} else {
tmp = Math.sqrt((F * (C - B_m))) * (Math.sqrt(2.0) / -B_m);
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if B_m <= 9e+18: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) elif B_m <= 1.65e+244: tmp = (math.sqrt(2.0) / B_m) * -math.sqrt((B_m * -F)) elif B_m <= 1.35e+301: tmp = math.sqrt(2.0) * -math.sqrt((F * (-1.0 / B_m))) else: tmp = math.sqrt((F * (C - B_m))) * (math.sqrt(2.0) / -B_m) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (B_m <= 9e+18) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); elseif (B_m <= 1.65e+244) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(B_m * Float64(-F))))); elseif (B_m <= 1.35e+301) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-1.0 / B_m))))); else tmp = Float64(sqrt(Float64(F * Float64(C - B_m))) * Float64(sqrt(2.0) / Float64(-B_m))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (B_m <= 9e+18)
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
elseif (B_m <= 1.65e+244)
tmp = (sqrt(2.0) / B_m) * -sqrt((B_m * -F));
elseif (B_m <= 1.35e+301)
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
else
tmp = sqrt((F * (C - B_m))) * (sqrt(2.0) / -B_m);
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 9e+18], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[B$95$m, 1.65e+244], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(B$95$m * (-F)), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[B$95$m, 1.35e+301], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 9 \cdot 10^{+18}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\mathbf{elif}\;B\_m \leq 1.65 \cdot 10^{+244}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{B\_m \cdot \left(-F\right)}\right)\\
\mathbf{elif}\;B\_m \leq 1.35 \cdot 10^{+301}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-1}{B\_m}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(C - B\_m\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if B < 9e18Initial program 22.1%
Taylor expanded in F around 0 18.4%
mul-1-neg18.4%
*-commutative18.4%
associate-/l*19.4%
associate--l+19.9%
unpow219.9%
unpow219.9%
hypot-undefine26.6%
cancel-sign-sub-inv26.6%
Simplified26.6%
Taylor expanded in A around -inf 15.6%
if 9e18 < B < 1.6499999999999999e244Initial program 16.1%
Taylor expanded in A around 0 22.8%
mul-1-neg22.8%
unpow222.8%
unpow222.8%
hypot-define55.0%
Simplified55.0%
Taylor expanded in C around 0 42.9%
associate-*r*42.9%
neg-mul-142.9%
Simplified42.9%
if 1.6499999999999999e244 < B < 1.34999999999999992e301Initial program 0.0%
Taylor expanded in F around 0 0.0%
mul-1-neg0.0%
*-commutative0.0%
associate-/l*0.0%
associate--l+0.0%
unpow20.0%
unpow20.0%
hypot-undefine3.5%
cancel-sign-sub-inv3.5%
Simplified3.5%
Taylor expanded in B around inf 83.2%
if 1.34999999999999992e301 < B Initial program 0.0%
Taylor expanded in A around 0 1.9%
mul-1-neg1.9%
unpow21.9%
unpow21.9%
hypot-define99.2%
Simplified99.2%
Taylor expanded in C around 0 99.2%
Final simplification24.6%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(if (<= B_m 8.8e+18)
(* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C)))))
(if (or (<= B_m 1.65e+244) (not (<= B_m 1.25e+301)))
(* (/ (sqrt 2.0) B_m) (- (sqrt (* B_m (- F)))))
(* (sqrt 2.0) (- (sqrt (* F (/ -1.0 B_m))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 8.8e+18) {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
} else if ((B_m <= 1.65e+244) || !(B_m <= 1.25e+301)) {
tmp = (sqrt(2.0) / B_m) * -sqrt((B_m * -F));
} else {
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
}
return tmp;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (b_m <= 8.8d+18) then
tmp = sqrt(2.0d0) * -sqrt((f * ((-0.5d0) / c)))
else if ((b_m <= 1.65d+244) .or. (.not. (b_m <= 1.25d+301))) then
tmp = (sqrt(2.0d0) / b_m) * -sqrt((b_m * -f))
else
tmp = sqrt(2.0d0) * -sqrt((f * ((-1.0d0) / b_m)))
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 8.8e+18) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
} else if ((B_m <= 1.65e+244) || !(B_m <= 1.25e+301)) {
tmp = (Math.sqrt(2.0) / B_m) * -Math.sqrt((B_m * -F));
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-1.0 / B_m)));
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if B_m <= 8.8e+18: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) elif (B_m <= 1.65e+244) or not (B_m <= 1.25e+301): tmp = (math.sqrt(2.0) / B_m) * -math.sqrt((B_m * -F)) else: tmp = math.sqrt(2.0) * -math.sqrt((F * (-1.0 / B_m))) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (B_m <= 8.8e+18) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); elseif ((B_m <= 1.65e+244) || !(B_m <= 1.25e+301)) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(B_m * Float64(-F))))); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-1.0 / B_m))))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (B_m <= 8.8e+18)
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
elseif ((B_m <= 1.65e+244) || ~((B_m <= 1.25e+301)))
tmp = (sqrt(2.0) / B_m) * -sqrt((B_m * -F));
else
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 8.8e+18], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[Or[LessEqual[B$95$m, 1.65e+244], N[Not[LessEqual[B$95$m, 1.25e+301]], $MachinePrecision]], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(B$95$m * (-F)), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 8.8 \cdot 10^{+18}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\mathbf{elif}\;B\_m \leq 1.65 \cdot 10^{+244} \lor \neg \left(B\_m \leq 1.25 \cdot 10^{+301}\right):\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{B\_m \cdot \left(-F\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-1}{B\_m}}\right)\\
\end{array}
\end{array}
if B < 8.8e18Initial program 22.1%
Taylor expanded in F around 0 18.4%
mul-1-neg18.4%
*-commutative18.4%
associate-/l*19.4%
associate--l+19.9%
unpow219.9%
unpow219.9%
hypot-undefine26.6%
cancel-sign-sub-inv26.6%
Simplified26.6%
Taylor expanded in A around -inf 15.6%
if 8.8e18 < B < 1.6499999999999999e244 or 1.2500000000000001e301 < B Initial program 15.4%
Taylor expanded in A around 0 22.0%
mul-1-neg22.0%
unpow222.0%
unpow222.0%
hypot-define56.9%
Simplified56.9%
Taylor expanded in C around 0 45.2%
associate-*r*45.2%
neg-mul-145.2%
Simplified45.2%
if 1.6499999999999999e244 < B < 1.2500000000000001e301Initial program 0.0%
Taylor expanded in F around 0 0.0%
mul-1-neg0.0%
*-commutative0.0%
associate-/l*0.0%
associate--l+0.0%
unpow20.0%
unpow20.0%
hypot-undefine3.5%
cancel-sign-sub-inv3.5%
Simplified3.5%
Taylor expanded in B around inf 83.2%
Final simplification24.6%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (if (<= B_m 1.2e+19) (* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C))))) (* (sqrt 2.0) (- (sqrt (* F (/ -1.0 B_m)))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 1.2e+19) {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
} else {
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
}
return tmp;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (b_m <= 1.2d+19) then
tmp = sqrt(2.0d0) * -sqrt((f * ((-0.5d0) / c)))
else
tmp = sqrt(2.0d0) * -sqrt((f * ((-1.0d0) / b_m)))
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 1.2e+19) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-1.0 / B_m)));
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if B_m <= 1.2e+19: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) else: tmp = math.sqrt(2.0) * -math.sqrt((F * (-1.0 / B_m))) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (B_m <= 1.2e+19) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-1.0 / B_m))))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (B_m <= 1.2e+19)
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
else
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 1.2e+19], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 1.2 \cdot 10^{+19}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-1}{B\_m}}\right)\\
\end{array}
\end{array}
if B < 1.2e19Initial program 22.1%
Taylor expanded in F around 0 18.4%
mul-1-neg18.4%
*-commutative18.4%
associate-/l*19.4%
associate--l+19.9%
unpow219.9%
unpow219.9%
hypot-undefine26.6%
cancel-sign-sub-inv26.6%
Simplified26.6%
Taylor expanded in A around -inf 15.6%
if 1.2e19 < B Initial program 12.1%
Taylor expanded in F around 0 15.4%
mul-1-neg15.4%
*-commutative15.4%
associate-/l*17.0%
associate--l+17.0%
unpow217.0%
unpow217.0%
hypot-undefine24.9%
cancel-sign-sub-inv24.9%
Simplified24.9%
Taylor expanded in B around inf 52.4%
Final simplification24.4%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (* (sqrt 2.0) (- (sqrt (* F (/ -1.0 B_m))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = sqrt(2.0d0) * -sqrt((f * ((-1.0d0) / b_m)))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return Math.sqrt(2.0) * -Math.sqrt((F * (-1.0 / B_m)));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return math.sqrt(2.0) * -math.sqrt((F * (-1.0 / B_m)))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-1.0 / B_m))))) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-1}{B\_m}}\right)
\end{array}
Initial program 19.7%
Taylor expanded in F around 0 17.7%
mul-1-neg17.7%
*-commutative17.7%
associate-/l*18.8%
associate--l+19.2%
unpow219.2%
unpow219.2%
hypot-undefine26.2%
cancel-sign-sub-inv26.2%
Simplified26.2%
Taylor expanded in B around inf 17.4%
Final simplification17.4%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (* (sqrt (/ F C)) (- (sqrt -1.0))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return sqrt((F / C)) * -sqrt(-1.0);
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = sqrt((f / c)) * -sqrt((-1.0d0))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return Math.sqrt((F / C)) * -Math.sqrt(-1.0);
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return math.sqrt((F / C)) * -math.sqrt(-1.0)
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(sqrt(Float64(F / C)) * Float64(-sqrt(-1.0))) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = sqrt((F / C)) * -sqrt(-1.0);
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[(N[Sqrt[N[(F / C), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[-1.0], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\sqrt{\frac{F}{C}} \cdot \left(-\sqrt{-1}\right)
\end{array}
Initial program 19.7%
Simplified19.4%
Taylor expanded in C around inf 14.9%
associate-*r*15.6%
*-commutative15.6%
mul-1-neg15.6%
Simplified15.6%
Taylor expanded in C around -inf 0.0%
mul-1-neg0.0%
Simplified0.0%
Final simplification0.0%
herbie shell --seed 2024103
(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))))