
(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 (* t_2 F))
(- (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_2)))
(if (<= t_3 -5e-172)
(/
(*
(sqrt (* 2.0 (* F (+ A (- C (hypot (- A C) B))))))
(- (sqrt (fma B B (* C (* A -4.0))))))
t_1)
(if (<= t_3 2e-89)
(/
(-
(sqrt
(*
2.0
(*
(* F t_0)
(+ A (+ A (* -0.5 (/ (+ (* B B) (- (* A A) (* A A))) C))))))))
t_0)
(if (<= t_3 INFINITY)
(/
(*
(sqrt
(*
(+ A (- A (* -0.5 (* B (/ B A)))))
(fma C (* A -8.0) (* B (* 2.0 B)))))
(- (sqrt F)))
t_1)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- C (hypot C 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 * (t_2 * F)) * ((A + C) - sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_2;
double tmp;
if (t_3 <= -5e-172) {
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 <= 2e-89) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / t_0;
} else if (t_3 <= ((double) INFINITY)) {
tmp = (sqrt(((A + (A - (-0.5 * (B * (B / A))))) * fma(C, (A * -8.0), (B * (2.0 * B))))) * -sqrt(F)) / t_1;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (C - hypot(C, 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(t_2 * F)) * Float64(Float64(A + C) - sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_2) tmp = 0.0 if (t_3 <= -5e-172) 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 <= 2e-89) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + Float64(A + Float64(-0.5 * Float64(Float64(Float64(B * B) + Float64(Float64(A * A) - Float64(A * A))) / C)))))))) / t_0); elseif (t_3 <= Inf) tmp = Float64(Float64(sqrt(Float64(Float64(A + Float64(A - Float64(-0.5 * Float64(B * Float64(B / A))))) * 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(C - hypot(C, 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[(t$95$2 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, -5e-172], 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, 2e-89], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + N[(A + N[(-0.5 * N[(N[(N[(B * B), $MachinePrecision] + N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(N[(N[Sqrt[N[(N[(A + N[(A - N[(-0.5 * N[(B * N[(B / A), $MachinePrecision]), $MachinePrecision]), $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[(C - N[Sqrt[C ^ 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(t_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\
\mathbf{if}\;t_3 \leq -5 \cdot 10^{-172}:\\
\;\;\;\;\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 2 \cdot 10^{-89}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + \left(A + -0.5 \cdot \frac{B \cdot B + \left(A \cdot A - A \cdot A\right)}{C}\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\left(A + \left(A - -0.5 \cdot \left(B \cdot \frac{B}{A}\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(C - \mathsf{hypot}\left(C, 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))) < -4.9999999999999999e-172Initial program 42.7%
Simplified54.0%
sqrt-prod63.8%
associate-*r*63.8%
*-commutative63.8%
associate-*l*63.8%
associate--r-63.0%
+-commutative63.0%
Applied egg-rr63.0%
hypot-def47.6%
unpow247.6%
unpow247.6%
+-commutative47.6%
unpow247.6%
unpow247.6%
hypot-def63.0%
Simplified63.0%
if -4.9999999999999999e-172 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < 2.00000000000000008e-89Initial program 8.6%
Simplified8.6%
Taylor expanded in C around inf 18.1%
associate--l+18.1%
associate--l+18.4%
unpow218.4%
unpow218.4%
unpow218.4%
mul-1-neg18.4%
mul-1-neg18.4%
sqr-neg18.4%
mul-1-neg18.4%
Simplified18.4%
if 2.00000000000000008e-89 < (/.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 35.6%
Simplified40.0%
Taylor expanded in A around -inf 27.1%
fma-def27.1%
unpow227.1%
mul-1-neg27.1%
Simplified27.1%
sqrt-prod41.3%
associate-/l*41.3%
Applied egg-rr41.3%
fma-udef41.3%
unsub-neg41.3%
associate-/r/41.3%
associate-*r*41.3%
Simplified41.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))) Initial program 0.0%
Simplified0.0%
Taylor expanded in A around 0 1.9%
mul-1-neg1.9%
*-commutative1.9%
+-commutative1.9%
unpow21.9%
unpow21.9%
hypot-def18.5%
Simplified18.5%
Final simplification33.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 1180.0)
(/ (- (sqrt (* 2.0 (* (* F t_0) (* 2.0 A))))) t_0)
(/ (- (sqrt (* (* 2.0 F) (- A (hypot B 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 <= 1180.0) {
tmp = -sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0;
} else {
tmp = -sqrt(((2.0 * F) * (A - hypot(B, 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 tmp;
if (B <= 1180.0) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0;
} else {
tmp = -Math.sqrt(((2.0 * F) * (A - Math.hypot(B, 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 <= 1180.0: tmp = -math.sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0 else: tmp = -math.sqrt(((2.0 * F) * (A - math.hypot(B, 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 <= 1180.0) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(2.0 * A))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * F) * Float64(A - hypot(B, 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 <= 1180.0)
tmp = -sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0;
else
tmp = -sqrt(((2.0 * F) * (A - hypot(B, 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, 1180.0], 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[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $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)\\
\mathbf{if}\;B \leq 1180:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot F\right) \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}}{B}\\
\end{array}
\end{array}
if B < 1180Initial program 19.1%
Simplified19.1%
Taylor expanded in A around -inf 12.2%
*-commutative12.2%
Simplified12.2%
if 1180 < B Initial program 11.6%
Simplified11.6%
Taylor expanded in C around 0 17.0%
mul-1-neg17.0%
*-commutative17.0%
unpow217.0%
unpow217.0%
Simplified17.0%
associate-*l/17.0%
+-commutative17.0%
hypot-udef48.3%
hypot-udef17.0%
+-commutative17.0%
hypot-def48.3%
Applied egg-rr48.3%
pow148.3%
sqrt-unprod48.5%
Applied egg-rr48.5%
unpow148.5%
associate-*r*48.5%
Simplified48.5%
Final simplification21.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 4600.0)
(/ (- (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 <= 4600.0) {
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 <= 4600.0d0) 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 <= 4600.0) {
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 <= 4600.0: 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 <= 4600.0) 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 <= 4600.0)
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, 4600.0], 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 4600:\\
\;\;\;\;\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 < 4600Initial program 19.1%
Simplified19.1%
Taylor expanded in A around -inf 12.2%
*-commutative12.2%
Simplified12.2%
if 4600 < B Initial program 11.6%
Simplified11.6%
Taylor expanded in C around 0 17.0%
mul-1-neg17.0%
*-commutative17.0%
unpow217.0%
unpow217.0%
Simplified17.0%
Taylor expanded in B around inf 44.0%
Final simplification20.0%
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 780.0)
(/ (- (sqrt (* 2.0 (* (* F t_0) (* 2.0 A))))) t_0)
(/ (* (sqrt 2.0) (- (sqrt (* F (- A B))))) 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 <= 780.0) {
tmp = -sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0;
} else {
tmp = (sqrt(2.0) * -sqrt((F * (A - B)))) / 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 <= 780.0d0) then
tmp = -sqrt((2.0d0 * ((f * t_0) * (2.0d0 * a)))) / t_0
else
tmp = (sqrt(2.0d0) * -sqrt((f * (a - b)))) / 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 <= 780.0) {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0;
} else {
tmp = (Math.sqrt(2.0) * -Math.sqrt((F * (A - B)))) / 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 <= 780.0: tmp = -math.sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0 else: tmp = (math.sqrt(2.0) * -math.sqrt((F * (A - B)))) / 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 <= 780.0) 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) * Float64(-sqrt(Float64(F * Float64(A - B))))) / 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 <= 780.0)
tmp = -sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0;
else
tmp = (sqrt(2.0) * -sqrt((F * (A - B)))) / 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, 780.0], 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] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $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)\\
\mathbf{if}\;B \leq 780:\\
\;\;\;\;\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} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)}{B}\\
\end{array}
\end{array}
if B < 780Initial program 19.1%
Simplified19.1%
Taylor expanded in A around -inf 12.2%
*-commutative12.2%
Simplified12.2%
if 780 < B Initial program 11.6%
Simplified11.6%
Taylor expanded in C around 0 17.0%
mul-1-neg17.0%
*-commutative17.0%
unpow217.0%
unpow217.0%
Simplified17.0%
associate-*l/17.0%
+-commutative17.0%
hypot-udef48.3%
hypot-udef17.0%
+-commutative17.0%
hypot-def48.3%
Applied egg-rr48.3%
Taylor expanded in A around 0 44.0%
mul-1-neg44.0%
sub-neg44.0%
Simplified44.0%
Final simplification20.0%
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 850.0)
(/ (- (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 <= 850.0) {
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 <= 850.0d0) 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 <= 850.0) {
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 <= 850.0: 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 <= 850.0) 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(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 <= 850.0)
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, 850.0], 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 850:\\
\;\;\;\;\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 \left(-F\right)}\right)\\
\end{array}
\end{array}
if B < 850Initial program 19.1%
Simplified19.1%
Taylor expanded in A around -inf 12.2%
*-commutative12.2%
Simplified12.2%
if 850 < B Initial program 11.6%
Simplified11.6%
Taylor expanded in C around 0 17.0%
mul-1-neg17.0%
*-commutative17.0%
unpow217.0%
unpow217.0%
Simplified17.0%
Taylor expanded in B around inf 44.0%
Taylor expanded in A around 0 43.8%
mul-1-neg43.8%
distribute-rgt-neg-in43.8%
Simplified43.8%
Final simplification20.0%
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 (<= C 3e-13)
(/ (- (sqrt (* 2.0 (* t_1 (* 2.0 A))))) t_0)
(/
(-
(sqrt
(*
2.0
(* t_1 (+ A (+ A (* -0.5 (/ (+ (* B B) (- (* A A) (* A A))) C))))))))
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 (C <= 3e-13) {
tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
} else {
tmp = -sqrt((2.0 * (t_1 * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / 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 (c <= 3d-13) then
tmp = -sqrt((2.0d0 * (t_1 * (2.0d0 * a)))) / t_0
else
tmp = -sqrt((2.0d0 * (t_1 * (a + (a + ((-0.5d0) * (((b * b) + ((a * a) - (a * a))) / c))))))) / 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 (C <= 3e-13) {
tmp = -Math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
} else {
tmp = -Math.sqrt((2.0 * (t_1 * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / 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 C <= 3e-13: tmp = -math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0 else: tmp = -math.sqrt((2.0 * (t_1 * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / 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 (C <= 3e-13) 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(A + Float64(A + Float64(-0.5 * Float64(Float64(Float64(B * B) + Float64(Float64(A * A) - Float64(A * A))) / C)))))))) / 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 (C <= 3e-13)
tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
else
tmp = -sqrt((2.0 * (t_1 * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / 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[C, 3e-13], 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[(A + N[(A + N[(-0.5 * N[(N[(N[(B * B), $MachinePrecision] + N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}\;C \leq 3 \cdot 10^{-13}:\\
\;\;\;\;\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(A + \left(A + -0.5 \cdot \frac{B \cdot B + \left(A \cdot A - A \cdot A\right)}{C}\right)\right)\right)}}{t_0}\\
\end{array}
\end{array}
if C < 2.99999999999999984e-13Initial program 22.2%
Simplified22.2%
Taylor expanded in A around -inf 11.6%
*-commutative11.6%
Simplified11.6%
if 2.99999999999999984e-13 < C Initial program 2.7%
Simplified2.7%
Taylor expanded in C around inf 21.0%
associate--l+21.0%
associate--l+21.0%
unpow221.0%
unpow221.0%
unpow221.0%
mul-1-neg21.0%
mul-1-neg21.0%
sqr-neg21.0%
mul-1-neg21.0%
Simplified21.0%
Final simplification14.0%
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))))) (/ (- (sqrt (* 2.0 (* (* F t_0) (* 2.0 A))))) 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));
return -sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0;
}
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
t_0 = (b * b) - (4.0d0 * (a * c))
code = -sqrt((2.0d0 * ((f * t_0) * (2.0d0 * a)))) / t_0
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));
return -Math.sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) return -math.sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0
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))) return Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(2.0 * A))))) / t_0) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
tmp = -sqrt((2.0 * ((F * t_0) * (2.0 * A)))) / t_0;
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]}, 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]]
\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)\\
\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}
\end{array}
\end{array}
Initial program 17.3%
Simplified17.3%
Taylor expanded in A around -inf 10.6%
*-commutative10.6%
Simplified10.6%
Final simplification10.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 (<= A -3.8e+155)
(* -2.0 (/ (sqrt (* A F)) B))
(/
(- (sqrt (* 2.0 (* -8.0 (* (* A A) (* C F))))))
(- (* B B) (* 4.0 (* A C))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (A <= -3.8e+155) {
tmp = -2.0 * (sqrt((A * F)) / B);
} else {
tmp = -sqrt((2.0 * (-8.0 * ((A * A) * (C * F))))) / ((B * B) - (4.0 * (A * C)));
}
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 (a <= (-3.8d+155)) then
tmp = (-2.0d0) * (sqrt((a * f)) / b)
else
tmp = -sqrt((2.0d0 * ((-8.0d0) * ((a * a) * (c * f))))) / ((b * b) - (4.0d0 * (a * c)))
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 (A <= -3.8e+155) {
tmp = -2.0 * (Math.sqrt((A * F)) / B);
} else {
tmp = -Math.sqrt((2.0 * (-8.0 * ((A * A) * (C * F))))) / ((B * B) - (4.0 * (A * C)));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if A <= -3.8e+155: tmp = -2.0 * (math.sqrt((A * F)) / B) else: tmp = -math.sqrt((2.0 * (-8.0 * ((A * A) * (C * F))))) / ((B * B) - (4.0 * (A * C))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (A <= -3.8e+155) tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-8.0 * Float64(Float64(A * A) * Float64(C * F)))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); 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 (A <= -3.8e+155)
tmp = -2.0 * (sqrt((A * F)) / B);
else
tmp = -sqrt((2.0 * (-8.0 * ((A * A) * (C * F))))) / ((B * B) - (4.0 * (A * C)));
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[A, -3.8e+155], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(-8.0 * N[(N[(A * A), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;A \leq -3.8 \cdot 10^{+155}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-8 \cdot \left(\left(A \cdot A\right) \cdot \left(C \cdot F\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\end{array}
\end{array}
if A < -3.8000000000000001e155Initial program 1.8%
Simplified9.8%
Taylor expanded in A around -inf 1.3%
fma-def1.3%
unpow21.3%
*-commutative1.3%
unpow21.3%
Simplified1.3%
Taylor expanded in C around 0 9.8%
associate-*r/9.8%
*-rgt-identity9.8%
*-commutative9.8%
Simplified9.8%
if -3.8000000000000001e155 < A Initial program 18.9%
Simplified18.9%
Taylor expanded in C around 0 15.6%
+-commutative15.6%
unpow215.6%
unpow215.6%
hypot-def15.8%
Simplified15.8%
Taylor expanded in A around -inf 7.5%
*-commutative7.5%
*-commutative7.5%
unpow27.5%
Simplified7.5%
Final simplification7.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 (* -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 17.3%
Simplified18.1%
Taylor expanded in A around -inf 7.5%
fma-def7.5%
unpow27.5%
*-commutative7.5%
unpow27.5%
Simplified7.5%
Taylor expanded in C around 0 3.6%
associate-*r/3.6%
*-rgt-identity3.6%
*-commutative3.6%
Simplified3.6%
Final simplification3.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 (- (sqrt (/ F A))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -sqrt((F / A));
}
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 = -sqrt((f / a))
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return -Math.sqrt((F / A));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -math.sqrt((F / A))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-sqrt(Float64(F / A))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt((F / A));
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[Sqrt[N[(F / A), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-\sqrt{\frac{F}{A}}
\end{array}
Initial program 17.3%
Simplified18.1%
Taylor expanded in A around -inf 7.3%
fma-def7.3%
unpow27.3%
mul-1-neg7.3%
Simplified7.3%
Taylor expanded in B around inf 2.7%
mul-1-neg2.7%
Simplified2.7%
Final simplification2.7%
herbie shell --seed 2023224
(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))))