
(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 14 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}
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma A (* C -4.0) (pow B_m 2.0)))
(t_1 (hypot B_m (- A C)))
(t_2 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_3
(/
(-
(sqrt
(*
(* 2.0 (* t_2 F))
(- (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0)))))))
t_2)))
(if (<= t_3 0.0)
(/ (* (sqrt t_0) (- (sqrt (* (* 2.0 F) (+ A (- C t_1)))))) t_0)
(if (<= t_3 INFINITY)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ C (- A t_1))))))) t_0)
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m))))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double t_0 = fma(A, (C * -4.0), pow(B_m, 2.0));
double t_1 = hypot(B_m, (A - C));
double t_2 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_3 = -sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / t_2;
double tmp;
if (t_3 <= 0.0) {
tmp = (sqrt(t_0) * -sqrt(((2.0 * F) * (A + (C - t_1))))) / t_0;
} else if (t_3 <= ((double) INFINITY)) {
tmp = -sqrt((2.0 * (t_0 * (F * (C + (A - t_1)))))) / t_0;
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
}
return tmp;
}
B_m = abs(B) function code(A, B_m, C, F) t_0 = fma(A, Float64(C * -4.0), (B_m ^ 2.0)) t_1 = hypot(B_m, Float64(A - C)) t_2 = Float64((B_m ^ 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_m ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_2) tmp = 0.0 if (t_3 <= 0.0) tmp = Float64(Float64(sqrt(t_0) * Float64(-sqrt(Float64(Float64(2.0 * F) * Float64(A + Float64(C - t_1)))))) / t_0); elseif (t_3 <= Inf) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(C + Float64(A - t_1))))))) / t_0); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[B$95$m, 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$95$m, 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, 0.0], N[(N[(N[Sqrt[t$95$0], $MachinePrecision] * (-N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * N[(A + N[(C - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(C + N[(A - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)\\
t_1 := \mathsf{hypot}\left(B_m, A - C\right)\\
t_2 := {B_m}^{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_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\
\mathbf{if}\;t_3 \leq 0:\\
\;\;\;\;\frac{\sqrt{t_0} \cdot \left(-\sqrt{\left(2 \cdot F\right) \cdot \left(A + \left(C - t_1\right)\right)}\right)}{t_0}\\
\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(C + \left(A - t_1\right)\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\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))) < -0.0Initial program 37.2%
Simplified41.8%
*-commutative41.8%
associate-*l*41.8%
associate-*r*41.8%
associate-+r-40.1%
+-commutative40.1%
associate-+r-41.6%
*-commutative41.6%
sqrt-prod51.1%
associate-+r-50.0%
+-commutative50.0%
associate-+r-51.0%
Applied egg-rr51.0%
associate-*r*51.0%
associate-+r-50.0%
+-commutative50.0%
associate-+r-51.1%
Simplified51.1%
if -0.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))) < +inf.0Initial program 36.6%
Simplified63.9%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) Initial program 0.0%
Simplified1.5%
Taylor expanded in A around 0 2.0%
associate-*r*2.0%
associate-*r/2.0%
mul-1-neg2.0%
Simplified2.0%
Taylor expanded in B around inf 14.2%
Final simplification35.7%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma A (* C -4.0) (pow B_m 2.0)))
(t_1 (hypot B_m (- A C)))
(t_2 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_3
(/
(-
(sqrt
(*
(* 2.0 (* t_2 F))
(- (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0)))))))
t_2)))
(if (<= t_3 0.0)
(/
(* (sqrt (* 2.0 t_0)) (- (sqrt (* F (- (+ A C) t_1)))))
(- (pow B_m 2.0) (* 4.0 (* A C))))
(if (<= t_3 INFINITY)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ C (- A t_1))))))) t_0)
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m))))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double t_0 = fma(A, (C * -4.0), pow(B_m, 2.0));
double t_1 = hypot(B_m, (A - C));
double t_2 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_3 = -sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / t_2;
double tmp;
if (t_3 <= 0.0) {
tmp = (sqrt((2.0 * t_0)) * -sqrt((F * ((A + C) - t_1)))) / (pow(B_m, 2.0) - (4.0 * (A * C)));
} else if (t_3 <= ((double) INFINITY)) {
tmp = -sqrt((2.0 * (t_0 * (F * (C + (A - t_1)))))) / t_0;
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
}
return tmp;
}
B_m = abs(B) function code(A, B_m, C, F) t_0 = fma(A, Float64(C * -4.0), (B_m ^ 2.0)) t_1 = hypot(B_m, Float64(A - C)) t_2 = Float64((B_m ^ 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_m ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_2) tmp = 0.0 if (t_3 <= 0.0) tmp = Float64(Float64(sqrt(Float64(2.0 * t_0)) * Float64(-sqrt(Float64(F * Float64(Float64(A + C) - t_1))))) / Float64((B_m ^ 2.0) - Float64(4.0 * Float64(A * C)))); elseif (t_3 <= Inf) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(C + Float64(A - t_1))))))) / t_0); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[B$95$m, 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$95$m, 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, 0.0], N[(N[(N[Sqrt[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(F * N[(N[(A + C), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(C + N[(A - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)\\
t_1 := \mathsf{hypot}\left(B_m, A - C\right)\\
t_2 := {B_m}^{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_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\
\mathbf{if}\;t_3 \leq 0:\\
\;\;\;\;\frac{\sqrt{2 \cdot t_0} \cdot \left(-\sqrt{F \cdot \left(\left(A + C\right) - t_1\right)}\right)}{{B_m}^{2} - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(C + \left(A - t_1\right)\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\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))) < -0.0Initial program 37.2%
Simplified37.2%
unpow237.2%
unpow237.2%
hypot-udef39.0%
+-commutative39.0%
associate-+r-40.8%
+-commutative40.8%
Applied egg-rr40.8%
associate-*l*41.8%
sqrt-prod51.0%
sub-neg51.0%
distribute-rgt-in51.0%
distribute-lft-neg-in51.0%
metadata-eval51.0%
*-commutative51.0%
associate-*r*51.0%
distribute-rgt-in51.0%
+-commutative51.0%
fma-udef51.0%
*-commutative51.0%
Applied egg-rr51.0%
associate-+r-49.9%
+-commutative49.9%
Simplified49.9%
if -0.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))) < +inf.0Initial program 36.6%
Simplified63.9%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) Initial program 0.0%
Simplified1.5%
Taylor expanded in A around 0 2.0%
associate-*r*2.0%
associate-*r/2.0%
mul-1-neg2.0%
Simplified2.0%
Taylor expanded in B around inf 14.2%
Final simplification35.2%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma A (* C -4.0) (pow B_m 2.0))))
(if (<= (pow B_m 2.0) 2e+264)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ C (- A (hypot B_m (- A C))))))))) t_0)
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m)))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double t_0 = fma(A, (C * -4.0), pow(B_m, 2.0));
double tmp;
if (pow(B_m, 2.0) <= 2e+264) {
tmp = -sqrt((2.0 * (t_0 * (F * (C + (A - hypot(B_m, (A - C)))))))) / t_0;
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
}
return tmp;
}
B_m = abs(B) function code(A, B_m, C, F) t_0 = fma(A, Float64(C * -4.0), (B_m ^ 2.0)) tmp = 0.0 if ((B_m ^ 2.0) <= 2e+264) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(C + Float64(A - hypot(B_m, Float64(A - C))))))))) / t_0); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+264], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(C + N[(A - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)\\
\mathbf{if}\;{B_m}^{2} \leq 2 \cdot 10^{+264}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(C + \left(A - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 2.00000000000000009e264Initial program 28.0%
Simplified36.5%
if 2.00000000000000009e264 < (pow.f64 B 2) Initial program 0.2%
Simplified0.2%
Taylor expanded in A around 0 3.1%
associate-*r*3.1%
associate-*r/3.1%
mul-1-neg3.1%
Simplified3.1%
Taylor expanded in B around inf 23.6%
Final simplification32.8%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (pow B_m 2.0) (* 4.0 (* A C)))))
(if (<= (pow B_m 2.0) 2e+264)
(/ (- (sqrt (* (+ C (- A (hypot B_m (- A C)))) (* F (* 2.0 t_0))))) t_0)
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m)))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double t_0 = pow(B_m, 2.0) - (4.0 * (A * C));
double tmp;
if (pow(B_m, 2.0) <= 2e+264) {
tmp = -sqrt(((C + (A - hypot(B_m, (A - C)))) * (F * (2.0 * t_0)))) / t_0;
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
}
return tmp;
}
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
double t_0 = Math.pow(B_m, 2.0) - (4.0 * (A * C));
double tmp;
if (Math.pow(B_m, 2.0) <= 2e+264) {
tmp = -Math.sqrt(((C + (A - Math.hypot(B_m, (A - C)))) * (F * (2.0 * t_0)))) / t_0;
} else {
tmp = (-Math.sqrt(2.0) / B_m) * Math.sqrt((F * (C - B_m)));
}
return tmp;
}
B_m = math.fabs(B) def code(A, B_m, C, F): t_0 = math.pow(B_m, 2.0) - (4.0 * (A * C)) tmp = 0 if math.pow(B_m, 2.0) <= 2e+264: tmp = -math.sqrt(((C + (A - math.hypot(B_m, (A - C)))) * (F * (2.0 * t_0)))) / t_0 else: tmp = (-math.sqrt(2.0) / B_m) * math.sqrt((F * (C - B_m))) return tmp
B_m = abs(B) function code(A, B_m, C, F) t_0 = Float64((B_m ^ 2.0) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if ((B_m ^ 2.0) <= 2e+264) tmp = Float64(Float64(-sqrt(Float64(Float64(C + Float64(A - hypot(B_m, Float64(A - C)))) * Float64(F * Float64(2.0 * t_0))))) / t_0); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m)))); end return tmp end
B_m = abs(B); function tmp_2 = code(A, B_m, C, F) t_0 = (B_m ^ 2.0) - (4.0 * (A * C)); tmp = 0.0; if ((B_m ^ 2.0) <= 2e+264) tmp = -sqrt(((C + (A - hypot(B_m, (A - C)))) * (F * (2.0 * t_0)))) / t_0; else tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m))); end tmp_2 = tmp; end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+264], N[((-N[Sqrt[N[(N[(C + N[(A - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(F * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
t_0 := {B_m}^{2} - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;{B_m}^{2} \leq 2 \cdot 10^{+264}:\\
\;\;\;\;\frac{-\sqrt{\left(C + \left(A - \mathsf{hypot}\left(B_m, A - C\right)\right)\right) \cdot \left(F \cdot \left(2 \cdot t_0\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 2.00000000000000009e264Initial program 28.0%
Simplified28.1%
unpow228.1%
unpow228.1%
hypot-udef34.3%
+-commutative34.3%
associate-+r-35.8%
+-commutative35.8%
Applied egg-rr35.8%
if 2.00000000000000009e264 < (pow.f64 B 2) Initial program 0.2%
Simplified0.2%
Taylor expanded in A around 0 3.1%
associate-*r*3.1%
associate-*r/3.1%
mul-1-neg3.1%
Simplified3.1%
Taylor expanded in B around inf 23.6%
Final simplification32.3%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma B_m B_m (* A (* C -4.0)))))
(if (<= (pow B_m 2.0) 2e+264)
(/ (- (sqrt (* (* F t_0) (* 2.0 (+ A (- C (hypot B_m (- A C)))))))) t_0)
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m)))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (pow(B_m, 2.0) <= 2e+264) {
tmp = -sqrt(((F * t_0) * (2.0 * (A + (C - hypot(B_m, (A - C))))))) / t_0;
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
}
return tmp;
}
B_m = abs(B) function code(A, B_m, C, F) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 2e+264) tmp = Float64(Float64(-sqrt(Float64(Float64(F * t_0) * Float64(2.0 * Float64(A + Float64(C - hypot(B_m, Float64(A - C)))))))) / t_0); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+264], N[((-N[Sqrt[N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * N[(A + N[(C - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B_m}^{2} \leq 2 \cdot 10^{+264}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot t_0\right) \cdot \left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 2.00000000000000009e264Initial program 28.0%
Simplified35.6%
if 2.00000000000000009e264 < (pow.f64 B 2) Initial program 0.2%
Simplified0.2%
Taylor expanded in A around 0 3.1%
associate-*r*3.1%
associate-*r/3.1%
mul-1-neg3.1%
Simplified3.1%
Taylor expanded in B around inf 23.6%
Final simplification32.2%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (pow B_m 2.0) (* 4.0 (* A C)))))
(if (<= B_m 9.5e-191)
(/
(- (sqrt (* 2.0 (* (* F (* 2.0 A)) (+ (pow B_m 2.0) (* A (* C -4.0)))))))
(fma A (* C -4.0) (pow B_m 2.0)))
(if (<= B_m 1.05e-12)
(/ (- (sqrt (* (* F (* 2.0 t_0)) (+ C C)))) t_0)
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m))))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double t_0 = pow(B_m, 2.0) - (4.0 * (A * C));
double tmp;
if (B_m <= 9.5e-191) {
tmp = -sqrt((2.0 * ((F * (2.0 * A)) * (pow(B_m, 2.0) + (A * (C * -4.0)))))) / fma(A, (C * -4.0), pow(B_m, 2.0));
} else if (B_m <= 1.05e-12) {
tmp = -sqrt(((F * (2.0 * t_0)) * (C + C))) / t_0;
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
}
return tmp;
}
B_m = abs(B) function code(A, B_m, C, F) t_0 = Float64((B_m ^ 2.0) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B_m <= 9.5e-191) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * Float64(2.0 * A)) * Float64((B_m ^ 2.0) + Float64(A * Float64(C * -4.0))))))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0))); elseif (B_m <= 1.05e-12) tmp = Float64(Float64(-sqrt(Float64(Float64(F * Float64(2.0 * t_0)) * Float64(C + C)))) / t_0); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 9.5e-191], N[((-N[Sqrt[N[(2.0 * N[(N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision] * N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 1.05e-12], N[((-N[Sqrt[N[(N[(F * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(C + C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
t_0 := {B_m}^{2} - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B_m \leq 9.5 \cdot 10^{-191}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot \left(2 \cdot A\right)\right) \cdot \left({B_m}^{2} + A \cdot \left(C \cdot -4\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}\\
\mathbf{elif}\;B_m \leq 1.05 \cdot 10^{-12}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot \left(2 \cdot t_0\right)\right) \cdot \left(C + C\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}\\
\end{array}
\end{array}
if B < 9.4999999999999996e-191Initial program 20.3%
Simplified26.5%
Taylor expanded in C around inf 16.8%
mul-1-neg16.8%
Simplified16.8%
*-commutative16.8%
fma-udef16.8%
distribute-lft-in16.5%
*-un-lft-identity16.5%
metadata-eval16.5%
neg-mul-116.5%
distribute-rgt-out--16.5%
metadata-eval16.5%
metadata-eval16.5%
*-un-lft-identity16.5%
metadata-eval16.5%
neg-mul-116.5%
distribute-rgt-out--16.5%
metadata-eval16.5%
metadata-eval16.5%
Applied egg-rr16.5%
distribute-lft-out16.8%
Simplified16.8%
if 9.4999999999999996e-191 < B < 1.04999999999999997e-12Initial program 30.0%
Simplified30.0%
unpow230.0%
unpow230.0%
hypot-udef40.0%
+-commutative40.0%
associate-+r-42.4%
+-commutative42.4%
Applied egg-rr42.4%
Taylor expanded in A around inf 35.5%
if 1.04999999999999997e-12 < B Initial program 14.0%
Simplified15.9%
Taylor expanded in A around 0 16.0%
associate-*r*16.0%
associate-*r/16.0%
mul-1-neg16.0%
Simplified16.0%
Taylor expanded in B around inf 35.2%
Final simplification24.9%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (pow B_m 2.0) (* 4.0 (* A C)))))
(if (<= B_m 5e-152)
(/ (- (sqrt (* (* F (* 2.0 t_0)) (* 2.0 A)))) t_0)
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m)))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double t_0 = pow(B_m, 2.0) - (4.0 * (A * C));
double tmp;
if (B_m <= 5e-152) {
tmp = -sqrt(((F * (2.0 * t_0)) * (2.0 * A))) / t_0;
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
}
return tmp;
}
B_m = abs(B)
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = (b_m ** 2.0d0) - (4.0d0 * (a * c))
if (b_m <= 5d-152) then
tmp = -sqrt(((f * (2.0d0 * t_0)) * (2.0d0 * a))) / t_0
else
tmp = (-sqrt(2.0d0) / b_m) * sqrt((f * (c - b_m)))
end if
code = tmp
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
double t_0 = Math.pow(B_m, 2.0) - (4.0 * (A * C));
double tmp;
if (B_m <= 5e-152) {
tmp = -Math.sqrt(((F * (2.0 * t_0)) * (2.0 * A))) / t_0;
} else {
tmp = (-Math.sqrt(2.0) / B_m) * Math.sqrt((F * (C - B_m)));
}
return tmp;
}
B_m = math.fabs(B) def code(A, B_m, C, F): t_0 = math.pow(B_m, 2.0) - (4.0 * (A * C)) tmp = 0 if B_m <= 5e-152: tmp = -math.sqrt(((F * (2.0 * t_0)) * (2.0 * A))) / t_0 else: tmp = (-math.sqrt(2.0) / B_m) * math.sqrt((F * (C - B_m))) return tmp
B_m = abs(B) function code(A, B_m, C, F) t_0 = Float64((B_m ^ 2.0) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B_m <= 5e-152) tmp = Float64(Float64(-sqrt(Float64(Float64(F * Float64(2.0 * t_0)) * Float64(2.0 * A)))) / t_0); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m)))); end return tmp end
B_m = abs(B); function tmp_2 = code(A, B_m, C, F) t_0 = (B_m ^ 2.0) - (4.0 * (A * C)); tmp = 0.0; if (B_m <= 5e-152) tmp = -sqrt(((F * (2.0 * t_0)) * (2.0 * A))) / t_0; else tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m))); end tmp_2 = tmp; end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 5e-152], N[((-N[Sqrt[N[(N[(F * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
t_0 := {B_m}^{2} - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B_m \leq 5 \cdot 10^{-152}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot \left(2 \cdot t_0\right)\right) \cdot \left(2 \cdot A\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}\\
\end{array}
\end{array}
if B < 4.9999999999999997e-152Initial program 20.6%
Simplified20.6%
unpow220.6%
unpow220.6%
hypot-udef24.8%
+-commutative24.8%
associate-+r-26.0%
+-commutative26.0%
Applied egg-rr26.0%
Taylor expanded in A around -inf 14.7%
if 4.9999999999999997e-152 < B Initial program 19.1%
Simplified25.1%
Taylor expanded in A around 0 16.6%
associate-*r*16.6%
associate-*r/16.6%
mul-1-neg16.6%
Simplified16.6%
Taylor expanded in B around inf 28.9%
Final simplification20.5%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (pow B_m 2.0) (* 4.0 (* A C)))))
(if (<= B_m 6.6e-13)
(/ (- (sqrt (* (* F (* 2.0 t_0)) (+ C C)))) t_0)
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m)))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double t_0 = pow(B_m, 2.0) - (4.0 * (A * C));
double tmp;
if (B_m <= 6.6e-13) {
tmp = -sqrt(((F * (2.0 * t_0)) * (C + C))) / t_0;
} else {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
}
return tmp;
}
B_m = abs(B)
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = (b_m ** 2.0d0) - (4.0d0 * (a * c))
if (b_m <= 6.6d-13) then
tmp = -sqrt(((f * (2.0d0 * t_0)) * (c + c))) / t_0
else
tmp = (-sqrt(2.0d0) / b_m) * sqrt((f * (c - b_m)))
end if
code = tmp
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
double t_0 = Math.pow(B_m, 2.0) - (4.0 * (A * C));
double tmp;
if (B_m <= 6.6e-13) {
tmp = -Math.sqrt(((F * (2.0 * t_0)) * (C + C))) / t_0;
} else {
tmp = (-Math.sqrt(2.0) / B_m) * Math.sqrt((F * (C - B_m)));
}
return tmp;
}
B_m = math.fabs(B) def code(A, B_m, C, F): t_0 = math.pow(B_m, 2.0) - (4.0 * (A * C)) tmp = 0 if B_m <= 6.6e-13: tmp = -math.sqrt(((F * (2.0 * t_0)) * (C + C))) / t_0 else: tmp = (-math.sqrt(2.0) / B_m) * math.sqrt((F * (C - B_m))) return tmp
B_m = abs(B) function code(A, B_m, C, F) t_0 = Float64((B_m ^ 2.0) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B_m <= 6.6e-13) tmp = Float64(Float64(-sqrt(Float64(Float64(F * Float64(2.0 * t_0)) * Float64(C + C)))) / t_0); else tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m)))); end return tmp end
B_m = abs(B); function tmp_2 = code(A, B_m, C, F) t_0 = (B_m ^ 2.0) - (4.0 * (A * C)); tmp = 0.0; if (B_m <= 6.6e-13) tmp = -sqrt(((F * (2.0 * t_0)) * (C + C))) / t_0; else tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m))); end tmp_2 = tmp; end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 6.6e-13], N[((-N[Sqrt[N[(N[(F * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(C + C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
t_0 := {B_m}^{2} - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B_m \leq 6.6 \cdot 10^{-13}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot \left(2 \cdot t_0\right)\right) \cdot \left(C + C\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}\\
\end{array}
\end{array}
if B < 6.6000000000000001e-13Initial program 22.4%
Simplified22.4%
unpow222.4%
unpow222.4%
hypot-udef28.1%
+-commutative28.1%
associate-+r-29.5%
+-commutative29.5%
Applied egg-rr29.5%
Taylor expanded in A around inf 20.7%
if 6.6000000000000001e-13 < B Initial program 14.0%
Simplified15.9%
Taylor expanded in A around 0 16.0%
associate-*r*16.0%
associate-*r/16.0%
mul-1-neg16.0%
Simplified16.0%
Taylor expanded in B around inf 35.2%
Final simplification24.9%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(if (<= F -9.5e-302)
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m))))
(/
(- (sqrt (* (* (* A -4.0) (* C F)) (* 2.0 (+ A (+ B_m C))))))
(fma B_m B_m (* A (* C -4.0))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -9.5e-302) {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
} else {
tmp = -sqrt((((A * -4.0) * (C * F)) * (2.0 * (A + (B_m + C))))) / fma(B_m, B_m, (A * (C * -4.0)));
}
return tmp;
}
B_m = abs(B) function code(A, B_m, C, F) tmp = 0.0 if (F <= -9.5e-302) tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m)))); else tmp = Float64(Float64(-sqrt(Float64(Float64(Float64(A * -4.0) * Float64(C * F)) * Float64(2.0 * Float64(A + Float64(B_m + C)))))) / fma(B_m, B_m, Float64(A * Float64(C * -4.0)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := If[LessEqual[F, -9.5e-302], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(N[(N[(A * -4.0), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(A + N[(B$95$m + C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
\mathbf{if}\;F \leq -9.5 \cdot 10^{-302}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{\left(\left(A \cdot -4\right) \cdot \left(C \cdot F\right)\right) \cdot \left(2 \cdot \left(A + \left(B_m + C\right)\right)\right)}}{\mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)}\\
\end{array}
\end{array}
if F < -9.49999999999999991e-302Initial program 18.5%
Simplified21.2%
Taylor expanded in A around 0 9.3%
associate-*r*9.3%
associate-*r/9.3%
mul-1-neg9.3%
Simplified9.3%
Taylor expanded in B around inf 14.4%
if -9.49999999999999991e-302 < F Initial program 27.0%
Simplified47.0%
Taylor expanded in B around -inf 10.8%
Taylor expanded in B around 0 10.2%
associate-*r*10.2%
Simplified10.2%
Final simplification13.7%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(if (<= F -5e-310)
(* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m))))
(/
(- (sqrt (* -8.0 (* A (* C (* F (+ A C)))))))
(fma B_m B_m (* A (* C -4.0))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -5e-310) {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
} else {
tmp = -sqrt((-8.0 * (A * (C * (F * (A + C)))))) / fma(B_m, B_m, (A * (C * -4.0)));
}
return tmp;
}
B_m = abs(B) function code(A, B_m, C, F) tmp = 0.0 if (F <= -5e-310) tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m)))); else tmp = Float64(Float64(-sqrt(Float64(-8.0 * Float64(A * Float64(C * Float64(F * Float64(A + C))))))) / fma(B_m, B_m, Float64(A * Float64(C * -4.0)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := If[LessEqual[F, -5e-310], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(-8.0 * N[(A * N[(C * N[(F * N[(A + C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
\mathbf{if}\;F \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{-8 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A + C\right)\right)\right)\right)}}{\mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)}\\
\end{array}
\end{array}
if F < -4.999999999999985e-310Initial program 18.4%
Simplified21.0%
Taylor expanded in A around 0 9.3%
associate-*r*9.3%
associate-*r/9.3%
mul-1-neg9.3%
Simplified9.3%
Taylor expanded in B around inf 14.4%
if -4.999999999999985e-310 < F Initial program 28.1%
Simplified48.9%
Taylor expanded in B around -inf 11.1%
Taylor expanded in B around 0 9.9%
+-commutative9.9%
Simplified9.9%
Final simplification13.6%
B_m = (fabs.f64 B) (FPCore (A B_m C F) :precision binary64 (if (<= C -4.6e-196) (* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (* 2.0 C)))) (* -2.0 (sqrt (* A (* F (pow B_m -2.0)))))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double tmp;
if (C <= -4.6e-196) {
tmp = (-sqrt(2.0) / B_m) * sqrt((F * (2.0 * C)));
} else {
tmp = -2.0 * sqrt((A * (F * pow(B_m, -2.0))));
}
return tmp;
}
B_m = abs(B)
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (c <= (-4.6d-196)) then
tmp = (-sqrt(2.0d0) / b_m) * sqrt((f * (2.0d0 * c)))
else
tmp = (-2.0d0) * sqrt((a * (f * (b_m ** (-2.0d0)))))
end if
code = tmp
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (C <= -4.6e-196) {
tmp = (-Math.sqrt(2.0) / B_m) * Math.sqrt((F * (2.0 * C)));
} else {
tmp = -2.0 * Math.sqrt((A * (F * Math.pow(B_m, -2.0))));
}
return tmp;
}
B_m = math.fabs(B) def code(A, B_m, C, F): tmp = 0 if C <= -4.6e-196: tmp = (-math.sqrt(2.0) / B_m) * math.sqrt((F * (2.0 * C))) else: tmp = -2.0 * math.sqrt((A * (F * math.pow(B_m, -2.0)))) return tmp
B_m = abs(B) function code(A, B_m, C, F) tmp = 0.0 if (C <= -4.6e-196) tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(2.0 * C)))); else tmp = Float64(-2.0 * sqrt(Float64(A * Float64(F * (B_m ^ -2.0))))); end return tmp end
B_m = abs(B); function tmp_2 = code(A, B_m, C, F) tmp = 0.0; if (C <= -4.6e-196) tmp = (-sqrt(2.0) / B_m) * sqrt((F * (2.0 * C))); else tmp = -2.0 * sqrt((A * (F * (B_m ^ -2.0)))); end tmp_2 = tmp; end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := If[LessEqual[C, -4.6e-196], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[Sqrt[N[(A * N[(F * N[Power[B$95$m, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
\mathbf{if}\;C \leq -4.6 \cdot 10^{-196}:\\
\;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(2 \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \sqrt{A \cdot \left(F \cdot {B_m}^{-2}\right)}\\
\end{array}
\end{array}
if C < -4.6000000000000004e-196Initial program 27.8%
Simplified36.7%
Taylor expanded in A around 0 9.4%
associate-*r*9.4%
associate-*r/9.4%
mul-1-neg9.4%
Simplified9.4%
Taylor expanded in C around -inf 4.9%
if -4.6000000000000004e-196 < C Initial program 14.3%
Simplified18.2%
Taylor expanded in C around inf 16.4%
mul-1-neg16.4%
Simplified16.4%
Taylor expanded in C around 0 1.6%
Applied egg-rr4.4%
associate-*l*4.7%
Simplified4.7%
Final simplification4.8%
B_m = (fabs.f64 B) (FPCore (A B_m C F) :precision binary64 (* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m)))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
return (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
}
B_m = abs(B)
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (-sqrt(2.0d0) / b_m) * sqrt((f * (c - b_m)))
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
return (-Math.sqrt(2.0) / B_m) * Math.sqrt((F * (C - B_m)));
}
B_m = math.fabs(B) def code(A, B_m, C, F): return (-math.sqrt(2.0) / B_m) * math.sqrt((F * (C - B_m)))
B_m = abs(B) function code(A, B_m, C, F) return Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m)))) end
B_m = abs(B); function tmp = code(A, B_m, C, F) tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m))); end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}
\end{array}
Initial program 20.0%
Simplified26.0%
Taylor expanded in A around 0 7.8%
associate-*r*7.8%
associate-*r/7.8%
mul-1-neg7.8%
Simplified7.8%
Taylor expanded in B around inf 12.1%
Final simplification12.1%
B_m = (fabs.f64 B) (FPCore (A B_m C F) :precision binary64 (* -2.0 (* (pow (* A F) 0.5) (/ 1.0 B_m))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
return -2.0 * (pow((A * F), 0.5) * (1.0 / B_m));
}
B_m = abs(B)
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (-2.0d0) * (((a * f) ** 0.5d0) * (1.0d0 / b_m))
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
return -2.0 * (Math.pow((A * F), 0.5) * (1.0 / B_m));
}
B_m = math.fabs(B) def code(A, B_m, C, F): return -2.0 * (math.pow((A * F), 0.5) * (1.0 / B_m))
B_m = abs(B) function code(A, B_m, C, F) return Float64(-2.0 * Float64((Float64(A * F) ^ 0.5) * Float64(1.0 / B_m))) end
B_m = abs(B); function tmp = code(A, B_m, C, F) tmp = -2.0 * (((A * F) ^ 0.5) * (1.0 / B_m)); end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := N[(-2.0 * N[(N[Power[N[(A * F), $MachinePrecision], 0.5], $MachinePrecision] * N[(1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
-2 \cdot \left({\left(A \cdot F\right)}^{0.5} \cdot \frac{1}{B_m}\right)
\end{array}
Initial program 20.0%
Simplified26.0%
Taylor expanded in C around inf 12.3%
mul-1-neg12.3%
Simplified12.3%
Taylor expanded in C around 0 1.7%
Applied egg-rr2.0%
Final simplification2.0%
B_m = (fabs.f64 B) (FPCore (A B_m C F) :precision binary64 (/ (* -2.0 (sqrt (* A F))) B_m))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
return (-2.0 * sqrt((A * F))) / B_m;
}
B_m = abs(B)
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = ((-2.0d0) * sqrt((a * f))) / b_m
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
return (-2.0 * Math.sqrt((A * F))) / B_m;
}
B_m = math.fabs(B) def code(A, B_m, C, F): return (-2.0 * math.sqrt((A * F))) / B_m
B_m = abs(B) function code(A, B_m, C, F) return Float64(Float64(-2.0 * sqrt(Float64(A * F))) / B_m) end
B_m = abs(B); function tmp = code(A, B_m, C, F) tmp = (-2.0 * sqrt((A * F))) / B_m; end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := N[(N[(-2.0 * N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / B$95$m), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
\frac{-2 \cdot \sqrt{A \cdot F}}{B_m}
\end{array}
Initial program 20.0%
Simplified26.0%
Taylor expanded in C around inf 12.3%
mul-1-neg12.3%
Simplified12.3%
Taylor expanded in C around 0 1.7%
Applied egg-rr1.7%
Final simplification1.7%
herbie shell --seed 2023336
(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))))