
(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 16 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 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_1 (* 2.0 (* t_0 F)))
(t_2
(/
(-
(sqrt (* t_1 (+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_0)))
(if (<= t_2 -2e-198)
(/
(*
(sqrt (* 2.0 (* F (- (* B B) (* 4.0 (* A C))))))
(- (sqrt (+ C (hypot B C)))))
t_0)
(if (<= t_2 2e+123)
(/ (- (sqrt (* t_1 (fma 2.0 C (* -0.5 (/ (* B B) A)))))) t_0)
(if (<= t_2 INFINITY)
(/
(-
(pow
(exp (* 0.25 (+ (* -2.0 (log (/ 1.0 C))) (log (* -16.0 (* A F))))))
2.0))
t_0)
(* (/ (sqrt 2.0) B) (* (sqrt F) (- (sqrt (+ A (hypot B A)))))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
double t_1 = 2.0 * (t_0 * F);
double t_2 = -sqrt((t_1 * ((A + C) + sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_0;
double tmp;
if (t_2 <= -2e-198) {
tmp = (sqrt((2.0 * (F * ((B * B) - (4.0 * (A * C)))))) * -sqrt((C + hypot(B, C)))) / t_0;
} else if (t_2 <= 2e+123) {
tmp = -sqrt((t_1 * fma(2.0, C, (-0.5 * ((B * B) / A))))) / t_0;
} else if (t_2 <= ((double) INFINITY)) {
tmp = -pow(exp((0.25 * ((-2.0 * log((1.0 / C))) + log((-16.0 * (A * F)))))), 2.0) / t_0;
} else {
tmp = (sqrt(2.0) / B) * (sqrt(F) * -sqrt((A + hypot(B, A))));
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_1 = Float64(2.0 * Float64(t_0 * F)) t_2 = Float64(Float64(-sqrt(Float64(t_1 * Float64(Float64(A + C) + sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_0) tmp = 0.0 if (t_2 <= -2e-198) tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(F * Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))))) * Float64(-sqrt(Float64(C + hypot(B, C))))) / t_0); elseif (t_2 <= 2e+123) tmp = Float64(Float64(-sqrt(Float64(t_1 * fma(2.0, C, Float64(-0.5 * Float64(Float64(B * B) / A)))))) / t_0); elseif (t_2 <= Inf) tmp = Float64(Float64(-(exp(Float64(0.25 * Float64(Float64(-2.0 * log(Float64(1.0 / C))) + log(Float64(-16.0 * Float64(A * F)))))) ^ 2.0)) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(sqrt(F) * Float64(-sqrt(Float64(A + hypot(B, A)))))); 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[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[((-N[Sqrt[N[(t$95$1 * 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$0), $MachinePrecision]}, If[LessEqual[t$95$2, -2e-198], N[(N[(N[Sqrt[N[(2.0 * N[(F * N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(C + N[Sqrt[B ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[t$95$2, 2e+123], 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], If[LessEqual[t$95$2, Infinity], N[((-N[Power[N[Exp[N[(0.25 * N[(N[(-2.0 * N[Log[N[(1.0 / C), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[Log[N[(-16.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * N[(N[Sqrt[F], $MachinePrecision] * (-N[Sqrt[N[(A + N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_1 := 2 \cdot \left(t_0 \cdot F\right)\\
t_2 := \frac{-\sqrt{t_1 \cdot \left(\left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_0}\\
\mathbf{if}\;t_2 \leq -2 \cdot 10^{-198}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right)\right)} \cdot \left(-\sqrt{C + \mathsf{hypot}\left(B, C\right)}\right)}{t_0}\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+123}:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \mathsf{fma}\left(2, C, -0.5 \cdot \frac{B \cdot B}{A}\right)}}{t_0}\\
\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\frac{-{\left(e^{0.25 \cdot \left(-2 \cdot \log \left(\frac{1}{C}\right) + \log \left(-16 \cdot \left(A \cdot F\right)\right)\right)}\right)}^{2}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(\sqrt{F} \cdot \left(-\sqrt{A + \mathsf{hypot}\left(B, A\right)}\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))) < -1.9999999999999998e-198Initial program 47.0%
Taylor expanded in A around 0 42.6%
unpow242.6%
unpow242.6%
hypot-def46.8%
Simplified46.8%
sqrt-prod57.1%
unpow257.1%
associate-*l*57.1%
Applied egg-rr57.1%
if -1.9999999999999998e-198 < (/.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))) < 1.99999999999999996e123Initial program 21.3%
Taylor expanded in A around -inf 22.5%
fma-def22.5%
unpow222.5%
Simplified22.5%
if 1.99999999999999996e123 < (/.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.7%
add-sqr-sqrt3.7%
pow23.7%
Applied egg-rr11.4%
Taylor expanded in C around inf 20.9%
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%
Taylor expanded in C around 0 2.3%
mul-1-neg2.3%
distribute-rgt-neg-in2.3%
*-commutative2.3%
unpow22.3%
unpow22.3%
hypot-def25.0%
Simplified25.0%
sqrt-prod33.3%
Applied egg-rr33.3%
Final simplification39.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) (* (* A C) -4.0))))
(if (<= (pow B 2.0) 1e-161)
(* (sqrt (* (* 2.0 (* F t_0)) (* 2.0 C))) (/ -1.0 t_0))
(if (<= (pow B 2.0) 4e+265)
(/
(*
(sqrt (* 2.0 (* F (- (* B B) (* 4.0 (* A C))))))
(- (sqrt (+ C (hypot B C)))))
(- (pow B 2.0) (* (* 4.0 A) C)))
(* (/ (sqrt 2.0) B) (* (sqrt F) (- (sqrt (+ A (hypot B A))))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + ((A * C) * -4.0);
double tmp;
if (pow(B, 2.0) <= 1e-161) {
tmp = sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0);
} else if (pow(B, 2.0) <= 4e+265) {
tmp = (sqrt((2.0 * (F * ((B * B) - (4.0 * (A * C)))))) * -sqrt((C + hypot(B, C)))) / (pow(B, 2.0) - ((4.0 * A) * C));
} else {
tmp = (sqrt(2.0) / B) * (sqrt(F) * -sqrt((A + hypot(B, A))));
}
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 tmp;
if (Math.pow(B, 2.0) <= 1e-161) {
tmp = Math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0);
} else if (Math.pow(B, 2.0) <= 4e+265) {
tmp = (Math.sqrt((2.0 * (F * ((B * B) - (4.0 * (A * C)))))) * -Math.sqrt((C + Math.hypot(B, C)))) / (Math.pow(B, 2.0) - ((4.0 * A) * C));
} else {
tmp = (Math.sqrt(2.0) / B) * (Math.sqrt(F) * -Math.sqrt((A + Math.hypot(B, A))));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + ((A * C) * -4.0) tmp = 0 if math.pow(B, 2.0) <= 1e-161: tmp = math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0) elif math.pow(B, 2.0) <= 4e+265: tmp = (math.sqrt((2.0 * (F * ((B * B) - (4.0 * (A * C)))))) * -math.sqrt((C + math.hypot(B, C)))) / (math.pow(B, 2.0) - ((4.0 * A) * C)) else: tmp = (math.sqrt(2.0) / B) * (math.sqrt(F) * -math.sqrt((A + math.hypot(B, A)))) 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)) tmp = 0.0 if ((B ^ 2.0) <= 1e-161) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * Float64(2.0 * C))) * Float64(-1.0 / t_0)); elseif ((B ^ 2.0) <= 4e+265) tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(F * Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))))) * Float64(-sqrt(Float64(C + hypot(B, C))))) / Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C))); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(sqrt(F) * Float64(-sqrt(Float64(A + hypot(B, A)))))); 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);
tmp = 0.0;
if ((B ^ 2.0) <= 1e-161)
tmp = sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0);
elseif ((B ^ 2.0) <= 4e+265)
tmp = (sqrt((2.0 * (F * ((B * B) - (4.0 * (A * C)))))) * -sqrt((C + hypot(B, C)))) / ((B ^ 2.0) - ((4.0 * A) * C));
else
tmp = (sqrt(2.0) / B) * (sqrt(F) * -sqrt((A + hypot(B, A))));
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]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 1e-161], N[(N[Sqrt[N[(N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 4e+265], N[(N[(N[Sqrt[N[(2.0 * N[(F * N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(C + N[Sqrt[B ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * N[(N[Sqrt[F], $MachinePrecision] * (-N[Sqrt[N[(A + N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $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\\
\mathbf{if}\;{B}^{2} \leq 10^{-161}:\\
\;\;\;\;\sqrt{\left(2 \cdot \left(F \cdot t_0\right)\right) \cdot \left(2 \cdot C\right)} \cdot \frac{-1}{t_0}\\
\mathbf{elif}\;{B}^{2} \leq 4 \cdot 10^{+265}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right)\right)} \cdot \left(-\sqrt{C + \mathsf{hypot}\left(B, C\right)}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(\sqrt{F} \cdot \left(-\sqrt{A + \mathsf{hypot}\left(B, A\right)}\right)\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 1.00000000000000003e-161Initial program 15.3%
Taylor expanded in A around -inf 18.8%
div-inv18.7%
*-commutative18.7%
pow218.7%
associate-*r*18.7%
cancel-sign-sub-inv18.7%
metadata-eval18.7%
pow218.7%
associate-*r*18.7%
Applied egg-rr18.7%
if 1.00000000000000003e-161 < (pow.f64 B 2) < 4.00000000000000027e265Initial program 41.9%
Taylor expanded in A around 0 38.8%
unpow238.8%
unpow238.8%
hypot-def42.0%
Simplified42.0%
sqrt-prod45.9%
unpow245.9%
associate-*l*45.9%
Applied egg-rr45.9%
if 4.00000000000000027e265 < (pow.f64 B 2) Initial program 0.2%
Taylor expanded in C around 0 6.0%
mul-1-neg6.0%
distribute-rgt-neg-in6.0%
*-commutative6.0%
unpow26.0%
unpow26.0%
hypot-def38.4%
Simplified38.4%
sqrt-prod53.9%
Applied egg-rr53.9%
Final simplification38.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 (* C (* A -4.0))))
(if (<= B -6.5e+26)
(/
(sqrt (* (fma B B t_0) (* F (* 2.0 (+ (+ A C) (hypot (- A C) B))))))
(- (* B (- B)) t_0))
(if (<= B 4.8e-14)
(/
(*
(sqrt (* 2.0 (* F (+ (* B B) (* (* A C) -4.0)))))
(- (sqrt (* 2.0 C))))
(- (pow B 2.0) (* (* 4.0 A) C)))
(* (/ (sqrt 2.0) B) (* (sqrt F) (- (sqrt (+ A (hypot B A))))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = C * (A * -4.0);
double tmp;
if (B <= -6.5e+26) {
tmp = sqrt((fma(B, B, t_0) * (F * (2.0 * ((A + C) + hypot((A - C), B)))))) / ((B * -B) - t_0);
} else if (B <= 4.8e-14) {
tmp = (sqrt((2.0 * (F * ((B * B) + ((A * C) * -4.0))))) * -sqrt((2.0 * C))) / (pow(B, 2.0) - ((4.0 * A) * C));
} else {
tmp = (sqrt(2.0) / B) * (sqrt(F) * -sqrt((A + hypot(B, A))));
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(C * Float64(A * -4.0)) tmp = 0.0 if (B <= -6.5e+26) tmp = Float64(sqrt(Float64(fma(B, B, t_0) * Float64(F * Float64(2.0 * Float64(Float64(A + C) + hypot(Float64(A - C), B)))))) / Float64(Float64(B * Float64(-B)) - t_0)); elseif (B <= 4.8e-14) tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(F * Float64(Float64(B * B) + Float64(Float64(A * C) * -4.0))))) * Float64(-sqrt(Float64(2.0 * C)))) / Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C))); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(sqrt(F) * Float64(-sqrt(Float64(A + hypot(B, A)))))); 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[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -6.5e+26], N[(N[Sqrt[N[(N[(B * B + t$95$0), $MachinePrecision] * N[(F * N[(2.0 * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(B * (-B)), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 4.8e-14], N[(N[(N[Sqrt[N[(2.0 * N[(F * N[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * N[(N[Sqrt[F], $MachinePrecision] * (-N[Sqrt[N[(A + N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := C \cdot \left(A \cdot -4\right)\\
\mathbf{if}\;B \leq -6.5 \cdot 10^{+26}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(B, B, t_0\right) \cdot \left(F \cdot \left(2 \cdot \left(\left(A + C\right) + \mathsf{hypot}\left(A - C, B\right)\right)\right)\right)}}{B \cdot \left(-B\right) - t_0}\\
\mathbf{elif}\;B \leq 4.8 \cdot 10^{-14}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(B \cdot B + \left(A \cdot C\right) \cdot -4\right)\right)} \cdot \left(-\sqrt{2 \cdot C}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(\sqrt{F} \cdot \left(-\sqrt{A + \mathsf{hypot}\left(B, A\right)}\right)\right)\\
\end{array}
\end{array}
if B < -6.50000000000000022e26Initial program 25.6%
distribute-frac-neg25.6%
neg-sub025.6%
Applied egg-rr25.6%
neg-sub025.6%
neg-mul-125.6%
metadata-eval25.6%
times-frac25.6%
*-lft-identity25.6%
associate-*l*25.7%
associate-+r+25.7%
+-commutative25.7%
neg-mul-125.7%
Simplified25.7%
fma-udef25.7%
Applied egg-rr25.7%
if -6.50000000000000022e26 < B < 4.8e-14Initial program 18.3%
Taylor expanded in A around -inf 19.2%
sqrt-prod22.1%
*-commutative22.1%
pow222.1%
associate-*r*22.1%
cancel-sign-sub-inv22.1%
metadata-eval22.1%
Applied egg-rr22.1%
if 4.8e-14 < B Initial program 22.4%
Taylor expanded in C around 0 30.7%
mul-1-neg30.7%
distribute-rgt-neg-in30.7%
*-commutative30.7%
unpow230.7%
unpow230.7%
hypot-def62.5%
Simplified62.5%
sqrt-prod80.7%
Applied egg-rr80.7%
Final simplification38.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 (* C (* A -4.0))))
(if (<= B -9e+25)
(/
(sqrt (* (fma B B t_0) (* F (* 2.0 (+ (+ A C) (hypot (- A C) B))))))
(- (* B (- B)) t_0))
(if (<= B 0.000265)
(/
(*
(sqrt (* 2.0 (* F (+ (* B B) (* (* A C) -4.0)))))
(- (sqrt (* 2.0 C))))
(- (pow B 2.0) (* (* 4.0 A) C)))
(* (/ (sqrt 2.0) B) (- (sqrt (* F (+ C (hypot B C))))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = C * (A * -4.0);
double tmp;
if (B <= -9e+25) {
tmp = sqrt((fma(B, B, t_0) * (F * (2.0 * ((A + C) + hypot((A - C), B)))))) / ((B * -B) - t_0);
} else if (B <= 0.000265) {
tmp = (sqrt((2.0 * (F * ((B * B) + ((A * C) * -4.0))))) * -sqrt((2.0 * C))) / (pow(B, 2.0) - ((4.0 * A) * C));
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (C + hypot(B, C))));
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(C * Float64(A * -4.0)) tmp = 0.0 if (B <= -9e+25) tmp = Float64(sqrt(Float64(fma(B, B, t_0) * Float64(F * Float64(2.0 * Float64(Float64(A + C) + hypot(Float64(A - C), B)))))) / Float64(Float64(B * Float64(-B)) - t_0)); elseif (B <= 0.000265) tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(F * Float64(Float64(B * B) + Float64(Float64(A * C) * -4.0))))) * Float64(-sqrt(Float64(2.0 * C)))) / Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C))); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(C + hypot(B, C)))))); 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[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -9e+25], N[(N[Sqrt[N[(N[(B * B + t$95$0), $MachinePrecision] * N[(F * N[(2.0 * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(B * (-B)), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 0.000265], N[(N[(N[Sqrt[N[(2.0 * N[(F * N[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(C + N[Sqrt[B ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := C \cdot \left(A \cdot -4\right)\\
\mathbf{if}\;B \leq -9 \cdot 10^{+25}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(B, B, t_0\right) \cdot \left(F \cdot \left(2 \cdot \left(\left(A + C\right) + \mathsf{hypot}\left(A - C, B\right)\right)\right)\right)}}{B \cdot \left(-B\right) - t_0}\\
\mathbf{elif}\;B \leq 0.000265:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(B \cdot B + \left(A \cdot C\right) \cdot -4\right)\right)} \cdot \left(-\sqrt{2 \cdot C}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(C + \mathsf{hypot}\left(B, C\right)\right)}\right)\\
\end{array}
\end{array}
if B < -9.0000000000000006e25Initial program 25.6%
distribute-frac-neg25.6%
neg-sub025.6%
Applied egg-rr25.6%
neg-sub025.6%
neg-mul-125.6%
metadata-eval25.6%
times-frac25.6%
*-lft-identity25.6%
associate-*l*25.7%
associate-+r+25.7%
+-commutative25.7%
neg-mul-125.7%
Simplified25.7%
fma-udef25.7%
Applied egg-rr25.7%
if -9.0000000000000006e25 < B < 2.6499999999999999e-4Initial program 18.3%
Taylor expanded in A around -inf 19.2%
sqrt-prod22.1%
*-commutative22.1%
pow222.1%
associate-*r*22.1%
cancel-sign-sub-inv22.1%
metadata-eval22.1%
Applied egg-rr22.1%
if 2.6499999999999999e-4 < B Initial program 22.4%
Taylor expanded in A around 0 31.8%
mul-1-neg31.8%
distribute-rgt-neg-in31.8%
*-commutative31.8%
unpow231.8%
unpow231.8%
hypot-def62.8%
Simplified62.8%
Final simplification33.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 (+ C (hypot B C))))
(if (<= B -1.6e+26)
(- (/ (sqrt (* 2.0 (* (* F t_0) t_1))) t_0))
(if (<= B 2.3e-21)
(/
(*
(sqrt (* 2.0 (* F (+ (* B B) (* (* A C) -4.0)))))
(- (sqrt (* 2.0 C))))
(- (pow B 2.0) (* (* 4.0 A) C)))
(* (/ (sqrt 2.0) B) (- (sqrt (* F t_1))))))))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 = C + hypot(B, C);
double tmp;
if (B <= -1.6e+26) {
tmp = -(sqrt((2.0 * ((F * t_0) * t_1))) / t_0);
} else if (B <= 2.3e-21) {
tmp = (sqrt((2.0 * (F * ((B * B) + ((A * C) * -4.0))))) * -sqrt((2.0 * C))) / (pow(B, 2.0) - ((4.0 * A) * C));
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * t_1));
}
return tmp;
}
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 = C + Math.hypot(B, C);
double tmp;
if (B <= -1.6e+26) {
tmp = -(Math.sqrt((2.0 * ((F * t_0) * t_1))) / t_0);
} else if (B <= 2.3e-21) {
tmp = (Math.sqrt((2.0 * (F * ((B * B) + ((A * C) * -4.0))))) * -Math.sqrt((2.0 * C))) / (Math.pow(B, 2.0) - ((4.0 * A) * C));
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * t_1));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = C + math.hypot(B, C) tmp = 0 if B <= -1.6e+26: tmp = -(math.sqrt((2.0 * ((F * t_0) * t_1))) / t_0) elif B <= 2.3e-21: tmp = (math.sqrt((2.0 * (F * ((B * B) + ((A * C) * -4.0))))) * -math.sqrt((2.0 * C))) / (math.pow(B, 2.0) - ((4.0 * A) * C)) else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * t_1)) 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(C + hypot(B, C)) tmp = 0.0 if (B <= -1.6e+26) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(F * t_0) * t_1))) / t_0)); elseif (B <= 2.3e-21) tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(F * Float64(Float64(B * B) + Float64(Float64(A * C) * -4.0))))) * Float64(-sqrt(Float64(2.0 * C)))) / Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C))); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * t_1)))); 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 = C + hypot(B, C);
tmp = 0.0;
if (B <= -1.6e+26)
tmp = -(sqrt((2.0 * ((F * t_0) * t_1))) / t_0);
elseif (B <= 2.3e-21)
tmp = (sqrt((2.0 * (F * ((B * B) + ((A * C) * -4.0))))) * -sqrt((2.0 * C))) / ((B ^ 2.0) - ((4.0 * A) * C));
else
tmp = (sqrt(2.0) / B) * -sqrt((F * t_1));
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[(C + N[Sqrt[B ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -1.6e+26], (-N[(N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), If[LessEqual[B, 2.3e-21], N[(N[(N[Sqrt[N[(2.0 * N[(F * N[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * t$95$1), $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 := C + \mathsf{hypot}\left(B, C\right)\\
\mathbf{if}\;B \leq -1.6 \cdot 10^{+26}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot t_1\right)}}{t_0}\\
\mathbf{elif}\;B \leq 2.3 \cdot 10^{-21}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(B \cdot B + \left(A \cdot C\right) \cdot -4\right)\right)} \cdot \left(-\sqrt{2 \cdot C}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot t_1}\right)\\
\end{array}
\end{array}
if B < -1.60000000000000014e26Initial program 25.6%
Taylor expanded in A around 0 21.7%
unpow221.7%
unpow221.7%
hypot-def21.7%
Simplified21.7%
distribute-frac-neg21.7%
associate-*l*21.7%
unpow221.7%
associate-*l*21.7%
unpow221.7%
associate-*l*21.7%
Applied egg-rr21.7%
if -1.60000000000000014e26 < B < 2.29999999999999999e-21Initial program 18.3%
Taylor expanded in A around -inf 19.2%
sqrt-prod22.1%
*-commutative22.1%
pow222.1%
associate-*r*22.1%
cancel-sign-sub-inv22.1%
metadata-eval22.1%
Applied egg-rr22.1%
if 2.29999999999999999e-21 < B Initial program 22.4%
Taylor expanded in A around 0 31.8%
mul-1-neg31.8%
distribute-rgt-neg-in31.8%
*-commutative31.8%
unpow231.8%
unpow231.8%
hypot-def62.8%
Simplified62.8%
Final simplification33.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)))) (t_1 (+ (* B B) (* (* A C) -4.0))))
(if (<= B -3.5e-64)
(- (/ (sqrt (* 2.0 (* (* F t_0) (+ C (hypot B C))))) t_0))
(if (<= B 8e+17)
(* (sqrt (* (* 2.0 (* F t_1)) (* 2.0 C))) (/ -1.0 t_1))
(* (/ (sqrt 2.0) B) (- (sqrt (* F (+ A (hypot B A))))))))))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 tmp;
if (B <= -3.5e-64) {
tmp = -(sqrt((2.0 * ((F * t_0) * (C + hypot(B, C))))) / t_0);
} else if (B <= 8e+17) {
tmp = sqrt(((2.0 * (F * t_1)) * (2.0 * C))) * (-1.0 / t_1);
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A + hypot(B, A))));
}
return tmp;
}
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 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= -3.5e-64) {
tmp = -(Math.sqrt((2.0 * ((F * t_0) * (C + Math.hypot(B, C))))) / t_0);
} else if (B <= 8e+17) {
tmp = Math.sqrt(((2.0 * (F * t_1)) * (2.0 * C))) * (-1.0 / t_1);
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * (A + Math.hypot(B, A))));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = (B * B) + ((A * C) * -4.0) tmp = 0 if B <= -3.5e-64: tmp = -(math.sqrt((2.0 * ((F * t_0) * (C + math.hypot(B, C))))) / t_0) elif B <= 8e+17: tmp = math.sqrt(((2.0 * (F * t_1)) * (2.0 * C))) * (-1.0 / t_1) else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * (A + math.hypot(B, A)))) 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)) tmp = 0.0 if (B <= -3.5e-64) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(C + hypot(B, C))))) / t_0)); elseif (B <= 8e+17) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(F * t_1)) * Float64(2.0 * C))) * Float64(-1.0 / t_1)); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A + hypot(B, A)))))); 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 = (B * B) + ((A * C) * -4.0);
tmp = 0.0;
if (B <= -3.5e-64)
tmp = -(sqrt((2.0 * ((F * t_0) * (C + hypot(B, C))))) / t_0);
elseif (B <= 8e+17)
tmp = sqrt(((2.0 * (F * t_1)) * (2.0 * C))) * (-1.0 / t_1);
else
tmp = (sqrt(2.0) / B) * -sqrt((F * (A + hypot(B, A))));
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[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -3.5e-64], (-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] / t$95$0), $MachinePrecision]), If[LessEqual[B, 8e+17], N[(N[Sqrt[N[(N[(2.0 * N[(F * t$95$1), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A + N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $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 := B \cdot B + \left(A \cdot C\right) \cdot -4\\
\mathbf{if}\;B \leq -3.5 \cdot 10^{-64}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(C + \mathsf{hypot}\left(B, C\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 8 \cdot 10^{+17}:\\
\;\;\;\;\sqrt{\left(2 \cdot \left(F \cdot t_1\right)\right) \cdot \left(2 \cdot C\right)} \cdot \frac{-1}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A + \mathsf{hypot}\left(B, A\right)\right)}\right)\\
\end{array}
\end{array}
if B < -3.5000000000000003e-64Initial program 26.0%
Taylor expanded in A around 0 23.3%
unpow223.3%
unpow223.3%
hypot-def24.7%
Simplified24.7%
distribute-frac-neg24.7%
associate-*l*24.7%
unpow224.7%
associate-*l*24.7%
unpow224.7%
associate-*l*24.7%
Applied egg-rr24.7%
if -3.5000000000000003e-64 < B < 8e17Initial program 17.7%
Taylor expanded in A around -inf 19.2%
div-inv19.2%
*-commutative19.2%
pow219.2%
associate-*r*19.2%
cancel-sign-sub-inv19.2%
metadata-eval19.2%
pow219.2%
associate-*r*19.2%
Applied egg-rr19.2%
if 8e17 < B Initial program 21.0%
Taylor expanded in C around 0 31.2%
mul-1-neg31.2%
distribute-rgt-neg-in31.2%
*-commutative31.2%
unpow231.2%
unpow231.2%
hypot-def65.4%
Simplified65.4%
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 (+ (* B B) (* (* A C) -4.0))))
(if (<= B -1.28e-64)
(- (/ (sqrt (* 2.0 (* (* F t_0) (+ C (hypot B C))))) t_0))
(if (<= B 1e+18)
(* (sqrt (* (* 2.0 (* F t_1)) (* 2.0 C))) (/ -1.0 t_1))
(* (/ (sqrt 2.0) B) (- (sqrt (* F (+ B A)))))))))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 tmp;
if (B <= -1.28e-64) {
tmp = -(sqrt((2.0 * ((F * t_0) * (C + hypot(B, C))))) / t_0);
} else if (B <= 1e+18) {
tmp = sqrt(((2.0 * (F * t_1)) * (2.0 * C))) * (-1.0 / t_1);
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (B + A)));
}
return tmp;
}
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 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= -1.28e-64) {
tmp = -(Math.sqrt((2.0 * ((F * t_0) * (C + Math.hypot(B, C))))) / t_0);
} else if (B <= 1e+18) {
tmp = Math.sqrt(((2.0 * (F * t_1)) * (2.0 * C))) * (-1.0 / t_1);
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * (B + A)));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = (B * B) + ((A * C) * -4.0) tmp = 0 if B <= -1.28e-64: tmp = -(math.sqrt((2.0 * ((F * t_0) * (C + math.hypot(B, C))))) / t_0) elif B <= 1e+18: tmp = math.sqrt(((2.0 * (F * t_1)) * (2.0 * C))) * (-1.0 / t_1) else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * (B + A))) 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)) tmp = 0.0 if (B <= -1.28e-64) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(C + hypot(B, C))))) / t_0)); elseif (B <= 1e+18) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(F * t_1)) * Float64(2.0 * C))) * Float64(-1.0 / t_1)); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(B + A))))); 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 = (B * B) + ((A * C) * -4.0);
tmp = 0.0;
if (B <= -1.28e-64)
tmp = -(sqrt((2.0 * ((F * t_0) * (C + hypot(B, C))))) / t_0);
elseif (B <= 1e+18)
tmp = sqrt(((2.0 * (F * t_1)) * (2.0 * C))) * (-1.0 / t_1);
else
tmp = (sqrt(2.0) / B) * -sqrt((F * (B + A)));
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[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -1.28e-64], (-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] / t$95$0), $MachinePrecision]), If[LessEqual[B, 1e+18], N[(N[Sqrt[N[(N[(2.0 * N[(F * t$95$1), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(B + A), $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 := B \cdot B + \left(A \cdot C\right) \cdot -4\\
\mathbf{if}\;B \leq -1.28 \cdot 10^{-64}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(C + \mathsf{hypot}\left(B, C\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 10^{+18}:\\
\;\;\;\;\sqrt{\left(2 \cdot \left(F \cdot t_1\right)\right) \cdot \left(2 \cdot C\right)} \cdot \frac{-1}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(B + A\right)}\right)\\
\end{array}
\end{array}
if B < -1.28e-64Initial program 26.0%
Taylor expanded in A around 0 23.3%
unpow223.3%
unpow223.3%
hypot-def24.7%
Simplified24.7%
distribute-frac-neg24.7%
associate-*l*24.7%
unpow224.7%
associate-*l*24.7%
unpow224.7%
associate-*l*24.7%
Applied egg-rr24.7%
if -1.28e-64 < B < 1e18Initial program 17.7%
Taylor expanded in A around -inf 19.2%
div-inv19.2%
*-commutative19.2%
pow219.2%
associate-*r*19.2%
cancel-sign-sub-inv19.2%
metadata-eval19.2%
pow219.2%
associate-*r*19.2%
Applied egg-rr19.2%
if 1e18 < B Initial program 21.0%
Taylor expanded in C around 0 31.2%
mul-1-neg31.2%
distribute-rgt-neg-in31.2%
*-commutative31.2%
unpow231.2%
unpow231.2%
hypot-def65.4%
Simplified65.4%
Taylor expanded in A around 0 63.7%
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) (* (* A C) -4.0))))
(if (<= B 1.08e+18)
(* (sqrt (* (* 2.0 (* F t_0)) (* 2.0 C))) (/ -1.0 t_0))
(* (/ (sqrt 2.0) B) (- (sqrt (* F (+ B A))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= 1.08e+18) {
tmp = sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0);
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (B + A)));
}
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) + ((a * c) * (-4.0d0))
if (b <= 1.08d+18) then
tmp = sqrt(((2.0d0 * (f * t_0)) * (2.0d0 * c))) * ((-1.0d0) / t_0)
else
tmp = (sqrt(2.0d0) / b) * -sqrt((f * (b + a)))
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) + ((A * C) * -4.0);
double tmp;
if (B <= 1.08e+18) {
tmp = Math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0);
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * (B + A)));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + ((A * C) * -4.0) tmp = 0 if B <= 1.08e+18: tmp = math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0) else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * (B + A))) 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)) tmp = 0.0 if (B <= 1.08e+18) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * Float64(2.0 * C))) * Float64(-1.0 / t_0)); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(B + A))))); 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);
tmp = 0.0;
if (B <= 1.08e+18)
tmp = sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0);
else
tmp = (sqrt(2.0) / B) * -sqrt((F * (B + A)));
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]}, If[LessEqual[B, 1.08e+18], N[(N[Sqrt[N[(N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(B + A), $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\\
\mathbf{if}\;B \leq 1.08 \cdot 10^{+18}:\\
\;\;\;\;\sqrt{\left(2 \cdot \left(F \cdot t_0\right)\right) \cdot \left(2 \cdot C\right)} \cdot \frac{-1}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(B + A\right)}\right)\\
\end{array}
\end{array}
if B < 1.08e18Initial program 21.0%
Taylor expanded in A around -inf 13.6%
div-inv13.6%
*-commutative13.6%
pow213.6%
associate-*r*13.6%
cancel-sign-sub-inv13.6%
metadata-eval13.6%
pow213.6%
associate-*r*13.6%
Applied egg-rr13.6%
if 1.08e18 < B Initial program 21.0%
Taylor expanded in C around 0 31.2%
mul-1-neg31.2%
distribute-rgt-neg-in31.2%
*-commutative31.2%
unpow231.2%
unpow231.2%
hypot-def65.4%
Simplified65.4%
Taylor expanded in A around 0 63.7%
Final simplification26.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) (* (* A C) -4.0))))
(if (<= B 850000000000.0)
(* (sqrt (* (* 2.0 (* F t_0)) (* 2.0 C))) (/ -1.0 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) + ((A * C) * -4.0);
double tmp;
if (B <= 850000000000.0) {
tmp = sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / 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) + ((a * c) * (-4.0d0))
if (b <= 850000000000.0d0) then
tmp = sqrt(((2.0d0 * (f * t_0)) * (2.0d0 * c))) * ((-1.0d0) / 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) + ((A * C) * -4.0);
double tmp;
if (B <= 850000000000.0) {
tmp = Math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / 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) + ((A * C) * -4.0) tmp = 0 if B <= 850000000000.0: tmp = math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / 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(Float64(A * C) * -4.0)) tmp = 0.0 if (B <= 850000000000.0) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * Float64(2.0 * C))) * Float64(-1.0 / 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) + ((A * C) * -4.0);
tmp = 0.0;
if (B <= 850000000000.0)
tmp = sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / 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[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 850000000000.0], N[(N[Sqrt[N[(N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$0), $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}
t_0 := B \cdot B + \left(A \cdot C\right) \cdot -4\\
\mathbf{if}\;B \leq 850000000000:\\
\;\;\;\;\sqrt{\left(2 \cdot \left(F \cdot t_0\right)\right) \cdot \left(2 \cdot C\right)} \cdot \frac{-1}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{B \cdot F}\right)\\
\end{array}
\end{array}
if B < 8.5e11Initial program 21.1%
Taylor expanded in A around -inf 13.7%
div-inv13.7%
*-commutative13.7%
pow213.7%
associate-*r*13.7%
cancel-sign-sub-inv13.7%
metadata-eval13.7%
pow213.7%
associate-*r*13.7%
Applied egg-rr13.7%
if 8.5e11 < B Initial program 20.7%
Taylor expanded in C around 0 30.7%
mul-1-neg30.7%
distribute-rgt-neg-in30.7%
*-commutative30.7%
unpow230.7%
unpow230.7%
hypot-def64.5%
Simplified64.5%
Taylor expanded in A around 0 62.2%
Final simplification26.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) (* (* A C) -4.0))))
(if (<= B 2700000000.0)
(* (sqrt (* (* 2.0 (* F t_0)) (* 2.0 C))) (/ -1.0 t_0))
(* (sqrt (/ F B)) (- (sqrt 2.0))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= 2700000000.0) {
tmp = sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0);
} else {
tmp = sqrt((F / B)) * -sqrt(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 = (b * b) + ((a * c) * (-4.0d0))
if (b <= 2700000000.0d0) then
tmp = sqrt(((2.0d0 * (f * t_0)) * (2.0d0 * c))) * ((-1.0d0) / t_0)
else
tmp = sqrt((f / b)) * -sqrt(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 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= 2700000000.0) {
tmp = Math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0);
} else {
tmp = Math.sqrt((F / B)) * -Math.sqrt(2.0);
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + ((A * C) * -4.0) tmp = 0 if B <= 2700000000.0: tmp = math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0) else: tmp = math.sqrt((F / B)) * -math.sqrt(2.0) 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)) tmp = 0.0 if (B <= 2700000000.0) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * Float64(2.0 * C))) * Float64(-1.0 / t_0)); else tmp = Float64(sqrt(Float64(F / B)) * Float64(-sqrt(2.0))); 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);
tmp = 0.0;
if (B <= 2700000000.0)
tmp = sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0);
else
tmp = sqrt((F / B)) * -sqrt(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[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 2700000000.0], N[(N[Sqrt[N[(N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F / B), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $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\\
\mathbf{if}\;B \leq 2700000000:\\
\;\;\;\;\sqrt{\left(2 \cdot \left(F \cdot t_0\right)\right) \cdot \left(2 \cdot C\right)} \cdot \frac{-1}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{F}{B}} \cdot \left(-\sqrt{2}\right)\\
\end{array}
\end{array}
if B < 2.7e9Initial program 21.1%
Taylor expanded in A around -inf 13.7%
div-inv13.7%
*-commutative13.7%
pow213.7%
associate-*r*13.7%
cancel-sign-sub-inv13.7%
metadata-eval13.7%
pow213.7%
associate-*r*13.7%
Applied egg-rr13.7%
if 2.7e9 < B Initial program 20.7%
Taylor expanded in A around 0 20.7%
unpow220.7%
unpow220.7%
hypot-def22.2%
Simplified22.2%
Taylor expanded in C around 0 60.2%
mul-1-neg60.2%
Simplified60.2%
Final simplification25.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) (* (* A C) -4.0))) (t_1 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 1.5e+18)
(/ (- (sqrt (* (* 2.0 (* F t_0)) (* 2.0 C)))) t_0)
(- (/ (sqrt (* 2.0 (* (* F t_1) (+ B (+ A C))))) t_1)))))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 <= 1.5e+18) {
tmp = -sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
} else {
tmp = -(sqrt((2.0 * ((F * t_1) * (B + (A + C))))) / t_1);
}
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) + ((a * c) * (-4.0d0))
t_1 = (b * b) - (4.0d0 * (a * c))
if (b <= 1.5d+18) then
tmp = -sqrt(((2.0d0 * (f * t_0)) * (2.0d0 * c))) / t_0
else
tmp = -(sqrt((2.0d0 * ((f * t_1) * (b + (a + c))))) / t_1)
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) + ((A * C) * -4.0);
double t_1 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 1.5e+18) {
tmp = -Math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
} else {
tmp = -(Math.sqrt((2.0 * ((F * t_1) * (B + (A + C))))) / t_1);
}
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)) tmp = 0 if B <= 1.5e+18: tmp = -math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0 else: tmp = -(math.sqrt((2.0 * ((F * t_1) * (B + (A + C))))) / t_1) 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 <= 1.5e+18) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * Float64(2.0 * C)))) / t_0); else tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(F * t_1) * Float64(B + Float64(A + C))))) / t_1)); 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));
tmp = 0.0;
if (B <= 1.5e+18)
tmp = -sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
else
tmp = -(sqrt((2.0 * ((F * t_1) * (B + (A + C))))) / t_1);
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]}, If[LessEqual[B, 1.5e+18], 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[N[(2.0 * N[(N[(F * t$95$1), $MachinePrecision] * N[(B + N[(A + C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1), $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 1.5 \cdot 10^{+18}:\\
\;\;\;\;\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 \cdot \left(\left(F \cdot t_1\right) \cdot \left(B + \left(A + C\right)\right)\right)}}{t_1}\\
\end{array}
\end{array}
if B < 1.5e18Initial program 21.0%
Taylor expanded in A around -inf 13.6%
distribute-frac-neg13.6%
*-commutative13.6%
pow213.6%
associate-*r*13.6%
cancel-sign-sub-inv13.6%
metadata-eval13.6%
pow213.6%
associate-*r*13.6%
cancel-sign-sub-inv13.6%
metadata-eval13.6%
Applied egg-rr13.6%
if 1.5e18 < B Initial program 21.0%
Taylor expanded in B around inf 21.2%
distribute-frac-neg21.2%
associate-*l*21.2%
unpow221.2%
associate-*l*21.2%
+-commutative21.2%
unpow221.2%
associate-*l*21.2%
Applied egg-rr21.2%
Final simplification15.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) (* (* A C) -4.0))) (t_1 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 1.9e+18)
(* (sqrt (* (* 2.0 (* F t_0)) (* 2.0 C))) (/ -1.0 t_0))
(- (/ (sqrt (* 2.0 (* (* F t_1) (+ B (+ A C))))) t_1)))))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 <= 1.9e+18) {
tmp = sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0);
} else {
tmp = -(sqrt((2.0 * ((F * t_1) * (B + (A + C))))) / t_1);
}
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) + ((a * c) * (-4.0d0))
t_1 = (b * b) - (4.0d0 * (a * c))
if (b <= 1.9d+18) then
tmp = sqrt(((2.0d0 * (f * t_0)) * (2.0d0 * c))) * ((-1.0d0) / t_0)
else
tmp = -(sqrt((2.0d0 * ((f * t_1) * (b + (a + c))))) / t_1)
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) + ((A * C) * -4.0);
double t_1 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 1.9e+18) {
tmp = Math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0);
} else {
tmp = -(Math.sqrt((2.0 * ((F * t_1) * (B + (A + C))))) / t_1);
}
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)) tmp = 0 if B <= 1.9e+18: tmp = math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0) else: tmp = -(math.sqrt((2.0 * ((F * t_1) * (B + (A + C))))) / t_1) 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 <= 1.9e+18) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * Float64(2.0 * C))) * Float64(-1.0 / t_0)); else tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(F * t_1) * Float64(B + Float64(A + C))))) / t_1)); 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));
tmp = 0.0;
if (B <= 1.9e+18)
tmp = sqrt(((2.0 * (F * t_0)) * (2.0 * C))) * (-1.0 / t_0);
else
tmp = -(sqrt((2.0 * ((F * t_1) * (B + (A + C))))) / t_1);
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]}, If[LessEqual[B, 1.9e+18], N[(N[Sqrt[N[(N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], (-N[(N[Sqrt[N[(2.0 * N[(N[(F * t$95$1), $MachinePrecision] * N[(B + N[(A + C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1), $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 1.9 \cdot 10^{+18}:\\
\;\;\;\;\sqrt{\left(2 \cdot \left(F \cdot t_0\right)\right) \cdot \left(2 \cdot C\right)} \cdot \frac{-1}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(F \cdot t_1\right) \cdot \left(B + \left(A + C\right)\right)\right)}}{t_1}\\
\end{array}
\end{array}
if B < 1.9e18Initial program 21.0%
Taylor expanded in A around -inf 13.6%
div-inv13.6%
*-commutative13.6%
pow213.6%
associate-*r*13.6%
cancel-sign-sub-inv13.6%
metadata-eval13.6%
pow213.6%
associate-*r*13.6%
Applied egg-rr13.6%
if 1.9e18 < B Initial program 21.0%
Taylor expanded in B around inf 21.2%
distribute-frac-neg21.2%
associate-*l*21.2%
unpow221.2%
associate-*l*21.2%
+-commutative21.2%
unpow221.2%
associate-*l*21.2%
Applied egg-rr21.2%
Final simplification15.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) (* (* A C) -4.0))))
(if (<= B 3.9e+14)
(/ (- (sqrt (* (* 2.0 (* F t_0)) (* 2.0 C)))) t_0)
(-
(/
(sqrt (* 2.0 (* (+ B C) (* F (* B B)))))
(- (* B B) (* 4.0 (* A C))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= 3.9e+14) {
tmp = -sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
} else {
tmp = -(sqrt((2.0 * ((B + C) * (F * (B * B))))) / ((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) :: t_0
real(8) :: tmp
t_0 = (b * b) + ((a * c) * (-4.0d0))
if (b <= 3.9d+14) then
tmp = -sqrt(((2.0d0 * (f * t_0)) * (2.0d0 * c))) / t_0
else
tmp = -(sqrt((2.0d0 * ((b + c) * (f * (b * b))))) / ((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 t_0 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= 3.9e+14) {
tmp = -Math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
} else {
tmp = -(Math.sqrt((2.0 * ((B + C) * (F * (B * B))))) / ((B * B) - (4.0 * (A * C))));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + ((A * C) * -4.0) tmp = 0 if B <= 3.9e+14: tmp = -math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0 else: tmp = -(math.sqrt((2.0 * ((B + C) * (F * (B * B))))) / ((B * B) - (4.0 * (A * C)))) 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)) tmp = 0.0 if (B <= 3.9e+14) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * Float64(2.0 * C)))) / t_0); else tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(B + C) * Float64(F * Float64(B * B))))) / 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)
t_0 = (B * B) + ((A * C) * -4.0);
tmp = 0.0;
if (B <= 3.9e+14)
tmp = -sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
else
tmp = -(sqrt((2.0 * ((B + C) * (F * (B * B))))) / ((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_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 3.9e+14], 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[N[(2.0 * N[(N[(B + C), $MachinePrecision] * N[(F * N[(B * B), $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}
t_0 := B \cdot B + \left(A \cdot C\right) \cdot -4\\
\mathbf{if}\;B \leq 3.9 \cdot 10^{+14}:\\
\;\;\;\;\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 \cdot \left(\left(B + C\right) \cdot \left(F \cdot \left(B \cdot B\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\end{array}
\end{array}
if B < 3.9e14Initial program 21.1%
Taylor expanded in A around -inf 13.7%
distribute-frac-neg13.7%
*-commutative13.7%
pow213.7%
associate-*r*13.7%
cancel-sign-sub-inv13.7%
metadata-eval13.7%
pow213.7%
associate-*r*13.7%
cancel-sign-sub-inv13.7%
metadata-eval13.7%
Applied egg-rr13.7%
if 3.9e14 < B Initial program 20.7%
Taylor expanded in B around inf 20.9%
distribute-frac-neg20.9%
associate-*l*20.9%
unpow220.9%
associate-*l*20.9%
+-commutative20.9%
unpow220.9%
associate-*l*20.9%
Applied egg-rr20.9%
Taylor expanded in A around 0 20.7%
unpow220.7%
Simplified20.7%
Final simplification15.5%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B -1.4e-248)
(* 2.0 (* (sqrt (* C F)) (/ 1.0 B)))
(-
(/ (sqrt (* 2.0 (* (+ B C) (* F (* B B))))) (- (* B B) (* 4.0 (* A C)))))))assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= -1.4e-248) {
tmp = 2.0 * (sqrt((C * F)) * (1.0 / B));
} else {
tmp = -(sqrt((2.0 * ((B + C) * (F * (B * B))))) / ((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.4d-248)) then
tmp = 2.0d0 * (sqrt((c * f)) * (1.0d0 / b))
else
tmp = -(sqrt((2.0d0 * ((b + c) * (f * (b * b))))) / ((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.4e-248) {
tmp = 2.0 * (Math.sqrt((C * F)) * (1.0 / B));
} else {
tmp = -(Math.sqrt((2.0 * ((B + C) * (F * (B * B))))) / ((B * B) - (4.0 * (A * C))));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= -1.4e-248: tmp = 2.0 * (math.sqrt((C * F)) * (1.0 / B)) else: tmp = -(math.sqrt((2.0 * ((B + C) * (F * (B * B))))) / ((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.4e-248) tmp = Float64(2.0 * Float64(sqrt(Float64(C * F)) * Float64(1.0 / B))); else tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(B + C) * Float64(F * Float64(B * B))))) / 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.4e-248)
tmp = 2.0 * (sqrt((C * F)) * (1.0 / B));
else
tmp = -(sqrt((2.0 * ((B + C) * (F * (B * B))))) / ((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.4e-248], N[(2.0 * N[(N[Sqrt[N[(C * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(N[Sqrt[N[(2.0 * N[(N[(B + C), $MachinePrecision] * N[(F * N[(B * B), $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.4 \cdot 10^{-248}:\\
\;\;\;\;2 \cdot \left(\sqrt{C \cdot F} \cdot \frac{1}{B}\right)\\
\mathbf{else}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(B + C\right) \cdot \left(F \cdot \left(B \cdot B\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\end{array}
\end{array}
if B < -1.40000000000000005e-248Initial program 21.6%
Taylor expanded in A around -inf 9.1%
Taylor expanded in B around -inf 3.9%
if -1.40000000000000005e-248 < B Initial program 20.5%
Taylor expanded in B around inf 13.3%
distribute-frac-neg13.3%
associate-*l*13.3%
unpow213.3%
associate-*l*13.3%
+-commutative13.3%
unpow213.3%
associate-*l*13.3%
Applied egg-rr13.3%
Taylor expanded in A around 0 11.7%
unpow211.7%
Simplified11.7%
Final simplification8.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 (* (sqrt (* C F)) (/ 1.0 B)))) (if (<= B -7.4e-296) (* 2.0 t_0) (* -2.0 t_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 <= -7.4e-296) {
tmp = 2.0 * t_0;
} else {
tmp = -2.0 * 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) :: tmp
t_0 = sqrt((c * f)) * (1.0d0 / b)
if (b <= (-7.4d-296)) then
tmp = 2.0d0 * t_0
else
tmp = (-2.0d0) * 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 = Math.sqrt((C * F)) * (1.0 / B);
double tmp;
if (B <= -7.4e-296) {
tmp = 2.0 * t_0;
} else {
tmp = -2.0 * t_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 <= -7.4e-296: tmp = 2.0 * t_0 else: tmp = -2.0 * t_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 <= -7.4e-296) tmp = Float64(2.0 * t_0); else tmp = Float64(-2.0 * t_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 <= -7.4e-296)
tmp = 2.0 * t_0;
else
tmp = -2.0 * 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[Sqrt[N[(C * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -7.4e-296], N[(2.0 * t$95$0), $MachinePrecision], N[(-2.0 * t$95$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 -7.4 \cdot 10^{-296}:\\
\;\;\;\;2 \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot t_0\\
\end{array}
\end{array}
if B < -7.40000000000000053e-296Initial program 20.7%
Taylor expanded in A around -inf 10.5%
Taylor expanded in B around -inf 3.5%
if -7.40000000000000053e-296 < B Initial program 21.3%
Taylor expanded in A around -inf 11.2%
Taylor expanded in B around inf 3.4%
Final simplification3.5%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* -2.0 (* (sqrt (* C F)) (/ 1.0 B))))
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (sqrt((C * F)) * (1.0 / 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((c * f)) * (1.0d0 / b))
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
return -2.0 * (Math.sqrt((C * F)) * (1.0 / B));
}
[A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.sqrt((C * F)) * (1.0 / B))
A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64(sqrt(Float64(C * F)) * Float64(1.0 / B))) end
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (sqrt((C * F)) * (1.0 / 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[(C * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \left(\sqrt{C \cdot F} \cdot \frac{1}{B}\right)
\end{array}
Initial program 21.0%
Taylor expanded in A around -inf 10.9%
Taylor expanded in B around inf 2.2%
Final simplification2.2%
herbie shell --seed 2023187
(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))))