
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))) (t_1 (fma B B (* C (* A -4.0)))))
(if (<= B 2.4e-101)
(- (/ (sqrt (* 2.0 (* (* F t_0) (* 2.0 A)))) t_0))
(if (<= B 3.3e-19)
(* (sqrt (* 2.0 (* t_1 (* F (- A (hypot B A)))))) (/ -1.0 t_1))
(if (<= B 2900000000.0)
(/
(-
(sqrt
(*
F
(*
(- A (fma 0.5 (/ (+ (* B B) (- (* A A) (* A A))) C) (- A)))
(fma C (* A -8.0) (* 2.0 (* B B)))))))
(fma B B (* A (* C -4.0))))
(* (sqrt (* F (- A (hypot A B)))) (/ (- (sqrt 2.0)) B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = fma(B, B, (C * (A * -4.0)));
double tmp;
if (B <= 2.4e-101) {
tmp = -(sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0);
} else if (B <= 3.3e-19) {
tmp = sqrt((2.0 * (t_1 * (F * (A - hypot(B, A)))))) * (-1.0 / t_1);
} else if (B <= 2900000000.0) {
tmp = -sqrt((F * ((A - fma(0.5, (((B * B) + ((A * A) - (A * A))) / C), -A)) * fma(C, (A * -8.0), (2.0 * (B * B)))))) / fma(B, B, (A * (C * -4.0)));
} else {
tmp = sqrt((F * (A - hypot(A, B)))) * (-sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = fma(B, B, Float64(C * Float64(A * -4.0))) tmp = 0.0 if (B <= 2.4e-101) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(2.0 * A)))) / t_0)); elseif (B <= 3.3e-19) tmp = Float64(sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A - hypot(B, A)))))) * Float64(-1.0 / t_1)); elseif (B <= 2900000000.0) tmp = Float64(Float64(-sqrt(Float64(F * Float64(Float64(A - fma(0.5, Float64(Float64(Float64(B * B) + Float64(Float64(A * A) - Float64(A * A))) / C), Float64(-A))) * fma(C, Float64(A * -8.0), Float64(2.0 * Float64(B * B))))))) / fma(B, B, Float64(A * Float64(C * -4.0)))); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(A, B)))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 2.4e-101], (-N[(N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), If[LessEqual[B, 3.3e-19], N[(N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 2900000000.0], N[((-N[Sqrt[N[(F * N[(N[(A - N[(0.5 * N[(N[(N[(B * B), $MachinePrecision] + N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision] + (-A)), $MachinePrecision]), $MachinePrecision] * N[(C * N[(A * -8.0), $MachinePrecision] + N[(2.0 * N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := \mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\\
\mathbf{if}\;B \leq 2.4 \cdot 10^{-101}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 3.3 \cdot 10^{-19}:\\
\;\;\;\;\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)} \cdot \frac{-1}{t_1}\\
\mathbf{elif}\;B \leq 2900000000:\\
\;\;\;\;\frac{-\sqrt{F \cdot \left(\left(A - \mathsf{fma}\left(0.5, \frac{B \cdot B + \left(A \cdot A - A \cdot A\right)}{C}, -A\right)\right) \cdot \mathsf{fma}\left(C, A \cdot -8, 2 \cdot \left(B \cdot B\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 2.4e-101Initial program 21.3%
Simplified21.3%
Taylor expanded in A around -inf 16.8%
*-commutative16.8%
Simplified16.8%
if 2.4e-101 < B < 3.2999999999999998e-19Initial program 51.2%
Simplified51.2%
Taylor expanded in C around 0 60.8%
+-commutative60.8%
unpow260.8%
unpow260.8%
hypot-def60.8%
Simplified60.8%
div-inv61.0%
associate-*l*71.2%
cancel-sign-sub-inv71.2%
metadata-eval71.2%
associate-*r*71.2%
*-commutative71.2%
*-commutative71.2%
fma-udef71.2%
cancel-sign-sub-inv71.2%
Applied egg-rr71.2%
hypot-def71.2%
unpow271.2%
unpow271.2%
+-commutative71.2%
unpow271.2%
unpow271.2%
hypot-def71.2%
Simplified71.2%
if 3.2999999999999998e-19 < B < 2.9e9Initial program 1.7%
Simplified5.8%
Taylor expanded in C around inf 20.8%
fma-def20.8%
associate--l+20.8%
unpow220.8%
unpow220.8%
unpow220.8%
mul-1-neg20.8%
mul-1-neg20.8%
sqr-neg20.8%
mul-1-neg20.8%
Simplified20.8%
if 2.9e9 < B Initial program 14.1%
Simplified14.1%
Taylor expanded in C around 0 24.7%
mul-1-neg24.7%
*-commutative24.7%
+-commutative24.7%
unpow224.7%
unpow224.7%
hypot-def53.8%
Simplified53.8%
Final simplification28.7%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C))))
(t_1 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_2
(/
(-
(sqrt
(*
(* 2.0 (* t_1 F))
(- (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_1)))
(if (<= t_2 -1e-205)
(/
(*
(sqrt (* 2.0 (* F (+ A (- C (hypot (- A C) B))))))
(- (sqrt (fma B B (* C (* A -4.0))))))
(fma B B (* A (* C -4.0))))
(if (<= t_2 1e+271)
(/
(-
(sqrt
(*
2.0
(*
(* F t_0)
(+ A (fma -0.5 (/ (+ (* B B) (- (* A A) (* A A))) C) A))))))
t_0)
(* (sqrt (* F (- C (hypot C B)))) (/ (- (sqrt 2.0)) B))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = pow(B, 2.0) - ((4.0 * A) * C);
double t_2 = -sqrt(((2.0 * (t_1 * F)) * ((A + C) - sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_1;
double tmp;
if (t_2 <= -1e-205) {
tmp = (sqrt((2.0 * (F * (A + (C - hypot((A - C), B)))))) * -sqrt(fma(B, B, (C * (A * -4.0))))) / fma(B, B, (A * (C * -4.0)));
} else if (t_2 <= 1e+271) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + fma(-0.5, (((B * B) + ((A * A) - (A * A))) / C), A))))) / t_0;
} else {
tmp = sqrt((F * (C - hypot(C, B)))) * (-sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_2 = 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) tmp = 0.0 if (t_2 <= -1e-205) tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(F * Float64(A + Float64(C - hypot(Float64(A - C), B)))))) * Float64(-sqrt(fma(B, B, Float64(C * Float64(A * -4.0)))))) / fma(B, B, Float64(A * Float64(C * -4.0)))); elseif (t_2 <= 1e+271) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + fma(-0.5, Float64(Float64(Float64(B * B) + Float64(Float64(A * A) - Float64(A * A))) / C), A)))))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(C - hypot(C, B)))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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]}, If[LessEqual[t$95$2, -1e-205], N[(N[(N[Sqrt[N[(2.0 * N[(F * N[(A + N[(C - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+271], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + N[(-0.5 * N[(N[(N[(B * B), $MachinePrecision] + N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision] + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(C - N[Sqrt[C ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_2 := \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}\\
\mathbf{if}\;t_2 \leq -1 \cdot 10^{-205}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(A - C, B\right)\right)\right)\right)} \cdot \left(-\sqrt{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}\right)}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{elif}\;t_2 \leq 10^{+271}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + \mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - A \cdot A\right)}{C}, A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(C - \mathsf{hypot}\left(C, B\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\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))) < -1e-205Initial program 43.9%
Simplified50.0%
sqrt-prod62.6%
associate-*r*62.6%
*-commutative62.6%
associate-*l*62.6%
associate--r-63.0%
+-commutative63.0%
Applied egg-rr63.0%
hypot-def53.4%
unpow253.4%
unpow253.4%
+-commutative53.4%
unpow253.4%
unpow253.4%
hypot-def63.0%
Simplified63.0%
if -1e-205 < (/.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))) < 9.99999999999999953e270Initial program 28.2%
Simplified28.2%
Taylor expanded in C around inf 40.6%
associate--l+40.6%
fma-neg40.6%
associate--l+40.8%
unpow240.8%
unpow240.8%
unpow240.8%
mul-1-neg40.8%
mul-1-neg40.8%
sqr-neg40.8%
mul-1-neg40.8%
Simplified40.8%
if 9.99999999999999953e270 < (/.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.3%
Simplified0.3%
Taylor expanded in A around 0 1.6%
mul-1-neg1.6%
*-commutative1.6%
+-commutative1.6%
unpow21.6%
unpow21.6%
hypot-def17.2%
Simplified17.2%
Final simplification37.3%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C))))
(t_1 (* F t_0))
(t_2 (fma B B (* C (* A -4.0)))))
(if (<= B 2.4e-101)
(- (/ (sqrt (* 2.0 (* t_1 (* 2.0 A)))) t_0))
(if (<= B 3.25e-21)
(* (sqrt (* 2.0 (* t_2 (* F (- A (hypot B A)))))) (/ -1.0 t_2))
(if (<= B 1400000000.0)
(/
(-
(sqrt
(*
2.0
(*
t_1
(+ A (fma -0.5 (/ (+ (* B B) (- (* A A) (* A A))) C) A))))))
t_0)
(* (sqrt (* F (- A (hypot A B)))) (/ (- (sqrt 2.0)) B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = F * t_0;
double t_2 = fma(B, B, (C * (A * -4.0)));
double tmp;
if (B <= 2.4e-101) {
tmp = -(sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0);
} else if (B <= 3.25e-21) {
tmp = sqrt((2.0 * (t_2 * (F * (A - hypot(B, A)))))) * (-1.0 / t_2);
} else if (B <= 1400000000.0) {
tmp = -sqrt((2.0 * (t_1 * (A + fma(-0.5, (((B * B) + ((A * A) - (A * A))) / C), A))))) / t_0;
} else {
tmp = sqrt((F * (A - hypot(A, B)))) * (-sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64(F * t_0) t_2 = fma(B, B, Float64(C * Float64(A * -4.0))) tmp = 0.0 if (B <= 2.4e-101) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(t_1 * Float64(2.0 * A)))) / t_0)); elseif (B <= 3.25e-21) tmp = Float64(sqrt(Float64(2.0 * Float64(t_2 * Float64(F * Float64(A - hypot(B, A)))))) * Float64(-1.0 / t_2)); elseif (B <= 1400000000.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A + fma(-0.5, Float64(Float64(Float64(B * B) + Float64(Float64(A * A) - Float64(A * A))) / C), A)))))) / t_0); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(A, B)))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(F * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 2.4e-101], (-N[(N[Sqrt[N[(2.0 * N[(t$95$1 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), If[LessEqual[B, 3.25e-21], N[(N[Sqrt[N[(2.0 * N[(t$95$2 * N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 1400000000.0], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A + N[(-0.5 * N[(N[(N[(B * B), $MachinePrecision] + N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision] + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := F \cdot t_0\\
t_2 := \mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\\
\mathbf{if}\;B \leq 2.4 \cdot 10^{-101}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(t_1 \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 3.25 \cdot 10^{-21}:\\
\;\;\;\;\sqrt{2 \cdot \left(t_2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)} \cdot \frac{-1}{t_2}\\
\mathbf{elif}\;B \leq 1400000000:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A + \mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - A \cdot A\right)}{C}, A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 2.4e-101Initial program 21.3%
Simplified21.3%
Taylor expanded in A around -inf 16.8%
*-commutative16.8%
Simplified16.8%
if 2.4e-101 < B < 3.24999999999999993e-21Initial program 51.2%
Simplified51.2%
Taylor expanded in C around 0 60.8%
+-commutative60.8%
unpow260.8%
unpow260.8%
hypot-def60.8%
Simplified60.8%
div-inv61.0%
associate-*l*71.2%
cancel-sign-sub-inv71.2%
metadata-eval71.2%
associate-*r*71.2%
*-commutative71.2%
*-commutative71.2%
fma-udef71.2%
cancel-sign-sub-inv71.2%
Applied egg-rr71.2%
hypot-def71.2%
unpow271.2%
unpow271.2%
+-commutative71.2%
unpow271.2%
unpow271.2%
hypot-def71.2%
Simplified71.2%
if 3.24999999999999993e-21 < B < 1.4e9Initial program 1.7%
Simplified1.7%
Taylor expanded in C around inf 20.6%
associate--l+20.6%
fma-neg20.6%
associate--l+20.6%
unpow220.6%
unpow220.6%
unpow220.6%
mul-1-neg20.6%
mul-1-neg20.6%
sqr-neg20.6%
mul-1-neg20.6%
Simplified20.6%
if 1.4e9 < B Initial program 14.1%
Simplified14.1%
Taylor expanded in C around 0 24.7%
mul-1-neg24.7%
*-commutative24.7%
+-commutative24.7%
unpow224.7%
unpow224.7%
hypot-def53.8%
Simplified53.8%
Final simplification28.7%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 3.4e-29)
(- (/ (sqrt (* 2.0 (* (* F t_0) (* 2.0 A)))) t_0))
(* (sqrt (* F (- A (hypot A B)))) (/ (- (sqrt 2.0)) B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 3.4e-29) {
tmp = -(sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0);
} else {
tmp = sqrt((F * (A - hypot(A, B)))) * (-sqrt(2.0) / B);
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 3.4e-29) {
tmp = -(Math.sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0);
} else {
tmp = Math.sqrt((F * (A - Math.hypot(A, B)))) * (-Math.sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) tmp = 0 if B <= 3.4e-29: tmp = -(math.sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0) else: tmp = math.sqrt((F * (A - math.hypot(A, B)))) * (-math.sqrt(2.0) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= 3.4e-29) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(2.0 * A)))) / t_0)); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(A, B)))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
tmp = 0.0;
if (B <= 3.4e-29)
tmp = -(sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0);
else
tmp = sqrt((F * (A - hypot(A, B)))) * (-sqrt(2.0) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 3.4e-29], (-N[(N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), N[(N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 3.4 \cdot 10^{-29}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 3.39999999999999972e-29Initial program 22.2%
Simplified22.2%
Taylor expanded in A around -inf 16.8%
*-commutative16.8%
Simplified16.8%
if 3.39999999999999972e-29 < B Initial program 15.4%
Simplified15.4%
Taylor expanded in C around 0 27.4%
mul-1-neg27.4%
*-commutative27.4%
+-commutative27.4%
unpow227.4%
unpow227.4%
hypot-def53.4%
Simplified53.4%
Final simplification27.5%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))) (t_1 (+ (* B B) (* -4.0 (* A C)))))
(if (<= C 5e-25)
(/ (- (sqrt (* 2.0 (* t_1 (* F (+ A (- C (hypot B (- A C))))))))) t_1)
(/
(-
(sqrt
(*
2.0
(*
(* F t_0)
(+ A (fma -0.5 (/ (+ (* B B) (- (* A A) (* A A))) C) A))))))
t_0))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (C <= 5e-25) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + (C - hypot(B, (A - C)))))))) / t_1;
} else {
tmp = -sqrt((2.0 * ((F * t_0) * (A + fma(-0.5, (((B * B) + ((A * A) - (A * A))) / C), A))))) / t_0;
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (C <= 5e-25) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C))))))))) / t_1); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + fma(-0.5, Float64(Float64(Float64(B * B) + Float64(Float64(A * A) - Float64(A * A))) / C), A)))))) / t_0); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[C, 5e-25], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + N[(-0.5 * N[(N[(N[(B * B), $MachinePrecision] + N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision] + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;C \leq 5 \cdot 10^{-25}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + \mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - A \cdot A\right)}{C}, A\right)\right)\right)}}{t_0}\\
\end{array}
\end{array}
if C < 4.99999999999999962e-25Initial program 27.6%
Simplified27.6%
distribute-frac-neg27.6%
Applied egg-rr32.8%
if 4.99999999999999962e-25 < C Initial program 3.4%
Simplified3.4%
Taylor expanded in C around inf 25.2%
associate--l+25.2%
fma-neg25.2%
associate--l+25.2%
unpow225.2%
unpow225.2%
unpow225.2%
mul-1-neg25.2%
mul-1-neg25.2%
sqr-neg25.2%
mul-1-neg25.2%
Simplified25.2%
Final simplification30.5%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))) (t_1 (* F t_0)))
(if (<= C 3.7e+56)
(/ (- (sqrt (* 2.0 (* t_1 (- A (hypot A B)))))) t_0)
(- (/ (sqrt (* 2.0 (* t_1 (* 2.0 A)))) t_0)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = F * t_0;
double tmp;
if (C <= 3.7e+56) {
tmp = -sqrt((2.0 * (t_1 * (A - hypot(A, B))))) / t_0;
} else {
tmp = -(sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0);
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = F * t_0;
double tmp;
if (C <= 3.7e+56) {
tmp = -Math.sqrt((2.0 * (t_1 * (A - Math.hypot(A, B))))) / t_0;
} else {
tmp = -(Math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = F * t_0 tmp = 0 if C <= 3.7e+56: tmp = -math.sqrt((2.0 * (t_1 * (A - math.hypot(A, B))))) / t_0 else: tmp = -(math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64(F * t_0) tmp = 0.0 if (C <= 3.7e+56) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A - hypot(A, B)))))) / t_0); else tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(t_1 * Float64(2.0 * A)))) / t_0)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
t_1 = F * t_0;
tmp = 0.0;
if (C <= 3.7e+56)
tmp = -sqrt((2.0 * (t_1 * (A - hypot(A, B))))) / t_0;
else
tmp = -(sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(F * t$95$0), $MachinePrecision]}, If[LessEqual[C, 3.7e+56], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], (-N[(N[Sqrt[N[(2.0 * N[(t$95$1 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision])]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := F \cdot t_0\\
\mathbf{if}\;C \leq 3.7 \cdot 10^{+56}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(t_1 \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\end{array}
\end{array}
if C < 3.69999999999999997e56Initial program 26.3%
Simplified26.3%
Taylor expanded in C around 0 22.4%
+-commutative22.4%
unpow222.4%
unpow222.4%
hypot-def24.7%
Simplified24.7%
if 3.69999999999999997e56 < C Initial program 2.2%
Simplified2.2%
Taylor expanded in A around -inf 19.3%
*-commutative19.3%
Simplified19.3%
Final simplification23.3%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 1.95e-28)
(- (/ (sqrt (* 2.0 (* (* F t_0) (* 2.0 A)))) t_0))
(/ (- (sqrt (* 2.0 (* (- A (hypot B A)) (* F (* B B)))))) t_0))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 1.95e-28) {
tmp = -(sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0);
} else {
tmp = -sqrt((2.0 * ((A - hypot(B, A)) * (F * (B * B))))) / t_0;
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 1.95e-28) {
tmp = -(Math.sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0);
} else {
tmp = -Math.sqrt((2.0 * ((A - Math.hypot(B, A)) * (F * (B * B))))) / t_0;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) tmp = 0 if B <= 1.95e-28: tmp = -(math.sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0) else: tmp = -math.sqrt((2.0 * ((A - math.hypot(B, A)) * (F * (B * B))))) / t_0 return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= 1.95e-28) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(2.0 * A)))) / t_0)); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(A - hypot(B, A)) * Float64(F * Float64(B * B)))))) / t_0); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
tmp = 0.0;
if (B <= 1.95e-28)
tmp = -(sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0);
else
tmp = -sqrt((2.0 * ((A - hypot(B, A)) * (F * (B * B))))) / t_0;
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 1.95e-28], (-N[(N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), N[((-N[Sqrt[N[(2.0 * N[(N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision] * N[(F * N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 1.95 \cdot 10^{-28}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(A - \mathsf{hypot}\left(B, A\right)\right) \cdot \left(F \cdot \left(B \cdot B\right)\right)\right)}}{t_0}\\
\end{array}
\end{array}
if B < 1.94999999999999999e-28Initial program 22.2%
Simplified22.2%
Taylor expanded in A around -inf 16.8%
*-commutative16.8%
Simplified16.8%
if 1.94999999999999999e-28 < B Initial program 15.4%
Simplified15.4%
Taylor expanded in C around 0 15.7%
+-commutative15.7%
unpow215.7%
unpow215.7%
hypot-def17.1%
Simplified17.1%
Taylor expanded in C around 0 15.8%
unpow215.8%
unpow215.8%
hypot-def17.4%
unpow217.4%
Simplified17.4%
Final simplification17.0%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))) (t_1 (* F t_0)))
(if (<= B 2100000000.0)
(- (/ (sqrt (* 2.0 (* t_1 (* 2.0 A)))) t_0))
(/ (- (sqrt (* 2.0 (* t_1 (- (+ A C) B))))) t_0))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = F * t_0;
double tmp;
if (B <= 2100000000.0) {
tmp = -(sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0);
} else {
tmp = -sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0;
}
return tmp;
}
NOTE: B should be positive before calling this function
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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (a * c))
t_1 = f * t_0
if (b <= 2100000000.0d0) then
tmp = -(sqrt((2.0d0 * (t_1 * (2.0d0 * a)))) / t_0)
else
tmp = -sqrt((2.0d0 * (t_1 * ((a + c) - b)))) / t_0
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = F * t_0;
double tmp;
if (B <= 2100000000.0) {
tmp = -(Math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0);
} else {
tmp = -Math.sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = F * t_0 tmp = 0 if B <= 2100000000.0: tmp = -(math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0) else: tmp = -math.sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0 return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64(F * t_0) tmp = 0.0 if (B <= 2100000000.0) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(t_1 * Float64(2.0 * A)))) / t_0)); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(Float64(A + C) - B))))) / t_0); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
t_1 = F * t_0;
tmp = 0.0;
if (B <= 2100000000.0)
tmp = -(sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0);
else
tmp = -sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0;
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(F * t$95$0), $MachinePrecision]}, If[LessEqual[B, 2100000000.0], (-N[(N[Sqrt[N[(2.0 * N[(t$95$1 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(N[(A + C), $MachinePrecision] - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := F \cdot t_0\\
\mathbf{if}\;B \leq 2100000000:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(t_1 \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(\left(A + C\right) - B\right)\right)}}{t_0}\\
\end{array}
\end{array}
if B < 2.1e9Initial program 22.4%
Simplified22.4%
Taylor expanded in A around -inf 16.7%
*-commutative16.7%
Simplified16.7%
if 2.1e9 < B Initial program 14.1%
Simplified14.1%
Taylor expanded in B around inf 13.2%
Final simplification15.8%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (let* ((t_0 (- (* B B) (* 4.0 (* A C))))) (- (/ (sqrt (* 2.0 (* (* F t_0) (* 2.0 A)))) t_0))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
return -(sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0);
}
NOTE: B should be positive before calling this function
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
real(8) :: t_0
t_0 = (b * b) - (4.0d0 * (a * c))
code = -(sqrt((2.0d0 * ((f * t_0) * (2.0d0 * a)))) / t_0)
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
return -(Math.sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0);
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) return -(math.sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0)
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) return Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(2.0 * A)))) / t_0)) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
tmp = -(sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0);
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, (-N[(N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision])]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
-\frac{\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}
\end{array}
\end{array}
Initial program 20.2%
Simplified20.2%
Taylor expanded in A around -inf 12.9%
*-commutative12.9%
Simplified12.9%
Final simplification12.9%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (/ (- (sqrt (* 2.0 (* -8.0 (* A (* F (* C C))))))) (- (* B B) (* 4.0 (* A C)))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -sqrt((2.0 * (-8.0 * (A * (F * (C * C)))))) / ((B * B) - (4.0 * (A * C)));
}
NOTE: B should be positive before calling this function
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 = -sqrt((2.0d0 * ((-8.0d0) * (a * (f * (c * c)))))) / ((b * b) - (4.0d0 * (a * c)))
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return -Math.sqrt((2.0 * (-8.0 * (A * (F * (C * C)))))) / ((B * B) - (4.0 * (A * C)));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -math.sqrt((2.0 * (-8.0 * (A * (F * (C * C)))))) / ((B * B) - (4.0 * (A * C)))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(-sqrt(Float64(2.0 * Float64(-8.0 * Float64(A * Float64(F * Float64(C * C))))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt((2.0 * (-8.0 * (A * (F * (C * C)))))) / ((B * B) - (4.0 * (A * C)));
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[((-N[Sqrt[N[(2.0 * N[(-8.0 * N[(A * N[(F * N[(C * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{-\sqrt{2 \cdot \left(-8 \cdot \left(A \cdot \left(F \cdot \left(C \cdot C\right)\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\end{array}
Initial program 20.2%
Simplified20.2%
Taylor expanded in C around -inf 10.1%
*-commutative10.1%
Simplified10.1%
Taylor expanded in B around 0 7.2%
unpow27.2%
Simplified7.2%
Final simplification7.2%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (/ (- (sqrt (* 2.0 (* -8.0 (* (* A A) (* C F)))))) (- (* B B) (* 4.0 (* A C)))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -sqrt((2.0 * (-8.0 * ((A * A) * (C * F))))) / ((B * B) - (4.0 * (A * C)));
}
NOTE: B should be positive before calling this function
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 = -sqrt((2.0d0 * ((-8.0d0) * ((a * a) * (c * f))))) / ((b * b) - (4.0d0 * (a * c)))
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return -Math.sqrt((2.0 * (-8.0 * ((A * A) * (C * F))))) / ((B * B) - (4.0 * (A * C)));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -math.sqrt((2.0 * (-8.0 * ((A * A) * (C * F))))) / ((B * B) - (4.0 * (A * C)))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(-sqrt(Float64(2.0 * Float64(-8.0 * Float64(Float64(A * A) * Float64(C * F)))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt((2.0 * (-8.0 * ((A * A) * (C * F))))) / ((B * B) - (4.0 * (A * C)));
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[((-N[Sqrt[N[(2.0 * N[(-8.0 * N[(N[(A * A), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{-\sqrt{2 \cdot \left(-8 \cdot \left(\left(A \cdot A\right) \cdot \left(C \cdot F\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\end{array}
Initial program 20.2%
Simplified20.2%
Taylor expanded in C around 0 17.7%
+-commutative17.7%
unpow217.7%
unpow217.7%
hypot-def19.6%
Simplified19.6%
Taylor expanded in A around -inf 8.7%
unpow28.7%
Simplified8.7%
Final simplification8.7%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* -2.0 (* (pow (* C F) 0.5) (/ 1.0 B))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (pow((C * F), 0.5) * (1.0 / B));
}
NOTE: B should be positive before calling this function
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) * (((c * f) ** 0.5d0) * (1.0d0 / b))
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return -2.0 * (Math.pow((C * F), 0.5) * (1.0 / B));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.pow((C * F), 0.5) * (1.0 / B))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64((Float64(C * F) ^ 0.5) * Float64(1.0 / B))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (((C * F) ^ 0.5) * (1.0 / B));
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(-2.0 * N[(N[Power[N[(C * F), $MachinePrecision], 0.5], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \left({\left(C \cdot F\right)}^{0.5} \cdot \frac{1}{B}\right)
\end{array}
Initial program 20.2%
Simplified20.2%
Taylor expanded in C around -inf 10.1%
*-commutative10.1%
Simplified10.1%
Taylor expanded in B around inf 2.9%
pow1/23.1%
*-commutative3.1%
Applied egg-rr3.1%
Final simplification3.1%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* -2.0 (/ (sqrt (* C F)) B)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (sqrt((C * F)) / B);
}
NOTE: B should be positive before calling this function
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((c * f)) / b)
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return -2.0 * (Math.sqrt((C * F)) / B);
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.sqrt((C * F)) / B)
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64(sqrt(Float64(C * F)) / B)) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (sqrt((C * F)) / B);
end
NOTE: B should be positive before calling this function 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[(C * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \frac{\sqrt{C \cdot F}}{B}
\end{array}
Initial program 20.2%
Simplified20.2%
Taylor expanded in C around -inf 10.1%
*-commutative10.1%
Simplified10.1%
Taylor expanded in B around inf 2.9%
un-div-inv3.0%
*-commutative3.0%
Applied egg-rr3.0%
Final simplification3.0%
herbie shell --seed 2023252
(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))))