
(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 12 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 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_1 (* 2.0 (* t_0 F)))
(t_2
(/
(-
(sqrt
(* t_1 (+ (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0)))))))
t_0))
(t_3
(/
(*
(sqrt (* 2.0 (* F (fma B_m B_m (* A (* C -4.0))))))
(- (sqrt (+ A (+ C (hypot (- A C) B_m))))))
t_0)))
(if (<= t_2 -1e-168)
t_3
(if (<= t_2 4e-40)
(/ (- (sqrt (* t_1 (+ (* -0.5 (/ (pow B_m 2.0) A)) (* 2.0 C))))) t_0)
(if (<= t_2 INFINITY)
t_3
(*
(* (sqrt (+ A (hypot B_m A))) (sqrt F))
(* (sqrt 2.0) (/ -1.0 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 t_1 = 2.0 * (t_0 * F);
double t_2 = -sqrt((t_1 * ((A + C) + sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / t_0;
double t_3 = (sqrt((2.0 * (F * fma(B_m, B_m, (A * (C * -4.0)))))) * -sqrt((A + (C + hypot((A - C), B_m))))) / t_0;
double tmp;
if (t_2 <= -1e-168) {
tmp = t_3;
} else if (t_2 <= 4e-40) {
tmp = -sqrt((t_1 * ((-0.5 * (pow(B_m, 2.0) / A)) + (2.0 * C)))) / t_0;
} else if (t_2 <= ((double) INFINITY)) {
tmp = t_3;
} else {
tmp = (sqrt((A + hypot(B_m, A))) * sqrt(F)) * (sqrt(2.0) * (-1.0 / B_m));
}
return tmp;
}
B_m = abs(B) function code(A, B_m, C, F) t_0 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_1 = Float64(2.0 * Float64(t_0 * F)) t_2 = Float64(Float64(-sqrt(Float64(t_1 * Float64(Float64(A + C) + sqrt(Float64((B_m ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_0) t_3 = Float64(Float64(sqrt(Float64(2.0 * Float64(F * fma(B_m, B_m, Float64(A * Float64(C * -4.0)))))) * Float64(-sqrt(Float64(A + Float64(C + hypot(Float64(A - C), B_m)))))) / t_0) tmp = 0.0 if (t_2 <= -1e-168) tmp = t_3; elseif (t_2 <= 4e-40) tmp = Float64(Float64(-sqrt(Float64(t_1 * Float64(Float64(-0.5 * Float64((B_m ^ 2.0) / A)) + Float64(2.0 * C))))) / t_0); elseif (t_2 <= Inf) tmp = t_3; else tmp = Float64(Float64(sqrt(Float64(A + hypot(B_m, A))) * sqrt(F)) * Float64(sqrt(2.0) * Float64(-1.0 / 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[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[((-N[Sqrt[N[(t$95$1 * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Sqrt[N[(2.0 * N[(F * N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(A + N[(C + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision]}, If[LessEqual[t$95$2, -1e-168], t$95$3, If[LessEqual[t$95$2, 4e-40], N[((-N[Sqrt[N[(t$95$1 * N[(N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision] + N[(2.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[t$95$2, Infinity], t$95$3, N[(N[(N[Sqrt[N[(A + N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
t_0 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_1 := 2 \cdot \left(t\_0 \cdot F\right)\\
t_2 := \frac{-\sqrt{t\_1 \cdot \left(\left(A + C\right) + \sqrt{{B\_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t\_0}\\
t_3 := \frac{\sqrt{2 \cdot \left(F \cdot \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\right)} \cdot \left(-\sqrt{A + \left(C + \mathsf{hypot}\left(A - C, B\_m\right)\right)}\right)}{t\_0}\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{-168}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{-40}:\\
\;\;\;\;\frac{-\sqrt{t\_1 \cdot \left(-0.5 \cdot \frac{{B\_m}^{2}}{A} + 2 \cdot C\right)}}{t\_0}\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{A + \mathsf{hypot}\left(B\_m, A\right)} \cdot \sqrt{F}\right) \cdot \left(\sqrt{2} \cdot \frac{-1}{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))) < -1e-168 or 3.9999999999999997e-40 < (/.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.8%
sqrt-prod41.4%
associate-*r*41.4%
associate-*l*41.4%
associate-+l+41.4%
unpow241.4%
unpow241.4%
hypot-def69.5%
Applied egg-rr69.5%
associate-*l*69.5%
*-commutative69.5%
unpow269.5%
fma-neg69.5%
distribute-lft-neg-in69.5%
metadata-eval69.5%
*-commutative69.5%
associate-*l*69.5%
Simplified69.5%
if -1e-168 < (/.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))) < 3.9999999999999997e-40Initial program 7.3%
Taylor expanded in A around -inf 36.1%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) Initial program 0.0%
Taylor expanded in C around 0 1.9%
mul-1-neg1.9%
distribute-rgt-neg-in1.9%
+-commutative1.9%
unpow21.9%
unpow21.9%
hypot-def18.8%
Simplified18.8%
pow1/218.9%
*-commutative18.9%
unpow-prod-down27.5%
pow1/227.5%
pow1/227.5%
Applied egg-rr27.5%
div-inv27.5%
Applied egg-rr27.5%
Final simplification45.4%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (/ (sqrt 2.0) B_m)))
(if (<= (pow B_m 2.0) 1e-322)
(/
(- (sqrt (* -16.0 (* (pow A 2.0) (* C F)))))
(fma B_m B_m (* A (* C -4.0))))
(if (<= (pow B_m 2.0) 2e-62)
(/
(- (sqrt (* (* 2.0 C) (* 2.0 (* -4.0 (* A (* C F)))))))
(- (pow B_m 2.0) (* (* 4.0 A) C)))
(if (<= (pow B_m 2.0) 4e+277)
(* t_0 (- (sqrt (* F (+ C (hypot B_m C))))))
(* t_0 (* (sqrt (+ B_m A)) (- (sqrt F)))))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double t_0 = sqrt(2.0) / B_m;
double tmp;
if (pow(B_m, 2.0) <= 1e-322) {
tmp = -sqrt((-16.0 * (pow(A, 2.0) * (C * F)))) / fma(B_m, B_m, (A * (C * -4.0)));
} else if (pow(B_m, 2.0) <= 2e-62) {
tmp = -sqrt(((2.0 * C) * (2.0 * (-4.0 * (A * (C * F)))))) / (pow(B_m, 2.0) - ((4.0 * A) * C));
} else if (pow(B_m, 2.0) <= 4e+277) {
tmp = t_0 * -sqrt((F * (C + hypot(B_m, C))));
} else {
tmp = t_0 * (sqrt((B_m + A)) * -sqrt(F));
}
return tmp;
}
B_m = abs(B) function code(A, B_m, C, F) t_0 = Float64(sqrt(2.0) / B_m) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-322) tmp = Float64(Float64(-sqrt(Float64(-16.0 * Float64((A ^ 2.0) * Float64(C * F))))) / fma(B_m, B_m, Float64(A * Float64(C * -4.0)))); elseif ((B_m ^ 2.0) <= 2e-62) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * C) * Float64(2.0 * Float64(-4.0 * Float64(A * Float64(C * F))))))) / Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C))); elseif ((B_m ^ 2.0) <= 4e+277) tmp = Float64(t_0 * Float64(-sqrt(Float64(F * Float64(C + hypot(B_m, C)))))); else tmp = Float64(t_0 * Float64(sqrt(Float64(B_m + A)) * Float64(-sqrt(F)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-322], N[((-N[Sqrt[N[(-16.0 * N[(N[Power[A, 2.0], $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-62], N[((-N[Sqrt[N[(N[(2.0 * C), $MachinePrecision] * N[(2.0 * N[(-4.0 * N[(A * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e+277], N[(t$95$0 * (-N[Sqrt[N[(F * N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(t$95$0 * N[(N[Sqrt[N[(B$95$m + A), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[F], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
t_0 := \frac{\sqrt{2}}{B\_m}\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-322}:\\
\;\;\;\;\frac{-\sqrt{-16 \cdot \left({A}^{2} \cdot \left(C \cdot F\right)\right)}}{\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{-62}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot C\right) \cdot \left(2 \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)\right)}}{{B\_m}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{elif}\;{B\_m}^{2} \leq 4 \cdot 10^{+277}:\\
\;\;\;\;t\_0 \cdot \left(-\sqrt{F \cdot \left(C + \mathsf{hypot}\left(B\_m, C\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\sqrt{B\_m + A} \cdot \left(-\sqrt{F}\right)\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 9.88131e-323Initial program 19.0%
neg-sub019.0%
div-sub19.0%
associate-*l*19.0%
Applied egg-rr31.6%
div031.6%
neg-sub031.6%
distribute-neg-frac31.6%
Simplified28.6%
Taylor expanded in B around 0 24.0%
*-commutative24.0%
Simplified24.0%
if 9.88131e-323 < (pow.f64 B 2) < 2.0000000000000001e-62Initial program 19.2%
Taylor expanded in A around -inf 37.7%
Taylor expanded in B around 0 31.6%
*-commutative31.6%
Simplified31.6%
if 2.0000000000000001e-62 < (pow.f64 B 2) < 4.00000000000000001e277Initial program 26.0%
Taylor expanded in A around 0 14.1%
mul-1-neg14.1%
*-commutative14.1%
distribute-rgt-neg-in14.1%
unpow214.1%
unpow214.1%
hypot-def18.8%
Simplified18.8%
if 4.00000000000000001e277 < (pow.f64 B 2) Initial program 0.2%
Taylor expanded in C around 0 3.2%
mul-1-neg3.2%
distribute-rgt-neg-in3.2%
+-commutative3.2%
unpow23.2%
unpow23.2%
hypot-def29.9%
Simplified29.9%
pow1/229.9%
*-commutative29.9%
unpow-prod-down47.3%
pow1/247.3%
pow1/247.3%
Applied egg-rr47.3%
Taylor expanded in A around 0 44.6%
+-commutative44.6%
Simplified44.6%
Final simplification30.0%
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) 1e-322)
(/ (- (sqrt (* (* t_0 (* 2.0 F)) (+ A A)))) t_0)
(if (<= (pow B_m 2.0) 20000000000000.0)
(/
(- (sqrt (* 4.0 (* C (* F (- (pow B_m 2.0) (* 4.0 (* A C))))))))
(- (pow B_m 2.0) (* (* 4.0 A) C)))
(* (* (sqrt (+ A (hypot B_m A))) (sqrt F)) (/ (- (sqrt 2.0)) 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) <= 1e-322) {
tmp = -sqrt(((t_0 * (2.0 * F)) * (A + A))) / t_0;
} else if (pow(B_m, 2.0) <= 20000000000000.0) {
tmp = -sqrt((4.0 * (C * (F * (pow(B_m, 2.0) - (4.0 * (A * C))))))) / (pow(B_m, 2.0) - ((4.0 * A) * C));
} else {
tmp = (sqrt((A + hypot(B_m, A))) * sqrt(F)) * (-sqrt(2.0) / 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) <= 1e-322) tmp = Float64(Float64(-sqrt(Float64(Float64(t_0 * Float64(2.0 * F)) * Float64(A + A)))) / t_0); elseif ((B_m ^ 2.0) <= 20000000000000.0) tmp = Float64(Float64(-sqrt(Float64(4.0 * Float64(C * Float64(F * Float64((B_m ^ 2.0) - Float64(4.0 * Float64(A * C)))))))) / Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C))); else tmp = Float64(Float64(sqrt(Float64(A + hypot(B_m, A))) * sqrt(F)) * Float64(Float64(-sqrt(2.0)) / 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], 1e-322], N[((-N[Sqrt[N[(N[(t$95$0 * N[(2.0 * F), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 20000000000000.0], N[((-N[Sqrt[N[(4.0 * N[(C * N[(F * N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(A + N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $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 10^{-322}:\\
\;\;\;\;\frac{-\sqrt{\left(t\_0 \cdot \left(2 \cdot F\right)\right) \cdot \left(A + A\right)}}{t\_0}\\
\mathbf{elif}\;{B\_m}^{2} \leq 20000000000000:\\
\;\;\;\;\frac{-\sqrt{4 \cdot \left(C \cdot \left(F \cdot \left({B\_m}^{2} - 4 \cdot \left(A \cdot C\right)\right)\right)\right)}}{{B\_m}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{A + \mathsf{hypot}\left(B\_m, A\right)} \cdot \sqrt{F}\right) \cdot \frac{-\sqrt{2}}{B\_m}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 9.88131e-323Initial program 19.0%
Simplified31.6%
Taylor expanded in A around inf 37.0%
distribute-rgt1-in37.0%
metadata-eval37.0%
mul0-lft37.0%
Simplified37.0%
if 9.88131e-323 < (pow.f64 B 2) < 2e13Initial program 22.7%
Taylor expanded in A around -inf 38.0%
Taylor expanded in F around 0 38.0%
if 2e13 < (pow.f64 B 2) Initial program 10.2%
Taylor expanded in C around 0 7.6%
mul-1-neg7.6%
distribute-rgt-neg-in7.6%
+-commutative7.6%
unpow27.6%
unpow27.6%
hypot-def24.5%
Simplified24.5%
pow1/224.6%
*-commutative24.6%
unpow-prod-down36.1%
pow1/236.1%
pow1/236.1%
Applied egg-rr36.1%
Final simplification36.8%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(if (<= (pow B_m 2.0) 1e-322)
(/
(- (sqrt (* -16.0 (* (pow A 2.0) (* C F)))))
(fma B_m B_m (* A (* C -4.0))))
(if (<= (pow B_m 2.0) 20000000000000.0)
(/
(- (sqrt (* 4.0 (* C (* F (- (pow B_m 2.0) (* 4.0 (* A C))))))))
(- (pow B_m 2.0) (* (* 4.0 A) C)))
(* (/ (sqrt 2.0) B_m) (* (sqrt F) (- (sqrt B_m)))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double tmp;
if (pow(B_m, 2.0) <= 1e-322) {
tmp = -sqrt((-16.0 * (pow(A, 2.0) * (C * F)))) / fma(B_m, B_m, (A * (C * -4.0)));
} else if (pow(B_m, 2.0) <= 20000000000000.0) {
tmp = -sqrt((4.0 * (C * (F * (pow(B_m, 2.0) - (4.0 * (A * C))))))) / (pow(B_m, 2.0) - ((4.0 * A) * C));
} else {
tmp = (sqrt(2.0) / B_m) * (sqrt(F) * -sqrt(B_m));
}
return tmp;
}
B_m = abs(B) function code(A, B_m, C, F) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-322) tmp = Float64(Float64(-sqrt(Float64(-16.0 * Float64((A ^ 2.0) * Float64(C * F))))) / fma(B_m, B_m, Float64(A * Float64(C * -4.0)))); elseif ((B_m ^ 2.0) <= 20000000000000.0) tmp = Float64(Float64(-sqrt(Float64(4.0 * Float64(C * Float64(F * Float64((B_m ^ 2.0) - Float64(4.0 * Float64(A * C)))))))) / Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C))); else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(sqrt(F) * Float64(-sqrt(B_m)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-322], N[((-N[Sqrt[N[(-16.0 * N[(N[Power[A, 2.0], $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 20000000000000.0], N[((-N[Sqrt[N[(4.0 * N[(C * N[(F * N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * N[(N[Sqrt[F], $MachinePrecision] * (-N[Sqrt[B$95$m], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
\mathbf{if}\;{B\_m}^{2} \leq 10^{-322}:\\
\;\;\;\;\frac{-\sqrt{-16 \cdot \left({A}^{2} \cdot \left(C \cdot F\right)\right)}}{\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{elif}\;{B\_m}^{2} \leq 20000000000000:\\
\;\;\;\;\frac{-\sqrt{4 \cdot \left(C \cdot \left(F \cdot \left({B\_m}^{2} - 4 \cdot \left(A \cdot C\right)\right)\right)\right)}}{{B\_m}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(\sqrt{F} \cdot \left(-\sqrt{B\_m}\right)\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 9.88131e-323Initial program 19.0%
neg-sub019.0%
div-sub19.0%
associate-*l*19.0%
Applied egg-rr31.6%
div031.6%
neg-sub031.6%
distribute-neg-frac31.6%
Simplified28.6%
Taylor expanded in B around 0 24.0%
*-commutative24.0%
Simplified24.0%
if 9.88131e-323 < (pow.f64 B 2) < 2e13Initial program 22.7%
Taylor expanded in A around -inf 38.0%
Taylor expanded in F around 0 38.0%
if 2e13 < (pow.f64 B 2) Initial program 10.2%
Taylor expanded in C around 0 7.6%
mul-1-neg7.6%
distribute-rgt-neg-in7.6%
+-commutative7.6%
unpow27.6%
unpow27.6%
hypot-def24.5%
Simplified24.5%
pow1/224.6%
*-commutative24.6%
unpow-prod-down36.1%
pow1/236.1%
pow1/236.1%
Applied egg-rr36.1%
Taylor expanded in A around 0 32.1%
Final simplification31.7%
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) 1e-322)
(/ (- (sqrt (* (* t_0 (* 2.0 F)) (+ A A)))) t_0)
(if (<= (pow B_m 2.0) 20000000000000.0)
(/
(- (sqrt (* 4.0 (* C (* F (- (pow B_m 2.0) (* 4.0 (* A C))))))))
(- (pow B_m 2.0) (* (* 4.0 A) C)))
(* (/ (sqrt 2.0) B_m) (* (sqrt F) (- (sqrt 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) <= 1e-322) {
tmp = -sqrt(((t_0 * (2.0 * F)) * (A + A))) / t_0;
} else if (pow(B_m, 2.0) <= 20000000000000.0) {
tmp = -sqrt((4.0 * (C * (F * (pow(B_m, 2.0) - (4.0 * (A * C))))))) / (pow(B_m, 2.0) - ((4.0 * A) * C));
} else {
tmp = (sqrt(2.0) / B_m) * (sqrt(F) * -sqrt(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) <= 1e-322) tmp = Float64(Float64(-sqrt(Float64(Float64(t_0 * Float64(2.0 * F)) * Float64(A + A)))) / t_0); elseif ((B_m ^ 2.0) <= 20000000000000.0) tmp = Float64(Float64(-sqrt(Float64(4.0 * Float64(C * Float64(F * Float64((B_m ^ 2.0) - Float64(4.0 * Float64(A * C)))))))) / Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C))); else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(sqrt(F) * Float64(-sqrt(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], 1e-322], N[((-N[Sqrt[N[(N[(t$95$0 * N[(2.0 * F), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 20000000000000.0], N[((-N[Sqrt[N[(4.0 * N[(C * N[(F * N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * N[(N[Sqrt[F], $MachinePrecision] * (-N[Sqrt[B$95$m], $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 10^{-322}:\\
\;\;\;\;\frac{-\sqrt{\left(t\_0 \cdot \left(2 \cdot F\right)\right) \cdot \left(A + A\right)}}{t\_0}\\
\mathbf{elif}\;{B\_m}^{2} \leq 20000000000000:\\
\;\;\;\;\frac{-\sqrt{4 \cdot \left(C \cdot \left(F \cdot \left({B\_m}^{2} - 4 \cdot \left(A \cdot C\right)\right)\right)\right)}}{{B\_m}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(\sqrt{F} \cdot \left(-\sqrt{B\_m}\right)\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 9.88131e-323Initial program 19.0%
Simplified31.6%
Taylor expanded in A around inf 37.0%
distribute-rgt1-in37.0%
metadata-eval37.0%
mul0-lft37.0%
Simplified37.0%
if 9.88131e-323 < (pow.f64 B 2) < 2e13Initial program 22.7%
Taylor expanded in A around -inf 38.0%
Taylor expanded in F around 0 38.0%
if 2e13 < (pow.f64 B 2) Initial program 10.2%
Taylor expanded in C around 0 7.6%
mul-1-neg7.6%
distribute-rgt-neg-in7.6%
+-commutative7.6%
unpow27.6%
unpow27.6%
hypot-def24.5%
Simplified24.5%
pow1/224.6%
*-commutative24.6%
unpow-prod-down36.1%
pow1/236.1%
pow1/236.1%
Applied egg-rr36.1%
Taylor expanded in A around 0 32.1%
Final simplification34.9%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (/ (sqrt 2.0) B_m)))
(if (<= (pow B_m 2.0) 2e-62)
(/
(- (sqrt (* (* 2.0 C) (* 2.0 (* -4.0 (* A (* C F)))))))
(- (pow B_m 2.0) (* (* 4.0 A) C)))
(if (<= (pow B_m 2.0) 4e+277)
(* t_0 (- (sqrt (* F (+ C (hypot B_m C))))))
(* t_0 (* (sqrt (+ B_m A)) (- (sqrt F))))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double t_0 = sqrt(2.0) / B_m;
double tmp;
if (pow(B_m, 2.0) <= 2e-62) {
tmp = -sqrt(((2.0 * C) * (2.0 * (-4.0 * (A * (C * F)))))) / (pow(B_m, 2.0) - ((4.0 * A) * C));
} else if (pow(B_m, 2.0) <= 4e+277) {
tmp = t_0 * -sqrt((F * (C + hypot(B_m, C))));
} else {
tmp = t_0 * (sqrt((B_m + A)) * -sqrt(F));
}
return tmp;
}
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
double t_0 = Math.sqrt(2.0) / B_m;
double tmp;
if (Math.pow(B_m, 2.0) <= 2e-62) {
tmp = -Math.sqrt(((2.0 * C) * (2.0 * (-4.0 * (A * (C * F)))))) / (Math.pow(B_m, 2.0) - ((4.0 * A) * C));
} else if (Math.pow(B_m, 2.0) <= 4e+277) {
tmp = t_0 * -Math.sqrt((F * (C + Math.hypot(B_m, C))));
} else {
tmp = t_0 * (Math.sqrt((B_m + A)) * -Math.sqrt(F));
}
return tmp;
}
B_m = math.fabs(B) def code(A, B_m, C, F): t_0 = math.sqrt(2.0) / B_m tmp = 0 if math.pow(B_m, 2.0) <= 2e-62: tmp = -math.sqrt(((2.0 * C) * (2.0 * (-4.0 * (A * (C * F)))))) / (math.pow(B_m, 2.0) - ((4.0 * A) * C)) elif math.pow(B_m, 2.0) <= 4e+277: tmp = t_0 * -math.sqrt((F * (C + math.hypot(B_m, C)))) else: tmp = t_0 * (math.sqrt((B_m + A)) * -math.sqrt(F)) return tmp
B_m = abs(B) function code(A, B_m, C, F) t_0 = Float64(sqrt(2.0) / B_m) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-62) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * C) * Float64(2.0 * Float64(-4.0 * Float64(A * Float64(C * F))))))) / Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C))); elseif ((B_m ^ 2.0) <= 4e+277) tmp = Float64(t_0 * Float64(-sqrt(Float64(F * Float64(C + hypot(B_m, C)))))); else tmp = Float64(t_0 * Float64(sqrt(Float64(B_m + A)) * Float64(-sqrt(F)))); end return tmp end
B_m = abs(B); function tmp_2 = code(A, B_m, C, F) t_0 = sqrt(2.0) / B_m; tmp = 0.0; if ((B_m ^ 2.0) <= 2e-62) tmp = -sqrt(((2.0 * C) * (2.0 * (-4.0 * (A * (C * F)))))) / ((B_m ^ 2.0) - ((4.0 * A) * C)); elseif ((B_m ^ 2.0) <= 4e+277) tmp = t_0 * -sqrt((F * (C + hypot(B_m, C)))); else tmp = t_0 * (sqrt((B_m + A)) * -sqrt(F)); end tmp_2 = tmp; end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-62], N[((-N[Sqrt[N[(N[(2.0 * C), $MachinePrecision] * N[(2.0 * N[(-4.0 * N[(A * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e+277], N[(t$95$0 * (-N[Sqrt[N[(F * N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(t$95$0 * N[(N[Sqrt[N[(B$95$m + A), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[F], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
t_0 := \frac{\sqrt{2}}{B\_m}\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-62}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot C\right) \cdot \left(2 \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)\right)}}{{B\_m}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{elif}\;{B\_m}^{2} \leq 4 \cdot 10^{+277}:\\
\;\;\;\;t\_0 \cdot \left(-\sqrt{F \cdot \left(C + \mathsf{hypot}\left(B\_m, C\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\sqrt{B\_m + A} \cdot \left(-\sqrt{F}\right)\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 2.0000000000000001e-62Initial program 19.1%
Taylor expanded in A around -inf 26.5%
Taylor expanded in B around 0 22.1%
*-commutative22.1%
Simplified22.1%
if 2.0000000000000001e-62 < (pow.f64 B 2) < 4.00000000000000001e277Initial program 26.0%
Taylor expanded in A around 0 14.1%
mul-1-neg14.1%
*-commutative14.1%
distribute-rgt-neg-in14.1%
unpow214.1%
unpow214.1%
hypot-def18.8%
Simplified18.8%
if 4.00000000000000001e277 < (pow.f64 B 2) Initial program 0.2%
Taylor expanded in C around 0 3.2%
mul-1-neg3.2%
distribute-rgt-neg-in3.2%
+-commutative3.2%
unpow23.2%
unpow23.2%
hypot-def29.9%
Simplified29.9%
pow1/229.9%
*-commutative29.9%
unpow-prod-down47.3%
pow1/247.3%
pow1/247.3%
Applied egg-rr47.3%
Taylor expanded in A around 0 44.6%
+-commutative44.6%
Simplified44.6%
Final simplification27.6%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(if (<= (pow B_m 2.0) 5e-55)
(/
(- (sqrt (* (* 2.0 C) (* 2.0 (* -4.0 (* A (* C F)))))))
(- (pow B_m 2.0) (* (* 4.0 A) C)))
(* (/ (sqrt 2.0) B_m) (* (sqrt F) (- (sqrt B_m))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double tmp;
if (pow(B_m, 2.0) <= 5e-55) {
tmp = -sqrt(((2.0 * C) * (2.0 * (-4.0 * (A * (C * F)))))) / (pow(B_m, 2.0) - ((4.0 * A) * C));
} else {
tmp = (sqrt(2.0) / B_m) * (sqrt(F) * -sqrt(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) :: tmp
if ((b_m ** 2.0d0) <= 5d-55) then
tmp = -sqrt(((2.0d0 * c) * (2.0d0 * ((-4.0d0) * (a * (c * f)))))) / ((b_m ** 2.0d0) - ((4.0d0 * a) * c))
else
tmp = (sqrt(2.0d0) / b_m) * (sqrt(f) * -sqrt(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 tmp;
if (Math.pow(B_m, 2.0) <= 5e-55) {
tmp = -Math.sqrt(((2.0 * C) * (2.0 * (-4.0 * (A * (C * F)))))) / (Math.pow(B_m, 2.0) - ((4.0 * A) * C));
} else {
tmp = (Math.sqrt(2.0) / B_m) * (Math.sqrt(F) * -Math.sqrt(B_m));
}
return tmp;
}
B_m = math.fabs(B) def code(A, B_m, C, F): tmp = 0 if math.pow(B_m, 2.0) <= 5e-55: tmp = -math.sqrt(((2.0 * C) * (2.0 * (-4.0 * (A * (C * F)))))) / (math.pow(B_m, 2.0) - ((4.0 * A) * C)) else: tmp = (math.sqrt(2.0) / B_m) * (math.sqrt(F) * -math.sqrt(B_m)) return tmp
B_m = abs(B) function code(A, B_m, C, F) tmp = 0.0 if ((B_m ^ 2.0) <= 5e-55) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * C) * Float64(2.0 * Float64(-4.0 * Float64(A * Float64(C * F))))))) / Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C))); else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(sqrt(F) * Float64(-sqrt(B_m)))); end return tmp end
B_m = abs(B); function tmp_2 = code(A, B_m, C, F) tmp = 0.0; if ((B_m ^ 2.0) <= 5e-55) tmp = -sqrt(((2.0 * C) * (2.0 * (-4.0 * (A * (C * F)))))) / ((B_m ^ 2.0) - ((4.0 * A) * C)); else tmp = (sqrt(2.0) / B_m) * (sqrt(F) * -sqrt(B_m)); end tmp_2 = tmp; end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-55], N[((-N[Sqrt[N[(N[(2.0 * C), $MachinePrecision] * N[(2.0 * N[(-4.0 * N[(A * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * N[(N[Sqrt[F], $MachinePrecision] * (-N[Sqrt[B$95$m], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
\mathbf{if}\;{B\_m}^{2} \leq 5 \cdot 10^{-55}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot C\right) \cdot \left(2 \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)\right)}}{{B\_m}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(\sqrt{F} \cdot \left(-\sqrt{B\_m}\right)\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 5.0000000000000002e-55Initial program 19.3%
Taylor expanded in A around -inf 27.3%
Taylor expanded in B around 0 22.2%
*-commutative22.2%
Simplified22.2%
if 5.0000000000000002e-55 < (pow.f64 B 2) Initial program 12.5%
Taylor expanded in C around 0 7.4%
mul-1-neg7.4%
distribute-rgt-neg-in7.4%
+-commutative7.4%
unpow27.4%
unpow27.4%
hypot-def23.0%
Simplified23.0%
pow1/223.0%
*-commutative23.0%
unpow-prod-down33.6%
pow1/233.6%
pow1/233.6%
Applied egg-rr33.6%
Taylor expanded in A around 0 30.0%
Final simplification26.4%
B_m = (fabs.f64 B) (FPCore (A B_m C F) :precision binary64 (if (<= F 3.6e+123) (* (/ (sqrt 2.0) B_m) (- (sqrt (* B_m F)))) (- (* (sqrt 2.0) (sqrt (/ F B_m))))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= 3.6e+123) {
tmp = (sqrt(2.0) / B_m) * -sqrt((B_m * F));
} else {
tmp = -(sqrt(2.0) * sqrt((F / 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) :: tmp
if (f <= 3.6d+123) then
tmp = (sqrt(2.0d0) / b_m) * -sqrt((b_m * f))
else
tmp = -(sqrt(2.0d0) * sqrt((f / 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 tmp;
if (F <= 3.6e+123) {
tmp = (Math.sqrt(2.0) / B_m) * -Math.sqrt((B_m * F));
} else {
tmp = -(Math.sqrt(2.0) * Math.sqrt((F / B_m)));
}
return tmp;
}
B_m = math.fabs(B) def code(A, B_m, C, F): tmp = 0 if F <= 3.6e+123: tmp = (math.sqrt(2.0) / B_m) * -math.sqrt((B_m * F)) else: tmp = -(math.sqrt(2.0) * math.sqrt((F / B_m))) return tmp
B_m = abs(B) function code(A, B_m, C, F) tmp = 0.0 if (F <= 3.6e+123) tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(B_m * F)))); else tmp = Float64(-Float64(sqrt(2.0) * sqrt(Float64(F / B_m)))); end return tmp end
B_m = abs(B); function tmp_2 = code(A, B_m, C, F) tmp = 0.0; if (F <= 3.6e+123) tmp = (sqrt(2.0) / B_m) * -sqrt((B_m * F)); else tmp = -(sqrt(2.0) * sqrt((F / B_m))); end tmp_2 = tmp; end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := If[LessEqual[F, 3.6e+123], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(B$95$m * F), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], (-N[(N[Sqrt[2.0], $MachinePrecision] * N[Sqrt[N[(F / B$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision])]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
\mathbf{if}\;F \leq 3.6 \cdot 10^{+123}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{B\_m \cdot F}\right)\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{2} \cdot \sqrt{\frac{F}{B\_m}}\\
\end{array}
\end{array}
if F < 3.59999999999999998e123Initial program 16.0%
Taylor expanded in C around 0 6.4%
mul-1-neg6.4%
distribute-rgt-neg-in6.4%
+-commutative6.4%
unpow26.4%
unpow26.4%
hypot-def18.1%
Simplified18.1%
Taylor expanded in A around 0 15.8%
if 3.59999999999999998e123 < F Initial program 14.7%
Taylor expanded in C around 0 4.1%
mul-1-neg4.1%
distribute-rgt-neg-in4.1%
+-commutative4.1%
unpow24.1%
unpow24.1%
hypot-def5.6%
Simplified5.6%
Taylor expanded in A around 0 24.5%
mul-1-neg24.5%
Simplified24.5%
Final simplification18.1%
B_m = (fabs.f64 B) (FPCore (A B_m C F) :precision binary64 (if (<= C 2e+196) (- (* (sqrt 2.0) (sqrt (/ F B_m)))) (* -2.0 (* (/ 1.0 B_m) (pow (* C F) 0.5)))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double tmp;
if (C <= 2e+196) {
tmp = -(sqrt(2.0) * sqrt((F / B_m)));
} else {
tmp = -2.0 * ((1.0 / B_m) * pow((C * F), 0.5));
}
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 <= 2d+196) then
tmp = -(sqrt(2.0d0) * sqrt((f / b_m)))
else
tmp = (-2.0d0) * ((1.0d0 / b_m) * ((c * f) ** 0.5d0))
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 <= 2e+196) {
tmp = -(Math.sqrt(2.0) * Math.sqrt((F / B_m)));
} else {
tmp = -2.0 * ((1.0 / B_m) * Math.pow((C * F), 0.5));
}
return tmp;
}
B_m = math.fabs(B) def code(A, B_m, C, F): tmp = 0 if C <= 2e+196: tmp = -(math.sqrt(2.0) * math.sqrt((F / B_m))) else: tmp = -2.0 * ((1.0 / B_m) * math.pow((C * F), 0.5)) return tmp
B_m = abs(B) function code(A, B_m, C, F) tmp = 0.0 if (C <= 2e+196) tmp = Float64(-Float64(sqrt(2.0) * sqrt(Float64(F / B_m)))); else tmp = Float64(-2.0 * Float64(Float64(1.0 / B_m) * (Float64(C * F) ^ 0.5))); end return tmp end
B_m = abs(B); function tmp_2 = code(A, B_m, C, F) tmp = 0.0; if (C <= 2e+196) tmp = -(sqrt(2.0) * sqrt((F / B_m))); else tmp = -2.0 * ((1.0 / B_m) * ((C * F) ^ 0.5)); end tmp_2 = tmp; end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := If[LessEqual[C, 2e+196], (-N[(N[Sqrt[2.0], $MachinePrecision] * N[Sqrt[N[(F / B$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), N[(-2.0 * N[(N[(1.0 / B$95$m), $MachinePrecision] * N[Power[N[(C * F), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
\mathbf{if}\;C \leq 2 \cdot 10^{+196}:\\
\;\;\;\;-\sqrt{2} \cdot \sqrt{\frac{F}{B\_m}}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\frac{1}{B\_m} \cdot {\left(C \cdot F\right)}^{0.5}\right)\\
\end{array}
\end{array}
if C < 1.9999999999999999e196Initial program 17.2%
Taylor expanded in C around 0 6.2%
mul-1-neg6.2%
distribute-rgt-neg-in6.2%
+-commutative6.2%
unpow26.2%
unpow26.2%
hypot-def16.1%
Simplified16.1%
Taylor expanded in A around 0 14.2%
mul-1-neg14.2%
Simplified14.2%
if 1.9999999999999999e196 < C Initial program 1.7%
Taylor expanded in A around -inf 24.9%
Taylor expanded in B around inf 17.2%
pow1/217.4%
*-commutative17.4%
Applied egg-rr17.4%
Final simplification14.5%
B_m = (fabs.f64 B) (FPCore (A B_m C F) :precision binary64 (if (<= A 7.5e-95) (* -2.0 (* (/ 1.0 B_m) (pow (* C F) 0.5))) (* (sqrt (* A F)) (/ (- 2.0) B_m))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double tmp;
if (A <= 7.5e-95) {
tmp = -2.0 * ((1.0 / B_m) * pow((C * F), 0.5));
} else {
tmp = sqrt((A * F)) * (-2.0 / 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) :: tmp
if (a <= 7.5d-95) then
tmp = (-2.0d0) * ((1.0d0 / b_m) * ((c * f) ** 0.5d0))
else
tmp = sqrt((a * f)) * (-2.0d0 / 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 tmp;
if (A <= 7.5e-95) {
tmp = -2.0 * ((1.0 / B_m) * Math.pow((C * F), 0.5));
} else {
tmp = Math.sqrt((A * F)) * (-2.0 / B_m);
}
return tmp;
}
B_m = math.fabs(B) def code(A, B_m, C, F): tmp = 0 if A <= 7.5e-95: tmp = -2.0 * ((1.0 / B_m) * math.pow((C * F), 0.5)) else: tmp = math.sqrt((A * F)) * (-2.0 / B_m) return tmp
B_m = abs(B) function code(A, B_m, C, F) tmp = 0.0 if (A <= 7.5e-95) tmp = Float64(-2.0 * Float64(Float64(1.0 / B_m) * (Float64(C * F) ^ 0.5))); else tmp = Float64(sqrt(Float64(A * F)) * Float64(Float64(-2.0) / B_m)); end return tmp end
B_m = abs(B); function tmp_2 = code(A, B_m, C, F) tmp = 0.0; if (A <= 7.5e-95) tmp = -2.0 * ((1.0 / B_m) * ((C * F) ^ 0.5)); else tmp = sqrt((A * F)) * (-2.0 / B_m); end tmp_2 = tmp; end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := If[LessEqual[A, 7.5e-95], N[(-2.0 * N[(N[(1.0 / B$95$m), $MachinePrecision] * N[Power[N[(C * F), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[((-2.0) / B$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
\mathbf{if}\;A \leq 7.5 \cdot 10^{-95}:\\
\;\;\;\;-2 \cdot \left(\frac{1}{B\_m} \cdot {\left(C \cdot F\right)}^{0.5}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{A \cdot F} \cdot \frac{-2}{B\_m}\\
\end{array}
\end{array}
if A < 7.5000000000000003e-95Initial program 14.1%
Taylor expanded in A around -inf 22.2%
Taylor expanded in B around inf 6.0%
pow1/26.1%
*-commutative6.1%
Applied egg-rr6.1%
if 7.5000000000000003e-95 < A Initial program 19.2%
Taylor expanded in C around 0 8.1%
mul-1-neg8.1%
distribute-rgt-neg-in8.1%
+-commutative8.1%
unpow28.1%
unpow28.1%
hypot-def17.2%
Simplified17.2%
pow1/217.5%
*-commutative17.5%
unpow-prod-down23.5%
pow1/223.5%
pow1/223.5%
Applied egg-rr23.5%
Taylor expanded in B around 0 7.9%
mul-1-neg7.9%
distribute-rgt-neg-in7.9%
unpow27.9%
rem-square-sqrt8.0%
Simplified8.0%
Final simplification6.7%
B_m = (fabs.f64 B) (FPCore (A B_m C F) :precision binary64 (if (<= A 8e-95) (* -2.0 (/ (sqrt (* C F)) B_m)) (* (sqrt (* A F)) (/ (- 2.0) B_m))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double tmp;
if (A <= 8e-95) {
tmp = -2.0 * (sqrt((C * F)) / B_m);
} else {
tmp = sqrt((A * F)) * (-2.0 / 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) :: tmp
if (a <= 8d-95) then
tmp = (-2.0d0) * (sqrt((c * f)) / b_m)
else
tmp = sqrt((a * f)) * (-2.0d0 / 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 tmp;
if (A <= 8e-95) {
tmp = -2.0 * (Math.sqrt((C * F)) / B_m);
} else {
tmp = Math.sqrt((A * F)) * (-2.0 / B_m);
}
return tmp;
}
B_m = math.fabs(B) def code(A, B_m, C, F): tmp = 0 if A <= 8e-95: tmp = -2.0 * (math.sqrt((C * F)) / B_m) else: tmp = math.sqrt((A * F)) * (-2.0 / B_m) return tmp
B_m = abs(B) function code(A, B_m, C, F) tmp = 0.0 if (A <= 8e-95) tmp = Float64(-2.0 * Float64(sqrt(Float64(C * F)) / B_m)); else tmp = Float64(sqrt(Float64(A * F)) * Float64(Float64(-2.0) / B_m)); end return tmp end
B_m = abs(B); function tmp_2 = code(A, B_m, C, F) tmp = 0.0; if (A <= 8e-95) tmp = -2.0 * (sqrt((C * F)) / B_m); else tmp = sqrt((A * F)) * (-2.0 / B_m); end tmp_2 = tmp; end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := If[LessEqual[A, 8e-95], N[(-2.0 * N[(N[Sqrt[N[(C * F), $MachinePrecision]], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[((-2.0) / B$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
\mathbf{if}\;A \leq 8 \cdot 10^{-95}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{C \cdot F}}{B\_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{A \cdot F} \cdot \frac{-2}{B\_m}\\
\end{array}
\end{array}
if A < 7.99999999999999992e-95Initial program 14.1%
Taylor expanded in A around -inf 22.2%
Taylor expanded in B around inf 6.0%
expm1-log1p-u2.8%
expm1-udef1.3%
*-commutative1.3%
associate-*l/1.3%
*-un-lft-identity1.3%
*-commutative1.3%
Applied egg-rr1.3%
expm1-def2.8%
expm1-log1p6.0%
Simplified6.0%
if 7.99999999999999992e-95 < A Initial program 19.2%
Taylor expanded in C around 0 8.1%
mul-1-neg8.1%
distribute-rgt-neg-in8.1%
+-commutative8.1%
unpow28.1%
unpow28.1%
hypot-def17.2%
Simplified17.2%
pow1/217.5%
*-commutative17.5%
unpow-prod-down23.5%
pow1/223.5%
pow1/223.5%
Applied egg-rr23.5%
Taylor expanded in B around 0 7.9%
mul-1-neg7.9%
distribute-rgt-neg-in7.9%
unpow27.9%
rem-square-sqrt8.0%
Simplified8.0%
Final simplification6.6%
B_m = (fabs.f64 B) (FPCore (A B_m C F) :precision binary64 (* -2.0 (/ (sqrt (* C F)) B_m)))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
return -2.0 * (sqrt((C * 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((c * 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((C * F)) / B_m);
}
B_m = math.fabs(B) def code(A, B_m, C, F): return -2.0 * (math.sqrt((C * F)) / B_m)
B_m = abs(B) function code(A, B_m, C, F) return Float64(-2.0 * Float64(sqrt(Float64(C * F)) / B_m)) end
B_m = abs(B); function tmp = code(A, B_m, C, F) tmp = -2.0 * (sqrt((C * F)) / B_m); end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := N[(-2.0 * N[(N[Sqrt[N[(C * F), $MachinePrecision]], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
-2 \cdot \frac{\sqrt{C \cdot F}}{B\_m}
\end{array}
Initial program 15.7%
Taylor expanded in A around -inf 15.8%
Taylor expanded in B around inf 4.5%
expm1-log1p-u2.3%
expm1-udef1.2%
*-commutative1.2%
associate-*l/1.2%
*-un-lft-identity1.2%
*-commutative1.2%
Applied egg-rr1.2%
expm1-def2.3%
expm1-log1p4.5%
Simplified4.5%
Final simplification4.5%
herbie shell --seed 2024031
(FPCore (A B C F)
:name "ABCF->ab-angle a"
:precision binary64
(/ (- (sqrt (* (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F)) (+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))) (- (pow B 2.0) (* (* 4.0 A) C))))