
(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 18 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) (* (* A C) -4.0)))
(t_1 (- (* B B) (* 4.0 (* A C))))
(t_2 (sqrt (* 2.0 (* F t_1))))
(t_3 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_4
(/
(-
(sqrt
(*
(* 2.0 (* t_3 F))
(+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_3)))
(if (<= t_4 (- INFINITY))
(/ (* t_2 (- (sqrt (+ C C)))) t_1)
(if (<= t_4 -2e-216)
(* (sqrt (* 2.0 (* (* F t_0) (+ C (hypot B C))))) (/ -1.0 t_0))
(if (<= t_4 INFINITY)
(/ (* (sqrt (+ C (+ C (* -0.5 (/ (* B B) A))))) (- t_2)) t_1)
(* (/ (sqrt 2.0) B) (* (sqrt (+ A (hypot B A))) (- (sqrt F)))))))))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 t_2 = sqrt((2.0 * (F * t_1)));
double t_3 = pow(B, 2.0) - ((4.0 * A) * C);
double t_4 = -sqrt(((2.0 * (t_3 * F)) * ((A + C) + sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_3;
double tmp;
if (t_4 <= -((double) INFINITY)) {
tmp = (t_2 * -sqrt((C + C))) / t_1;
} else if (t_4 <= -2e-216) {
tmp = sqrt((2.0 * ((F * t_0) * (C + hypot(B, C))))) * (-1.0 / t_0);
} else if (t_4 <= ((double) INFINITY)) {
tmp = (sqrt((C + (C + (-0.5 * ((B * B) / A))))) * -t_2) / t_1;
} else {
tmp = (sqrt(2.0) / B) * (sqrt((A + hypot(B, A))) * -sqrt(F));
}
return tmp;
}
assert A < C;
public static 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 t_2 = Math.sqrt((2.0 * (F * t_1)));
double t_3 = Math.pow(B, 2.0) - ((4.0 * A) * C);
double t_4 = -Math.sqrt(((2.0 * (t_3 * F)) * ((A + C) + Math.sqrt((Math.pow(B, 2.0) + Math.pow((A - C), 2.0)))))) / t_3;
double tmp;
if (t_4 <= -Double.POSITIVE_INFINITY) {
tmp = (t_2 * -Math.sqrt((C + C))) / t_1;
} else if (t_4 <= -2e-216) {
tmp = Math.sqrt((2.0 * ((F * t_0) * (C + Math.hypot(B, C))))) * (-1.0 / t_0);
} else if (t_4 <= Double.POSITIVE_INFINITY) {
tmp = (Math.sqrt((C + (C + (-0.5 * ((B * B) / A))))) * -t_2) / t_1;
} else {
tmp = (Math.sqrt(2.0) / B) * (Math.sqrt((A + Math.hypot(B, A))) * -Math.sqrt(F));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + ((A * C) * -4.0) t_1 = (B * B) - (4.0 * (A * C)) t_2 = math.sqrt((2.0 * (F * t_1))) t_3 = math.pow(B, 2.0) - ((4.0 * A) * C) t_4 = -math.sqrt(((2.0 * (t_3 * F)) * ((A + C) + math.sqrt((math.pow(B, 2.0) + math.pow((A - C), 2.0)))))) / t_3 tmp = 0 if t_4 <= -math.inf: tmp = (t_2 * -math.sqrt((C + C))) / t_1 elif t_4 <= -2e-216: tmp = math.sqrt((2.0 * ((F * t_0) * (C + math.hypot(B, C))))) * (-1.0 / t_0) elif t_4 <= math.inf: tmp = (math.sqrt((C + (C + (-0.5 * ((B * B) / A))))) * -t_2) / t_1 else: tmp = (math.sqrt(2.0) / B) * (math.sqrt((A + math.hypot(B, A))) * -math.sqrt(F)) 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))) t_2 = sqrt(Float64(2.0 * Float64(F * t_1))) t_3 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_4 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_3 * F)) * Float64(Float64(A + C) + sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_3) tmp = 0.0 if (t_4 <= Float64(-Inf)) tmp = Float64(Float64(t_2 * Float64(-sqrt(Float64(C + C)))) / t_1); elseif (t_4 <= -2e-216) tmp = Float64(sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(C + hypot(B, C))))) * Float64(-1.0 / t_0)); elseif (t_4 <= Inf) tmp = Float64(Float64(sqrt(Float64(C + Float64(C + Float64(-0.5 * Float64(Float64(B * B) / A))))) * Float64(-t_2)) / t_1); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(sqrt(Float64(A + hypot(B, A))) * Float64(-sqrt(F)))); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + ((A * C) * -4.0);
t_1 = (B * B) - (4.0 * (A * C));
t_2 = sqrt((2.0 * (F * t_1)));
t_3 = (B ^ 2.0) - ((4.0 * A) * C);
t_4 = -sqrt(((2.0 * (t_3 * F)) * ((A + C) + sqrt(((B ^ 2.0) + ((A - C) ^ 2.0)))))) / t_3;
tmp = 0.0;
if (t_4 <= -Inf)
tmp = (t_2 * -sqrt((C + C))) / t_1;
elseif (t_4 <= -2e-216)
tmp = sqrt((2.0 * ((F * t_0) * (C + hypot(B, C))))) * (-1.0 / t_0);
elseif (t_4 <= Inf)
tmp = (sqrt((C + (C + (-0.5 * ((B * B) / A))))) * -t_2) / t_1;
else
tmp = (sqrt(2.0) / B) * (sqrt((A + hypot(B, A))) * -sqrt(F));
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[(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]}, Block[{t$95$2 = N[Sqrt[N[(2.0 * N[(F * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$3 * 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$3), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], N[(N[(t$95$2 * (-N[Sqrt[N[(C + C), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$4, -2e-216], N[(N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(C + N[Sqrt[B ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(N[(N[Sqrt[N[(C + N[(C + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-t$95$2)), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * N[(N[Sqrt[N[(A + N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[F], $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)\\
t_2 := \sqrt{2 \cdot \left(F \cdot t_1\right)}\\
t_3 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_4 := \frac{-\sqrt{\left(2 \cdot \left(t_3 \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_3}\\
\mathbf{if}\;t_4 \leq -\infty:\\
\;\;\;\;\frac{t_2 \cdot \left(-\sqrt{C + C}\right)}{t_1}\\
\mathbf{elif}\;t_4 \leq -2 \cdot 10^{-216}:\\
\;\;\;\;\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(C + \mathsf{hypot}\left(B, C\right)\right)\right)} \cdot \frac{-1}{t_0}\\
\mathbf{elif}\;t_4 \leq \infty:\\
\;\;\;\;\frac{\sqrt{C + \left(C + -0.5 \cdot \frac{B \cdot B}{A}\right)} \cdot \left(-t_2\right)}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(\sqrt{A + \mathsf{hypot}\left(B, A\right)} \cdot \left(-\sqrt{F}\right)\right)\\
\end{array}
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -inf.0Initial program 3.1%
associate-*l*3.1%
unpow23.1%
+-commutative3.1%
unpow23.1%
associate-*l*3.1%
unpow23.1%
Simplified3.1%
sqrt-prod18.5%
*-commutative18.5%
*-commutative18.5%
associate-+l+18.5%
unpow218.5%
hypot-udef40.5%
associate-+r+38.0%
+-commutative38.0%
associate-+r+39.1%
Applied egg-rr39.1%
Taylor expanded in A around -inf 20.3%
if -inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -2.0000000000000001e-216Initial program 96.3%
associate-*l*96.3%
unpow296.3%
+-commutative96.3%
unpow296.3%
associate-*l*96.3%
unpow296.3%
Simplified96.3%
Taylor expanded in A around 0 78.6%
unpow278.6%
unpow278.6%
hypot-def78.7%
Simplified78.7%
div-inv78.7%
associate-*l*78.7%
*-commutative78.7%
cancel-sign-sub-inv78.7%
metadata-eval78.7%
*-commutative78.7%
cancel-sign-sub-inv78.7%
metadata-eval78.7%
*-commutative78.7%
Applied egg-rr78.7%
if -2.0000000000000001e-216 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < +inf.0Initial program 12.9%
associate-*l*12.9%
unpow212.9%
+-commutative12.9%
unpow212.9%
associate-*l*12.9%
unpow212.9%
Simplified12.9%
sqrt-prod16.7%
*-commutative16.7%
*-commutative16.7%
associate-+l+18.0%
unpow218.0%
hypot-udef26.1%
associate-+r+24.8%
+-commutative24.8%
associate-+r+26.8%
Applied egg-rr26.8%
Taylor expanded in A around -inf 31.2%
unpow231.2%
Simplified31.2%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) Initial program 0.0%
Simplified0.6%
Taylor expanded in C around 0 1.6%
mul-1-neg1.6%
*-commutative1.6%
distribute-rgt-neg-in1.6%
unpow21.6%
unpow21.6%
hypot-def20.6%
Simplified20.6%
sqrt-prod30.0%
Applied egg-rr30.0%
Final simplification36.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 (- (* B B) (* 4.0 (* A C)))) (t_1 (* 2.0 (* F t_0))))
(if (<= A -1.16e+33)
(- (/ (sqrt (* t_1 (fma 2.0 C (* -0.5 (/ (* B B) A))))) t_0))
(/ (* (sqrt t_1) (- (sqrt (+ C (+ A (hypot B (- A C))))))) 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 = 2.0 * (F * t_0);
double tmp;
if (A <= -1.16e+33) {
tmp = -(sqrt((t_1 * fma(2.0, C, (-0.5 * ((B * B) / A))))) / t_0);
} else {
tmp = (sqrt(t_1) * -sqrt((C + (A + hypot(B, (A - C)))))) / 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(2.0 * Float64(F * t_0)) tmp = 0.0 if (A <= -1.16e+33) tmp = Float64(-Float64(sqrt(Float64(t_1 * fma(2.0, C, Float64(-0.5 * Float64(Float64(B * B) / A))))) / t_0)); else tmp = Float64(Float64(sqrt(t_1) * Float64(-sqrt(Float64(C + Float64(A + hypot(B, Float64(A - C))))))) / t_0); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[A, -1.16e+33], (-N[(N[Sqrt[N[(t$95$1 * N[(2.0 * C + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), N[(N[(N[Sqrt[t$95$1], $MachinePrecision] * (-N[Sqrt[N[(C + N[(A + N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $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 := 2 \cdot \left(F \cdot t_0\right)\\
\mathbf{if}\;A \leq -1.16 \cdot 10^{+33}:\\
\;\;\;\;-\frac{\sqrt{t_1 \cdot \mathsf{fma}\left(2, C, -0.5 \cdot \frac{B \cdot B}{A}\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{t_1} \cdot \left(-\sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}\right)}{t_0}\\
\end{array}
\end{array}
if A < -1.16000000000000001e33Initial program 4.9%
associate-*l*4.9%
unpow24.9%
+-commutative4.9%
unpow24.9%
associate-*l*4.9%
unpow24.9%
Simplified4.9%
Taylor expanded in A around -inf 30.5%
fma-def30.5%
unpow230.5%
Simplified30.5%
if -1.16000000000000001e33 < A Initial program 25.3%
associate-*l*25.3%
unpow225.3%
+-commutative25.3%
unpow225.3%
associate-*l*25.3%
unpow225.3%
Simplified25.3%
sqrt-prod30.6%
*-commutative30.6%
*-commutative30.6%
associate-+l+31.0%
unpow231.0%
hypot-udef39.3%
associate-+r+38.2%
+-commutative38.2%
associate-+r+38.3%
Applied egg-rr38.3%
Final simplification36.3%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ C (hypot B C)))
(t_1 (+ (* B B) (* (* A C) -4.0)))
(t_2 (- (* B B) (* 4.0 (* A C))))
(t_3 (* 2.0 (* F t_2))))
(if (<= B -0.0034)
(/
(* (sqrt (+ C (+ A (hypot B (- A C))))) (- (sqrt (* 2.0 (* F (* B B))))))
t_2)
(if (<= B 2e-147)
(/ (* (sqrt (+ C (+ C (* -0.5 (/ (* B B) A))))) (- (sqrt t_3))) t_2)
(if (<= B 2.6e-78)
(* (sqrt (* 2.0 (* (* F t_1) (* 2.0 C)))) (/ -1.0 t_1))
(if (<= B 1.72e+27)
(/ (- (sqrt (* t_0 t_3))) t_2)
(* (/ (sqrt 2.0) B) (- (sqrt (* F t_0))))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = C + hypot(B, C);
double t_1 = (B * B) + ((A * C) * -4.0);
double t_2 = (B * B) - (4.0 * (A * C));
double t_3 = 2.0 * (F * t_2);
double tmp;
if (B <= -0.0034) {
tmp = (sqrt((C + (A + hypot(B, (A - C))))) * -sqrt((2.0 * (F * (B * B))))) / t_2;
} else if (B <= 2e-147) {
tmp = (sqrt((C + (C + (-0.5 * ((B * B) / A))))) * -sqrt(t_3)) / t_2;
} else if (B <= 2.6e-78) {
tmp = sqrt((2.0 * ((F * t_1) * (2.0 * C)))) * (-1.0 / t_1);
} else if (B <= 1.72e+27) {
tmp = -sqrt((t_0 * t_3)) / t_2;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * t_0));
}
return tmp;
}
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = C + Math.hypot(B, C);
double t_1 = (B * B) + ((A * C) * -4.0);
double t_2 = (B * B) - (4.0 * (A * C));
double t_3 = 2.0 * (F * t_2);
double tmp;
if (B <= -0.0034) {
tmp = (Math.sqrt((C + (A + Math.hypot(B, (A - C))))) * -Math.sqrt((2.0 * (F * (B * B))))) / t_2;
} else if (B <= 2e-147) {
tmp = (Math.sqrt((C + (C + (-0.5 * ((B * B) / A))))) * -Math.sqrt(t_3)) / t_2;
} else if (B <= 2.6e-78) {
tmp = Math.sqrt((2.0 * ((F * t_1) * (2.0 * C)))) * (-1.0 / t_1);
} else if (B <= 1.72e+27) {
tmp = -Math.sqrt((t_0 * t_3)) / t_2;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * t_0));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = C + math.hypot(B, C) t_1 = (B * B) + ((A * C) * -4.0) t_2 = (B * B) - (4.0 * (A * C)) t_3 = 2.0 * (F * t_2) tmp = 0 if B <= -0.0034: tmp = (math.sqrt((C + (A + math.hypot(B, (A - C))))) * -math.sqrt((2.0 * (F * (B * B))))) / t_2 elif B <= 2e-147: tmp = (math.sqrt((C + (C + (-0.5 * ((B * B) / A))))) * -math.sqrt(t_3)) / t_2 elif B <= 2.6e-78: tmp = math.sqrt((2.0 * ((F * t_1) * (2.0 * C)))) * (-1.0 / t_1) elif B <= 1.72e+27: tmp = -math.sqrt((t_0 * t_3)) / t_2 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * t_0)) return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(C + hypot(B, C)) t_1 = Float64(Float64(B * B) + Float64(Float64(A * C) * -4.0)) t_2 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_3 = Float64(2.0 * Float64(F * t_2)) tmp = 0.0 if (B <= -0.0034) tmp = Float64(Float64(sqrt(Float64(C + Float64(A + hypot(B, Float64(A - C))))) * Float64(-sqrt(Float64(2.0 * Float64(F * Float64(B * B)))))) / t_2); elseif (B <= 2e-147) tmp = Float64(Float64(sqrt(Float64(C + Float64(C + Float64(-0.5 * Float64(Float64(B * B) / A))))) * Float64(-sqrt(t_3))) / t_2); elseif (B <= 2.6e-78) tmp = Float64(sqrt(Float64(2.0 * Float64(Float64(F * t_1) * Float64(2.0 * C)))) * Float64(-1.0 / t_1)); elseif (B <= 1.72e+27) tmp = Float64(Float64(-sqrt(Float64(t_0 * t_3))) / t_2); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * t_0)))); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = C + hypot(B, C);
t_1 = (B * B) + ((A * C) * -4.0);
t_2 = (B * B) - (4.0 * (A * C));
t_3 = 2.0 * (F * t_2);
tmp = 0.0;
if (B <= -0.0034)
tmp = (sqrt((C + (A + hypot(B, (A - C))))) * -sqrt((2.0 * (F * (B * B))))) / t_2;
elseif (B <= 2e-147)
tmp = (sqrt((C + (C + (-0.5 * ((B * B) / A))))) * -sqrt(t_3)) / t_2;
elseif (B <= 2.6e-78)
tmp = sqrt((2.0 * ((F * t_1) * (2.0 * C)))) * (-1.0 / t_1);
elseif (B <= 1.72e+27)
tmp = -sqrt((t_0 * t_3)) / t_2;
else
tmp = (sqrt(2.0) / B) * -sqrt((F * 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[(C + N[Sqrt[B ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(2.0 * N[(F * t$95$2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -0.0034], N[(N[(N[Sqrt[N[(C + N[(A + N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(2.0 * N[(F * N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[B, 2e-147], N[(N[(N[Sqrt[N[(C + N[(C + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[t$95$3], $MachinePrecision])), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[B, 2.6e-78], N[(N[Sqrt[N[(2.0 * N[(N[(F * t$95$1), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 1.72e+27], N[((-N[Sqrt[N[(t$95$0 * t$95$3), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * t$95$0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := C + \mathsf{hypot}\left(B, C\right)\\
t_1 := B \cdot B + \left(A \cdot C\right) \cdot -4\\
t_2 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_3 := 2 \cdot \left(F \cdot t_2\right)\\
\mathbf{if}\;B \leq -0.0034:\\
\;\;\;\;\frac{\sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \left(-\sqrt{2 \cdot \left(F \cdot \left(B \cdot B\right)\right)}\right)}{t_2}\\
\mathbf{elif}\;B \leq 2 \cdot 10^{-147}:\\
\;\;\;\;\frac{\sqrt{C + \left(C + -0.5 \cdot \frac{B \cdot B}{A}\right)} \cdot \left(-\sqrt{t_3}\right)}{t_2}\\
\mathbf{elif}\;B \leq 2.6 \cdot 10^{-78}:\\
\;\;\;\;\sqrt{2 \cdot \left(\left(F \cdot t_1\right) \cdot \left(2 \cdot C\right)\right)} \cdot \frac{-1}{t_1}\\
\mathbf{elif}\;B \leq 1.72 \cdot 10^{+27}:\\
\;\;\;\;\frac{-\sqrt{t_0 \cdot t_3}}{t_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot t_0}\right)\\
\end{array}
\end{array}
if B < -0.00339999999999999981Initial program 13.9%
associate-*l*13.9%
unpow213.9%
+-commutative13.9%
unpow213.9%
associate-*l*13.9%
unpow213.9%
Simplified13.9%
sqrt-prod20.2%
*-commutative20.2%
*-commutative20.2%
associate-+l+20.1%
unpow220.1%
hypot-udef25.0%
associate-+r+24.9%
+-commutative24.9%
associate-+r+25.0%
Applied egg-rr25.0%
Taylor expanded in B around inf 23.6%
unpow223.6%
Simplified23.6%
if -0.00339999999999999981 < B < 1.9999999999999999e-147Initial program 25.0%
associate-*l*25.0%
unpow225.0%
+-commutative25.0%
unpow225.0%
associate-*l*25.0%
unpow225.0%
Simplified25.0%
sqrt-prod26.4%
*-commutative26.4%
*-commutative26.4%
associate-+l+27.2%
unpow227.2%
hypot-udef31.9%
associate-+r+30.4%
+-commutative30.4%
associate-+r+31.9%
Applied egg-rr31.9%
Taylor expanded in A around -inf 25.1%
unpow225.1%
Simplified25.1%
if 1.9999999999999999e-147 < B < 2.6000000000000001e-78Initial program 21.8%
associate-*l*21.8%
unpow221.8%
+-commutative21.8%
unpow221.8%
associate-*l*21.8%
unpow221.8%
Simplified21.8%
Taylor expanded in A around -inf 41.1%
div-inv41.2%
associate-*l*41.2%
*-commutative41.2%
cancel-sign-sub-inv41.2%
metadata-eval41.2%
*-commutative41.2%
cancel-sign-sub-inv41.2%
metadata-eval41.2%
*-commutative41.2%
Applied egg-rr41.2%
if 2.6000000000000001e-78 < B < 1.7199999999999999e27Initial program 33.5%
associate-*l*33.5%
unpow233.5%
+-commutative33.5%
unpow233.5%
associate-*l*33.5%
unpow233.5%
Simplified33.5%
Taylor expanded in A around 0 35.4%
unpow235.4%
unpow235.4%
hypot-def44.8%
Simplified44.8%
if 1.7199999999999999e27 < B Initial program 12.9%
Simplified16.3%
Taylor expanded in A around 0 18.9%
mul-1-neg18.9%
*-commutative18.9%
distribute-rgt-neg-in18.9%
*-commutative18.9%
unpow218.9%
unpow218.9%
hypot-def54.1%
Simplified54.1%
Final simplification33.9%
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))))
(t_2 (* 2.0 (* F t_1)))
(t_3 (sqrt t_2))
(t_4 (+ C (hypot B C))))
(if (<= B -74000.0)
(/ (* t_3 (- (sqrt (- C B)))) t_1)
(if (<= B 8.8e-148)
(/ (* (sqrt (+ C (+ C (* -0.5 (/ (* B B) A))))) (- t_3)) t_1)
(if (<= B 4.5e-79)
(* (sqrt (* 2.0 (* (* F t_0) (* 2.0 C)))) (/ -1.0 t_0))
(if (<= B 12600000000000.0)
(/ (- (sqrt (* t_4 t_2))) t_1)
(* (/ (sqrt 2.0) B) (- (sqrt (* F t_4))))))))))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 t_2 = 2.0 * (F * t_1);
double t_3 = sqrt(t_2);
double t_4 = C + hypot(B, C);
double tmp;
if (B <= -74000.0) {
tmp = (t_3 * -sqrt((C - B))) / t_1;
} else if (B <= 8.8e-148) {
tmp = (sqrt((C + (C + (-0.5 * ((B * B) / A))))) * -t_3) / t_1;
} else if (B <= 4.5e-79) {
tmp = sqrt((2.0 * ((F * t_0) * (2.0 * C)))) * (-1.0 / t_0);
} else if (B <= 12600000000000.0) {
tmp = -sqrt((t_4 * t_2)) / t_1;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * t_4));
}
return tmp;
}
assert A < C;
public static 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 t_2 = 2.0 * (F * t_1);
double t_3 = Math.sqrt(t_2);
double t_4 = C + Math.hypot(B, C);
double tmp;
if (B <= -74000.0) {
tmp = (t_3 * -Math.sqrt((C - B))) / t_1;
} else if (B <= 8.8e-148) {
tmp = (Math.sqrt((C + (C + (-0.5 * ((B * B) / A))))) * -t_3) / t_1;
} else if (B <= 4.5e-79) {
tmp = Math.sqrt((2.0 * ((F * t_0) * (2.0 * C)))) * (-1.0 / t_0);
} else if (B <= 12600000000000.0) {
tmp = -Math.sqrt((t_4 * t_2)) / t_1;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * t_4));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + ((A * C) * -4.0) t_1 = (B * B) - (4.0 * (A * C)) t_2 = 2.0 * (F * t_1) t_3 = math.sqrt(t_2) t_4 = C + math.hypot(B, C) tmp = 0 if B <= -74000.0: tmp = (t_3 * -math.sqrt((C - B))) / t_1 elif B <= 8.8e-148: tmp = (math.sqrt((C + (C + (-0.5 * ((B * B) / A))))) * -t_3) / t_1 elif B <= 4.5e-79: tmp = math.sqrt((2.0 * ((F * t_0) * (2.0 * C)))) * (-1.0 / t_0) elif B <= 12600000000000.0: tmp = -math.sqrt((t_4 * t_2)) / t_1 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * t_4)) 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))) t_2 = Float64(2.0 * Float64(F * t_1)) t_3 = sqrt(t_2) t_4 = Float64(C + hypot(B, C)) tmp = 0.0 if (B <= -74000.0) tmp = Float64(Float64(t_3 * Float64(-sqrt(Float64(C - B)))) / t_1); elseif (B <= 8.8e-148) tmp = Float64(Float64(sqrt(Float64(C + Float64(C + Float64(-0.5 * Float64(Float64(B * B) / A))))) * Float64(-t_3)) / t_1); elseif (B <= 4.5e-79) tmp = Float64(sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(2.0 * C)))) * Float64(-1.0 / t_0)); elseif (B <= 12600000000000.0) tmp = Float64(Float64(-sqrt(Float64(t_4 * t_2))) / t_1); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * t_4)))); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + ((A * C) * -4.0);
t_1 = (B * B) - (4.0 * (A * C));
t_2 = 2.0 * (F * t_1);
t_3 = sqrt(t_2);
t_4 = C + hypot(B, C);
tmp = 0.0;
if (B <= -74000.0)
tmp = (t_3 * -sqrt((C - B))) / t_1;
elseif (B <= 8.8e-148)
tmp = (sqrt((C + (C + (-0.5 * ((B * B) / A))))) * -t_3) / t_1;
elseif (B <= 4.5e-79)
tmp = sqrt((2.0 * ((F * t_0) * (2.0 * C)))) * (-1.0 / t_0);
elseif (B <= 12600000000000.0)
tmp = -sqrt((t_4 * t_2)) / t_1;
else
tmp = (sqrt(2.0) / B) * -sqrt((F * t_4));
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[(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]}, Block[{t$95$2 = N[(2.0 * N[(F * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[t$95$2], $MachinePrecision]}, Block[{t$95$4 = N[(C + N[Sqrt[B ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -74000.0], N[(N[(t$95$3 * (-N[Sqrt[N[(C - B), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[B, 8.8e-148], N[(N[(N[Sqrt[N[(C + N[(C + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-t$95$3)), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[B, 4.5e-79], N[(N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 12600000000000.0], N[((-N[Sqrt[N[(t$95$4 * t$95$2), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * t$95$4), $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)\\
t_2 := 2 \cdot \left(F \cdot t_1\right)\\
t_3 := \sqrt{t_2}\\
t_4 := C + \mathsf{hypot}\left(B, C\right)\\
\mathbf{if}\;B \leq -74000:\\
\;\;\;\;\frac{t_3 \cdot \left(-\sqrt{C - B}\right)}{t_1}\\
\mathbf{elif}\;B \leq 8.8 \cdot 10^{-148}:\\
\;\;\;\;\frac{\sqrt{C + \left(C + -0.5 \cdot \frac{B \cdot B}{A}\right)} \cdot \left(-t_3\right)}{t_1}\\
\mathbf{elif}\;B \leq 4.5 \cdot 10^{-79}:\\
\;\;\;\;\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(2 \cdot C\right)\right)} \cdot \frac{-1}{t_0}\\
\mathbf{elif}\;B \leq 12600000000000:\\
\;\;\;\;\frac{-\sqrt{t_4 \cdot t_2}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot t_4}\right)\\
\end{array}
\end{array}
if B < -74000Initial program 13.9%
associate-*l*13.9%
unpow213.9%
+-commutative13.9%
unpow213.9%
associate-*l*13.9%
unpow213.9%
Simplified13.9%
sqrt-prod20.2%
*-commutative20.2%
*-commutative20.2%
associate-+l+20.1%
unpow220.1%
hypot-udef25.0%
associate-+r+24.9%
+-commutative24.9%
associate-+r+25.0%
Applied egg-rr25.0%
Taylor expanded in B around -inf 17.3%
mul-1-neg17.3%
Simplified17.3%
if -74000 < B < 8.80000000000000068e-148Initial program 25.0%
associate-*l*25.0%
unpow225.0%
+-commutative25.0%
unpow225.0%
associate-*l*25.0%
unpow225.0%
Simplified25.0%
sqrt-prod26.4%
*-commutative26.4%
*-commutative26.4%
associate-+l+27.2%
unpow227.2%
hypot-udef31.9%
associate-+r+30.4%
+-commutative30.4%
associate-+r+31.9%
Applied egg-rr31.9%
Taylor expanded in A around -inf 25.1%
unpow225.1%
Simplified25.1%
if 8.80000000000000068e-148 < B < 4.5000000000000003e-79Initial program 21.8%
associate-*l*21.8%
unpow221.8%
+-commutative21.8%
unpow221.8%
associate-*l*21.8%
unpow221.8%
Simplified21.8%
Taylor expanded in A around -inf 41.1%
div-inv41.2%
associate-*l*41.2%
*-commutative41.2%
cancel-sign-sub-inv41.2%
metadata-eval41.2%
*-commutative41.2%
cancel-sign-sub-inv41.2%
metadata-eval41.2%
*-commutative41.2%
Applied egg-rr41.2%
if 4.5000000000000003e-79 < B < 1.26e13Initial program 33.5%
associate-*l*33.5%
unpow233.5%
+-commutative33.5%
unpow233.5%
associate-*l*33.5%
unpow233.5%
Simplified33.5%
Taylor expanded in A around 0 35.4%
unpow235.4%
unpow235.4%
hypot-def44.8%
Simplified44.8%
if 1.26e13 < B Initial program 12.9%
Simplified16.3%
Taylor expanded in A around 0 18.9%
mul-1-neg18.9%
*-commutative18.9%
distribute-rgt-neg-in18.9%
*-commutative18.9%
unpow218.9%
unpow218.9%
hypot-def54.1%
Simplified54.1%
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 (* -0.5 (/ (* B B) A)))
(t_2 (* 2.0 (* F t_0)))
(t_3 (sqrt t_2)))
(if (<= C -3.1e-83)
(- (/ (sqrt (* t_2 (fma 2.0 C t_1))) t_0))
(if (<= C -3.3e-300)
(* (sqrt 2.0) (- (sqrt (/ F B))))
(if (<= C 1.86e-112)
(/ (* (sqrt (+ C (+ C t_1))) (- t_3)) t_0)
(if (<= C 1.35e-49)
(* (/ (sqrt 2.0) B) (- (sqrt (* B F))))
(/ (* t_3 (- (sqrt (+ C C)))) 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 = -0.5 * ((B * B) / A);
double t_2 = 2.0 * (F * t_0);
double t_3 = sqrt(t_2);
double tmp;
if (C <= -3.1e-83) {
tmp = -(sqrt((t_2 * fma(2.0, C, t_1))) / t_0);
} else if (C <= -3.3e-300) {
tmp = sqrt(2.0) * -sqrt((F / B));
} else if (C <= 1.86e-112) {
tmp = (sqrt((C + (C + t_1))) * -t_3) / t_0;
} else if (C <= 1.35e-49) {
tmp = (sqrt(2.0) / B) * -sqrt((B * F));
} else {
tmp = (t_3 * -sqrt((C + C))) / 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(-0.5 * Float64(Float64(B * B) / A)) t_2 = Float64(2.0 * Float64(F * t_0)) t_3 = sqrt(t_2) tmp = 0.0 if (C <= -3.1e-83) tmp = Float64(-Float64(sqrt(Float64(t_2 * fma(2.0, C, t_1))) / t_0)); elseif (C <= -3.3e-300) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F / B)))); elseif (C <= 1.86e-112) tmp = Float64(Float64(sqrt(Float64(C + Float64(C + t_1))) * Float64(-t_3)) / t_0); elseif (C <= 1.35e-49) tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(B * F)))); else tmp = Float64(Float64(t_3 * Float64(-sqrt(Float64(C + C)))) / t_0); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[t$95$2], $MachinePrecision]}, If[LessEqual[C, -3.1e-83], (-N[(N[Sqrt[N[(t$95$2 * N[(2.0 * C + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), If[LessEqual[C, -3.3e-300], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F / B), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[C, 1.86e-112], N[(N[(N[Sqrt[N[(C + N[(C + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-t$95$3)), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[C, 1.35e-49], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(B * F), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(t$95$3 * (-N[Sqrt[N[(C + C), $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 := -0.5 \cdot \frac{B \cdot B}{A}\\
t_2 := 2 \cdot \left(F \cdot t_0\right)\\
t_3 := \sqrt{t_2}\\
\mathbf{if}\;C \leq -3.1 \cdot 10^{-83}:\\
\;\;\;\;-\frac{\sqrt{t_2 \cdot \mathsf{fma}\left(2, C, t_1\right)}}{t_0}\\
\mathbf{elif}\;C \leq -3.3 \cdot 10^{-300}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{F}{B}}\right)\\
\mathbf{elif}\;C \leq 1.86 \cdot 10^{-112}:\\
\;\;\;\;\frac{\sqrt{C + \left(C + t_1\right)} \cdot \left(-t_3\right)}{t_0}\\
\mathbf{elif}\;C \leq 1.35 \cdot 10^{-49}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{B \cdot F}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_3 \cdot \left(-\sqrt{C + C}\right)}{t_0}\\
\end{array}
\end{array}
if C < -3.09999999999999992e-83Initial program 8.1%
associate-*l*8.1%
unpow28.1%
+-commutative8.1%
unpow28.1%
associate-*l*8.1%
unpow28.1%
Simplified8.1%
Taylor expanded in A around -inf 7.5%
fma-def7.5%
unpow27.5%
Simplified7.5%
if -3.09999999999999992e-83 < C < -3.3000000000000002e-300Initial program 38.8%
associate-*l*38.8%
unpow238.8%
+-commutative38.8%
unpow238.8%
associate-*l*38.8%
unpow238.8%
Simplified38.8%
Taylor expanded in A around 0 31.6%
unpow231.6%
unpow231.6%
hypot-def30.8%
Simplified30.8%
Taylor expanded in C around 0 21.7%
associate-*r*21.7%
neg-mul-121.7%
Simplified21.7%
if -3.3000000000000002e-300 < C < 1.86e-112Initial program 20.7%
associate-*l*20.7%
unpow220.7%
+-commutative20.7%
unpow220.7%
associate-*l*20.7%
unpow220.7%
Simplified20.7%
sqrt-prod22.9%
*-commutative22.9%
*-commutative22.9%
associate-+l+22.9%
unpow222.9%
hypot-udef27.6%
associate-+r+27.6%
+-commutative27.6%
associate-+r+30.2%
Applied egg-rr30.2%
Taylor expanded in A around -inf 22.8%
unpow222.8%
Simplified22.8%
if 1.86e-112 < C < 1.35e-49Initial program 1.6%
Simplified1.6%
Taylor expanded in C around 0 2.2%
mul-1-neg2.2%
*-commutative2.2%
distribute-rgt-neg-in2.2%
unpow22.2%
unpow22.2%
hypot-def51.2%
Simplified51.2%
Taylor expanded in A around 0 50.3%
if 1.35e-49 < C Initial program 27.1%
associate-*l*27.1%
unpow227.1%
+-commutative27.1%
unpow227.1%
associate-*l*27.1%
unpow227.1%
Simplified27.1%
sqrt-prod33.4%
*-commutative33.4%
*-commutative33.4%
associate-+l+33.4%
unpow233.4%
hypot-udef45.9%
associate-+r+45.9%
+-commutative45.9%
associate-+r+46.8%
Applied egg-rr46.8%
Taylor expanded in A around -inf 46.5%
Final simplification25.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 (* F t_0)) (t_2 (* 2.0 t_1)))
(if (<= A -3.4e-43)
(- (/ (sqrt (* t_2 (fma 2.0 C (* -0.5 (/ (* B B) A))))) t_0))
(if (<= A 1.85e-288)
(* (sqrt (* 2.0 (* t_1 (+ C (+ A (hypot B (- A C))))))) (/ -1.0 t_0))
(/ (* (sqrt t_2) (- (sqrt (+ C C)))) 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 = F * t_0;
double t_2 = 2.0 * t_1;
double tmp;
if (A <= -3.4e-43) {
tmp = -(sqrt((t_2 * fma(2.0, C, (-0.5 * ((B * B) / A))))) / t_0);
} else if (A <= 1.85e-288) {
tmp = sqrt((2.0 * (t_1 * (C + (A + hypot(B, (A - C))))))) * (-1.0 / t_0);
} else {
tmp = (sqrt(t_2) * -sqrt((C + C))) / 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(F * t_0) t_2 = Float64(2.0 * t_1) tmp = 0.0 if (A <= -3.4e-43) tmp = Float64(-Float64(sqrt(Float64(t_2 * fma(2.0, C, Float64(-0.5 * Float64(Float64(B * B) / A))))) / t_0)); elseif (A <= 1.85e-288) tmp = Float64(sqrt(Float64(2.0 * Float64(t_1 * Float64(C + Float64(A + hypot(B, Float64(A - C))))))) * Float64(-1.0 / t_0)); else tmp = Float64(Float64(sqrt(t_2) * Float64(-sqrt(Float64(C + C)))) / t_0); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(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[(2.0 * t$95$1), $MachinePrecision]}, If[LessEqual[A, -3.4e-43], (-N[(N[Sqrt[N[(t$95$2 * N[(2.0 * C + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), If[LessEqual[A, 1.85e-288], N[(N[Sqrt[N[(2.0 * N[(t$95$1 * N[(C + N[(A + N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[t$95$2], $MachinePrecision] * (-N[Sqrt[N[(C + C), $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 := F \cdot t_0\\
t_2 := 2 \cdot t_1\\
\mathbf{if}\;A \leq -3.4 \cdot 10^{-43}:\\
\;\;\;\;-\frac{\sqrt{t_2 \cdot \mathsf{fma}\left(2, C, -0.5 \cdot \frac{B \cdot B}{A}\right)}}{t_0}\\
\mathbf{elif}\;A \leq 1.85 \cdot 10^{-288}:\\
\;\;\;\;\sqrt{2 \cdot \left(t_1 \cdot \left(C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)} \cdot \frac{-1}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{t_2} \cdot \left(-\sqrt{C + C}\right)}{t_0}\\
\end{array}
\end{array}
if A < -3.4000000000000001e-43Initial program 5.7%
associate-*l*5.7%
unpow25.7%
+-commutative5.7%
unpow25.7%
associate-*l*5.7%
unpow25.7%
Simplified5.7%
Taylor expanded in A around -inf 28.3%
fma-def28.3%
unpow228.3%
Simplified28.3%
if -3.4000000000000001e-43 < A < 1.85e-288Initial program 38.3%
associate-*l*38.3%
unpow238.3%
+-commutative38.3%
unpow238.3%
associate-*l*38.3%
unpow238.3%
Simplified38.3%
div-inv38.3%
Applied egg-rr40.2%
if 1.85e-288 < A Initial program 21.0%
associate-*l*21.0%
unpow221.0%
+-commutative21.0%
unpow221.0%
associate-*l*21.0%
unpow221.0%
Simplified21.0%
sqrt-prod26.3%
*-commutative26.3%
*-commutative26.3%
associate-+l+27.0%
unpow227.0%
hypot-udef36.7%
associate-+r+35.0%
+-commutative35.0%
associate-+r+35.0%
Applied egg-rr35.0%
Taylor expanded in A around -inf 9.8%
Final simplification22.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 (<= C -6.5e-116)
(*
(sqrt (* 2.0 (* -8.0 (* A (* F (* C C))))))
(/ -1.0 (fma B B (* C (* A -4.0)))))
(if (or (<= C 2.3e-296) (and (not (<= C 2.75e-111)) (<= C 4.5e-50)))
(* (/ (sqrt 2.0) B) (- (sqrt (* B F))))
(/ (* (sqrt (* 2.0 (* F t_0))) (- (sqrt (+ C C)))) 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 tmp;
if (C <= -6.5e-116) {
tmp = sqrt((2.0 * (-8.0 * (A * (F * (C * C)))))) * (-1.0 / fma(B, B, (C * (A * -4.0))));
} else if ((C <= 2.3e-296) || (!(C <= 2.75e-111) && (C <= 4.5e-50))) {
tmp = (sqrt(2.0) / B) * -sqrt((B * F));
} else {
tmp = (sqrt((2.0 * (F * t_0))) * -sqrt((C + C))) / 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))) tmp = 0.0 if (C <= -6.5e-116) tmp = Float64(sqrt(Float64(2.0 * Float64(-8.0 * Float64(A * Float64(F * Float64(C * C)))))) * Float64(-1.0 / fma(B, B, Float64(C * Float64(A * -4.0))))); elseif ((C <= 2.3e-296) || (!(C <= 2.75e-111) && (C <= 4.5e-50))) tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(B * F)))); else tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(F * t_0))) * Float64(-sqrt(Float64(C + C)))) / t_0); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[C, -6.5e-116], N[(N[Sqrt[N[(2.0 * N[(-8.0 * N[(A * N[(F * N[(C * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[C, 2.3e-296], And[N[Not[LessEqual[C, 2.75e-111]], $MachinePrecision], LessEqual[C, 4.5e-50]]], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(B * F), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(C + C), $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)\\
\mathbf{if}\;C \leq -6.5 \cdot 10^{-116}:\\
\;\;\;\;\sqrt{2 \cdot \left(-8 \cdot \left(A \cdot \left(F \cdot \left(C \cdot C\right)\right)\right)\right)} \cdot \frac{-1}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}\\
\mathbf{elif}\;C \leq 2.3 \cdot 10^{-296} \lor \neg \left(C \leq 2.75 \cdot 10^{-111}\right) \land C \leq 4.5 \cdot 10^{-50}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{B \cdot F}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot t_0\right)} \cdot \left(-\sqrt{C + C}\right)}{t_0}\\
\end{array}
\end{array}
if C < -6.5000000000000001e-116Initial program 10.8%
Simplified13.1%
div-inv13.1%
associate-*l*13.2%
Applied egg-rr13.2%
Simplified10.1%
Taylor expanded in C around inf 7.1%
unpow27.1%
Simplified7.1%
if -6.5000000000000001e-116 < C < 2.30000000000000004e-296 or 2.7499999999999999e-111 < C < 4.49999999999999962e-50Initial program 27.0%
Simplified27.8%
Taylor expanded in C around 0 15.7%
mul-1-neg15.7%
*-commutative15.7%
distribute-rgt-neg-in15.7%
unpow215.7%
unpow215.7%
hypot-def29.8%
Simplified29.8%
Taylor expanded in A around 0 28.1%
if 2.30000000000000004e-296 < C < 2.7499999999999999e-111 or 4.49999999999999962e-50 < C Initial program 25.0%
associate-*l*25.0%
unpow225.0%
+-commutative25.0%
unpow225.0%
associate-*l*25.0%
unpow225.0%
Simplified25.0%
sqrt-prod29.9%
*-commutative29.9%
*-commutative29.9%
associate-+l+29.9%
unpow229.9%
hypot-udef39.6%
associate-+r+39.6%
+-commutative39.6%
associate-+r+41.2%
Applied egg-rr41.2%
Taylor expanded in A around -inf 35.1%
Final simplification23.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 (+ (* B B) (* (* A C) -4.0)))
(t_2 (* 2.0 (* F t_0))))
(if (<= A -2.8e-43)
(- (/ (sqrt (* t_2 (fma 2.0 C (* -0.5 (/ (* B B) A))))) t_0))
(if (<= A 4.6e-288)
(* (sqrt (* 2.0 (* (* F t_1) (+ C (hypot B C))))) (/ -1.0 t_1))
(/ (* (sqrt t_2) (- (sqrt (+ C C)))) 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 = (B * B) + ((A * C) * -4.0);
double t_2 = 2.0 * (F * t_0);
double tmp;
if (A <= -2.8e-43) {
tmp = -(sqrt((t_2 * fma(2.0, C, (-0.5 * ((B * B) / A))))) / t_0);
} else if (A <= 4.6e-288) {
tmp = sqrt((2.0 * ((F * t_1) * (C + hypot(B, C))))) * (-1.0 / t_1);
} else {
tmp = (sqrt(t_2) * -sqrt((C + C))) / 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(Float64(B * B) + Float64(Float64(A * C) * -4.0)) t_2 = Float64(2.0 * Float64(F * t_0)) tmp = 0.0 if (A <= -2.8e-43) tmp = Float64(-Float64(sqrt(Float64(t_2 * fma(2.0, C, Float64(-0.5 * Float64(Float64(B * B) / A))))) / t_0)); elseif (A <= 4.6e-288) tmp = Float64(sqrt(Float64(2.0 * Float64(Float64(F * t_1) * Float64(C + hypot(B, C))))) * Float64(-1.0 / t_1)); else tmp = Float64(Float64(sqrt(t_2) * Float64(-sqrt(Float64(C + C)))) / t_0); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[A, -2.8e-43], (-N[(N[Sqrt[N[(t$95$2 * N[(2.0 * C + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), If[LessEqual[A, 4.6e-288], N[(N[Sqrt[N[(2.0 * N[(N[(F * t$95$1), $MachinePrecision] * N[(C + N[Sqrt[B ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[t$95$2], $MachinePrecision] * (-N[Sqrt[N[(C + C), $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 := B \cdot B + \left(A \cdot C\right) \cdot -4\\
t_2 := 2 \cdot \left(F \cdot t_0\right)\\
\mathbf{if}\;A \leq -2.8 \cdot 10^{-43}:\\
\;\;\;\;-\frac{\sqrt{t_2 \cdot \mathsf{fma}\left(2, C, -0.5 \cdot \frac{B \cdot B}{A}\right)}}{t_0}\\
\mathbf{elif}\;A \leq 4.6 \cdot 10^{-288}:\\
\;\;\;\;\sqrt{2 \cdot \left(\left(F \cdot t_1\right) \cdot \left(C + \mathsf{hypot}\left(B, C\right)\right)\right)} \cdot \frac{-1}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{t_2} \cdot \left(-\sqrt{C + C}\right)}{t_0}\\
\end{array}
\end{array}
if A < -2.7999999999999998e-43Initial program 5.7%
associate-*l*5.7%
unpow25.7%
+-commutative5.7%
unpow25.7%
associate-*l*5.7%
unpow25.7%
Simplified5.7%
Taylor expanded in A around -inf 28.3%
fma-def28.3%
unpow228.3%
Simplified28.3%
if -2.7999999999999998e-43 < A < 4.6e-288Initial program 38.3%
associate-*l*38.3%
unpow238.3%
+-commutative38.3%
unpow238.3%
associate-*l*38.3%
unpow238.3%
Simplified38.3%
Taylor expanded in A around 0 38.3%
unpow238.3%
unpow238.3%
hypot-def40.2%
Simplified40.2%
div-inv40.2%
associate-*l*40.2%
*-commutative40.2%
cancel-sign-sub-inv40.2%
metadata-eval40.2%
*-commutative40.2%
cancel-sign-sub-inv40.2%
metadata-eval40.2%
*-commutative40.2%
Applied egg-rr40.2%
if 4.6e-288 < A Initial program 21.0%
associate-*l*21.0%
unpow221.0%
+-commutative21.0%
unpow221.0%
associate-*l*21.0%
unpow221.0%
Simplified21.0%
sqrt-prod26.3%
*-commutative26.3%
*-commutative26.3%
associate-+l+27.0%
unpow227.0%
hypot-udef36.7%
associate-+r+35.0%
+-commutative35.0%
associate-+r+35.0%
Applied egg-rr35.0%
Taylor expanded in A around -inf 9.8%
Final simplification22.1%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B -5.9e+31)
(* 2.0 (* (sqrt (* C F)) (/ 1.0 B)))
(if (<= B 2e-30)
(/
(- (sqrt (* 2.0 (* F (* (* 2.0 C) (fma B B (* (* A C) -4.0)))))))
(- (* B B) (* 4.0 (* A C))))
(* (/ (sqrt 2.0) B) (- (sqrt (* B F)))))))assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= -5.9e+31) {
tmp = 2.0 * (sqrt((C * F)) * (1.0 / B));
} else if (B <= 2e-30) {
tmp = -sqrt((2.0 * (F * ((2.0 * C) * fma(B, B, ((A * C) * -4.0)))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = (sqrt(2.0) / B) * -sqrt((B * F));
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= -5.9e+31) tmp = Float64(2.0 * Float64(sqrt(Float64(C * F)) * Float64(1.0 / B))); elseif (B <= 2e-30) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(F * Float64(Float64(2.0 * C) * fma(B, B, Float64(Float64(A * C) * -4.0))))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(B * F)))); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, -5.9e+31], N[(2.0 * N[(N[Sqrt[N[(C * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 2e-30], N[((-N[Sqrt[N[(2.0 * N[(F * N[(N[(2.0 * C), $MachinePrecision] * N[(B * B + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(B * F), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq -5.9 \cdot 10^{+31}:\\
\;\;\;\;2 \cdot \left(\sqrt{C \cdot F} \cdot \frac{1}{B}\right)\\
\mathbf{elif}\;B \leq 2 \cdot 10^{-30}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(\left(2 \cdot C\right) \cdot \mathsf{fma}\left(B, B, \left(A \cdot C\right) \cdot -4\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{B \cdot F}\right)\\
\end{array}
\end{array}
if B < -5.9000000000000004e31Initial program 9.6%
associate-*l*9.6%
unpow29.6%
+-commutative9.6%
unpow29.6%
associate-*l*9.6%
unpow29.6%
Simplified9.6%
Taylor expanded in A around -inf 2.5%
Taylor expanded in B around -inf 3.8%
if -5.9000000000000004e31 < B < 2e-30Initial program 26.5%
associate-*l*26.5%
unpow226.5%
+-commutative26.5%
unpow226.5%
associate-*l*26.5%
unpow226.5%
Simplified26.5%
Taylor expanded in A around -inf 23.2%
*-un-lft-identity23.2%
associate-*l*23.2%
*-commutative23.2%
cancel-sign-sub-inv23.2%
metadata-eval23.2%
*-commutative23.2%
Applied egg-rr23.2%
*-lft-identity23.2%
associate-*l*22.8%
fma-def22.8%
Simplified22.8%
if 2e-30 < B Initial program 16.5%
Simplified21.0%
Taylor expanded in C around 0 19.3%
mul-1-neg19.3%
*-commutative19.3%
distribute-rgt-neg-in19.3%
unpow219.3%
unpow219.3%
hypot-def50.4%
Simplified50.4%
Taylor expanded in A around 0 47.2%
Final simplification24.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)))))
(if (<= B -1.6e+31)
(* 2.0 (* (sqrt (* C F)) (/ 1.0 B)))
(if (<= B 2.4e-35)
(/ (- (sqrt (* (* 2.0 (* F t_0)) (* 2.0 C)))) t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* B F))))))))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.6e+31) {
tmp = 2.0 * (sqrt((C * F)) * (1.0 / B));
} else if (B <= 2.4e-35) {
tmp = -sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((B * F));
}
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 <= (-1.6d+31)) then
tmp = 2.0d0 * (sqrt((c * f)) * (1.0d0 / b))
else if (b <= 2.4d-35) then
tmp = -sqrt(((2.0d0 * (f * t_0)) * (2.0d0 * c))) / t_0
else
tmp = (sqrt(2.0d0) / b) * -sqrt((b * f))
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 <= -1.6e+31) {
tmp = 2.0 * (Math.sqrt((C * F)) * (1.0 / B));
} else if (B <= 2.4e-35) {
tmp = -Math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((B * F));
}
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 <= -1.6e+31: tmp = 2.0 * (math.sqrt((C * F)) * (1.0 / B)) elif B <= 2.4e-35: tmp = -math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((B * F)) 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 <= -1.6e+31) tmp = Float64(2.0 * Float64(sqrt(Float64(C * F)) * Float64(1.0 / B))); elseif (B <= 2.4e-35) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * Float64(2.0 * C)))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(B * F)))); 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 <= -1.6e+31)
tmp = 2.0 * (sqrt((C * F)) * (1.0 / B));
elseif (B <= 2.4e-35)
tmp = -sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
else
tmp = (sqrt(2.0) / B) * -sqrt((B * F));
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, -1.6e+31], N[(2.0 * N[(N[Sqrt[N[(C * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 2.4e-35], N[((-N[Sqrt[N[(N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(B * F), $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 -1.6 \cdot 10^{+31}:\\
\;\;\;\;2 \cdot \left(\sqrt{C \cdot F} \cdot \frac{1}{B}\right)\\
\mathbf{elif}\;B \leq 2.4 \cdot 10^{-35}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(F \cdot t_0\right)\right) \cdot \left(2 \cdot C\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{B \cdot F}\right)\\
\end{array}
\end{array}
if B < -1.6e31Initial program 9.6%
associate-*l*9.6%
unpow29.6%
+-commutative9.6%
unpow29.6%
associate-*l*9.6%
unpow29.6%
Simplified9.6%
Taylor expanded in A around -inf 2.5%
Taylor expanded in B around -inf 3.8%
if -1.6e31 < B < 2.4000000000000001e-35Initial program 26.6%
associate-*l*26.6%
unpow226.6%
+-commutative26.6%
unpow226.6%
associate-*l*26.6%
unpow226.6%
Simplified26.6%
Taylor expanded in A around -inf 23.4%
if 2.4000000000000001e-35 < B Initial program 16.3%
Simplified20.8%
Taylor expanded in C around 0 19.1%
mul-1-neg19.1%
*-commutative19.1%
distribute-rgt-neg-in19.1%
unpow219.1%
unpow219.1%
hypot-def49.8%
Simplified49.8%
Taylor expanded in A around 0 46.5%
Final simplification25.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 -3e+32)
(* 2.0 (* (sqrt (* C F)) (/ 1.0 B)))
(if (<= B 8.5e-35)
(/ (- (sqrt (* (* 2.0 (* F t_0)) (* 2.0 C)))) t_0)
(* (sqrt 2.0) (- (sqrt (/ F 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 <= -3e+32) {
tmp = 2.0 * (sqrt((C * F)) * (1.0 / B));
} else if (B <= 8.5e-35) {
tmp = -sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
} else {
tmp = sqrt(2.0) * -sqrt((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) :: t_0
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (a * c))
if (b <= (-3d+32)) then
tmp = 2.0d0 * (sqrt((c * f)) * (1.0d0 / b))
else if (b <= 8.5d-35) then
tmp = -sqrt(((2.0d0 * (f * t_0)) * (2.0d0 * c))) / t_0
else
tmp = sqrt(2.0d0) * -sqrt((f / 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 <= -3e+32) {
tmp = 2.0 * (Math.sqrt((C * F)) * (1.0 / B));
} else if (B <= 8.5e-35) {
tmp = -Math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((F / 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 <= -3e+32: tmp = 2.0 * (math.sqrt((C * F)) * (1.0 / B)) elif B <= 8.5e-35: tmp = -math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0 else: tmp = math.sqrt(2.0) * -math.sqrt((F / 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 <= -3e+32) tmp = Float64(2.0 * Float64(sqrt(Float64(C * F)) * Float64(1.0 / B))); elseif (B <= 8.5e-35) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * Float64(2.0 * C)))) / t_0); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F / 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 <= -3e+32)
tmp = 2.0 * (sqrt((C * F)) * (1.0 / B));
elseif (B <= 8.5e-35)
tmp = -sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
else
tmp = sqrt(2.0) * -sqrt((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_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -3e+32], N[(2.0 * N[(N[Sqrt[N[(C * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 8.5e-35], N[((-N[Sqrt[N[(N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F / B), $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 \cdot 10^{+32}:\\
\;\;\;\;2 \cdot \left(\sqrt{C \cdot F} \cdot \frac{1}{B}\right)\\
\mathbf{elif}\;B \leq 8.5 \cdot 10^{-35}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(F \cdot t_0\right)\right) \cdot \left(2 \cdot C\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{F}{B}}\right)\\
\end{array}
\end{array}
if B < -3e32Initial program 9.6%
associate-*l*9.6%
unpow29.6%
+-commutative9.6%
unpow29.6%
associate-*l*9.6%
unpow29.6%
Simplified9.6%
Taylor expanded in A around -inf 2.5%
Taylor expanded in B around -inf 3.8%
if -3e32 < B < 8.5000000000000001e-35Initial program 26.6%
associate-*l*26.6%
unpow226.6%
+-commutative26.6%
unpow226.6%
associate-*l*26.6%
unpow226.6%
Simplified26.6%
Taylor expanded in A around -inf 23.4%
if 8.5000000000000001e-35 < B Initial program 16.3%
associate-*l*16.3%
unpow216.3%
+-commutative16.3%
unpow216.3%
associate-*l*16.3%
unpow216.3%
Simplified16.3%
Taylor expanded in A around 0 16.9%
unpow216.9%
unpow216.9%
hypot-def18.5%
Simplified18.5%
Taylor expanded in C around 0 45.3%
associate-*r*45.3%
neg-mul-145.3%
Simplified45.3%
Final simplification24.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 (* 2.0 (* F t_0))))
(if (<= B -3e+32)
(* 2.0 (* (sqrt (* C F)) (/ 1.0 B)))
(if (<= B 4.4e-36)
(/ (- (sqrt (* t_1 (* 2.0 C)))) t_0)
(/ (- (sqrt (* t_1 (+ B (+ A C))))) 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 = 2.0 * (F * t_0);
double tmp;
if (B <= -3e+32) {
tmp = 2.0 * (sqrt((C * F)) * (1.0 / B));
} else if (B <= 4.4e-36) {
tmp = -sqrt((t_1 * (2.0 * C))) / t_0;
} else {
tmp = -sqrt((t_1 * (B + (A + C)))) / 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 = 2.0d0 * (f * t_0)
if (b <= (-3d+32)) then
tmp = 2.0d0 * (sqrt((c * f)) * (1.0d0 / b))
else if (b <= 4.4d-36) then
tmp = -sqrt((t_1 * (2.0d0 * c))) / t_0
else
tmp = -sqrt((t_1 * (b + (a + c)))) / 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 = 2.0 * (F * t_0);
double tmp;
if (B <= -3e+32) {
tmp = 2.0 * (Math.sqrt((C * F)) * (1.0 / B));
} else if (B <= 4.4e-36) {
tmp = -Math.sqrt((t_1 * (2.0 * C))) / t_0;
} else {
tmp = -Math.sqrt((t_1 * (B + (A + C)))) / 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 = 2.0 * (F * t_0) tmp = 0 if B <= -3e+32: tmp = 2.0 * (math.sqrt((C * F)) * (1.0 / B)) elif B <= 4.4e-36: tmp = -math.sqrt((t_1 * (2.0 * C))) / t_0 else: tmp = -math.sqrt((t_1 * (B + (A + C)))) / 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(2.0 * Float64(F * t_0)) tmp = 0.0 if (B <= -3e+32) tmp = Float64(2.0 * Float64(sqrt(Float64(C * F)) * Float64(1.0 / B))); elseif (B <= 4.4e-36) tmp = Float64(Float64(-sqrt(Float64(t_1 * Float64(2.0 * C)))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(t_1 * Float64(B + Float64(A + C))))) / 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 = 2.0 * (F * t_0);
tmp = 0.0;
if (B <= -3e+32)
tmp = 2.0 * (sqrt((C * F)) * (1.0 / B));
elseif (B <= 4.4e-36)
tmp = -sqrt((t_1 * (2.0 * C))) / t_0;
else
tmp = -sqrt((t_1 * (B + (A + C)))) / 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[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -3e+32], N[(2.0 * N[(N[Sqrt[N[(C * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 4.4e-36], N[((-N[Sqrt[N[(t$95$1 * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(t$95$1 * N[(B + N[(A + C), $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 := 2 \cdot \left(F \cdot t_0\right)\\
\mathbf{if}\;B \leq -3 \cdot 10^{+32}:\\
\;\;\;\;2 \cdot \left(\sqrt{C \cdot F} \cdot \frac{1}{B}\right)\\
\mathbf{elif}\;B \leq 4.4 \cdot 10^{-36}:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \left(2 \cdot C\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \left(B + \left(A + C\right)\right)}}{t_0}\\
\end{array}
\end{array}
if B < -3e32Initial program 9.6%
associate-*l*9.6%
unpow29.6%
+-commutative9.6%
unpow29.6%
associate-*l*9.6%
unpow29.6%
Simplified9.6%
Taylor expanded in A around -inf 2.5%
Taylor expanded in B around -inf 3.8%
if -3e32 < B < 4.3999999999999999e-36Initial program 26.8%
associate-*l*26.8%
unpow226.8%
+-commutative26.8%
unpow226.8%
associate-*l*26.8%
unpow226.8%
Simplified26.8%
Taylor expanded in A around -inf 23.5%
if 4.3999999999999999e-36 < B Initial program 16.1%
associate-*l*16.1%
unpow216.1%
+-commutative16.1%
unpow216.1%
associate-*l*16.1%
unpow216.1%
Simplified16.1%
Taylor expanded in B around inf 15.8%
associate-+r+15.8%
Simplified15.8%
Final simplification17.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 (* C F)) (/ 1.0 B))) (t_1 (- (* B B) (* 4.0 (* A C)))))
(if (<= B -2.75e+32)
(* 2.0 t_0)
(if (<= B 13500000.0)
(/ (- (sqrt (* (* 2.0 (* F t_1)) (* 2.0 C)))) t_1)
(* t_0 -2.0)))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt((C * F)) * (1.0 / B);
double t_1 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= -2.75e+32) {
tmp = 2.0 * t_0;
} else if (B <= 13500000.0) {
tmp = -sqrt(((2.0 * (F * t_1)) * (2.0 * C))) / t_1;
} else {
tmp = t_0 * -2.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 = sqrt((c * f)) * (1.0d0 / b)
t_1 = (b * b) - (4.0d0 * (a * c))
if (b <= (-2.75d+32)) then
tmp = 2.0d0 * t_0
else if (b <= 13500000.0d0) then
tmp = -sqrt(((2.0d0 * (f * t_1)) * (2.0d0 * c))) / t_1
else
tmp = t_0 * (-2.0d0)
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((C * F)) * (1.0 / B);
double t_1 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= -2.75e+32) {
tmp = 2.0 * t_0;
} else if (B <= 13500000.0) {
tmp = -Math.sqrt(((2.0 * (F * t_1)) * (2.0 * C))) / t_1;
} else {
tmp = t_0 * -2.0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt((C * F)) * (1.0 / B) t_1 = (B * B) - (4.0 * (A * C)) tmp = 0 if B <= -2.75e+32: tmp = 2.0 * t_0 elif B <= 13500000.0: tmp = -math.sqrt(((2.0 * (F * t_1)) * (2.0 * C))) / t_1 else: tmp = t_0 * -2.0 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(sqrt(Float64(C * F)) * Float64(1.0 / B)) t_1 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= -2.75e+32) tmp = Float64(2.0 * t_0); elseif (B <= 13500000.0) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_1)) * Float64(2.0 * C)))) / t_1); else tmp = Float64(t_0 * -2.0); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt((C * F)) * (1.0 / B);
t_1 = (B * B) - (4.0 * (A * C));
tmp = 0.0;
if (B <= -2.75e+32)
tmp = 2.0 * t_0;
elseif (B <= 13500000.0)
tmp = -sqrt(((2.0 * (F * t_1)) * (2.0 * C))) / t_1;
else
tmp = t_0 * -2.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[Sqrt[N[(C * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -2.75e+32], N[(2.0 * t$95$0), $MachinePrecision], If[LessEqual[B, 13500000.0], N[((-N[Sqrt[N[(N[(2.0 * N[(F * t$95$1), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[(t$95$0 * -2.0), $MachinePrecision]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{C \cdot F} \cdot \frac{1}{B}\\
t_1 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq -2.75 \cdot 10^{+32}:\\
\;\;\;\;2 \cdot t_0\\
\mathbf{elif}\;B \leq 13500000:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(F \cdot t_1\right)\right) \cdot \left(2 \cdot C\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot -2\\
\end{array}
\end{array}
if B < -2.74999999999999992e32Initial program 9.6%
associate-*l*9.6%
unpow29.6%
+-commutative9.6%
unpow29.6%
associate-*l*9.6%
unpow29.6%
Simplified9.6%
Taylor expanded in A around -inf 2.5%
Taylor expanded in B around -inf 3.8%
if -2.74999999999999992e32 < B < 1.35e7Initial program 26.8%
associate-*l*26.8%
unpow226.8%
+-commutative26.8%
unpow226.8%
associate-*l*26.8%
unpow226.8%
Simplified26.8%
Taylor expanded in A around -inf 23.5%
if 1.35e7 < B Initial program 14.4%
associate-*l*14.4%
unpow214.4%
+-commutative14.4%
unpow214.4%
associate-*l*14.4%
unpow214.4%
Simplified14.4%
Taylor expanded in A around -inf 1.1%
Taylor expanded in B around inf 8.7%
Final simplification15.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 (* C F)) (/ 1.0 B))))
(if (<= B -3e+32)
(* 2.0 t_0)
(if (<= B 180000000.0)
(/
(- (sqrt (* 4.0 (* C (* F (+ (* B B) (* (* A C) -4.0)))))))
(- (* B B) (* 4.0 (* A C))))
(* t_0 -2.0)))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt((C * F)) * (1.0 / B);
double tmp;
if (B <= -3e+32) {
tmp = 2.0 * t_0;
} else if (B <= 180000000.0) {
tmp = -sqrt((4.0 * (C * (F * ((B * B) + ((A * C) * -4.0)))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = t_0 * -2.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) :: tmp
t_0 = sqrt((c * f)) * (1.0d0 / b)
if (b <= (-3d+32)) then
tmp = 2.0d0 * t_0
else if (b <= 180000000.0d0) then
tmp = -sqrt((4.0d0 * (c * (f * ((b * b) + ((a * c) * (-4.0d0))))))) / ((b * b) - (4.0d0 * (a * c)))
else
tmp = t_0 * (-2.0d0)
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((C * F)) * (1.0 / B);
double tmp;
if (B <= -3e+32) {
tmp = 2.0 * t_0;
} else if (B <= 180000000.0) {
tmp = -Math.sqrt((4.0 * (C * (F * ((B * B) + ((A * C) * -4.0)))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = t_0 * -2.0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt((C * F)) * (1.0 / B) tmp = 0 if B <= -3e+32: tmp = 2.0 * t_0 elif B <= 180000000.0: tmp = -math.sqrt((4.0 * (C * (F * ((B * B) + ((A * C) * -4.0)))))) / ((B * B) - (4.0 * (A * C))) else: tmp = t_0 * -2.0 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(sqrt(Float64(C * F)) * Float64(1.0 / B)) tmp = 0.0 if (B <= -3e+32) tmp = Float64(2.0 * t_0); elseif (B <= 180000000.0) tmp = Float64(Float64(-sqrt(Float64(4.0 * Float64(C * Float64(F * Float64(Float64(B * B) + Float64(Float64(A * C) * -4.0))))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(t_0 * -2.0); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt((C * F)) * (1.0 / B);
tmp = 0.0;
if (B <= -3e+32)
tmp = 2.0 * t_0;
elseif (B <= 180000000.0)
tmp = -sqrt((4.0 * (C * (F * ((B * B) + ((A * C) * -4.0)))))) / ((B * B) - (4.0 * (A * C)));
else
tmp = t_0 * -2.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[Sqrt[N[(C * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -3e+32], N[(2.0 * t$95$0), $MachinePrecision], If[LessEqual[B, 180000000.0], N[((-N[Sqrt[N[(4.0 * N[(C * N[(F * N[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * -2.0), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{C \cdot F} \cdot \frac{1}{B}\\
\mathbf{if}\;B \leq -3 \cdot 10^{+32}:\\
\;\;\;\;2 \cdot t_0\\
\mathbf{elif}\;B \leq 180000000:\\
\;\;\;\;\frac{-\sqrt{4 \cdot \left(C \cdot \left(F \cdot \left(B \cdot B + \left(A \cdot C\right) \cdot -4\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot -2\\
\end{array}
\end{array}
if B < -3e32Initial program 9.6%
associate-*l*9.6%
unpow29.6%
+-commutative9.6%
unpow29.6%
associate-*l*9.6%
unpow29.6%
Simplified9.6%
Taylor expanded in A around -inf 2.5%
Taylor expanded in B around -inf 3.8%
if -3e32 < B < 1.8e8Initial program 26.8%
associate-*l*26.8%
unpow226.8%
+-commutative26.8%
unpow226.8%
associate-*l*26.8%
unpow226.8%
Simplified26.8%
Taylor expanded in A around -inf 23.5%
Taylor expanded in F around 0 23.5%
cancel-sign-sub-inv23.5%
metadata-eval23.5%
unpow223.5%
Simplified23.5%
if 1.8e8 < B Initial program 14.4%
associate-*l*14.4%
unpow214.4%
+-commutative14.4%
unpow214.4%
associate-*l*14.4%
unpow214.4%
Simplified14.4%
Taylor expanded in A around -inf 1.1%
Taylor expanded in B around inf 8.7%
Final simplification15.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 (* C F)) (/ 1.0 B))))
(if (<= B -1.55e+25)
(* 2.0 t_0)
(if (<= B 7.2e-57)
(- (/ (sqrt (* (* A (* F (* C C))) -16.0)) (- (* B B) (* 4.0 (* A C)))))
(* t_0 -2.0)))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt((C * F)) * (1.0 / B);
double tmp;
if (B <= -1.55e+25) {
tmp = 2.0 * t_0;
} else if (B <= 7.2e-57) {
tmp = -(sqrt(((A * (F * (C * C))) * -16.0)) / ((B * B) - (4.0 * (A * C))));
} else {
tmp = t_0 * -2.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) :: tmp
t_0 = sqrt((c * f)) * (1.0d0 / b)
if (b <= (-1.55d+25)) then
tmp = 2.0d0 * t_0
else if (b <= 7.2d-57) then
tmp = -(sqrt(((a * (f * (c * c))) * (-16.0d0))) / ((b * b) - (4.0d0 * (a * c))))
else
tmp = t_0 * (-2.0d0)
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((C * F)) * (1.0 / B);
double tmp;
if (B <= -1.55e+25) {
tmp = 2.0 * t_0;
} else if (B <= 7.2e-57) {
tmp = -(Math.sqrt(((A * (F * (C * C))) * -16.0)) / ((B * B) - (4.0 * (A * C))));
} else {
tmp = t_0 * -2.0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt((C * F)) * (1.0 / B) tmp = 0 if B <= -1.55e+25: tmp = 2.0 * t_0 elif B <= 7.2e-57: tmp = -(math.sqrt(((A * (F * (C * C))) * -16.0)) / ((B * B) - (4.0 * (A * C)))) else: tmp = t_0 * -2.0 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(sqrt(Float64(C * F)) * Float64(1.0 / B)) tmp = 0.0 if (B <= -1.55e+25) tmp = Float64(2.0 * t_0); elseif (B <= 7.2e-57) tmp = Float64(-Float64(sqrt(Float64(Float64(A * Float64(F * Float64(C * C))) * -16.0)) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))))); else tmp = Float64(t_0 * -2.0); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt((C * F)) * (1.0 / B);
tmp = 0.0;
if (B <= -1.55e+25)
tmp = 2.0 * t_0;
elseif (B <= 7.2e-57)
tmp = -(sqrt(((A * (F * (C * C))) * -16.0)) / ((B * B) - (4.0 * (A * C))));
else
tmp = t_0 * -2.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[Sqrt[N[(C * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -1.55e+25], N[(2.0 * t$95$0), $MachinePrecision], If[LessEqual[B, 7.2e-57], (-N[(N[Sqrt[N[(N[(A * N[(F * N[(C * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -16.0), $MachinePrecision]], $MachinePrecision] / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(t$95$0 * -2.0), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{C \cdot F} \cdot \frac{1}{B}\\
\mathbf{if}\;B \leq -1.55 \cdot 10^{+25}:\\
\;\;\;\;2 \cdot t_0\\
\mathbf{elif}\;B \leq 7.2 \cdot 10^{-57}:\\
\;\;\;\;-\frac{\sqrt{\left(A \cdot \left(F \cdot \left(C \cdot C\right)\right)\right) \cdot -16}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot -2\\
\end{array}
\end{array}
if B < -1.5499999999999999e25Initial program 11.1%
associate-*l*11.1%
unpow211.1%
+-commutative11.1%
unpow211.1%
associate-*l*11.1%
unpow211.1%
Simplified11.1%
Taylor expanded in A around -inf 2.7%
Taylor expanded in B around -inf 3.9%
if -1.5499999999999999e25 < B < 7.2000000000000005e-57Initial program 26.2%
associate-*l*26.2%
unpow226.2%
+-commutative26.2%
unpow226.2%
associate-*l*26.2%
unpow226.2%
Simplified26.2%
Taylor expanded in A around -inf 22.9%
Taylor expanded in B around 0 20.7%
unpow220.7%
Simplified20.7%
if 7.2000000000000005e-57 < B Initial program 16.9%
associate-*l*16.9%
unpow216.9%
+-commutative16.9%
unpow216.9%
associate-*l*16.9%
unpow216.9%
Simplified16.9%
Taylor expanded in A around -inf 6.6%
Taylor expanded in B around inf 7.5%
Final simplification13.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 (* (sqrt (* C F)) (/ 1.0 B)))) (if (<= B -5e-311) (* 2.0 t_0) (* t_0 -2.0))))
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt((C * F)) * (1.0 / B);
double tmp;
if (B <= -5e-311) {
tmp = 2.0 * t_0;
} else {
tmp = t_0 * -2.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) :: tmp
t_0 = sqrt((c * f)) * (1.0d0 / b)
if (b <= (-5d-311)) then
tmp = 2.0d0 * t_0
else
tmp = t_0 * (-2.0d0)
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((C * F)) * (1.0 / B);
double tmp;
if (B <= -5e-311) {
tmp = 2.0 * t_0;
} else {
tmp = t_0 * -2.0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt((C * F)) * (1.0 / B) tmp = 0 if B <= -5e-311: tmp = 2.0 * t_0 else: tmp = t_0 * -2.0 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(sqrt(Float64(C * F)) * Float64(1.0 / B)) tmp = 0.0 if (B <= -5e-311) tmp = Float64(2.0 * t_0); else tmp = Float64(t_0 * -2.0); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt((C * F)) * (1.0 / B);
tmp = 0.0;
if (B <= -5e-311)
tmp = 2.0 * t_0;
else
tmp = t_0 * -2.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[Sqrt[N[(C * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -5e-311], N[(2.0 * t$95$0), $MachinePrecision], N[(t$95$0 * -2.0), $MachinePrecision]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{C \cdot F} \cdot \frac{1}{B}\\
\mathbf{if}\;B \leq -5 \cdot 10^{-311}:\\
\;\;\;\;2 \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot -2\\
\end{array}
\end{array}
if B < -5.00000000000023e-311Initial program 19.6%
associate-*l*19.6%
unpow219.6%
+-commutative19.6%
unpow219.6%
associate-*l*19.6%
unpow219.6%
Simplified19.6%
Taylor expanded in A around -inf 9.2%
Taylor expanded in B around -inf 3.0%
if -5.00000000000023e-311 < B Initial program 20.6%
associate-*l*20.6%
unpow220.6%
+-commutative20.6%
unpow220.6%
associate-*l*20.6%
unpow220.6%
Simplified20.6%
Taylor expanded in A around -inf 17.9%
Taylor expanded in B around inf 5.6%
Final simplification4.3%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* (* (sqrt (* C F)) (/ 1.0 B)) -2.0))
assert(A < C);
double code(double A, double B, double C, double F) {
return (sqrt((C * F)) * (1.0 / B)) * -2.0;
}
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (sqrt((c * f)) * (1.0d0 / b)) * (-2.0d0)
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
return (Math.sqrt((C * F)) * (1.0 / B)) * -2.0;
}
[A, C] = sort([A, C]) def code(A, B, C, F): return (math.sqrt((C * F)) * (1.0 / B)) * -2.0
A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(sqrt(Float64(C * F)) * Float64(1.0 / B)) * -2.0) end
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = (sqrt((C * F)) * (1.0 / B)) * -2.0;
end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(N[(N[Sqrt[N[(C * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\left(\sqrt{C \cdot F} \cdot \frac{1}{B}\right) \cdot -2
\end{array}
Initial program 20.1%
associate-*l*20.1%
unpow220.1%
+-commutative20.1%
unpow220.1%
associate-*l*20.1%
unpow220.1%
Simplified20.1%
Taylor expanded in A around -inf 13.7%
Taylor expanded in B around inf 3.4%
Final simplification3.4%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* (/ 2.0 B) (- (sqrt (* A F)))))
assert(A < C);
double code(double A, double B, double C, double F) {
return (2.0 / B) * -sqrt((A * F));
}
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 / b) * -sqrt((a * f))
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
return (2.0 / B) * -Math.sqrt((A * F));
}
[A, C] = sort([A, C]) def code(A, B, C, F): return (2.0 / B) * -math.sqrt((A * F))
A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(2.0 / B) * Float64(-sqrt(Float64(A * F)))) end
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = (2.0 / B) * -sqrt((A * F));
end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(N[(2.0 / B), $MachinePrecision] * (-N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{2}{B} \cdot \left(-\sqrt{A \cdot F}\right)
\end{array}
Initial program 20.1%
Simplified22.8%
Taylor expanded in C around 0 7.9%
mul-1-neg7.9%
*-commutative7.9%
distribute-rgt-neg-in7.9%
unpow27.9%
unpow27.9%
hypot-def16.4%
Simplified16.4%
Taylor expanded in B around 0 3.1%
mul-1-neg3.1%
unpow23.1%
rem-square-sqrt3.2%
Simplified3.2%
Final simplification3.2%
herbie shell --seed 2023193
(FPCore (A B C F)
:name "ABCF->ab-angle a"
: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))))