
(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 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma B_m B_m (* A (* C -4.0))))
(t_1 (fma A (* C -4.0) (pow B_m 2.0)))
(t_2 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_3
(/
(-
(sqrt
(*
(* 2.0 (* t_2 F))
(- (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0)))))))
t_2)))
(if (<= t_3 -5e-197)
(/
(- (* (sqrt (* F (+ C (- A (hypot B_m (- A C)))))) (sqrt (* 2.0 t_1))))
t_1)
(if (<= t_3 INFINITY)
(/
(-
(sqrt (* (* F t_0) (* 2.0 (+ A (+ A (* -0.5 (/ (pow B_m 2.0) C))))))))
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 = fma(B_m, B_m, (A * (C * -4.0)));
double t_1 = fma(A, (C * -4.0), pow(B_m, 2.0));
double t_2 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_3 = -sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / t_2;
double tmp;
if (t_3 <= -5e-197) {
tmp = -(sqrt((F * (C + (A - hypot(B_m, (A - C)))))) * sqrt((2.0 * t_1))) / t_1;
} else if (t_3 <= ((double) INFINITY)) {
tmp = -sqrt(((F * t_0) * (2.0 * (A + (A + (-0.5 * (pow(B_m, 2.0) / C))))))) / 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 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_1 = fma(A, Float64(C * -4.0), (B_m ^ 2.0)) t_2 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_3 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_2 * F)) * Float64(Float64(A + C) - sqrt(Float64((B_m ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_2) tmp = 0.0 if (t_3 <= -5e-197) tmp = Float64(Float64(-Float64(sqrt(Float64(F * Float64(C + Float64(A - hypot(B_m, Float64(A - C)))))) * sqrt(Float64(2.0 * t_1)))) / t_1); elseif (t_3 <= Inf) tmp = Float64(Float64(-sqrt(Float64(Float64(F * t_0) * Float64(2.0 * Float64(A + Float64(A + Float64(-0.5 * Float64((B_m ^ 2.0) / C)))))))) / 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[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $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[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$2 * 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$2), $MachinePrecision]}, If[LessEqual[t$95$3, -5e-197], N[((-N[(N[Sqrt[N[(F * N[(C + N[(A - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(2.0 * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[((-N[Sqrt[N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * N[(A + N[(A + N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], 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 := \mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)\\
t_2 := {B_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := \frac{-\sqrt{\left(2 \cdot \left(t_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\
\mathbf{if}\;t_3 \leq -5 \cdot 10^{-197}:\\
\;\;\;\;\frac{-\sqrt{F \cdot \left(C + \left(A - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)} \cdot \sqrt{2 \cdot t_1}}{t_1}\\
\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot t_0\right) \cdot \left(2 \cdot \left(A + \left(A + -0.5 \cdot \frac{{B_m}^{2}}{C}\right)\right)\right)}}{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 (/.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))) < -5.0000000000000002e-197Initial program 52.7%
Simplified50.1%
associate-*r*60.8%
sqrt-prod73.2%
Applied egg-rr73.2%
if -5.0000000000000002e-197 < (/.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 22.5%
Simplified33.2%
Taylor expanded in C around inf 25.7%
associate--l+25.7%
mul-1-neg25.7%
Simplified25.7%
Taylor expanded in A around 0 29.6%
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%
Simplified1.3%
Taylor expanded in C around 0 1.9%
associate-*r*1.9%
mul-1-neg1.9%
+-commutative1.9%
unpow21.9%
unpow21.9%
hypot-def23.1%
Simplified23.1%
Final simplification44.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 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_3
(/
(-
(sqrt
(*
(* 2.0 (* t_2 F))
(- (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0)))))))
t_2)))
(if (<= t_3 (- INFINITY))
(/ (- (sqrt (* t_1 (* 2.0 (+ A A))))) t_0)
(if (<= t_3 -5e-197)
(/ (- (sqrt (* t_1 (* 2.0 (+ A (- C (hypot B_m (- A C)))))))) t_0)
(if (<= t_3 INFINITY)
(/
(- (sqrt (* t_1 (* 2.0 (+ A (+ A (* -0.5 (/ (pow B_m 2.0) C))))))))
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 = fma(B_m, B_m, (A * (C * -4.0)));
double t_1 = F * t_0;
double t_2 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_3 = -sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / t_2;
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = -sqrt((t_1 * (2.0 * (A + A)))) / t_0;
} else if (t_3 <= -5e-197) {
tmp = -sqrt((t_1 * (2.0 * (A + (C - hypot(B_m, (A - C))))))) / t_0;
} else if (t_3 <= ((double) INFINITY)) {
tmp = -sqrt((t_1 * (2.0 * (A + (A + (-0.5 * (pow(B_m, 2.0) / C))))))) / 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 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_1 = Float64(F * t_0) t_2 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_3 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_2 * F)) * Float64(Float64(A + C) - sqrt(Float64((B_m ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_2) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(Float64(-sqrt(Float64(t_1 * Float64(2.0 * Float64(A + A))))) / t_0); elseif (t_3 <= -5e-197) tmp = Float64(Float64(-sqrt(Float64(t_1 * Float64(2.0 * Float64(A + Float64(C - hypot(B_m, Float64(A - C)))))))) / t_0); elseif (t_3 <= Inf) tmp = Float64(Float64(-sqrt(Float64(t_1 * Float64(2.0 * Float64(A + Float64(A + Float64(-0.5 * Float64((B_m ^ 2.0) / C)))))))) / 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[(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[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$2 * 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$2), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[((-N[Sqrt[N[(t$95$1 * N[(2.0 * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[t$95$3, -5e-197], 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$3, Infinity], N[((-N[Sqrt[N[(t$95$1 * N[(2.0 * N[(A + N[(A + N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], 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 := {B_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := \frac{-\sqrt{\left(2 \cdot \left(t_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \left(2 \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;t_3 \leq -5 \cdot 10^{-197}:\\
\;\;\;\;\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_3 \leq \infty:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \left(2 \cdot \left(A + \left(A + -0.5 \cdot \frac{{B_m}^{2}}{C}\right)\right)\right)}}{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 (/.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.1%
Simplified21.6%
Taylor expanded in C around inf 27.2%
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))) < -5.0000000000000002e-197Initial program 99.5%
Simplified99.5%
if -5.0000000000000002e-197 < (/.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 22.5%
Simplified33.2%
Taylor expanded in C around inf 25.7%
associate--l+25.7%
mul-1-neg25.7%
Simplified25.7%
Taylor expanded in A around 0 29.6%
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%
Simplified1.3%
Taylor expanded in C around 0 1.9%
associate-*r*1.9%
mul-1-neg1.9%
+-commutative1.9%
unpow21.9%
unpow21.9%
hypot-def23.1%
Simplified23.1%
Final simplification41.1%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma B_m B_m (* A (* C -4.0))))
(t_1 (/ (- (sqrt (* (* F t_0) (* 2.0 (+ A A))))) t_0))
(t_2
(/ (* (* B_m (sqrt 2.0)) (- (sqrt (* F (- A (hypot A B_m)))))) t_0)))
(if (<= (pow B_m 2.0) 2e-135)
t_1
(if (<= (pow B_m 2.0) 5e-90)
t_2
(if (<= (pow B_m 2.0) 5e-35)
t_1
(if (<= (pow B_m 2.0) 2e+154)
t_2
(if (<= (pow B_m 2.0) 2e+178)
(*
(/ (- (sqrt 2.0)) B_m)
(sqrt (* F (* -0.5 (/ (pow B_m 2.0) 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 = -sqrt(((F * t_0) * (2.0 * (A + A)))) / t_0;
double t_2 = ((B_m * sqrt(2.0)) * -sqrt((F * (A - hypot(A, B_m))))) / t_0;
double tmp;
if (pow(B_m, 2.0) <= 2e-135) {
tmp = t_1;
} else if (pow(B_m, 2.0) <= 5e-90) {
tmp = t_2;
} else if (pow(B_m, 2.0) <= 5e-35) {
tmp = t_1;
} else if (pow(B_m, 2.0) <= 2e+154) {
tmp = t_2;
} else if (pow(B_m, 2.0) <= 2e+178) {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (-0.5 * (pow(B_m, 2.0) / 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(Float64(-sqrt(Float64(Float64(F * t_0) * Float64(2.0 * Float64(A + A))))) / t_0) t_2 = Float64(Float64(Float64(B_m * sqrt(2.0)) * Float64(-sqrt(Float64(F * Float64(A - hypot(A, B_m)))))) / t_0) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-135) tmp = t_1; elseif ((B_m ^ 2.0) <= 5e-90) tmp = t_2; elseif ((B_m ^ 2.0) <= 5e-35) tmp = t_1; elseif ((B_m ^ 2.0) <= 2e+154) tmp = t_2; elseif ((B_m ^ 2.0) <= 2e+178) tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(-0.5 * Float64((B_m ^ 2.0) / 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[((-N[Sqrt[N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(B$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-135], t$95$1, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-90], t$95$2, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-35], t$95$1, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+154], t$95$2, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+178], 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], 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 := \frac{-\sqrt{\left(F \cdot t_0\right) \cdot \left(2 \cdot \left(A + A\right)\right)}}{t_0}\\
t_2 := \frac{\left(B_m \cdot \sqrt{2}\right) \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B_m\right)\right)}\right)}{t_0}\\
\mathbf{if}\;{B_m}^{2} \leq 2 \cdot 10^{-135}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;{B_m}^{2} \leq 5 \cdot 10^{-90}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;{B_m}^{2} \leq 5 \cdot 10^{-35}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;{B_m}^{2} \leq 2 \cdot 10^{+154}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;{B_m}^{2} \leq 2 \cdot 10^{+178}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(-0.5 \cdot \frac{{B_m}^{2}}{C}\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) < 2.0000000000000001e-135 or 5.00000000000000019e-90 < (pow.f64 B 2) < 4.99999999999999964e-35Initial program 33.5%
Simplified42.0%
Taylor expanded in C around inf 25.8%
if 2.0000000000000001e-135 < (pow.f64 B 2) < 5.00000000000000019e-90 or 4.99999999999999964e-35 < (pow.f64 B 2) < 2.00000000000000007e154Initial program 37.1%
Simplified47.3%
add-cube-cbrt46.9%
pow346.9%
*-commutative46.9%
Applied egg-rr46.9%
Taylor expanded in C around 0 17.3%
*-commutative17.3%
unpow217.3%
unpow217.3%
hypot-def23.7%
Simplified23.7%
if 2.00000000000000007e154 < (pow.f64 B 2) < 2.0000000000000001e178Initial program 27.1%
Simplified27.3%
Taylor expanded in A around 0 3.4%
associate-*r*3.4%
mul-1-neg3.4%
unpow23.4%
unpow23.4%
hypot-def3.7%
Simplified3.7%
Taylor expanded in C around inf 13.9%
if 2.0000000000000001e178 < (pow.f64 B 2) Initial program 4.7%
Simplified0.6%
Taylor expanded in C around 0 7.6%
associate-*r*7.6%
mul-1-neg7.6%
+-commutative7.6%
unpow27.6%
unpow27.6%
hypot-def34.2%
Simplified34.2%
Final simplification27.3%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma B_m B_m (* A (* C -4.0))))
(t_1 (/ (- (sqrt (* (* F t_0) (* 2.0 (+ A A))))) t_0))
(t_2 (/ (- (sqrt 2.0)) B_m)))
(if (<= (pow B_m 2.0) 2e-135)
t_1
(if (<= (pow B_m 2.0) 5e-90)
(* t_2 (sqrt (* B_m (- F))))
(if (<= (pow B_m 2.0) 5e-35)
t_1
(if (or (<= (pow B_m 2.0) 2e+154) (not (<= (pow B_m 2.0) 2e+178)))
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A))))))
(* t_2 (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 t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double t_1 = -sqrt(((F * t_0) * (2.0 * (A + A)))) / t_0;
double t_2 = -sqrt(2.0) / B_m;
double tmp;
if (pow(B_m, 2.0) <= 2e-135) {
tmp = t_1;
} else if (pow(B_m, 2.0) <= 5e-90) {
tmp = t_2 * sqrt((B_m * -F));
} else if (pow(B_m, 2.0) <= 5e-35) {
tmp = t_1;
} else if ((pow(B_m, 2.0) <= 2e+154) || !(pow(B_m, 2.0) <= 2e+178)) {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
} else {
tmp = t_2 * sqrt((F * (-0.5 * (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) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_1 = Float64(Float64(-sqrt(Float64(Float64(F * t_0) * Float64(2.0 * Float64(A + A))))) / t_0) t_2 = Float64(Float64(-sqrt(2.0)) / B_m) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-135) tmp = t_1; elseif ((B_m ^ 2.0) <= 5e-90) tmp = Float64(t_2 * sqrt(Float64(B_m * Float64(-F)))); elseif ((B_m ^ 2.0) <= 5e-35) tmp = t_1; elseif (((B_m ^ 2.0) <= 2e+154) || !((B_m ^ 2.0) <= 2e+178)) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); else tmp = Float64(t_2 * sqrt(Float64(F * Float64(-0.5 * Float64((B_m ^ 2.0) / C))))); 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[((-N[Sqrt[N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-135], t$95$1, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-90], N[(t$95$2 * N[Sqrt[N[(B$95$m * (-F)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-35], t$95$1, If[Or[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+154], N[Not[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+178]], $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], N[(t$95$2 * 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}
t_0 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := \frac{-\sqrt{\left(F \cdot t_0\right) \cdot \left(2 \cdot \left(A + A\right)\right)}}{t_0}\\
t_2 := \frac{-\sqrt{2}}{B_m}\\
\mathbf{if}\;{B_m}^{2} \leq 2 \cdot 10^{-135}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;{B_m}^{2} \leq 5 \cdot 10^{-90}:\\
\;\;\;\;t_2 \cdot \sqrt{B_m \cdot \left(-F\right)}\\
\mathbf{elif}\;{B_m}^{2} \leq 5 \cdot 10^{-35}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;{B_m}^{2} \leq 2 \cdot 10^{+154} \lor \neg \left({B_m}^{2} \leq 2 \cdot 10^{+178}\right):\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t_2 \cdot \sqrt{F \cdot \left(-0.5 \cdot \frac{{B_m}^{2}}{C}\right)}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 2.0000000000000001e-135 or 5.00000000000000019e-90 < (pow.f64 B 2) < 4.99999999999999964e-35Initial program 33.5%
Simplified42.0%
Taylor expanded in C around inf 25.8%
if 2.0000000000000001e-135 < (pow.f64 B 2) < 5.00000000000000019e-90Initial program 39.7%
Simplified40.9%
Taylor expanded in A around 0 18.0%
associate-*r*18.0%
mul-1-neg18.0%
unpow218.0%
unpow218.0%
hypot-def18.6%
Simplified18.6%
Taylor expanded in C around 0 17.4%
associate-*r*17.4%
mul-1-neg17.4%
Simplified17.4%
if 4.99999999999999964e-35 < (pow.f64 B 2) < 2.00000000000000007e154 or 2.0000000000000001e178 < (pow.f64 B 2) Initial program 16.9%
Simplified16.5%
Taylor expanded in C around 0 11.3%
associate-*r*11.3%
mul-1-neg11.3%
+-commutative11.3%
unpow211.3%
unpow211.3%
hypot-def30.9%
Simplified30.9%
if 2.00000000000000007e154 < (pow.f64 B 2) < 2.0000000000000001e178Initial program 27.1%
Simplified27.3%
Taylor expanded in A around 0 3.4%
associate-*r*3.4%
mul-1-neg3.4%
unpow23.4%
unpow23.4%
hypot-def3.7%
Simplified3.7%
Taylor expanded in C around inf 13.9%
Final simplification27.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
(let* ((t_0 (fma B_m B_m (* A (* C -4.0)))) (t_1 (* F t_0)))
(if (<= (pow B_m 2.0) 5e-182)
(/ (- (sqrt (* t_1 (* 2.0 (+ A A))))) t_0)
(if (<= (pow B_m 2.0) 2e+154)
(/ (- (sqrt (* t_1 (* 2.0 (+ A (- C (hypot B_m (- A C)))))))) t_0)
(if (<= (pow B_m 2.0) 2e+197)
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (* -0.5 (/ (pow B_m 2.0) 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 tmp;
if (pow(B_m, 2.0) <= 5e-182) {
tmp = -sqrt((t_1 * (2.0 * (A + A)))) / t_0;
} else if (pow(B_m, 2.0) <= 2e+154) {
tmp = -sqrt((t_1 * (2.0 * (A + (C - hypot(B_m, (A - C))))))) / t_0;
} else if (pow(B_m, 2.0) <= 2e+197) {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (-0.5 * (pow(B_m, 2.0) / 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) tmp = 0.0 if ((B_m ^ 2.0) <= 5e-182) tmp = Float64(Float64(-sqrt(Float64(t_1 * Float64(2.0 * Float64(A + A))))) / t_0); elseif ((B_m ^ 2.0) <= 2e+154) tmp = Float64(Float64(-sqrt(Float64(t_1 * Float64(2.0 * Float64(A + Float64(C - hypot(B_m, Float64(A - C)))))))) / t_0); elseif ((B_m ^ 2.0) <= 2e+197) tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(-0.5 * Float64((B_m ^ 2.0) / 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]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-182], N[((-N[Sqrt[N[(t$95$1 * N[(2.0 * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+154], 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[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+197], 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], 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\\
\mathbf{if}\;{B_m}^{2} \leq 5 \cdot 10^{-182}:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \left(2 \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;{B_m}^{2} \leq 2 \cdot 10^{+154}:\\
\;\;\;\;\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}\;{B_m}^{2} \leq 2 \cdot 10^{+197}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(-0.5 \cdot \frac{{B_m}^{2}}{C}\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) < 5.00000000000000024e-182Initial program 28.5%
Simplified36.3%
Taylor expanded in C around inf 24.2%
if 5.00000000000000024e-182 < (pow.f64 B 2) < 2.00000000000000007e154Initial program 41.4%
Simplified51.7%
if 2.00000000000000007e154 < (pow.f64 B 2) < 1.9999999999999999e197Initial program 22.0%
Simplified22.1%
Taylor expanded in A around 0 12.9%
associate-*r*12.9%
mul-1-neg12.9%
unpow212.9%
unpow212.9%
hypot-def13.4%
Simplified13.4%
Taylor expanded in C around inf 21.4%
if 1.9999999999999999e197 < (pow.f64 B 2) Initial program 4.7%
Simplified0.6%
Taylor expanded in C around 0 6.4%
associate-*r*6.4%
mul-1-neg6.4%
+-commutative6.4%
unpow26.4%
unpow26.4%
hypot-def33.7%
Simplified33.7%
Final simplification36.0%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(if (<= (pow B_m 2.0) 2e-135)
(/
(- (sqrt (* -8.0 (* (* A C) (* F (+ A A))))))
(fma A (* C -4.0) (pow B_m 2.0)))
(if (or (<= (pow B_m 2.0) 2e+154) (not (<= (pow B_m 2.0) 2e+178)))
(* (/ (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 (pow(B_m, 2.0) <= 2e-135) {
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) <= 2e+154) || !(pow(B_m, 2.0) <= 2e+178)) {
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 = 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-135) tmp = Float64(Float64(-sqrt(Float64(-8.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A)))))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0))); elseif (((B_m ^ 2.0) <= 2e+154) || !((B_m ^ 2.0) <= 2e+178)) 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 = 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-135], N[((-N[Sqrt[N[(-8.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+154], N[Not[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+178]], $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], 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}\;{B_m}^{2} \leq 2 \cdot 10^{-135}:\\
\;\;\;\;\frac{-\sqrt{-8 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}\\
\mathbf{elif}\;{B_m}^{2} \leq 2 \cdot 10^{+154} \lor \neg \left({B_m}^{2} \leq 2 \cdot 10^{+178}\right):\\
\;\;\;\;\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 (pow.f64 B 2) < 2.0000000000000001e-135Initial program 31.1%
Simplified32.3%
Taylor expanded in C around inf 23.7%
associate-*r*23.7%
sub-neg23.7%
mul-1-neg23.7%
remove-double-neg23.7%
Simplified23.7%
if 2.0000000000000001e-135 < (pow.f64 B 2) < 2.00000000000000007e154 or 2.0000000000000001e178 < (pow.f64 B 2) Initial program 22.6%
Simplified22.7%
Taylor expanded in C around 0 11.5%
associate-*r*11.5%
mul-1-neg11.5%
+-commutative11.5%
unpow211.5%
unpow211.5%
hypot-def27.3%
Simplified27.3%
if 2.00000000000000007e154 < (pow.f64 B 2) < 2.0000000000000001e178Initial program 27.1%
Simplified27.3%
Taylor expanded in A around 0 3.4%
associate-*r*3.4%
mul-1-neg3.4%
unpow23.4%
unpow23.4%
hypot-def3.7%
Simplified3.7%
Taylor expanded in C around inf 13.9%
Final simplification25.4%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (if (<= C 5.4e+67) (* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A)))))) (* (/ (- (sqrt 2.0)) B_m) (sqrt (* -0.5 (/ (* (pow B_m 2.0) 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 (C <= 5.4e+67) {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((-0.5 * ((pow(B_m, 2.0) * 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 (C <= 5.4e+67) {
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((-0.5 * ((Math.pow(B_m, 2.0) * 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 C <= 5.4e+67: 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((-0.5 * ((math.pow(B_m, 2.0) * 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 (C <= 5.4e+67) 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(-0.5 * Float64(Float64((B_m ^ 2.0) * 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 (C <= 5.4e+67)
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
else
tmp = (-sqrt(2.0) / B_m) * sqrt((-0.5 * (((B_m ^ 2.0) * 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[C, 5.4e+67], 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[(-0.5 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] * F), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;C \leq 5.4 \cdot 10^{+67}:\\
\;\;\;\;\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{-0.5 \cdot \frac{{B_m}^{2} \cdot F}{C}}\\
\end{array}
\end{array}
if C < 5.3999999999999998e67Initial program 29.9%
Simplified30.8%
Taylor expanded in C around 0 9.5%
associate-*r*9.5%
mul-1-neg9.5%
+-commutative9.5%
unpow29.5%
unpow29.5%
hypot-def19.8%
Simplified19.8%
if 5.3999999999999998e67 < C Initial program 4.3%
Simplified2.7%
Taylor expanded in A around 0 4.8%
associate-*r*4.8%
mul-1-neg4.8%
unpow24.8%
unpow24.8%
hypot-def11.6%
Simplified11.6%
Taylor expanded in C around inf 26.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 (* (/ (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 26.1%
Simplified26.6%
Taylor expanded in C around 0 8.6%
associate-*r*8.6%
mul-1-neg8.6%
+-commutative8.6%
unpow28.6%
unpow28.6%
hypot-def18.3%
Simplified18.3%
Final simplification18.3%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (* (/ (- (sqrt 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(Float64(-sqrt(2.0)) / B_m) * 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 \sqrt{B_m \cdot \left(-F\right)}
\end{array}
Initial program 26.1%
Simplified26.6%
Taylor expanded in A around 0 9.1%
associate-*r*9.1%
mul-1-neg9.1%
unpow29.1%
unpow29.1%
hypot-def17.5%
Simplified17.5%
Taylor expanded in C around 0 15.7%
associate-*r*15.7%
mul-1-neg15.7%
Simplified15.7%
Final simplification15.7%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (* (/ (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 26.1%
Simplified26.6%
Taylor expanded in A around 0 9.1%
associate-*r*9.1%
mul-1-neg9.1%
unpow29.1%
unpow29.1%
hypot-def17.5%
Simplified17.5%
Taylor expanded in B around -inf 1.4%
Final simplification1.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 (* 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 26.1%
Simplified26.6%
Taylor expanded in A around -inf 11.1%
*-commutative11.1%
Simplified11.1%
Taylor expanded in A around inf 0.0%
Final simplification0.0%
herbie shell --seed 2023333
(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))))