
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0))))
(t_1 (- (* B B) (* 4.0 (* A C))))
(t_2 (pow (- A C) 2.0))
(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) t_2))))))
t_3))
(t_5
(/
(-
(sqrt
(* 2.0 (* t_0 (* F (+ A (+ A (* -0.5 (/ (* B B) (- C A))))))))))
t_0)))
(if (<= t_4 (- INFINITY))
t_5
(if (<= t_4 -5e-156)
(/
(- (sqrt (* 2.0 (* (* F t_1) (- (+ A C) (sqrt (+ t_2 (* B B))))))))
t_1)
(if (<= t_4 INFINITY)
t_5
(/ (* (sqrt 2.0) (- (sqrt (* F (- A (hypot A B)))))) B))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double t_1 = (B * B) - (4.0 * (A * C));
double t_2 = pow((A - C), 2.0);
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) + t_2))))) / t_3;
double t_5 = -sqrt((2.0 * (t_0 * (F * (A + (A + (-0.5 * ((B * B) / (C - A))))))))) / t_0;
double tmp;
if (t_4 <= -((double) INFINITY)) {
tmp = t_5;
} else if (t_4 <= -5e-156) {
tmp = -sqrt((2.0 * ((F * t_1) * ((A + C) - sqrt((t_2 + (B * B))))))) / t_1;
} else if (t_4 <= ((double) INFINITY)) {
tmp = t_5;
} else {
tmp = (sqrt(2.0) * -sqrt((F * (A - hypot(A, B))))) / B;
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) t_1 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_2 = Float64(A - C) ^ 2.0 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) + t_2)))))) / t_3) t_5 = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + Float64(A + Float64(-0.5 * Float64(Float64(B * B) / Float64(C - A)))))))))) / t_0) tmp = 0.0 if (t_4 <= Float64(-Inf)) tmp = t_5; elseif (t_4 <= -5e-156) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_1) * Float64(Float64(A + C) - sqrt(Float64(t_2 + Float64(B * B)))))))) / t_1); elseif (t_4 <= Inf) tmp = t_5; else tmp = Float64(Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(A - hypot(A, B)))))) / B); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $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[Power[N[(A - C), $MachinePrecision], 2.0], $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] + t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + N[(A + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / N[(C - A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], t$95$5, If[LessEqual[t$95$4, -5e-156], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$1), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(t$95$2 + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[t$95$4, Infinity], t$95$5, N[(N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / B), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_2 := {\left(A - C\right)}^{2}\\
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} + t_2}\right)}}{t_3}\\
t_5 := \frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + \left(A + -0.5 \cdot \frac{B \cdot B}{C - A}\right)\right)\right)\right)}}{t_0}\\
\mathbf{if}\;t_4 \leq -\infty:\\
\;\;\;\;t_5\\
\mathbf{elif}\;t_4 \leq -5 \cdot 10^{-156}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_1\right) \cdot \left(\left(A + C\right) - \sqrt{t_2 + B \cdot B}\right)\right)}}{t_1}\\
\mathbf{elif}\;t_4 \leq \infty:\\
\;\;\;\;t_5\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}\right)}{B}\\
\end{array}
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -inf.0 or -5.00000000000000007e-156 < (/.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 14.0%
Simplified26.3%
Taylor expanded in B around 0 26.3%
unpow226.3%
Simplified26.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))) < -5.00000000000000007e-156Initial program 98.4%
Simplified98.4%
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.0%
Taylor expanded in C around 0 1.5%
mul-1-neg1.5%
distribute-rgt-neg-in1.5%
unpow21.5%
unpow21.5%
hypot-def11.8%
Simplified11.8%
associate-*l/11.8%
Applied egg-rr11.8%
Final simplification29.4%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0)))))
(if (<= B 3.4e+30)
(/
(- (sqrt (* 2.0 (* t_0 (* F (+ A (+ A (* -0.5 (/ (* B B) (- C A))))))))))
t_0)
(/ (* (sqrt 2.0) (- (sqrt (* F (- A (hypot A B)))))) B))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (B <= 3.4e+30) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + (A + (-0.5 * ((B * B) / (C - A))))))))) / t_0;
} else {
tmp = (sqrt(2.0) * -sqrt((F * (A - hypot(A, B))))) / B;
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (B <= 3.4e+30) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + Float64(A + Float64(-0.5 * Float64(Float64(B * B) / Float64(C - A)))))))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(A - hypot(A, B)))))) / B); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 3.4e+30], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + N[(A + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / N[(C - A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / B), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;B \leq 3.4 \cdot 10^{+30}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + \left(A + -0.5 \cdot \frac{B \cdot B}{C - A}\right)\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}\right)}{B}\\
\end{array}
\end{array}
if B < 3.4000000000000002e30Initial program 20.2%
Simplified25.9%
Taylor expanded in B around 0 16.7%
unpow216.7%
Simplified16.7%
if 3.4000000000000002e30 < B Initial program 13.7%
Simplified13.7%
Taylor expanded in C around 0 17.8%
mul-1-neg17.8%
distribute-rgt-neg-in17.8%
unpow217.8%
unpow217.8%
hypot-def41.6%
Simplified41.6%
associate-*l/41.6%
Applied egg-rr41.6%
Final simplification21.2%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C))))
(t_1 (* F t_0))
(t_2 (- A (hypot A B))))
(if (<= B 2.55e-46)
(/ (- (sqrt (* 2.0 (* t_1 (+ A A))))) t_0)
(if (<= B 1.55e+70)
(/ (- (sqrt (* 2.0 (* t_1 t_2)))) t_0)
(* (sqrt (* F t_2)) (* (sqrt 2.0) (/ -1.0 B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = F * t_0;
double t_2 = A - hypot(A, B);
double tmp;
if (B <= 2.55e-46) {
tmp = -sqrt((2.0 * (t_1 * (A + A)))) / t_0;
} else if (B <= 1.55e+70) {
tmp = -sqrt((2.0 * (t_1 * t_2))) / t_0;
} else {
tmp = sqrt((F * t_2)) * (sqrt(2.0) * (-1.0 / B));
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = F * t_0;
double t_2 = A - Math.hypot(A, B);
double tmp;
if (B <= 2.55e-46) {
tmp = -Math.sqrt((2.0 * (t_1 * (A + A)))) / t_0;
} else if (B <= 1.55e+70) {
tmp = -Math.sqrt((2.0 * (t_1 * t_2))) / t_0;
} else {
tmp = Math.sqrt((F * t_2)) * (Math.sqrt(2.0) * (-1.0 / B));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = F * t_0 t_2 = A - math.hypot(A, B) tmp = 0 if B <= 2.55e-46: tmp = -math.sqrt((2.0 * (t_1 * (A + A)))) / t_0 elif B <= 1.55e+70: tmp = -math.sqrt((2.0 * (t_1 * t_2))) / t_0 else: tmp = math.sqrt((F * t_2)) * (math.sqrt(2.0) * (-1.0 / B)) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64(F * t_0) t_2 = Float64(A - hypot(A, B)) tmp = 0.0 if (B <= 2.55e-46) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A + A))))) / t_0); elseif (B <= 1.55e+70) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * t_2)))) / t_0); else tmp = Float64(sqrt(Float64(F * t_2)) * Float64(sqrt(2.0) * Float64(-1.0 / B))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
t_1 = F * t_0;
t_2 = A - hypot(A, B);
tmp = 0.0;
if (B <= 2.55e-46)
tmp = -sqrt((2.0 * (t_1 * (A + A)))) / t_0;
elseif (B <= 1.55e+70)
tmp = -sqrt((2.0 * (t_1 * t_2))) / t_0;
else
tmp = sqrt((F * t_2)) * (sqrt(2.0) * (-1.0 / B));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(F * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 2.55e-46], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 1.55e+70], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * t$95$2), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := F \cdot t_0\\
t_2 := A - \mathsf{hypot}\left(A, B\right)\\
\mathbf{if}\;B \leq 2.55 \cdot 10^{-46}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 1.55 \cdot 10^{+70}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot t_2\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot t_2} \cdot \left(\sqrt{2} \cdot \frac{-1}{B}\right)\\
\end{array}
\end{array}
if B < 2.5499999999999999e-46Initial program 19.0%
Simplified19.0%
Taylor expanded in C around inf 14.1%
cancel-sign-sub-inv14.1%
metadata-eval14.1%
*-lft-identity14.1%
Simplified14.1%
if 2.5499999999999999e-46 < B < 1.55000000000000015e70Initial program 36.7%
Simplified36.7%
Taylor expanded in C around 0 24.5%
unpow224.5%
unpow224.5%
hypot-def24.7%
Simplified24.7%
if 1.55000000000000015e70 < B Initial program 6.0%
Simplified6.0%
Taylor expanded in C around 0 15.3%
mul-1-neg15.3%
distribute-rgt-neg-in15.3%
unpow215.3%
unpow215.3%
hypot-def44.1%
Simplified44.1%
div-inv44.1%
Applied egg-rr44.1%
Final simplification19.7%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C))))
(t_1 (* F t_0))
(t_2 (- A (hypot A B))))
(if (<= B 6.5e-46)
(/ (- (sqrt (* 2.0 (* t_1 (+ A A))))) t_0)
(if (<= B 3e+69)
(/ (- (sqrt (* 2.0 (* t_1 t_2)))) t_0)
(* (sqrt (* F t_2)) (/ (- (sqrt 2.0)) B))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = F * t_0;
double t_2 = A - hypot(A, B);
double tmp;
if (B <= 6.5e-46) {
tmp = -sqrt((2.0 * (t_1 * (A + A)))) / t_0;
} else if (B <= 3e+69) {
tmp = -sqrt((2.0 * (t_1 * t_2))) / t_0;
} else {
tmp = sqrt((F * t_2)) * (-sqrt(2.0) / B);
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = F * t_0;
double t_2 = A - Math.hypot(A, B);
double tmp;
if (B <= 6.5e-46) {
tmp = -Math.sqrt((2.0 * (t_1 * (A + A)))) / t_0;
} else if (B <= 3e+69) {
tmp = -Math.sqrt((2.0 * (t_1 * t_2))) / t_0;
} else {
tmp = Math.sqrt((F * t_2)) * (-Math.sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = F * t_0 t_2 = A - math.hypot(A, B) tmp = 0 if B <= 6.5e-46: tmp = -math.sqrt((2.0 * (t_1 * (A + A)))) / t_0 elif B <= 3e+69: tmp = -math.sqrt((2.0 * (t_1 * t_2))) / t_0 else: tmp = math.sqrt((F * t_2)) * (-math.sqrt(2.0) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64(F * t_0) t_2 = Float64(A - hypot(A, B)) tmp = 0.0 if (B <= 6.5e-46) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A + A))))) / t_0); elseif (B <= 3e+69) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * t_2)))) / t_0); else tmp = Float64(sqrt(Float64(F * t_2)) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
t_1 = F * t_0;
t_2 = A - hypot(A, B);
tmp = 0.0;
if (B <= 6.5e-46)
tmp = -sqrt((2.0 * (t_1 * (A + A)))) / t_0;
elseif (B <= 3e+69)
tmp = -sqrt((2.0 * (t_1 * t_2))) / t_0;
else
tmp = sqrt((F * t_2)) * (-sqrt(2.0) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(F * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 6.5e-46], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 3e+69], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * t$95$2), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := F \cdot t_0\\
t_2 := A - \mathsf{hypot}\left(A, B\right)\\
\mathbf{if}\;B \leq 6.5 \cdot 10^{-46}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 3 \cdot 10^{+69}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot t_2\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot t_2} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 6.49999999999999966e-46Initial program 19.0%
Simplified19.0%
Taylor expanded in C around inf 14.1%
cancel-sign-sub-inv14.1%
metadata-eval14.1%
*-lft-identity14.1%
Simplified14.1%
if 6.49999999999999966e-46 < B < 2.99999999999999983e69Initial program 36.7%
Simplified36.7%
Taylor expanded in C around 0 24.5%
unpow224.5%
unpow224.5%
hypot-def24.7%
Simplified24.7%
if 2.99999999999999983e69 < B Initial program 6.0%
Simplified6.0%
Taylor expanded in C around 0 15.3%
mul-1-neg15.3%
distribute-rgt-neg-in15.3%
unpow215.3%
unpow215.3%
hypot-def44.1%
Simplified44.1%
Final simplification19.7%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C))))
(t_1 (* F t_0))
(t_2 (- A (hypot A B))))
(if (<= B 4e-46)
(/ (- (sqrt (* 2.0 (* t_1 (+ A A))))) t_0)
(if (<= B 1.55e+70)
(/ (- (sqrt (* 2.0 (* t_1 t_2)))) t_0)
(/ (* (sqrt 2.0) (- (sqrt (* F t_2)))) B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = F * t_0;
double t_2 = A - hypot(A, B);
double tmp;
if (B <= 4e-46) {
tmp = -sqrt((2.0 * (t_1 * (A + A)))) / t_0;
} else if (B <= 1.55e+70) {
tmp = -sqrt((2.0 * (t_1 * t_2))) / t_0;
} else {
tmp = (sqrt(2.0) * -sqrt((F * t_2))) / B;
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = F * t_0;
double t_2 = A - Math.hypot(A, B);
double tmp;
if (B <= 4e-46) {
tmp = -Math.sqrt((2.0 * (t_1 * (A + A)))) / t_0;
} else if (B <= 1.55e+70) {
tmp = -Math.sqrt((2.0 * (t_1 * t_2))) / t_0;
} else {
tmp = (Math.sqrt(2.0) * -Math.sqrt((F * t_2))) / B;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = F * t_0 t_2 = A - math.hypot(A, B) tmp = 0 if B <= 4e-46: tmp = -math.sqrt((2.0 * (t_1 * (A + A)))) / t_0 elif B <= 1.55e+70: tmp = -math.sqrt((2.0 * (t_1 * t_2))) / t_0 else: tmp = (math.sqrt(2.0) * -math.sqrt((F * t_2))) / B return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64(F * t_0) t_2 = Float64(A - hypot(A, B)) tmp = 0.0 if (B <= 4e-46) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A + A))))) / t_0); elseif (B <= 1.55e+70) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * t_2)))) / t_0); else tmp = Float64(Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * t_2)))) / B); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
t_1 = F * t_0;
t_2 = A - hypot(A, B);
tmp = 0.0;
if (B <= 4e-46)
tmp = -sqrt((2.0 * (t_1 * (A + A)))) / t_0;
elseif (B <= 1.55e+70)
tmp = -sqrt((2.0 * (t_1 * t_2))) / t_0;
else
tmp = (sqrt(2.0) * -sqrt((F * t_2))) / B;
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(F * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 4e-46], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 1.55e+70], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * t$95$2), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / B), $MachinePrecision]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := F \cdot t_0\\
t_2 := A - \mathsf{hypot}\left(A, B\right)\\
\mathbf{if}\;B \leq 4 \cdot 10^{-46}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 1.55 \cdot 10^{+70}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot t_2\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2} \cdot \left(-\sqrt{F \cdot t_2}\right)}{B}\\
\end{array}
\end{array}
if B < 4.00000000000000009e-46Initial program 19.0%
Simplified19.0%
Taylor expanded in C around inf 14.1%
cancel-sign-sub-inv14.1%
metadata-eval14.1%
*-lft-identity14.1%
Simplified14.1%
if 4.00000000000000009e-46 < B < 1.55000000000000015e70Initial program 36.7%
Simplified36.7%
Taylor expanded in C around 0 24.5%
unpow224.5%
unpow224.5%
hypot-def24.7%
Simplified24.7%
if 1.55000000000000015e70 < B Initial program 6.0%
Simplified6.0%
Taylor expanded in C around 0 15.3%
mul-1-neg15.3%
distribute-rgt-neg-in15.3%
unpow215.3%
unpow215.3%
hypot-def44.1%
Simplified44.1%
associate-*l/44.1%
Applied egg-rr44.1%
Final simplification19.7%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))) (t_1 (* F t_0)))
(if (<= B 8.6e-46)
(/ (- (sqrt (* 2.0 (* t_1 (+ A A))))) t_0)
(if (<= B 9.8e+69)
(/ (- (sqrt (* 2.0 (* t_1 (- A (hypot A B)))))) t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A B)))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = F * t_0;
double tmp;
if (B <= 8.6e-46) {
tmp = -sqrt((2.0 * (t_1 * (A + A)))) / t_0;
} else if (B <= 9.8e+69) {
tmp = -sqrt((2.0 * (t_1 * (A - hypot(A, B))))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = F * t_0;
double tmp;
if (B <= 8.6e-46) {
tmp = -Math.sqrt((2.0 * (t_1 * (A + A)))) / t_0;
} else if (B <= 9.8e+69) {
tmp = -Math.sqrt((2.0 * (t_1 * (A - Math.hypot(A, B))))) / t_0;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * (A - B)));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = F * t_0 tmp = 0 if B <= 8.6e-46: tmp = -math.sqrt((2.0 * (t_1 * (A + A)))) / t_0 elif B <= 9.8e+69: tmp = -math.sqrt((2.0 * (t_1 * (A - math.hypot(A, B))))) / t_0 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * (A - B))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64(F * t_0) tmp = 0.0 if (B <= 8.6e-46) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A + A))))) / t_0); elseif (B <= 9.8e+69) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A - hypot(A, B)))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - B))))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
t_1 = F * t_0;
tmp = 0.0;
if (B <= 8.6e-46)
tmp = -sqrt((2.0 * (t_1 * (A + A)))) / t_0;
elseif (B <= 9.8e+69)
tmp = -sqrt((2.0 * (t_1 * (A - hypot(A, B))))) / t_0;
else
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(F * t$95$0), $MachinePrecision]}, If[LessEqual[B, 8.6e-46], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 9.8e+69], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := F \cdot t_0\\
\mathbf{if}\;B \leq 8.6 \cdot 10^{-46}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 9.8 \cdot 10^{+69}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < 8.6000000000000007e-46Initial program 19.0%
Simplified19.0%
Taylor expanded in C around inf 14.1%
cancel-sign-sub-inv14.1%
metadata-eval14.1%
*-lft-identity14.1%
Simplified14.1%
if 8.6000000000000007e-46 < B < 9.7999999999999999e69Initial program 36.7%
Simplified36.7%
Taylor expanded in C around 0 24.5%
unpow224.5%
unpow224.5%
hypot-def24.7%
Simplified24.7%
if 9.7999999999999999e69 < B Initial program 6.0%
Simplified6.0%
Taylor expanded in C around 0 15.3%
mul-1-neg15.3%
distribute-rgt-neg-in15.3%
unpow215.3%
unpow215.3%
hypot-def44.1%
Simplified44.1%
Taylor expanded in A around 0 41.1%
mul-1-neg41.1%
unsub-neg41.1%
Simplified41.1%
Final simplification19.3%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 2.2e+52)
(/ (- (sqrt (* 2.0 (* (* F t_0) (+ A A))))) t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A B))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 2.2e+52) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (a * c))
if (b <= 2.2d+52) then
tmp = -sqrt((2.0d0 * ((f * t_0) * (a + a)))) / t_0
else
tmp = (sqrt(2.0d0) / b) * -sqrt((f * (a - b)))
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 2.2e+52) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * (A - B)));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) tmp = 0 if B <= 2.2e+52: tmp = -math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * (A - B))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= 2.2e+52) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + A))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - B))))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
tmp = 0.0;
if (B <= 2.2e+52)
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
else
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 2.2e+52], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 2.2 \cdot 10^{+52}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < 2.2e52Initial program 21.3%
Simplified21.3%
Taylor expanded in C around inf 14.4%
cancel-sign-sub-inv14.4%
metadata-eval14.4%
*-lft-identity14.4%
Simplified14.4%
if 2.2e52 < B Initial program 7.7%
Simplified7.7%
Taylor expanded in C around 0 16.1%
mul-1-neg16.1%
distribute-rgt-neg-in16.1%
unpow216.1%
unpow216.1%
hypot-def41.6%
Simplified41.6%
Taylor expanded in A around 0 38.9%
mul-1-neg38.9%
unsub-neg38.9%
Simplified38.9%
Final simplification18.5%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 2.8e+53)
(/ (- (sqrt (* 2.0 (* (* F t_0) (+ A A))))) t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* B (- F))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 2.8e+53) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((B * -F));
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (a * c))
if (b <= 2.8d+53) then
tmp = -sqrt((2.0d0 * ((f * t_0) * (a + a)))) / t_0
else
tmp = (sqrt(2.0d0) / b) * -sqrt((b * -f))
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 2.8e+53) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((B * -F));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) tmp = 0 if B <= 2.8e+53: tmp = -math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((B * -F)) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= 2.8e+53) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + A))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(B * Float64(-F))))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
tmp = 0.0;
if (B <= 2.8e+53)
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
else
tmp = (sqrt(2.0) / B) * -sqrt((B * -F));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 2.8e+53], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + A), $MachinePrecision]), $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}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 2.8 \cdot 10^{+53}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{B \cdot \left(-F\right)}\right)\\
\end{array}
\end{array}
if B < 2.8e53Initial program 21.3%
Simplified21.3%
Taylor expanded in C around inf 14.4%
cancel-sign-sub-inv14.4%
metadata-eval14.4%
*-lft-identity14.4%
Simplified14.4%
if 2.8e53 < B Initial program 7.7%
Simplified7.7%
Taylor expanded in C around 0 16.1%
mul-1-neg16.1%
distribute-rgt-neg-in16.1%
unpow216.1%
unpow216.1%
hypot-def41.6%
Simplified41.6%
Taylor expanded in A around 0 40.2%
mul-1-neg40.2%
Simplified40.2%
Final simplification18.8%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B 2e+90)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A A)))))) t_0)
(* -2.0 (/ (sqrt (* A F)) B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 2e+90) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
} else {
tmp = -2.0 * (sqrt((A * F)) / B);
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = (b * b) + ((-4.0d0) * (a * c))
if (b <= 2d+90) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (a + a))))) / t_0
else
tmp = (-2.0d0) * (sqrt((a * f)) / b)
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= 2e+90) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
} else {
tmp = -2.0 * (Math.sqrt((A * F)) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + (-4.0 * (A * C)) tmp = 0 if B <= 2e+90: tmp = -math.sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0 else: tmp = -2.0 * (math.sqrt((A * F)) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= 2e+90) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + A)))))) / t_0); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= 2e+90)
tmp = -sqrt((2.0 * (t_0 * (F * (A + A))))) / t_0;
else
tmp = -2.0 * (sqrt((A * F)) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 2e+90], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 2 \cdot 10^{+90}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 1.99999999999999993e90Initial program 20.8%
Simplified20.8%
Taylor expanded in C around inf 13.8%
cancel-sign-sub-inv13.8%
metadata-eval13.8%
*-lft-identity13.8%
Simplified13.8%
distribute-frac-neg13.8%
associate-*l*14.1%
cancel-sign-sub-inv14.1%
metadata-eval14.1%
cancel-sign-sub-inv14.1%
metadata-eval14.1%
Applied egg-rr14.1%
if 1.99999999999999993e90 < B Initial program 6.7%
Simplified6.7%
Taylor expanded in C around inf 3.6%
cancel-sign-sub-inv3.6%
metadata-eval3.6%
*-lft-identity3.6%
Simplified3.6%
Taylor expanded in B around inf 5.2%
Taylor expanded in B around inf 6.0%
associate-*r/6.1%
*-commutative6.1%
*-rgt-identity6.1%
Simplified6.1%
Final simplification13.1%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 1.15e+83)
(/ (- (sqrt (* 2.0 (* (* F t_0) (+ A A))))) t_0)
(* -2.0 (/ (sqrt (* A F)) B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 1.15e+83) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else {
tmp = -2.0 * (sqrt((A * F)) / B);
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (a * c))
if (b <= 1.15d+83) then
tmp = -sqrt((2.0d0 * ((f * t_0) * (a + a)))) / t_0
else
tmp = (-2.0d0) * (sqrt((a * f)) / b)
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 1.15e+83) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else {
tmp = -2.0 * (Math.sqrt((A * F)) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) tmp = 0 if B <= 1.15e+83: tmp = -math.sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0 else: tmp = -2.0 * (math.sqrt((A * F)) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= 1.15e+83) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + A))))) / t_0); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
tmp = 0.0;
if (B <= 1.15e+83)
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
else
tmp = -2.0 * (sqrt((A * F)) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 1.15e+83], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 1.15 \cdot 10^{+83}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 1.14999999999999997e83Initial program 21.0%
Simplified21.0%
Taylor expanded in C around inf 13.9%
cancel-sign-sub-inv13.9%
metadata-eval13.9%
*-lft-identity13.9%
Simplified13.9%
if 1.14999999999999997e83 < B Initial program 6.5%
Simplified6.5%
Taylor expanded in C around inf 3.5%
cancel-sign-sub-inv3.5%
metadata-eval3.5%
*-lft-identity3.5%
Simplified3.5%
Taylor expanded in B around inf 5.1%
Taylor expanded in B around inf 5.8%
associate-*r/5.9%
*-commutative5.9%
*-rgt-identity5.9%
Simplified5.9%
Final simplification12.8%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 100000000000.0)
(/
(- (sqrt (* 2.0 (* (+ A A) (* -4.0 (* F (* A C)))))))
(- (* B B) (* 4.0 (* A C))))
(* -2.0 (/ (sqrt (* A F)) B))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 100000000000.0) {
tmp = -sqrt((2.0 * ((A + A) * (-4.0 * (F * (A * C)))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = -2.0 * (sqrt((A * F)) / B);
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (b <= 100000000000.0d0) then
tmp = -sqrt((2.0d0 * ((a + a) * ((-4.0d0) * (f * (a * c)))))) / ((b * b) - (4.0d0 * (a * c)))
else
tmp = (-2.0d0) * (sqrt((a * f)) / b)
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= 100000000000.0) {
tmp = -Math.sqrt((2.0 * ((A + A) * (-4.0 * (F * (A * C)))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = -2.0 * (Math.sqrt((A * F)) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= 100000000000.0: tmp = -math.sqrt((2.0 * ((A + A) * (-4.0 * (F * (A * C)))))) / ((B * B) - (4.0 * (A * C))) else: tmp = -2.0 * (math.sqrt((A * F)) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 100000000000.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(A + A) * Float64(-4.0 * Float64(F * Float64(A * C))))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (B <= 100000000000.0)
tmp = -sqrt((2.0 * ((A + A) * (-4.0 * (F * (A * C)))))) / ((B * B) - (4.0 * (A * C)));
else
tmp = -2.0 * (sqrt((A * F)) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 100000000000.0], N[((-N[Sqrt[N[(2.0 * N[(N[(A + A), $MachinePrecision] * N[(-4.0 * N[(F * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 100000000000:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(A + A\right) \cdot \left(-4 \cdot \left(F \cdot \left(A \cdot C\right)\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 1e11Initial program 19.6%
Simplified19.6%
Taylor expanded in C around inf 13.9%
cancel-sign-sub-inv13.9%
metadata-eval13.9%
*-lft-identity13.9%
Simplified13.9%
Taylor expanded in B around 0 11.9%
associate-*r*13.6%
Simplified13.6%
if 1e11 < B Initial program 16.7%
Simplified16.7%
Taylor expanded in C around inf 6.9%
cancel-sign-sub-inv6.9%
metadata-eval6.9%
*-lft-identity6.9%
Simplified6.9%
Taylor expanded in B around inf 6.5%
Taylor expanded in B around inf 7.1%
associate-*r/7.1%
*-commutative7.1%
*-rgt-identity7.1%
Simplified7.1%
Final simplification12.3%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 1.15e-40)
(/
(- (sqrt (* 2.0 (* (* -8.0 (* A A)) (* C F)))))
(- (* B B) (* 4.0 (* A C))))
(* -2.0 (/ (sqrt (* A F)) B))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 1.15e-40) {
tmp = -sqrt((2.0 * ((-8.0 * (A * A)) * (C * F)))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = -2.0 * (sqrt((A * F)) / B);
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (b <= 1.15d-40) then
tmp = -sqrt((2.0d0 * (((-8.0d0) * (a * a)) * (c * f)))) / ((b * b) - (4.0d0 * (a * c)))
else
tmp = (-2.0d0) * (sqrt((a * f)) / b)
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= 1.15e-40) {
tmp = -Math.sqrt((2.0 * ((-8.0 * (A * A)) * (C * F)))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = -2.0 * (Math.sqrt((A * F)) / B);
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= 1.15e-40: tmp = -math.sqrt((2.0 * ((-8.0 * (A * A)) * (C * F)))) / ((B * B) - (4.0 * (A * C))) else: tmp = -2.0 * (math.sqrt((A * F)) / B) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 1.15e-40) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(-8.0 * Float64(A * A)) * Float64(C * F))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (B <= 1.15e-40)
tmp = -sqrt((2.0 * ((-8.0 * (A * A)) * (C * F)))) / ((B * B) - (4.0 * (A * C)));
else
tmp = -2.0 * (sqrt((A * F)) / B);
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 1.15e-40], N[((-N[Sqrt[N[(2.0 * N[(N[(-8.0 * N[(A * A), $MachinePrecision]), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 1.15 \cdot 10^{-40}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(-8 \cdot \left(A \cdot A\right)\right) \cdot \left(C \cdot F\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 1.15e-40Initial program 19.3%
Simplified19.3%
Taylor expanded in C around inf 13.9%
cancel-sign-sub-inv13.9%
metadata-eval13.9%
*-lft-identity13.9%
Simplified13.9%
Taylor expanded in B around 0 9.0%
associate-*r*9.0%
unpow29.0%
*-commutative9.0%
Simplified9.0%
if 1.15e-40 < B Initial program 18.3%
Simplified18.3%
Taylor expanded in C around inf 8.1%
cancel-sign-sub-inv8.1%
metadata-eval8.1%
*-lft-identity8.1%
Simplified8.1%
Taylor expanded in B around inf 5.5%
Taylor expanded in B around inf 6.0%
associate-*r/6.0%
*-commutative6.0%
*-rgt-identity6.0%
Simplified6.0%
Final simplification8.3%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* -2.0 (/ (sqrt (* A F)) B)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (sqrt((A * F)) / B);
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (-2.0d0) * (sqrt((a * f)) / b)
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return -2.0 * (Math.sqrt((A * F)) / B);
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.sqrt((A * F)) / B)
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (sqrt((A * F)) / B);
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \frac{\sqrt{A \cdot F}}{B}
\end{array}
Initial program 19.0%
Simplified19.0%
Taylor expanded in C around inf 12.5%
cancel-sign-sub-inv12.5%
metadata-eval12.5%
*-lft-identity12.5%
Simplified12.5%
Taylor expanded in B around inf 2.6%
Taylor expanded in B around inf 2.7%
associate-*r/2.7%
*-commutative2.7%
*-rgt-identity2.7%
Simplified2.7%
Final simplification2.7%
herbie shell --seed 2023282
(FPCore (A B C F)
:name "ABCF->ab-angle b"
:precision binary64
(/ (- (sqrt (* (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F)) (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))) (- (pow B 2.0) (* (* 4.0 A) C))))