
(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 9 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)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (* C (* A 4.0)))
(t_1 (- t_0 (pow B_m 2.0)))
(t_2
(/
(sqrt
(*
(- (+ C A) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))
(* (* F (- (pow B_m 2.0) t_0)) 2.0)))
t_1)))
(if (<= t_2 (- INFINITY))
(/
(* (sqrt (* (+ A A) F)) (sqrt (* (fma -4.0 (* C A) (* B_m B_m)) 2.0)))
t_1)
(if (<= t_2 -1e-203)
t_2
(if (<= t_2 INFINITY)
(/
1.0
(/
(fma (* C 4.0) A (* (- B_m) B_m))
(sqrt
(*
(fma (* -4.0 C) A (* B_m B_m))
(* (* F 2.0) (+ (fma (/ (* B_m B_m) C) -0.5 A) A))))))
(* (- (sqrt 2.0)) (sqrt (* (/ -1.0 B_m) F))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = C * (A * 4.0);
double t_1 = t_0 - pow(B_m, 2.0);
double t_2 = sqrt((((C + A) - sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))) * ((F * (pow(B_m, 2.0) - t_0)) * 2.0))) / t_1;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = (sqrt(((A + A) * F)) * sqrt((fma(-4.0, (C * A), (B_m * B_m)) * 2.0))) / t_1;
} else if (t_2 <= -1e-203) {
tmp = t_2;
} else if (t_2 <= ((double) INFINITY)) {
tmp = 1.0 / (fma((C * 4.0), A, (-B_m * B_m)) / sqrt((fma((-4.0 * C), A, (B_m * B_m)) * ((F * 2.0) * (fma(((B_m * B_m) / C), -0.5, A) + A)))));
} else {
tmp = -sqrt(2.0) * sqrt(((-1.0 / B_m) * F));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(C * Float64(A * 4.0)) t_1 = Float64(t_0 - (B_m ^ 2.0)) t_2 = Float64(sqrt(Float64(Float64(Float64(C + A) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0)))) * Float64(Float64(F * Float64((B_m ^ 2.0) - t_0)) * 2.0))) / t_1) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(sqrt(Float64(Float64(A + A) * F)) * sqrt(Float64(fma(-4.0, Float64(C * A), Float64(B_m * B_m)) * 2.0))) / t_1); elseif (t_2 <= -1e-203) tmp = t_2; elseif (t_2 <= Inf) tmp = Float64(1.0 / Float64(fma(Float64(C * 4.0), A, Float64(Float64(-B_m) * B_m)) / sqrt(Float64(fma(Float64(-4.0 * C), A, Float64(B_m * B_m)) * Float64(Float64(F * 2.0) * Float64(fma(Float64(Float64(B_m * B_m) / C), -0.5, A) + A)))))); else tmp = Float64(Float64(-sqrt(2.0)) * sqrt(Float64(Float64(-1.0 / B_m) * F))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(N[(N[(C + A), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(F * N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(N[Sqrt[N[(N[(A + A), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$2, -1e-203], t$95$2, If[LessEqual[t$95$2, Infinity], N[(1.0 / N[(N[(N[(C * 4.0), $MachinePrecision] * A + N[((-B$95$m) * B$95$m), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(N[(-4.0 * C), $MachinePrecision] * A + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(F * 2.0), $MachinePrecision] * N[(N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] / C), $MachinePrecision] * -0.5 + A), $MachinePrecision] + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[2.0], $MachinePrecision]) * N[Sqrt[N[(N[(-1.0 / B$95$m), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := C \cdot \left(A \cdot 4\right)\\
t_1 := t\_0 - {B\_m}^{2}\\
t_2 := \frac{\sqrt{\left(\left(C + A\right) - \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right) \cdot \left(\left(F \cdot \left({B\_m}^{2} - t\_0\right)\right) \cdot 2\right)}}{t\_1}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\frac{\sqrt{\left(A + A\right) \cdot F} \cdot \sqrt{\mathsf{fma}\left(-4, C \cdot A, B\_m \cdot B\_m\right) \cdot 2}}{t\_1}\\
\mathbf{elif}\;t\_2 \leq -1 \cdot 10^{-203}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(C \cdot 4, A, \left(-B\_m\right) \cdot B\_m\right)}{\sqrt{\mathsf{fma}\left(-4 \cdot C, A, B\_m \cdot B\_m\right) \cdot \left(\left(F \cdot 2\right) \cdot \left(\mathsf{fma}\left(\frac{B\_m \cdot B\_m}{C}, -0.5, A\right) + A\right)\right)}}}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{2}\right) \cdot \sqrt{\frac{-1}{B\_m} \cdot F}\\
\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%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
sqrt-prodN/A
pow1/2N/A
lower-*.f64N/A
Applied rewrites8.2%
Taylor expanded in C around inf
lower--.f64N/A
mul-1-negN/A
lower-neg.f6423.4
Applied rewrites23.4%
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))) < -1e-203Initial program 99.0%
if -1e-203 < (/.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 18.8%
Taylor expanded in C around inf
sub-negN/A
mul-1-negN/A
remove-double-negN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6442.0
Applied rewrites42.0%
lift--.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6442.0
Applied rewrites42.0%
Applied rewrites42.0%
Applied rewrites43.1%
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))) Initial program 0.0%
Taylor expanded in B around -inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f642.9
Applied rewrites2.9%
Applied rewrites2.9%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites4.0%
Taylor expanded in B around inf
Applied rewrites10.1%
Final simplification31.2%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (* C (* A 4.0)))
(t_1 (- t_0 (pow B_m 2.0)))
(t_2
(/
(sqrt
(*
(- (+ C A) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))
(* (* F (- (pow B_m 2.0) t_0)) 2.0)))
t_1))
(t_3 (- (sqrt 2.0))))
(if (<= t_2 -4e+165)
(/
(* (sqrt (* (+ A A) F)) (sqrt (* (fma -4.0 (* C A) (* B_m B_m)) 2.0)))
t_1)
(if (<= t_2 -2e-158)
(*
t_3
(sqrt
(*
(/
(- (+ C A) (sqrt (fma (- A C) (- A C) (* B_m B_m))))
(fma (* -4.0 A) C (* B_m B_m)))
F)))
(if (<= t_2 INFINITY)
(/
1.0
(/
(fma (* C 4.0) A (* (- B_m) B_m))
(sqrt
(*
(fma (* -4.0 C) A (* B_m B_m))
(* (* F 2.0) (+ (fma (/ (* B_m B_m) C) -0.5 A) A))))))
(* t_3 (sqrt (* (/ -1.0 B_m) F))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = C * (A * 4.0);
double t_1 = t_0 - pow(B_m, 2.0);
double t_2 = sqrt((((C + A) - sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))) * ((F * (pow(B_m, 2.0) - t_0)) * 2.0))) / t_1;
double t_3 = -sqrt(2.0);
double tmp;
if (t_2 <= -4e+165) {
tmp = (sqrt(((A + A) * F)) * sqrt((fma(-4.0, (C * A), (B_m * B_m)) * 2.0))) / t_1;
} else if (t_2 <= -2e-158) {
tmp = t_3 * sqrt(((((C + A) - sqrt(fma((A - C), (A - C), (B_m * B_m)))) / fma((-4.0 * A), C, (B_m * B_m))) * F));
} else if (t_2 <= ((double) INFINITY)) {
tmp = 1.0 / (fma((C * 4.0), A, (-B_m * B_m)) / sqrt((fma((-4.0 * C), A, (B_m * B_m)) * ((F * 2.0) * (fma(((B_m * B_m) / C), -0.5, A) + A)))));
} else {
tmp = t_3 * sqrt(((-1.0 / B_m) * F));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(C * Float64(A * 4.0)) t_1 = Float64(t_0 - (B_m ^ 2.0)) t_2 = Float64(sqrt(Float64(Float64(Float64(C + A) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0)))) * Float64(Float64(F * Float64((B_m ^ 2.0) - t_0)) * 2.0))) / t_1) t_3 = Float64(-sqrt(2.0)) tmp = 0.0 if (t_2 <= -4e+165) tmp = Float64(Float64(sqrt(Float64(Float64(A + A) * F)) * sqrt(Float64(fma(-4.0, Float64(C * A), Float64(B_m * B_m)) * 2.0))) / t_1); elseif (t_2 <= -2e-158) tmp = Float64(t_3 * sqrt(Float64(Float64(Float64(Float64(C + A) - sqrt(fma(Float64(A - C), Float64(A - C), Float64(B_m * B_m)))) / fma(Float64(-4.0 * A), C, Float64(B_m * B_m))) * F))); elseif (t_2 <= Inf) tmp = Float64(1.0 / Float64(fma(Float64(C * 4.0), A, Float64(Float64(-B_m) * B_m)) / sqrt(Float64(fma(Float64(-4.0 * C), A, Float64(B_m * B_m)) * Float64(Float64(F * 2.0) * Float64(fma(Float64(Float64(B_m * B_m) / C), -0.5, A) + A)))))); else tmp = Float64(t_3 * sqrt(Float64(Float64(-1.0 / B_m) * F))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(N[(N[(C + A), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(F * N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision]}, Block[{t$95$3 = (-N[Sqrt[2.0], $MachinePrecision])}, If[LessEqual[t$95$2, -4e+165], N[(N[(N[Sqrt[N[(N[(A + A), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$2, -2e-158], N[(t$95$3 * N[Sqrt[N[(N[(N[(N[(C + A), $MachinePrecision] - N[Sqrt[N[(N[(A - C), $MachinePrecision] * N[(A - C), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(-4.0 * A), $MachinePrecision] * C + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(1.0 / N[(N[(N[(C * 4.0), $MachinePrecision] * A + N[((-B$95$m) * B$95$m), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(N[(-4.0 * C), $MachinePrecision] * A + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(F * 2.0), $MachinePrecision] * N[(N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] / C), $MachinePrecision] * -0.5 + A), $MachinePrecision] + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$3 * N[Sqrt[N[(N[(-1.0 / B$95$m), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := C \cdot \left(A \cdot 4\right)\\
t_1 := t\_0 - {B\_m}^{2}\\
t_2 := \frac{\sqrt{\left(\left(C + A\right) - \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right) \cdot \left(\left(F \cdot \left({B\_m}^{2} - t\_0\right)\right) \cdot 2\right)}}{t\_1}\\
t_3 := -\sqrt{2}\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{+165}:\\
\;\;\;\;\frac{\sqrt{\left(A + A\right) \cdot F} \cdot \sqrt{\mathsf{fma}\left(-4, C \cdot A, B\_m \cdot B\_m\right) \cdot 2}}{t\_1}\\
\mathbf{elif}\;t\_2 \leq -2 \cdot 10^{-158}:\\
\;\;\;\;t\_3 \cdot \sqrt{\frac{\left(C + A\right) - \sqrt{\mathsf{fma}\left(A - C, A - C, B\_m \cdot B\_m\right)}}{\mathsf{fma}\left(-4 \cdot A, C, B\_m \cdot B\_m\right)} \cdot F}\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(C \cdot 4, A, \left(-B\_m\right) \cdot B\_m\right)}{\sqrt{\mathsf{fma}\left(-4 \cdot C, A, B\_m \cdot B\_m\right) \cdot \left(\left(F \cdot 2\right) \cdot \left(\mathsf{fma}\left(\frac{B\_m \cdot B\_m}{C}, -0.5, A\right) + A\right)\right)}}}\\
\mathbf{else}:\\
\;\;\;\;t\_3 \cdot \sqrt{\frac{-1}{B\_m} \cdot F}\\
\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))) < -3.9999999999999996e165Initial program 11.2%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
sqrt-prodN/A
pow1/2N/A
lower-*.f64N/A
Applied rewrites8.7%
Taylor expanded in C around inf
lower--.f64N/A
mul-1-negN/A
lower-neg.f6423.6
Applied rewrites23.6%
if -3.9999999999999996e165 < (/.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))) < -2.00000000000000013e-158Initial program 99.0%
Taylor expanded in B around -inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f641.1
Applied rewrites1.1%
Applied rewrites1.1%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites11.3%
Applied rewrites96.6%
if -2.00000000000000013e-158 < (/.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 22.5%
Taylor expanded in C around inf
sub-negN/A
mul-1-negN/A
remove-double-negN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6441.7
Applied rewrites41.7%
lift--.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6441.7
Applied rewrites41.7%
Applied rewrites41.7%
Applied rewrites42.7%
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))) Initial program 0.0%
Taylor expanded in B around -inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f642.9
Applied rewrites2.9%
Applied rewrites2.9%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites4.0%
Taylor expanded in B around inf
Applied rewrites10.1%
Final simplification29.1%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma (* -4.0 A) C (* B_m B_m))))
(if (<= (pow B_m 2.0) 1e+128)
(/
(sqrt (* (+ (fma -0.5 (/ (* B_m B_m) C) A) A) (* t_0 (* F 2.0))))
(- t_0))
(* (- (sqrt 2.0)) (sqrt (* (/ (+ (- (/ C B_m) 1.0) (/ A B_m)) B_m) F))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = fma((-4.0 * A), C, (B_m * B_m));
double tmp;
if (pow(B_m, 2.0) <= 1e+128) {
tmp = sqrt(((fma(-0.5, ((B_m * B_m) / C), A) + A) * (t_0 * (F * 2.0)))) / -t_0;
} else {
tmp = -sqrt(2.0) * sqrt((((((C / B_m) - 1.0) + (A / B_m)) / B_m) * F));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = fma(Float64(-4.0 * A), C, Float64(B_m * B_m)) tmp = 0.0 if ((B_m ^ 2.0) <= 1e+128) tmp = Float64(sqrt(Float64(Float64(fma(-0.5, Float64(Float64(B_m * B_m) / C), A) + A) * Float64(t_0 * Float64(F * 2.0)))) / Float64(-t_0)); else tmp = Float64(Float64(-sqrt(2.0)) * sqrt(Float64(Float64(Float64(Float64(Float64(C / B_m) - 1.0) + Float64(A / B_m)) / B_m) * F))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[(-4.0 * A), $MachinePrecision] * C + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+128], N[(N[Sqrt[N[(N[(N[(-0.5 * N[(N[(B$95$m * B$95$m), $MachinePrecision] / C), $MachinePrecision] + A), $MachinePrecision] + A), $MachinePrecision] * N[(t$95$0 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], N[((-N[Sqrt[2.0], $MachinePrecision]) * N[Sqrt[N[(N[(N[(N[(N[(C / B$95$m), $MachinePrecision] - 1.0), $MachinePrecision] + N[(A / B$95$m), $MachinePrecision]), $MachinePrecision] / B$95$m), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4 \cdot A, C, B\_m \cdot B\_m\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{+128}:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(-0.5, \frac{B\_m \cdot B\_m}{C}, A\right) + A\right) \cdot \left(t\_0 \cdot \left(F \cdot 2\right)\right)}}{-t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{2}\right) \cdot \sqrt{\frac{\left(\frac{C}{B\_m} - 1\right) + \frac{A}{B\_m}}{B\_m} \cdot F}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 1.0000000000000001e128Initial program 24.2%
Taylor expanded in C around inf
sub-negN/A
mul-1-negN/A
remove-double-negN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6426.3
Applied rewrites26.3%
lift--.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6426.3
Applied rewrites26.3%
Applied rewrites26.3%
if 1.0000000000000001e128 < (pow.f64 B #s(literal 2 binary64)) Initial program 7.8%
Taylor expanded in B around -inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f642.8
Applied rewrites2.8%
Applied rewrites2.8%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites5.8%
Taylor expanded in B around inf
Applied rewrites18.8%
Final simplification23.1%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (sqrt 2.0))))
(if (<= (pow B_m 2.0) 1e+128)
(* t_0 (sqrt (* (/ -0.5 C) F)))
(* t_0 (sqrt (* (/ -1.0 B_m) F))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = -sqrt(2.0);
double tmp;
if (pow(B_m, 2.0) <= 1e+128) {
tmp = t_0 * sqrt(((-0.5 / C) * F));
} else {
tmp = t_0 * sqrt(((-1.0 / B_m) * F));
}
return tmp;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = -sqrt(2.0d0)
if ((b_m ** 2.0d0) <= 1d+128) then
tmp = t_0 * sqrt((((-0.5d0) / c) * f))
else
tmp = t_0 * sqrt((((-1.0d0) / b_m) * f))
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double t_0 = -Math.sqrt(2.0);
double tmp;
if (Math.pow(B_m, 2.0) <= 1e+128) {
tmp = t_0 * Math.sqrt(((-0.5 / C) * F));
} else {
tmp = t_0 * Math.sqrt(((-1.0 / B_m) * F));
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): t_0 = -math.sqrt(2.0) tmp = 0 if math.pow(B_m, 2.0) <= 1e+128: tmp = t_0 * math.sqrt(((-0.5 / C) * F)) else: tmp = t_0 * math.sqrt(((-1.0 / B_m) * F)) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(-sqrt(2.0)) tmp = 0.0 if ((B_m ^ 2.0) <= 1e+128) tmp = Float64(t_0 * sqrt(Float64(Float64(-0.5 / C) * F))); else tmp = Float64(t_0 * sqrt(Float64(Float64(-1.0 / B_m) * F))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
t_0 = -sqrt(2.0);
tmp = 0.0;
if ((B_m ^ 2.0) <= 1e+128)
tmp = t_0 * sqrt(((-0.5 / C) * F));
else
tmp = t_0 * sqrt(((-1.0 / B_m) * F));
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = (-N[Sqrt[2.0], $MachinePrecision])}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+128], N[(t$95$0 * N[Sqrt[N[(N[(-0.5 / C), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Sqrt[N[(N[(-1.0 / B$95$m), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := -\sqrt{2}\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{+128}:\\
\;\;\;\;t\_0 \cdot \sqrt{\frac{-0.5}{C} \cdot F}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{\frac{-1}{B\_m} \cdot F}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 1.0000000000000001e128Initial program 24.2%
Taylor expanded in B around -inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f641.8
Applied rewrites1.8%
Applied rewrites1.8%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites5.4%
Taylor expanded in A around -inf
Applied rewrites22.5%
if 1.0000000000000001e128 < (pow.f64 B #s(literal 2 binary64)) Initial program 7.8%
Taylor expanded in B around -inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f642.8
Applied rewrites2.8%
Applied rewrites2.8%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites5.8%
Taylor expanded in B around inf
Applied rewrites17.5%
Final simplification20.4%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (sqrt 2.0))))
(if (<= B_m 4.3e-234)
(/
(sqrt
(*
(* (* (fma (* -4.0 C) A (* B_m B_m)) F) 2.0)
(+ (fma (/ (* B_m B_m) C) -0.5 A) A)))
(- (* (* C A) -4.0)))
(if (<= B_m 4.2e+64)
(* t_0 (sqrt (* (/ -0.5 C) F)))
(* t_0 (sqrt (* (/ (+ (- (/ C B_m) 1.0) (/ A B_m)) B_m) F)))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = -sqrt(2.0);
double tmp;
if (B_m <= 4.3e-234) {
tmp = sqrt((((fma((-4.0 * C), A, (B_m * B_m)) * F) * 2.0) * (fma(((B_m * B_m) / C), -0.5, A) + A))) / -((C * A) * -4.0);
} else if (B_m <= 4.2e+64) {
tmp = t_0 * sqrt(((-0.5 / C) * F));
} else {
tmp = t_0 * sqrt((((((C / B_m) - 1.0) + (A / B_m)) / B_m) * F));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(-sqrt(2.0)) tmp = 0.0 if (B_m <= 4.3e-234) tmp = Float64(sqrt(Float64(Float64(Float64(fma(Float64(-4.0 * C), A, Float64(B_m * B_m)) * F) * 2.0) * Float64(fma(Float64(Float64(B_m * B_m) / C), -0.5, A) + A))) / Float64(-Float64(Float64(C * A) * -4.0))); elseif (B_m <= 4.2e+64) tmp = Float64(t_0 * sqrt(Float64(Float64(-0.5 / C) * F))); else tmp = Float64(t_0 * sqrt(Float64(Float64(Float64(Float64(Float64(C / B_m) - 1.0) + Float64(A / B_m)) / B_m) * F))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = (-N[Sqrt[2.0], $MachinePrecision])}, If[LessEqual[B$95$m, 4.3e-234], N[(N[Sqrt[N[(N[(N[(N[(N[(-4.0 * C), $MachinePrecision] * A + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision] * N[(N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] / C), $MachinePrecision] * -0.5 + A), $MachinePrecision] + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(N[(C * A), $MachinePrecision] * -4.0), $MachinePrecision])), $MachinePrecision], If[LessEqual[B$95$m, 4.2e+64], N[(t$95$0 * N[Sqrt[N[(N[(-0.5 / C), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Sqrt[N[(N[(N[(N[(N[(C / B$95$m), $MachinePrecision] - 1.0), $MachinePrecision] + N[(A / B$95$m), $MachinePrecision]), $MachinePrecision] / B$95$m), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := -\sqrt{2}\\
\mathbf{if}\;B\_m \leq 4.3 \cdot 10^{-234}:\\
\;\;\;\;\frac{\sqrt{\left(\left(\mathsf{fma}\left(-4 \cdot C, A, B\_m \cdot B\_m\right) \cdot F\right) \cdot 2\right) \cdot \left(\mathsf{fma}\left(\frac{B\_m \cdot B\_m}{C}, -0.5, A\right) + A\right)}}{-\left(C \cdot A\right) \cdot -4}\\
\mathbf{elif}\;B\_m \leq 4.2 \cdot 10^{+64}:\\
\;\;\;\;t\_0 \cdot \sqrt{\frac{-0.5}{C} \cdot F}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{\frac{\left(\frac{C}{B\_m} - 1\right) + \frac{A}{B\_m}}{B\_m} \cdot F}\\
\end{array}
\end{array}
if B < 4.3000000000000001e-234Initial program 16.2%
Taylor expanded in C around inf
sub-negN/A
mul-1-negN/A
remove-double-negN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6415.1
Applied rewrites15.1%
lift--.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6415.1
Applied rewrites15.1%
Taylor expanded in C around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6413.1
Applied rewrites13.1%
if 4.3000000000000001e-234 < B < 4.2000000000000001e64Initial program 26.4%
Taylor expanded in B around -inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f641.4
Applied rewrites1.4%
Applied rewrites1.4%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites5.7%
Taylor expanded in A around -inf
Applied rewrites21.4%
if 4.2000000000000001e64 < B Initial program 7.6%
Taylor expanded in B around -inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f642.0
Applied rewrites2.0%
Applied rewrites2.0%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites6.1%
Taylor expanded in B around inf
Applied rewrites43.1%
Final simplification20.0%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (sqrt 2.0))))
(if (<= B_m 4.2e+64)
(* t_0 (sqrt (* (/ -0.5 C) F)))
(* t_0 (sqrt (* (/ (+ (- (/ C B_m) 1.0) (/ A B_m)) B_m) F))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = -sqrt(2.0);
double tmp;
if (B_m <= 4.2e+64) {
tmp = t_0 * sqrt(((-0.5 / C) * F));
} else {
tmp = t_0 * sqrt((((((C / B_m) - 1.0) + (A / B_m)) / B_m) * F));
}
return tmp;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = -sqrt(2.0d0)
if (b_m <= 4.2d+64) then
tmp = t_0 * sqrt((((-0.5d0) / c) * f))
else
tmp = t_0 * sqrt((((((c / b_m) - 1.0d0) + (a / b_m)) / b_m) * f))
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double t_0 = -Math.sqrt(2.0);
double tmp;
if (B_m <= 4.2e+64) {
tmp = t_0 * Math.sqrt(((-0.5 / C) * F));
} else {
tmp = t_0 * Math.sqrt((((((C / B_m) - 1.0) + (A / B_m)) / B_m) * F));
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): t_0 = -math.sqrt(2.0) tmp = 0 if B_m <= 4.2e+64: tmp = t_0 * math.sqrt(((-0.5 / C) * F)) else: tmp = t_0 * math.sqrt((((((C / B_m) - 1.0) + (A / B_m)) / B_m) * F)) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(-sqrt(2.0)) tmp = 0.0 if (B_m <= 4.2e+64) tmp = Float64(t_0 * sqrt(Float64(Float64(-0.5 / C) * F))); else tmp = Float64(t_0 * sqrt(Float64(Float64(Float64(Float64(Float64(C / B_m) - 1.0) + Float64(A / B_m)) / B_m) * F))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
t_0 = -sqrt(2.0);
tmp = 0.0;
if (B_m <= 4.2e+64)
tmp = t_0 * sqrt(((-0.5 / C) * F));
else
tmp = t_0 * sqrt((((((C / B_m) - 1.0) + (A / B_m)) / B_m) * F));
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = (-N[Sqrt[2.0], $MachinePrecision])}, If[LessEqual[B$95$m, 4.2e+64], N[(t$95$0 * N[Sqrt[N[(N[(-0.5 / C), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Sqrt[N[(N[(N[(N[(N[(C / B$95$m), $MachinePrecision] - 1.0), $MachinePrecision] + N[(A / B$95$m), $MachinePrecision]), $MachinePrecision] / B$95$m), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := -\sqrt{2}\\
\mathbf{if}\;B\_m \leq 4.2 \cdot 10^{+64}:\\
\;\;\;\;t\_0 \cdot \sqrt{\frac{-0.5}{C} \cdot F}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{\frac{\left(\frac{C}{B\_m} - 1\right) + \frac{A}{B\_m}}{B\_m} \cdot F}\\
\end{array}
\end{array}
if B < 4.2000000000000001e64Initial program 19.1%
Taylor expanded in B around -inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f642.3
Applied rewrites2.3%
Applied rewrites2.3%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites5.5%
Taylor expanded in A around -inf
Applied rewrites17.1%
if 4.2000000000000001e64 < B Initial program 7.6%
Taylor expanded in B around -inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f642.0
Applied rewrites2.0%
Applied rewrites2.0%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites6.1%
Taylor expanded in B around inf
Applied rewrites43.1%
Final simplification21.4%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (* (- (sqrt 2.0)) (sqrt (* (/ -1.0 B_m) F))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return -sqrt(2.0) * sqrt(((-1.0 / B_m) * F));
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = -sqrt(2.0d0) * sqrt((((-1.0d0) / b_m) * f))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return -Math.sqrt(2.0) * Math.sqrt(((-1.0 / B_m) * F));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return -math.sqrt(2.0) * math.sqrt(((-1.0 / B_m) * F))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(Float64(-sqrt(2.0)) * sqrt(Float64(Float64(-1.0 / B_m) * F))) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = -sqrt(2.0) * sqrt(((-1.0 / B_m) * F));
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[((-N[Sqrt[2.0], $MachinePrecision]) * N[Sqrt[N[(N[(-1.0 / B$95$m), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\left(-\sqrt{2}\right) \cdot \sqrt{\frac{-1}{B\_m} \cdot F}
\end{array}
Initial program 17.1%
Taylor expanded in B around -inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f642.2
Applied rewrites2.2%
Applied rewrites2.2%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites5.6%
Taylor expanded in B around inf
Applied rewrites12.1%
Final simplification12.1%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (sqrt (/ 2.0 (/ B_m F))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return sqrt((2.0 / (B_m / F)));
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = sqrt((2.0d0 / (b_m / f)))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return Math.sqrt((2.0 / (B_m / F)));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return math.sqrt((2.0 / (B_m / F)))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return sqrt(Float64(2.0 / Float64(B_m / F))) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = sqrt((2.0 / (B_m / F)));
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[Sqrt[N[(2.0 / N[(B$95$m / F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\sqrt{\frac{2}{\frac{B\_m}{F}}}
\end{array}
Initial program 17.1%
Taylor expanded in B around -inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f642.2
Applied rewrites2.2%
Applied rewrites2.2%
Applied rewrites2.2%
Applied rewrites2.3%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (sqrt (* (/ 2.0 B_m) F)))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return sqrt(((2.0 / B_m) * F));
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = sqrt(((2.0d0 / b_m) * f))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return Math.sqrt(((2.0 / B_m) * F));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return math.sqrt(((2.0 / B_m) * F))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return sqrt(Float64(Float64(2.0 / B_m) * F)) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = sqrt(((2.0 / B_m) * F));
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[Sqrt[N[(N[(2.0 / B$95$m), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\sqrt{\frac{2}{B\_m} \cdot F}
\end{array}
Initial program 17.1%
Taylor expanded in B around -inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f642.2
Applied rewrites2.2%
Applied rewrites2.2%
Applied rewrites2.2%
Applied rewrites2.2%
Final simplification2.2%
herbie shell --seed 2024249
(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))))