
(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 (fma B_m B_m (* A (* C -4.0)))) (t_1 (- t_0)) (t_2 (* t_0 F)))
(if (<= (pow B_m 2.0) 5e-164)
(/ (sqrt (* t_2 (- (* C 4.0) (/ (pow B_m 2.0) A)))) t_1)
(if (<= (pow B_m 2.0) 5e-99)
(* (sqrt (* -0.5 (/ F A))) (- (sqrt 2.0)))
(if (<= (pow B_m 2.0) 1e+56)
(/ (* (sqrt (* 2.0 t_2)) (sqrt (+ A (+ C (hypot (- A C) B_m))))) t_1)
(*
(* (sqrt (+ C (hypot C B_m))) (sqrt F))
(/ -1.0 (/ 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 = fma(B_m, B_m, (A * (C * -4.0)));
double t_1 = -t_0;
double t_2 = t_0 * F;
double tmp;
if (pow(B_m, 2.0) <= 5e-164) {
tmp = sqrt((t_2 * ((C * 4.0) - (pow(B_m, 2.0) / A)))) / t_1;
} else if (pow(B_m, 2.0) <= 5e-99) {
tmp = sqrt((-0.5 * (F / A))) * -sqrt(2.0);
} else if (pow(B_m, 2.0) <= 1e+56) {
tmp = (sqrt((2.0 * t_2)) * sqrt((A + (C + hypot((A - C), B_m))))) / t_1;
} else {
tmp = (sqrt((C + hypot(C, B_m))) * sqrt(F)) * (-1.0 / (B_m / 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 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_1 = Float64(-t_0) t_2 = Float64(t_0 * F) tmp = 0.0 if ((B_m ^ 2.0) <= 5e-164) tmp = Float64(sqrt(Float64(t_2 * Float64(Float64(C * 4.0) - Float64((B_m ^ 2.0) / A)))) / t_1); elseif ((B_m ^ 2.0) <= 5e-99) tmp = Float64(sqrt(Float64(-0.5 * Float64(F / A))) * Float64(-sqrt(2.0))); elseif ((B_m ^ 2.0) <= 1e+56) tmp = Float64(Float64(sqrt(Float64(2.0 * t_2)) * sqrt(Float64(A + Float64(C + hypot(Float64(A - C), B_m))))) / t_1); else tmp = Float64(Float64(sqrt(Float64(C + hypot(C, B_m))) * sqrt(F)) * Float64(-1.0 / Float64(B_m / sqrt(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[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = (-t$95$0)}, Block[{t$95$2 = N[(t$95$0 * F), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-164], N[(N[Sqrt[N[(t$95$2 * N[(N[(C * 4.0), $MachinePrecision] - N[(N[Power[B$95$m, 2.0], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-99], N[(N[Sqrt[N[(-0.5 * N[(F / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+56], N[(N[(N[Sqrt[N[(2.0 * t$95$2), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(A + N[(C + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(N[Sqrt[N[(C + N[Sqrt[C ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(B$95$m / N[Sqrt[2.0], $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 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := -t\_0\\
t_2 := t\_0 \cdot F\\
\mathbf{if}\;{B\_m}^{2} \leq 5 \cdot 10^{-164}:\\
\;\;\;\;\frac{\sqrt{t\_2 \cdot \left(C \cdot 4 - \frac{{B\_m}^{2}}{A}\right)}}{t\_1}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{-99}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{F}{A}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{+56}:\\
\;\;\;\;\frac{\sqrt{2 \cdot t\_2} \cdot \sqrt{A + \left(C + \mathsf{hypot}\left(A - C, B\_m\right)\right)}}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{C + \mathsf{hypot}\left(C, B\_m\right)} \cdot \sqrt{F}\right) \cdot \frac{-1}{\frac{B\_m}{\sqrt{2}}}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999962e-164Initial program 19.7%
Simplified30.6%
Taylor expanded in A around -inf 20.3%
if 4.99999999999999962e-164 < (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999969e-99Initial program 19.1%
Taylor expanded in F around 0 28.2%
mul-1-neg28.2%
*-commutative28.2%
cancel-sign-sub-inv28.2%
metadata-eval28.2%
+-commutative28.2%
Simplified36.7%
Taylor expanded in A around -inf 44.0%
if 4.99999999999999969e-99 < (pow.f64 B #s(literal 2 binary64)) < 1.00000000000000009e56Initial program 54.3%
Simplified64.5%
associate-*r*64.5%
associate-+r+64.5%
hypot-undefine54.3%
unpow254.3%
unpow254.3%
+-commutative54.3%
sqrt-prod54.2%
*-commutative54.2%
associate-+l+54.0%
Applied egg-rr74.6%
if 1.00000000000000009e56 < (pow.f64 B #s(literal 2 binary64)) Initial program 11.9%
Taylor expanded in A around 0 10.7%
mul-1-neg10.7%
*-commutative10.7%
*-commutative10.7%
+-commutative10.7%
unpow210.7%
unpow210.7%
hypot-define23.4%
Simplified23.4%
sqrt-prod32.9%
Applied egg-rr32.9%
clear-num32.9%
inv-pow32.9%
Applied egg-rr32.9%
unpow-132.9%
Simplified32.9%
Final simplification33.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
(let* ((t_0 (fma B_m B_m (* A (* C -4.0)))))
(if (<= (pow B_m 2.0) 5e-164)
(/ (sqrt (* (* t_0 F) (- (* C 4.0) (/ (pow B_m 2.0) A)))) (- t_0))
(if (<= (pow B_m 2.0) 5e+198)
(*
(sqrt
(*
F
(/
(+ (+ A C) (hypot B_m (- A C)))
(fma -4.0 (* A C) (pow B_m 2.0)))))
(- (sqrt 2.0)))
(*
(* (sqrt (+ C (hypot C B_m))) (sqrt F))
(/ (exp (* (log 2.0) 0.5)) (- 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 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (pow(B_m, 2.0) <= 5e-164) {
tmp = sqrt(((t_0 * F) * ((C * 4.0) - (pow(B_m, 2.0) / A)))) / -t_0;
} else if (pow(B_m, 2.0) <= 5e+198) {
tmp = sqrt((F * (((A + C) + hypot(B_m, (A - C))) / fma(-4.0, (A * C), pow(B_m, 2.0))))) * -sqrt(2.0);
} else {
tmp = (sqrt((C + hypot(C, B_m))) * sqrt(F)) * (exp((log(2.0) * 0.5)) / -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 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 5e-164) tmp = Float64(sqrt(Float64(Float64(t_0 * F) * Float64(Float64(C * 4.0) - Float64((B_m ^ 2.0) / A)))) / Float64(-t_0)); elseif ((B_m ^ 2.0) <= 5e+198) tmp = Float64(sqrt(Float64(F * Float64(Float64(Float64(A + C) + hypot(B_m, Float64(A - C))) / fma(-4.0, Float64(A * C), (B_m ^ 2.0))))) * Float64(-sqrt(2.0))); else tmp = Float64(Float64(sqrt(Float64(C + hypot(C, B_m))) * sqrt(F)) * Float64(exp(Float64(log(2.0) * 0.5)) / Float64(-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[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-164], N[(N[Sqrt[N[(N[(t$95$0 * F), $MachinePrecision] * N[(N[(C * 4.0), $MachinePrecision] - N[(N[Power[B$95$m, 2.0], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+198], N[(N[Sqrt[N[(F * N[(N[(N[(A + C), $MachinePrecision] + N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[(-4.0 * N[(A * C), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[N[(C + N[Sqrt[C ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(N[Log[2.0], $MachinePrecision] * 0.5), $MachinePrecision]], $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}
t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 5 \cdot 10^{-164}:\\
\;\;\;\;\frac{\sqrt{\left(t\_0 \cdot F\right) \cdot \left(C \cdot 4 - \frac{{B\_m}^{2}}{A}\right)}}{-t\_0}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+198}:\\
\;\;\;\;\sqrt{F \cdot \frac{\left(A + C\right) + \mathsf{hypot}\left(B\_m, A - C\right)}{\mathsf{fma}\left(-4, A \cdot C, {B\_m}^{2}\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{C + \mathsf{hypot}\left(C, B\_m\right)} \cdot \sqrt{F}\right) \cdot \frac{e^{\log 2 \cdot 0.5}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999962e-164Initial program 19.7%
Simplified30.6%
Taylor expanded in A around -inf 20.3%
if 4.99999999999999962e-164 < (pow.f64 B #s(literal 2 binary64)) < 5.00000000000000049e198Initial program 41.3%
Taylor expanded in F around 0 45.2%
Simplified57.7%
if 5.00000000000000049e198 < (pow.f64 B #s(literal 2 binary64)) Initial program 4.7%
Taylor expanded in A around 0 7.9%
mul-1-neg7.9%
*-commutative7.9%
*-commutative7.9%
+-commutative7.9%
unpow27.9%
unpow27.9%
hypot-define24.2%
Simplified24.2%
sqrt-prod34.4%
Applied egg-rr34.4%
pow1/234.4%
pow-to-exp34.3%
Applied egg-rr34.3%
Final simplification35.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 (fma B_m B_m (* A (* C -4.0)))))
(if (<= (pow B_m 2.0) 5e-164)
(/ (sqrt (* (* t_0 F) (- (* C 4.0) (/ (pow B_m 2.0) A)))) (- t_0))
(if (<= (pow B_m 2.0) 5e-12)
(* (sqrt (* -0.5 (/ F A))) (- (sqrt 2.0)))
(* (* (sqrt (+ C (hypot C B_m))) (sqrt F)) (/ (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 t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (pow(B_m, 2.0) <= 5e-164) {
tmp = sqrt(((t_0 * F) * ((C * 4.0) - (pow(B_m, 2.0) / A)))) / -t_0;
} else if (pow(B_m, 2.0) <= 5e-12) {
tmp = sqrt((-0.5 * (F / A))) * -sqrt(2.0);
} else {
tmp = (sqrt((C + hypot(C, B_m))) * sqrt(F)) * (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) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 5e-164) tmp = Float64(sqrt(Float64(Float64(t_0 * F) * Float64(Float64(C * 4.0) - Float64((B_m ^ 2.0) / A)))) / Float64(-t_0)); elseif ((B_m ^ 2.0) <= 5e-12) tmp = Float64(sqrt(Float64(-0.5 * Float64(F / A))) * Float64(-sqrt(2.0))); else tmp = Float64(Float64(sqrt(Float64(C + hypot(C, B_m))) * sqrt(F)) * Float64(sqrt(2.0) / Float64(-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[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-164], N[(N[Sqrt[N[(N[(t$95$0 * F), $MachinePrecision] * N[(N[(C * 4.0), $MachinePrecision] - N[(N[Power[B$95$m, 2.0], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-12], N[(N[Sqrt[N[(-0.5 * N[(F / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[N[(C + N[Sqrt[C ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[F], $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}
t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 5 \cdot 10^{-164}:\\
\;\;\;\;\frac{\sqrt{\left(t\_0 \cdot F\right) \cdot \left(C \cdot 4 - \frac{{B\_m}^{2}}{A}\right)}}{-t\_0}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{F}{A}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{C + \mathsf{hypot}\left(C, B\_m\right)} \cdot \sqrt{F}\right) \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999962e-164Initial program 19.7%
Simplified30.6%
Taylor expanded in A around -inf 20.3%
if 4.99999999999999962e-164 < (pow.f64 B #s(literal 2 binary64)) < 4.9999999999999997e-12Initial program 33.6%
Taylor expanded in F around 0 34.0%
mul-1-neg34.0%
*-commutative34.0%
cancel-sign-sub-inv34.0%
metadata-eval34.0%
+-commutative34.0%
Simplified46.2%
Taylor expanded in A around -inf 34.3%
if 4.9999999999999997e-12 < (pow.f64 B #s(literal 2 binary64)) Initial program 17.2%
Taylor expanded in A around 0 13.3%
mul-1-neg13.3%
*-commutative13.3%
*-commutative13.3%
+-commutative13.3%
unpow213.3%
unpow213.3%
hypot-define24.7%
Simplified24.7%
sqrt-prod33.2%
Applied egg-rr33.2%
Final simplification28.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
(let* ((t_0 (fma B_m B_m (* A (* C -4.0)))))
(if (<= B_m 2e-164)
(/ (sqrt (* (* t_0 F) (* C 4.0))) (- t_0))
(if (<= B_m 8.6e-100)
(sqrt (/ F (- A)))
(if (<= B_m 6.2e-5)
(* (sqrt (* -0.5 (/ F A))) (- (sqrt 2.0)))
(*
(* (sqrt (+ C (hypot C B_m))) (sqrt F))
(/ (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 t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (B_m <= 2e-164) {
tmp = sqrt(((t_0 * F) * (C * 4.0))) / -t_0;
} else if (B_m <= 8.6e-100) {
tmp = sqrt((F / -A));
} else if (B_m <= 6.2e-5) {
tmp = sqrt((-0.5 * (F / A))) * -sqrt(2.0);
} else {
tmp = (sqrt((C + hypot(C, B_m))) * sqrt(F)) * (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) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (B_m <= 2e-164) tmp = Float64(sqrt(Float64(Float64(t_0 * F) * Float64(C * 4.0))) / Float64(-t_0)); elseif (B_m <= 8.6e-100) tmp = sqrt(Float64(F / Float64(-A))); elseif (B_m <= 6.2e-5) tmp = Float64(sqrt(Float64(-0.5 * Float64(F / A))) * Float64(-sqrt(2.0))); else tmp = Float64(Float64(sqrt(Float64(C + hypot(C, B_m))) * sqrt(F)) * Float64(sqrt(2.0) / Float64(-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[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 2e-164], N[(N[Sqrt[N[(N[(t$95$0 * F), $MachinePrecision] * N[(C * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[B$95$m, 8.6e-100], N[Sqrt[N[(F / (-A)), $MachinePrecision]], $MachinePrecision], If[LessEqual[B$95$m, 6.2e-5], N[(N[Sqrt[N[(-0.5 * N[(F / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[N[(C + N[Sqrt[C ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[F], $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}
t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;B\_m \leq 2 \cdot 10^{-164}:\\
\;\;\;\;\frac{\sqrt{\left(t\_0 \cdot F\right) \cdot \left(C \cdot 4\right)}}{-t\_0}\\
\mathbf{elif}\;B\_m \leq 8.6 \cdot 10^{-100}:\\
\;\;\;\;\sqrt{\frac{F}{-A}}\\
\mathbf{elif}\;B\_m \leq 6.2 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{F}{A}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{C + \mathsf{hypot}\left(C, B\_m\right)} \cdot \sqrt{F}\right) \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if B < 1.99999999999999992e-164Initial program 18.1%
Simplified24.6%
Taylor expanded in A around -inf 12.3%
*-commutative12.3%
Simplified12.3%
if 1.99999999999999992e-164 < B < 8.59999999999999997e-100Initial program 15.0%
Simplified24.2%
add-sqr-sqrt22.3%
sqrt-unprod22.5%
frac-times22.3%
Applied egg-rr22.4%
Taylor expanded in A around -inf 41.6%
associate-*r/41.6%
neg-mul-141.6%
Simplified41.6%
if 8.59999999999999997e-100 < B < 6.20000000000000027e-5Initial program 32.5%
Taylor expanded in F around 0 27.0%
mul-1-neg27.0%
*-commutative27.0%
cancel-sign-sub-inv27.0%
metadata-eval27.0%
+-commutative27.0%
Simplified40.3%
Taylor expanded in A around -inf 20.5%
if 6.20000000000000027e-5 < B Initial program 22.0%
Taylor expanded in A around 0 28.6%
mul-1-neg28.6%
*-commutative28.6%
*-commutative28.6%
+-commutative28.6%
unpow228.6%
unpow228.6%
hypot-define53.4%
Simplified53.4%
sqrt-prod72.7%
Applied egg-rr72.7%
Final simplification28.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 (fma B_m B_m (* A (* C -4.0)))))
(if (<= B_m 1.9e-164)
(/ (sqrt (* (* t_0 F) (* C 4.0))) (- t_0))
(if (<= B_m 7.8e-100)
(sqrt (/ F (- A)))
(if (<= B_m 3.3e-5)
(* (sqrt (* -0.5 (/ F A))) (- (sqrt 2.0)))
(if (<= B_m 1.65e+180)
(/ (sqrt (* 2.0 (* F (+ C (hypot C B_m))))) (- B_m))
(/ (sqrt (* 2.0 F)) (- (sqrt 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 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (B_m <= 1.9e-164) {
tmp = sqrt(((t_0 * F) * (C * 4.0))) / -t_0;
} else if (B_m <= 7.8e-100) {
tmp = sqrt((F / -A));
} else if (B_m <= 3.3e-5) {
tmp = sqrt((-0.5 * (F / A))) * -sqrt(2.0);
} else if (B_m <= 1.65e+180) {
tmp = sqrt((2.0 * (F * (C + hypot(C, B_m))))) / -B_m;
} else {
tmp = sqrt((2.0 * F)) / -sqrt(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 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (B_m <= 1.9e-164) tmp = Float64(sqrt(Float64(Float64(t_0 * F) * Float64(C * 4.0))) / Float64(-t_0)); elseif (B_m <= 7.8e-100) tmp = sqrt(Float64(F / Float64(-A))); elseif (B_m <= 3.3e-5) tmp = Float64(sqrt(Float64(-0.5 * Float64(F / A))) * Float64(-sqrt(2.0))); elseif (B_m <= 1.65e+180) tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(C + hypot(C, B_m))))) / Float64(-B_m)); else tmp = Float64(sqrt(Float64(2.0 * F)) / Float64(-sqrt(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[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 1.9e-164], N[(N[Sqrt[N[(N[(t$95$0 * F), $MachinePrecision] * N[(C * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[B$95$m, 7.8e-100], N[Sqrt[N[(F / (-A)), $MachinePrecision]], $MachinePrecision], If[LessEqual[B$95$m, 3.3e-5], N[(N[Sqrt[N[(-0.5 * N[(F / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[B$95$m, 1.65e+180], N[(N[Sqrt[N[(2.0 * N[(F * N[(C + N[Sqrt[C ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision], N[(N[Sqrt[N[(2.0 * F), $MachinePrecision]], $MachinePrecision] / (-N[Sqrt[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}
t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;B\_m \leq 1.9 \cdot 10^{-164}:\\
\;\;\;\;\frac{\sqrt{\left(t\_0 \cdot F\right) \cdot \left(C \cdot 4\right)}}{-t\_0}\\
\mathbf{elif}\;B\_m \leq 7.8 \cdot 10^{-100}:\\
\;\;\;\;\sqrt{\frac{F}{-A}}\\
\mathbf{elif}\;B\_m \leq 3.3 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{F}{A}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;B\_m \leq 1.65 \cdot 10^{+180}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(C + \mathsf{hypot}\left(C, B\_m\right)\right)\right)}}{-B\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot F}}{-\sqrt{B\_m}}\\
\end{array}
\end{array}
if B < 1.89999999999999995e-164Initial program 18.1%
Simplified24.6%
Taylor expanded in A around -inf 12.3%
*-commutative12.3%
Simplified12.3%
if 1.89999999999999995e-164 < B < 7.79999999999999955e-100Initial program 15.0%
Simplified24.2%
add-sqr-sqrt22.3%
sqrt-unprod22.5%
frac-times22.3%
Applied egg-rr22.4%
Taylor expanded in A around -inf 41.6%
associate-*r/41.6%
neg-mul-141.6%
Simplified41.6%
if 7.79999999999999955e-100 < B < 3.3000000000000003e-5Initial program 32.5%
Taylor expanded in F around 0 27.0%
mul-1-neg27.0%
*-commutative27.0%
cancel-sign-sub-inv27.0%
metadata-eval27.0%
+-commutative27.0%
Simplified40.3%
Taylor expanded in A around -inf 20.5%
if 3.3000000000000003e-5 < B < 1.64999999999999995e180Initial program 33.8%
Taylor expanded in A around 0 42.7%
mul-1-neg42.7%
*-commutative42.7%
*-commutative42.7%
+-commutative42.7%
unpow242.7%
unpow242.7%
hypot-define57.9%
Simplified57.9%
neg-sub057.9%
associate-*r/57.8%
pow1/257.8%
pow1/257.8%
pow-prod-down58.0%
Applied egg-rr58.0%
neg-sub058.0%
distribute-neg-frac258.0%
unpow1/258.0%
Simplified58.0%
if 1.64999999999999995e180 < B Initial program 0.0%
Taylor expanded in B around inf 55.8%
mul-1-neg55.8%
*-commutative55.8%
Simplified55.8%
*-commutative55.8%
pow1/255.8%
pow1/255.8%
pow-prod-down56.1%
Applied egg-rr56.1%
unpow1/256.1%
Simplified56.1%
associate-*l/56.1%
sqrt-div81.5%
Applied egg-rr81.5%
Final simplification27.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 (<= B_m 9.5e-100)
(sqrt (/ F (- A)))
(if (<= B_m 4.2e-6)
(* (sqrt (* -0.5 (/ F A))) (- (sqrt 2.0)))
(if (<= B_m 1.12e+180)
(/ (sqrt (* 2.0 (* F (+ C (hypot C B_m))))) (- B_m))
(/ (sqrt (* 2.0 F)) (- (sqrt 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.5e-100) {
tmp = sqrt((F / -A));
} else if (B_m <= 4.2e-6) {
tmp = sqrt((-0.5 * (F / A))) * -sqrt(2.0);
} else if (B_m <= 1.12e+180) {
tmp = sqrt((2.0 * (F * (C + hypot(C, B_m))))) / -B_m;
} else {
tmp = sqrt((2.0 * F)) / -sqrt(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.5e-100) {
tmp = Math.sqrt((F / -A));
} else if (B_m <= 4.2e-6) {
tmp = Math.sqrt((-0.5 * (F / A))) * -Math.sqrt(2.0);
} else if (B_m <= 1.12e+180) {
tmp = Math.sqrt((2.0 * (F * (C + Math.hypot(C, B_m))))) / -B_m;
} else {
tmp = Math.sqrt((2.0 * F)) / -Math.sqrt(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.5e-100: tmp = math.sqrt((F / -A)) elif B_m <= 4.2e-6: tmp = math.sqrt((-0.5 * (F / A))) * -math.sqrt(2.0) elif B_m <= 1.12e+180: tmp = math.sqrt((2.0 * (F * (C + math.hypot(C, B_m))))) / -B_m else: tmp = math.sqrt((2.0 * F)) / -math.sqrt(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.5e-100) tmp = sqrt(Float64(F / Float64(-A))); elseif (B_m <= 4.2e-6) tmp = Float64(sqrt(Float64(-0.5 * Float64(F / A))) * Float64(-sqrt(2.0))); elseif (B_m <= 1.12e+180) tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(C + hypot(C, B_m))))) / Float64(-B_m)); else tmp = Float64(sqrt(Float64(2.0 * F)) / Float64(-sqrt(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.5e-100)
tmp = sqrt((F / -A));
elseif (B_m <= 4.2e-6)
tmp = sqrt((-0.5 * (F / A))) * -sqrt(2.0);
elseif (B_m <= 1.12e+180)
tmp = sqrt((2.0 * (F * (C + hypot(C, B_m))))) / -B_m;
else
tmp = sqrt((2.0 * F)) / -sqrt(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.5e-100], N[Sqrt[N[(F / (-A)), $MachinePrecision]], $MachinePrecision], If[LessEqual[B$95$m, 4.2e-6], N[(N[Sqrt[N[(-0.5 * N[(F / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[B$95$m, 1.12e+180], N[(N[Sqrt[N[(2.0 * N[(F * N[(C + N[Sqrt[C ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision], N[(N[Sqrt[N[(2.0 * F), $MachinePrecision]], $MachinePrecision] / (-N[Sqrt[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.5 \cdot 10^{-100}:\\
\;\;\;\;\sqrt{\frac{F}{-A}}\\
\mathbf{elif}\;B\_m \leq 4.2 \cdot 10^{-6}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{F}{A}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;B\_m \leq 1.12 \cdot 10^{+180}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(C + \mathsf{hypot}\left(C, B\_m\right)\right)\right)}}{-B\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot F}}{-\sqrt{B\_m}}\\
\end{array}
\end{array}
if B < 9.4999999999999992e-100Initial program 17.8%
Simplified24.5%
add-sqr-sqrt10.4%
sqrt-unprod9.8%
frac-times8.5%
Applied egg-rr8.6%
Taylor expanded in A around -inf 13.8%
associate-*r/13.8%
neg-mul-113.8%
Simplified13.8%
if 9.4999999999999992e-100 < B < 4.1999999999999996e-6Initial program 32.5%
Taylor expanded in F around 0 27.0%
mul-1-neg27.0%
*-commutative27.0%
cancel-sign-sub-inv27.0%
metadata-eval27.0%
+-commutative27.0%
Simplified40.3%
Taylor expanded in A around -inf 20.5%
if 4.1999999999999996e-6 < B < 1.12e180Initial program 33.8%
Taylor expanded in A around 0 42.7%
mul-1-neg42.7%
*-commutative42.7%
*-commutative42.7%
+-commutative42.7%
unpow242.7%
unpow242.7%
hypot-define57.9%
Simplified57.9%
neg-sub057.9%
associate-*r/57.8%
pow1/257.8%
pow1/257.8%
pow-prod-down58.0%
Applied egg-rr58.0%
neg-sub058.0%
distribute-neg-frac258.0%
unpow1/258.0%
Simplified58.0%
if 1.12e180 < B Initial program 0.0%
Taylor expanded in B around inf 55.8%
mul-1-neg55.8%
*-commutative55.8%
Simplified55.8%
*-commutative55.8%
pow1/255.8%
pow1/255.8%
pow-prod-down56.1%
Applied egg-rr56.1%
unpow1/256.1%
Simplified56.1%
associate-*l/56.1%
sqrt-div81.5%
Applied egg-rr81.5%
Final simplification26.5%
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.2e-100)
(sqrt (/ F (- A)))
(if (<= B_m 2.25e-6)
(* (sqrt (* -0.5 (/ F A))) (- (sqrt 2.0)))
(/ (sqrt (* 2.0 F)) (- (sqrt 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.2e-100) {
tmp = sqrt((F / -A));
} else if (B_m <= 2.25e-6) {
tmp = sqrt((-0.5 * (F / A))) * -sqrt(2.0);
} else {
tmp = sqrt((2.0 * F)) / -sqrt(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.2d-100) then
tmp = sqrt((f / -a))
else if (b_m <= 2.25d-6) then
tmp = sqrt(((-0.5d0) * (f / a))) * -sqrt(2.0d0)
else
tmp = sqrt((2.0d0 * f)) / -sqrt(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.2e-100) {
tmp = Math.sqrt((F / -A));
} else if (B_m <= 2.25e-6) {
tmp = Math.sqrt((-0.5 * (F / A))) * -Math.sqrt(2.0);
} else {
tmp = Math.sqrt((2.0 * F)) / -Math.sqrt(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.2e-100: tmp = math.sqrt((F / -A)) elif B_m <= 2.25e-6: tmp = math.sqrt((-0.5 * (F / A))) * -math.sqrt(2.0) else: tmp = math.sqrt((2.0 * F)) / -math.sqrt(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.2e-100) tmp = sqrt(Float64(F / Float64(-A))); elseif (B_m <= 2.25e-6) tmp = Float64(sqrt(Float64(-0.5 * Float64(F / A))) * Float64(-sqrt(2.0))); else tmp = Float64(sqrt(Float64(2.0 * F)) / Float64(-sqrt(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.2e-100)
tmp = sqrt((F / -A));
elseif (B_m <= 2.25e-6)
tmp = sqrt((-0.5 * (F / A))) * -sqrt(2.0);
else
tmp = sqrt((2.0 * F)) / -sqrt(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.2e-100], N[Sqrt[N[(F / (-A)), $MachinePrecision]], $MachinePrecision], If[LessEqual[B$95$m, 2.25e-6], N[(N[Sqrt[N[(-0.5 * N[(F / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[N[(2.0 * F), $MachinePrecision]], $MachinePrecision] / (-N[Sqrt[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 8.2 \cdot 10^{-100}:\\
\;\;\;\;\sqrt{\frac{F}{-A}}\\
\mathbf{elif}\;B\_m \leq 2.25 \cdot 10^{-6}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{F}{A}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot F}}{-\sqrt{B\_m}}\\
\end{array}
\end{array}
if B < 8.1999999999999998e-100Initial program 17.8%
Simplified24.5%
add-sqr-sqrt10.4%
sqrt-unprod9.8%
frac-times8.5%
Applied egg-rr8.6%
Taylor expanded in A around -inf 13.8%
associate-*r/13.8%
neg-mul-113.8%
Simplified13.8%
if 8.1999999999999998e-100 < B < 2.25000000000000006e-6Initial program 32.5%
Taylor expanded in F around 0 27.0%
mul-1-neg27.0%
*-commutative27.0%
cancel-sign-sub-inv27.0%
metadata-eval27.0%
+-commutative27.0%
Simplified40.3%
Taylor expanded in A around -inf 20.5%
if 2.25000000000000006e-6 < B Initial program 22.0%
Taylor expanded in B around inf 48.5%
mul-1-neg48.5%
*-commutative48.5%
Simplified48.5%
*-commutative48.5%
pow1/248.5%
pow1/248.5%
pow-prod-down48.6%
Applied egg-rr48.6%
unpow1/248.6%
Simplified48.6%
associate-*l/48.6%
sqrt-div60.8%
Applied egg-rr60.8%
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 (<= B_m 1.4e-96) (sqrt (/ F (- A))) (/ (sqrt (* 2.0 F)) (- (sqrt 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.4e-96) {
tmp = sqrt((F / -A));
} else {
tmp = sqrt((2.0 * F)) / -sqrt(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.4d-96) then
tmp = sqrt((f / -a))
else
tmp = sqrt((2.0d0 * f)) / -sqrt(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.4e-96) {
tmp = Math.sqrt((F / -A));
} else {
tmp = Math.sqrt((2.0 * F)) / -Math.sqrt(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.4e-96: tmp = math.sqrt((F / -A)) else: tmp = math.sqrt((2.0 * F)) / -math.sqrt(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.4e-96) tmp = sqrt(Float64(F / Float64(-A))); else tmp = Float64(sqrt(Float64(2.0 * F)) / Float64(-sqrt(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.4e-96)
tmp = sqrt((F / -A));
else
tmp = sqrt((2.0 * F)) / -sqrt(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.4e-96], N[Sqrt[N[(F / (-A)), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[N[(2.0 * F), $MachinePrecision]], $MachinePrecision] / (-N[Sqrt[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 1.4 \cdot 10^{-96}:\\
\;\;\;\;\sqrt{\frac{F}{-A}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot F}}{-\sqrt{B\_m}}\\
\end{array}
\end{array}
if B < 1.40000000000000008e-96Initial program 17.7%
Simplified24.2%
add-sqr-sqrt10.3%
sqrt-unprod9.7%
frac-times8.4%
Applied egg-rr8.5%
Taylor expanded in A around -inf 13.7%
associate-*r/13.7%
neg-mul-113.7%
Simplified13.7%
if 1.40000000000000008e-96 < B Initial program 24.8%
Taylor expanded in B around inf 42.9%
mul-1-neg42.9%
*-commutative42.9%
Simplified42.9%
*-commutative42.9%
pow1/242.9%
pow1/242.9%
pow-prod-down43.0%
Applied egg-rr43.0%
unpow1/243.0%
Simplified43.0%
associate-*l/43.0%
sqrt-div52.8%
Applied egg-rr52.8%
Final simplification25.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 (<= B_m 4.6e-96) (sqrt (/ F (- A))) (- (sqrt (* 2.0 (* 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 <= 4.6e-96) {
tmp = sqrt((F / -A));
} else {
tmp = -sqrt((2.0 * (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 <= 4.6d-96) then
tmp = sqrt((f / -a))
else
tmp = -sqrt((2.0d0 * (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 <= 4.6e-96) {
tmp = Math.sqrt((F / -A));
} else {
tmp = -Math.sqrt((2.0 * (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 <= 4.6e-96: tmp = math.sqrt((F / -A)) else: tmp = -math.sqrt((2.0 * (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 <= 4.6e-96) tmp = sqrt(Float64(F / Float64(-A))); else tmp = Float64(-sqrt(Float64(2.0 * 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 <= 4.6e-96)
tmp = sqrt((F / -A));
else
tmp = -sqrt((2.0 * (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, 4.6e-96], N[Sqrt[N[(F / (-A)), $MachinePrecision]], $MachinePrecision], (-N[Sqrt[N[(2.0 * 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 4.6 \cdot 10^{-96}:\\
\;\;\;\;\sqrt{\frac{F}{-A}}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{1}{B\_m}\right)}\\
\end{array}
\end{array}
if B < 4.6e-96Initial program 17.7%
Simplified24.2%
add-sqr-sqrt10.3%
sqrt-unprod9.7%
frac-times8.4%
Applied egg-rr8.5%
Taylor expanded in A around -inf 13.7%
associate-*r/13.7%
neg-mul-113.7%
Simplified13.7%
if 4.6e-96 < B Initial program 24.8%
Taylor expanded in B around inf 42.9%
mul-1-neg42.9%
*-commutative42.9%
Simplified42.9%
*-commutative42.9%
pow1/242.9%
pow1/242.9%
pow-prod-down43.0%
Applied egg-rr43.0%
unpow1/243.0%
Simplified43.0%
div-inv43.0%
Applied egg-rr43.0%
Final simplification22.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 (<= B_m 6.2e-97) (sqrt (/ F (- A))) (- (sqrt (* F (/ 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 <= 6.2e-97) {
tmp = sqrt((F / -A));
} else {
tmp = -sqrt((F * (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 <= 6.2d-97) then
tmp = sqrt((f / -a))
else
tmp = -sqrt((f * (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 <= 6.2e-97) {
tmp = Math.sqrt((F / -A));
} else {
tmp = -Math.sqrt((F * (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 <= 6.2e-97: tmp = math.sqrt((F / -A)) else: tmp = -math.sqrt((F * (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 <= 6.2e-97) tmp = sqrt(Float64(F / Float64(-A))); else tmp = Float64(-sqrt(Float64(F * Float64(2.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 <= 6.2e-97)
tmp = sqrt((F / -A));
else
tmp = -sqrt((F * (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, 6.2e-97], N[Sqrt[N[(F / (-A)), $MachinePrecision]], $MachinePrecision], (-N[Sqrt[N[(F * N[(2.0 / B$95$m), $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 6.2 \cdot 10^{-97}:\\
\;\;\;\;\sqrt{\frac{F}{-A}}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{F \cdot \frac{2}{B\_m}}\\
\end{array}
\end{array}
if B < 6.20000000000000004e-97Initial program 17.7%
Simplified24.2%
add-sqr-sqrt10.3%
sqrt-unprod9.7%
frac-times8.4%
Applied egg-rr8.5%
Taylor expanded in A around -inf 13.7%
associate-*r/13.7%
neg-mul-113.7%
Simplified13.7%
if 6.20000000000000004e-97 < B Initial program 24.8%
Taylor expanded in B around inf 42.9%
mul-1-neg42.9%
*-commutative42.9%
Simplified42.9%
*-commutative42.9%
pow1/242.9%
pow1/242.9%
pow-prod-down43.0%
Applied egg-rr43.0%
neg-sub043.0%
unpow1/243.0%
associate-*l/43.0%
Applied egg-rr43.0%
neg-sub043.0%
associate-/l*43.0%
Simplified43.0%
Final simplification22.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 (sqrt (/ F (- 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) {
return sqrt((F / -A));
}
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))
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));
}
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))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return sqrt(Float64(F / Float64(-A))) 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));
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[Sqrt[N[(F / (-A)), $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}}
\end{array}
Initial program 19.7%
Simplified25.6%
add-sqr-sqrt7.9%
sqrt-unprod7.6%
frac-times6.7%
Applied egg-rr6.8%
Taylor expanded in A around -inf 11.3%
associate-*r/11.3%
neg-mul-111.3%
Simplified11.3%
Final simplification11.3%
herbie shell --seed 2024165
(FPCore (A B C F)
:name "ABCF->ab-angle a"
: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))))