
(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}
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* (* A C) -4.0)))
(t_1 (- 0.0 (fma (* A C) -4.0 (* B B))))
(t_2 (* (* 4.0 A) C))
(t_3
(/
(sqrt
(*
(* 2.0 (* (- (pow B 2.0) t_2) F))
(- (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0))))))
(- t_2 (pow B 2.0))))
(t_4 (* t_0 (* 2.0 F))))
(if (<= t_3 (- INFINITY))
(/ (* (sqrt (* 2.0 t_0)) (sqrt (* F (+ A A)))) t_1)
(if (<= t_3 -2e-199)
(/
(sqrt (* (- (+ A C) (sqrt (fma (- A C) (- A C) (* B B)))) t_4))
(- 0.0 t_0))
(/ (sqrt (* t_4 (+ A (fma (/ (* B B) C) -0.5 A)))) t_1)))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, ((A * C) * -4.0));
double t_1 = 0.0 - fma((A * C), -4.0, (B * B));
double t_2 = (4.0 * A) * C;
double t_3 = sqrt(((2.0 * ((pow(B, 2.0) - t_2) * F)) * ((A + C) - sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / (t_2 - pow(B, 2.0));
double t_4 = t_0 * (2.0 * F);
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = (sqrt((2.0 * t_0)) * sqrt((F * (A + A)))) / t_1;
} else if (t_3 <= -2e-199) {
tmp = sqrt((((A + C) - sqrt(fma((A - C), (A - C), (B * B)))) * t_4)) / (0.0 - t_0);
} else {
tmp = sqrt((t_4 * (A + fma(((B * B) / C), -0.5, A)))) / t_1;
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) t_0 = fma(B, B, Float64(Float64(A * C) * -4.0)) t_1 = Float64(0.0 - fma(Float64(A * C), -4.0, Float64(B * B))) t_2 = Float64(Float64(4.0 * A) * C) t_3 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B ^ 2.0) - t_2) * F)) * Float64(Float64(A + C) - sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0)))))) / Float64(t_2 - (B ^ 2.0))) t_4 = Float64(t_0 * Float64(2.0 * F)) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(Float64(sqrt(Float64(2.0 * t_0)) * sqrt(Float64(F * Float64(A + A)))) / t_1); elseif (t_3 <= -2e-199) tmp = Float64(sqrt(Float64(Float64(Float64(A + C) - sqrt(fma(Float64(A - C), Float64(A - C), Float64(B * B)))) * t_4)) / Float64(0.0 - t_0)); else tmp = Float64(sqrt(Float64(t_4 * Float64(A + fma(Float64(Float64(B * B) / C), -0.5, A)))) / t_1); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.0 - N[(N[(A * C), $MachinePrecision] * -4.0 + N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B, 2.0], $MachinePrecision] - t$95$2), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$2 - N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$0 * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(N[(N[Sqrt[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$3, -2e-199], N[(N[Sqrt[N[(N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[(A - C), $MachinePrecision] * N[(A - C), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$4), $MachinePrecision]], $MachinePrecision] / N[(0.0 - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(t$95$4 * N[(A + N[(N[(N[(B * B), $MachinePrecision] / C), $MachinePrecision] * -0.5 + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision]]]]]]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, \left(A \cdot C\right) \cdot -4\right)\\
t_1 := 0 - \mathsf{fma}\left(A \cdot C, -4, B \cdot B\right)\\
t_2 := \left(4 \cdot A\right) \cdot C\\
t_3 := \frac{\sqrt{\left(2 \cdot \left(\left({B}^{2} - t\_2\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t\_2 - {B}^{2}}\\
t_4 := t\_0 \cdot \left(2 \cdot F\right)\\
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;\frac{\sqrt{2 \cdot t\_0} \cdot \sqrt{F \cdot \left(A + A\right)}}{t\_1}\\
\mathbf{elif}\;t\_3 \leq -2 \cdot 10^{-199}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A + C\right) - \sqrt{\mathsf{fma}\left(A - C, A - C, B \cdot B\right)}\right) \cdot t\_4}}{0 - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{t\_4 \cdot \left(A + \mathsf{fma}\left(\frac{B \cdot B}{C}, -0.5, A\right)\right)}}{t\_1}\\
\end{array}
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -inf.0Initial program 3.4%
Taylor expanded in C around inf
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f6421.2%
Simplified21.2%
associate-*r*N/A
associate-*l*N/A
sqrt-prodN/A
pow1/2N/A
*-lowering-*.f64N/A
Applied egg-rr29.9%
pow2N/A
associate-*l*N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6429.9%
Applied egg-rr29.9%
if -inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -1.99999999999999996e-199Initial program 97.3%
distribute-frac-negN/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
Applied egg-rr97.3%
if -1.99999999999999996e-199 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) Initial program 4.4%
Taylor expanded in C around inf
associate--l+N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-commutativeN/A
+-lowering-+.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6413.9%
Simplified13.9%
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6413.9%
Applied egg-rr13.9%
pow2N/A
associate-*r*N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6413.9%
Applied egg-rr13.9%
Final simplification29.4%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 1.65e-21)
(/
(sqrt
(*
(* (fma B B (* (* A C) -4.0)) (* 2.0 F))
(+ A (fma (/ (* B B) C) -0.5 A))))
(- 0.0 (fma (* A C) -4.0 (* B B))))
(* (sqrt (* F (- A (sqrt (fma B B (* A A)))))) (/ (sqrt 2.0) (- 0.0 B)))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 1.65e-21) {
tmp = sqrt(((fma(B, B, ((A * C) * -4.0)) * (2.0 * F)) * (A + fma(((B * B) / C), -0.5, A)))) / (0.0 - fma((A * C), -4.0, (B * B)));
} else {
tmp = sqrt((F * (A - sqrt(fma(B, B, (A * A)))))) * (sqrt(2.0) / (0.0 - B));
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (B <= 1.65e-21) tmp = Float64(sqrt(Float64(Float64(fma(B, B, Float64(Float64(A * C) * -4.0)) * Float64(2.0 * F)) * Float64(A + fma(Float64(Float64(B * B) / C), -0.5, A)))) / Float64(0.0 - fma(Float64(A * C), -4.0, Float64(B * B)))); else tmp = Float64(sqrt(Float64(F * Float64(A - sqrt(fma(B, B, Float64(A * A)))))) * Float64(sqrt(2.0) / Float64(0.0 - B))); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 1.65e-21], N[(N[Sqrt[N[(N[(N[(B * B + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision] * N[(A + N[(N[(N[(B * B), $MachinePrecision] / C), $MachinePrecision] * -0.5 + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(0.0 - N[(N[(A * C), $MachinePrecision] * -4.0 + N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[N[(B * B + N[(A * A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / N[(0.0 - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 1.65 \cdot 10^{-21}:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B, B, \left(A \cdot C\right) \cdot -4\right) \cdot \left(2 \cdot F\right)\right) \cdot \left(A + \mathsf{fma}\left(\frac{B \cdot B}{C}, -0.5, A\right)\right)}}{0 - \mathsf{fma}\left(A \cdot C, -4, B \cdot B\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \sqrt{\mathsf{fma}\left(B, B, A \cdot A\right)}\right)} \cdot \frac{\sqrt{2}}{0 - B}\\
\end{array}
\end{array}
if B < 1.65000000000000004e-21Initial program 20.6%
Taylor expanded in C around inf
associate--l+N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-commutativeN/A
+-lowering-+.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6419.5%
Simplified19.5%
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6419.5%
Applied egg-rr19.5%
pow2N/A
associate-*r*N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6419.5%
Applied egg-rr19.5%
if 1.65000000000000004e-21 < B Initial program 10.9%
Taylor expanded in C around 0
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
Simplified16.6%
Final simplification18.8%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 6e-23)
(/
(sqrt (* (+ A A) (* (fma B B (* (* A C) -4.0)) (* 2.0 F))))
(- 0.0 (fma (* A C) -4.0 (* B B))))
(* (sqrt (* F (- A (sqrt (fma B B (* A A)))))) (/ (sqrt 2.0) (- 0.0 B)))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 6e-23) {
tmp = sqrt(((A + A) * (fma(B, B, ((A * C) * -4.0)) * (2.0 * F)))) / (0.0 - fma((A * C), -4.0, (B * B)));
} else {
tmp = sqrt((F * (A - sqrt(fma(B, B, (A * A)))))) * (sqrt(2.0) / (0.0 - B));
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (B <= 6e-23) tmp = Float64(sqrt(Float64(Float64(A + A) * Float64(fma(B, B, Float64(Float64(A * C) * -4.0)) * Float64(2.0 * F)))) / Float64(0.0 - fma(Float64(A * C), -4.0, Float64(B * B)))); else tmp = Float64(sqrt(Float64(F * Float64(A - sqrt(fma(B, B, Float64(A * A)))))) * Float64(sqrt(2.0) / Float64(0.0 - B))); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 6e-23], N[(N[Sqrt[N[(N[(A + A), $MachinePrecision] * N[(N[(B * B + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(0.0 - N[(N[(A * C), $MachinePrecision] * -4.0 + N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[N[(B * B + N[(A * A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / N[(0.0 - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 6 \cdot 10^{-23}:\\
\;\;\;\;\frac{\sqrt{\left(A + A\right) \cdot \left(\mathsf{fma}\left(B, B, \left(A \cdot C\right) \cdot -4\right) \cdot \left(2 \cdot F\right)\right)}}{0 - \mathsf{fma}\left(A \cdot C, -4, B \cdot B\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \sqrt{\mathsf{fma}\left(B, B, A \cdot A\right)}\right)} \cdot \frac{\sqrt{2}}{0 - B}\\
\end{array}
\end{array}
if B < 6.00000000000000006e-23Initial program 20.7%
Taylor expanded in C around inf
associate--l+N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-commutativeN/A
+-lowering-+.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6419.5%
Simplified19.5%
*-commutativeN/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6419.5%
Applied egg-rr19.5%
pow2N/A
associate-*r*N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6419.5%
Applied egg-rr19.5%
Taylor expanded in B around 0
Simplified18.0%
if 6.00000000000000006e-23 < B Initial program 10.8%
Taylor expanded in C around 0
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
Simplified16.4%
Final simplification17.6%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma (* A C) -4.0 (* B B))))
(if (<= B 7.8e-28)
(* (sqrt (* t_0 (* A F))) (/ (- 0.0 2.0) t_0))
(*
(sqrt (* F (- A (sqrt (fma B B (* A A))))))
(/ (sqrt 2.0) (- 0.0 B))))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double t_0 = fma((A * C), -4.0, (B * B));
double tmp;
if (B <= 7.8e-28) {
tmp = sqrt((t_0 * (A * F))) * ((0.0 - 2.0) / t_0);
} else {
tmp = sqrt((F * (A - sqrt(fma(B, B, (A * A)))))) * (sqrt(2.0) / (0.0 - B));
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) t_0 = fma(Float64(A * C), -4.0, Float64(B * B)) tmp = 0.0 if (B <= 7.8e-28) tmp = Float64(sqrt(Float64(t_0 * Float64(A * F))) * Float64(Float64(0.0 - 2.0) / t_0)); else tmp = Float64(sqrt(Float64(F * Float64(A - sqrt(fma(B, B, Float64(A * A)))))) * Float64(sqrt(2.0) / Float64(0.0 - B))); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(A * C), $MachinePrecision] * -4.0 + N[(B * B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 7.8e-28], N[(N[Sqrt[N[(t$95$0 * N[(A * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(0.0 - 2.0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[N[(B * B + N[(A * A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / N[(0.0 - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(A \cdot C, -4, B \cdot B\right)\\
\mathbf{if}\;B \leq 7.8 \cdot 10^{-28}:\\
\;\;\;\;\sqrt{t\_0 \cdot \left(A \cdot F\right)} \cdot \frac{0 - 2}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \sqrt{\mathsf{fma}\left(B, B, A \cdot A\right)}\right)} \cdot \frac{\sqrt{2}}{0 - B}\\
\end{array}
\end{array}
if B < 7.79999999999999998e-28Initial program 20.9%
Taylor expanded in C around inf
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f6417.6%
Simplified17.6%
associate-*r*N/A
associate-*l*N/A
sqrt-prodN/A
pow1/2N/A
*-lowering-*.f64N/A
Applied egg-rr12.7%
Taylor expanded in F around 0
mul-1-negN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
Simplified17.6%
if 7.79999999999999998e-28 < B Initial program 10.5%
Taylor expanded in C around 0
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
Simplified16.1%
Final simplification17.3%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (/ -1.0 (fma B B (* (* A C) -4.0)))))
(if (<= B 2.35e-23)
(* t_0 (sqrt (* (* (* A A) -16.0) (* C F))))
(if (<= B 4e+96)
(* t_0 (sqrt (* -2.0 (* F (* B (* B B))))))
(/ (* -2.0 (sqrt (* A F))) B)))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double t_0 = -1.0 / fma(B, B, ((A * C) * -4.0));
double tmp;
if (B <= 2.35e-23) {
tmp = t_0 * sqrt((((A * A) * -16.0) * (C * F)));
} else if (B <= 4e+96) {
tmp = t_0 * sqrt((-2.0 * (F * (B * (B * B)))));
} else {
tmp = (-2.0 * sqrt((A * F))) / B;
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) t_0 = Float64(-1.0 / fma(B, B, Float64(Float64(A * C) * -4.0))) tmp = 0.0 if (B <= 2.35e-23) tmp = Float64(t_0 * sqrt(Float64(Float64(Float64(A * A) * -16.0) * Float64(C * F)))); elseif (B <= 4e+96) tmp = Float64(t_0 * sqrt(Float64(-2.0 * Float64(F * Float64(B * Float64(B * B)))))); else tmp = Float64(Float64(-2.0 * sqrt(Float64(A * F))) / B); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(-1.0 / N[(B * B + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 2.35e-23], N[(t$95$0 * N[Sqrt[N[(N[(N[(A * A), $MachinePrecision] * -16.0), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 4e+96], N[(t$95$0 * N[Sqrt[N[(-2.0 * N[(F * N[(B * N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := \frac{-1}{\mathsf{fma}\left(B, B, \left(A \cdot C\right) \cdot -4\right)}\\
\mathbf{if}\;B \leq 2.35 \cdot 10^{-23}:\\
\;\;\;\;t\_0 \cdot \sqrt{\left(\left(A \cdot A\right) \cdot -16\right) \cdot \left(C \cdot F\right)}\\
\mathbf{elif}\;B \leq 4 \cdot 10^{+96}:\\
\;\;\;\;t\_0 \cdot \sqrt{-2 \cdot \left(F \cdot \left(B \cdot \left(B \cdot B\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 2.35e-23Initial program 20.7%
frac-2negN/A
div-invN/A
remove-double-negN/A
frac-2negN/A
metadata-evalN/A
remove-double-negN/A
*-lowering-*.f64N/A
Applied egg-rr20.7%
Taylor expanded in C around inf
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
mul-1-negN/A
neg-lowering-neg.f6417.0%
Simplified17.0%
Taylor expanded in A around 0
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f6412.3%
Simplified12.3%
if 2.35e-23 < B < 4.0000000000000002e96Initial program 26.9%
frac-2negN/A
div-invN/A
remove-double-negN/A
frac-2negN/A
metadata-evalN/A
remove-double-negN/A
*-lowering-*.f64N/A
Applied egg-rr26.7%
Taylor expanded in B around inf
*-lowering-*.f64N/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6428.9%
Simplified28.9%
if 4.0000000000000002e96 < B Initial program 3.0%
Taylor expanded in C around inf
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f642.4%
Simplified2.4%
*-commutativeN/A
associate-*r*N/A
sqrt-prodN/A
pow1/2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
pow1/2N/A
sqrt-lowering-sqrt.f64N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr0.0%
Taylor expanded in B around inf
/-lowering-/.f64N/A
Simplified1.8%
Taylor expanded in A around 0
sqrt-lowering-sqrt.f64N/A
*-commutativeN/A
*-lowering-*.f647.9%
Simplified7.9%
Final simplification12.9%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (/ -1.0 (fma B B (* (* A C) -4.0)))))
(if (<= B 6e-24)
(* t_0 (sqrt (* -16.0 (* F (* C (* A A))))))
(if (<= B 6.5e+95)
(* t_0 (sqrt (* -2.0 (* F (* B (* B B))))))
(/ (* -2.0 (sqrt (* A F))) B)))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double t_0 = -1.0 / fma(B, B, ((A * C) * -4.0));
double tmp;
if (B <= 6e-24) {
tmp = t_0 * sqrt((-16.0 * (F * (C * (A * A)))));
} else if (B <= 6.5e+95) {
tmp = t_0 * sqrt((-2.0 * (F * (B * (B * B)))));
} else {
tmp = (-2.0 * sqrt((A * F))) / B;
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) t_0 = Float64(-1.0 / fma(B, B, Float64(Float64(A * C) * -4.0))) tmp = 0.0 if (B <= 6e-24) tmp = Float64(t_0 * sqrt(Float64(-16.0 * Float64(F * Float64(C * Float64(A * A)))))); elseif (B <= 6.5e+95) tmp = Float64(t_0 * sqrt(Float64(-2.0 * Float64(F * Float64(B * Float64(B * B)))))); else tmp = Float64(Float64(-2.0 * sqrt(Float64(A * F))) / B); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(-1.0 / N[(B * B + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 6e-24], N[(t$95$0 * N[Sqrt[N[(-16.0 * N[(F * N[(C * N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 6.5e+95], N[(t$95$0 * N[Sqrt[N[(-2.0 * N[(F * N[(B * N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := \frac{-1}{\mathsf{fma}\left(B, B, \left(A \cdot C\right) \cdot -4\right)}\\
\mathbf{if}\;B \leq 6 \cdot 10^{-24}:\\
\;\;\;\;t\_0 \cdot \sqrt{-16 \cdot \left(F \cdot \left(C \cdot \left(A \cdot A\right)\right)\right)}\\
\mathbf{elif}\;B \leq 6.5 \cdot 10^{+95}:\\
\;\;\;\;t\_0 \cdot \sqrt{-2 \cdot \left(F \cdot \left(B \cdot \left(B \cdot B\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 5.99999999999999991e-24Initial program 20.7%
frac-2negN/A
div-invN/A
remove-double-negN/A
frac-2negN/A
metadata-evalN/A
remove-double-negN/A
*-lowering-*.f64N/A
Applied egg-rr20.7%
Taylor expanded in A around -inf
*-lowering-*.f64N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6411.4%
Simplified11.4%
if 5.99999999999999991e-24 < B < 6.5e95Initial program 26.9%
frac-2negN/A
div-invN/A
remove-double-negN/A
frac-2negN/A
metadata-evalN/A
remove-double-negN/A
*-lowering-*.f64N/A
Applied egg-rr26.7%
Taylor expanded in B around inf
*-lowering-*.f64N/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6428.9%
Simplified28.9%
if 6.5e95 < B Initial program 3.0%
Taylor expanded in C around inf
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f642.4%
Simplified2.4%
*-commutativeN/A
associate-*r*N/A
sqrt-prodN/A
pow1/2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
pow1/2N/A
sqrt-lowering-sqrt.f64N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr0.0%
Taylor expanded in B around inf
/-lowering-/.f64N/A
Simplified1.8%
Taylor expanded in A around 0
sqrt-lowering-sqrt.f64N/A
*-commutativeN/A
*-lowering-*.f647.9%
Simplified7.9%
Final simplification12.2%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 7.2e-28)
(*
(sqrt (* (* A -8.0) (* C (* F (+ A A)))))
(/ -1.0 (fma B B (* (* A C) -4.0))))
(* (sqrt (* F (- A (sqrt (fma B B (* A A)))))) (/ (sqrt 2.0) (- 0.0 B)))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 7.2e-28) {
tmp = sqrt(((A * -8.0) * (C * (F * (A + A))))) * (-1.0 / fma(B, B, ((A * C) * -4.0)));
} else {
tmp = sqrt((F * (A - sqrt(fma(B, B, (A * A)))))) * (sqrt(2.0) / (0.0 - B));
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (B <= 7.2e-28) tmp = Float64(sqrt(Float64(Float64(A * -8.0) * Float64(C * Float64(F * Float64(A + A))))) * Float64(-1.0 / fma(B, B, Float64(Float64(A * C) * -4.0)))); else tmp = Float64(sqrt(Float64(F * Float64(A - sqrt(fma(B, B, Float64(A * A)))))) * Float64(sqrt(2.0) / Float64(0.0 - B))); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 7.2e-28], N[(N[Sqrt[N[(N[(A * -8.0), $MachinePrecision] * N[(C * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / N[(B * B + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[N[(B * B + N[(A * A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / N[(0.0 - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 7.2 \cdot 10^{-28}:\\
\;\;\;\;\sqrt{\left(A \cdot -8\right) \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)} \cdot \frac{-1}{\mathsf{fma}\left(B, B, \left(A \cdot C\right) \cdot -4\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \sqrt{\mathsf{fma}\left(B, B, A \cdot A\right)}\right)} \cdot \frac{\sqrt{2}}{0 - B}\\
\end{array}
\end{array}
if B < 7.1999999999999997e-28Initial program 20.9%
frac-2negN/A
div-invN/A
remove-double-negN/A
frac-2negN/A
metadata-evalN/A
remove-double-negN/A
*-lowering-*.f64N/A
Applied egg-rr20.9%
Taylor expanded in C around inf
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
mul-1-negN/A
neg-lowering-neg.f6417.1%
Simplified17.1%
if 7.1999999999999997e-28 < B Initial program 10.5%
Taylor expanded in C around 0
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
Simplified16.1%
Final simplification16.9%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= B 4.5e-25) (* (/ -1.0 (fma B B (* (* A C) -4.0))) (sqrt (* (* (* A A) -16.0) (* C F)))) (* (sqrt (* F (- A (sqrt (fma B B (* A A)))))) (/ (sqrt 2.0) (- 0.0 B)))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 4.5e-25) {
tmp = (-1.0 / fma(B, B, ((A * C) * -4.0))) * sqrt((((A * A) * -16.0) * (C * F)));
} else {
tmp = sqrt((F * (A - sqrt(fma(B, B, (A * A)))))) * (sqrt(2.0) / (0.0 - B));
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (B <= 4.5e-25) tmp = Float64(Float64(-1.0 / fma(B, B, Float64(Float64(A * C) * -4.0))) * sqrt(Float64(Float64(Float64(A * A) * -16.0) * Float64(C * F)))); else tmp = Float64(sqrt(Float64(F * Float64(A - sqrt(fma(B, B, Float64(A * A)))))) * Float64(sqrt(2.0) / Float64(0.0 - B))); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 4.5e-25], N[(N[(-1.0 / N[(B * B + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(N[(A * A), $MachinePrecision] * -16.0), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[N[(B * B + N[(A * A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / N[(0.0 - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 4.5 \cdot 10^{-25}:\\
\;\;\;\;\frac{-1}{\mathsf{fma}\left(B, B, \left(A \cdot C\right) \cdot -4\right)} \cdot \sqrt{\left(\left(A \cdot A\right) \cdot -16\right) \cdot \left(C \cdot F\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \sqrt{\mathsf{fma}\left(B, B, A \cdot A\right)}\right)} \cdot \frac{\sqrt{2}}{0 - B}\\
\end{array}
\end{array}
if B < 4.5000000000000001e-25Initial program 20.7%
frac-2negN/A
div-invN/A
remove-double-negN/A
frac-2negN/A
metadata-evalN/A
remove-double-negN/A
*-lowering-*.f64N/A
Applied egg-rr20.7%
Taylor expanded in C around inf
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
mul-1-negN/A
neg-lowering-neg.f6417.0%
Simplified17.0%
Taylor expanded in A around 0
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f6412.3%
Simplified12.3%
if 4.5000000000000001e-25 < B Initial program 10.8%
Taylor expanded in C around 0
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
Simplified16.4%
Final simplification13.3%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= B 9.5e-23) (* (/ -1.0 (fma B B (* (* A C) -4.0))) (sqrt (* -16.0 (* F (* C (* A A)))))) (/ (* -2.0 (sqrt (* A F))) B)))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 9.5e-23) {
tmp = (-1.0 / fma(B, B, ((A * C) * -4.0))) * sqrt((-16.0 * (F * (C * (A * A)))));
} else {
tmp = (-2.0 * sqrt((A * F))) / B;
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (B <= 9.5e-23) tmp = Float64(Float64(-1.0 / fma(B, B, Float64(Float64(A * C) * -4.0))) * sqrt(Float64(-16.0 * Float64(F * Float64(C * Float64(A * A)))))); else tmp = Float64(Float64(-2.0 * sqrt(Float64(A * F))) / B); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 9.5e-23], N[(N[(-1.0 / N[(B * B + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(-16.0 * N[(F * N[(C * N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 9.5 \cdot 10^{-23}:\\
\;\;\;\;\frac{-1}{\mathsf{fma}\left(B, B, \left(A \cdot C\right) \cdot -4\right)} \cdot \sqrt{-16 \cdot \left(F \cdot \left(C \cdot \left(A \cdot A\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 9.50000000000000058e-23Initial program 20.6%
frac-2negN/A
div-invN/A
remove-double-negN/A
frac-2negN/A
metadata-evalN/A
remove-double-negN/A
*-lowering-*.f64N/A
Applied egg-rr20.6%
Taylor expanded in A around -inf
*-lowering-*.f64N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6411.4%
Simplified11.4%
if 9.50000000000000058e-23 < B Initial program 10.9%
Taylor expanded in C around inf
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f642.1%
Simplified2.1%
*-commutativeN/A
associate-*r*N/A
sqrt-prodN/A
pow1/2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
pow1/2N/A
sqrt-lowering-sqrt.f64N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr1.6%
Taylor expanded in B around inf
/-lowering-/.f64N/A
Simplified1.7%
Taylor expanded in A around 0
sqrt-lowering-sqrt.f64N/A
*-commutativeN/A
*-lowering-*.f647.7%
Simplified7.7%
Final simplification10.5%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (/ (* -2.0 (sqrt (* A F))) B))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return (-2.0 * sqrt((A * F))) / B;
}
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = ((-2.0d0) * sqrt((a * f))) / b
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
return (-2.0 * Math.sqrt((A * F))) / B;
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): return (-2.0 * math.sqrt((A * F))) / B
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return Float64(Float64(-2.0 * sqrt(Float64(A * F))) / B) end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp = code(A, B, C, F)
tmp = (-2.0 * sqrt((A * F))) / B;
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(N[(-2.0 * N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\frac{-2 \cdot \sqrt{A \cdot F}}{B}
\end{array}
Initial program 18.3%
Taylor expanded in C around inf
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f6414.2%
Simplified14.2%
*-commutativeN/A
associate-*r*N/A
sqrt-prodN/A
pow1/2N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
pow1/2N/A
sqrt-lowering-sqrt.f64N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
*-lowering-*.f64N/A
Applied egg-rr5.1%
Taylor expanded in B around inf
/-lowering-/.f64N/A
Simplified1.2%
Taylor expanded in A around 0
sqrt-lowering-sqrt.f64N/A
*-commutativeN/A
*-lowering-*.f643.0%
Simplified3.0%
Final simplification3.0%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (sqrt (fabs (fma 2.0 (/ F B) 0.0))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return sqrt(fabs(fma(2.0, (F / B), 0.0)));
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return sqrt(abs(fma(2.0, Float64(F / B), 0.0))) end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[Sqrt[N[Abs[N[(2.0 * N[(F / B), $MachinePrecision] + 0.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\sqrt{\left|\mathsf{fma}\left(2, \frac{F}{B}, 0\right)\right|}
\end{array}
Initial program 18.3%
Taylor expanded in B around -inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
rem-square-sqrtN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f642.0%
Simplified2.0%
*-commutativeN/A
mul-1-negN/A
cancel-sign-subN/A
+-lowering-+.f64N/A
sqrt-unprodN/A
rem-square-sqrtN/A
sqr-negN/A
mul-1-negN/A
mul-1-negN/A
rem-square-sqrtN/A
swap-sqrN/A
*-commutativeN/A
*-commutativeN/A
+-lft-identityN/A
+-commutativeN/A
distribute-rgt-outN/A
Applied egg-rr2.0%
+-lft-identityN/A
+-rgt-identityN/A
sqrt-lowering-sqrt.f64N/A
+-rgt-identityN/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f642.0%
Applied egg-rr2.0%
flip3-+N/A
metadata-evalN/A
associate-+r-N/A
metadata-evalN/A
sub-negN/A
--rgt-identityN/A
+-rgt-identityN/A
metadata-evalN/A
sub-negN/A
mul0-rgtN/A
--rgt-identityN/A
Applied egg-rr3.1%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (sqrt (* F (/ 2.0 B))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return sqrt((F * (2.0 / B)));
}
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = sqrt((f * (2.0d0 / b)))
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
return Math.sqrt((F * (2.0 / B)));
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): return math.sqrt((F * (2.0 / B)))
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return sqrt(Float64(F * Float64(2.0 / B))) end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp = code(A, B, C, F)
tmp = sqrt((F * (2.0 / B)));
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[Sqrt[N[(F * N[(2.0 / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\sqrt{F \cdot \frac{2}{B}}
\end{array}
Initial program 18.3%
Taylor expanded in B around -inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
unpow2N/A
rem-square-sqrtN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f642.0%
Simplified2.0%
*-commutativeN/A
mul-1-negN/A
cancel-sign-subN/A
+-lowering-+.f64N/A
sqrt-unprodN/A
rem-square-sqrtN/A
sqr-negN/A
mul-1-negN/A
mul-1-negN/A
rem-square-sqrtN/A
swap-sqrN/A
*-commutativeN/A
*-commutativeN/A
+-lft-identityN/A
+-commutativeN/A
distribute-rgt-outN/A
Applied egg-rr2.0%
+-lft-identityN/A
+-rgt-identityN/A
sqrt-lowering-sqrt.f64N/A
+-rgt-identityN/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f642.0%
Applied egg-rr2.0%
+-rgt-identityN/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f642.0%
Applied egg-rr2.0%
Final simplification2.0%
herbie shell --seed 2024193
(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))))