
(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 13 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 A (* C -4.0) (pow B_m 2.0)))
(t_1 (sqrt (* 2.0 t_0)))
(t_2 (fma B_m B_m (* A (* C -4.0))))
(t_3 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_4
(/
(-
(sqrt
(*
(* 2.0 (* t_3 F))
(- (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0)))))))
t_3)))
(if (<= t_4 (- INFINITY))
(/ (* t_1 (- (sqrt (* F (+ A A))))) t_0)
(if (<= t_4 -4e-211)
(/ (* t_1 (- (sqrt (* F (+ A (- C (hypot B_m (- A C)))))))) t_0)
(if (<= t_4 2e+225)
(/
(-
(sqrt
(*
(* F t_2)
(*
2.0
(+
A
(+
A
(*
-0.5
(/ (+ (pow A 2.0) (- (pow B_m 2.0) (pow (- A) 2.0))) C))))))))
t_2)
(if (<= t_4 INFINITY)
(sqrt (/ (- F) C))
(* (/ (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 = fma(A, (C * -4.0), pow(B_m, 2.0));
double t_1 = sqrt((2.0 * t_0));
double t_2 = fma(B_m, B_m, (A * (C * -4.0)));
double t_3 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_4 = -sqrt(((2.0 * (t_3 * F)) * ((A + C) - sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / t_3;
double tmp;
if (t_4 <= -((double) INFINITY)) {
tmp = (t_1 * -sqrt((F * (A + A)))) / t_0;
} else if (t_4 <= -4e-211) {
tmp = (t_1 * -sqrt((F * (A + (C - hypot(B_m, (A - C))))))) / t_0;
} else if (t_4 <= 2e+225) {
tmp = -sqrt(((F * t_2) * (2.0 * (A + (A + (-0.5 * ((pow(A, 2.0) + (pow(B_m, 2.0) - pow(-A, 2.0))) / C))))))) / t_2;
} else if (t_4 <= ((double) INFINITY)) {
tmp = sqrt((-F / C));
} 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 = fma(A, Float64(C * -4.0), (B_m ^ 2.0)) t_1 = sqrt(Float64(2.0 * t_0)) t_2 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_3 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_4 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_3 * F)) * Float64(Float64(A + C) - sqrt(Float64((B_m ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_3) tmp = 0.0 if (t_4 <= Float64(-Inf)) tmp = Float64(Float64(t_1 * Float64(-sqrt(Float64(F * Float64(A + A))))) / t_0); elseif (t_4 <= -4e-211) tmp = Float64(Float64(t_1 * Float64(-sqrt(Float64(F * Float64(A + Float64(C - hypot(B_m, Float64(A - C)))))))) / t_0); elseif (t_4 <= 2e+225) tmp = Float64(Float64(-sqrt(Float64(Float64(F * t_2) * Float64(2.0 * Float64(A + Float64(A + Float64(-0.5 * Float64(Float64((A ^ 2.0) + Float64((B_m ^ 2.0) - (Float64(-A) ^ 2.0))) / C)))))))) / t_2); elseif (t_4 <= Inf) tmp = sqrt(Float64(Float64(-F) / C)); 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[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$3 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$3), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], N[(N[(t$95$1 * (-N[Sqrt[N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[t$95$4, -4e-211], N[(N[(t$95$1 * (-N[Sqrt[N[(F * N[(A + N[(C - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[t$95$4, 2e+225], N[((-N[Sqrt[N[(N[(F * t$95$2), $MachinePrecision] * N[(2.0 * N[(A + N[(A + N[(-0.5 * N[(N[(N[Power[A, 2.0], $MachinePrecision] + N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[Power[(-A), 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[Sqrt[N[((-F) / C), $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}
t_0 := \mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)\\
t_1 := \sqrt{2 \cdot t_0}\\
t_2 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\
t_3 := {B_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_4 := \frac{-\sqrt{\left(2 \cdot \left(t_3 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_3}\\
\mathbf{if}\;t_4 \leq -\infty:\\
\;\;\;\;\frac{t_1 \cdot \left(-\sqrt{F \cdot \left(A + A\right)}\right)}{t_0}\\
\mathbf{elif}\;t_4 \leq -4 \cdot 10^{-211}:\\
\;\;\;\;\frac{t_1 \cdot \left(-\sqrt{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)}\right)}{t_0}\\
\mathbf{elif}\;t_4 \leq 2 \cdot 10^{+225}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot t_2\right) \cdot \left(2 \cdot \left(A + \left(A + -0.5 \cdot \frac{{A}^{2} + \left({B_m}^{2} - {\left(-A\right)}^{2}\right)}{C}\right)\right)\right)}}{t_2}\\
\mathbf{elif}\;t_4 \leq \infty:\\
\;\;\;\;\sqrt{\frac{-F}{C}}\\
\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 (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -inf.0Initial program 3.3%
Simplified10.8%
pow1/210.8%
associate-*r*24.7%
unpow-prod-down50.3%
pow1/250.3%
Applied egg-rr50.3%
unpow1/250.3%
associate-+r-49.0%
+-commutative49.0%
associate--l+51.2%
Simplified51.2%
Taylor expanded in C around inf 28.0%
if -inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -4.00000000000000034e-211Initial program 98.4%
Simplified79.4%
pow1/279.4%
associate-*r*98.5%
unpow-prod-down98.9%
pow1/298.9%
Applied egg-rr98.9%
unpow1/298.9%
associate-+r-98.9%
+-commutative98.9%
associate--l+98.9%
Simplified98.9%
if -4.00000000000000034e-211 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < 1.99999999999999986e225Initial program 17.8%
Simplified21.7%
Taylor expanded in C around inf 42.2%
associate--l+42.2%
mul-1-neg42.2%
Simplified42.2%
if 1.99999999999999986e225 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < +inf.0Initial program 4.7%
Simplified57.1%
add-sqr-sqrt56.4%
sqrt-unprod39.9%
frac-times29.9%
Applied egg-rr29.9%
Taylor expanded in A around -inf 48.8%
mul-1-neg48.8%
Simplified48.8%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) Initial program 0.0%
Simplified2.7%
Taylor expanded in C around 0 1.9%
associate-*r*1.9%
mul-1-neg1.9%
+-commutative1.9%
unpow21.9%
unpow21.9%
hypot-def17.2%
Simplified17.2%
Final simplification37.7%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma B_m B_m (* A (* C -4.0))))
(t_1 (* F t_0))
(t_2 (fma A (* C -4.0) (pow B_m 2.0)))
(t_3 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_4
(/
(-
(sqrt
(*
(* 2.0 (* t_3 F))
(- (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0)))))))
t_3)))
(if (<= t_4 (- INFINITY))
(/ (* (sqrt (* 2.0 t_2)) (- (sqrt (* F (+ A A))))) t_2)
(if (<= t_4 -4e-211)
(/ (- (sqrt (* t_1 (* 2.0 (+ A (- C (hypot B_m (- A C)))))))) t_0)
(if (<= t_4 2e+225)
(/
(-
(sqrt
(*
t_1
(*
2.0
(+
A
(+
A
(*
-0.5
(/ (+ (pow A 2.0) (- (pow B_m 2.0) (pow (- A) 2.0))) C))))))))
t_0)
(if (<= t_4 INFINITY)
(sqrt (/ (- F) C))
(* (/ (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 = fma(B_m, B_m, (A * (C * -4.0)));
double t_1 = F * t_0;
double t_2 = fma(A, (C * -4.0), pow(B_m, 2.0));
double t_3 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_4 = -sqrt(((2.0 * (t_3 * F)) * ((A + C) - sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / t_3;
double tmp;
if (t_4 <= -((double) INFINITY)) {
tmp = (sqrt((2.0 * t_2)) * -sqrt((F * (A + A)))) / t_2;
} else if (t_4 <= -4e-211) {
tmp = -sqrt((t_1 * (2.0 * (A + (C - hypot(B_m, (A - C))))))) / t_0;
} else if (t_4 <= 2e+225) {
tmp = -sqrt((t_1 * (2.0 * (A + (A + (-0.5 * ((pow(A, 2.0) + (pow(B_m, 2.0) - pow(-A, 2.0))) / C))))))) / t_0;
} else if (t_4 <= ((double) INFINITY)) {
tmp = sqrt((-F / C));
} 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 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_1 = Float64(F * t_0) t_2 = fma(A, Float64(C * -4.0), (B_m ^ 2.0)) t_3 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_4 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_3 * F)) * Float64(Float64(A + C) - sqrt(Float64((B_m ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_3) tmp = 0.0 if (t_4 <= Float64(-Inf)) tmp = Float64(Float64(sqrt(Float64(2.0 * t_2)) * Float64(-sqrt(Float64(F * Float64(A + A))))) / t_2); elseif (t_4 <= -4e-211) tmp = Float64(Float64(-sqrt(Float64(t_1 * Float64(2.0 * Float64(A + Float64(C - hypot(B_m, Float64(A - C)))))))) / t_0); elseif (t_4 <= 2e+225) tmp = Float64(Float64(-sqrt(Float64(t_1 * Float64(2.0 * Float64(A + Float64(A + Float64(-0.5 * Float64(Float64((A ^ 2.0) + Float64((B_m ^ 2.0) - (Float64(-A) ^ 2.0))) / C)))))))) / t_0); elseif (t_4 <= Inf) tmp = sqrt(Float64(Float64(-F) / C)); 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[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(F * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$3 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$3), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], N[(N[(N[Sqrt[N[(2.0 * t$95$2), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[t$95$4, -4e-211], N[((-N[Sqrt[N[(t$95$1 * N[(2.0 * N[(A + N[(C - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[t$95$4, 2e+225], N[((-N[Sqrt[N[(t$95$1 * N[(2.0 * N[(A + N[(A + N[(-0.5 * N[(N[(N[Power[A, 2.0], $MachinePrecision] + N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[Power[(-A), 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[Sqrt[N[((-F) / C), $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}
t_0 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := F \cdot t_0\\
t_2 := \mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)\\
t_3 := {B_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_4 := \frac{-\sqrt{\left(2 \cdot \left(t_3 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_3}\\
\mathbf{if}\;t_4 \leq -\infty:\\
\;\;\;\;\frac{\sqrt{2 \cdot t_2} \cdot \left(-\sqrt{F \cdot \left(A + A\right)}\right)}{t_2}\\
\mathbf{elif}\;t_4 \leq -4 \cdot 10^{-211}:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;t_4 \leq 2 \cdot 10^{+225}:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \left(2 \cdot \left(A + \left(A + -0.5 \cdot \frac{{A}^{2} + \left({B_m}^{2} - {\left(-A\right)}^{2}\right)}{C}\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;t_4 \leq \infty:\\
\;\;\;\;\sqrt{\frac{-F}{C}}\\
\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 (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -inf.0Initial program 3.3%
Simplified10.8%
pow1/210.8%
associate-*r*24.7%
unpow-prod-down50.3%
pow1/250.3%
Applied egg-rr50.3%
unpow1/250.3%
associate-+r-49.0%
+-commutative49.0%
associate--l+51.2%
Simplified51.2%
Taylor expanded in C around inf 28.0%
if -inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -4.00000000000000034e-211Initial program 98.4%
Simplified98.4%
if -4.00000000000000034e-211 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < 1.99999999999999986e225Initial program 17.8%
Simplified21.7%
Taylor expanded in C around inf 42.2%
associate--l+42.2%
mul-1-neg42.2%
Simplified42.2%
if 1.99999999999999986e225 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < +inf.0Initial program 4.7%
Simplified57.1%
add-sqr-sqrt56.4%
sqrt-unprod39.9%
frac-times29.9%
Applied egg-rr29.9%
Taylor expanded in A around -inf 48.8%
mul-1-neg48.8%
Simplified48.8%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) Initial program 0.0%
Simplified2.7%
Taylor expanded in C around 0 1.9%
associate-*r*1.9%
mul-1-neg1.9%
+-commutative1.9%
unpow21.9%
unpow21.9%
hypot-def17.2%
Simplified17.2%
Final simplification37.6%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0
(/
(- (sqrt (* -8.0 (* (* F (+ A A)) (* A C)))))
(fma A (* C -4.0) (pow B_m 2.0)))))
(if (<= (pow B_m 2.0) 2e-80)
t_0
(if (<= (pow B_m 2.0) 20000000000.0)
(/
(-
(sqrt
(* (* 2.0 (+ A (- C (hypot B_m (- A C))))) (* (pow B_m 2.0) F))))
(fma B_m B_m (* A (* C -4.0))))
(if (<= (pow B_m 2.0) 4e+38)
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 * ((F * (A + A)) * (A * C)))) / fma(A, (C * -4.0), pow(B_m, 2.0));
double tmp;
if (pow(B_m, 2.0) <= 2e-80) {
tmp = t_0;
} else if (pow(B_m, 2.0) <= 20000000000.0) {
tmp = -sqrt(((2.0 * (A + (C - hypot(B_m, (A - C))))) * (pow(B_m, 2.0) * F))) / fma(B_m, B_m, (A * (C * -4.0)));
} else if (pow(B_m, 2.0) <= 4e+38) {
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(Float64(F * Float64(A + A)) * Float64(A * C))))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-80) tmp = t_0; elseif ((B_m ^ 2.0) <= 20000000000.0) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(A + Float64(C - hypot(B_m, Float64(A - C))))) * Float64((B_m ^ 2.0) * F)))) / fma(B_m, B_m, Float64(A * Float64(C * -4.0)))); elseif ((B_m ^ 2.0) <= 4e+38) 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[(N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision] * N[(A * C), $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], 2e-80], t$95$0, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 20000000000.0], N[((-N[Sqrt[N[(N[(2.0 * N[(A + N[(C - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Power[B$95$m, 2.0], $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e+38], 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(\left(F \cdot \left(A + A\right)\right) \cdot \left(A \cdot C\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}\\
\mathbf{if}\;{B_m}^{2} \leq 2 \cdot 10^{-80}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;{B_m}^{2} \leq 20000000000:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)\right) \cdot \left({B_m}^{2} \cdot F\right)}}{\mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{elif}\;{B_m}^{2} \leq 4 \cdot 10^{+38}:\\
\;\;\;\;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) < 1.99999999999999992e-80 or 2e10 < (pow.f64 B 2) < 3.99999999999999991e38Initial program 19.7%
Simplified26.1%
Taylor expanded in C around inf 27.9%
associate-*r*32.6%
sub-neg32.6%
mul-1-neg32.6%
remove-double-neg32.6%
Simplified32.6%
if 1.99999999999999992e-80 < (pow.f64 B 2) < 2e10Initial program 47.7%
Simplified49.6%
Taylor expanded in B around inf 46.9%
if 3.99999999999999991e38 < (pow.f64 B 2) Initial program 14.3%
Simplified11.4%
Taylor expanded in C around 0 7.2%
associate-*r*7.2%
mul-1-neg7.2%
+-commutative7.2%
unpow27.2%
unpow27.2%
hypot-def22.1%
Simplified22.1%
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 (- A (hypot B_m A)))
(t_1 (fma A (* C -4.0) (pow B_m 2.0)))
(t_2 (fma B_m B_m (* A (* C -4.0))))
(t_3 (* F (+ A A)))
(t_4 (/ (- (sqrt (* -8.0 (* t_3 (* A C))))) t_1)))
(if (<= B_m 4.2e-166)
t_4
(if (<= B_m 5.8e-126)
(/ (* (sqrt (* 2.0 t_1)) (- (sqrt t_3))) t_1)
(if (<= B_m 2.7e-50)
t_4
(if (<= B_m 2.6e+36)
(/ (- (sqrt (* (* F t_2) (* 2.0 t_0)))) t_2)
(* (/ (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(A, (C * -4.0), pow(B_m, 2.0));
double t_2 = fma(B_m, B_m, (A * (C * -4.0)));
double t_3 = F * (A + A);
double t_4 = -sqrt((-8.0 * (t_3 * (A * C)))) / t_1;
double tmp;
if (B_m <= 4.2e-166) {
tmp = t_4;
} else if (B_m <= 5.8e-126) {
tmp = (sqrt((2.0 * t_1)) * -sqrt(t_3)) / t_1;
} else if (B_m <= 2.7e-50) {
tmp = t_4;
} else if (B_m <= 2.6e+36) {
tmp = -sqrt(((F * t_2) * (2.0 * t_0))) / t_2;
} 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(A, Float64(C * -4.0), (B_m ^ 2.0)) t_2 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_3 = Float64(F * Float64(A + A)) t_4 = Float64(Float64(-sqrt(Float64(-8.0 * Float64(t_3 * Float64(A * C))))) / t_1) tmp = 0.0 if (B_m <= 4.2e-166) tmp = t_4; elseif (B_m <= 5.8e-126) tmp = Float64(Float64(sqrt(Float64(2.0 * t_1)) * Float64(-sqrt(t_3))) / t_1); elseif (B_m <= 2.7e-50) tmp = t_4; elseif (B_m <= 2.6e+36) tmp = Float64(Float64(-sqrt(Float64(Float64(F * t_2) * Float64(2.0 * t_0)))) / t_2); 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[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[((-N[Sqrt[N[(-8.0 * N[(t$95$3 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision]}, If[LessEqual[B$95$m, 4.2e-166], t$95$4, If[LessEqual[B$95$m, 5.8e-126], N[(N[(N[Sqrt[N[(2.0 * t$95$1), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[t$95$3], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[B$95$m, 2.7e-50], t$95$4, If[LessEqual[B$95$m, 2.6e+36], N[((-N[Sqrt[N[(N[(F * t$95$2), $MachinePrecision] * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $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(A, C \cdot -4, {B_m}^{2}\right)\\
t_2 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\
t_3 := F \cdot \left(A + A\right)\\
t_4 := \frac{-\sqrt{-8 \cdot \left(t_3 \cdot \left(A \cdot C\right)\right)}}{t_1}\\
\mathbf{if}\;B_m \leq 4.2 \cdot 10^{-166}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;B_m \leq 5.8 \cdot 10^{-126}:\\
\;\;\;\;\frac{\sqrt{2 \cdot t_1} \cdot \left(-\sqrt{t_3}\right)}{t_1}\\
\mathbf{elif}\;B_m \leq 2.7 \cdot 10^{-50}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;B_m \leq 2.6 \cdot 10^{+36}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot t_2\right) \cdot \left(2 \cdot t_0\right)}}{t_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot t_0}\right)\\
\end{array}
\end{array}
if B < 4.1999999999999999e-166 or 5.79999999999999975e-126 < B < 2.7e-50Initial program 19.3%
Simplified22.5%
Taylor expanded in C around inf 18.8%
associate-*r*22.0%
sub-neg22.0%
mul-1-neg22.0%
remove-double-neg22.0%
Simplified22.0%
if 4.1999999999999999e-166 < B < 5.79999999999999975e-126Initial program 16.3%
Simplified18.7%
pow1/218.7%
associate-*r*18.7%
unpow-prod-down32.4%
pow1/232.4%
Applied egg-rr32.4%
unpow1/232.4%
associate-+r-30.0%
+-commutative30.0%
associate--l+30.0%
Simplified30.0%
Taylor expanded in C around inf 14.8%
if 2.7e-50 < B < 2.6000000000000001e36Initial program 45.6%
Simplified50.2%
Taylor expanded in C around 0 56.2%
mul-1-neg56.2%
+-commutative56.2%
unpow256.2%
unpow256.2%
hypot-def56.4%
Simplified56.4%
if 2.6000000000000001e36 < B Initial program 9.9%
Simplified6.8%
Taylor expanded in C around 0 11.9%
associate-*r*11.9%
mul-1-neg11.9%
+-commutative11.9%
unpow211.9%
unpow211.9%
hypot-def43.8%
Simplified43.8%
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 (* A (* C -4.0)))
(t_1 (- A (hypot B_m A)))
(t_2
(/
(- (sqrt (* -8.0 (* (* F (+ A A)) (* A C)))))
(fma A (* C -4.0) (pow B_m 2.0))))
(t_3 (fma B_m B_m t_0)))
(if (<= B_m 5.5e-163)
t_2
(if (<= B_m 8.5e-127)
(/
(*
(hypot B_m (sqrt t_0))
(- (sqrt (* F (* 2.0 (+ A (- C (hypot B_m (- A C)))))))))
t_3)
(if (<= B_m 1.05e-50)
t_2
(if (<= B_m 2.35e+36)
(/ (- (sqrt (* (* F t_3) (* 2.0 t_1)))) t_3)
(* (/ (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 = A * (C * -4.0);
double t_1 = A - hypot(B_m, A);
double t_2 = -sqrt((-8.0 * ((F * (A + A)) * (A * C)))) / fma(A, (C * -4.0), pow(B_m, 2.0));
double t_3 = fma(B_m, B_m, t_0);
double tmp;
if (B_m <= 5.5e-163) {
tmp = t_2;
} else if (B_m <= 8.5e-127) {
tmp = (hypot(B_m, sqrt(t_0)) * -sqrt((F * (2.0 * (A + (C - hypot(B_m, (A - C)))))))) / t_3;
} else if (B_m <= 1.05e-50) {
tmp = t_2;
} else if (B_m <= 2.35e+36) {
tmp = -sqrt(((F * t_3) * (2.0 * t_1))) / t_3;
} 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 = Float64(A * Float64(C * -4.0)) t_1 = Float64(A - hypot(B_m, A)) t_2 = Float64(Float64(-sqrt(Float64(-8.0 * Float64(Float64(F * Float64(A + A)) * Float64(A * C))))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0))) t_3 = fma(B_m, B_m, t_0) tmp = 0.0 if (B_m <= 5.5e-163) tmp = t_2; elseif (B_m <= 8.5e-127) tmp = Float64(Float64(hypot(B_m, sqrt(t_0)) * Float64(-sqrt(Float64(F * Float64(2.0 * Float64(A + Float64(C - hypot(B_m, Float64(A - C))))))))) / t_3); elseif (B_m <= 1.05e-50) tmp = t_2; elseif (B_m <= 2.35e+36) tmp = Float64(Float64(-sqrt(Float64(Float64(F * t_3) * Float64(2.0 * t_1)))) / t_3); 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[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[((-N[Sqrt[N[(-8.0 * N[(N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision] * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(B$95$m * B$95$m + t$95$0), $MachinePrecision]}, If[LessEqual[B$95$m, 5.5e-163], t$95$2, If[LessEqual[B$95$m, 8.5e-127], N[(N[(N[Sqrt[B$95$m ^ 2 + N[Sqrt[t$95$0], $MachinePrecision] ^ 2], $MachinePrecision] * (-N[Sqrt[N[(F * N[(2.0 * N[(A + N[(C - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[B$95$m, 1.05e-50], t$95$2, If[LessEqual[B$95$m, 2.35e+36], N[((-N[Sqrt[N[(N[(F * t$95$3), $MachinePrecision] * N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$3), $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 := A \cdot \left(C \cdot -4\right)\\
t_1 := A - \mathsf{hypot}\left(B_m, A\right)\\
t_2 := \frac{-\sqrt{-8 \cdot \left(\left(F \cdot \left(A + A\right)\right) \cdot \left(A \cdot C\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}\\
t_3 := \mathsf{fma}\left(B_m, B_m, t_0\right)\\
\mathbf{if}\;B_m \leq 5.5 \cdot 10^{-163}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;B_m \leq 8.5 \cdot 10^{-127}:\\
\;\;\;\;\frac{\mathsf{hypot}\left(B_m, \sqrt{t_0}\right) \cdot \left(-\sqrt{F \cdot \left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)\right)}\right)}{t_3}\\
\mathbf{elif}\;B_m \leq 1.05 \cdot 10^{-50}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;B_m \leq 2.35 \cdot 10^{+36}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot t_3\right) \cdot \left(2 \cdot t_1\right)}}{t_3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot t_1}\right)\\
\end{array}
\end{array}
if B < 5.4999999999999998e-163 or 8.5e-127 < B < 1.05e-50Initial program 19.7%
Simplified22.9%
Taylor expanded in C around inf 19.2%
associate-*r*22.4%
sub-neg22.4%
mul-1-neg22.4%
remove-double-neg22.4%
Simplified22.4%
if 5.4999999999999998e-163 < B < 8.5e-127Initial program 2.3%
Simplified2.3%
add-sqr-sqrt2.3%
sqr-neg2.3%
sqrt-unprod1.9%
add-sqr-sqrt2.0%
neg-sub02.0%
sub-neg2.0%
add-sqr-sqrt1.9%
Applied egg-rr18.3%
+-lft-identity18.3%
associate--l+18.3%
Simplified18.3%
if 1.05e-50 < B < 2.34999999999999994e36Initial program 45.6%
Simplified50.2%
Taylor expanded in C around 0 56.2%
mul-1-neg56.2%
+-commutative56.2%
unpow256.2%
unpow256.2%
hypot-def56.4%
Simplified56.4%
if 2.34999999999999994e36 < B Initial program 9.9%
Simplified6.8%
Taylor expanded in C around 0 11.9%
associate-*r*11.9%
mul-1-neg11.9%
+-commutative11.9%
unpow211.9%
unpow211.9%
hypot-def43.8%
Simplified43.8%
Final simplification29.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 (- A (hypot B_m A)))
(t_1 (* A (* C -4.0)))
(t_2 (fma B_m B_m t_1))
(t_3
(/
(- (sqrt (* -8.0 (* (* F (+ A A)) (* A C)))))
(fma A (* C -4.0) (pow B_m 2.0)))))
(if (<= B_m 6.6e-163)
t_3
(if (<= B_m 6.2e-140)
(/
(- (sqrt (* F (* 2.0 (- (+ A C) (hypot B_m (- A C)))))))
(hypot B_m (sqrt t_1)))
(if (<= B_m 2.5e-50)
t_3
(if (<= B_m 9.2e+35)
(/ (- (sqrt (* (* F t_2) (* 2.0 t_0)))) t_2)
(* (/ (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 = A * (C * -4.0);
double t_2 = fma(B_m, B_m, t_1);
double t_3 = -sqrt((-8.0 * ((F * (A + A)) * (A * C)))) / fma(A, (C * -4.0), pow(B_m, 2.0));
double tmp;
if (B_m <= 6.6e-163) {
tmp = t_3;
} else if (B_m <= 6.2e-140) {
tmp = -sqrt((F * (2.0 * ((A + C) - hypot(B_m, (A - C)))))) / hypot(B_m, sqrt(t_1));
} else if (B_m <= 2.5e-50) {
tmp = t_3;
} else if (B_m <= 9.2e+35) {
tmp = -sqrt(((F * t_2) * (2.0 * t_0))) / t_2;
} 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 = Float64(A * Float64(C * -4.0)) t_2 = fma(B_m, B_m, t_1) t_3 = Float64(Float64(-sqrt(Float64(-8.0 * Float64(Float64(F * Float64(A + A)) * Float64(A * C))))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0))) tmp = 0.0 if (B_m <= 6.6e-163) tmp = t_3; elseif (B_m <= 6.2e-140) tmp = Float64(Float64(-sqrt(Float64(F * Float64(2.0 * Float64(Float64(A + C) - hypot(B_m, Float64(A - C))))))) / hypot(B_m, sqrt(t_1))); elseif (B_m <= 2.5e-50) tmp = t_3; elseif (B_m <= 9.2e+35) tmp = Float64(Float64(-sqrt(Float64(Float64(F * t_2) * Float64(2.0 * t_0)))) / t_2); 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[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(B$95$m * B$95$m + t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[((-N[Sqrt[N[(-8.0 * N[(N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision] * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 6.6e-163], t$95$3, If[LessEqual[B$95$m, 6.2e-140], N[((-N[Sqrt[N[(F * N[(2.0 * N[(N[(A + C), $MachinePrecision] - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[Sqrt[B$95$m ^ 2 + N[Sqrt[t$95$1], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 2.5e-50], t$95$3, If[LessEqual[B$95$m, 9.2e+35], N[((-N[Sqrt[N[(N[(F * t$95$2), $MachinePrecision] * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $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 := A \cdot \left(C \cdot -4\right)\\
t_2 := \mathsf{fma}\left(B_m, B_m, t_1\right)\\
t_3 := \frac{-\sqrt{-8 \cdot \left(\left(F \cdot \left(A + A\right)\right) \cdot \left(A \cdot C\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}\\
\mathbf{if}\;B_m \leq 6.6 \cdot 10^{-163}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;B_m \leq 6.2 \cdot 10^{-140}:\\
\;\;\;\;\frac{-\sqrt{F \cdot \left(2 \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)}}{\mathsf{hypot}\left(B_m, \sqrt{t_1}\right)}\\
\mathbf{elif}\;B_m \leq 2.5 \cdot 10^{-50}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;B_m \leq 9.2 \cdot 10^{+35}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot t_2\right) \cdot \left(2 \cdot t_0\right)}}{t_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot t_0}\right)\\
\end{array}
\end{array}
if B < 6.60000000000000002e-163 or 6.1999999999999998e-140 < B < 2.49999999999999984e-50Initial program 19.5%
Simplified22.8%
Taylor expanded in C around inf 19.0%
associate-*r*22.2%
sub-neg22.2%
mul-1-neg22.2%
remove-double-neg22.2%
Simplified22.2%
if 6.60000000000000002e-163 < B < 6.1999999999999998e-140Initial program 1.6%
Simplified1.6%
neg-mul-11.6%
add-sqr-sqrt1.6%
times-frac1.6%
fma-udef1.6%
add-sqr-sqrt1.6%
hypot-def1.6%
Applied egg-rr25.9%
associate-*l/25.9%
mul-1-neg25.9%
associate-/l*25.9%
associate--l+25.9%
Simplified25.9%
associate-/r/25.9%
pow125.9%
pow125.9%
pow-div26.8%
metadata-eval26.8%
metadata-eval26.8%
*-un-lft-identity26.8%
associate-+r-26.8%
Applied egg-rr26.8%
if 2.49999999999999984e-50 < B < 9.1999999999999993e35Initial program 45.6%
Simplified50.2%
Taylor expanded in C around 0 56.2%
mul-1-neg56.2%
+-commutative56.2%
unpow256.2%
unpow256.2%
hypot-def56.4%
Simplified56.4%
if 9.1999999999999993e35 < B Initial program 9.9%
Simplified6.8%
Taylor expanded in C around 0 11.9%
associate-*r*11.9%
mul-1-neg11.9%
+-commutative11.9%
unpow211.9%
unpow211.9%
hypot-def43.8%
Simplified43.8%
Final simplification29.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) 2e-80)
(/
(- (sqrt (* -8.0 (* (* F (+ A A)) (* A C)))))
(fma A (* C -4.0) (pow B_m 2.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 tmp;
if (pow(B_m, 2.0) <= 2e-80) {
tmp = -sqrt((-8.0 * ((F * (A + A)) * (A * C)))) / fma(A, (C * -4.0), pow(B_m, 2.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) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-80) tmp = Float64(Float64(-sqrt(Float64(-8.0 * Float64(Float64(F * Float64(A + A)) * Float64(A * C))))) / fma(A, Float64(C * -4.0), (B_m ^ 2.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_] := If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-80], N[((-N[Sqrt[N[(-8.0 * N[(N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision] * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $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 2 \cdot 10^{-80}:\\
\;\;\;\;\frac{-\sqrt{-8 \cdot \left(\left(F \cdot \left(A + A\right)\right) \cdot \left(A \cdot C\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}\\
\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) < 1.99999999999999992e-80Initial program 19.9%
Simplified26.4%
Taylor expanded in C around inf 26.8%
associate-*r*31.0%
sub-neg31.0%
mul-1-neg31.0%
remove-double-neg31.0%
Simplified31.0%
if 1.99999999999999992e-80 < (pow.f64 B 2) Initial program 18.4%
Simplified16.5%
Taylor expanded in C around 0 10.5%
associate-*r*10.5%
mul-1-neg10.5%
+-commutative10.5%
unpow210.5%
unpow210.5%
hypot-def22.9%
Simplified22.9%
Final simplification26.5%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (/ (sqrt 2.0) B_m)))
(if (<= F -1.7e+253)
(* (- t_0) (sqrt (* F (/ (* (pow B_m 2.0) -0.5) C))))
(if (<= F -1.56e-307)
(* t_0 (- (sqrt (* F (- A (hypot B_m A))))))
(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) {
double t_0 = sqrt(2.0) / B_m;
double tmp;
if (F <= -1.7e+253) {
tmp = -t_0 * sqrt((F * ((pow(B_m, 2.0) * -0.5) / C)));
} else if (F <= -1.56e-307) {
tmp = t_0 * -sqrt((F * (A - hypot(B_m, A))));
} else {
tmp = sqrt((-F / 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(2.0) / B_m;
double tmp;
if (F <= -1.7e+253) {
tmp = -t_0 * Math.sqrt((F * ((Math.pow(B_m, 2.0) * -0.5) / C)));
} else if (F <= -1.56e-307) {
tmp = t_0 * -Math.sqrt((F * (A - Math.hypot(B_m, A))));
} else {
tmp = Math.sqrt((-F / 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(2.0) / B_m tmp = 0 if F <= -1.7e+253: tmp = -t_0 * math.sqrt((F * ((math.pow(B_m, 2.0) * -0.5) / C))) elif F <= -1.56e-307: tmp = t_0 * -math.sqrt((F * (A - math.hypot(B_m, A)))) else: tmp = math.sqrt((-F / 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(2.0) / B_m) tmp = 0.0 if (F <= -1.7e+253) tmp = Float64(Float64(-t_0) * sqrt(Float64(F * Float64(Float64((B_m ^ 2.0) * -0.5) / C)))); elseif (F <= -1.56e-307) tmp = Float64(t_0 * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); else tmp = sqrt(Float64(Float64(-F) / 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(2.0) / B_m;
tmp = 0.0;
if (F <= -1.7e+253)
tmp = -t_0 * sqrt((F * (((B_m ^ 2.0) * -0.5) / C)));
elseif (F <= -1.56e-307)
tmp = t_0 * -sqrt((F * (A - hypot(B_m, A))));
else
tmp = sqrt((-F / 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[2.0], $MachinePrecision] / B$95$m), $MachinePrecision]}, If[LessEqual[F, -1.7e+253], N[((-t$95$0) * N[Sqrt[N[(F * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] * -0.5), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[F, -1.56e-307], N[(t$95$0 * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], 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])\\
\\
\begin{array}{l}
t_0 := \frac{\sqrt{2}}{B_m}\\
\mathbf{if}\;F \leq -1.7 \cdot 10^{+253}:\\
\;\;\;\;\left(-t_0\right) \cdot \sqrt{F \cdot \frac{{B_m}^{2} \cdot -0.5}{C}}\\
\mathbf{elif}\;F \leq -1.56 \cdot 10^{-307}:\\
\;\;\;\;t_0 \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{-F}{C}}\\
\end{array}
\end{array}
if F < -1.70000000000000009e253Initial program 13.5%
Simplified14.9%
Taylor expanded in A around 0 2.3%
associate-*r*2.3%
mul-1-neg2.3%
unpow22.3%
unpow22.3%
hypot-def2.4%
Simplified2.4%
Taylor expanded in C around inf 12.2%
associate-*r/12.2%
Simplified12.2%
if -1.70000000000000009e253 < F < -1.56e-307Initial program 19.0%
Simplified18.8%
Taylor expanded in C around 0 9.2%
associate-*r*9.2%
mul-1-neg9.2%
+-commutative9.2%
unpow29.2%
unpow29.2%
hypot-def18.0%
Simplified18.0%
if -1.56e-307 < F Initial program 22.7%
Simplified40.4%
add-sqr-sqrt40.2%
sqrt-unprod31.8%
frac-times28.5%
Applied egg-rr31.4%
Taylor expanded in A around -inf 48.6%
mul-1-neg48.6%
Simplified48.6%
Final simplification21.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 (<= F -1.56e-307) (* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A)))))) (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) {
double tmp;
if (F <= -1.56e-307) {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
} else {
tmp = sqrt((-F / 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 (F <= -1.56e-307) {
tmp = (Math.sqrt(2.0) / B_m) * -Math.sqrt((F * (A - Math.hypot(B_m, A))));
} else {
tmp = Math.sqrt((-F / 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 F <= -1.56e-307: tmp = (math.sqrt(2.0) / B_m) * -math.sqrt((F * (A - math.hypot(B_m, A)))) else: tmp = math.sqrt((-F / 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 (F <= -1.56e-307) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); else tmp = sqrt(Float64(Float64(-F) / 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 (F <= -1.56e-307)
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
else
tmp = sqrt((-F / 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[F, -1.56e-307], 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[((-F) / C), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;F \leq -1.56 \cdot 10^{-307}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{-F}{C}}\\
\end{array}
\end{array}
if F < -1.56e-307Initial program 18.6%
Simplified18.5%
Taylor expanded in C around 0 8.7%
associate-*r*8.7%
mul-1-neg8.7%
+-commutative8.7%
unpow28.7%
unpow28.7%
hypot-def16.7%
Simplified16.7%
if -1.56e-307 < F Initial program 22.7%
Simplified40.4%
add-sqr-sqrt40.2%
sqrt-unprod31.8%
frac-times28.5%
Applied egg-rr31.4%
Taylor expanded in A around -inf 48.6%
mul-1-neg48.6%
Simplified48.6%
Final simplification20.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
(let* ((t_0 (sqrt (/ (- F) C))))
(if (<= A -1.32e+154)
t_0
(if (<= A -7e+24)
(/ (- (sqrt (* -16.0 (* (pow A 2.0) (* C F))))) (* A (* C -4.0)))
(if (<= A 6.8e-155)
(* (- (/ (sqrt 2.0) B_m)) (sqrt (* B_m (- 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 = sqrt((-F / C));
double tmp;
if (A <= -1.32e+154) {
tmp = t_0;
} else if (A <= -7e+24) {
tmp = -sqrt((-16.0 * (pow(A, 2.0) * (C * F)))) / (A * (C * -4.0));
} else if (A <= 6.8e-155) {
tmp = -(sqrt(2.0) / B_m) * sqrt((B_m * -F));
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = sqrt((-f / c))
if (a <= (-1.32d+154)) then
tmp = t_0
else if (a <= (-7d+24)) then
tmp = -sqrt(((-16.0d0) * ((a ** 2.0d0) * (c * f)))) / (a * (c * (-4.0d0)))
else if (a <= 6.8d-155) then
tmp = -(sqrt(2.0d0) / b_m) * sqrt((b_m * -f))
else
tmp = t_0
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 t_0 = Math.sqrt((-F / C));
double tmp;
if (A <= -1.32e+154) {
tmp = t_0;
} else if (A <= -7e+24) {
tmp = -Math.sqrt((-16.0 * (Math.pow(A, 2.0) * (C * F)))) / (A * (C * -4.0));
} else if (A <= 6.8e-155) {
tmp = -(Math.sqrt(2.0) / B_m) * Math.sqrt((B_m * -F));
} else {
tmp = t_0;
}
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 / C)) tmp = 0 if A <= -1.32e+154: tmp = t_0 elif A <= -7e+24: tmp = -math.sqrt((-16.0 * (math.pow(A, 2.0) * (C * F)))) / (A * (C * -4.0)) elif A <= 6.8e-155: tmp = -(math.sqrt(2.0) / B_m) * math.sqrt((B_m * -F)) else: tmp = 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 = sqrt(Float64(Float64(-F) / C)) tmp = 0.0 if (A <= -1.32e+154) tmp = t_0; elseif (A <= -7e+24) tmp = Float64(Float64(-sqrt(Float64(-16.0 * Float64((A ^ 2.0) * Float64(C * F))))) / Float64(A * Float64(C * -4.0))); elseif (A <= 6.8e-155) tmp = Float64(Float64(-Float64(sqrt(2.0) / B_m)) * sqrt(Float64(B_m * Float64(-F)))); else tmp = t_0; 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 / C));
tmp = 0.0;
if (A <= -1.32e+154)
tmp = t_0;
elseif (A <= -7e+24)
tmp = -sqrt((-16.0 * ((A ^ 2.0) * (C * F)))) / (A * (C * -4.0));
elseif (A <= 6.8e-155)
tmp = -(sqrt(2.0) / B_m) * sqrt((B_m * -F));
else
tmp = t_0;
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[Sqrt[N[((-F) / C), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[A, -1.32e+154], t$95$0, If[LessEqual[A, -7e+24], N[((-N[Sqrt[N[(-16.0 * N[(N[Power[A, 2.0], $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 6.8e-155], N[((-N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision]) * N[Sqrt[N[(B$95$m * (-F)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\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{\frac{-F}{C}}\\
\mathbf{if}\;A \leq -1.32 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;A \leq -7 \cdot 10^{+24}:\\
\;\;\;\;\frac{-\sqrt{-16 \cdot \left({A}^{2} \cdot \left(C \cdot F\right)\right)}}{A \cdot \left(C \cdot -4\right)}\\
\mathbf{elif}\;A \leq 6.8 \cdot 10^{-155}:\\
\;\;\;\;\left(-\frac{\sqrt{2}}{B_m}\right) \cdot \sqrt{B_m \cdot \left(-F\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if A < -1.31999999999999998e154 or 6.8e-155 < A Initial program 7.4%
Simplified15.8%
add-sqr-sqrt5.7%
sqrt-unprod4.0%
frac-times2.8%
Applied egg-rr3.4%
Taylor expanded in A around -inf 17.5%
mul-1-neg17.5%
Simplified17.5%
if -1.31999999999999998e154 < A < -7.0000000000000004e24Initial program 43.9%
Simplified47.4%
Taylor expanded in A around -inf 31.7%
*-commutative31.7%
Simplified31.7%
Taylor expanded in A around inf 31.8%
*-commutative31.8%
associate-*r*31.8%
Simplified31.8%
if -7.0000000000000004e24 < A < 6.8e-155Initial program 27.6%
Simplified23.8%
Taylor expanded in A around 0 11.2%
associate-*r*11.2%
mul-1-neg11.2%
unpow211.2%
unpow211.2%
hypot-def21.0%
Simplified21.0%
Taylor expanded in C around 0 18.5%
associate-*r*18.5%
mul-1-neg18.5%
Simplified18.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 (if (or (<= A -1.26e+153) (not (<= A 6e-154))) (sqrt (/ (- F) C)) (* (- (/ (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) {
double tmp;
if ((A <= -1.26e+153) || !(A <= 6e-154)) {
tmp = sqrt((-F / C));
} else {
tmp = -(sqrt(2.0) / B_m) * sqrt((B_m * -F));
}
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 ((a <= (-1.26d+153)) .or. (.not. (a <= 6d-154))) then
tmp = sqrt((-f / c))
else
tmp = -(sqrt(2.0d0) / b_m) * sqrt((b_m * -f))
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 ((A <= -1.26e+153) || !(A <= 6e-154)) {
tmp = Math.sqrt((-F / C));
} else {
tmp = -(Math.sqrt(2.0) / B_m) * Math.sqrt((B_m * -F));
}
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 (A <= -1.26e+153) or not (A <= 6e-154): tmp = math.sqrt((-F / C)) else: tmp = -(math.sqrt(2.0) / B_m) * math.sqrt((B_m * -F)) 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 ((A <= -1.26e+153) || !(A <= 6e-154)) tmp = sqrt(Float64(Float64(-F) / C)); else tmp = Float64(Float64(-Float64(sqrt(2.0) / B_m)) * sqrt(Float64(B_m * Float64(-F)))); 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 ((A <= -1.26e+153) || ~((A <= 6e-154)))
tmp = sqrt((-F / C));
else
tmp = -(sqrt(2.0) / B_m) * sqrt((B_m * -F));
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[Or[LessEqual[A, -1.26e+153], N[Not[LessEqual[A, 6e-154]], $MachinePrecision]], N[Sqrt[N[((-F) / C), $MachinePrecision]], $MachinePrecision], 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])\\
\\
\begin{array}{l}
\mathbf{if}\;A \leq -1.26 \cdot 10^{+153} \lor \neg \left(A \leq 6 \cdot 10^{-154}\right):\\
\;\;\;\;\sqrt{\frac{-F}{C}}\\
\mathbf{else}:\\
\;\;\;\;\left(-\frac{\sqrt{2}}{B_m}\right) \cdot \sqrt{B_m \cdot \left(-F\right)}\\
\end{array}
\end{array}
if A < -1.25999999999999991e153 or 6.0000000000000005e-154 < A Initial program 8.1%
Simplified16.4%
add-sqr-sqrt6.3%
sqrt-unprod4.7%
frac-times3.5%
Applied egg-rr4.1%
Taylor expanded in A around -inf 18.1%
mul-1-neg18.1%
Simplified18.1%
if -1.25999999999999991e153 < A < 6.0000000000000005e-154Initial program 31.0%
Simplified28.9%
Taylor expanded in A around 0 9.2%
associate-*r*9.2%
mul-1-neg9.2%
unpow29.2%
unpow29.2%
hypot-def19.2%
Simplified19.2%
Taylor expanded in C around 0 17.4%
associate-*r*17.4%
mul-1-neg17.4%
Simplified17.4%
Final simplification17.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 A))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return sqrt(-(F / A));
}
B_m = abs(B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = sqrt(-(f / a))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return Math.sqrt(-(F / A));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return math.sqrt(-(F / A))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return sqrt(Float64(-Float64(F / A))) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = sqrt(-(F / A));
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[Sqrt[(-N[(F / A), $MachinePrecision])], $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\sqrt{-\frac{F}{A}}
\end{array}
Initial program 19.1%
Simplified26.7%
add-sqr-sqrt6.6%
sqrt-unprod5.8%
frac-times5.1%
Applied egg-rr5.4%
Taylor expanded in B around 0 11.8%
mul-1-neg11.8%
Simplified11.8%
Final simplification11.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 sqrt(Float64(Float64(-F) / 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 19.1%
Simplified26.7%
add-sqr-sqrt6.6%
sqrt-unprod5.8%
frac-times5.1%
Applied egg-rr5.4%
Taylor expanded in A around -inf 13.1%
mul-1-neg13.1%
Simplified13.1%
Final simplification13.1%
herbie shell --seed 2024011
(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))))