
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0}
\end{array}
\end{array}
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma B_m B_m (* A (* C -4.0)))))
(if (<= (pow B_m 2.0) 5e-40)
(/
(sqrt (* (* t_0 F) (* 2.0 (+ A (+ A (* -0.5 (/ (pow B_m 2.0) C)))))))
(- t_0))
(if (<= (pow B_m 2.0) 1e+292)
(-
(sqrt
(*
2.0
(*
F
(/
(- (+ A C) (hypot B_m (- A C)))
(fma A (* C -4.0) (pow B_m 2.0)))))))
(- (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) {
double t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (pow(B_m, 2.0) <= 5e-40) {
tmp = sqrt(((t_0 * F) * (2.0 * (A + (A + (-0.5 * (pow(B_m, 2.0) / C))))))) / -t_0;
} else if (pow(B_m, 2.0) <= 1e+292) {
tmp = -sqrt((2.0 * (F * (((A + C) - hypot(B_m, (A - C))) / fma(A, (C * -4.0), pow(B_m, 2.0))))));
} else {
tmp = -sqrt((-2.0 * (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) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 5e-40) tmp = Float64(sqrt(Float64(Float64(t_0 * F) * Float64(2.0 * Float64(A + Float64(A + Float64(-0.5 * Float64((B_m ^ 2.0) / C))))))) / Float64(-t_0)); elseif ((B_m ^ 2.0) <= 1e+292) tmp = Float64(-sqrt(Float64(2.0 * Float64(F * Float64(Float64(Float64(A + C) - hypot(B_m, Float64(A - C))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0))))))); else tmp = Float64(-sqrt(Float64(-2.0 * Float64(F / 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-40], N[(N[Sqrt[N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * N[(A + N[(A + N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+292], (-N[Sqrt[N[(2.0 * N[(F * N[(N[(N[(A + C), $MachinePrecision] - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), (-N[Sqrt[N[(-2.0 * 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}
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^{-40}:\\
\;\;\;\;\frac{\sqrt{\left(t\_0 \cdot F\right) \cdot \left(2 \cdot \left(A + \left(A + -0.5 \cdot \frac{{B\_m}^{2}}{C}\right)\right)\right)}}{-t\_0}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{+292}:\\
\;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B\_m, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B\_m}^{2}\right)}\right)}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999965e-40Initial program 29.3%
Simplified40.3%
Taylor expanded in C around inf 36.8%
mul-1-neg36.8%
Simplified36.8%
if 4.99999999999999965e-40 < (pow.f64 B #s(literal 2 binary64)) < 1e292Initial program 27.5%
Taylor expanded in F around 0 33.4%
Simplified46.4%
sqrt-unprod46.5%
associate-/l*59.6%
associate-+r-60.5%
fma-undefine60.5%
*-commutative60.5%
associate-*r*60.5%
fma-define60.5%
Applied egg-rr60.5%
if 1e292 < (pow.f64 B #s(literal 2 binary64)) Initial program 1.8%
Taylor expanded in F around 0 5.1%
Simplified9.2%
sqrt-unprod9.2%
associate-/l*10.4%
associate-+r-10.4%
fma-undefine10.4%
*-commutative10.4%
associate-*r*10.4%
fma-define10.6%
Applied egg-rr10.6%
Taylor expanded in B around inf 31.0%
Final simplification42.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-40)
(/ (sqrt (* (* t_0 F) (* A 4.0))) (- t_0))
(if (<= (pow B_m 2.0) 1e+292)
(-
(sqrt
(*
2.0
(*
F
(/
(- (+ A C) (hypot B_m (- A C)))
(fma A (* C -4.0) (pow B_m 2.0)))))))
(- (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) {
double t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (pow(B_m, 2.0) <= 5e-40) {
tmp = sqrt(((t_0 * F) * (A * 4.0))) / -t_0;
} else if (pow(B_m, 2.0) <= 1e+292) {
tmp = -sqrt((2.0 * (F * (((A + C) - hypot(B_m, (A - C))) / fma(A, (C * -4.0), pow(B_m, 2.0))))));
} else {
tmp = -sqrt((-2.0 * (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) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 5e-40) tmp = Float64(sqrt(Float64(Float64(t_0 * F) * Float64(A * 4.0))) / Float64(-t_0)); elseif ((B_m ^ 2.0) <= 1e+292) tmp = Float64(-sqrt(Float64(2.0 * Float64(F * Float64(Float64(Float64(A + C) - hypot(B_m, Float64(A - C))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0))))))); else tmp = Float64(-sqrt(Float64(-2.0 * Float64(F / 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-40], N[(N[Sqrt[N[(N[(t$95$0 * F), $MachinePrecision] * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+292], (-N[Sqrt[N[(2.0 * N[(F * N[(N[(N[(A + C), $MachinePrecision] - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), (-N[Sqrt[N[(-2.0 * 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}
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^{-40}:\\
\;\;\;\;\frac{\sqrt{\left(t\_0 \cdot F\right) \cdot \left(A \cdot 4\right)}}{-t\_0}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{+292}:\\
\;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B\_m, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B\_m}^{2}\right)}\right)}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999965e-40Initial program 29.3%
Simplified40.3%
Taylor expanded in A around -inf 36.5%
if 4.99999999999999965e-40 < (pow.f64 B #s(literal 2 binary64)) < 1e292Initial program 27.5%
Taylor expanded in F around 0 33.4%
Simplified46.4%
sqrt-unprod46.5%
associate-/l*59.6%
associate-+r-60.5%
fma-undefine60.5%
*-commutative60.5%
associate-*r*60.5%
fma-define60.5%
Applied egg-rr60.5%
if 1e292 < (pow.f64 B #s(literal 2 binary64)) Initial program 1.8%
Taylor expanded in F around 0 5.1%
Simplified9.2%
sqrt-unprod9.2%
associate-/l*10.4%
associate-+r-10.4%
fma-undefine10.4%
*-commutative10.4%
associate-*r*10.4%
fma-define10.6%
Applied egg-rr10.6%
Taylor expanded in B around inf 31.0%
Final simplification42.1%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma B_m B_m (* A (* C -4.0)))))
(if (<= (pow B_m 2.0) 1e-7)
(/ (sqrt (* (* t_0 F) (* A 4.0))) (- t_0))
(if (<= (pow B_m 2.0) 2e+266)
(- (sqrt (* 2.0 (* F (/ (- A (hypot A B_m)) (pow B_m 2.0))))))
(- (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) {
double t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (pow(B_m, 2.0) <= 1e-7) {
tmp = sqrt(((t_0 * F) * (A * 4.0))) / -t_0;
} else if (pow(B_m, 2.0) <= 2e+266) {
tmp = -sqrt((2.0 * (F * ((A - hypot(A, B_m)) / pow(B_m, 2.0)))));
} else {
tmp = -sqrt((-2.0 * (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) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-7) tmp = Float64(sqrt(Float64(Float64(t_0 * F) * Float64(A * 4.0))) / Float64(-t_0)); elseif ((B_m ^ 2.0) <= 2e+266) tmp = Float64(-sqrt(Float64(2.0 * Float64(F * Float64(Float64(A - hypot(A, B_m)) / (B_m ^ 2.0)))))); else tmp = Float64(-sqrt(Float64(-2.0 * Float64(F / 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], 1e-7], N[(N[Sqrt[N[(N[(t$95$0 * F), $MachinePrecision] * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+266], (-N[Sqrt[N[(2.0 * N[(F * N[(N[(A - N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] / N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), (-N[Sqrt[N[(-2.0 * 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}
t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-7}:\\
\;\;\;\;\frac{\sqrt{\left(t\_0 \cdot F\right) \cdot \left(A \cdot 4\right)}}{-t\_0}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+266}:\\
\;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{A - \mathsf{hypot}\left(A, B\_m\right)}{{B\_m}^{2}}\right)}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 9.9999999999999995e-8Initial program 30.6%
Simplified42.7%
Taylor expanded in A around -inf 36.0%
if 9.9999999999999995e-8 < (pow.f64 B #s(literal 2 binary64)) < 2.0000000000000001e266Initial program 24.6%
Taylor expanded in F around 0 31.7%
Simplified43.3%
sqrt-unprod43.5%
associate-/l*56.6%
associate-+r-57.7%
fma-undefine57.7%
*-commutative57.7%
associate-*r*57.7%
fma-define57.7%
Applied egg-rr57.7%
Taylor expanded in C around 0 25.9%
associate-/l*30.2%
unpow230.2%
unpow230.2%
hypot-define33.6%
Simplified33.6%
if 2.0000000000000001e266 < (pow.f64 B #s(literal 2 binary64)) Initial program 3.4%
Taylor expanded in F around 0 7.5%
Simplified11.5%
sqrt-unprod11.4%
associate-/l*14.1%
associate-+r-14.1%
fma-undefine14.1%
*-commutative14.1%
associate-*r*14.1%
fma-define14.3%
Applied egg-rr14.3%
Taylor expanded in B around inf 32.5%
Final simplification34.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 (<= (pow B_m 2.0) 1e-7)
(/
(sqrt (* (* (fma B_m B_m (* A (* C -4.0))) F) (* A 4.0)))
(* C (* A 4.0)))
(if (<= (pow B_m 2.0) 2e+266)
(- (sqrt (* 2.0 (* F (/ (- A (hypot A B_m)) (pow B_m 2.0))))))
(- (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) {
double tmp;
if (pow(B_m, 2.0) <= 1e-7) {
tmp = sqrt(((fma(B_m, B_m, (A * (C * -4.0))) * F) * (A * 4.0))) / (C * (A * 4.0));
} else if (pow(B_m, 2.0) <= 2e+266) {
tmp = -sqrt((2.0 * (F * ((A - hypot(A, B_m)) / pow(B_m, 2.0)))));
} else {
tmp = -sqrt((-2.0 * (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 ^ 2.0) <= 1e-7) tmp = Float64(sqrt(Float64(Float64(fma(B_m, B_m, Float64(A * Float64(C * -4.0))) * F) * Float64(A * 4.0))) / Float64(C * Float64(A * 4.0))); elseif ((B_m ^ 2.0) <= 2e+266) tmp = Float64(-sqrt(Float64(2.0 * Float64(F * Float64(Float64(A - hypot(A, B_m)) / (B_m ^ 2.0)))))); else tmp = Float64(-sqrt(Float64(-2.0 * Float64(F / 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[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-7], N[(N[Sqrt[N[(N[(N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+266], (-N[Sqrt[N[(2.0 * N[(F * N[(N[(A - N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] / N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), (-N[Sqrt[N[(-2.0 * 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}^{2} \leq 10^{-7}:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(A \cdot 4\right)}}{C \cdot \left(A \cdot 4\right)}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+266}:\\
\;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{A - \mathsf{hypot}\left(A, B\_m\right)}{{B\_m}^{2}}\right)}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 9.9999999999999995e-8Initial program 30.6%
Simplified42.7%
Taylor expanded in A around -inf 36.0%
Taylor expanded in B around 0 35.3%
associate-*r*35.3%
Simplified35.3%
if 9.9999999999999995e-8 < (pow.f64 B #s(literal 2 binary64)) < 2.0000000000000001e266Initial program 24.6%
Taylor expanded in F around 0 31.7%
Simplified43.3%
sqrt-unprod43.5%
associate-/l*56.6%
associate-+r-57.7%
fma-undefine57.7%
*-commutative57.7%
associate-*r*57.7%
fma-define57.7%
Applied egg-rr57.7%
Taylor expanded in C around 0 25.9%
associate-/l*30.2%
unpow230.2%
unpow230.2%
hypot-define33.6%
Simplified33.6%
if 2.0000000000000001e266 < (pow.f64 B #s(literal 2 binary64)) Initial program 3.4%
Taylor expanded in F around 0 7.5%
Simplified11.5%
sqrt-unprod11.4%
associate-/l*14.1%
associate-+r-14.1%
fma-undefine14.1%
*-commutative14.1%
associate-*r*14.1%
fma-define14.3%
Applied egg-rr14.3%
Taylor expanded in B around inf 32.5%
Final simplification34.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 (<= (pow B_m 2.0) 1e-7)
(/
(sqrt (* (* (fma B_m B_m (* A (* C -4.0))) F) (* A 4.0)))
(* C (* A 4.0)))
(if (<= (pow B_m 2.0) 2e+306)
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A))))))
(- (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) {
double tmp;
if (pow(B_m, 2.0) <= 1e-7) {
tmp = sqrt(((fma(B_m, B_m, (A * (C * -4.0))) * F) * (A * 4.0))) / (C * (A * 4.0));
} else if (pow(B_m, 2.0) <= 2e+306) {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
} else {
tmp = -sqrt((-2.0 * (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 ^ 2.0) <= 1e-7) tmp = Float64(sqrt(Float64(Float64(fma(B_m, B_m, Float64(A * Float64(C * -4.0))) * F) * Float64(A * 4.0))) / Float64(C * Float64(A * 4.0))); elseif ((B_m ^ 2.0) <= 2e+306) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); else tmp = Float64(-sqrt(Float64(-2.0 * Float64(F / 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[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-7], N[(N[Sqrt[N[(N[(N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+306], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], (-N[Sqrt[N[(-2.0 * 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}^{2} \leq 10^{-7}:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(A \cdot 4\right)}}{C \cdot \left(A \cdot 4\right)}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+306}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 9.9999999999999995e-8Initial program 30.6%
Simplified42.7%
Taylor expanded in A around -inf 36.0%
Taylor expanded in B around 0 35.3%
associate-*r*35.3%
Simplified35.3%
if 9.9999999999999995e-8 < (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000003e306Initial program 24.9%
Taylor expanded in C around 0 19.4%
mul-1-neg19.4%
+-commutative19.4%
unpow219.4%
unpow219.4%
hypot-define21.2%
Simplified21.2%
if 2.00000000000000003e306 < (pow.f64 B #s(literal 2 binary64)) Initial program 0.0%
Taylor expanded in F around 0 1.8%
Simplified6.2%
sqrt-unprod6.2%
associate-/l*7.5%
associate-+r-7.5%
fma-undefine7.5%
*-commutative7.5%
associate-*r*7.5%
fma-define7.8%
Applied egg-rr7.8%
Taylor expanded in B around inf 30.0%
Final simplification30.1%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(if (<= (pow B_m 2.0) 1e-109)
(/
(sqrt (* (* (fma B_m B_m (* A (* C -4.0))) F) (* A 4.0)))
(* C (* A 4.0)))
(if (<= (pow B_m 2.0) 5e+132)
(- (sqrt (/ F (- C))))
(- (sqrt (/ (fma -2.0 F (* 2.0 (* F (/ (+ A C) B_m)))) 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) <= 1e-109) {
tmp = sqrt(((fma(B_m, B_m, (A * (C * -4.0))) * F) * (A * 4.0))) / (C * (A * 4.0));
} else if (pow(B_m, 2.0) <= 5e+132) {
tmp = -sqrt((F / -C));
} else {
tmp = -sqrt((fma(-2.0, F, (2.0 * (F * ((A + C) / B_m)))) / 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) <= 1e-109) tmp = Float64(sqrt(Float64(Float64(fma(B_m, B_m, Float64(A * Float64(C * -4.0))) * F) * Float64(A * 4.0))) / Float64(C * Float64(A * 4.0))); elseif ((B_m ^ 2.0) <= 5e+132) tmp = Float64(-sqrt(Float64(F / Float64(-C)))); else tmp = Float64(-sqrt(Float64(fma(-2.0, F, Float64(2.0 * Float64(F * Float64(Float64(A + C) / B_m)))) / 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[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-109], N[(N[Sqrt[N[(N[(N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+132], (-N[Sqrt[N[(F / (-C)), $MachinePrecision]], $MachinePrecision]), (-N[Sqrt[N[(N[(-2.0 * F + N[(2.0 * N[(F * N[(N[(A + C), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]), $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}
\mathbf{if}\;{B\_m}^{2} \leq 10^{-109}:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(A \cdot 4\right)}}{C \cdot \left(A \cdot 4\right)}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+132}:\\
\;\;\;\;-\sqrt{\frac{F}{-C}}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\frac{\mathsf{fma}\left(-2, F, 2 \cdot \left(F \cdot \frac{A + C}{B\_m}\right)\right)}{B\_m}}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 9.9999999999999999e-110Initial program 31.3%
Simplified42.2%
Taylor expanded in A around -inf 37.6%
Taylor expanded in B around 0 36.9%
associate-*r*36.9%
Simplified36.9%
if 9.9999999999999999e-110 < (pow.f64 B #s(literal 2 binary64)) < 5.0000000000000001e132Initial program 25.9%
Taylor expanded in F around 0 29.2%
Simplified41.3%
sqrt-unprod41.3%
associate-/l*46.9%
associate-+r-48.3%
fma-undefine48.3%
*-commutative48.3%
associate-*r*48.3%
fma-define48.3%
Applied egg-rr48.3%
Taylor expanded in A around -inf 24.3%
associate-*r/24.3%
mul-1-neg24.3%
Simplified24.3%
if 5.0000000000000001e132 < (pow.f64 B #s(literal 2 binary64)) Initial program 9.4%
Taylor expanded in F around 0 15.4%
Simplified22.7%
sqrt-unprod22.7%
associate-/l*31.7%
associate-+r-31.6%
fma-undefine31.6%
*-commutative31.6%
associate-*r*31.6%
fma-define31.7%
Applied egg-rr31.7%
Taylor expanded in B around inf 26.2%
fma-define26.2%
associate-/l*31.3%
Simplified31.3%
Final simplification32.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 (<= (pow B_m 2.0) 5e+132) (- (sqrt (/ F (- C)))) (- (sqrt (/ (fma -2.0 F (* 2.0 (* F (/ (+ A C) B_m)))) 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) <= 5e+132) {
tmp = -sqrt((F / -C));
} else {
tmp = -sqrt((fma(-2.0, F, (2.0 * (F * ((A + C) / B_m)))) / 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) <= 5e+132) tmp = Float64(-sqrt(Float64(F / Float64(-C)))); else tmp = Float64(-sqrt(Float64(fma(-2.0, F, Float64(2.0 * Float64(F * Float64(Float64(A + C) / B_m)))) / 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[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+132], (-N[Sqrt[N[(F / (-C)), $MachinePrecision]], $MachinePrecision]), (-N[Sqrt[N[(N[(-2.0 * F + N[(2.0 * N[(F * N[(N[(A + C), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]), $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}
\mathbf{if}\;{B\_m}^{2} \leq 5 \cdot 10^{+132}:\\
\;\;\;\;-\sqrt{\frac{F}{-C}}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\frac{\mathsf{fma}\left(-2, F, 2 \cdot \left(F \cdot \frac{A + C}{B\_m}\right)\right)}{B\_m}}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 5.0000000000000001e132Initial program 29.5%
Taylor expanded in F around 0 21.0%
Simplified29.5%
sqrt-unprod29.6%
associate-/l*31.8%
associate-+r-35.4%
fma-undefine35.4%
*-commutative35.4%
associate-*r*35.4%
fma-define35.4%
Applied egg-rr35.4%
Taylor expanded in A around -inf 18.9%
associate-*r/18.9%
mul-1-neg18.9%
Simplified18.9%
if 5.0000000000000001e132 < (pow.f64 B #s(literal 2 binary64)) Initial program 9.4%
Taylor expanded in F around 0 15.4%
Simplified22.7%
sqrt-unprod22.7%
associate-/l*31.7%
associate-+r-31.6%
fma-undefine31.6%
*-commutative31.6%
associate-*r*31.6%
fma-define31.7%
Applied egg-rr31.7%
Taylor expanded in B around inf 26.2%
fma-define26.2%
associate-/l*31.3%
Simplified31.3%
Final simplification23.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 (if (<= B_m 1.85e+66) (- (sqrt (/ F (- C)))) (- (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) {
double tmp;
if (B_m <= 1.85e+66) {
tmp = -sqrt((F / -C));
} else {
tmp = -sqrt((-2.0 * (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 <= 1.85d+66) then
tmp = -sqrt((f / -c))
else
tmp = -sqrt(((-2.0d0) * (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 <= 1.85e+66) {
tmp = -Math.sqrt((F / -C));
} else {
tmp = -Math.sqrt((-2.0 * (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 <= 1.85e+66: tmp = -math.sqrt((F / -C)) else: tmp = -math.sqrt((-2.0 * (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 <= 1.85e+66) tmp = Float64(-sqrt(Float64(F / Float64(-C)))); else tmp = Float64(-sqrt(Float64(-2.0 * 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 <= 1.85e+66)
tmp = -sqrt((F / -C));
else
tmp = -sqrt((-2.0 * (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, 1.85e+66], (-N[Sqrt[N[(F / (-C)), $MachinePrecision]], $MachinePrecision]), (-N[Sqrt[N[(-2.0 * 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 1.85 \cdot 10^{+66}:\\
\;\;\;\;-\sqrt{\frac{F}{-C}}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\
\end{array}
\end{array}
if B < 1.85e66Initial program 24.7%
Taylor expanded in F around 0 18.9%
Simplified26.5%
sqrt-unprod26.6%
associate-/l*29.3%
associate-+r-32.0%
fma-undefine32.0%
*-commutative32.0%
associate-*r*32.0%
fma-define32.1%
Applied egg-rr32.1%
Taylor expanded in A around -inf 15.7%
associate-*r/15.7%
mul-1-neg15.7%
Simplified15.7%
if 1.85e66 < B Initial program 10.3%
Taylor expanded in F around 0 19.4%
Simplified29.7%
sqrt-unprod29.7%
associate-/l*43.9%
associate-+r-43.9%
fma-undefine43.9%
*-commutative43.9%
associate-*r*43.9%
fma-define44.0%
Applied egg-rr44.0%
Taylor expanded in B around inf 63.9%
Final simplification23.8%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (- (sqrt (/ F (- C)))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return -sqrt((F / -C));
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = -sqrt((f / -c))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return -Math.sqrt((F / -C));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return -math.sqrt((F / -C))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(-sqrt(Float64(F / Float64(-C)))) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = -sqrt((F / -C));
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 / (-C)), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
-\sqrt{\frac{F}{-C}}
\end{array}
Initial program 22.2%
Taylor expanded in F around 0 19.0%
Simplified27.0%
sqrt-unprod27.1%
associate-/l*31.8%
associate-+r-34.0%
fma-undefine34.0%
*-commutative34.0%
associate-*r*34.0%
fma-define34.1%
Applied egg-rr34.1%
Taylor expanded in A around -inf 14.3%
associate-*r/14.3%
mul-1-neg14.3%
Simplified14.3%
Final simplification14.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 (/ 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 Float64(-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 22.2%
Taylor expanded in F around 0 19.0%
Simplified27.0%
sqrt-unprod27.1%
associate-/l*31.8%
associate-+r-34.0%
fma-undefine34.0%
*-commutative34.0%
associate-*r*34.0%
fma-define34.1%
Applied egg-rr34.1%
Taylor expanded in C around -inf 10.5%
associate-*r/10.5%
mul-1-neg10.5%
Simplified10.5%
Final simplification10.5%
herbie shell --seed 2024181
(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))))