
(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 14 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)))))
(if (<= (pow B_m 2.0) 5e-49)
(/ (sqrt (* t_0 (* F (* A 4.0)))) (- t_0))
(if (<= (pow B_m 2.0) 1e+308)
(*
(sqrt
(*
F
(/
(- (+ A C) (hypot B_m (- A C)))
(fma -4.0 (* A C) (pow B_m 2.0)))))
(- (sqrt 2.0)))
(*
(sqrt 2.0)
(- (sqrt (* F (/ (+ (+ (/ A B_m) (/ C B_m)) -1.0) B_m)))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (pow(B_m, 2.0) <= 5e-49) {
tmp = sqrt((t_0 * (F * (A * 4.0)))) / -t_0;
} else if (pow(B_m, 2.0) <= 1e+308) {
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(2.0) * -sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m)));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 5e-49) tmp = Float64(sqrt(Float64(t_0 * Float64(F * Float64(A * 4.0)))) / Float64(-t_0)); elseif ((B_m ^ 2.0) <= 1e+308) 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(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(Float64(Float64(Float64(A / B_m) + Float64(C / B_m)) + -1.0) / B_m))))); end return tmp end
B_m = 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-49], N[(N[Sqrt[N[(t$95$0 * N[(F * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+308], 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[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(N[(N[(N[(A / B$95$m), $MachinePrecision] + N[(C / B$95$m), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
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^{-49}:\\
\;\;\;\;\frac{\sqrt{t\_0 \cdot \left(F \cdot \left(A \cdot 4\right)\right)}}{-t\_0}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{+308}:\\
\;\;\;\;\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}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{\left(\frac{A}{B\_m} + \frac{C}{B\_m}\right) + -1}{B\_m}}\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 4.9999999999999999e-49Initial program 22.5%
Simplified32.2%
Taylor expanded in C around inf 17.7%
mul-1-neg17.7%
Simplified17.7%
Taylor expanded in A around -inf 17.7%
associate-*r*17.7%
neg-mul-117.7%
sub-neg17.7%
metadata-eval17.7%
Simplified17.7%
*-un-lft-identity17.7%
associate-*l*20.6%
*-commutative20.6%
Applied egg-rr20.6%
*-lft-identity20.6%
+-commutative20.6%
Simplified20.6%
Taylor expanded in B around 0 20.3%
if 4.9999999999999999e-49 < (pow.f64 B #s(literal 2 binary64)) < 1e308Initial program 25.6%
Simplified17.2%
div-inv17.2%
Applied egg-rr31.6%
Taylor expanded in F around 0 30.0%
mul-1-neg30.0%
Simplified53.8%
if 1e308 < (pow.f64 B #s(literal 2 binary64)) Initial program 0.0%
Simplified0.0%
Taylor expanded in B around inf 0.0%
Taylor expanded in F around 0 2.9%
mul-1-neg2.9%
associate-/l*4.3%
+-commutative4.3%
sub-neg4.3%
metadata-eval4.3%
fma-undefine4.3%
+-commutative4.3%
fma-define4.3%
Simplified4.3%
Taylor expanded in B around inf 32.1%
Final simplification31.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 (<= (pow B_m 2.0) 2e-8)
(/ (sqrt (* t_0 (* F (* A 4.0)))) (- t_0))
(* (sqrt (* F (- A (hypot B_m A)))) (/ (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) <= 2e-8) {
tmp = sqrt((t_0 * (F * (A * 4.0)))) / -t_0;
} else {
tmp = sqrt((F * (A - hypot(B_m, A)))) * (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) <= 2e-8) tmp = Float64(sqrt(Float64(t_0 * Float64(F * Float64(A * 4.0)))) / Float64(-t_0)); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * 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], 2e-8], N[(N[Sqrt[N[(t$95$0 * N[(F * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], 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]]]
\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 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\sqrt{t\_0 \cdot \left(F \cdot \left(A \cdot 4\right)\right)}}{-t\_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2e-8Initial program 22.0%
Simplified31.3%
Taylor expanded in C around inf 17.2%
mul-1-neg17.2%
Simplified17.2%
Taylor expanded in A around -inf 17.2%
associate-*r*17.2%
neg-mul-117.2%
sub-neg17.2%
metadata-eval17.2%
Simplified17.2%
*-un-lft-identity17.2%
associate-*l*20.1%
*-commutative20.1%
Applied egg-rr20.1%
*-lft-identity20.1%
+-commutative20.1%
Simplified20.1%
Taylor expanded in B around 0 19.7%
if 2e-8 < (pow.f64 B #s(literal 2 binary64)) Initial program 14.1%
Taylor expanded in C around 0 11.5%
mul-1-neg11.5%
+-commutative11.5%
unpow211.5%
unpow211.5%
hypot-define24.5%
Simplified24.5%
Final simplification22.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 (<= (pow B_m 2.0) 2e-8) (/ (sqrt (* (* -16.0 (pow A 2.0)) (* C F))) (* C (* A 4.0))) (* (sqrt (* F (- A (hypot B_m A)))) (/ (sqrt 2.0) (- B_m)))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (pow(B_m, 2.0) <= 2e-8) {
tmp = sqrt(((-16.0 * pow(A, 2.0)) * (C * F))) / (C * (A * 4.0));
} else {
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
}
return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (Math.pow(B_m, 2.0) <= 2e-8) {
tmp = Math.sqrt(((-16.0 * Math.pow(A, 2.0)) * (C * F))) / (C * (A * 4.0));
} else {
tmp = Math.sqrt((F * (A - Math.hypot(B_m, A)))) * (Math.sqrt(2.0) / -B_m);
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if math.pow(B_m, 2.0) <= 2e-8: tmp = math.sqrt(((-16.0 * math.pow(A, 2.0)) * (C * F))) / (C * (A * 4.0)) else: tmp = math.sqrt((F * (A - math.hypot(B_m, A)))) * (math.sqrt(2.0) / -B_m) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-8) tmp = Float64(sqrt(Float64(Float64(-16.0 * (A ^ 2.0)) * Float64(C * F))) / Float64(C * Float64(A * 4.0))); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * Float64(sqrt(2.0) / Float64(-B_m))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if ((B_m ^ 2.0) <= 2e-8)
tmp = sqrt(((-16.0 * (A ^ 2.0)) * (C * F))) / (C * (A * 4.0));
else
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-8], N[(N[Sqrt[N[(N[(-16.0 * N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\sqrt{\left(-16 \cdot {A}^{2}\right) \cdot \left(C \cdot F\right)}}{C \cdot \left(A \cdot 4\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2e-8Initial program 22.0%
Simplified27.5%
Taylor expanded in A around -inf 11.5%
associate-*r*11.5%
Simplified11.5%
Taylor expanded in C around inf 11.4%
associate-*r*11.4%
Simplified11.4%
if 2e-8 < (pow.f64 B #s(literal 2 binary64)) Initial program 14.1%
Taylor expanded in C around 0 11.5%
mul-1-neg11.5%
+-commutative11.5%
unpow211.5%
unpow211.5%
hypot-define24.5%
Simplified24.5%
Final simplification17.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 0.0058)
(/ (sqrt (* (* A 4.0) (* t_0 F))) (- t_0))
(* (sqrt (* F (- A (hypot B_m A)))) (/ (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 <= 0.0058) {
tmp = sqrt(((A * 4.0) * (t_0 * F))) / -t_0;
} else {
tmp = sqrt((F * (A - hypot(B_m, A)))) * (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 <= 0.0058) tmp = Float64(sqrt(Float64(Float64(A * 4.0) * Float64(t_0 * F))) / Float64(-t_0)); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * 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, 0.0058], N[(N[Sqrt[N[(N[(A * 4.0), $MachinePrecision] * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], 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]]]
\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 0.0058:\\
\;\;\;\;\frac{\sqrt{\left(A \cdot 4\right) \cdot \left(t\_0 \cdot F\right)}}{-t\_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if B < 0.0058Initial program 18.5%
Simplified25.7%
Taylor expanded in A around -inf 13.2%
if 0.0058 < B Initial program 17.4%
Taylor expanded in C around 0 20.1%
mul-1-neg20.1%
+-commutative20.1%
unpow220.1%
unpow220.1%
hypot-define43.1%
Simplified43.1%
Final simplification20.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 (<= B_m 0.000125)
(/
(sqrt (* (* A -8.0) (* C (* F (+ A A)))))
(- (fma C (* A -4.0) (pow B_m 2.0))))
(* (sqrt (* F (- A (hypot B_m A)))) (/ (sqrt 2.0) (- B_m)))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 0.000125) {
tmp = sqrt(((A * -8.0) * (C * (F * (A + A))))) / -fma(C, (A * -4.0), pow(B_m, 2.0));
} else {
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (B_m <= 0.000125) tmp = Float64(sqrt(Float64(Float64(A * -8.0) * Float64(C * Float64(F * Float64(A + A))))) / Float64(-fma(C, Float64(A * -4.0), (B_m ^ 2.0)))); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * 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_] := If[LessEqual[B$95$m, 0.000125], N[(N[Sqrt[N[(N[(A * -8.0), $MachinePrecision] * N[(C * 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], 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]]
\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 0.000125:\\
\;\;\;\;\frac{\sqrt{\left(A \cdot -8\right) \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{-\mathsf{fma}\left(C, A \cdot -4, {B\_m}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if B < 1.25e-4Initial program 18.5%
Simplified20.9%
Taylor expanded in C around inf 13.2%
associate-*r*13.2%
mul-1-neg13.2%
Simplified13.2%
if 1.25e-4 < B Initial program 17.4%
Taylor expanded in C around 0 20.1%
mul-1-neg20.1%
+-commutative20.1%
unpow220.1%
unpow220.1%
hypot-define43.1%
Simplified43.1%
Final simplification20.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 (<= B_m 0.0042) (/ (sqrt (* (* -16.0 (pow A 2.0)) (* C F))) (* C (* A 4.0))) (* (sqrt 2.0) (- (sqrt (* F (/ (+ (+ (/ A B_m) (/ C B_m)) -1.0) B_m)))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 0.0042) {
tmp = sqrt(((-16.0 * pow(A, 2.0)) * (C * F))) / (C * (A * 4.0));
} else {
tmp = sqrt(2.0) * -sqrt((F * ((((A / B_m) + (C / B_m)) + -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 <= 0.0042d0) then
tmp = sqrt((((-16.0d0) * (a ** 2.0d0)) * (c * f))) / (c * (a * 4.0d0))
else
tmp = sqrt(2.0d0) * -sqrt((f * ((((a / b_m) + (c / b_m)) + (-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 <= 0.0042) {
tmp = Math.sqrt(((-16.0 * Math.pow(A, 2.0)) * (C * F))) / (C * (A * 4.0));
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m)));
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if B_m <= 0.0042: tmp = math.sqrt(((-16.0 * math.pow(A, 2.0)) * (C * F))) / (C * (A * 4.0)) else: tmp = math.sqrt(2.0) * -math.sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m))) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (B_m <= 0.0042) tmp = Float64(sqrt(Float64(Float64(-16.0 * (A ^ 2.0)) * Float64(C * F))) / Float64(C * Float64(A * 4.0))); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(Float64(Float64(Float64(A / B_m) + Float64(C / B_m)) + -1.0) / B_m))))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (B_m <= 0.0042)
tmp = sqrt(((-16.0 * (A ^ 2.0)) * (C * F))) / (C * (A * 4.0));
else
tmp = sqrt(2.0) * -sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m)));
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 0.0042], N[(N[Sqrt[N[(N[(-16.0 * N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(N[(N[(N[(A / B$95$m), $MachinePrecision] + N[(C / B$95$m), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 0.0042:\\
\;\;\;\;\frac{\sqrt{\left(-16 \cdot {A}^{2}\right) \cdot \left(C \cdot F\right)}}{C \cdot \left(A \cdot 4\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{\left(\frac{A}{B\_m} + \frac{C}{B\_m}\right) + -1}{B\_m}}\right)\\
\end{array}
\end{array}
if B < 0.00419999999999999974Initial program 18.5%
Simplified20.9%
Taylor expanded in A around -inf 8.8%
associate-*r*8.8%
Simplified8.8%
Taylor expanded in C around inf 8.6%
associate-*r*8.6%
Simplified8.6%
if 0.00419999999999999974 < B Initial program 17.4%
Simplified13.3%
Taylor expanded in B around inf 11.5%
Taylor expanded in F around 0 15.7%
mul-1-neg15.7%
associate-/l*17.3%
+-commutative17.3%
sub-neg17.3%
metadata-eval17.3%
fma-undefine17.3%
+-commutative17.3%
fma-define17.3%
Simplified17.3%
Taylor expanded in B around inf 41.2%
Final simplification17.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 0.000145) (/ (sqrt (* (* -16.0 (pow A 2.0)) (* C F))) (* C (* A 4.0))) (* (sqrt 2.0) (- (sqrt (/ (- (* F (/ (+ A C) B_m)) F) 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 <= 0.000145) {
tmp = sqrt(((-16.0 * pow(A, 2.0)) * (C * F))) / (C * (A * 4.0));
} else {
tmp = sqrt(2.0) * -sqrt((((F * ((A + C) / B_m)) - F) / 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 <= 0.000145d0) then
tmp = sqrt((((-16.0d0) * (a ** 2.0d0)) * (c * f))) / (c * (a * 4.0d0))
else
tmp = sqrt(2.0d0) * -sqrt((((f * ((a + c) / b_m)) - f) / 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 <= 0.000145) {
tmp = Math.sqrt(((-16.0 * Math.pow(A, 2.0)) * (C * F))) / (C * (A * 4.0));
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((((F * ((A + C) / B_m)) - F) / 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 <= 0.000145: tmp = math.sqrt(((-16.0 * math.pow(A, 2.0)) * (C * F))) / (C * (A * 4.0)) else: tmp = math.sqrt(2.0) * -math.sqrt((((F * ((A + C) / B_m)) - F) / 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 <= 0.000145) tmp = Float64(sqrt(Float64(Float64(-16.0 * (A ^ 2.0)) * Float64(C * F))) / Float64(C * Float64(A * 4.0))); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(Float64(Float64(F * Float64(Float64(A + C) / B_m)) - F) / 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 <= 0.000145)
tmp = sqrt(((-16.0 * (A ^ 2.0)) * (C * F))) / (C * (A * 4.0));
else
tmp = sqrt(2.0) * -sqrt((((F * ((A + C) / B_m)) - F) / 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, 0.000145], N[(N[Sqrt[N[(N[(-16.0 * N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(N[(N[(F * N[(N[(A + C), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision] - F), $MachinePrecision] / 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 0.000145:\\
\;\;\;\;\frac{\sqrt{\left(-16 \cdot {A}^{2}\right) \cdot \left(C \cdot F\right)}}{C \cdot \left(A \cdot 4\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{F \cdot \frac{A + C}{B\_m} - F}{B\_m}}\right)\\
\end{array}
\end{array}
if B < 1.45e-4Initial program 18.5%
Simplified20.9%
Taylor expanded in A around -inf 8.8%
associate-*r*8.8%
Simplified8.8%
Taylor expanded in C around inf 8.6%
associate-*r*8.6%
Simplified8.6%
if 1.45e-4 < B Initial program 17.4%
Simplified13.3%
Taylor expanded in B around inf 11.5%
Taylor expanded in F around 0 15.7%
mul-1-neg15.7%
associate-/l*17.3%
+-commutative17.3%
sub-neg17.3%
metadata-eval17.3%
fma-undefine17.3%
+-commutative17.3%
fma-define17.3%
Simplified17.3%
Taylor expanded in B around -inf 39.3%
mul-1-neg39.3%
mul-1-neg39.3%
associate-/l*41.3%
Simplified41.3%
Final simplification17.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 0.0071) (/ (sqrt (* (* -16.0 (pow A 2.0)) (* C F))) (* C (* A 4.0))) (* (sqrt 2.0) (- (sqrt (/ (- F) 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 <= 0.0071) {
tmp = sqrt(((-16.0 * pow(A, 2.0)) * (C * F))) / (C * (A * 4.0));
} else {
tmp = sqrt(2.0) * -sqrt((-F / 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 <= 0.0071d0) then
tmp = sqrt((((-16.0d0) * (a ** 2.0d0)) * (c * f))) / (c * (a * 4.0d0))
else
tmp = sqrt(2.0d0) * -sqrt((-f / 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 <= 0.0071) {
tmp = Math.sqrt(((-16.0 * Math.pow(A, 2.0)) * (C * F))) / (C * (A * 4.0));
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((-F / 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 <= 0.0071: tmp = math.sqrt(((-16.0 * math.pow(A, 2.0)) * (C * F))) / (C * (A * 4.0)) else: tmp = math.sqrt(2.0) * -math.sqrt((-F / 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 <= 0.0071) tmp = Float64(sqrt(Float64(Float64(-16.0 * (A ^ 2.0)) * Float64(C * F))) / Float64(C * Float64(A * 4.0))); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(Float64(-F) / 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 <= 0.0071)
tmp = sqrt(((-16.0 * (A ^ 2.0)) * (C * F))) / (C * (A * 4.0));
else
tmp = sqrt(2.0) * -sqrt((-F / 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, 0.0071], N[(N[Sqrt[N[(N[(-16.0 * N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[((-F) / 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 0.0071:\\
\;\;\;\;\frac{\sqrt{\left(-16 \cdot {A}^{2}\right) \cdot \left(C \cdot F\right)}}{C \cdot \left(A \cdot 4\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{-F}{B\_m}}\right)\\
\end{array}
\end{array}
if B < 0.0071000000000000004Initial program 18.5%
Simplified20.9%
Taylor expanded in A around -inf 8.8%
associate-*r*8.8%
Simplified8.8%
Taylor expanded in C around inf 8.6%
associate-*r*8.6%
Simplified8.6%
if 0.0071000000000000004 < B Initial program 17.4%
Simplified13.3%
Taylor expanded in B around inf 11.5%
Taylor expanded in F around 0 15.7%
mul-1-neg15.7%
associate-/l*17.3%
+-commutative17.3%
sub-neg17.3%
metadata-eval17.3%
fma-undefine17.3%
+-commutative17.3%
fma-define17.3%
Simplified17.3%
Taylor expanded in B around inf 40.9%
associate-*r/40.9%
mul-1-neg40.9%
Simplified40.9%
Final simplification16.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 (<= F -2.6e-68) (* (sqrt 2.0) (- (sqrt (/ (- F) B_m)))) (* (sqrt (* F (- A B_m))) (/ (sqrt 2.0) (- B_m)))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -2.6e-68) {
tmp = sqrt(2.0) * -sqrt((-F / B_m));
} else {
tmp = sqrt((F * (A - B_m))) * (sqrt(2.0) / -B_m);
}
return tmp;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (f <= (-2.6d-68)) then
tmp = sqrt(2.0d0) * -sqrt((-f / b_m))
else
tmp = sqrt((f * (a - b_m))) * (sqrt(2.0d0) / -b_m)
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -2.6e-68) {
tmp = Math.sqrt(2.0) * -Math.sqrt((-F / B_m));
} else {
tmp = Math.sqrt((F * (A - B_m))) * (Math.sqrt(2.0) / -B_m);
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if F <= -2.6e-68: tmp = math.sqrt(2.0) * -math.sqrt((-F / B_m)) else: tmp = math.sqrt((F * (A - B_m))) * (math.sqrt(2.0) / -B_m) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (F <= -2.6e-68) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(Float64(-F) / B_m)))); else tmp = Float64(sqrt(Float64(F * Float64(A - B_m))) * Float64(sqrt(2.0) / Float64(-B_m))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (F <= -2.6e-68)
tmp = sqrt(2.0) * -sqrt((-F / B_m));
else
tmp = sqrt((F * (A - B_m))) * (sqrt(2.0) / -B_m);
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[F, -2.6e-68], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[((-F) / B$95$m), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;F \leq -2.6 \cdot 10^{-68}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{-F}{B\_m}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - B\_m\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if F < -2.5999999999999998e-68Initial program 10.1%
Simplified10.6%
Taylor expanded in B around inf 3.4%
Taylor expanded in F around 0 5.1%
mul-1-neg5.1%
associate-/l*7.0%
+-commutative7.0%
sub-neg7.0%
metadata-eval7.0%
fma-undefine7.0%
+-commutative7.0%
fma-define7.0%
Simplified7.0%
Taylor expanded in B around inf 17.0%
associate-*r/17.0%
mul-1-neg17.0%
Simplified17.0%
if -2.5999999999999998e-68 < F Initial program 28.5%
Simplified29.5%
Taylor expanded in B around inf 8.8%
Taylor expanded in C around 0 15.8%
mul-1-neg15.8%
mul-1-neg15.8%
Simplified15.8%
Final simplification16.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 0.000118) (* (sqrt 2.0) (- (sqrt (* -0.25 (/ F C))))) (* (sqrt 2.0) (- (sqrt (/ (- F) 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 <= 0.000118) {
tmp = sqrt(2.0) * -sqrt((-0.25 * (F / C)));
} else {
tmp = sqrt(2.0) * -sqrt((-F / 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 <= 0.000118d0) then
tmp = sqrt(2.0d0) * -sqrt(((-0.25d0) * (f / c)))
else
tmp = sqrt(2.0d0) * -sqrt((-f / 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 <= 0.000118) {
tmp = Math.sqrt(2.0) * -Math.sqrt((-0.25 * (F / C)));
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((-F / 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 <= 0.000118: tmp = math.sqrt(2.0) * -math.sqrt((-0.25 * (F / C))) else: tmp = math.sqrt(2.0) * -math.sqrt((-F / 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 <= 0.000118) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(-0.25 * Float64(F / C))))); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(Float64(-F) / 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 <= 0.000118)
tmp = sqrt(2.0) * -sqrt((-0.25 * (F / C)));
else
tmp = sqrt(2.0) * -sqrt((-F / 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, 0.000118], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(-0.25 * N[(F / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[((-F) / 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 0.000118:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{-0.25 \cdot \frac{F}{C}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{-F}{B\_m}}\right)\\
\end{array}
\end{array}
if B < 1.18e-4Initial program 18.5%
Simplified20.9%
Taylor expanded in B around inf 3.8%
Taylor expanded in F around 0 3.4%
mul-1-neg3.4%
associate-/l*4.3%
+-commutative4.3%
sub-neg4.3%
metadata-eval4.3%
fma-undefine4.3%
+-commutative4.3%
fma-define4.3%
Simplified4.3%
Taylor expanded in A around inf 5.0%
if 1.18e-4 < B Initial program 17.4%
Simplified13.3%
Taylor expanded in B around inf 11.5%
Taylor expanded in F around 0 15.7%
mul-1-neg15.7%
associate-/l*17.3%
+-commutative17.3%
sub-neg17.3%
metadata-eval17.3%
fma-undefine17.3%
+-commutative17.3%
fma-define17.3%
Simplified17.3%
Taylor expanded in B around inf 40.9%
associate-*r/40.9%
mul-1-neg40.9%
Simplified40.9%
Final simplification14.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 2.0) (- (sqrt (/ (- F) 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 / 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 / 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 / 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 / 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(Float64(-F) / 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 / 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) / 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])\\
\\
\sqrt{2} \cdot \left(-\sqrt{\frac{-F}{B\_m}}\right)
\end{array}
Initial program 18.2%
Simplified18.9%
Taylor expanded in B around inf 5.8%
Taylor expanded in F around 0 6.6%
mul-1-neg6.6%
associate-/l*7.7%
+-commutative7.7%
sub-neg7.7%
metadata-eval7.7%
fma-undefine7.7%
+-commutative7.7%
fma-define7.7%
Simplified7.7%
Taylor expanded in B around inf 12.3%
associate-*r/12.3%
mul-1-neg12.3%
Simplified12.3%
Final simplification12.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 (fabs (* 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) {
return sqrt(fabs((F * (2.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(abs((f * (2.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(Math.abs((F * (2.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(math.fabs((F * (2.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 sqrt(abs(Float64(F * Float64(2.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(abs((F * (2.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[Sqrt[N[Abs[N[(F * N[(2.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{\left|F \cdot \frac{2}{B\_m}\right|}
\end{array}
Initial program 18.2%
Taylor expanded in B around -inf 0.0%
mul-1-neg0.0%
unpow20.0%
rem-square-sqrt2.0%
Simplified2.0%
Taylor expanded in F around 0 2.0%
pow12.0%
sqrt-unprod2.0%
Applied egg-rr2.0%
unpow12.0%
associate-*l/2.0%
Simplified2.0%
associate-*l/2.0%
add-sqr-sqrt2.0%
pow1/22.0%
pow1/22.2%
pow-prod-down3.3%
pow23.3%
associate-*l/3.3%
associate-/l*3.3%
Applied egg-rr3.3%
unpow1/23.3%
unpow23.3%
rem-sqrt-square3.2%
Simplified3.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 (pow (* 2.0 (/ F B_m)) 0.5))
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 pow((2.0 * (F / B_m)), 0.5);
}
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 = (2.0d0 * (f / b_m)) ** 0.5d0
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.pow((2.0 * (F / B_m)), 0.5);
}
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.pow((2.0 * (F / B_m)), 0.5)
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(2.0 * Float64(F / B_m)) ^ 0.5 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 = (2.0 * (F / B_m)) ^ 0.5;
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[Power[N[(2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
{\left(2 \cdot \frac{F}{B\_m}\right)}^{0.5}
\end{array}
Initial program 18.2%
Taylor expanded in B around -inf 0.0%
mul-1-neg0.0%
unpow20.0%
rem-square-sqrt2.0%
Simplified2.0%
Taylor expanded in F around 0 2.0%
sqrt-unprod2.0%
pow1/22.2%
Applied egg-rr2.2%
Final simplification2.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 (/ (* 2.0 F) 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 * F) / 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 * f) / 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 * F) / 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 * F) / 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 sqrt(Float64(Float64(2.0 * F) / 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 * F) / 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[Sqrt[N[(N[(2.0 * F), $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])\\
\\
\sqrt{\frac{2 \cdot F}{B\_m}}
\end{array}
Initial program 18.2%
Taylor expanded in B around -inf 0.0%
mul-1-neg0.0%
unpow20.0%
rem-square-sqrt2.0%
Simplified2.0%
Taylor expanded in F around 0 2.0%
pow12.0%
sqrt-unprod2.0%
Applied egg-rr2.0%
unpow12.0%
associate-*l/2.0%
Simplified2.0%
Final simplification2.0%
herbie shell --seed 2024144
(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))))