
(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) 1e-152)
(*
(sqrt (* t_0 (* F (* 2.0 (+ A (+ A (* -0.5 (/ (pow B_m 2.0) C))))))))
(/ -1.0 t_0))
(if (<= (pow B_m 2.0) 1e+297)
(*
(sqrt 2.0)
(-
(sqrt
(*
F
(/
(+ A (- C (hypot B_m (- A C))))
(fma -4.0 (* A C) (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 t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (pow(B_m, 2.0) <= 1e-152) {
tmp = sqrt((t_0 * (F * (2.0 * (A + (A + (-0.5 * (pow(B_m, 2.0) / C)))))))) * (-1.0 / t_0);
} else if (pow(B_m, 2.0) <= 1e+297) {
tmp = sqrt(2.0) * -sqrt((F * ((A + (C - hypot(B_m, (A - C)))) / fma(-4.0, (A * C), 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) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-152) tmp = Float64(sqrt(Float64(t_0 * Float64(F * Float64(2.0 * Float64(A + Float64(A + Float64(-0.5 * Float64((B_m ^ 2.0) / C)))))))) * Float64(-1.0 / t_0)); elseif ((B_m ^ 2.0) <= 1e+297) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(Float64(A + Float64(C - hypot(B_m, Float64(A - C)))) / fma(-4.0, Float64(A * C), (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_] := 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-152], N[(N[Sqrt[N[(t$95$0 * N[(F * 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]], $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+297], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(N[(A + N[(C - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-4.0 * N[(A * C), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}
t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-152}:\\
\;\;\;\;\sqrt{t\_0 \cdot \left(F \cdot \left(2 \cdot \left(A + \left(A + -0.5 \cdot \frac{{B\_m}^{2}}{C}\right)\right)\right)\right)} \cdot \frac{-1}{t\_0}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{+297}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B\_m, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B\_m}^{2}\right)}}\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)) < 1.00000000000000007e-152Initial program 11.5%
Simplified21.6%
Taylor expanded in C around inf 20.5%
associate-*r/20.5%
mul-1-neg20.5%
Simplified20.5%
div-inv20.4%
associate-*l*22.6%
associate-/l*22.6%
Applied egg-rr22.6%
if 1.00000000000000007e-152 < (pow.f64 B #s(literal 2 binary64)) < 1e297Initial program 38.2%
Taylor expanded in F around 0 45.1%
mul-1-neg45.1%
*-commutative45.1%
associate-/l*50.6%
associate--l+50.7%
unpow250.7%
unpow250.7%
hypot-undefine59.6%
cancel-sign-sub-inv59.6%
Simplified59.6%
if 1e297 < (pow.f64 B #s(literal 2 binary64)) Initial program 1.6%
Taylor expanded in C around 0 3.2%
mul-1-neg3.2%
+-commutative3.2%
unpow23.2%
unpow23.2%
hypot-define25.2%
Simplified25.2%
Final simplification38.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-152)
(/
(sqrt (* -8.0 (* (* A C) (* F (+ A A)))))
(- (fma C (* A -4.0) (pow B_m 2.0))))
(if (<= (pow B_m 2.0) 1e+297)
(-
(sqrt
(*
2.0
(*
F
(/
(- (+ A C) (hypot B_m (- A C)))
(fma -4.0 (* A C) (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 (pow(B_m, 2.0) <= 1e-152) {
tmp = sqrt((-8.0 * ((A * C) * (F * (A + A))))) / -fma(C, (A * -4.0), pow(B_m, 2.0));
} else if (pow(B_m, 2.0) <= 1e+297) {
tmp = -sqrt((2.0 * (F * (((A + C) - hypot(B_m, (A - C))) / fma(-4.0, (A * C), 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 ^ 2.0) <= 1e-152) tmp = Float64(sqrt(Float64(-8.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))) / Float64(-fma(C, Float64(A * -4.0), (B_m ^ 2.0)))); elseif ((B_m ^ 2.0) <= 1e+297) tmp = Float64(-sqrt(Float64(2.0 * Float64(F * Float64(Float64(Float64(A + C) - hypot(B_m, Float64(A - C))) / fma(-4.0, Float64(A * C), (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[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-152], N[(N[Sqrt[N[(-8.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(C * N[(A * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision])), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+297], (-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[(-4.0 * N[(A * C), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 10^{-152}:\\
\;\;\;\;\frac{\sqrt{-8 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{-\mathsf{fma}\left(C, A \cdot -4, {B\_m}^{2}\right)}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{+297}:\\
\;\;\;\;-\sqrt{2 \cdot \left(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)}\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)) < 1.00000000000000007e-152Initial program 11.5%
Simplified20.3%
Taylor expanded in C around inf 20.4%
associate-*r*22.6%
*-commutative22.6%
mul-1-neg22.6%
Simplified22.6%
if 1.00000000000000007e-152 < (pow.f64 B #s(literal 2 binary64)) < 1e297Initial program 38.2%
Taylor expanded in F around 0 45.1%
mul-1-neg45.1%
*-commutative45.1%
associate-/l*50.6%
associate--l+50.7%
unpow250.7%
unpow250.7%
hypot-undefine59.6%
cancel-sign-sub-inv59.6%
Simplified59.6%
*-commutative59.6%
pow1/259.6%
pow1/259.6%
pow-prod-down59.8%
*-commutative59.8%
associate-+r-59.3%
*-commutative59.3%
Applied egg-rr59.3%
unpow1/259.3%
Simplified59.3%
if 1e297 < (pow.f64 B #s(literal 2 binary64)) Initial program 1.6%
Taylor expanded in C around 0 3.2%
mul-1-neg3.2%
+-commutative3.2%
unpow23.2%
unpow23.2%
hypot-define25.2%
Simplified25.2%
Final simplification38.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-147)
(*
(sqrt (* t_0 (* F (* 2.0 (+ A (+ A (* -0.5 (/ (pow B_m 2.0) C))))))))
(/ -1.0 t_0))
(if (<= (pow B_m 2.0) 1e+297)
(-
(sqrt
(*
2.0
(*
F
(/
(- (+ A C) (hypot B_m (- A C)))
(fma -4.0 (* A C) (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 t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (pow(B_m, 2.0) <= 5e-147) {
tmp = sqrt((t_0 * (F * (2.0 * (A + (A + (-0.5 * (pow(B_m, 2.0) / C)))))))) * (-1.0 / t_0);
} else if (pow(B_m, 2.0) <= 1e+297) {
tmp = -sqrt((2.0 * (F * (((A + C) - hypot(B_m, (A - C))) / fma(-4.0, (A * C), 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) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 5e-147) tmp = Float64(sqrt(Float64(t_0 * Float64(F * Float64(2.0 * Float64(A + Float64(A + Float64(-0.5 * Float64((B_m ^ 2.0) / C)))))))) * Float64(-1.0 / t_0)); elseif ((B_m ^ 2.0) <= 1e+297) tmp = Float64(-sqrt(Float64(2.0 * Float64(F * Float64(Float64(Float64(A + C) - hypot(B_m, Float64(A - C))) / fma(-4.0, Float64(A * C), (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_] := 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-147], N[(N[Sqrt[N[(t$95$0 * N[(F * 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]], $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+297], (-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[(-4.0 * N[(A * C), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}
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^{-147}:\\
\;\;\;\;\sqrt{t\_0 \cdot \left(F \cdot \left(2 \cdot \left(A + \left(A + -0.5 \cdot \frac{{B\_m}^{2}}{C}\right)\right)\right)\right)} \cdot \frac{-1}{t\_0}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{+297}:\\
\;\;\;\;-\sqrt{2 \cdot \left(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)}\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)) < 5.00000000000000013e-147Initial program 12.1%
Simplified22.0%
Taylor expanded in C around inf 20.1%
associate-*r/20.1%
mul-1-neg20.1%
Simplified20.1%
div-inv20.0%
associate-*l*22.2%
associate-/l*22.2%
Applied egg-rr22.2%
if 5.00000000000000013e-147 < (pow.f64 B #s(literal 2 binary64)) < 1e297Initial program 38.2%
Taylor expanded in F around 0 45.0%
mul-1-neg45.0%
*-commutative45.0%
associate-/l*50.6%
associate--l+50.7%
unpow250.7%
unpow250.7%
hypot-undefine59.7%
cancel-sign-sub-inv59.7%
Simplified59.7%
*-commutative59.7%
pow1/259.7%
pow1/259.7%
pow-prod-down59.9%
*-commutative59.9%
associate-+r-59.5%
*-commutative59.5%
Applied egg-rr59.5%
unpow1/259.5%
Simplified59.5%
if 1e297 < (pow.f64 B #s(literal 2 binary64)) Initial program 1.6%
Taylor expanded in C around 0 3.2%
mul-1-neg3.2%
+-commutative3.2%
unpow23.2%
unpow23.2%
hypot-define25.2%
Simplified25.2%
Final simplification38.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) 5e-147)
(/
-1.0
(/
t_0
(sqrt (* t_0 (* F (* 2.0 (+ A (+ A (* -0.5 (/ (pow B_m 2.0) C))))))))))
(if (<= (pow B_m 2.0) 1e+297)
(-
(sqrt
(*
2.0
(*
F
(/
(- (+ A C) (hypot B_m (- A C)))
(fma -4.0 (* A C) (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 t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (pow(B_m, 2.0) <= 5e-147) {
tmp = -1.0 / (t_0 / sqrt((t_0 * (F * (2.0 * (A + (A + (-0.5 * (pow(B_m, 2.0) / C)))))))));
} else if (pow(B_m, 2.0) <= 1e+297) {
tmp = -sqrt((2.0 * (F * (((A + C) - hypot(B_m, (A - C))) / fma(-4.0, (A * C), 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) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 5e-147) tmp = Float64(-1.0 / Float64(t_0 / sqrt(Float64(t_0 * Float64(F * Float64(2.0 * Float64(A + Float64(A + Float64(-0.5 * Float64((B_m ^ 2.0) / C)))))))))); elseif ((B_m ^ 2.0) <= 1e+297) tmp = Float64(-sqrt(Float64(2.0 * Float64(F * Float64(Float64(Float64(A + C) - hypot(B_m, Float64(A - C))) / fma(-4.0, Float64(A * C), (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_] := 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-147], N[(-1.0 / N[(t$95$0 / N[Sqrt[N[(t$95$0 * N[(F * 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]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+297], (-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[(-4.0 * N[(A * C), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}
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^{-147}:\\
\;\;\;\;\frac{-1}{\frac{t\_0}{\sqrt{t\_0 \cdot \left(F \cdot \left(2 \cdot \left(A + \left(A + -0.5 \cdot \frac{{B\_m}^{2}}{C}\right)\right)\right)\right)}}}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{+297}:\\
\;\;\;\;-\sqrt{2 \cdot \left(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)}\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)) < 5.00000000000000013e-147Initial program 12.1%
Simplified22.0%
Taylor expanded in C around inf 20.1%
associate-*r/20.1%
mul-1-neg20.1%
Simplified20.1%
clear-num20.1%
inv-pow20.1%
associate-*l*22.2%
associate-/l*22.2%
Applied egg-rr22.2%
unpow-122.2%
Simplified22.2%
if 5.00000000000000013e-147 < (pow.f64 B #s(literal 2 binary64)) < 1e297Initial program 38.2%
Taylor expanded in F around 0 45.0%
mul-1-neg45.0%
*-commutative45.0%
associate-/l*50.6%
associate--l+50.7%
unpow250.7%
unpow250.7%
hypot-undefine59.7%
cancel-sign-sub-inv59.7%
Simplified59.7%
*-commutative59.7%
pow1/259.7%
pow1/259.7%
pow-prod-down59.9%
*-commutative59.9%
associate-+r-59.5%
*-commutative59.5%
Applied egg-rr59.5%
unpow1/259.5%
Simplified59.5%
if 1e297 < (pow.f64 B #s(literal 2 binary64)) Initial program 1.6%
Taylor expanded in C around 0 3.2%
mul-1-neg3.2%
+-commutative3.2%
unpow23.2%
unpow23.2%
hypot-define25.2%
Simplified25.2%
Final simplification38.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-152)
(/
(sqrt (* -8.0 (* (* A 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 (pow(B_m, 2.0) <= 1e-152) {
tmp = sqrt((-8.0 * ((A * 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 ^ 2.0) <= 1e-152) tmp = Float64(sqrt(Float64(-8.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))) / Float64(-fma(C, Float64(A * -4.0), (B_m ^ 2.0)))); 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[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-152], N[(N[Sqrt[N[(-8.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(C * N[(A * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision])), $MachinePrecision], 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 10^{-152}:\\
\;\;\;\;\frac{\sqrt{-8 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{-\mathsf{fma}\left(C, A \cdot -4, {B\_m}^{2}\right)}\\
\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)) < 1.00000000000000007e-152Initial program 11.5%
Simplified20.3%
Taylor expanded in C around inf 20.4%
associate-*r*22.6%
*-commutative22.6%
mul-1-neg22.6%
Simplified22.6%
if 1.00000000000000007e-152 < (pow.f64 B #s(literal 2 binary64)) Initial program 24.7%
Taylor expanded in C around 0 16.0%
mul-1-neg16.0%
+-commutative16.0%
unpow216.0%
unpow216.0%
hypot-define24.9%
Simplified24.9%
Final simplification24.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 (* (sqrt (* F (- A (hypot B_m A)))) (/ (sqrt 2.0) (- B_m)))))
(if (<= C 1.35e-162)
t_0
(if (<= C 2.8e+19)
(* (sqrt (* F (/ (+ (+ (/ A B_m) (/ C B_m)) -1.0) B_m))) (- (sqrt 2.0)))
(if (<= C 1.08e+71) t_0 (* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C))))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
double tmp;
if (C <= 1.35e-162) {
tmp = t_0;
} else if (C <= 2.8e+19) {
tmp = sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m))) * -sqrt(2.0);
} else if (C <= 1.08e+71) {
tmp = t_0;
} else {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
}
return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double t_0 = Math.sqrt((F * (A - Math.hypot(B_m, A)))) * (Math.sqrt(2.0) / -B_m);
double tmp;
if (C <= 1.35e-162) {
tmp = t_0;
} else if (C <= 2.8e+19) {
tmp = Math.sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m))) * -Math.sqrt(2.0);
} else if (C <= 1.08e+71) {
tmp = t_0;
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): t_0 = math.sqrt((F * (A - math.hypot(B_m, A)))) * (math.sqrt(2.0) / -B_m) tmp = 0 if C <= 1.35e-162: tmp = t_0 elif C <= 2.8e+19: tmp = math.sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m))) * -math.sqrt(2.0) elif C <= 1.08e+71: tmp = t_0 else: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * Float64(sqrt(2.0) / Float64(-B_m))) tmp = 0.0 if (C <= 1.35e-162) tmp = t_0; elseif (C <= 2.8e+19) tmp = Float64(sqrt(Float64(F * Float64(Float64(Float64(Float64(A / B_m) + Float64(C / B_m)) + -1.0) / B_m))) * Float64(-sqrt(2.0))); elseif (C <= 1.08e+71) tmp = t_0; else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
t_0 = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
tmp = 0.0;
if (C <= 1.35e-162)
tmp = t_0;
elseif (C <= 2.8e+19)
tmp = sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m))) * -sqrt(2.0);
elseif (C <= 1.08e+71)
tmp = t_0;
else
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[C, 1.35e-162], t$95$0, If[LessEqual[C, 2.8e+19], N[(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] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[C, 1.08e+71], t$95$0, N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\mathbf{if}\;C \leq 1.35 \cdot 10^{-162}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;C \leq 2.8 \cdot 10^{+19}:\\
\;\;\;\;\sqrt{F \cdot \frac{\left(\frac{A}{B\_m} + \frac{C}{B\_m}\right) + -1}{B\_m}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;C \leq 1.08 \cdot 10^{+71}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\end{array}
\end{array}
if C < 1.34999999999999992e-162 or 2.8e19 < C < 1.08e71Initial program 25.4%
Taylor expanded in C around 0 14.0%
mul-1-neg14.0%
+-commutative14.0%
unpow214.0%
unpow214.0%
hypot-define20.8%
Simplified20.8%
if 1.34999999999999992e-162 < C < 2.8e19Initial program 21.2%
Taylor expanded in F around 0 23.4%
mul-1-neg23.4%
*-commutative23.4%
associate-/l*30.4%
associate--l+30.9%
unpow230.9%
unpow230.9%
hypot-undefine43.8%
cancel-sign-sub-inv43.8%
Simplified43.8%
Taylor expanded in B around inf 28.8%
if 1.08e71 < C Initial program 0.9%
Taylor expanded in F around 0 1.0%
mul-1-neg1.0%
*-commutative1.0%
associate-/l*1.0%
associate--l+1.3%
unpow21.3%
unpow21.3%
hypot-undefine7.0%
cancel-sign-sub-inv7.0%
Simplified7.0%
Taylor expanded in A around -inf 47.8%
Final simplification27.1%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (if (<= C 3.8e+24) (* (sqrt (* F (/ (+ (+ (/ A B_m) (/ C B_m)) -1.0) B_m))) (- (sqrt 2.0))) (* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C)))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (C <= 3.8e+24) {
tmp = sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m))) * -sqrt(2.0);
} else {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
}
return tmp;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (c <= 3.8d+24) then
tmp = sqrt((f * ((((a / b_m) + (c / b_m)) + (-1.0d0)) / b_m))) * -sqrt(2.0d0)
else
tmp = sqrt(2.0d0) * -sqrt((f * ((-0.5d0) / c)))
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (C <= 3.8e+24) {
tmp = Math.sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m))) * -Math.sqrt(2.0);
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if C <= 3.8e+24: tmp = math.sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m))) * -math.sqrt(2.0) else: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (C <= 3.8e+24) tmp = Float64(sqrt(Float64(F * Float64(Float64(Float64(Float64(A / B_m) + Float64(C / B_m)) + -1.0) / B_m))) * Float64(-sqrt(2.0))); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (C <= 3.8e+24)
tmp = sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m))) * -sqrt(2.0);
else
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[C, 3.8e+24], N[(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] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;C \leq 3.8 \cdot 10^{+24}:\\
\;\;\;\;\sqrt{F \cdot \frac{\left(\frac{A}{B\_m} + \frac{C}{B\_m}\right) + -1}{B\_m}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\end{array}
\end{array}
if C < 3.80000000000000015e24Initial program 25.4%
Taylor expanded in F around 0 27.2%
mul-1-neg27.2%
*-commutative27.2%
associate-/l*31.0%
associate--l+31.1%
unpow231.1%
unpow231.1%
hypot-undefine38.0%
cancel-sign-sub-inv38.0%
Simplified38.0%
Taylor expanded in B around inf 19.8%
if 3.80000000000000015e24 < C Initial program 1.0%
Taylor expanded in F around 0 1.1%
mul-1-neg1.1%
*-commutative1.1%
associate-/l*1.1%
associate--l+1.6%
unpow21.6%
unpow21.6%
hypot-undefine6.9%
cancel-sign-sub-inv6.9%
Simplified6.9%
Taylor expanded in A around -inf 44.0%
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 (<= C 2.1e+70) (* (sqrt 2.0) (- (sqrt (* F (/ -1.0 B_m))))) (* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C)))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (C <= 2.1e+70) {
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
} else {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
}
return tmp;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (c <= 2.1d+70) then
tmp = sqrt(2.0d0) * -sqrt((f * ((-1.0d0) / b_m)))
else
tmp = sqrt(2.0d0) * -sqrt((f * ((-0.5d0) / c)))
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (C <= 2.1e+70) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-1.0 / B_m)));
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if C <= 2.1e+70: tmp = math.sqrt(2.0) * -math.sqrt((F * (-1.0 / B_m))) else: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (C <= 2.1e+70) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-1.0 / B_m))))); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (C <= 2.1e+70)
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
else
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[C, 2.1e+70], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;C \leq 2.1 \cdot 10^{+70}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-1}{B\_m}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\end{array}
\end{array}
if C < 2.10000000000000008e70Initial program 24.6%
Taylor expanded in F around 0 26.3%
mul-1-neg26.3%
*-commutative26.3%
associate-/l*30.0%
associate--l+30.2%
unpow230.2%
unpow230.2%
hypot-undefine37.0%
cancel-sign-sub-inv37.0%
Simplified37.0%
Taylor expanded in B around inf 17.8%
if 2.10000000000000008e70 < C Initial program 0.9%
Taylor expanded in F around 0 1.0%
mul-1-neg1.0%
*-commutative1.0%
associate-/l*1.0%
associate--l+1.3%
unpow21.3%
unpow21.3%
hypot-undefine7.0%
cancel-sign-sub-inv7.0%
Simplified7.0%
Taylor expanded in A around -inf 47.8%
Final simplification23.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 (* (sqrt 2.0) (- (sqrt (* F (/ -1.0 B_m))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = sqrt(2.0d0) * -sqrt((f * ((-1.0d0) / b_m)))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return Math.sqrt(2.0) * -Math.sqrt((F * (-1.0 / B_m)));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return math.sqrt(2.0) * -math.sqrt((F * (-1.0 / B_m)))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-1.0 / B_m))))) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = sqrt(2.0) * -sqrt((F * (-1.0 / B_m)));
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-1}{B\_m}}\right)
\end{array}
Initial program 20.2%
Taylor expanded in F around 0 21.6%
mul-1-neg21.6%
*-commutative21.6%
associate-/l*24.6%
associate--l+24.8%
unpow224.8%
unpow224.8%
hypot-undefine31.4%
cancel-sign-sub-inv31.4%
Simplified31.4%
Taylor expanded in B around inf 15.7%
Final simplification15.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 (* 0.25 (* (sqrt (/ F C)) (sqrt -16.0))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return 0.25 * (sqrt((F / C)) * sqrt(-16.0));
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = 0.25d0 * (sqrt((f / c)) * sqrt((-16.0d0)))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return 0.25 * (Math.sqrt((F / C)) * Math.sqrt(-16.0));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return 0.25 * (math.sqrt((F / C)) * math.sqrt(-16.0))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(0.25 * Float64(sqrt(Float64(F / C)) * sqrt(-16.0))) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = 0.25 * (sqrt((F / C)) * sqrt(-16.0));
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[(0.25 * N[(N[Sqrt[N[(F / C), $MachinePrecision]], $MachinePrecision] * N[Sqrt[-16.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
0.25 \cdot \left(\sqrt{\frac{F}{C}} \cdot \sqrt{-16}\right)
\end{array}
Initial program 20.2%
Simplified22.5%
Taylor expanded in C around inf 9.4%
Taylor expanded in A around inf 0.0%
Final simplification0.0%
herbie shell --seed 2024095
(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))))