
(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 11 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
(let* ((t_0
(*
(sqrt (* F (/ (+ -1.0 (+ (/ A B_m) (/ C B_m))) B_m)))
(- (sqrt 2.0))))
(t_1 (* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C)))))))
(if (<= F -2.4e+261)
t_1
(if (<= F -1.2e+180)
t_0
(if (<= F -9.8e+138)
t_1
(if (<= F -9.2e+24)
t_0
(if (<= F -2.2e-37)
t_1
(if (<= F -5e-310)
(* (sqrt (* F (- A (hypot B_m A)))) (/ (sqrt 2.0) (- B_m)))
(/
(sqrt (* -8.0 (* (* A C) (* F (+ A A)))))
(- (fma C (* A -4.0) (pow B_m 2.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) {
double t_0 = sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -sqrt(2.0);
double t_1 = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
double tmp;
if (F <= -2.4e+261) {
tmp = t_1;
} else if (F <= -1.2e+180) {
tmp = t_0;
} else if (F <= -9.8e+138) {
tmp = t_1;
} else if (F <= -9.2e+24) {
tmp = t_0;
} else if (F <= -2.2e-37) {
tmp = t_1;
} else if (F <= -5e-310) {
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
} else {
tmp = sqrt((-8.0 * ((A * C) * (F * (A + A))))) / -fma(C, (A * -4.0), pow(B_m, 2.0));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(sqrt(Float64(F * Float64(Float64(-1.0 + Float64(Float64(A / B_m) + Float64(C / B_m))) / B_m))) * Float64(-sqrt(2.0))) t_1 = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))) tmp = 0.0 if (F <= -2.4e+261) tmp = t_1; elseif (F <= -1.2e+180) tmp = t_0; elseif (F <= -9.8e+138) tmp = t_1; elseif (F <= -9.2e+24) tmp = t_0; elseif (F <= -2.2e-37) tmp = t_1; elseif (F <= -5e-310) tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * Float64(sqrt(2.0) / Float64(-B_m))); else tmp = Float64(sqrt(Float64(-8.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))) / Float64(-fma(C, Float64(A * -4.0), (B_m ^ 2.0)))); 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_] := Block[{t$95$0 = N[(N[Sqrt[N[(F * N[(N[(-1.0 + N[(N[(A / B$95$m), $MachinePrecision] + N[(C / B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[F, -2.4e+261], t$95$1, If[LessEqual[F, -1.2e+180], t$95$0, If[LessEqual[F, -9.8e+138], t$95$1, If[LessEqual[F, -9.2e+24], t$95$0, If[LessEqual[F, -2.2e-37], t$95$1, If[LessEqual[F, -5e-310], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(-8.0 * N[(N[(A * C), $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]]]]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \sqrt{F \cdot \frac{-1 + \left(\frac{A}{B\_m} + \frac{C}{B\_m}\right)}{B\_m}} \cdot \left(-\sqrt{2}\right)\\
t_1 := \sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\mathbf{if}\;F \leq -2.4 \cdot 10^{+261}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;F \leq -1.2 \cdot 10^{+180}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;F \leq -9.8 \cdot 10^{+138}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;F \leq -9.2 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;F \leq -2.2 \cdot 10^{-37}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;F \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{-8 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{-\mathsf{fma}\left(C, A \cdot -4, {B\_m}^{2}\right)}\\
\end{array}
\end{array}
if F < -2.3999999999999998e261 or -1.1999999999999999e180 < F < -9.79999999999999966e138 or -9.1999999999999996e24 < F < -2.20000000000000002e-37Initial program 13.5%
Taylor expanded in F around 0 10.6%
mul-1-neg10.6%
*-commutative10.6%
associate-/l*12.3%
associate--l+13.2%
unpow213.2%
unpow213.2%
hypot-undefine25.7%
cancel-sign-sub-inv25.7%
Simplified25.7%
Taylor expanded in A around -inf 29.7%
if -2.3999999999999998e261 < F < -1.1999999999999999e180 or -9.79999999999999966e138 < F < -9.1999999999999996e24Initial program 15.6%
Taylor expanded in F around 0 18.0%
mul-1-neg18.0%
*-commutative18.0%
associate-/l*21.7%
associate--l+21.8%
unpow221.8%
unpow221.8%
hypot-undefine32.6%
cancel-sign-sub-inv32.6%
Simplified32.6%
Taylor expanded in B around inf 26.3%
if -2.20000000000000002e-37 < F < -4.999999999999985e-310Initial program 18.0%
Taylor expanded in C around 0 10.0%
mul-1-neg10.0%
+-commutative10.0%
unpow210.0%
unpow210.0%
hypot-define29.6%
Simplified29.6%
if -4.999999999999985e-310 < F Initial program 24.5%
Simplified30.6%
Taylor expanded in C around inf 21.6%
associate-*r*21.7%
*-commutative21.7%
mul-1-neg21.7%
Simplified21.7%
Final simplification27.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
(let* ((t_0 (* (* 4.0 A) C))
(t_1 (+ A (- C (hypot B_m (- A C)))))
(t_2 (fma B_m B_m (* A (* C -4.0))))
(t_3 (* F t_2))
(t_4
(/
(sqrt
(*
(* 2.0 (* (- (pow B_m 2.0) t_0) F))
(- (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0))))))
(- t_0 (pow B_m 2.0))))
(t_5 (- t_2)))
(if (<= t_4 (- INFINITY))
(* (sqrt (* F (/ t_1 (+ (pow B_m 2.0) (* -4.0 (* A C)))))) (- (sqrt 2.0)))
(if (<= t_4 -5e-225)
(/ (sqrt (* t_3 (* 2.0 t_1))) t_5)
(if (<= t_4 INFINITY)
(/
(sqrt (* t_3 (* 2.0 (+ A (+ A (/ (* (pow B_m 2.0) -0.5) C))))))
t_5)
(* (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 t_0 = (4.0 * A) * C;
double t_1 = A + (C - hypot(B_m, (A - C)));
double t_2 = fma(B_m, B_m, (A * (C * -4.0)));
double t_3 = F * t_2;
double t_4 = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * ((A + C) - sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / (t_0 - pow(B_m, 2.0));
double t_5 = -t_2;
double tmp;
if (t_4 <= -((double) INFINITY)) {
tmp = sqrt((F * (t_1 / (pow(B_m, 2.0) + (-4.0 * (A * C)))))) * -sqrt(2.0);
} else if (t_4 <= -5e-225) {
tmp = sqrt((t_3 * (2.0 * t_1))) / t_5;
} else if (t_4 <= ((double) INFINITY)) {
tmp = sqrt((t_3 * (2.0 * (A + (A + ((pow(B_m, 2.0) * -0.5) / C)))))) / t_5;
} else {
tmp = sqrt(2.0) * -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) t_0 = Float64(Float64(4.0 * A) * C) t_1 = Float64(A + Float64(C - hypot(B_m, Float64(A - C)))) t_2 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_3 = Float64(F * t_2) t_4 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(Float64(A + C) - sqrt(Float64((B_m ^ 2.0) + (Float64(A - C) ^ 2.0)))))) / Float64(t_0 - (B_m ^ 2.0))) t_5 = Float64(-t_2) tmp = 0.0 if (t_4 <= Float64(-Inf)) tmp = Float64(sqrt(Float64(F * Float64(t_1 / Float64((B_m ^ 2.0) + Float64(-4.0 * Float64(A * C)))))) * Float64(-sqrt(2.0))); elseif (t_4 <= -5e-225) tmp = Float64(sqrt(Float64(t_3 * Float64(2.0 * t_1))) / t_5); elseif (t_4 <= Inf) tmp = Float64(sqrt(Float64(t_3 * Float64(2.0 * Float64(A + Float64(A + Float64(Float64((B_m ^ 2.0) * -0.5) / C)))))) / t_5); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-1.0 / B_m))))); 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_] := Block[{t$95$0 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[(A + N[(C - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(F * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = (-t$95$2)}, If[LessEqual[t$95$4, (-Infinity)], N[(N[Sqrt[N[(F * N[(t$95$1 / N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$4, -5e-225], N[(N[Sqrt[N[(t$95$3 * N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$5), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(N[Sqrt[N[(t$95$3 * N[(2.0 * N[(A + N[(A + N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] * -0.5), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$5), $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}
t_0 := \left(4 \cdot A\right) \cdot C\\
t_1 := A + \left(C - \mathsf{hypot}\left(B\_m, A - C\right)\right)\\
t_2 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
t_3 := F \cdot t\_2\\
t_4 := \frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B\_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t\_0 - {B\_m}^{2}}\\
t_5 := -t\_2\\
\mathbf{if}\;t\_4 \leq -\infty:\\
\;\;\;\;\sqrt{F \cdot \frac{t\_1}{{B\_m}^{2} + -4 \cdot \left(A \cdot C\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;t\_4 \leq -5 \cdot 10^{-225}:\\
\;\;\;\;\frac{\sqrt{t\_3 \cdot \left(2 \cdot t\_1\right)}}{t\_5}\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;\frac{\sqrt{t\_3 \cdot \left(2 \cdot \left(A + \left(A + \frac{{B\_m}^{2} \cdot -0.5}{C}\right)\right)\right)}}{t\_5}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-1}{B\_m}}\right)\\
\end{array}
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -inf.0Initial program 3.5%
Taylor expanded in F around 0 16.9%
mul-1-neg16.9%
*-commutative16.9%
associate-/l*23.6%
associate--l+23.6%
unpow223.6%
unpow223.6%
hypot-undefine55.3%
cancel-sign-sub-inv55.3%
Simplified55.3%
Taylor expanded in C around 0 55.3%
if -inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -5.0000000000000001e-225Initial program 97.3%
Simplified97.3%
if -5.0000000000000001e-225 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < +inf.0Initial program 17.7%
Simplified33.0%
Taylor expanded in C around inf 23.6%
associate-*r/23.6%
mul-1-neg23.6%
Simplified23.6%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) Initial program 0.0%
Taylor expanded in F around 0 0.1%
mul-1-neg0.1%
*-commutative0.1%
associate-/l*0.2%
associate--l+0.5%
unpow20.5%
unpow20.5%
hypot-undefine4.3%
cancel-sign-sub-inv4.3%
Simplified4.3%
Taylor expanded in B around inf 18.0%
Final simplification37.9%
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
(let* ((t_0 (* (* 4.0 A) C)) (t_1 (- (sqrt 2.0))))
(if (<= (pow B_m 2.0) 1e-158)
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (* 2.0 A)))
(- t_0 (pow B_m 2.0)))
(if (<= (pow B_m 2.0) 2e+303)
(*
(sqrt
(*
F
(/
(+ A (- C (hypot B_m (- A C))))
(+ (pow B_m 2.0) (* -4.0 (* A C))))))
t_1)
(* (sqrt (* F (/ (+ -1.0 (+ (/ A B_m) (/ C B_m))) B_m))) t_1)))))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 t_0 = (4.0 * A) * C;
double t_1 = -sqrt(2.0);
double tmp;
if (pow(B_m, 2.0) <= 1e-158) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - pow(B_m, 2.0));
} else if (pow(B_m, 2.0) <= 2e+303) {
tmp = sqrt((F * ((A + (C - hypot(B_m, (A - C)))) / (pow(B_m, 2.0) + (-4.0 * (A * C)))))) * t_1;
} else {
tmp = sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * t_1;
}
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 t_0 = (4.0 * A) * C;
double t_1 = -Math.sqrt(2.0);
double tmp;
if (Math.pow(B_m, 2.0) <= 1e-158) {
tmp = Math.sqrt(((2.0 * ((Math.pow(B_m, 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - Math.pow(B_m, 2.0));
} else if (Math.pow(B_m, 2.0) <= 2e+303) {
tmp = Math.sqrt((F * ((A + (C - Math.hypot(B_m, (A - C)))) / (Math.pow(B_m, 2.0) + (-4.0 * (A * C)))))) * t_1;
} else {
tmp = Math.sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * t_1;
}
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): t_0 = (4.0 * A) * C t_1 = -math.sqrt(2.0) tmp = 0 if math.pow(B_m, 2.0) <= 1e-158: tmp = math.sqrt(((2.0 * ((math.pow(B_m, 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - math.pow(B_m, 2.0)) elif math.pow(B_m, 2.0) <= 2e+303: tmp = math.sqrt((F * ((A + (C - math.hypot(B_m, (A - C)))) / (math.pow(B_m, 2.0) + (-4.0 * (A * C)))))) * t_1 else: tmp = math.sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * t_1 return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(Float64(4.0 * A) * C) t_1 = Float64(-sqrt(2.0)) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-158) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(2.0 * A))) / Float64(t_0 - (B_m ^ 2.0))); elseif ((B_m ^ 2.0) <= 2e+303) tmp = Float64(sqrt(Float64(F * Float64(Float64(A + Float64(C - hypot(B_m, Float64(A - C)))) / Float64((B_m ^ 2.0) + Float64(-4.0 * Float64(A * C)))))) * t_1); else tmp = Float64(sqrt(Float64(F * Float64(Float64(-1.0 + Float64(Float64(A / B_m) + Float64(C / B_m))) / B_m))) * t_1); 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)
t_0 = (4.0 * A) * C;
t_1 = -sqrt(2.0);
tmp = 0.0;
if ((B_m ^ 2.0) <= 1e-158)
tmp = sqrt(((2.0 * (((B_m ^ 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - (B_m ^ 2.0));
elseif ((B_m ^ 2.0) <= 2e+303)
tmp = sqrt((F * ((A + (C - hypot(B_m, (A - C)))) / ((B_m ^ 2.0) + (-4.0 * (A * C)))))) * t_1;
else
tmp = sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * t_1;
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_] := Block[{t$95$0 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = (-N[Sqrt[2.0], $MachinePrecision])}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-158], N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+303], N[(N[Sqrt[N[(F * N[(N[(A + N[(C - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[Sqrt[N[(F * N[(N[(-1.0 + N[(N[(A / B$95$m), $MachinePrecision] + N[(C / B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \left(4 \cdot A\right) \cdot C\\
t_1 := -\sqrt{2}\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-158}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(2 \cdot A\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+303}:\\
\;\;\;\;\sqrt{F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B\_m, A - C\right)\right)}{{B\_m}^{2} + -4 \cdot \left(A \cdot C\right)}} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \frac{-1 + \left(\frac{A}{B\_m} + \frac{C}{B\_m}\right)}{B\_m}} \cdot t\_1\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 1.00000000000000006e-158Initial program 18.5%
Taylor expanded in A around -inf 20.2%
if 1.00000000000000006e-158 < (pow.f64 B #s(literal 2 binary64)) < 2e303Initial program 28.7%
Taylor expanded in F around 0 29.5%
mul-1-neg29.5%
*-commutative29.5%
associate-/l*34.9%
associate--l+34.8%
unpow234.8%
unpow234.8%
hypot-undefine46.8%
cancel-sign-sub-inv46.8%
Simplified46.8%
Taylor expanded in C around 0 46.8%
if 2e303 < (pow.f64 B #s(literal 2 binary64)) Initial 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-undefine4.0%
cancel-sign-sub-inv4.0%
Simplified4.0%
Taylor expanded in B around inf 28.5%
Final simplification31.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
(let* ((t_0 (* (* 4.0 A) C)))
(if (<= (pow B_m 2.0) 5e-49)
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (* 2.0 A)))
(- t_0 (pow B_m 2.0)))
(if (<= (pow B_m 2.0) 2e+303)
(*
(sqrt 2.0)
(- (sqrt (* F (/ (+ A (- C (hypot B_m (- A C)))) (pow B_m 2.0))))))
(*
(sqrt (* F (/ (+ -1.0 (+ (/ A B_m) (/ C B_m))) B_m)))
(- (sqrt 2.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) {
double t_0 = (4.0 * A) * C;
double tmp;
if (pow(B_m, 2.0) <= 5e-49) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - pow(B_m, 2.0));
} else if (pow(B_m, 2.0) <= 2e+303) {
tmp = sqrt(2.0) * -sqrt((F * ((A + (C - hypot(B_m, (A - C)))) / pow(B_m, 2.0))));
} else {
tmp = sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -sqrt(2.0);
}
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 t_0 = (4.0 * A) * C;
double tmp;
if (Math.pow(B_m, 2.0) <= 5e-49) {
tmp = Math.sqrt(((2.0 * ((Math.pow(B_m, 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - Math.pow(B_m, 2.0));
} else if (Math.pow(B_m, 2.0) <= 2e+303) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * ((A + (C - Math.hypot(B_m, (A - C)))) / Math.pow(B_m, 2.0))));
} else {
tmp = Math.sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -Math.sqrt(2.0);
}
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): t_0 = (4.0 * A) * C tmp = 0 if math.pow(B_m, 2.0) <= 5e-49: tmp = math.sqrt(((2.0 * ((math.pow(B_m, 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - math.pow(B_m, 2.0)) elif math.pow(B_m, 2.0) <= 2e+303: tmp = math.sqrt(2.0) * -math.sqrt((F * ((A + (C - math.hypot(B_m, (A - C)))) / math.pow(B_m, 2.0)))) else: tmp = math.sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -math.sqrt(2.0) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(Float64(4.0 * A) * C) tmp = 0.0 if ((B_m ^ 2.0) <= 5e-49) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(2.0 * A))) / Float64(t_0 - (B_m ^ 2.0))); elseif ((B_m ^ 2.0) <= 2e+303) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(Float64(A + Float64(C - hypot(B_m, Float64(A - C)))) / (B_m ^ 2.0)))))); else tmp = Float64(sqrt(Float64(F * Float64(Float64(-1.0 + Float64(Float64(A / B_m) + Float64(C / B_m))) / B_m))) * Float64(-sqrt(2.0))); 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)
t_0 = (4.0 * A) * C;
tmp = 0.0;
if ((B_m ^ 2.0) <= 5e-49)
tmp = sqrt(((2.0 * (((B_m ^ 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - (B_m ^ 2.0));
elseif ((B_m ^ 2.0) <= 2e+303)
tmp = sqrt(2.0) * -sqrt((F * ((A + (C - hypot(B_m, (A - C)))) / (B_m ^ 2.0))));
else
tmp = sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -sqrt(2.0);
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_] := Block[{t$95$0 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-49], N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+303], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(N[(A + N[(C - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[N[(F * N[(N[(-1.0 + N[(N[(A / B$95$m), $MachinePrecision] + N[(C / B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $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}
t_0 := \left(4 \cdot A\right) \cdot C\\
\mathbf{if}\;{B\_m}^{2} \leq 5 \cdot 10^{-49}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(2 \cdot A\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+303}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B\_m, A - C\right)\right)}{{B\_m}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \frac{-1 + \left(\frac{A}{B\_m} + \frac{C}{B\_m}\right)}{B\_m}} \cdot \left(-\sqrt{2}\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 4.9999999999999999e-49Initial program 21.8%
Taylor expanded in A around -inf 19.2%
if 4.9999999999999999e-49 < (pow.f64 B #s(literal 2 binary64)) < 2e303Initial program 26.0%
Taylor expanded in F around 0 29.7%
mul-1-neg29.7%
*-commutative29.7%
associate-/l*35.2%
associate--l+35.1%
unpow235.1%
unpow235.1%
hypot-undefine47.5%
cancel-sign-sub-inv47.5%
Simplified47.5%
Taylor expanded in C around 0 42.8%
if 2e303 < (pow.f64 B #s(literal 2 binary64)) Initial 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-undefine4.0%
cancel-sign-sub-inv4.0%
Simplified4.0%
Taylor expanded in B around inf 28.5%
Final simplification28.3%
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
(let* ((t_0 (* (* 4.0 A) C)))
(if (<= B_m 1.04e-20)
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (* 2.0 A)))
(- t_0 (pow B_m 2.0)))
(if (or (<= B_m 8e+211) (and (not (<= B_m 1.4e+263)) (<= B_m 5.2e+287)))
(* (sqrt (* F (- A (hypot B_m A)))) (/ (sqrt 2.0) (- B_m)))
(*
(sqrt (* F (/ (+ -1.0 (+ (/ A B_m) (/ C B_m))) B_m)))
(- (sqrt 2.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) {
double t_0 = (4.0 * A) * C;
double tmp;
if (B_m <= 1.04e-20) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - pow(B_m, 2.0));
} else if ((B_m <= 8e+211) || (!(B_m <= 1.4e+263) && (B_m <= 5.2e+287))) {
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
} else {
tmp = sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -sqrt(2.0);
}
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 t_0 = (4.0 * A) * C;
double tmp;
if (B_m <= 1.04e-20) {
tmp = Math.sqrt(((2.0 * ((Math.pow(B_m, 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - Math.pow(B_m, 2.0));
} else if ((B_m <= 8e+211) || (!(B_m <= 1.4e+263) && (B_m <= 5.2e+287))) {
tmp = Math.sqrt((F * (A - Math.hypot(B_m, A)))) * (Math.sqrt(2.0) / -B_m);
} else {
tmp = Math.sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -Math.sqrt(2.0);
}
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): t_0 = (4.0 * A) * C tmp = 0 if B_m <= 1.04e-20: tmp = math.sqrt(((2.0 * ((math.pow(B_m, 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - math.pow(B_m, 2.0)) elif (B_m <= 8e+211) or (not (B_m <= 1.4e+263) and (B_m <= 5.2e+287)): tmp = math.sqrt((F * (A - math.hypot(B_m, A)))) * (math.sqrt(2.0) / -B_m) else: tmp = math.sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -math.sqrt(2.0) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(Float64(4.0 * A) * C) tmp = 0.0 if (B_m <= 1.04e-20) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(2.0 * A))) / Float64(t_0 - (B_m ^ 2.0))); elseif ((B_m <= 8e+211) || (!(B_m <= 1.4e+263) && (B_m <= 5.2e+287))) tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * Float64(sqrt(2.0) / Float64(-B_m))); else tmp = Float64(sqrt(Float64(F * Float64(Float64(-1.0 + Float64(Float64(A / B_m) + Float64(C / B_m))) / B_m))) * Float64(-sqrt(2.0))); 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)
t_0 = (4.0 * A) * C;
tmp = 0.0;
if (B_m <= 1.04e-20)
tmp = sqrt(((2.0 * (((B_m ^ 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - (B_m ^ 2.0));
elseif ((B_m <= 8e+211) || (~((B_m <= 1.4e+263)) && (B_m <= 5.2e+287)))
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
else
tmp = sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -sqrt(2.0);
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_] := Block[{t$95$0 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, If[LessEqual[B$95$m, 1.04e-20], N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[B$95$m, 8e+211], And[N[Not[LessEqual[B$95$m, 1.4e+263]], $MachinePrecision], LessEqual[B$95$m, 5.2e+287]]], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(N[(-1.0 + N[(N[(A / B$95$m), $MachinePrecision] + N[(C / B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $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}
t_0 := \left(4 \cdot A\right) \cdot C\\
\mathbf{if}\;B\_m \leq 1.04 \cdot 10^{-20}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(2 \cdot A\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{elif}\;B\_m \leq 8 \cdot 10^{+211} \lor \neg \left(B\_m \leq 1.4 \cdot 10^{+263}\right) \land B\_m \leq 5.2 \cdot 10^{+287}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \frac{-1 + \left(\frac{A}{B\_m} + \frac{C}{B\_m}\right)}{B\_m}} \cdot \left(-\sqrt{2}\right)\\
\end{array}
\end{array}
if B < 1.04000000000000007e-20Initial program 19.9%
Taylor expanded in A around -inf 13.4%
if 1.04000000000000007e-20 < B < 7.9999999999999997e211 or 1.3999999999999999e263 < B < 5.2000000000000003e287Initial program 13.5%
Taylor expanded in C around 0 20.7%
mul-1-neg20.7%
+-commutative20.7%
unpow220.7%
unpow220.7%
hypot-define43.9%
Simplified43.9%
if 7.9999999999999997e211 < B < 1.3999999999999999e263 or 5.2000000000000003e287 < B Initial 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 78.1%
Final simplification25.1%
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 (<= C 6.2e-271)
(* (sqrt (* F (- A (hypot B_m A)))) (/ (sqrt 2.0) (- B_m)))
(if (or (<= C 1e-93) (and (not (<= C 1e+79)) (<= C 2.8e+135)))
(* (sqrt (* F (/ (+ -1.0 (+ (/ A B_m) (/ C B_m))) B_m))) (- (sqrt 2.0)))
(* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C))))))))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 (C <= 6.2e-271) {
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
} else if ((C <= 1e-93) || (!(C <= 1e+79) && (C <= 2.8e+135))) {
tmp = sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -sqrt(2.0);
} else {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
}
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 (C <= 6.2e-271) {
tmp = Math.sqrt((F * (A - Math.hypot(B_m, A)))) * (Math.sqrt(2.0) / -B_m);
} else if ((C <= 1e-93) || (!(C <= 1e+79) && (C <= 2.8e+135))) {
tmp = Math.sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -Math.sqrt(2.0);
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
}
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 C <= 6.2e-271: tmp = math.sqrt((F * (A - math.hypot(B_m, A)))) * (math.sqrt(2.0) / -B_m) elif (C <= 1e-93) or (not (C <= 1e+79) and (C <= 2.8e+135)): tmp = math.sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -math.sqrt(2.0) else: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) 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 (C <= 6.2e-271) tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * Float64(sqrt(2.0) / Float64(-B_m))); elseif ((C <= 1e-93) || (!(C <= 1e+79) && (C <= 2.8e+135))) tmp = Float64(sqrt(Float64(F * Float64(Float64(-1.0 + Float64(Float64(A / B_m) + Float64(C / B_m))) / B_m))) * Float64(-sqrt(2.0))); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); 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 (C <= 6.2e-271)
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
elseif ((C <= 1e-93) || (~((C <= 1e+79)) && (C <= 2.8e+135)))
tmp = sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -sqrt(2.0);
else
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
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[C, 6.2e-271], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[C, 1e-93], And[N[Not[LessEqual[C, 1e+79]], $MachinePrecision], LessEqual[C, 2.8e+135]]], N[(N[Sqrt[N[(F * N[(N[(-1.0 + N[(N[(A / B$95$m), $MachinePrecision] + N[(C / B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $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}\;C \leq 6.2 \cdot 10^{-271}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\mathbf{elif}\;C \leq 10^{-93} \lor \neg \left(C \leq 10^{+79}\right) \land C \leq 2.8 \cdot 10^{+135}:\\
\;\;\;\;\sqrt{F \cdot \frac{-1 + \left(\frac{A}{B\_m} + \frac{C}{B\_m}\right)}{B\_m}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\end{array}
\end{array}
if C < 6.1999999999999998e-271Initial program 21.3%
Taylor expanded in C around 0 9.8%
mul-1-neg9.8%
+-commutative9.8%
unpow29.8%
unpow29.8%
hypot-define18.2%
Simplified18.2%
if 6.1999999999999998e-271 < C < 9.999999999999999e-94 or 9.99999999999999967e78 < C < 2.80000000000000002e135Initial program 16.5%
Taylor expanded in F around 0 10.4%
mul-1-neg10.4%
*-commutative10.4%
associate-/l*10.4%
associate--l+11.0%
unpow211.0%
unpow211.0%
hypot-undefine15.2%
cancel-sign-sub-inv15.2%
Simplified15.2%
Taylor expanded in B around inf 23.3%
if 9.999999999999999e-94 < C < 9.99999999999999967e78 or 2.80000000000000002e135 < C Initial program 7.5%
Taylor expanded in F around 0 7.6%
mul-1-neg7.6%
*-commutative7.6%
associate-/l*9.2%
associate--l+9.8%
unpow29.8%
unpow29.8%
hypot-undefine23.4%
cancel-sign-sub-inv23.4%
Simplified23.4%
Taylor expanded in A around -inf 45.5%
Final simplification25.9%
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 (<= C -2.2e-235)
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- B_m)))))
(if (or (<= C 2.6e-94) (and (not (<= C 4.4e+77)) (<= C 3.5e+135)))
(* (sqrt (* F (/ (+ -1.0 (+ (/ A B_m) (/ C B_m))) B_m))) (- (sqrt 2.0)))
(* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C))))))))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 (C <= -2.2e-235) {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * -B_m));
} else if ((C <= 2.6e-94) || (!(C <= 4.4e+77) && (C <= 3.5e+135))) {
tmp = sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -sqrt(2.0);
} else {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
}
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 (c <= (-2.2d-235)) then
tmp = (sqrt(2.0d0) / b_m) * -sqrt((f * -b_m))
else if ((c <= 2.6d-94) .or. (.not. (c <= 4.4d+77)) .and. (c <= 3.5d+135)) then
tmp = sqrt((f * (((-1.0d0) + ((a / b_m) + (c / b_m))) / b_m))) * -sqrt(2.0d0)
else
tmp = sqrt(2.0d0) * -sqrt((f * ((-0.5d0) / c)))
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 (C <= -2.2e-235) {
tmp = (Math.sqrt(2.0) / B_m) * -Math.sqrt((F * -B_m));
} else if ((C <= 2.6e-94) || (!(C <= 4.4e+77) && (C <= 3.5e+135))) {
tmp = Math.sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -Math.sqrt(2.0);
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
}
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 C <= -2.2e-235: tmp = (math.sqrt(2.0) / B_m) * -math.sqrt((F * -B_m)) elif (C <= 2.6e-94) or (not (C <= 4.4e+77) and (C <= 3.5e+135)): tmp = math.sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -math.sqrt(2.0) else: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) 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 (C <= -2.2e-235) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(-B_m))))); elseif ((C <= 2.6e-94) || (!(C <= 4.4e+77) && (C <= 3.5e+135))) tmp = Float64(sqrt(Float64(F * Float64(Float64(-1.0 + Float64(Float64(A / B_m) + Float64(C / B_m))) / B_m))) * Float64(-sqrt(2.0))); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); 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 (C <= -2.2e-235)
tmp = (sqrt(2.0) / B_m) * -sqrt((F * -B_m));
elseif ((C <= 2.6e-94) || (~((C <= 4.4e+77)) && (C <= 3.5e+135)))
tmp = sqrt((F * ((-1.0 + ((A / B_m) + (C / B_m))) / B_m))) * -sqrt(2.0);
else
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
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[C, -2.2e-235], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * (-B$95$m)), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[Or[LessEqual[C, 2.6e-94], And[N[Not[LessEqual[C, 4.4e+77]], $MachinePrecision], LessEqual[C, 3.5e+135]]], N[(N[Sqrt[N[(F * N[(N[(-1.0 + N[(N[(A / B$95$m), $MachinePrecision] + N[(C / B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $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}\;C \leq -2.2 \cdot 10^{-235}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(-B\_m\right)}\right)\\
\mathbf{elif}\;C \leq 2.6 \cdot 10^{-94} \lor \neg \left(C \leq 4.4 \cdot 10^{+77}\right) \land C \leq 3.5 \cdot 10^{+135}:\\
\;\;\;\;\sqrt{F \cdot \frac{-1 + \left(\frac{A}{B\_m} + \frac{C}{B\_m}\right)}{B\_m}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\end{array}
\end{array}
if C < -2.19999999999999984e-235Initial program 21.7%
Taylor expanded in A around 0 11.4%
mul-1-neg11.4%
unpow211.4%
unpow211.4%
hypot-define18.4%
Simplified18.4%
Taylor expanded in C around 0 16.8%
associate-*r*16.8%
mul-1-neg16.8%
Simplified16.8%
if -2.19999999999999984e-235 < C < 2.59999999999999994e-94 or 4.4000000000000001e77 < C < 3.5000000000000003e135Initial program 17.6%
Taylor expanded in F around 0 13.8%
mul-1-neg13.8%
*-commutative13.8%
associate-/l*17.7%
associate--l+18.1%
unpow218.1%
unpow218.1%
hypot-undefine25.1%
cancel-sign-sub-inv25.1%
Simplified25.1%
Taylor expanded in B around inf 24.0%
if 2.59999999999999994e-94 < C < 4.4000000000000001e77 or 3.5000000000000003e135 < C Initial program 7.5%
Taylor expanded in F around 0 7.6%
mul-1-neg7.6%
*-commutative7.6%
associate-/l*9.2%
associate--l+9.8%
unpow29.8%
unpow29.8%
hypot-undefine23.4%
cancel-sign-sub-inv23.4%
Simplified23.4%
Taylor expanded in A around -inf 45.5%
Final simplification26.0%
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 (<= C -4e-238)
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- B_m)))))
(if (or (<= C 1.45e-93) (and (not (<= C 1e+79)) (<= C 2.8e+135)))
(* (sqrt 2.0) (- (sqrt (* F (/ -1.0 B_m)))))
(* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C))))))))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 (C <= -4e-238) {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * -B_m));
} else if ((C <= 1.45e-93) || (!(C <= 1e+79) && (C <= 2.8e+135))) {
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
} else {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
}
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 (c <= (-4d-238)) then
tmp = (sqrt(2.0d0) / b_m) * -sqrt((f * -b_m))
else if ((c <= 1.45d-93) .or. (.not. (c <= 1d+79)) .and. (c <= 2.8d+135)) then
tmp = sqrt(2.0d0) * -sqrt((f * ((-1.0d0) / b_m)))
else
tmp = sqrt(2.0d0) * -sqrt((f * ((-0.5d0) / c)))
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 (C <= -4e-238) {
tmp = (Math.sqrt(2.0) / B_m) * -Math.sqrt((F * -B_m));
} else if ((C <= 1.45e-93) || (!(C <= 1e+79) && (C <= 2.8e+135))) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-1.0 / B_m)));
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
}
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 C <= -4e-238: tmp = (math.sqrt(2.0) / B_m) * -math.sqrt((F * -B_m)) elif (C <= 1.45e-93) or (not (C <= 1e+79) and (C <= 2.8e+135)): tmp = math.sqrt(2.0) * -math.sqrt((F * (-1.0 / B_m))) else: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) 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 (C <= -4e-238) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(-B_m))))); elseif ((C <= 1.45e-93) || (!(C <= 1e+79) && (C <= 2.8e+135))) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-1.0 / B_m))))); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); 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 (C <= -4e-238)
tmp = (sqrt(2.0) / B_m) * -sqrt((F * -B_m));
elseif ((C <= 1.45e-93) || (~((C <= 1e+79)) && (C <= 2.8e+135)))
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
else
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
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[C, -4e-238], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * (-B$95$m)), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[Or[LessEqual[C, 1.45e-93], And[N[Not[LessEqual[C, 1e+79]], $MachinePrecision], LessEqual[C, 2.8e+135]]], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $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}\;C \leq -4 \cdot 10^{-238}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(-B\_m\right)}\right)\\
\mathbf{elif}\;C \leq 1.45 \cdot 10^{-93} \lor \neg \left(C \leq 10^{+79}\right) \land C \leq 2.8 \cdot 10^{+135}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-1}{B\_m}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\end{array}
\end{array}
if C < -4e-238Initial program 21.4%
Taylor expanded in A around 0 11.3%
mul-1-neg11.3%
unpow211.3%
unpow211.3%
hypot-define18.2%
Simplified18.2%
Taylor expanded in C around 0 16.6%
associate-*r*16.6%
mul-1-neg16.6%
Simplified16.6%
if -4e-238 < C < 1.4499999999999999e-93 or 9.99999999999999967e78 < C < 2.80000000000000002e135Initial program 18.1%
Taylor expanded in F around 0 14.2%
mul-1-neg14.2%
*-commutative14.2%
associate-/l*18.1%
associate--l+18.5%
unpow218.5%
unpow218.5%
hypot-undefine25.7%
cancel-sign-sub-inv25.7%
Simplified25.7%
Taylor expanded in B around inf 21.6%
if 1.4499999999999999e-93 < C < 9.99999999999999967e78 or 2.80000000000000002e135 < C Initial program 7.5%
Taylor expanded in F around 0 7.6%
mul-1-neg7.6%
*-commutative7.6%
associate-/l*9.2%
associate--l+9.8%
unpow29.8%
unpow29.8%
hypot-undefine23.4%
cancel-sign-sub-inv23.4%
Simplified23.4%
Taylor expanded in A around -inf 45.5%
Final simplification25.2%
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 (or (<= C 1.15e-92) (and (not (<= C 8.5e+78)) (<= C 2.8e+135))) (* (sqrt 2.0) (- (sqrt (* F (/ -1.0 B_m))))) (* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C)))))))
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 ((C <= 1.15e-92) || (!(C <= 8.5e+78) && (C <= 2.8e+135))) {
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
} else {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
}
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 ((c <= 1.15d-92) .or. (.not. (c <= 8.5d+78)) .and. (c <= 2.8d+135)) then
tmp = sqrt(2.0d0) * -sqrt((f * ((-1.0d0) / b_m)))
else
tmp = sqrt(2.0d0) * -sqrt((f * ((-0.5d0) / c)))
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 ((C <= 1.15e-92) || (!(C <= 8.5e+78) && (C <= 2.8e+135))) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-1.0 / B_m)));
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
}
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 (C <= 1.15e-92) or (not (C <= 8.5e+78) and (C <= 2.8e+135)): tmp = math.sqrt(2.0) * -math.sqrt((F * (-1.0 / B_m))) else: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) 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 ((C <= 1.15e-92) || (!(C <= 8.5e+78) && (C <= 2.8e+135))) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-1.0 / B_m))))); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); 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 ((C <= 1.15e-92) || (~((C <= 8.5e+78)) && (C <= 2.8e+135)))
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
else
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
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[Or[LessEqual[C, 1.15e-92], And[N[Not[LessEqual[C, 8.5e+78]], $MachinePrecision], LessEqual[C, 2.8e+135]]], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $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}\;C \leq 1.15 \cdot 10^{-92} \lor \neg \left(C \leq 8.5 \cdot 10^{+78}\right) \land C \leq 2.8 \cdot 10^{+135}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-1}{B\_m}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\end{array}
\end{array}
if C < 1.15000000000000008e-92 or 8.50000000000000079e78 < C < 2.80000000000000002e135Initial program 20.2%
Taylor expanded in F around 0 16.8%
mul-1-neg16.8%
*-commutative16.8%
associate-/l*18.8%
associate--l+19.0%
unpow219.0%
unpow219.0%
hypot-undefine26.2%
cancel-sign-sub-inv26.2%
Simplified26.2%
Taylor expanded in B around inf 17.2%
if 1.15000000000000008e-92 < C < 8.50000000000000079e78 or 2.80000000000000002e135 < C Initial program 7.5%
Taylor expanded in F around 0 7.6%
mul-1-neg7.6%
*-commutative7.6%
associate-/l*9.2%
associate--l+9.8%
unpow29.8%
unpow29.8%
hypot-undefine23.4%
cancel-sign-sub-inv23.4%
Simplified23.4%
Taylor expanded in A around -inf 45.5%
Final simplification24.3%
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 17.0%
Taylor expanded in F around 0 14.5%
mul-1-neg14.5%
*-commutative14.5%
associate-/l*16.4%
associate--l+16.7%
unpow216.7%
unpow216.7%
hypot-undefine25.5%
cancel-sign-sub-inv25.5%
Simplified25.5%
Taylor expanded in B around inf 14.0%
Final simplification14.0%
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 A)) (- (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 / A)) * -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 / a)) * -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 / A)) * -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 / A)) * -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 / A)) * 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 / A)) * -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 / A), $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}{A}} \cdot \left(-\sqrt{-1}\right)
\end{array}
Initial program 17.0%
Simplified18.1%
Taylor expanded in C around -inf 7.8%
associate-*r*7.4%
Simplified7.4%
Taylor expanded in A around -inf 0.0%
mul-1-neg0.0%
Simplified0.0%
Final simplification0.0%
herbie shell --seed 2024112
(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))))