
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0}
\end{array}
\end{array}
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma B_m B_m (* A (* C -4.0))))
(t_1 (hypot (- A C) B_m))
(t_2 (- t_0))
(t_3 (* (* 4.0 A) C))
(t_4
(/
(sqrt
(*
(* 2.0 (* (- (pow B_m 2.0) t_3) F))
(- (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0))))))
(- t_3 (pow B_m 2.0))))
(t_5 (* F t_0)))
(if (<= t_4 (- INFINITY))
(*
(sqrt (* F (/ (- (+ A C) t_1) (fma -4.0 (* A C) (pow B_m 2.0)))))
(- (sqrt 2.0)))
(if (<= t_4 -5e-163)
(/
(sqrt
(* t_5 (* 2.0 (+ A (/ (- (pow C 2.0) (pow t_1 2.0)) (+ C t_1))))))
t_2)
(if (<= t_4 INFINITY)
(/
(sqrt (* t_5 (* 2.0 (+ A (+ A (* -0.5 (/ (pow B_m 2.0) C)))))))
t_2)
(-
(expm1
(log1p (/ (sqrt (* 2.0 (* F (- A (hypot B_m A))))) B_m)))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double t_1 = hypot((A - C), B_m);
double t_2 = -t_0;
double t_3 = (4.0 * A) * C;
double t_4 = sqrt(((2.0 * ((pow(B_m, 2.0) - t_3) * F)) * ((A + C) - sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / (t_3 - pow(B_m, 2.0));
double t_5 = F * t_0;
double tmp;
if (t_4 <= -((double) INFINITY)) {
tmp = sqrt((F * (((A + C) - t_1) / fma(-4.0, (A * C), pow(B_m, 2.0))))) * -sqrt(2.0);
} else if (t_4 <= -5e-163) {
tmp = sqrt((t_5 * (2.0 * (A + ((pow(C, 2.0) - pow(t_1, 2.0)) / (C + t_1)))))) / t_2;
} else if (t_4 <= ((double) INFINITY)) {
tmp = sqrt((t_5 * (2.0 * (A + (A + (-0.5 * (pow(B_m, 2.0) / C))))))) / t_2;
} else {
tmp = -expm1(log1p((sqrt((2.0 * (F * (A - hypot(B_m, A))))) / B_m)));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_1 = hypot(Float64(A - C), B_m) t_2 = Float64(-t_0) t_3 = Float64(Float64(4.0 * A) * C) t_4 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_3) * F)) * Float64(Float64(A + C) - sqrt(Float64((B_m ^ 2.0) + (Float64(A - C) ^ 2.0)))))) / Float64(t_3 - (B_m ^ 2.0))) t_5 = Float64(F * t_0) tmp = 0.0 if (t_4 <= Float64(-Inf)) tmp = Float64(sqrt(Float64(F * Float64(Float64(Float64(A + C) - t_1) / fma(-4.0, Float64(A * C), (B_m ^ 2.0))))) * Float64(-sqrt(2.0))); elseif (t_4 <= -5e-163) tmp = Float64(sqrt(Float64(t_5 * Float64(2.0 * Float64(A + Float64(Float64((C ^ 2.0) - (t_1 ^ 2.0)) / Float64(C + t_1)))))) / t_2); elseif (t_4 <= Inf) tmp = Float64(sqrt(Float64(t_5 * Float64(2.0 * Float64(A + Float64(A + Float64(-0.5 * Float64((B_m ^ 2.0) / C))))))) / t_2); else tmp = Float64(-expm1(log1p(Float64(sqrt(Float64(2.0 * Float64(F * Float64(A - hypot(B_m, A))))) / B_m)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]}, Block[{t$95$2 = (-t$95$0)}, Block[{t$95$3 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$3), $MachinePrecision] * 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] / N[(t$95$3 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(F * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], N[(N[Sqrt[N[(F * N[(N[(N[(A + C), $MachinePrecision] - t$95$1), $MachinePrecision] / N[(-4.0 * N[(A * C), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$4, -5e-163], N[(N[Sqrt[N[(t$95$5 * N[(2.0 * N[(A + N[(N[(N[Power[C, 2.0], $MachinePrecision] - N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision] / N[(C + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(N[Sqrt[N[(t$95$5 * 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$2), $MachinePrecision], (-N[(Exp[N[Log[1 + N[(N[Sqrt[N[(2.0 * N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision]] - 1), $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{hypot}\left(A - C, B\_m\right)\\
t_2 := -t\_0\\
t_3 := \left(4 \cdot A\right) \cdot C\\
t_4 := \frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_3\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B\_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t\_3 - {B\_m}^{2}}\\
t_5 := F \cdot t\_0\\
\mathbf{if}\;t\_4 \leq -\infty:\\
\;\;\;\;\sqrt{F \cdot \frac{\left(A + C\right) - t\_1}{\mathsf{fma}\left(-4, A \cdot C, {B\_m}^{2}\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;t\_4 \leq -5 \cdot 10^{-163}:\\
\;\;\;\;\frac{\sqrt{t\_5 \cdot \left(2 \cdot \left(A + \frac{{C}^{2} - {t\_1}^{2}}{C + t\_1}\right)\right)}}{t\_2}\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;\frac{\sqrt{t\_5 \cdot \left(2 \cdot \left(A + \left(A + -0.5 \cdot \frac{{B\_m}^{2}}{C}\right)\right)\right)}}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)\right)}}{B\_m}\right)\right)\\
\end{array}
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -inf.0Initial program 3.1%
Simplified19.5%
div-inv19.5%
Applied egg-rr18.3%
Taylor expanded in F around 0 24.5%
mul-1-neg24.5%
associate-/l*26.3%
+-commutative26.3%
unpow226.3%
unpow226.3%
hypot-undefine60.1%
fma-define60.1%
Simplified60.1%
if -inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -4.99999999999999977e-163Initial program 96.4%
Simplified96.3%
flip--81.6%
pow281.6%
hypot-undefine81.6%
unpow281.6%
unpow281.6%
+-commutative81.6%
hypot-undefine81.6%
unpow281.6%
unpow281.6%
+-commutative81.6%
pow281.6%
unpow281.6%
unpow281.6%
hypot-define81.6%
Applied egg-rr81.6%
if -4.99999999999999977e-163 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < +inf.0Initial program 21.3%
Simplified27.7%
Taylor expanded in C around inf 27.9%
mul-1-neg27.9%
Simplified27.9%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) Initial program 0.0%
Taylor expanded in C around 0 1.9%
mul-1-neg1.9%
+-commutative1.9%
unpow21.9%
unpow21.9%
hypot-define21.5%
Simplified21.5%
expm1-log1p-u21.4%
expm1-undefine3.5%
associate-*l/3.5%
pow1/23.5%
pow1/23.5%
pow-prod-down3.5%
Applied egg-rr3.5%
expm1-define21.4%
unpow1/221.4%
Simplified21.4%
Final simplification38.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
(let* ((t_0 (* (* 4.0 A) C))
(t_1
(/
(sqrt
(*
(* 2.0 (* (- (pow B_m 2.0) t_0) F))
(- (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0))))))
(- t_0 (pow B_m 2.0))))
(t_2 (fma B_m B_m (* A (* C -4.0)))))
(if (<= t_1 -5e-163)
(*
(sqrt
(*
F
(/ (- (+ A C) (hypot (- A C) B_m)) (fma -4.0 (* A C) (pow B_m 2.0)))))
(- (sqrt 2.0)))
(if (<= t_1 INFINITY)
(/
(sqrt (* (* F t_2) (* 2.0 (+ A (+ A (* -0.5 (/ (pow B_m 2.0) C)))))))
(- t_2))
(- (expm1 (log1p (/ (sqrt (* 2.0 (* F (- A (hypot B_m A))))) B_m))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = (4.0 * A) * C;
double t_1 = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * ((A + C) - sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / (t_0 - pow(B_m, 2.0));
double t_2 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (t_1 <= -5e-163) {
tmp = sqrt((F * (((A + C) - hypot((A - C), B_m)) / fma(-4.0, (A * C), pow(B_m, 2.0))))) * -sqrt(2.0);
} else if (t_1 <= ((double) INFINITY)) {
tmp = sqrt(((F * t_2) * (2.0 * (A + (A + (-0.5 * (pow(B_m, 2.0) / C))))))) / -t_2;
} else {
tmp = -expm1(log1p((sqrt((2.0 * (F * (A - hypot(B_m, A))))) / B_m)));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(Float64(4.0 * A) * C) t_1 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(Float64(A + C) - sqrt(Float64((B_m ^ 2.0) + (Float64(A - C) ^ 2.0)))))) / Float64(t_0 - (B_m ^ 2.0))) t_2 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (t_1 <= -5e-163) tmp = Float64(sqrt(Float64(F * Float64(Float64(Float64(A + C) - hypot(Float64(A - C), B_m)) / fma(-4.0, Float64(A * C), (B_m ^ 2.0))))) * Float64(-sqrt(2.0))); elseif (t_1 <= Inf) tmp = Float64(sqrt(Float64(Float64(F * t_2) * Float64(2.0 * Float64(A + Float64(A + Float64(-0.5 * Float64((B_m ^ 2.0) / C))))))) / Float64(-t_2)); else tmp = Float64(-expm1(log1p(Float64(sqrt(Float64(2.0 * Float64(F * Float64(A - hypot(B_m, A))))) / B_m)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * 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] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-163], N[(N[Sqrt[N[(F * N[(N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] / N[(-4.0 * N[(A * C), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[Sqrt[N[(N[(F * t$95$2), $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$2)), $MachinePrecision], (-N[(Exp[N[Log[1 + N[(N[Sqrt[N[(2.0 * N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision]] - 1), $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 := \left(4 \cdot A\right) \cdot C\\
t_1 := \frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B\_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t\_0 - {B\_m}^{2}}\\
t_2 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-163}:\\
\;\;\;\;\sqrt{F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(A - C, B\_m\right)}{\mathsf{fma}\left(-4, A \cdot C, {B\_m}^{2}\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\left(F \cdot t\_2\right) \cdot \left(2 \cdot \left(A + \left(A + -0.5 \cdot \frac{{B\_m}^{2}}{C}\right)\right)\right)}}{-t\_2}\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)\right)}}{B\_m}\right)\right)\\
\end{array}
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -4.99999999999999977e-163Initial program 37.2%
Simplified47.6%
div-inv46.0%
Applied egg-rr45.2%
Taylor expanded in F around 0 45.9%
mul-1-neg45.9%
associate-/l*47.1%
+-commutative47.1%
unpow247.1%
unpow247.1%
hypot-undefine68.5%
fma-define68.5%
Simplified68.5%
if -4.99999999999999977e-163 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < +inf.0Initial program 21.3%
Simplified27.7%
Taylor expanded in C around inf 27.9%
mul-1-neg27.9%
Simplified27.9%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) Initial program 0.0%
Taylor expanded in C around 0 1.9%
mul-1-neg1.9%
+-commutative1.9%
unpow21.9%
unpow21.9%
hypot-define21.5%
Simplified21.5%
expm1-log1p-u21.4%
expm1-undefine3.5%
associate-*l/3.5%
pow1/23.5%
pow1/23.5%
pow-prod-down3.5%
Applied egg-rr3.5%
expm1-define21.4%
unpow1/221.4%
Simplified21.4%
Final simplification38.1%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma B_m B_m (* A (* C -4.0)))))
(if (<= (pow B_m 2.0) 1e-224)
(/ (sqrt (* (* 4.0 A) (* F t_0))) (- t_0))
(if (<= (pow B_m 2.0) 5e+39)
(* (sqrt (* -0.5 (* (pow B_m 2.0) (/ F C)))) (/ (sqrt 2.0) (- B_m)))
(* (sqrt (* 2.0 (* F (- A (hypot B_m A))))) (/ -1.0 B_m))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (pow(B_m, 2.0) <= 1e-224) {
tmp = sqrt(((4.0 * A) * (F * t_0))) / -t_0;
} else if (pow(B_m, 2.0) <= 5e+39) {
tmp = sqrt((-0.5 * (pow(B_m, 2.0) * (F / C)))) * (sqrt(2.0) / -B_m);
} else {
tmp = sqrt((2.0 * (F * (A - hypot(B_m, A))))) * (-1.0 / B_m);
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-224) tmp = Float64(sqrt(Float64(Float64(4.0 * A) * Float64(F * t_0))) / Float64(-t_0)); elseif ((B_m ^ 2.0) <= 5e+39) tmp = Float64(sqrt(Float64(-0.5 * Float64((B_m ^ 2.0) * Float64(F / C)))) * Float64(sqrt(2.0) / Float64(-B_m))); else tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(A - hypot(B_m, A))))) * Float64(-1.0 / B_m)); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-224], N[(N[Sqrt[N[(N[(4.0 * A), $MachinePrecision] * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+39], N[(N[Sqrt[N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] * N[(F / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(2.0 * N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-224}:\\
\;\;\;\;\frac{\sqrt{\left(4 \cdot A\right) \cdot \left(F \cdot t\_0\right)}}{-t\_0}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+39}:\\
\;\;\;\;\sqrt{-0.5 \cdot \left({B\_m}^{2} \cdot \frac{F}{C}\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)\right)} \cdot \frac{-1}{B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 1e-224Initial program 22.4%
Simplified29.3%
Taylor expanded in A around -inf 22.2%
if 1e-224 < (pow.f64 B #s(literal 2 binary64)) < 5.00000000000000015e39Initial program 21.3%
Taylor expanded in A around 0 13.6%
mul-1-neg13.6%
+-commutative13.6%
unpow213.6%
unpow213.6%
hypot-define14.1%
Simplified14.1%
Taylor expanded in C around inf 15.3%
associate-/l*15.3%
Simplified15.3%
if 5.00000000000000015e39 < (pow.f64 B #s(literal 2 binary64)) Initial program 11.8%
Taylor expanded in C around 0 14.0%
mul-1-neg14.0%
+-commutative14.0%
unpow214.0%
unpow214.0%
hypot-define32.1%
Simplified32.1%
neg-sub032.1%
associate-*l/32.1%
pow1/232.1%
pow1/232.1%
pow-prod-down32.2%
Applied egg-rr32.2%
neg-sub032.2%
distribute-neg-frac232.2%
unpow1/232.2%
Simplified32.2%
pow1/232.2%
clear-num32.2%
inv-pow32.2%
pow1/232.2%
associate-*r*32.2%
Applied egg-rr32.2%
unpow-132.2%
associate-/r/32.2%
associate-*l*32.2%
Simplified32.2%
Final simplification25.2%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(if (<= (pow B_m 2.0) 1e-224)
(/
(sqrt (* (* A -8.0) (* C (* F (+ A A)))))
(- (fma C (* A -4.0) (pow B_m 2.0))))
(if (<= (pow B_m 2.0) 5e+39)
(* (sqrt (* -0.5 (* (pow B_m 2.0) (/ F C)))) (/ (sqrt 2.0) (- B_m)))
(* (sqrt (* 2.0 (* F (- A (hypot B_m A))))) (/ -1.0 B_m)))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (pow(B_m, 2.0) <= 1e-224) {
tmp = sqrt(((A * -8.0) * (C * (F * (A + A))))) / -fma(C, (A * -4.0), pow(B_m, 2.0));
} else if (pow(B_m, 2.0) <= 5e+39) {
tmp = sqrt((-0.5 * (pow(B_m, 2.0) * (F / C)))) * (sqrt(2.0) / -B_m);
} else {
tmp = sqrt((2.0 * (F * (A - hypot(B_m, A))))) * (-1.0 / B_m);
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-224) tmp = Float64(sqrt(Float64(Float64(A * -8.0) * Float64(C * Float64(F * Float64(A + A))))) / Float64(-fma(C, Float64(A * -4.0), (B_m ^ 2.0)))); elseif ((B_m ^ 2.0) <= 5e+39) tmp = Float64(sqrt(Float64(-0.5 * Float64((B_m ^ 2.0) * Float64(F / C)))) * Float64(sqrt(2.0) / Float64(-B_m))); else tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(A - hypot(B_m, A))))) * Float64(-1.0 / B_m)); end return tmp end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-224], N[(N[Sqrt[N[(N[(A * -8.0), $MachinePrecision] * N[(C * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(C * N[(A * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision])), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+39], N[(N[Sqrt[N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] * N[(F / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(2.0 * N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;{B\_m}^{2} \leq 10^{-224}:\\
\;\;\;\;\frac{\sqrt{\left(A \cdot -8\right) \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{-\mathsf{fma}\left(C, A \cdot -4, {B\_m}^{2}\right)}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+39}:\\
\;\;\;\;\sqrt{-0.5 \cdot \left({B\_m}^{2} \cdot \frac{F}{C}\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)\right)} \cdot \frac{-1}{B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 1e-224Initial program 22.4%
Simplified24.2%
Taylor expanded in C around inf 21.0%
associate-*r*21.1%
mul-1-neg21.1%
Simplified21.1%
if 1e-224 < (pow.f64 B #s(literal 2 binary64)) < 5.00000000000000015e39Initial program 21.3%
Taylor expanded in A around 0 13.6%
mul-1-neg13.6%
+-commutative13.6%
unpow213.6%
unpow213.6%
hypot-define14.1%
Simplified14.1%
Taylor expanded in C around inf 15.3%
associate-/l*15.3%
Simplified15.3%
if 5.00000000000000015e39 < (pow.f64 B #s(literal 2 binary64)) Initial program 11.8%
Taylor expanded in C around 0 14.0%
mul-1-neg14.0%
+-commutative14.0%
unpow214.0%
unpow214.0%
hypot-define32.1%
Simplified32.1%
neg-sub032.1%
associate-*l/32.1%
pow1/232.1%
pow1/232.1%
pow-prod-down32.2%
Applied egg-rr32.2%
neg-sub032.2%
distribute-neg-frac232.2%
unpow1/232.2%
Simplified32.2%
pow1/232.2%
clear-num32.2%
inv-pow32.2%
pow1/232.2%
associate-*r*32.2%
Applied egg-rr32.2%
unpow-132.2%
associate-/r/32.2%
associate-*l*32.2%
Simplified32.2%
Final simplification24.8%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(if (<= (pow B_m 2.0) 1e-224)
(*
(sqrt (* -8.0 (* A (* C (* F (+ A A))))))
(/ -1.0 (fma B_m B_m (* A (* C -4.0)))))
(if (<= (pow B_m 2.0) 5e+39)
(* (sqrt (* -0.5 (* (pow B_m 2.0) (/ F C)))) (/ (sqrt 2.0) (- B_m)))
(* (sqrt (* 2.0 (* F (- A (hypot B_m A))))) (/ -1.0 B_m)))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (pow(B_m, 2.0) <= 1e-224) {
tmp = sqrt((-8.0 * (A * (C * (F * (A + A)))))) * (-1.0 / fma(B_m, B_m, (A * (C * -4.0))));
} else if (pow(B_m, 2.0) <= 5e+39) {
tmp = sqrt((-0.5 * (pow(B_m, 2.0) * (F / C)))) * (sqrt(2.0) / -B_m);
} else {
tmp = sqrt((2.0 * (F * (A - hypot(B_m, A))))) * (-1.0 / B_m);
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-224) tmp = Float64(sqrt(Float64(-8.0 * Float64(A * Float64(C * Float64(F * Float64(A + A)))))) * Float64(-1.0 / fma(B_m, B_m, Float64(A * Float64(C * -4.0))))); elseif ((B_m ^ 2.0) <= 5e+39) tmp = Float64(sqrt(Float64(-0.5 * Float64((B_m ^ 2.0) * Float64(F / C)))) * Float64(sqrt(2.0) / Float64(-B_m))); else tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(A - hypot(B_m, A))))) * Float64(-1.0 / B_m)); end return tmp end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-224], N[(N[Sqrt[N[(-8.0 * N[(A * N[(C * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+39], N[(N[Sqrt[N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] * N[(F / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(2.0 * N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;{B\_m}^{2} \leq 10^{-224}:\\
\;\;\;\;\sqrt{-8 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)} \cdot \frac{-1}{\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+39}:\\
\;\;\;\;\sqrt{-0.5 \cdot \left({B\_m}^{2} \cdot \frac{F}{C}\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)\right)} \cdot \frac{-1}{B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 1e-224Initial program 22.4%
Simplified29.3%
div-inv27.6%
Applied egg-rr25.8%
Taylor expanded in C around inf 21.0%
if 1e-224 < (pow.f64 B #s(literal 2 binary64)) < 5.00000000000000015e39Initial program 21.3%
Taylor expanded in A around 0 13.6%
mul-1-neg13.6%
+-commutative13.6%
unpow213.6%
unpow213.6%
hypot-define14.1%
Simplified14.1%
Taylor expanded in C around inf 15.3%
associate-/l*15.3%
Simplified15.3%
if 5.00000000000000015e39 < (pow.f64 B #s(literal 2 binary64)) Initial program 11.8%
Taylor expanded in C around 0 14.0%
mul-1-neg14.0%
+-commutative14.0%
unpow214.0%
unpow214.0%
hypot-define32.1%
Simplified32.1%
neg-sub032.1%
associate-*l/32.1%
pow1/232.1%
pow1/232.1%
pow-prod-down32.2%
Applied egg-rr32.2%
neg-sub032.2%
distribute-neg-frac232.2%
unpow1/232.2%
Simplified32.2%
pow1/232.2%
clear-num32.2%
inv-pow32.2%
pow1/232.2%
associate-*r*32.2%
Applied egg-rr32.2%
unpow-132.2%
associate-/r/32.2%
associate-*l*32.2%
Simplified32.2%
Final simplification24.8%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(if (<= (pow B_m 2.0) 4e-65)
(*
(sqrt (* -8.0 (* A (* C (* F (+ A A))))))
(/ -1.0 (fma B_m B_m (* A (* C -4.0)))))
(/ (sqrt (* 2.0 (* F (- A (hypot B_m A))))) (- B_m))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (pow(B_m, 2.0) <= 4e-65) {
tmp = sqrt((-8.0 * (A * (C * (F * (A + A)))))) * (-1.0 / fma(B_m, B_m, (A * (C * -4.0))));
} else {
tmp = sqrt((2.0 * (F * (A - hypot(B_m, A))))) / -B_m;
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if ((B_m ^ 2.0) <= 4e-65) tmp = Float64(sqrt(Float64(-8.0 * Float64(A * Float64(C * Float64(F * Float64(A + A)))))) * Float64(-1.0 / fma(B_m, B_m, Float64(A * Float64(C * -4.0))))); else tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(A - hypot(B_m, A))))) / Float64(-B_m)); end return tmp end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e-65], N[(N[Sqrt[N[(-8.0 * N[(A * N[(C * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(2.0 * N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $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 4 \cdot 10^{-65}:\\
\;\;\;\;\sqrt{-8 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)} \cdot \frac{-1}{\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)\right)}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 3.99999999999999969e-65Initial program 20.4%
Simplified27.9%
div-inv26.8%
Applied egg-rr25.2%
Taylor expanded in C around inf 18.0%
if 3.99999999999999969e-65 < (pow.f64 B #s(literal 2 binary64)) Initial program 14.6%
Taylor expanded in C around 0 13.7%
mul-1-neg13.7%
+-commutative13.7%
unpow213.7%
unpow213.7%
hypot-define29.2%
Simplified29.2%
neg-sub029.2%
associate-*l/29.1%
pow1/229.1%
pow1/229.1%
pow-prod-down29.3%
Applied egg-rr29.3%
neg-sub029.3%
distribute-neg-frac229.3%
unpow1/229.2%
Simplified29.2%
Final simplification24.1%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(if (<= (pow B_m 2.0) 4e-65)
(*
(/ -1.0 (fma B_m B_m (* A (* C -4.0))))
(sqrt (* -8.0 (* A (* (+ A A) (* C F))))))
(/ (sqrt (* 2.0 (* F (- A (hypot B_m A))))) (- B_m))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (pow(B_m, 2.0) <= 4e-65) {
tmp = (-1.0 / fma(B_m, B_m, (A * (C * -4.0)))) * sqrt((-8.0 * (A * ((A + A) * (C * F)))));
} else {
tmp = sqrt((2.0 * (F * (A - hypot(B_m, A))))) / -B_m;
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if ((B_m ^ 2.0) <= 4e-65) tmp = Float64(Float64(-1.0 / fma(B_m, B_m, Float64(A * Float64(C * -4.0)))) * sqrt(Float64(-8.0 * Float64(A * Float64(Float64(A + A) * Float64(C * F)))))); else tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(A - hypot(B_m, A))))) / Float64(-B_m)); end return tmp end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e-65], N[(N[(-1.0 / N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(-8.0 * N[(A * N[(N[(A + A), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(2.0 * N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $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 4 \cdot 10^{-65}:\\
\;\;\;\;\frac{-1}{\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{-8 \cdot \left(A \cdot \left(\left(A + A\right) \cdot \left(C \cdot F\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)\right)}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 3.99999999999999969e-65Initial program 20.4%
Simplified27.9%
div-inv26.8%
Applied egg-rr25.2%
Taylor expanded in C around inf 18.0%
associate-*r*14.8%
mul-1-neg14.8%
Simplified14.8%
if 3.99999999999999969e-65 < (pow.f64 B #s(literal 2 binary64)) Initial program 14.6%
Taylor expanded in C around 0 13.7%
mul-1-neg13.7%
+-commutative13.7%
unpow213.7%
unpow213.7%
hypot-define29.2%
Simplified29.2%
neg-sub029.2%
associate-*l/29.1%
pow1/229.1%
pow1/229.1%
pow-prod-down29.3%
Applied egg-rr29.3%
neg-sub029.3%
distribute-neg-frac229.3%
unpow1/229.2%
Simplified29.2%
Final simplification22.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 (/ (sqrt (* 2.0 (* F (- A (hypot B_m A))))) (- B_m)))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return sqrt((2.0 * (F * (A - hypot(B_m, A))))) / -B_m;
}
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 * (F * (A - Math.hypot(B_m, A))))) / -B_m;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return math.sqrt((2.0 * (F * (A - math.hypot(B_m, A))))) / -B_m
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(sqrt(Float64(2.0 * Float64(F * Float64(A - hypot(B_m, A))))) / Float64(-B_m)) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = sqrt((2.0 * (F * (A - hypot(B_m, A))))) / -B_m;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[(N[Sqrt[N[(2.0 * N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)\right)}}{-B\_m}
\end{array}
Initial program 17.2%
Taylor expanded in C around 0 9.4%
mul-1-neg9.4%
+-commutative9.4%
unpow29.4%
unpow29.4%
hypot-define18.0%
Simplified18.0%
neg-sub018.0%
associate-*l/18.0%
pow1/218.0%
pow1/218.0%
pow-prod-down18.1%
Applied egg-rr18.1%
neg-sub018.1%
distribute-neg-frac218.1%
unpow1/218.1%
Simplified18.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 (/ (sqrt (+ (* -2.0 (* B_m F)) (* 2.0 (* A F)))) (- B_m)))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return sqrt(((-2.0 * (B_m * F)) + (2.0 * (A * F)))) / -B_m;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = sqrt((((-2.0d0) * (b_m * f)) + (2.0d0 * (a * f)))) / -b_m
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return Math.sqrt(((-2.0 * (B_m * F)) + (2.0 * (A * F)))) / -B_m;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return math.sqrt(((-2.0 * (B_m * F)) + (2.0 * (A * F)))) / -B_m
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(sqrt(Float64(Float64(-2.0 * Float64(B_m * F)) + Float64(2.0 * Float64(A * F)))) / Float64(-B_m)) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = sqrt(((-2.0 * (B_m * F)) + (2.0 * (A * F)))) / -B_m;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[(N[Sqrt[N[(N[(-2.0 * N[(B$95$m * F), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{\sqrt{-2 \cdot \left(B\_m \cdot F\right) + 2 \cdot \left(A \cdot F\right)}}{-B\_m}
\end{array}
Initial program 17.2%
Taylor expanded in C around 0 9.4%
mul-1-neg9.4%
+-commutative9.4%
unpow29.4%
unpow29.4%
hypot-define18.0%
Simplified18.0%
neg-sub018.0%
associate-*l/18.0%
pow1/218.0%
pow1/218.0%
pow-prod-down18.1%
Applied egg-rr18.1%
neg-sub018.1%
distribute-neg-frac218.1%
unpow1/218.1%
Simplified18.1%
Taylor expanded in A around 0 16.2%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (/ (sqrt (* -2.0 (* B_m F))) (- B_m)))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return sqrt((-2.0 * (B_m * F))) / -B_m;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = sqrt(((-2.0d0) * (b_m * f))) / -b_m
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return Math.sqrt((-2.0 * (B_m * F))) / -B_m;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return math.sqrt((-2.0 * (B_m * F))) / -B_m
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(sqrt(Float64(-2.0 * Float64(B_m * F))) / Float64(-B_m)) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = sqrt((-2.0 * (B_m * F))) / -B_m;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[(N[Sqrt[N[(-2.0 * N[(B$95$m * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{\sqrt{-2 \cdot \left(B\_m \cdot F\right)}}{-B\_m}
\end{array}
Initial program 17.2%
Taylor expanded in C around 0 9.4%
mul-1-neg9.4%
+-commutative9.4%
unpow29.4%
unpow29.4%
hypot-define18.0%
Simplified18.0%
neg-sub018.0%
associate-*l/18.0%
pow1/218.0%
pow1/218.0%
pow-prod-down18.1%
Applied egg-rr18.1%
neg-sub018.1%
distribute-neg-frac218.1%
unpow1/218.1%
Simplified18.1%
Taylor expanded in A around 0 17.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 (pow (* 2.0 (/ F B_m)) 0.5))
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 pow((2.0 * (F / B_m)), 0.5);
}
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 = (2.0d0 * (f / b_m)) ** 0.5d0
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.pow((2.0 * (F / B_m)), 0.5);
}
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.pow((2.0 * (F / B_m)), 0.5)
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(2.0 * Float64(F / B_m)) ^ 0.5 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 = (2.0 * (F / B_m)) ^ 0.5;
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[Power[N[(2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
{\left(2 \cdot \frac{F}{B\_m}\right)}^{0.5}
\end{array}
Initial program 17.2%
Taylor expanded in B around -inf 0.0%
mul-1-neg0.0%
unpow20.0%
rem-square-sqrt1.8%
Simplified1.8%
Taylor expanded in F around 0 1.8%
sqrt-unprod1.8%
pow1/22.0%
Applied egg-rr2.0%
Final simplification2.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 (sqrt (* F (/ 2.0 B_m))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return sqrt((F * (2.0 / B_m)));
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = sqrt((f * (2.0d0 / b_m)))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return Math.sqrt((F * (2.0 / B_m)));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return math.sqrt((F * (2.0 / B_m)))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return sqrt(Float64(F * Float64(2.0 / B_m))) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = sqrt((F * (2.0 / B_m)));
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[Sqrt[N[(F * N[(2.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\sqrt{F \cdot \frac{2}{B\_m}}
\end{array}
Initial program 17.2%
Taylor expanded in B around -inf 0.0%
mul-1-neg0.0%
unpow20.0%
rem-square-sqrt1.8%
Simplified1.8%
Taylor expanded in F around 0 1.8%
pow11.8%
sqrt-unprod1.8%
Applied egg-rr1.8%
unpow11.8%
associate-*l/1.8%
Simplified1.8%
*-un-lft-identity1.8%
associate-/l*1.8%
Applied egg-rr1.8%
*-lft-identity1.8%
Simplified1.8%
herbie shell --seed 2024188
(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))))