
(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 12 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 (- A (hypot B_m A))) (t_1 (fma B_m B_m (* A (* C -4.0)))))
(if (<= B_m 1.65e-223)
(/
(-
(pow
(*
(exp (* 0.25 (+ (log (* -8.0 (* C F))) (* -2.0 (log (/ -1.0 A))))))
(sqrt (sqrt 2.0)))
2.0))
t_1)
(if (<= B_m 9.5e-83)
(/ (- (pow (sqrt (sqrt (* t_1 (* F (* 2.0 (* A 2.0)))))) 2.0)) t_1)
(if (<= B_m 2.2e-42)
(* (sqrt (* -0.5 (/ (pow B_m 2.0) (/ C F)))) (/ (- (sqrt 2.0)) B_m))
(if (<= B_m 3.5e+37)
(/ (- (sqrt (* (* F t_1) (* 2.0 t_0)))) t_1)
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F t_0))))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = A - hypot(B_m, A);
double t_1 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (B_m <= 1.65e-223) {
tmp = -pow((exp((0.25 * (log((-8.0 * (C * F))) + (-2.0 * log((-1.0 / A)))))) * sqrt(sqrt(2.0))), 2.0) / t_1;
} else if (B_m <= 9.5e-83) {
tmp = -pow(sqrt(sqrt((t_1 * (F * (2.0 * (A * 2.0)))))), 2.0) / t_1;
} else if (B_m <= 2.2e-42) {
tmp = sqrt((-0.5 * (pow(B_m, 2.0) / (C / F)))) * (-sqrt(2.0) / B_m);
} else if (B_m <= 3.5e+37) {
tmp = -sqrt(((F * t_1) * (2.0 * t_0))) / t_1;
} else {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * t_0));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(A - hypot(B_m, A)) t_1 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (B_m <= 1.65e-223) tmp = Float64(Float64(-(Float64(exp(Float64(0.25 * Float64(log(Float64(-8.0 * Float64(C * F))) + Float64(-2.0 * log(Float64(-1.0 / A)))))) * sqrt(sqrt(2.0))) ^ 2.0)) / t_1); elseif (B_m <= 9.5e-83) tmp = Float64(Float64(-(sqrt(sqrt(Float64(t_1 * Float64(F * Float64(2.0 * Float64(A * 2.0)))))) ^ 2.0)) / t_1); elseif (B_m <= 2.2e-42) tmp = Float64(sqrt(Float64(-0.5 * Float64((B_m ^ 2.0) / Float64(C / F)))) * Float64(Float64(-sqrt(2.0)) / B_m)); elseif (B_m <= 3.5e+37) tmp = Float64(Float64(-sqrt(Float64(Float64(F * t_1) * Float64(2.0 * t_0)))) / t_1); else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * t_0)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 1.65e-223], N[((-N[Power[N[(N[Exp[N[(0.25 * N[(N[Log[N[(-8.0 * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-2.0 * N[Log[N[(-1.0 / A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Sqrt[2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B$95$m, 9.5e-83], N[((-N[Power[N[Sqrt[N[Sqrt[N[(t$95$1 * N[(F * N[(2.0 * N[(A * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B$95$m, 2.2e-42], N[(N[Sqrt[N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / N[(C / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 3.5e+37], N[((-N[Sqrt[N[(N[(F * t$95$1), $MachinePrecision] * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * t$95$0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := A - \mathsf{hypot}\left(B_m, A\right)\\
t_1 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;B_m \leq 1.65 \cdot 10^{-223}:\\
\;\;\;\;\frac{-{\left(e^{0.25 \cdot \left(\log \left(-8 \cdot \left(C \cdot F\right)\right) + -2 \cdot \log \left(\frac{-1}{A}\right)\right)} \cdot \sqrt{\sqrt{2}}\right)}^{2}}{t_1}\\
\mathbf{elif}\;B_m \leq 9.5 \cdot 10^{-83}:\\
\;\;\;\;\frac{-{\left(\sqrt{\sqrt{t_1 \cdot \left(F \cdot \left(2 \cdot \left(A \cdot 2\right)\right)\right)}}\right)}^{2}}{t_1}\\
\mathbf{elif}\;B_m \leq 2.2 \cdot 10^{-42}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{{B_m}^{2}}{\frac{C}{F}}} \cdot \frac{-\sqrt{2}}{B_m}\\
\mathbf{elif}\;B_m \leq 3.5 \cdot 10^{+37}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot t_1\right) \cdot \left(2 \cdot t_0\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot t_0}\right)\\
\end{array}
\end{array}
if B < 1.64999999999999997e-223Initial program 19.6%
Simplified25.3%
add-sqr-sqrt25.2%
pow225.2%
associate-*l*25.3%
*-commutative25.3%
associate-+r-24.0%
+-commutative24.0%
Applied egg-rr24.0%
Taylor expanded in A around -inf 16.5%
if 1.64999999999999997e-223 < B < 9.50000000000000051e-83Initial program 26.9%
Simplified34.1%
add-sqr-sqrt34.1%
pow234.1%
associate-*l*37.6%
*-commutative37.6%
associate-+r-34.5%
+-commutative34.5%
Applied egg-rr34.5%
Taylor expanded in A around -inf 39.6%
if 9.50000000000000051e-83 < B < 2.20000000000000005e-42Initial program 22.1%
Simplified41.0%
Taylor expanded in A around 0 31.5%
mul-1-neg31.5%
*-commutative31.5%
distribute-rgt-neg-in31.5%
unpow231.5%
unpow231.5%
hypot-def31.5%
Simplified31.5%
Taylor expanded in C around inf 20.8%
associate-/l*20.8%
Simplified20.8%
if 2.20000000000000005e-42 < B < 3.5e37Initial program 36.8%
Simplified51.4%
Taylor expanded in C around 0 30.7%
mul-1-neg30.7%
+-commutative30.7%
unpow230.7%
unpow230.7%
hypot-def38.4%
Simplified38.4%
if 3.5e37 < B Initial program 14.2%
Simplified8.8%
Taylor expanded in C around 0 22.0%
mul-1-neg22.0%
*-commutative22.0%
distribute-rgt-neg-in22.0%
+-commutative22.0%
unpow222.0%
unpow222.0%
hypot-def47.7%
Simplified47.7%
Final simplification28.7%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0
(/
(- (sqrt (* -8.0 (* A (* C (* F (+ A A)))))))
(fma A (* C -4.0) (pow B_m 2.0)))))
(if (<= (pow B_m 2.0) 4e-179)
t_0
(if (<= (pow B_m 2.0) 5e-73)
(* (sqrt (* -0.5 (/ (pow B_m 2.0) (/ C F)))) (/ (- (sqrt 2.0)) B_m))
(if (<= (pow B_m 2.0) 5e-42)
t_0
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m 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) {
double t_0 = -sqrt((-8.0 * (A * (C * (F * (A + A)))))) / fma(A, (C * -4.0), pow(B_m, 2.0));
double tmp;
if (pow(B_m, 2.0) <= 4e-179) {
tmp = t_0;
} else if (pow(B_m, 2.0) <= 5e-73) {
tmp = sqrt((-0.5 * (pow(B_m, 2.0) / (C / F)))) * (-sqrt(2.0) / B_m);
} else if (pow(B_m, 2.0) <= 5e-42) {
tmp = t_0;
} else {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(Float64(-sqrt(Float64(-8.0 * Float64(A * Float64(C * Float64(F * Float64(A + A))))))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 4e-179) tmp = t_0; elseif ((B_m ^ 2.0) <= 5e-73) tmp = Float64(sqrt(Float64(-0.5 * Float64((B_m ^ 2.0) / Float64(C / F)))) * Float64(Float64(-sqrt(2.0)) / B_m)); elseif ((B_m ^ 2.0) <= 5e-42) tmp = t_0; else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[((-N[Sqrt[N[(-8.0 * N[(A * N[(C * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e-179], t$95$0, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-73], N[(N[Sqrt[N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / N[(C / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-42], t$95$0, 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]]]]]
\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 := \frac{-\sqrt{-8 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}\\
\mathbf{if}\;{B_m}^{2} \leq 4 \cdot 10^{-179}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;{B_m}^{2} \leq 5 \cdot 10^{-73}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{{B_m}^{2}}{\frac{C}{F}}} \cdot \frac{-\sqrt{2}}{B_m}\\
\mathbf{elif}\;{B_m}^{2} \leq 5 \cdot 10^{-42}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 4.0000000000000001e-179 or 4.9999999999999998e-73 < (pow.f64 B 2) < 5.00000000000000003e-42Initial program 23.7%
Simplified24.3%
Taylor expanded in C around inf 30.7%
if 4.0000000000000001e-179 < (pow.f64 B 2) < 4.9999999999999998e-73Initial program 33.2%
Simplified38.0%
Taylor expanded in A around 0 20.4%
mul-1-neg20.4%
*-commutative20.4%
distribute-rgt-neg-in20.4%
unpow220.4%
unpow220.4%
hypot-def20.4%
Simplified20.4%
Taylor expanded in C around inf 12.5%
associate-/l*11.9%
Simplified11.9%
if 5.00000000000000003e-42 < (pow.f64 B 2) Initial program 15.7%
Simplified14.1%
Taylor expanded in C around 0 13.4%
mul-1-neg13.4%
*-commutative13.4%
distribute-rgt-neg-in13.4%
+-commutative13.4%
unpow213.4%
unpow213.4%
hypot-def26.3%
Simplified26.3%
Final simplification26.9%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma B_m B_m (* A (* C -4.0)))) (t_1 (- A (hypot B_m A))))
(if (<= (pow B_m 2.0) 5e-186)
(/
(- (sqrt (* -8.0 (* A (* C (* F (+ A A)))))))
(fma A (* C -4.0) (pow B_m 2.0)))
(if (<= (pow B_m 2.0) 1e+75)
(/ (- (sqrt (* t_0 (* F (* 2.0 t_1))))) t_0)
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F t_1))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double t_1 = A - hypot(B_m, A);
double tmp;
if (pow(B_m, 2.0) <= 5e-186) {
tmp = -sqrt((-8.0 * (A * (C * (F * (A + A)))))) / fma(A, (C * -4.0), pow(B_m, 2.0));
} else if (pow(B_m, 2.0) <= 1e+75) {
tmp = -sqrt((t_0 * (F * (2.0 * t_1)))) / t_0;
} else {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * t_1));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_1 = Float64(A - hypot(B_m, A)) tmp = 0.0 if ((B_m ^ 2.0) <= 5e-186) tmp = Float64(Float64(-sqrt(Float64(-8.0 * Float64(A * Float64(C * Float64(F * Float64(A + A))))))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0))); elseif ((B_m ^ 2.0) <= 1e+75) tmp = Float64(Float64(-sqrt(Float64(t_0 * Float64(F * Float64(2.0 * t_1))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * t_1)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-186], N[((-N[Sqrt[N[(-8.0 * N[(A * N[(C * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+75], N[((-N[Sqrt[N[(t$95$0 * N[(F * N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * t$95$1), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := A - \mathsf{hypot}\left(B_m, A\right)\\
\mathbf{if}\;{B_m}^{2} \leq 5 \cdot 10^{-186}:\\
\;\;\;\;\frac{-\sqrt{-8 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}\\
\mathbf{elif}\;{B_m}^{2} \leq 10^{+75}:\\
\;\;\;\;\frac{-\sqrt{t_0 \cdot \left(F \cdot \left(2 \cdot t_1\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot t_1}\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 5e-186Initial program 22.8%
Simplified23.1%
Taylor expanded in C around inf 30.0%
if 5e-186 < (pow.f64 B 2) < 9.99999999999999927e74Initial program 39.3%
Simplified47.3%
Taylor expanded in C around 0 35.5%
mul-1-neg35.5%
+-commutative35.5%
unpow235.5%
unpow235.5%
hypot-def40.3%
Simplified40.3%
distribute-frac-neg40.3%
associate-*l*40.3%
sub-neg40.3%
Applied egg-rr40.3%
if 9.99999999999999927e74 < (pow.f64 B 2) Initial program 11.4%
Simplified8.5%
Taylor expanded in C around 0 12.7%
mul-1-neg12.7%
*-commutative12.7%
distribute-rgt-neg-in12.7%
+-commutative12.7%
unpow212.7%
unpow212.7%
hypot-def27.4%
Simplified27.4%
Final simplification30.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)))) (t_1 (- A (hypot B_m A))))
(if (<= B_m 1.22e-82)
(/ (- (pow (sqrt (sqrt (* t_0 (* F (* 2.0 (* A 2.0)))))) 2.0)) t_0)
(if (<= B_m 1.45e-41)
(* (sqrt (* -0.5 (/ (pow B_m 2.0) (/ C F)))) (/ (- (sqrt 2.0)) B_m))
(if (<= B_m 7.4e+37)
(/ (- (sqrt (* (* F t_0) (* 2.0 t_1)))) t_0)
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F t_1)))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double t_1 = A - hypot(B_m, A);
double tmp;
if (B_m <= 1.22e-82) {
tmp = -pow(sqrt(sqrt((t_0 * (F * (2.0 * (A * 2.0)))))), 2.0) / t_0;
} else if (B_m <= 1.45e-41) {
tmp = sqrt((-0.5 * (pow(B_m, 2.0) / (C / F)))) * (-sqrt(2.0) / B_m);
} else if (B_m <= 7.4e+37) {
tmp = -sqrt(((F * t_0) * (2.0 * t_1))) / t_0;
} else {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * t_1));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_1 = Float64(A - hypot(B_m, A)) tmp = 0.0 if (B_m <= 1.22e-82) tmp = Float64(Float64(-(sqrt(sqrt(Float64(t_0 * Float64(F * Float64(2.0 * Float64(A * 2.0)))))) ^ 2.0)) / t_0); elseif (B_m <= 1.45e-41) tmp = Float64(sqrt(Float64(-0.5 * Float64((B_m ^ 2.0) / Float64(C / F)))) * Float64(Float64(-sqrt(2.0)) / B_m)); elseif (B_m <= 7.4e+37) tmp = Float64(Float64(-sqrt(Float64(Float64(F * t_0) * Float64(2.0 * t_1)))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * t_1)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 1.22e-82], N[((-N[Power[N[Sqrt[N[Sqrt[N[(t$95$0 * N[(F * N[(2.0 * N[(A * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B$95$m, 1.45e-41], N[(N[Sqrt[N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / N[(C / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 7.4e+37], N[((-N[Sqrt[N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * t$95$1), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := A - \mathsf{hypot}\left(B_m, A\right)\\
\mathbf{if}\;B_m \leq 1.22 \cdot 10^{-82}:\\
\;\;\;\;\frac{-{\left(\sqrt{\sqrt{t_0 \cdot \left(F \cdot \left(2 \cdot \left(A \cdot 2\right)\right)\right)}}\right)}^{2}}{t_0}\\
\mathbf{elif}\;B_m \leq 1.45 \cdot 10^{-41}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{{B_m}^{2}}{\frac{C}{F}}} \cdot \frac{-\sqrt{2}}{B_m}\\
\mathbf{elif}\;B_m \leq 7.4 \cdot 10^{+37}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot t_0\right) \cdot \left(2 \cdot t_1\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot t_1}\right)\\
\end{array}
\end{array}
if B < 1.22000000000000001e-82Initial program 20.9%
Simplified26.8%
add-sqr-sqrt26.7%
pow226.7%
associate-*l*27.4%
*-commutative27.4%
associate-+r-25.8%
+-commutative25.8%
Applied egg-rr25.8%
Taylor expanded in A around -inf 21.7%
if 1.22000000000000001e-82 < B < 1.44999999999999989e-41Initial program 22.1%
Simplified41.0%
Taylor expanded in A around 0 31.5%
mul-1-neg31.5%
*-commutative31.5%
distribute-rgt-neg-in31.5%
unpow231.5%
unpow231.5%
hypot-def31.5%
Simplified31.5%
Taylor expanded in C around inf 20.8%
associate-/l*20.8%
Simplified20.8%
if 1.44999999999999989e-41 < B < 7.3999999999999999e37Initial program 36.8%
Simplified51.4%
Taylor expanded in C around 0 30.7%
mul-1-neg30.7%
+-commutative30.7%
unpow230.7%
unpow230.7%
hypot-def38.4%
Simplified38.4%
if 7.3999999999999999e37 < B Initial program 14.2%
Simplified8.8%
Taylor expanded in C around 0 22.0%
mul-1-neg22.0%
*-commutative22.0%
distribute-rgt-neg-in22.0%
+-commutative22.0%
unpow222.0%
unpow222.0%
hypot-def47.7%
Simplified47.7%
Final simplification29.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) 5e-202)
(/
(- (sqrt (* -16.0 (* (* C F) (pow A 2.0)))))
(+ (pow B_m 2.0) (* -4.0 (* C A))))
(if (<= (pow B_m 2.0) 5e-42)
(* (sqrt (* -0.5 (/ (pow B_m 2.0) (/ C F)))) (/ (- (sqrt 2.0)) B_m))
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m 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) {
double tmp;
if (pow(B_m, 2.0) <= 5e-202) {
tmp = -sqrt((-16.0 * ((C * F) * pow(A, 2.0)))) / (pow(B_m, 2.0) + (-4.0 * (C * A)));
} else if (pow(B_m, 2.0) <= 5e-42) {
tmp = sqrt((-0.5 * (pow(B_m, 2.0) / (C / F)))) * (-sqrt(2.0) / B_m);
} else {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
}
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) <= 5e-202) {
tmp = -Math.sqrt((-16.0 * ((C * F) * Math.pow(A, 2.0)))) / (Math.pow(B_m, 2.0) + (-4.0 * (C * A)));
} else if (Math.pow(B_m, 2.0) <= 5e-42) {
tmp = Math.sqrt((-0.5 * (Math.pow(B_m, 2.0) / (C / F)))) * (-Math.sqrt(2.0) / B_m);
} else {
tmp = (Math.sqrt(2.0) / B_m) * -Math.sqrt((F * (A - Math.hypot(B_m, A))));
}
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) <= 5e-202: tmp = -math.sqrt((-16.0 * ((C * F) * math.pow(A, 2.0)))) / (math.pow(B_m, 2.0) + (-4.0 * (C * A))) elif math.pow(B_m, 2.0) <= 5e-42: tmp = math.sqrt((-0.5 * (math.pow(B_m, 2.0) / (C / F)))) * (-math.sqrt(2.0) / B_m) else: tmp = (math.sqrt(2.0) / B_m) * -math.sqrt((F * (A - math.hypot(B_m, A)))) 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-202) tmp = Float64(Float64(-sqrt(Float64(-16.0 * Float64(Float64(C * F) * (A ^ 2.0))))) / Float64((B_m ^ 2.0) + Float64(-4.0 * Float64(C * A)))); elseif ((B_m ^ 2.0) <= 5e-42) tmp = Float64(sqrt(Float64(-0.5 * Float64((B_m ^ 2.0) / Float64(C / F)))) * Float64(Float64(-sqrt(2.0)) / B_m)); else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); 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) <= 5e-202)
tmp = -sqrt((-16.0 * ((C * F) * (A ^ 2.0)))) / ((B_m ^ 2.0) + (-4.0 * (C * A)));
elseif ((B_m ^ 2.0) <= 5e-42)
tmp = sqrt((-0.5 * ((B_m ^ 2.0) / (C / F)))) * (-sqrt(2.0) / B_m);
else
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
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], 5e-202], N[((-N[Sqrt[N[(-16.0 * N[(N[(C * F), $MachinePrecision] * N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[(-4.0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-42], N[(N[Sqrt[N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / N[(C / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision]), $MachinePrecision], 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]]]
\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^{-202}:\\
\;\;\;\;\frac{-\sqrt{-16 \cdot \left(\left(C \cdot F\right) \cdot {A}^{2}\right)}}{{B_m}^{2} + -4 \cdot \left(C \cdot A\right)}\\
\mathbf{elif}\;{B_m}^{2} \leq 5 \cdot 10^{-42}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{{B_m}^{2}}{\frac{C}{F}}} \cdot \frac{-\sqrt{2}}{B_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 4.99999999999999973e-202Initial program 23.2%
Simplified23.6%
Taylor expanded in A around -inf 23.2%
*-commutative23.2%
Simplified23.2%
Taylor expanded in A around 0 24.2%
if 4.99999999999999973e-202 < (pow.f64 B 2) < 5.00000000000000003e-42Initial program 32.4%
Simplified36.7%
Taylor expanded in A around 0 15.6%
mul-1-neg15.6%
*-commutative15.6%
distribute-rgt-neg-in15.6%
unpow215.6%
unpow215.6%
hypot-def15.7%
Simplified15.7%
Taylor expanded in C around inf 13.4%
associate-/l*13.0%
Simplified13.0%
if 5.00000000000000003e-42 < (pow.f64 B 2) Initial program 15.7%
Simplified14.1%
Taylor expanded in C around 0 13.4%
mul-1-neg13.4%
*-commutative13.4%
distribute-rgt-neg-in13.4%
+-commutative13.4%
unpow213.4%
unpow213.4%
hypot-def26.3%
Simplified26.3%
Final simplification24.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-193)
(/
(- (sqrt (* (* -8.0 A) (* (* C F) (+ A A)))))
(fma A (* C -4.0) (pow B_m 2.0)))
(if (<= (pow B_m 2.0) 5e-42)
(* (sqrt (* -0.5 (/ (pow B_m 2.0) (/ C F)))) (/ (- (sqrt 2.0)) B_m))
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m 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) {
double tmp;
if (pow(B_m, 2.0) <= 5e-193) {
tmp = -sqrt(((-8.0 * A) * ((C * F) * (A + A)))) / fma(A, (C * -4.0), pow(B_m, 2.0));
} else if (pow(B_m, 2.0) <= 5e-42) {
tmp = sqrt((-0.5 * (pow(B_m, 2.0) / (C / F)))) * (-sqrt(2.0) / B_m);
} else {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
}
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-193) tmp = Float64(Float64(-sqrt(Float64(Float64(-8.0 * A) * Float64(Float64(C * F) * Float64(A + A))))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0))); elseif ((B_m ^ 2.0) <= 5e-42) tmp = Float64(sqrt(Float64(-0.5 * Float64((B_m ^ 2.0) / Float64(C / F)))) * Float64(Float64(-sqrt(2.0)) / B_m)); else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); 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-193], N[((-N[Sqrt[N[(N[(-8.0 * A), $MachinePrecision] * N[(N[(C * F), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-42], N[(N[Sqrt[N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / N[(C / F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision]), $MachinePrecision], 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]]]
\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^{-193}:\\
\;\;\;\;\frac{-\sqrt{\left(-8 \cdot A\right) \cdot \left(\left(C \cdot F\right) \cdot \left(A + A\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}\\
\mathbf{elif}\;{B_m}^{2} \leq 5 \cdot 10^{-42}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{{B_m}^{2}}{\frac{C}{F}}} \cdot \frac{-\sqrt{2}}{B_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 5.0000000000000005e-193Initial program 23.0%
Simplified23.3%
Taylor expanded in C around inf 29.3%
associate-*r*29.3%
rem-square-sqrt0.0%
unpow20.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt29.3%
associate-*r*27.6%
*-commutative27.6%
sub-neg27.6%
mul-1-neg27.6%
remove-double-neg27.6%
Simplified27.6%
if 5.0000000000000005e-193 < (pow.f64 B 2) < 5.00000000000000003e-42Initial program 33.7%
Simplified38.0%
Taylor expanded in A around 0 16.1%
mul-1-neg16.1%
*-commutative16.1%
distribute-rgt-neg-in16.1%
unpow216.1%
unpow216.1%
hypot-def16.2%
Simplified16.2%
Taylor expanded in C around inf 13.8%
associate-/l*13.3%
Simplified13.3%
if 5.00000000000000003e-42 < (pow.f64 B 2) Initial program 15.7%
Simplified14.1%
Taylor expanded in C around 0 13.4%
mul-1-neg13.4%
*-commutative13.4%
distribute-rgt-neg-in13.4%
+-commutative13.4%
unpow213.4%
unpow213.4%
hypot-def26.3%
Simplified26.3%
Final simplification25.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 (<= C 3.7e+115) (* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A)))))) (* (sqrt (* -0.5 (/ (pow B_m 2.0) (/ C F)))) (/ (- (sqrt 2.0)) B_m))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (C <= 3.7e+115) {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
} else {
tmp = sqrt((-0.5 * (pow(B_m, 2.0) / (C / F)))) * (-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 (C <= 3.7e+115) {
tmp = (Math.sqrt(2.0) / B_m) * -Math.sqrt((F * (A - Math.hypot(B_m, A))));
} else {
tmp = Math.sqrt((-0.5 * (Math.pow(B_m, 2.0) / (C / F)))) * (-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 C <= 3.7e+115: tmp = (math.sqrt(2.0) / B_m) * -math.sqrt((F * (A - math.hypot(B_m, A)))) else: tmp = math.sqrt((-0.5 * (math.pow(B_m, 2.0) / (C / F)))) * (-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 (C <= 3.7e+115) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); else tmp = Float64(sqrt(Float64(-0.5 * Float64((B_m ^ 2.0) / Float64(C / F)))) * Float64(Float64(-sqrt(2.0)) / B_m)); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (C <= 3.7e+115)
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
else
tmp = sqrt((-0.5 * ((B_m ^ 2.0) / (C / F)))) * (-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[C, 3.7e+115], 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[(N[Sqrt[N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / N[(C / F), $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}\;C \leq 3.7 \cdot 10^{+115}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{{B_m}^{2}}{\frac{C}{F}}} \cdot \frac{-\sqrt{2}}{B_m}\\
\end{array}
\end{array}
if C < 3.70000000000000006e115Initial program 23.7%
Simplified23.0%
Taylor expanded in C around 0 11.1%
mul-1-neg11.1%
*-commutative11.1%
distribute-rgt-neg-in11.1%
+-commutative11.1%
unpow211.1%
unpow211.1%
hypot-def18.9%
Simplified18.9%
if 3.70000000000000006e115 < C Initial program 1.2%
Simplified2.7%
Taylor expanded in A around 0 2.0%
mul-1-neg2.0%
*-commutative2.0%
distribute-rgt-neg-in2.0%
unpow22.0%
unpow22.0%
hypot-def9.3%
Simplified9.3%
Taylor expanded in C around inf 20.1%
associate-/l*17.9%
Simplified17.9%
Final simplification18.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 (if (<= C 5.8e+115) (* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A)))))) (* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (* -0.5 (/ (pow B_m 2.0) 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 <= 5.8e+115) {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (-0.5 * (pow(B_m, 2.0) / C))));
}
return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (C <= 5.8e+115) {
tmp = (Math.sqrt(2.0) / B_m) * -Math.sqrt((F * (A - Math.hypot(B_m, A))));
} else {
tmp = (-Math.sqrt(2.0) / B_m) * Math.sqrt((F * (-0.5 * (Math.pow(B_m, 2.0) / 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 <= 5.8e+115: tmp = (math.sqrt(2.0) / B_m) * -math.sqrt((F * (A - math.hypot(B_m, A)))) else: tmp = (-math.sqrt(2.0) / B_m) * math.sqrt((F * (-0.5 * (math.pow(B_m, 2.0) / 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 <= 5.8e+115) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(-0.5 * Float64((B_m ^ 2.0) / 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 <= 5.8e+115)
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
else
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (-0.5 * ((B_m ^ 2.0) / 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, 5.8e+115], 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[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $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 5.8 \cdot 10^{+115}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(-0.5 \cdot \frac{{B_m}^{2}}{C}\right)}\\
\end{array}
\end{array}
if C < 5.80000000000000009e115Initial program 23.7%
Simplified23.0%
Taylor expanded in C around 0 11.1%
mul-1-neg11.1%
*-commutative11.1%
distribute-rgt-neg-in11.1%
+-commutative11.1%
unpow211.1%
unpow211.1%
hypot-def18.9%
Simplified18.9%
if 5.80000000000000009e115 < C Initial program 1.2%
Simplified2.7%
Taylor expanded in A around 0 2.0%
mul-1-neg2.0%
*-commutative2.0%
distribute-rgt-neg-in2.0%
unpow22.0%
unpow22.0%
hypot-def9.3%
Simplified9.3%
Taylor expanded in C around inf 22.5%
Final simplification19.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) B_m) (- (sqrt (* F (- A (hypot B_m 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(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
}
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) / B_m) * -Math.sqrt((F * (A - Math.hypot(B_m, 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(2.0) / B_m) * -math.sqrt((F * (A - math.hypot(B_m, 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(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, 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(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, 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[(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]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\right)
\end{array}
Initial program 20.0%
Simplified19.7%
Taylor expanded in C around 0 9.9%
mul-1-neg9.9%
*-commutative9.9%
distribute-rgt-neg-in9.9%
+-commutative9.9%
unpow29.9%
unpow29.9%
hypot-def17.2%
Simplified17.2%
Final simplification17.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) B_m) (- (sqrt (* B_m (- F))))))
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) / B_m) * -sqrt((B_m * -F));
}
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) / b_m) * -sqrt((b_m * -f))
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) / B_m) * -Math.sqrt((B_m * -F));
}
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) / B_m) * -math.sqrt((B_m * -F))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(B_m * Float64(-F))))) 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) / B_m) * -sqrt((B_m * -F));
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[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(B$95$m * (-F)), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{B_m \cdot \left(-F\right)}\right)
\end{array}
Initial program 20.0%
Simplified19.7%
Taylor expanded in A around 0 9.6%
mul-1-neg9.6%
*-commutative9.6%
distribute-rgt-neg-in9.6%
unpow29.6%
unpow29.6%
hypot-def16.0%
Simplified16.0%
Taylor expanded in C around 0 14.5%
mul-1-neg14.5%
Simplified14.5%
Final simplification14.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) B_m) (- (sqrt (* B_m F)))))
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) / B_m) * -sqrt((B_m * F));
}
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) / b_m) * -sqrt((b_m * f))
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) / B_m) * -Math.sqrt((B_m * F));
}
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) / B_m) * -math.sqrt((B_m * F))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(B_m * F)))) 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) / B_m) * -sqrt((B_m * F));
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[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(B$95$m * F), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{B_m \cdot F}\right)
\end{array}
Initial program 20.0%
Simplified19.7%
Taylor expanded in A around 0 9.6%
mul-1-neg9.6%
*-commutative9.6%
distribute-rgt-neg-in9.6%
unpow29.6%
unpow29.6%
hypot-def16.0%
Simplified16.0%
Taylor expanded in B around -inf 1.3%
Final simplification1.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 (* 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.0%
Simplified19.7%
Taylor expanded in A around -inf 12.6%
*-commutative12.6%
Simplified12.6%
Taylor expanded in A around inf 0.0%
Final simplification0.0%
herbie shell --seed 2024020
(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))))