
(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 17 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 (- (* B B) (* 4.0 (* A C)))))
(if (<= (pow B 2.0) 200000000000.0)
(/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 A))))) t_0)
(if (<= (pow B 2.0) 1e+308)
(/
(*
(sqrt (fma B B (* C (* A -4.0))))
(- (sqrt (* 2.0 (* F (+ A (- C (hypot (- A C) B))))))))
(fma B B (* A (* C -4.0))))
(* (sqrt (* F (- A (hypot A B)))) (- (/ (sqrt 2.0) 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 (pow(B, 2.0) <= 200000000000.0) {
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else if (pow(B, 2.0) <= 1e+308) {
tmp = (sqrt(fma(B, B, (C * (A * -4.0)))) * -sqrt((2.0 * (F * (A + (C - hypot((A - C), B))))))) / fma(B, B, (A * (C * -4.0)));
} else {
tmp = sqrt((F * (A - hypot(A, B)))) * -(sqrt(2.0) / B);
}
return tmp;
}
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 ^ 2.0) <= 200000000000.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / t_0); elseif ((B ^ 2.0) <= 1e+308) tmp = Float64(Float64(sqrt(fma(B, B, Float64(C * Float64(A * -4.0)))) * Float64(-sqrt(Float64(2.0 * Float64(F * Float64(A + Float64(C - hypot(Float64(A - C), 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: 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[N[Power[B, 2.0], $MachinePrecision], 200000000000.0], N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 1e+308], N[(N[(N[Sqrt[N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-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])), $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}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;{B}^{2} \leq 200000000000:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{elif}\;{B}^{2} \leq 10^{+308}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)} \cdot \left(-\sqrt{2 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(A - C, B\right)\right)\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 \left(-\frac{\sqrt{2}}{B}\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 2e11Initial program 26.5%
Simplified26.4%
Taylor expanded in A around -inf 30.3%
*-commutative30.3%
Simplified30.3%
if 2e11 < (pow.f64 B 2) < 1e308Initial program 27.2%
Simplified32.1%
sqrt-prod45.0%
associate-*r*45.0%
*-commutative45.0%
associate-*l*45.0%
associate--r-45.0%
+-commutative45.0%
Applied egg-rr45.0%
hypot-def38.9%
unpow238.9%
unpow238.9%
+-commutative38.9%
unpow238.9%
unpow238.9%
hypot-def45.0%
Simplified45.0%
if 1e308 < (pow.f64 B 2) Initial program 1.6%
Simplified1.6%
Taylor expanded in C around 0 3.2%
mul-1-neg3.2%
*-commutative3.2%
+-commutative3.2%
unpow23.2%
unpow23.2%
hypot-def34.7%
Simplified34.7%
Final simplification35.1%
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 (* C (* A -4.0)))) (t_1 (- (* B B) (* 4.0 (* A C)))))
(if (<= B -7.4e+101)
(/ (sqrt (fma -4.0 (* C F) (* F (* 4.0 A)))) B)
(if (<= B -5.2e-19)
(/ (- (sqrt (* (* 2.0 (* F t_0)) (+ A (- C (hypot B (- A C))))))) t_0)
(if (<= B 400000.0)
(/ (- (sqrt (* 2.0 (* (* t_1 F) (* 2.0 A))))) t_1)
(* (sqrt (* F (- A (hypot A B)))) (- (/ (sqrt 2.0) B))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (C * (A * -4.0)));
double t_1 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= -7.4e+101) {
tmp = sqrt(fma(-4.0, (C * F), (F * (4.0 * A)))) / B;
} else if (B <= -5.2e-19) {
tmp = -sqrt(((2.0 * (F * t_0)) * (A + (C - hypot(B, (A - C)))))) / t_0;
} else if (B <= 400000.0) {
tmp = -sqrt((2.0 * ((t_1 * F) * (2.0 * A)))) / t_1;
} else {
tmp = sqrt((F * (A - hypot(A, B)))) * -(sqrt(2.0) / B);
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(C * Float64(A * -4.0))) t_1 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= -7.4e+101) tmp = Float64(sqrt(fma(-4.0, Float64(C * F), Float64(F * Float64(4.0 * A)))) / B); elseif (B <= -5.2e-19) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * Float64(A + Float64(C - hypot(B, Float64(A - C))))))) / t_0); elseif (B <= 400000.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_1 * F) * Float64(2.0 * A))))) / t_1); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(A, B)))) * Float64(-Float64(sqrt(2.0) / 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[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -7.4e+101], N[(N[Sqrt[N[(-4.0 * N[(C * F), $MachinePrecision] + N[(F * N[(4.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision], If[LessEqual[B, -5.2e-19], N[((-N[Sqrt[N[(N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 400000.0], N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$1 * F), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $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}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\\
t_1 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq -7.4 \cdot 10^{+101}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-4, C \cdot F, F \cdot \left(4 \cdot A\right)\right)}}{B}\\
\mathbf{elif}\;B \leq -5.2 \cdot 10^{-19}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(F \cdot t_0\right)\right) \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 400000:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_1 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B}\right)\\
\end{array}
\end{array}
if B < -7.3999999999999995e101Initial program 1.1%
Simplified1.1%
Taylor expanded in A around -inf 0.4%
fma-def0.4%
unpow20.4%
fma-def0.4%
*-commutative0.4%
unpow20.4%
*-commutative0.4%
unpow20.4%
Simplified0.4%
Taylor expanded in B around -inf 6.6%
associate-*r/6.6%
*-rgt-identity6.6%
fma-def6.6%
*-commutative6.6%
associate-*r*6.6%
Simplified6.6%
if -7.3999999999999995e101 < B < -5.20000000000000026e-19Initial program 41.8%
Simplified47.8%
if -5.20000000000000026e-19 < B < 4e5Initial program 26.1%
Simplified26.0%
Taylor expanded in A around -inf 30.7%
*-commutative30.7%
Simplified30.7%
if 4e5 < B Initial program 18.3%
Simplified18.3%
Taylor expanded in C around 0 23.6%
mul-1-neg23.6%
*-commutative23.6%
+-commutative23.6%
unpow223.6%
unpow223.6%
hypot-def54.8%
Simplified54.8%
Final simplification33.2%
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) (* (* A C) -4.0))) (t_1 (- (* B B) (* 4.0 (* A C)))))
(if (<= B -7.2e+101)
(/ (sqrt (fma -4.0 (* C F) (* F (* 4.0 A)))) B)
(if (<= B -5.2e-18)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A (- C (hypot B (- A C))))))))) t_0)
(if (<= B 1900000.0)
(/ (- (sqrt (* 2.0 (* (* t_1 F) (* 2.0 A))))) t_1)
(* (sqrt (* F (- A (hypot A B)))) (- (/ (sqrt 2.0) B))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + ((A * C) * -4.0);
double t_1 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= -7.2e+101) {
tmp = sqrt(fma(-4.0, (C * F), (F * (4.0 * A)))) / B;
} else if (B <= -5.2e-18) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + (C - hypot(B, (A - C)))))))) / t_0;
} else if (B <= 1900000.0) {
tmp = -sqrt((2.0 * ((t_1 * F) * (2.0 * A)))) / t_1;
} else {
tmp = sqrt((F * (A - hypot(A, B)))) * -(sqrt(2.0) / B);
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(Float64(A * C) * -4.0)) t_1 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= -7.2e+101) tmp = Float64(sqrt(fma(-4.0, Float64(C * F), Float64(F * Float64(4.0 * A)))) / B); elseif (B <= -5.2e-18) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C))))))))) / t_0); elseif (B <= 1900000.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_1 * F) * Float64(2.0 * A))))) / t_1); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(A, B)))) * Float64(-Float64(sqrt(2.0) / 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[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -7.2e+101], N[(N[Sqrt[N[(-4.0 * N[(C * F), $MachinePrecision] + N[(F * N[(4.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision], If[LessEqual[B, -5.2e-18], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 1900000.0], N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$1 * F), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $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}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + \left(A \cdot C\right) \cdot -4\\
t_1 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq -7.2 \cdot 10^{+101}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-4, C \cdot F, F \cdot \left(4 \cdot A\right)\right)}}{B}\\
\mathbf{elif}\;B \leq -5.2 \cdot 10^{-18}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 1900000:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_1 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B}\right)\\
\end{array}
\end{array}
if B < -7.20000000000000058e101Initial program 1.1%
Simplified1.1%
Taylor expanded in A around -inf 0.4%
fma-def0.4%
unpow20.4%
fma-def0.4%
*-commutative0.4%
unpow20.4%
*-commutative0.4%
unpow20.4%
Simplified0.4%
Taylor expanded in B around -inf 6.6%
associate-*r/6.6%
*-rgt-identity6.6%
fma-def6.6%
*-commutative6.6%
associate-*r*6.6%
Simplified6.6%
if -7.20000000000000058e101 < B < -5.2000000000000001e-18Initial program 41.8%
Simplified41.8%
distribute-frac-neg41.8%
Applied egg-rr47.7%
if -5.2000000000000001e-18 < B < 1.9e6Initial program 26.1%
Simplified26.0%
Taylor expanded in A around -inf 30.7%
*-commutative30.7%
Simplified30.7%
if 1.9e6 < B Initial program 18.3%
Simplified18.3%
Taylor expanded in C around 0 23.6%
mul-1-neg23.6%
*-commutative23.6%
+-commutative23.6%
unpow223.6%
unpow223.6%
hypot-def54.8%
Simplified54.8%
Final simplification33.2%
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) (* (* A C) -4.0))) (t_1 (- (* B B) (* 4.0 (* A C)))))
(if (<= B -7.4e+101)
(/ (sqrt (fma -4.0 (* C F) (* F (* 4.0 A)))) B)
(if (<= B -7.6e-19)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A (- C (hypot B (- A C))))))))) t_0)
(if (<= B 4200000.0)
(/ (- (sqrt (* 2.0 (* (* t_1 F) (* 2.0 A))))) t_1)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A B))))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + ((A * C) * -4.0);
double t_1 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= -7.4e+101) {
tmp = sqrt(fma(-4.0, (C * F), (F * (4.0 * A)))) / B;
} else if (B <= -7.6e-19) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + (C - hypot(B, (A - C)))))))) / t_0;
} else if (B <= 4200000.0) {
tmp = -sqrt((2.0 * ((t_1 * F) * (2.0 * A)))) / t_1;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(Float64(A * C) * -4.0)) t_1 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= -7.4e+101) tmp = Float64(sqrt(fma(-4.0, Float64(C * F), Float64(F * Float64(4.0 * A)))) / B); elseif (B <= -7.6e-19) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C))))))))) / t_0); elseif (B <= 4200000.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_1 * F) * Float64(2.0 * A))))) / t_1); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - 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[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -7.4e+101], N[(N[Sqrt[N[(-4.0 * N[(C * F), $MachinePrecision] + N[(F * N[(4.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision], If[LessEqual[B, -7.6e-19], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 4200000.0], N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$1 * F), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + \left(A \cdot C\right) \cdot -4\\
t_1 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq -7.4 \cdot 10^{+101}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-4, C \cdot F, F \cdot \left(4 \cdot A\right)\right)}}{B}\\
\mathbf{elif}\;B \leq -7.6 \cdot 10^{-19}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 4200000:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_1 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < -7.3999999999999995e101Initial program 1.1%
Simplified1.1%
Taylor expanded in A around -inf 0.4%
fma-def0.4%
unpow20.4%
fma-def0.4%
*-commutative0.4%
unpow20.4%
*-commutative0.4%
unpow20.4%
Simplified0.4%
Taylor expanded in B around -inf 6.6%
associate-*r/6.6%
*-rgt-identity6.6%
fma-def6.6%
*-commutative6.6%
associate-*r*6.6%
Simplified6.6%
if -7.3999999999999995e101 < B < -7.6e-19Initial program 41.8%
Simplified41.8%
distribute-frac-neg41.8%
Applied egg-rr47.7%
if -7.6e-19 < B < 4.2e6Initial program 26.1%
Simplified26.0%
Taylor expanded in A around -inf 30.7%
*-commutative30.7%
Simplified30.7%
if 4.2e6 < B Initial program 18.3%
Simplified18.3%
Taylor expanded in B around inf 17.5%
Taylor expanded in A around 0 17.1%
unpow217.1%
associate-*r*17.1%
Simplified17.1%
Taylor expanded in C around 0 52.8%
mul-1-neg52.8%
*-commutative52.8%
Simplified52.8%
Final simplification32.8%
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 (* t_0 F)))
(if (<= B -7.5e+110)
(/ (sqrt (fma -4.0 (* C F) (* F (* 4.0 A)))) B)
(if (<= B -2.6e-18)
(/ (- (sqrt (* 2.0 (* t_1 (- A (hypot A B)))))) t_0)
(if (<= B 2300000.0)
(/ (- (sqrt (* 2.0 (* t_1 (* 2.0 A))))) t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A 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 = t_0 * F;
double tmp;
if (B <= -7.5e+110) {
tmp = sqrt(fma(-4.0, (C * F), (F * (4.0 * A)))) / B;
} else if (B <= -2.6e-18) {
tmp = -sqrt((2.0 * (t_1 * (A - hypot(A, B))))) / t_0;
} else if (B <= 2300000.0) {
tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
}
return tmp;
}
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(t_0 * F) tmp = 0.0 if (B <= -7.5e+110) tmp = Float64(sqrt(fma(-4.0, Float64(C * F), Float64(F * Float64(4.0 * A)))) / B); elseif (B <= -2.6e-18) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A - hypot(A, B)))))) / t_0); elseif (B <= 2300000.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(2.0 * A))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - 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[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * F), $MachinePrecision]}, If[LessEqual[B, -7.5e+110], N[(N[Sqrt[N[(-4.0 * N[(C * F), $MachinePrecision] + N[(F * N[(4.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision], If[LessEqual[B, -2.6e-18], 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], If[LessEqual[B, 2300000.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[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := t_0 \cdot F\\
\mathbf{if}\;B \leq -7.5 \cdot 10^{+110}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-4, C \cdot F, F \cdot \left(4 \cdot A\right)\right)}}{B}\\
\mathbf{elif}\;B \leq -2.6 \cdot 10^{-18}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 2300000:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < -7.5e110Initial program 0.9%
Simplified1.0%
Taylor expanded in A around -inf 0.4%
fma-def0.4%
unpow20.4%
fma-def0.4%
*-commutative0.4%
unpow20.4%
*-commutative0.4%
unpow20.4%
Simplified0.4%
Taylor expanded in B around -inf 6.9%
associate-*r/6.9%
*-rgt-identity6.9%
fma-def6.9%
*-commutative6.9%
associate-*r*6.9%
Simplified6.9%
if -7.5e110 < B < -2.6e-18Initial program 38.4%
Simplified38.4%
Taylor expanded in C around 0 35.0%
+-commutative35.0%
unpow235.0%
unpow235.0%
hypot-def39.4%
Simplified39.4%
if -2.6e-18 < B < 2.3e6Initial program 26.1%
Simplified26.0%
Taylor expanded in A around -inf 30.7%
*-commutative30.7%
Simplified30.7%
if 2.3e6 < B Initial program 18.3%
Simplified18.3%
Taylor expanded in B around inf 17.5%
Taylor expanded in A around 0 17.1%
unpow217.1%
associate-*r*17.1%
Simplified17.1%
Taylor expanded in C around 0 52.8%
mul-1-neg52.8%
*-commutative52.8%
Simplified52.8%
Final simplification32.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 (- (* B B) (* 4.0 (* A C)))) (t_1 (* t_0 F)))
(if (<= B -3.05e+100)
(/ (sqrt (fma -4.0 (* C F) (* F (* 4.0 A)))) B)
(if (<= B -2.9e-18)
(/ (- (sqrt (* 2.0 (* t_1 (+ A (+ B C)))))) t_0)
(if (<= B -1.35e-114)
(/
(- (sqrt (* 2.0 (* F (* (fma B B (* C (* A -4.0))) (* 2.0 A))))))
t_0)
(if (<= B 1400000.0)
(/ (- (sqrt (* 2.0 (* t_1 (* 2.0 A))))) t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A 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 = t_0 * F;
double tmp;
if (B <= -3.05e+100) {
tmp = sqrt(fma(-4.0, (C * F), (F * (4.0 * A)))) / B;
} else if (B <= -2.9e-18) {
tmp = -sqrt((2.0 * (t_1 * (A + (B + C))))) / t_0;
} else if (B <= -1.35e-114) {
tmp = -sqrt((2.0 * (F * (fma(B, B, (C * (A * -4.0))) * (2.0 * A))))) / t_0;
} else if (B <= 1400000.0) {
tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
}
return tmp;
}
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(t_0 * F) tmp = 0.0 if (B <= -3.05e+100) tmp = Float64(sqrt(fma(-4.0, Float64(C * F), Float64(F * Float64(4.0 * A)))) / B); elseif (B <= -2.9e-18) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A + Float64(B + C)))))) / t_0); elseif (B <= -1.35e-114) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(F * Float64(fma(B, B, Float64(C * Float64(A * -4.0))) * Float64(2.0 * A)))))) / t_0); elseif (B <= 1400000.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(2.0 * A))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - 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[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * F), $MachinePrecision]}, If[LessEqual[B, -3.05e+100], N[(N[Sqrt[N[(-4.0 * N[(C * F), $MachinePrecision] + N[(F * N[(4.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision], If[LessEqual[B, -2.9e-18], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A + N[(B + C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, -1.35e-114], N[((-N[Sqrt[N[(2.0 * N[(F * N[(N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 1400000.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[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := t_0 \cdot F\\
\mathbf{if}\;B \leq -3.05 \cdot 10^{+100}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-4, C \cdot F, F \cdot \left(4 \cdot A\right)\right)}}{B}\\
\mathbf{elif}\;B \leq -2.9 \cdot 10^{-18}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A + \left(B + C\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq -1.35 \cdot 10^{-114}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 1400000:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < -3.05e100Initial program 1.1%
Simplified1.1%
Taylor expanded in A around -inf 0.4%
fma-def0.4%
unpow20.4%
fma-def0.4%
*-commutative0.4%
unpow20.4%
*-commutative0.4%
unpow20.4%
Simplified0.4%
Taylor expanded in B around -inf 6.6%
associate-*r/6.6%
*-rgt-identity6.6%
fma-def6.6%
*-commutative6.6%
associate-*r*6.6%
Simplified6.6%
if -3.05e100 < B < -2.9e-18Initial program 41.8%
Simplified41.8%
Taylor expanded in B around -inf 38.2%
if -2.9e-18 < B < -1.35e-114Initial program 18.3%
Simplified18.3%
Taylor expanded in A around -inf 29.5%
*-commutative29.5%
Simplified29.5%
sqrt-prod29.5%
associate-*l*24.2%
cancel-sign-sub-inv24.2%
metadata-eval24.2%
*-commutative24.2%
Applied egg-rr24.2%
pow124.2%
sqrt-unprod24.2%
metadata-eval24.2%
cancel-sign-sub-inv24.2%
*-commutative24.2%
cancel-sign-sub-inv24.2%
metadata-eval24.2%
fma-def24.2%
Applied egg-rr24.2%
unpow124.2%
associate-*l*29.5%
associate-*r*29.5%
Simplified29.5%
if -1.35e-114 < B < 1.4e6Initial program 27.3%
Simplified27.3%
Taylor expanded in A around -inf 30.9%
*-commutative30.9%
Simplified30.9%
if 1.4e6 < B Initial program 18.3%
Simplified18.3%
Taylor expanded in B around inf 17.5%
Taylor expanded in A around 0 17.1%
unpow217.1%
associate-*r*17.1%
Simplified17.1%
Taylor expanded in C around 0 52.8%
mul-1-neg52.8%
*-commutative52.8%
Simplified52.8%
Final simplification32.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 (- (* B B) (* 4.0 (* A C)))))
(if (<= B -2.3e+55)
(* (sqrt (+ (* -4.0 (* C F)) (* 4.0 (* A F)))) (/ 1.0 B))
(if (<= B 4400000.0)
(/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 A))))) t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A 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 <= -2.3e+55) {
tmp = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B);
} else if (B <= 4400000.0) {
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
}
return tmp;
}
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) :: tmp
t_0 = (b * b) - (4.0d0 * (a * c))
if (b <= (-2.3d+55)) then
tmp = sqrt((((-4.0d0) * (c * f)) + (4.0d0 * (a * f)))) * (1.0d0 / b)
else if (b <= 4400000.0d0) then
tmp = -sqrt((2.0d0 * ((t_0 * f) * (2.0d0 * a)))) / t_0
else
tmp = (sqrt(2.0d0) / b) * -sqrt((f * (a - b)))
end if
code = tmp
end function
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 <= -2.3e+55) {
tmp = Math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B);
} else if (B <= 4400000.0) {
tmp = -Math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * (A - B)));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) tmp = 0 if B <= -2.3e+55: tmp = math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B) elif B <= 4400000.0: tmp = -math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * (A - B))) return tmp
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 <= -2.3e+55) tmp = Float64(sqrt(Float64(Float64(-4.0 * Float64(C * F)) + Float64(4.0 * Float64(A * F)))) * Float64(1.0 / B)); elseif (B <= 4400000.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - B))))); end return tmp end
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 <= -2.3e+55)
tmp = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B);
elseif (B <= 4400000.0)
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
else
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
end
tmp_2 = 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[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -2.3e+55], N[(N[Sqrt[N[(N[(-4.0 * N[(C * F), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 4400000.0], N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
[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 -2.3 \cdot 10^{+55}:\\
\;\;\;\;\sqrt{-4 \cdot \left(C \cdot F\right) + 4 \cdot \left(A \cdot F\right)} \cdot \frac{1}{B}\\
\mathbf{elif}\;B \leq 4400000:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < -2.29999999999999987e55Initial program 6.7%
Simplified6.6%
Taylor expanded in A around -inf 0.7%
fma-def0.7%
unpow20.7%
fma-def0.7%
*-commutative0.7%
unpow20.7%
*-commutative0.7%
unpow20.7%
Simplified0.7%
Taylor expanded in B around -inf 6.2%
if -2.29999999999999987e55 < B < 4.4e6Initial program 27.2%
Simplified27.2%
Taylor expanded in A around -inf 29.4%
*-commutative29.4%
Simplified29.4%
if 4.4e6 < B Initial program 18.3%
Simplified18.3%
Taylor expanded in B around inf 17.5%
Taylor expanded in A around 0 17.1%
unpow217.1%
associate-*r*17.1%
Simplified17.1%
Taylor expanded in C around 0 52.8%
mul-1-neg52.8%
*-commutative52.8%
Simplified52.8%
Final simplification30.1%
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.1e+55)
(/ (sqrt (fma -4.0 (* C F) (* F (* 4.0 A)))) B)
(if (<= B 2020000.0)
(/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 A))))) t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A 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.1e+55) {
tmp = sqrt(fma(-4.0, (C * F), (F * (4.0 * A)))) / B;
} else if (B <= 2020000.0) {
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
}
return tmp;
}
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.1e+55) tmp = Float64(sqrt(fma(-4.0, Float64(C * F), Float64(F * Float64(4.0 * A)))) / B); elseif (B <= 2020000.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - 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[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -3.1e+55], N[(N[Sqrt[N[(-4.0 * N[(C * F), $MachinePrecision] + N[(F * N[(4.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision], If[LessEqual[B, 2020000.0], N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
[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.1 \cdot 10^{+55}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-4, C \cdot F, F \cdot \left(4 \cdot A\right)\right)}}{B}\\
\mathbf{elif}\;B \leq 2020000:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < -3.09999999999999994e55Initial program 6.7%
Simplified6.6%
Taylor expanded in A around -inf 0.7%
fma-def0.7%
unpow20.7%
fma-def0.7%
*-commutative0.7%
unpow20.7%
*-commutative0.7%
unpow20.7%
Simplified0.7%
Taylor expanded in B around -inf 6.2%
associate-*r/6.2%
*-rgt-identity6.2%
fma-def6.2%
*-commutative6.2%
associate-*r*6.2%
Simplified6.2%
if -3.09999999999999994e55 < B < 2.02e6Initial program 27.2%
Simplified27.2%
Taylor expanded in A around -inf 29.4%
*-commutative29.4%
Simplified29.4%
if 2.02e6 < B Initial program 18.3%
Simplified18.3%
Taylor expanded in B around inf 17.5%
Taylor expanded in A around 0 17.1%
unpow217.1%
associate-*r*17.1%
Simplified17.1%
Taylor expanded in C around 0 52.8%
mul-1-neg52.8%
*-commutative52.8%
Simplified52.8%
Final simplification30.1%
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 (* t_0 F)))
(if (<= B -1e+54)
(* (sqrt (+ (* -4.0 (* C F)) (* 4.0 (* A F)))) (/ 1.0 B))
(if (<= B 25.0)
(/ (- (sqrt (* 2.0 (* t_1 (* 2.0 A))))) t_0)
(/
(- (sqrt (* 2.0 (* t_1 (- (+ A C) (+ B (* 0.5 (/ (* C C) B))))))))
t_0)))))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 = t_0 * F;
double tmp;
if (B <= -1e+54) {
tmp = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B);
} else if (B <= 25.0) {
tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
} else {
tmp = -sqrt((2.0 * (t_1 * ((A + C) - (B + (0.5 * ((C * C) / B))))))) / t_0;
}
return tmp;
}
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 = t_0 * f
if (b <= (-1d+54)) then
tmp = sqrt((((-4.0d0) * (c * f)) + (4.0d0 * (a * f)))) * (1.0d0 / b)
else if (b <= 25.0d0) then
tmp = -sqrt((2.0d0 * (t_1 * (2.0d0 * a)))) / t_0
else
tmp = -sqrt((2.0d0 * (t_1 * ((a + c) - (b + (0.5d0 * ((c * c) / b))))))) / t_0
end if
code = tmp
end function
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 = t_0 * F;
double tmp;
if (B <= -1e+54) {
tmp = Math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B);
} else if (B <= 25.0) {
tmp = -Math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
} else {
tmp = -Math.sqrt((2.0 * (t_1 * ((A + C) - (B + (0.5 * ((C * C) / B))))))) / t_0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = t_0 * F tmp = 0 if B <= -1e+54: tmp = math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B) elif B <= 25.0: tmp = -math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0 else: tmp = -math.sqrt((2.0 * (t_1 * ((A + C) - (B + (0.5 * ((C * C) / B))))))) / t_0 return tmp
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(t_0 * F) tmp = 0.0 if (B <= -1e+54) tmp = Float64(sqrt(Float64(Float64(-4.0 * Float64(C * F)) + Float64(4.0 * Float64(A * F)))) * Float64(1.0 / B)); elseif (B <= 25.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) - Float64(B + Float64(0.5 * Float64(Float64(C * C) / B)))))))) / t_0); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
t_1 = t_0 * F;
tmp = 0.0;
if (B <= -1e+54)
tmp = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B);
elseif (B <= 25.0)
tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
else
tmp = -sqrt((2.0 * (t_1 * ((A + C) - (B + (0.5 * ((C * C) / B))))))) / t_0;
end
tmp_2 = 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[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * F), $MachinePrecision]}, If[LessEqual[B, -1e+54], N[(N[Sqrt[N[(N[(-4.0 * N[(C * F), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 25.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] - N[(B + N[(0.5 * N[(N[(C * C), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := t_0 \cdot F\\
\mathbf{if}\;B \leq -1 \cdot 10^{+54}:\\
\;\;\;\;\sqrt{-4 \cdot \left(C \cdot F\right) + 4 \cdot \left(A \cdot F\right)} \cdot \frac{1}{B}\\
\mathbf{elif}\;B \leq 25:\\
\;\;\;\;\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) - \left(B + 0.5 \cdot \frac{C \cdot C}{B}\right)\right)\right)}}{t_0}\\
\end{array}
\end{array}
if B < -1.0000000000000001e54Initial program 6.7%
Simplified6.6%
Taylor expanded in A around -inf 0.7%
fma-def0.7%
unpow20.7%
fma-def0.7%
*-commutative0.7%
unpow20.7%
*-commutative0.7%
unpow20.7%
Simplified0.7%
Taylor expanded in B around -inf 6.2%
if -1.0000000000000001e54 < B < 25Initial program 26.2%
Simplified26.1%
Taylor expanded in A around -inf 29.1%
*-commutative29.1%
Simplified29.1%
if 25 < B Initial program 20.8%
Simplified20.8%
Taylor expanded in B around inf 18.6%
Taylor expanded in A around 0 18.2%
unpow218.2%
Simplified18.2%
Final simplification21.6%
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 (* t_0 F)))
(if (<= B -1.06e+54)
(* (sqrt (+ (* -4.0 (* C F)) (* 4.0 (* A F)))) (/ 1.0 B))
(if (<= B 18.0)
(/ (- (sqrt (* 2.0 (* t_1 (* 2.0 A))))) t_0)
(/ (- (sqrt (* 2.0 (* t_1 (- (+ A C) B))))) t_0)))))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 = t_0 * F;
double tmp;
if (B <= -1.06e+54) {
tmp = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B);
} else if (B <= 18.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: 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 = t_0 * f
if (b <= (-1.06d+54)) then
tmp = sqrt((((-4.0d0) * (c * f)) + (4.0d0 * (a * f)))) * (1.0d0 / b)
else if (b <= 18.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
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 = t_0 * F;
double tmp;
if (B <= -1.06e+54) {
tmp = Math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B);
} else if (B <= 18.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;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = t_0 * F tmp = 0 if B <= -1.06e+54: tmp = math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B) elif B <= 18.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
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(t_0 * F) tmp = 0.0 if (B <= -1.06e+54) tmp = Float64(sqrt(Float64(Float64(-4.0 * Float64(C * F)) + Float64(4.0 * Float64(A * F)))) * Float64(1.0 / B)); elseif (B <= 18.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
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
t_1 = t_0 * F;
tmp = 0.0;
if (B <= -1.06e+54)
tmp = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B);
elseif (B <= 18.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: 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[(t$95$0 * F), $MachinePrecision]}, If[LessEqual[B, -1.06e+54], N[(N[Sqrt[N[(N[(-4.0 * N[(C * F), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 18.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}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := t_0 \cdot F\\
\mathbf{if}\;B \leq -1.06 \cdot 10^{+54}:\\
\;\;\;\;\sqrt{-4 \cdot \left(C \cdot F\right) + 4 \cdot \left(A \cdot F\right)} \cdot \frac{1}{B}\\
\mathbf{elif}\;B \leq 18:\\
\;\;\;\;\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 < -1.06e54Initial program 6.7%
Simplified6.6%
Taylor expanded in A around -inf 0.7%
fma-def0.7%
unpow20.7%
fma-def0.7%
*-commutative0.7%
unpow20.7%
*-commutative0.7%
unpow20.7%
Simplified0.7%
Taylor expanded in B around -inf 6.2%
if -1.06e54 < B < 18Initial program 26.2%
Simplified26.1%
Taylor expanded in A around -inf 29.1%
*-commutative29.1%
Simplified29.1%
if 18 < B Initial program 20.8%
Simplified20.8%
Taylor expanded in B around inf 18.5%
Final simplification21.7%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (sqrt (+ (* -4.0 (* C F)) (* 4.0 (* A F)))))
(t_1 (+ (* B B) (* (* A C) -4.0))))
(if (<= B -2.35e+55)
(* t_0 (/ 1.0 B))
(if (<= B 1.5e+28)
(/ (- (sqrt (* 2.0 (* t_1 (* F (* 2.0 A)))))) t_1)
(* t_0 (/ -1.0 B))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F))));
double t_1 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= -2.35e+55) {
tmp = t_0 * (1.0 / B);
} else if (B <= 1.5e+28) {
tmp = -sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1;
} else {
tmp = t_0 * (-1.0 / B);
}
return tmp;
}
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 = sqrt((((-4.0d0) * (c * f)) + (4.0d0 * (a * f))))
t_1 = (b * b) + ((a * c) * (-4.0d0))
if (b <= (-2.35d+55)) then
tmp = t_0 * (1.0d0 / b)
else if (b <= 1.5d+28) then
tmp = -sqrt((2.0d0 * (t_1 * (f * (2.0d0 * a))))) / t_1
else
tmp = t_0 * ((-1.0d0) / b)
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = Math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F))));
double t_1 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= -2.35e+55) {
tmp = t_0 * (1.0 / B);
} else if (B <= 1.5e+28) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1;
} else {
tmp = t_0 * (-1.0 / B);
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) t_1 = (B * B) + ((A * C) * -4.0) tmp = 0 if B <= -2.35e+55: tmp = t_0 * (1.0 / B) elif B <= 1.5e+28: tmp = -math.sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1 else: tmp = t_0 * (-1.0 / B) return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = sqrt(Float64(Float64(-4.0 * Float64(C * F)) + Float64(4.0 * Float64(A * F)))) t_1 = Float64(Float64(B * B) + Float64(Float64(A * C) * -4.0)) tmp = 0.0 if (B <= -2.35e+55) tmp = Float64(t_0 * Float64(1.0 / B)); elseif (B <= 1.5e+28) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(2.0 * A)))))) / t_1); else tmp = Float64(t_0 * Float64(-1.0 / B)); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F))));
t_1 = (B * B) + ((A * C) * -4.0);
tmp = 0.0;
if (B <= -2.35e+55)
tmp = t_0 * (1.0 / B);
elseif (B <= 1.5e+28)
tmp = -sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1;
else
tmp = t_0 * (-1.0 / B);
end
tmp_2 = 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[Sqrt[N[(N[(-4.0 * N[(C * F), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -2.35e+55], N[(t$95$0 * N[(1.0 / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 1.5e+28], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[(t$95$0 * N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{-4 \cdot \left(C \cdot F\right) + 4 \cdot \left(A \cdot F\right)}\\
t_1 := B \cdot B + \left(A \cdot C\right) \cdot -4\\
\mathbf{if}\;B \leq -2.35 \cdot 10^{+55}:\\
\;\;\;\;t_0 \cdot \frac{1}{B}\\
\mathbf{elif}\;B \leq 1.5 \cdot 10^{+28}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{-1}{B}\\
\end{array}
\end{array}
if B < -2.35e55Initial program 6.7%
Simplified6.6%
Taylor expanded in A around -inf 0.7%
fma-def0.7%
unpow20.7%
fma-def0.7%
*-commutative0.7%
unpow20.7%
*-commutative0.7%
unpow20.7%
Simplified0.7%
Taylor expanded in B around -inf 6.2%
if -2.35e55 < B < 1.5e28Initial program 28.2%
Simplified28.2%
Taylor expanded in A around -inf 29.0%
*-commutative29.0%
Simplified29.0%
distribute-frac-neg29.0%
associate-*l*28.2%
cancel-sign-sub-inv28.2%
metadata-eval28.2%
*-commutative28.2%
cancel-sign-sub-inv28.2%
metadata-eval28.2%
Applied egg-rr28.2%
if 1.5e28 < B Initial program 14.6%
Simplified11.1%
Taylor expanded in A around -inf 0.7%
fma-def0.7%
unpow20.7%
fma-def0.7%
*-commutative0.7%
unpow20.7%
*-commutative0.7%
unpow20.7%
Simplified0.7%
Taylor expanded in B around inf 4.6%
Final simplification18.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 (- (* B B) (* 4.0 (* A C))))
(t_1 (sqrt (+ (* -4.0 (* C F)) (* 4.0 (* A F))))))
(if (<= B -6.4e+54)
(* t_1 (/ 1.0 B))
(if (<= B 1.3e+28)
(/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 A))))) t_0)
(* t_1 (/ -1.0 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 = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F))));
double tmp;
if (B <= -6.4e+54) {
tmp = t_1 * (1.0 / B);
} else if (B <= 1.3e+28) {
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else {
tmp = t_1 * (-1.0 / B);
}
return tmp;
}
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 = sqrt((((-4.0d0) * (c * f)) + (4.0d0 * (a * f))))
if (b <= (-6.4d+54)) then
tmp = t_1 * (1.0d0 / b)
else if (b <= 1.3d+28) then
tmp = -sqrt((2.0d0 * ((t_0 * f) * (2.0d0 * a)))) / t_0
else
tmp = t_1 * ((-1.0d0) / b)
end if
code = tmp
end function
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 = Math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F))));
double tmp;
if (B <= -6.4e+54) {
tmp = t_1 * (1.0 / B);
} else if (B <= 1.3e+28) {
tmp = -Math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else {
tmp = t_1 * (-1.0 / B);
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) tmp = 0 if B <= -6.4e+54: tmp = t_1 * (1.0 / B) elif B <= 1.3e+28: tmp = -math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0 else: tmp = t_1 * (-1.0 / B) return tmp
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 = sqrt(Float64(Float64(-4.0 * Float64(C * F)) + Float64(4.0 * Float64(A * F)))) tmp = 0.0 if (B <= -6.4e+54) tmp = Float64(t_1 * Float64(1.0 / B)); elseif (B <= 1.3e+28) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / t_0); else tmp = Float64(t_1 * Float64(-1.0 / B)); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
t_1 = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F))));
tmp = 0.0;
if (B <= -6.4e+54)
tmp = t_1 * (1.0 / B);
elseif (B <= 1.3e+28)
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
else
tmp = t_1 * (-1.0 / B);
end
tmp_2 = 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[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(-4.0 * N[(C * F), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[B, -6.4e+54], N[(t$95$1 * N[(1.0 / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 1.3e+28], N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(t$95$1 * N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := \sqrt{-4 \cdot \left(C \cdot F\right) + 4 \cdot \left(A \cdot F\right)}\\
\mathbf{if}\;B \leq -6.4 \cdot 10^{+54}:\\
\;\;\;\;t_1 \cdot \frac{1}{B}\\
\mathbf{elif}\;B \leq 1.3 \cdot 10^{+28}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \frac{-1}{B}\\
\end{array}
\end{array}
if B < -6.4e54Initial program 6.7%
Simplified6.6%
Taylor expanded in A around -inf 0.7%
fma-def0.7%
unpow20.7%
fma-def0.7%
*-commutative0.7%
unpow20.7%
*-commutative0.7%
unpow20.7%
Simplified0.7%
Taylor expanded in B around -inf 6.2%
if -6.4e54 < B < 1.3000000000000001e28Initial program 28.2%
Simplified28.2%
Taylor expanded in A around -inf 29.0%
*-commutative29.0%
Simplified29.0%
if 1.3000000000000001e28 < B Initial program 14.6%
Simplified11.1%
Taylor expanded in A around -inf 0.7%
fma-def0.7%
unpow20.7%
fma-def0.7%
*-commutative0.7%
unpow20.7%
*-commutative0.7%
unpow20.7%
Simplified0.7%
Taylor expanded in B around inf 4.6%
Final simplification18.9%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B -1.5e-50)
(* (sqrt (+ (* -4.0 (* C F)) (* 4.0 (* A F)))) (/ 1.0 B))
(/
(- (sqrt (* 2.0 (* (* 2.0 A) (* -4.0 (* A (* C F)))))))
(- (* B B) (* 4.0 (* A C))))))assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= -1.5e-50) {
tmp = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B);
} else {
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C)));
}
return tmp;
}
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) :: tmp
if (b <= (-1.5d-50)) then
tmp = sqrt((((-4.0d0) * (c * f)) + (4.0d0 * (a * f)))) * (1.0d0 / b)
else
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * ((-4.0d0) * (a * (c * f)))))) / ((b * b) - (4.0d0 * (a * c)))
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= -1.5e-50) {
tmp = Math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B);
} else {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C)));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= -1.5e-50: tmp = math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B) else: tmp = -math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C))) return tmp
A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= -1.5e-50) tmp = Float64(sqrt(Float64(Float64(-4.0 * Float64(C * F)) + Float64(4.0 * Float64(A * F)))) * Float64(1.0 / B)); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(-4.0 * Float64(A * Float64(C * F))))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (B <= -1.5e-50)
tmp = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B);
else
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (A * (C * F)))))) / ((B * B) - (4.0 * (A * C)));
end
tmp_2 = tmp;
end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, -1.5e-50], N[(N[Sqrt[N[(N[(-4.0 * N[(C * F), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(N[(2.0 * A), $MachinePrecision] * N[(-4.0 * N[(A * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq -1.5 \cdot 10^{-50}:\\
\;\;\;\;\sqrt{-4 \cdot \left(C \cdot F\right) + 4 \cdot \left(A \cdot F\right)} \cdot \frac{1}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\end{array}
\end{array}
if B < -1.49999999999999995e-50Initial program 13.5%
Simplified14.1%
Taylor expanded in A around -inf 1.0%
fma-def1.0%
unpow21.0%
fma-def1.0%
*-commutative1.0%
unpow21.0%
*-commutative1.0%
unpow21.0%
Simplified1.0%
Taylor expanded in B around -inf 5.0%
if -1.49999999999999995e-50 < B Initial program 23.7%
Simplified23.7%
Taylor expanded in A around -inf 21.7%
*-commutative21.7%
Simplified21.7%
Taylor expanded in B around 0 19.2%
Final simplification15.1%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= B 1.75e-287) (* (sqrt (+ (* -4.0 (* C F)) (* 4.0 (* A F)))) (/ 1.0 B)) (* -2.0 (/ (sqrt (* A F)) B))))
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 1.75e-287) {
tmp = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B);
} else {
tmp = -2.0 * (sqrt((A * F)) / B);
}
return tmp;
}
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) :: tmp
if (b <= 1.75d-287) then
tmp = sqrt((((-4.0d0) * (c * f)) + (4.0d0 * (a * f)))) * (1.0d0 / b)
else
tmp = (-2.0d0) * (sqrt((a * f)) / b)
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= 1.75e-287) {
tmp = Math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B);
} else {
tmp = -2.0 * (Math.sqrt((A * F)) / B);
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= 1.75e-287: tmp = math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B) else: tmp = -2.0 * (math.sqrt((A * F)) / B) return tmp
A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 1.75e-287) tmp = Float64(sqrt(Float64(Float64(-4.0 * Float64(C * F)) + Float64(4.0 * Float64(A * F)))) * Float64(1.0 / B)); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (B <= 1.75e-287)
tmp = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) * (1.0 / B);
else
tmp = -2.0 * (sqrt((A * F)) / B);
end
tmp_2 = tmp;
end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 1.75e-287], N[(N[Sqrt[N[(N[(-4.0 * N[(C * F), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $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 1.75 \cdot 10^{-287}:\\
\;\;\;\;\sqrt{-4 \cdot \left(C \cdot F\right) + 4 \cdot \left(A \cdot F\right)} \cdot \frac{1}{B}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 1.75e-287Initial program 20.5%
Simplified21.7%
Taylor expanded in A around -inf 12.7%
fma-def12.7%
unpow212.7%
fma-def12.7%
*-commutative12.7%
unpow212.7%
*-commutative12.7%
unpow212.7%
Simplified12.7%
Taylor expanded in B around -inf 3.6%
if 1.75e-287 < B Initial program 21.0%
Simplified21.8%
Taylor expanded in A around -inf 10.1%
fma-def10.1%
unpow210.1%
fma-def10.1%
*-commutative10.1%
unpow210.1%
*-commutative10.1%
unpow210.1%
Simplified10.1%
Taylor expanded in C around 0 4.6%
associate-*r/4.6%
*-rgt-identity4.6%
*-commutative4.6%
Simplified4.6%
Final simplification4.1%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (let* ((t_0 (sqrt (+ (* -4.0 (* C F)) (* 4.0 (* A F)))))) (if (<= B 1.45e-287) (* t_0 (/ 1.0 B)) (* t_0 (/ -1.0 B)))))
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F))));
double tmp;
if (B <= 1.45e-287) {
tmp = t_0 * (1.0 / B);
} else {
tmp = t_0 * (-1.0 / B);
}
return tmp;
}
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) :: tmp
t_0 = sqrt((((-4.0d0) * (c * f)) + (4.0d0 * (a * f))))
if (b <= 1.45d-287) then
tmp = t_0 * (1.0d0 / b)
else
tmp = t_0 * ((-1.0d0) / b)
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = Math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F))));
double tmp;
if (B <= 1.45e-287) {
tmp = t_0 * (1.0 / B);
} else {
tmp = t_0 * (-1.0 / B);
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt(((-4.0 * (C * F)) + (4.0 * (A * F)))) tmp = 0 if B <= 1.45e-287: tmp = t_0 * (1.0 / B) else: tmp = t_0 * (-1.0 / B) return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = sqrt(Float64(Float64(-4.0 * Float64(C * F)) + Float64(4.0 * Float64(A * F)))) tmp = 0.0 if (B <= 1.45e-287) tmp = Float64(t_0 * Float64(1.0 / B)); else tmp = Float64(t_0 * Float64(-1.0 / B)); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt(((-4.0 * (C * F)) + (4.0 * (A * F))));
tmp = 0.0;
if (B <= 1.45e-287)
tmp = t_0 * (1.0 / B);
else
tmp = t_0 * (-1.0 / B);
end
tmp_2 = 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[Sqrt[N[(N[(-4.0 * N[(C * F), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[B, 1.45e-287], N[(t$95$0 * N[(1.0 / B), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{-4 \cdot \left(C \cdot F\right) + 4 \cdot \left(A \cdot F\right)}\\
\mathbf{if}\;B \leq 1.45 \cdot 10^{-287}:\\
\;\;\;\;t_0 \cdot \frac{1}{B}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{-1}{B}\\
\end{array}
\end{array}
if B < 1.4499999999999999e-287Initial program 20.5%
Simplified21.7%
Taylor expanded in A around -inf 12.7%
fma-def12.7%
unpow212.7%
fma-def12.7%
*-commutative12.7%
unpow212.7%
*-commutative12.7%
unpow212.7%
Simplified12.7%
Taylor expanded in B around -inf 3.6%
if 1.4499999999999999e-287 < B Initial program 21.0%
Simplified21.8%
Taylor expanded in A around -inf 10.1%
fma-def10.1%
unpow210.1%
fma-def10.1%
*-commutative10.1%
unpow210.1%
*-commutative10.1%
unpow210.1%
Simplified10.1%
Taylor expanded in B around inf 4.5%
Final simplification4.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 (sqrt (* A F)))) (if (<= B -5e-310) (* t_0 (/ 2.0 B)) (* -2.0 (/ t_0 B)))))
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt((A * F));
double tmp;
if (B <= -5e-310) {
tmp = t_0 * (2.0 / B);
} else {
tmp = -2.0 * (t_0 / B);
}
return tmp;
}
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) :: tmp
t_0 = sqrt((a * f))
if (b <= (-5d-310)) then
tmp = t_0 * (2.0d0 / b)
else
tmp = (-2.0d0) * (t_0 / b)
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = Math.sqrt((A * F));
double tmp;
if (B <= -5e-310) {
tmp = t_0 * (2.0 / B);
} else {
tmp = -2.0 * (t_0 / B);
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt((A * F)) tmp = 0 if B <= -5e-310: tmp = t_0 * (2.0 / B) else: tmp = -2.0 * (t_0 / B) return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = sqrt(Float64(A * F)) tmp = 0.0 if (B <= -5e-310) tmp = Float64(t_0 * Float64(2.0 / B)); else tmp = Float64(-2.0 * Float64(t_0 / B)); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt((A * F));
tmp = 0.0;
if (B <= -5e-310)
tmp = t_0 * (2.0 / B);
else
tmp = -2.0 * (t_0 / B);
end
tmp_2 = 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[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[B, -5e-310], N[(t$95$0 * N[(2.0 / B), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(t$95$0 / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{A \cdot F}\\
\mathbf{if}\;B \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t_0 \cdot \frac{2}{B}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{t_0}{B}\\
\end{array}
\end{array}
if B < -4.999999999999985e-310Initial program 21.1%
Simplified21.0%
Taylor expanded in A around -inf 20.9%
*-commutative20.9%
Simplified20.9%
sqrt-prod20.8%
associate-*l*20.1%
cancel-sign-sub-inv20.1%
metadata-eval20.1%
*-commutative20.1%
Applied egg-rr20.1%
Taylor expanded in B around -inf 3.8%
*-commutative3.8%
unpow23.8%
rem-square-sqrt3.8%
Simplified3.8%
if -4.999999999999985e-310 < B Initial program 20.4%
Simplified21.2%
Taylor expanded in A around -inf 9.8%
fma-def9.8%
unpow29.8%
fma-def9.8%
*-commutative9.8%
unpow29.8%
*-commutative9.8%
unpow29.8%
Simplified9.8%
Taylor expanded in C around 0 4.4%
associate-*r/4.5%
*-rgt-identity4.5%
*-commutative4.5%
Simplified4.5%
Final simplification4.1%
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 20.8%
Simplified21.7%
Taylor expanded in A around -inf 11.4%
fma-def11.4%
unpow211.4%
fma-def11.4%
*-commutative11.4%
unpow211.4%
*-commutative11.4%
unpow211.4%
Simplified11.4%
Taylor expanded in C around 0 2.6%
associate-*r/2.6%
*-rgt-identity2.6%
*-commutative2.6%
Simplified2.6%
Final simplification2.6%
herbie shell --seed 2023196
(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))))