
(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}
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0))))
(t_1 (* (* 2.0 F) t_0))
(t_2 (+ A (- C (hypot B (- A C))))))
(if (<= C 4.4e-292)
(/ (- (sqrt (* t_2 t_1))) t_0)
(if (<= C 420000.0)
(/
(* (sqrt (* 2.0 (fma A (* C -4.0) (pow B 2.0)))) (- (sqrt (* F t_2))))
(- (pow B 2.0) (* 4.0 (* A C))))
(/ (- (sqrt (* t_1 (+ A (+ A (* (pow B 2.0) (/ -0.5 C))))))) t_0)))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double t_1 = (2.0 * F) * t_0;
double t_2 = A + (C - hypot(B, (A - C)));
double tmp;
if (C <= 4.4e-292) {
tmp = -sqrt((t_2 * t_1)) / t_0;
} else if (C <= 420000.0) {
tmp = (sqrt((2.0 * fma(A, (C * -4.0), pow(B, 2.0)))) * -sqrt((F * t_2))) / (pow(B, 2.0) - (4.0 * (A * C)));
} else {
tmp = -sqrt((t_1 * (A + (A + (pow(B, 2.0) * (-0.5 / C)))))) / t_0;
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) t_1 = Float64(Float64(2.0 * F) * t_0) t_2 = Float64(A + Float64(C - hypot(B, Float64(A - C)))) tmp = 0.0 if (C <= 4.4e-292) tmp = Float64(Float64(-sqrt(Float64(t_2 * t_1))) / t_0); elseif (C <= 420000.0) tmp = Float64(Float64(sqrt(Float64(2.0 * fma(A, Float64(C * -4.0), (B ^ 2.0)))) * Float64(-sqrt(Float64(F * t_2)))) / Float64((B ^ 2.0) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(Float64(-sqrt(Float64(t_1 * Float64(A + Float64(A + Float64((B ^ 2.0) * Float64(-0.5 / C))))))) / t_0); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[C, 4.4e-292], N[((-N[Sqrt[N[(t$95$2 * t$95$1), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[C, 420000.0], N[(N[(N[Sqrt[N[(2.0 * N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(F * t$95$2), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / N[(N[Power[B, 2.0], $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(t$95$1 * N[(A + N[(A + N[(N[Power[B, 2.0], $MachinePrecision] * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := \left(2 \cdot F\right) \cdot t_0\\
t_2 := A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\\
\mathbf{if}\;C \leq 4.4 \cdot 10^{-292}:\\
\;\;\;\;\frac{-\sqrt{t_2 \cdot t_1}}{t_0}\\
\mathbf{elif}\;C \leq 420000:\\
\;\;\;\;\frac{\sqrt{2 \cdot \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \cdot \left(-\sqrt{F \cdot t_2}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \left(A + \left(A + {B}^{2} \cdot \frac{-0.5}{C}\right)\right)}}{t_0}\\
\end{array}
\end{array}
if C < 4.40000000000000023e-292Initial program 25.4%
Simplified37.8%
if 4.40000000000000023e-292 < C < 4.2e5Initial program 29.6%
Simplified29.6%
associate--l+29.6%
unpow229.6%
unpow229.6%
hypot-udef31.5%
add-cbrt-cube26.9%
*-commutative26.9%
pow126.9%
metadata-eval26.9%
pow126.9%
metadata-eval26.9%
pow-sqr26.9%
metadata-eval26.9%
metadata-eval26.9%
Applied egg-rr26.9%
associate-+r-26.9%
+-commutative26.9%
associate-+r-26.9%
associate-+r-26.9%
+-commutative26.9%
associate-+r-27.8%
Simplified27.8%
associate-*l*27.6%
sqrt-prod30.3%
*-commutative30.3%
cancel-sign-sub-inv30.3%
metadata-eval30.3%
*-commutative30.3%
associate-*r*30.3%
+-commutative30.3%
fma-udef30.3%
Applied egg-rr36.4%
*-commutative36.4%
associate-+r-36.5%
+-commutative36.5%
associate--l+36.5%
Simplified36.5%
if 4.2e5 < C Initial program 5.7%
Simplified10.3%
Taylor expanded in C around inf 33.1%
associate-*r/33.1%
+-commutative33.1%
mul-1-neg33.1%
Simplified33.1%
Taylor expanded in B around 0 33.1%
associate-*r/33.1%
+-rgt-identity33.1%
associate-*l/33.1%
*-commutative33.1%
+-rgt-identity33.1%
Simplified33.1%
Final simplification36.3%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma A (* C -4.0) (pow B 2.0)))
(t_1 (- (pow B 2.0) (* (* 4.0 A) C))))
(if (<=
(/
(-
(sqrt
(*
(* 2.0 (* t_1 F))
(- (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_1)
-5e-197)
(/
(* (sqrt (* 2.0 t_0)) (- (sqrt (* F (+ A (- C (hypot B (- A C))))))))
(- (pow B 2.0) (* 4.0 (* A C))))
(*
(sqrt (* (* t_0 (* 2.0 F)) (+ (* (pow B 2.0) (/ -0.5 C)) (* 2.0 A))))
(/ -1.0 t_0)))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(A, (C * -4.0), pow(B, 2.0));
double t_1 = pow(B, 2.0) - ((4.0 * A) * C);
double tmp;
if ((-sqrt(((2.0 * (t_1 * F)) * ((A + C) - sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_1) <= -5e-197) {
tmp = (sqrt((2.0 * t_0)) * -sqrt((F * (A + (C - hypot(B, (A - C))))))) / (pow(B, 2.0) - (4.0 * (A * C)));
} else {
tmp = sqrt(((t_0 * (2.0 * F)) * ((pow(B, 2.0) * (-0.5 / C)) + (2.0 * A)))) * (-1.0 / t_0);
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(A, Float64(C * -4.0), (B ^ 2.0)) t_1 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) tmp = 0.0 if (Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_1 * F)) * Float64(Float64(A + C) - sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_1) <= -5e-197) tmp = Float64(Float64(sqrt(Float64(2.0 * t_0)) * Float64(-sqrt(Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C)))))))) / Float64((B ^ 2.0) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(sqrt(Float64(Float64(t_0 * Float64(2.0 * F)) * Float64(Float64((B ^ 2.0) * Float64(-0.5 / C)) + Float64(2.0 * A)))) * Float64(-1.0 / t_0)); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$1 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], -5e-197], N[(N[(N[Sqrt[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / N[(N[Power[B, 2.0], $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(t$95$0 * N[(2.0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Power[B, 2.0], $MachinePrecision] * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision] + N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)\\
t_1 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\mathbf{if}\;\frac{-\sqrt{\left(2 \cdot \left(t_1 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_1} \leq -5 \cdot 10^{-197}:\\
\;\;\;\;\frac{\sqrt{2 \cdot t_0} \cdot \left(-\sqrt{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(t_0 \cdot \left(2 \cdot F\right)\right) \cdot \left({B}^{2} \cdot \frac{-0.5}{C} + 2 \cdot A\right)} \cdot \frac{-1}{t_0}\\
\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 50.6%
Simplified50.6%
associate--l+50.6%
unpow250.6%
unpow250.6%
hypot-udef61.3%
add-cbrt-cube41.9%
*-commutative41.9%
pow141.9%
metadata-eval41.9%
pow141.9%
metadata-eval41.9%
pow-sqr41.9%
metadata-eval41.9%
metadata-eval41.9%
Applied egg-rr41.9%
associate-+r-41.7%
+-commutative41.7%
associate-+r-41.7%
associate-+r-41.7%
+-commutative41.7%
associate-+r-42.1%
Simplified42.1%
associate-*l*40.1%
sqrt-prod44.7%
*-commutative44.7%
cancel-sign-sub-inv44.7%
metadata-eval44.7%
*-commutative44.7%
associate-*r*44.7%
+-commutative44.7%
fma-udef44.7%
Applied egg-rr74.3%
*-commutative74.3%
associate-+r-73.1%
+-commutative73.1%
associate--l+73.8%
Simplified73.8%
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))) Initial program 6.5%
Simplified12.7%
Taylor expanded in C around inf 11.5%
associate-*r/11.5%
+-commutative11.5%
mul-1-neg11.5%
Simplified11.5%
Taylor expanded in B around 0 14.1%
associate-*r/14.1%
+-rgt-identity14.1%
associate-*l/14.1%
*-commutative14.1%
+-rgt-identity14.1%
Simplified14.1%
div-inv14.1%
*-commutative14.1%
fma-udef14.1%
unpow214.1%
+-commutative14.1%
fma-udef14.1%
fma-udef14.1%
unpow214.1%
+-commutative14.1%
fma-udef14.1%
+-commutative14.1%
+-commutative14.1%
Applied egg-rr14.1%
Final simplification34.1%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= (pow B 2.0) 1e-21)
(/
(- (sqrt (* 4.0 (* A (* F (+ (pow B 2.0) (* -4.0 (* A C))))))))
(fma B B (* A (* C -4.0))))
(if (<= (pow B 2.0) 3e+262)
(/
(* (sqrt (* F (- C B))) (* B (- (sqrt 2.0))))
(- (pow B 2.0) (* 4.0 (* A C))))
(* -2.0 (/ (sqrt (* A F)) B)))))assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (pow(B, 2.0) <= 1e-21) {
tmp = -sqrt((4.0 * (A * (F * (pow(B, 2.0) + (-4.0 * (A * C))))))) / fma(B, B, (A * (C * -4.0)));
} else if (pow(B, 2.0) <= 3e+262) {
tmp = (sqrt((F * (C - B))) * (B * -sqrt(2.0))) / (pow(B, 2.0) - (4.0 * (A * C)));
} else {
tmp = -2.0 * (sqrt((A * F)) / B);
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if ((B ^ 2.0) <= 1e-21) tmp = Float64(Float64(-sqrt(Float64(4.0 * Float64(A * Float64(F * Float64((B ^ 2.0) + Float64(-4.0 * Float64(A * C)))))))) / fma(B, B, Float64(A * Float64(C * -4.0)))); elseif ((B ^ 2.0) <= 3e+262) tmp = Float64(Float64(sqrt(Float64(F * Float64(C - B))) * Float64(B * Float64(-sqrt(2.0)))) / Float64((B ^ 2.0) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 1e-21], N[((-N[Sqrt[N[(4.0 * N[(A * N[(F * N[(N[Power[B, 2.0], $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 3e+262], N[(N[(N[Sqrt[N[(F * N[(C - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(B * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] / N[(N[Power[B, 2.0], $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 10^{-21}:\\
\;\;\;\;\frac{-\sqrt{4 \cdot \left(A \cdot \left(F \cdot \left({B}^{2} + -4 \cdot \left(A \cdot C\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{elif}\;{B}^{2} \leq 3 \cdot 10^{+262}:\\
\;\;\;\;\frac{\sqrt{F \cdot \left(C - B\right)} \cdot \left(B \cdot \left(-\sqrt{2}\right)\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 9.99999999999999908e-22Initial program 23.6%
Simplified38.2%
Taylor expanded in C around inf 24.9%
Taylor expanded in F around 0 24.8%
if 9.99999999999999908e-22 < (pow.f64 B 2) < 3e262Initial program 42.5%
Simplified42.5%
associate--l+42.7%
unpow242.7%
unpow242.7%
hypot-udef43.3%
add-cbrt-cube34.5%
*-commutative34.5%
pow134.5%
metadata-eval34.5%
pow134.5%
metadata-eval34.5%
pow-sqr34.5%
metadata-eval34.5%
metadata-eval34.5%
Applied egg-rr34.5%
associate-+r-34.3%
+-commutative34.3%
associate-+r-34.3%
associate-+r-34.3%
+-commutative34.3%
associate-+r-34.5%
Simplified34.5%
Taylor expanded in A around 0 26.9%
Taylor expanded in B around inf 26.4%
if 3e262 < (pow.f64 B 2) Initial program 0.2%
Simplified1.7%
Taylor expanded in C around inf 1.7%
Taylor expanded in B around inf 4.8%
*-commutative4.8%
Simplified4.8%
Taylor expanded in B around 0 4.8%
associate-*r/4.9%
*-rgt-identity4.9%
Simplified4.9%
Final simplification19.5%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0)))) (t_1 (* (* 2.0 F) t_0)))
(if (<= C 25000.0)
(/ (- (sqrt (* (+ A (- C (hypot B (- A C)))) t_1))) t_0)
(/ (- (sqrt (* t_1 (+ A (+ A (* (pow B 2.0) (/ -0.5 C))))))) t_0))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double t_1 = (2.0 * F) * t_0;
double tmp;
if (C <= 25000.0) {
tmp = -sqrt(((A + (C - hypot(B, (A - C)))) * t_1)) / t_0;
} else {
tmp = -sqrt((t_1 * (A + (A + (pow(B, 2.0) * (-0.5 / C)))))) / t_0;
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) t_1 = Float64(Float64(2.0 * F) * t_0) tmp = 0.0 if (C <= 25000.0) tmp = Float64(Float64(-sqrt(Float64(Float64(A + Float64(C - hypot(B, Float64(A - C)))) * t_1))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(t_1 * Float64(A + Float64(A + Float64((B ^ 2.0) * Float64(-0.5 / C))))))) / t_0); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[C, 25000.0], N[((-N[Sqrt[N[(N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(t$95$1 * N[(A + N[(A + N[(N[Power[B, 2.0], $MachinePrecision] * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := \left(2 \cdot F\right) \cdot t_0\\
\mathbf{if}\;C \leq 25000:\\
\;\;\;\;\frac{-\sqrt{\left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right) \cdot t_1}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \left(A + \left(A + {B}^{2} \cdot \frac{-0.5}{C}\right)\right)}}{t_0}\\
\end{array}
\end{array}
if C < 25000Initial program 27.0%
Simplified35.9%
if 25000 < C Initial program 5.7%
Simplified10.2%
Taylor expanded in C around inf 32.7%
associate-*r/32.7%
+-commutative32.7%
mul-1-neg32.7%
Simplified32.7%
Taylor expanded in B around 0 32.8%
associate-*r/32.8%
+-rgt-identity32.8%
associate-*l/32.8%
*-commutative32.8%
+-rgt-identity32.8%
Simplified32.8%
Final simplification35.0%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0)))))
(if (<= B 4.2e-15)
(/ (- (sqrt (* (* (* 2.0 F) t_0) (+ A A)))) t_0)
(if (<= B 1.9e+131)
(/
(*
(* B (sqrt 2.0))
(- (sqrt (* F (- C (+ B (* 0.5 (/ (pow C 2.0) B))))))))
(- (pow B 2.0) (* 4.0 (* A C))))
(* -2.0 (/ (sqrt (* A F)) B))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (B <= 4.2e-15) {
tmp = -sqrt((((2.0 * F) * t_0) * (A + A))) / t_0;
} else if (B <= 1.9e+131) {
tmp = ((B * sqrt(2.0)) * -sqrt((F * (C - (B + (0.5 * (pow(C, 2.0) / B))))))) / (pow(B, 2.0) - (4.0 * (A * C)));
} else {
tmp = -2.0 * (sqrt((A * F)) / B);
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (B <= 4.2e-15) tmp = Float64(Float64(-sqrt(Float64(Float64(Float64(2.0 * F) * t_0) * Float64(A + A)))) / t_0); elseif (B <= 1.9e+131) tmp = Float64(Float64(Float64(B * sqrt(2.0)) * Float64(-sqrt(Float64(F * Float64(C - Float64(B + Float64(0.5 * Float64((C ^ 2.0) / B)))))))) / Float64((B ^ 2.0) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 4.2e-15], N[((-N[Sqrt[N[(N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 1.9e+131], N[(N[(N[(B * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * (-N[Sqrt[N[(F * N[(C - N[(B + N[(0.5 * N[(N[Power[C, 2.0], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / N[(N[Power[B, 2.0], $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;B \leq 4.2 \cdot 10^{-15}:\\
\;\;\;\;\frac{-\sqrt{\left(\left(2 \cdot F\right) \cdot t_0\right) \cdot \left(A + A\right)}}{t_0}\\
\mathbf{elif}\;B \leq 1.9 \cdot 10^{+131}:\\
\;\;\;\;\frac{\left(B \cdot \sqrt{2}\right) \cdot \left(-\sqrt{F \cdot \left(C - \left(B + 0.5 \cdot \frac{{C}^{2}}{B}\right)\right)}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 4.19999999999999962e-15Initial program 21.6%
Simplified31.8%
Taylor expanded in C around inf 17.4%
if 4.19999999999999962e-15 < B < 1.9000000000000002e131Initial program 38.3%
Simplified38.3%
associate--l+38.6%
unpow238.6%
unpow238.6%
hypot-udef39.6%
add-cbrt-cube30.7%
*-commutative30.7%
pow130.7%
metadata-eval30.7%
pow130.7%
metadata-eval30.7%
pow-sqr30.7%
metadata-eval30.7%
metadata-eval30.7%
Applied egg-rr30.7%
associate-+r-30.4%
+-commutative30.4%
associate-+r-30.4%
associate-+r-30.4%
+-commutative30.4%
associate-+r-30.7%
Simplified30.7%
Taylor expanded in A around 0 43.3%
Taylor expanded in B around inf 43.5%
if 1.9000000000000002e131 < B Initial program 0.2%
Simplified0.3%
Taylor expanded in C around inf 0.2%
Taylor expanded in B around inf 8.4%
*-commutative8.4%
Simplified8.4%
Taylor expanded in B around 0 8.4%
associate-*r/8.4%
*-rgt-identity8.4%
Simplified8.4%
Final simplification19.9%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= (pow B 2.0) 5e+115)
(/
(- (sqrt (* -8.0 (* A (* 2.0 (* C (* A F)))))))
(fma A (* C -4.0) (pow B 2.0)))
(* -2.0 (/ (sqrt (* A F)) B))))assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (pow(B, 2.0) <= 5e+115) {
tmp = -sqrt((-8.0 * (A * (2.0 * (C * (A * F)))))) / fma(A, (C * -4.0), pow(B, 2.0));
} else {
tmp = -2.0 * (sqrt((A * F)) / B);
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if ((B ^ 2.0) <= 5e+115) tmp = Float64(Float64(-sqrt(Float64(-8.0 * Float64(A * Float64(2.0 * Float64(C * Float64(A * F))))))) / fma(A, Float64(C * -4.0), (B ^ 2.0))); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e+115], N[((-N[Sqrt[N[(-8.0 * N[(A * N[(2.0 * N[(C * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{+115}:\\
\;\;\;\;\frac{-\sqrt{-8 \cdot \left(A \cdot \left(2 \cdot \left(C \cdot \left(A \cdot F\right)\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 5.00000000000000008e115Initial program 28.4%
Simplified35.1%
Taylor expanded in C around inf 21.1%
mul-1-neg21.1%
Simplified21.1%
Taylor expanded in C around 0 18.1%
*-commutative18.1%
associate-*l*21.1%
Simplified21.1%
if 5.00000000000000008e115 < (pow.f64 B 2) Initial program 10.4%
Simplified11.5%
Taylor expanded in C around inf 1.8%
Taylor expanded in B around inf 4.1%
*-commutative4.1%
Simplified4.1%
Taylor expanded in B around 0 4.1%
associate-*r/4.1%
*-rgt-identity4.1%
Simplified4.1%
Final simplification14.4%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0)))))
(if (<= B 5.7e-11)
(/ (- (sqrt (* (* (* 2.0 F) t_0) (+ A A)))) t_0)
(if (<= B 1.9e+131)
(/
(* (sqrt (* F (- C B))) (* B (- (sqrt 2.0))))
(- (pow B 2.0) (* 4.0 (* A C))))
(* -2.0 (/ (sqrt (* A F)) B))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (B <= 5.7e-11) {
tmp = -sqrt((((2.0 * F) * t_0) * (A + A))) / t_0;
} else if (B <= 1.9e+131) {
tmp = (sqrt((F * (C - B))) * (B * -sqrt(2.0))) / (pow(B, 2.0) - (4.0 * (A * C)));
} else {
tmp = -2.0 * (sqrt((A * F)) / B);
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (B <= 5.7e-11) tmp = Float64(Float64(-sqrt(Float64(Float64(Float64(2.0 * F) * t_0) * Float64(A + A)))) / t_0); elseif (B <= 1.9e+131) tmp = Float64(Float64(sqrt(Float64(F * Float64(C - B))) * Float64(B * Float64(-sqrt(2.0)))) / Float64((B ^ 2.0) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 5.7e-11], N[((-N[Sqrt[N[(N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 1.9e+131], N[(N[(N[Sqrt[N[(F * N[(C - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(B * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] / N[(N[Power[B, 2.0], $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;B \leq 5.7 \cdot 10^{-11}:\\
\;\;\;\;\frac{-\sqrt{\left(\left(2 \cdot F\right) \cdot t_0\right) \cdot \left(A + A\right)}}{t_0}\\
\mathbf{elif}\;B \leq 1.9 \cdot 10^{+131}:\\
\;\;\;\;\frac{\sqrt{F \cdot \left(C - B\right)} \cdot \left(B \cdot \left(-\sqrt{2}\right)\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 5.6999999999999997e-11Initial program 21.5%
Simplified31.7%
Taylor expanded in C around inf 17.3%
if 5.6999999999999997e-11 < B < 1.9000000000000002e131Initial program 39.4%
Simplified39.4%
associate--l+39.6%
unpow239.6%
unpow239.6%
hypot-udef40.6%
add-cbrt-cube31.5%
*-commutative31.5%
pow131.5%
metadata-eval31.5%
pow131.5%
metadata-eval31.5%
pow-sqr31.5%
metadata-eval31.5%
metadata-eval31.5%
Applied egg-rr31.5%
associate-+r-31.2%
+-commutative31.2%
associate-+r-31.2%
associate-+r-31.2%
+-commutative31.2%
associate-+r-31.5%
Simplified31.5%
Taylor expanded in A around 0 44.6%
Taylor expanded in B around inf 44.9%
if 1.9000000000000002e131 < B Initial program 0.2%
Simplified0.3%
Taylor expanded in C around inf 0.2%
Taylor expanded in B around inf 8.4%
*-commutative8.4%
Simplified8.4%
Taylor expanded in B around 0 8.4%
associate-*r/8.4%
*-rgt-identity8.4%
Simplified8.4%
Final simplification19.9%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 5e-11)
(/
(- (sqrt (* -8.0 (* A (* 2.0 (* C (* A F)))))))
(fma A (* C -4.0) (pow B 2.0)))
(if (<= B 1.9e+131)
(/
(* (sqrt (* F (- C B))) (* B (- (sqrt 2.0))))
(- (pow B 2.0) (* 4.0 (* A C))))
(* -2.0 (/ (sqrt (* A F)) B)))))assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 5e-11) {
tmp = -sqrt((-8.0 * (A * (2.0 * (C * (A * F)))))) / fma(A, (C * -4.0), pow(B, 2.0));
} else if (B <= 1.9e+131) {
tmp = (sqrt((F * (C - B))) * (B * -sqrt(2.0))) / (pow(B, 2.0) - (4.0 * (A * C)));
} else {
tmp = -2.0 * (sqrt((A * F)) / B);
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 5e-11) tmp = Float64(Float64(-sqrt(Float64(-8.0 * Float64(A * Float64(2.0 * Float64(C * Float64(A * F))))))) / fma(A, Float64(C * -4.0), (B ^ 2.0))); elseif (B <= 1.9e+131) tmp = Float64(Float64(sqrt(Float64(F * Float64(C - B))) * Float64(B * Float64(-sqrt(2.0)))) / Float64((B ^ 2.0) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 5e-11], N[((-N[Sqrt[N[(-8.0 * N[(A * N[(2.0 * N[(C * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 1.9e+131], N[(N[(N[Sqrt[N[(F * N[(C - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(B * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] / N[(N[Power[B, 2.0], $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\frac{-\sqrt{-8 \cdot \left(A \cdot \left(2 \cdot \left(C \cdot \left(A \cdot F\right)\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\\
\mathbf{elif}\;B \leq 1.9 \cdot 10^{+131}:\\
\;\;\;\;\frac{\sqrt{F \cdot \left(C - B\right)} \cdot \left(B \cdot \left(-\sqrt{2}\right)\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 5.00000000000000018e-11Initial program 21.5%
Simplified25.8%
Taylor expanded in C around inf 17.0%
mul-1-neg17.0%
Simplified17.0%
Taylor expanded in C around 0 14.6%
*-commutative14.6%
associate-*l*17.0%
Simplified17.0%
if 5.00000000000000018e-11 < B < 1.9000000000000002e131Initial program 39.4%
Simplified39.4%
associate--l+39.6%
unpow239.6%
unpow239.6%
hypot-udef40.6%
add-cbrt-cube31.5%
*-commutative31.5%
pow131.5%
metadata-eval31.5%
pow131.5%
metadata-eval31.5%
pow-sqr31.5%
metadata-eval31.5%
metadata-eval31.5%
Applied egg-rr31.5%
associate-+r-31.2%
+-commutative31.2%
associate-+r-31.2%
associate-+r-31.2%
+-commutative31.2%
associate-+r-31.5%
Simplified31.5%
Taylor expanded in A around 0 44.6%
Taylor expanded in B around inf 44.9%
if 1.9000000000000002e131 < B Initial program 0.2%
Simplified0.3%
Taylor expanded in C around inf 0.2%
Taylor expanded in B around inf 8.4%
*-commutative8.4%
Simplified8.4%
Taylor expanded in B around 0 8.4%
associate-*r/8.4%
*-rgt-identity8.4%
Simplified8.4%
Final simplification19.7%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= B 2.9e+54) (/ (- (sqrt (* (+ A A) (* -8.0 (* A (* C F)))))) (fma B B (* A (* C -4.0)))) (* -2.0 (/ (sqrt (* A F)) B))))
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 2.9e+54) {
tmp = -sqrt(((A + A) * (-8.0 * (A * (C * F))))) / fma(B, B, (A * (C * -4.0)));
} else {
tmp = -2.0 * (sqrt((A * F)) / B);
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 2.9e+54) tmp = Float64(Float64(-sqrt(Float64(Float64(A + A) * Float64(-8.0 * Float64(A * Float64(C * F)))))) / fma(B, B, Float64(A * Float64(C * -4.0)))); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 2.9e+54], N[((-N[Sqrt[N[(N[(A + A), $MachinePrecision] * N[(-8.0 * N[(A * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 2.9 \cdot 10^{+54}:\\
\;\;\;\;\frac{-\sqrt{\left(A + A\right) \cdot \left(-8 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 2.8999999999999999e54Initial program 23.4%
Simplified32.8%
Taylor expanded in C around inf 16.4%
Taylor expanded in B around 0 14.2%
*-commutative14.2%
Simplified14.2%
if 2.8999999999999999e54 < B Initial program 11.6%
Simplified11.7%
Taylor expanded in C around inf 0.9%
Taylor expanded in B around inf 6.6%
*-commutative6.6%
Simplified6.6%
Taylor expanded in B around 0 6.6%
associate-*r/6.6%
*-rgt-identity6.6%
Simplified6.6%
Final simplification12.8%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* -2.0 (/ (sqrt (* A F)) B)))
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (sqrt((A * F)) / B);
}
NOTE: A and C should be sorted in increasing order before calling this function.
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
code = (-2.0d0) * (sqrt((a * f)) / b)
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
return -2.0 * (Math.sqrt((A * F)) / B);
}
[A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.sqrt((A * F)) / B)
A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)) end
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (sqrt((A * F)) / B);
end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \frac{\sqrt{A \cdot F}}{B}
\end{array}
Initial program 21.3%
Simplified29.0%
Taylor expanded in C around inf 13.7%
Taylor expanded in B around inf 2.6%
*-commutative2.6%
Simplified2.6%
Taylor expanded in B around 0 2.6%
associate-*r/2.6%
*-rgt-identity2.6%
Simplified2.6%
Final simplification2.6%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 0.0)
assert(A < C);
double code(double A, double B, double C, double F) {
return 0.0;
}
NOTE: A and C should be sorted in increasing order before calling this function.
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
code = 0.0d0
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
return 0.0;
}
[A, C] = sort([A, C]) def code(A, B, C, F): return 0.0
A, C = sort([A, C]) function code(A, B, C, F) return 0.0 end
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = 0.0;
end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := 0.0
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
0
\end{array}
Initial program 21.3%
Simplified29.0%
Taylor expanded in C around inf 13.7%
Applied egg-rr2.1%
sub0-neg2.1%
distribute-neg-frac2.1%
unpow1/22.1%
mul0-rgt2.1%
metadata-eval2.1%
mul0-rgt2.1%
mul0-rgt2.1%
distribute-lft-out--2.1%
+-inverses3.7%
metadata-eval3.7%
metadata-eval3.7%
div03.8%
Simplified3.8%
Final simplification3.8%
herbie shell --seed 2023301
(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))))