
(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 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C))))
(t_1 (fma B B (* A (* C -4.0))))
(t_2 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_3
(/
(-
(sqrt
(*
(* 2.0 (* F t_2))
(- (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_2)))
(if (<= t_3 -2e-205)
(/
(*
(sqrt (* 2.0 (* F (+ A (- C (hypot (- A C) B))))))
(- (sqrt (fma B B (* C (* A -4.0))))))
t_1)
(if (<= t_3 1e+201)
(/
(-
(sqrt
(*
2.0
(*
(* F t_0)
(+ A (fma -0.5 (/ (+ (* B B) (- (* A A) (* A A))) C) A))))))
t_0)
(if (<= t_3 INFINITY)
(/
(*
(sqrt
(*
(+ C (- A (hypot B (- A C))))
(fma C (* A -8.0) (* B (* 2.0 B)))))
(- (sqrt F)))
t_1)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A (hypot 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 = fma(B, B, (A * (C * -4.0)));
double t_2 = pow(B, 2.0) - ((4.0 * A) * C);
double t_3 = -sqrt(((2.0 * (F * t_2)) * ((A + C) - sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_2;
double tmp;
if (t_3 <= -2e-205) {
tmp = (sqrt((2.0 * (F * (A + (C - hypot((A - C), B)))))) * -sqrt(fma(B, B, (C * (A * -4.0))))) / t_1;
} else if (t_3 <= 1e+201) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + fma(-0.5, (((B * B) + ((A * A) - (A * A))) / C), A))))) / t_0;
} else if (t_3 <= ((double) INFINITY)) {
tmp = (sqrt(((C + (A - hypot(B, (A - C)))) * fma(C, (A * -8.0), (B * (2.0 * B))))) * -sqrt(F)) / t_1;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(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 = fma(B, B, Float64(A * Float64(C * -4.0))) t_2 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_3 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_2)) * Float64(Float64(A + C) - sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_2) tmp = 0.0 if (t_3 <= -2e-205) tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(F * Float64(A + Float64(C - hypot(Float64(A - C), B)))))) * Float64(-sqrt(fma(B, B, Float64(C * Float64(A * -4.0)))))) / t_1); elseif (t_3 <= 1e+201) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + fma(-0.5, Float64(Float64(Float64(B * B) + Float64(Float64(A * A) - Float64(A * A))) / C), A)))))) / t_0); elseif (t_3 <= Inf) tmp = Float64(Float64(sqrt(Float64(Float64(C + Float64(A - hypot(B, Float64(A - C)))) * fma(C, Float64(A * -8.0), Float64(B * Float64(2.0 * B))))) * Float64(-sqrt(F))) / t_1); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - hypot(A, B)))))); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[((-N[Sqrt[N[(N[(2.0 * N[(F * t$95$2), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, -2e-205], N[(N[(N[Sqrt[N[(2.0 * N[(F * N[(A + N[(C - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$3, 1e+201], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + N[(-0.5 * N[(N[(N[(B * B), $MachinePrecision] + N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision] + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(N[(N[Sqrt[N[(N[(C + N[(A - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(C * N[(A * -8.0), $MachinePrecision] + N[(B * N[(2.0 * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[F], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $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 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := \frac{-\sqrt{\left(2 \cdot \left(F \cdot t_2\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\
\mathbf{if}\;t_3 \leq -2 \cdot 10^{-205}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(A - C, B\right)\right)\right)\right)} \cdot \left(-\sqrt{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}\right)}{t_1}\\
\mathbf{elif}\;t_3 \leq 10^{+201}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + \mathsf{fma}\left(-0.5, \frac{B \cdot B + \left(A \cdot A - A \cdot A\right)}{C}, A\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\left(C + \left(A - \mathsf{hypot}\left(B, A - C\right)\right)\right) \cdot \mathsf{fma}\left(C, A \cdot -8, B \cdot \left(2 \cdot B\right)\right)} \cdot \left(-\sqrt{F}\right)}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\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))) < -2e-205Initial program 42.6%
Simplified51.5%
sqrt-prod67.5%
associate-*r*67.5%
*-commutative67.5%
associate-*l*67.5%
associate--r-67.2%
+-commutative67.2%
Applied egg-rr67.2%
hypot-def54.2%
unpow254.2%
unpow254.2%
+-commutative54.2%
unpow254.2%
unpow254.2%
hypot-def67.2%
Simplified67.2%
if -2e-205 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < 1.00000000000000004e201Initial program 28.4%
Simplified28.4%
Taylor expanded in C around inf 43.9%
associate--l+43.9%
fma-neg43.9%
associate--l+44.2%
unpow244.2%
unpow244.2%
unpow244.2%
mul-1-neg44.2%
mul-1-neg44.2%
sqr-neg44.2%
mul-1-neg44.2%
Simplified44.2%
if 1.00000000000000004e201 < (/.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 4.4%
Simplified22.3%
sqrt-prod57.8%
associate--r-57.8%
associate-*r*57.8%
Applied egg-rr57.8%
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.7%
mul-1-neg1.7%
*-commutative1.7%
+-commutative1.7%
unpow21.7%
unpow21.7%
hypot-def18.1%
Simplified18.1%
Final simplification42.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
(if (<= B 2.7e-31)
(/
(- (sqrt (* 2.0 (* (fma B B (* A (* C -4.0))) (* 2.0 (* A F))))))
(- (* B B) (* 4.0 (* A C))))
(* (sqrt (* F (- A (hypot A B)))) (/ (- (sqrt 2.0)) B))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 2.7e-31) {
tmp = -sqrt((2.0 * (fma(B, B, (A * (C * -4.0))) * (2.0 * (A * F))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = sqrt((F * (A - hypot(A, B)))) * (-sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 2.7e-31) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(fma(B, B, Float64(A * Float64(C * -4.0))) * Float64(2.0 * Float64(A * F)))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(A, B)))) * Float64(Float64(-sqrt(2.0)) / B)); end return tmp end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 2.7e-31], N[((-N[Sqrt[N[(2.0 * N[(N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 2.7 \cdot 10^{-31}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot \left(2 \cdot \left(A \cdot F\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if B < 2.70000000000000014e-31Initial program 20.3%
Simplified20.3%
Taylor expanded in A around -inf 16.4%
*-commutative16.4%
Simplified16.4%
*-un-lft-identity16.4%
associate-*l*17.4%
cancel-sign-sub-inv17.4%
metadata-eval17.4%
*-commutative17.4%
associate-*r*17.4%
fma-udef17.4%
Applied egg-rr17.4%
*-lft-identity17.4%
*-commutative17.4%
associate-*r*17.4%
*-commutative17.4%
*-commutative17.4%
Simplified17.4%
if 2.70000000000000014e-31 < B Initial program 18.4%
Simplified18.4%
Taylor expanded in C around 0 25.6%
mul-1-neg25.6%
*-commutative25.6%
+-commutative25.6%
unpow225.6%
unpow225.6%
hypot-def51.9%
Simplified51.9%
Final simplification26.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
(if (<= B 0.02)
(/
(- (sqrt (* 2.0 (* (fma B B (* A (* C -4.0))) (* 2.0 (* A F))))))
(- (* B B) (* 4.0 (* A C))))
(* (/ (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 tmp;
if (B <= 0.02) {
tmp = -sqrt((2.0 * (fma(B, B, (A * (C * -4.0))) * (2.0 * (A * F))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 0.02) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(fma(B, B, Float64(A * Float64(C * -4.0))) * Float64(2.0 * Float64(A * F)))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - 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_] := If[LessEqual[B, 0.02], N[((-N[Sqrt[N[(2.0 * N[(N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 0.02:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot \left(2 \cdot \left(A \cdot F\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < 0.0200000000000000004Initial program 20.3%
Simplified20.3%
Taylor expanded in A around -inf 16.4%
*-commutative16.4%
Simplified16.4%
*-un-lft-identity16.4%
associate-*l*17.4%
cancel-sign-sub-inv17.4%
metadata-eval17.4%
*-commutative17.4%
associate-*r*17.4%
fma-udef17.4%
Applied egg-rr17.4%
*-lft-identity17.4%
*-commutative17.4%
associate-*r*17.4%
*-commutative17.4%
*-commutative17.4%
Simplified17.4%
if 0.0200000000000000004 < B Initial program 18.4%
Simplified18.4%
Taylor expanded in C around 0 27.5%
mul-1-neg27.5%
*-commutative27.5%
+-commutative27.5%
unpow227.5%
unpow227.5%
hypot-def56.3%
Simplified56.3%
Taylor expanded in A around 0 54.6%
mul-1-neg54.6%
unsub-neg54.6%
Simplified54.6%
Final simplification26.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 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 0.0125)
(/ (- (sqrt (* 2.0 (* (* F t_0) (* 2.0 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 <= 0.0125) {
tmp = -sqrt((2.0 * ((F * t_0) * (2.0 * 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 <= 0.0125d0) then
tmp = -sqrt((2.0d0 * ((f * t_0) * (2.0d0 * 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 <= 0.0125) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (2.0 * 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 <= 0.0125: tmp = -math.sqrt((2.0 * ((F * t_0) * (2.0 * 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 <= 0.0125) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(2.0 * A))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - B))))); end return tmp end
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 <= 0.0125)
tmp = -sqrt((2.0 * ((F * t_0) * (2.0 * 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, 0.0125], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(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 0.0125:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < 0.012500000000000001Initial program 20.3%
Simplified20.3%
Taylor expanded in A around -inf 16.4%
*-commutative16.4%
Simplified16.4%
if 0.012500000000000001 < B Initial program 18.4%
Simplified18.4%
Taylor expanded in C around 0 27.5%
mul-1-neg27.5%
*-commutative27.5%
+-commutative27.5%
unpow227.5%
unpow227.5%
hypot-def56.3%
Simplified56.3%
Taylor expanded in A around 0 54.6%
mul-1-neg54.6%
unsub-neg54.6%
Simplified54.6%
Final simplification25.6%
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 0.013)
(/ (- (sqrt (* 2.0 (* (* F t_0) (* 2.0 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 <= 0.013) {
tmp = -sqrt((2.0 * ((F * t_0) * (2.0 * 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 <= 0.013d0) then
tmp = -sqrt((2.0d0 * ((f * t_0) * (2.0d0 * 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 <= 0.013) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (2.0 * 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 <= 0.013: tmp = -math.sqrt((2.0 * ((F * t_0) * (2.0 * 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 <= 0.013) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(2.0 * A))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(-Float64(B * 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 <= 0.013)
tmp = -sqrt((2.0 * ((F * t_0) * (2.0 * 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, 0.013], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(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 0.013:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{-B \cdot F}\right)\\
\end{array}
\end{array}
if B < 0.0129999999999999994Initial program 20.3%
Simplified20.3%
Taylor expanded in A around -inf 16.4%
*-commutative16.4%
Simplified16.4%
if 0.0129999999999999994 < B Initial program 18.4%
Simplified18.4%
Taylor expanded in C around 0 27.5%
mul-1-neg27.5%
*-commutative27.5%
+-commutative27.5%
unpow227.5%
unpow227.5%
hypot-def56.3%
Simplified56.3%
Taylor expanded in A around 0 55.0%
mul-1-neg55.0%
Simplified55.0%
Final simplification25.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 0.0118)
(/ (- (sqrt (* 2.0 (* t_1 (* 2.0 A))))) t_0)
(/ (- (sqrt (* 2.0 (* t_1 (- (+ A C) B))))) t_0))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = F * t_0;
double tmp;
if (B <= 0.0118) {
tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
} else {
tmp = -sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0;
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (a * c))
t_1 = f * t_0
if (b <= 0.0118d0) then
tmp = -sqrt((2.0d0 * (t_1 * (2.0d0 * a)))) / t_0
else
tmp = -sqrt((2.0d0 * (t_1 * ((a + c) - b)))) / t_0
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = F * t_0;
double tmp;
if (B <= 0.0118) {
tmp = -Math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
} else {
tmp = -Math.sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = F * t_0 tmp = 0 if B <= 0.0118: tmp = -math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0 else: tmp = -math.sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0 return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64(F * t_0) tmp = 0.0 if (B <= 0.0118) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(2.0 * A))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(Float64(A + C) - B))))) / t_0); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
t_1 = F * t_0;
tmp = 0.0;
if (B <= 0.0118)
tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
else
tmp = -sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0;
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(F * t$95$0), $MachinePrecision]}, If[LessEqual[B, 0.0118], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(N[(A + C), $MachinePrecision] - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := F \cdot t_0\\
\mathbf{if}\;B \leq 0.0118:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(\left(A + C\right) - B\right)\right)}}{t_0}\\
\end{array}
\end{array}
if B < 0.0117999999999999997Initial program 20.3%
Simplified20.3%
Taylor expanded in A around -inf 16.4%
*-commutative16.4%
Simplified16.4%
if 0.0117999999999999997 < B Initial program 18.4%
Simplified18.4%
Taylor expanded in B around inf 18.3%
Final simplification16.9%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 2.1e+50)
(/ (- (sqrt (* 2.0 (* (* F t_0) (* 2.0 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 <= 2.1e+50) {
tmp = -sqrt((2.0 * ((F * t_0) * (2.0 * 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 <= 2.1d+50) then
tmp = -sqrt((2.0d0 * ((f * t_0) * (2.0d0 * 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 <= 2.1e+50) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (2.0 * 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 <= 2.1e+50: tmp = -math.sqrt((2.0 * ((F * t_0) * (2.0 * 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 <= 2.1e+50) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(2.0 * 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 <= 2.1e+50)
tmp = -sqrt((2.0 * ((F * t_0) * (2.0 * 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, 2.1e+50], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-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.1 \cdot 10^{+50}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 2.1e50Initial program 22.1%
Simplified22.1%
Taylor expanded in A around -inf 15.7%
*-commutative15.7%
Simplified15.7%
if 2.1e50 < B Initial program 10.5%
Simplified10.5%
Taylor expanded in A around -inf 2.7%
*-commutative2.7%
Simplified2.7%
Taylor expanded in B around inf 4.7%
associate-*r/4.8%
*-rgt-identity4.8%
Simplified4.8%
Final simplification13.6%
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.3e+51)
(/
(- (sqrt (* 2.0 (* (* 2.0 A) (* -4.0 (* 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.3e+51) {
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (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.3d+51) then
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * ((-4.0d0) * (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.3e+51) {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (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.3e+51: tmp = -math.sqrt((2.0 * ((2.0 * A) * (-4.0 * (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.3e+51) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(-4.0 * Float64(A * Float64(C * F))))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); 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.3e+51)
tmp = -sqrt((2.0 * ((2.0 * A) * (-4.0 * (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.3e+51], N[((-N[Sqrt[N[(2.0 * N[(N[(2.0 * A), $MachinePrecision] * N[(-4.0 * N[(A * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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.3 \cdot 10^{+51}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 1.3000000000000001e51Initial program 22.1%
Simplified22.1%
Taylor expanded in A around -inf 15.7%
*-commutative15.7%
Simplified15.7%
Taylor expanded in B around 0 13.0%
*-commutative13.0%
Simplified13.0%
if 1.3000000000000001e51 < B Initial program 10.5%
Simplified10.5%
Taylor expanded in A around -inf 2.7%
*-commutative2.7%
Simplified2.7%
Taylor expanded in B around inf 4.7%
associate-*r/4.8%
*-rgt-identity4.8%
Simplified4.8%
Final simplification11.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
(if (<= B 1.85e+50)
(/
(- (sqrt (* 2.0 (* (* 2.0 A) (* F (* A (* C -4.0)))))))
(- (* 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.85e+50) {
tmp = -sqrt((2.0 * ((2.0 * A) * (F * (A * (C * -4.0)))))) / ((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.85d+50) then
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * (f * (a * (c * (-4.0d0))))))) / ((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.85e+50) {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * (F * (A * (C * -4.0)))))) / ((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.85e+50: tmp = -math.sqrt((2.0 * ((2.0 * A) * (F * (A * (C * -4.0)))))) / ((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.85e+50) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(F * Float64(A * Float64(C * -4.0))))))) / 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.85e+50)
tmp = -sqrt((2.0 * ((2.0 * A) * (F * (A * (C * -4.0)))))) / ((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.85e+50], N[((-N[Sqrt[N[(2.0 * N[(N[(2.0 * A), $MachinePrecision] * N[(F * N[(A * N[(C * -4.0), $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 1.85 \cdot 10^{+50}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(F \cdot \left(A \cdot \left(C \cdot -4\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 < 1.85e50Initial program 22.1%
Simplified22.1%
Taylor expanded in A around -inf 15.7%
*-commutative15.7%
Simplified15.7%
Taylor expanded in B around 0 15.3%
*-commutative15.3%
associate-*r*15.3%
Simplified15.3%
if 1.85e50 < B Initial program 10.5%
Simplified10.5%
Taylor expanded in A around -inf 2.7%
*-commutative2.7%
Simplified2.7%
Taylor expanded in B around inf 4.7%
associate-*r/4.8%
*-rgt-identity4.8%
Simplified4.8%
Final simplification13.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 (* -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.8%
Simplified19.8%
Taylor expanded in A around -inf 13.1%
*-commutative13.1%
Simplified13.1%
Taylor expanded in B around inf 2.2%
associate-*r/2.2%
*-rgt-identity2.2%
Simplified2.2%
Final simplification2.2%
herbie shell --seed 2023200
(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))))