
(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 18 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 (fma (* C A) -4.0 (* B_m B_m)))
(t_1 (* t_0 2.0))
(t_2 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_3
(/
(sqrt
(*
(* 2.0 (* t_2 F))
(+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))))
(- t_2)))
(t_4 (fma -4.0 (* C A) (* B_m B_m)))
(t_5 (sqrt (+ (+ (hypot B_m (- A C)) A) C))))
(if (<= t_3 -5e-196)
(* (/ t_5 -1.0) (/ (* (sqrt t_1) (sqrt F)) t_4))
(if (<= t_3 1e+228)
(/ (sqrt (* (* t_1 F) (+ (fma (/ (* B_m B_m) A) -0.5 C) C))) (- t_0))
(if (<= t_3 INFINITY)
(* (/ (sqrt (* (* 2.0 F) t_4)) -1.0) (/ t_5 t_4))
(*
(- (sqrt (+ (+ C A) (hypot (- A C) B_m))))
(/ (sqrt (* F 2.0)) B_m)))))))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((C * A), -4.0, (B_m * B_m));
double t_1 = t_0 * 2.0;
double t_2 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_3 = sqrt(((2.0 * (t_2 * F)) * ((A + C) + sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / -t_2;
double t_4 = fma(-4.0, (C * A), (B_m * B_m));
double t_5 = sqrt(((hypot(B_m, (A - C)) + A) + C));
double tmp;
if (t_3 <= -5e-196) {
tmp = (t_5 / -1.0) * ((sqrt(t_1) * sqrt(F)) / t_4);
} else if (t_3 <= 1e+228) {
tmp = sqrt(((t_1 * F) * (fma(((B_m * B_m) / A), -0.5, C) + C))) / -t_0;
} else if (t_3 <= ((double) INFINITY)) {
tmp = (sqrt(((2.0 * F) * t_4)) / -1.0) * (t_5 / t_4);
} else {
tmp = -sqrt(((C + A) + hypot((A - C), B_m))) * (sqrt((F * 2.0)) / B_m);
}
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(C * A), -4.0, Float64(B_m * B_m)) t_1 = Float64(t_0 * 2.0) t_2 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_3 = Float64(sqrt(Float64(Float64(2.0 * Float64(t_2 * F)) * Float64(Float64(A + C) + sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0)))))) / Float64(-t_2)) t_4 = fma(-4.0, Float64(C * A), Float64(B_m * B_m)) t_5 = sqrt(Float64(Float64(hypot(B_m, Float64(A - C)) + A) + C)) tmp = 0.0 if (t_3 <= -5e-196) tmp = Float64(Float64(t_5 / -1.0) * Float64(Float64(sqrt(t_1) * sqrt(F)) / t_4)); elseif (t_3 <= 1e+228) tmp = Float64(sqrt(Float64(Float64(t_1 * F) * Float64(fma(Float64(Float64(B_m * B_m) / A), -0.5, C) + C))) / Float64(-t_0)); elseif (t_3 <= Inf) tmp = Float64(Float64(sqrt(Float64(Float64(2.0 * F) * t_4)) / -1.0) * Float64(t_5 / t_4)); else tmp = Float64(Float64(-sqrt(Float64(Float64(C + A) + hypot(Float64(A - C), B_m)))) * Float64(sqrt(Float64(F * 2.0)) / B_m)); 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[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(N[(2.0 * N[(t$95$2 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$2)), $MachinePrecision]}, Block[{t$95$4 = N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(N[(N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision] + A), $MachinePrecision] + C), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$3, -5e-196], N[(N[(t$95$5 / -1.0), $MachinePrecision] * N[(N[(N[Sqrt[t$95$1], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision] / t$95$4), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 1e+228], N[(N[Sqrt[N[(N[(t$95$1 * F), $MachinePrecision] * N[(N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision] * -0.5 + C), $MachinePrecision] + C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(N[(N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * t$95$4), $MachinePrecision]], $MachinePrecision] / -1.0), $MachinePrecision] * N[(t$95$5 / t$95$4), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(N[(C + A), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * N[(N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision] / B$95$m), $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(C \cdot A, -4, B\_m \cdot B\_m\right)\\
t_1 := t\_0 \cdot 2\\
t_2 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := \frac{\sqrt{\left(2 \cdot \left(t\_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right)}}{-t\_2}\\
t_4 := \mathsf{fma}\left(-4, C \cdot A, B\_m \cdot B\_m\right)\\
t_5 := \sqrt{\left(\mathsf{hypot}\left(B\_m, A - C\right) + A\right) + C}\\
\mathbf{if}\;t\_3 \leq -5 \cdot 10^{-196}:\\
\;\;\;\;\frac{t\_5}{-1} \cdot \frac{\sqrt{t\_1} \cdot \sqrt{F}}{t\_4}\\
\mathbf{elif}\;t\_3 \leq 10^{+228}:\\
\;\;\;\;\frac{\sqrt{\left(t\_1 \cdot F\right) \cdot \left(\mathsf{fma}\left(\frac{B\_m \cdot B\_m}{A}, -0.5, C\right) + C\right)}}{-t\_0}\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot F\right) \cdot t\_4}}{-1} \cdot \frac{t\_5}{t\_4}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{\left(C + A\right) + \mathsf{hypot}\left(A - C, B\_m\right)}\right) \cdot \frac{\sqrt{F \cdot 2}}{B\_m}\\
\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))) < -5.0000000000000005e-196Initial program 34.8%
Applied rewrites60.2%
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
sqrt-prodN/A
lift-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lift-*.f64N/A
pow2N/A
lift-pow.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
sqrt-prodN/A
lift-*.f64N/A
Applied rewrites77.1%
if -5.0000000000000005e-196 < (/.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))) < 9.9999999999999992e227Initial program 25.4%
Applied rewrites26.8%
Taylor expanded in A around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6426.1
Applied rewrites26.1%
Applied rewrites33.5%
if 9.9999999999999992e227 < (/.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.7%
Applied rewrites68.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%
Applied rewrites0.1%
Taylor expanded in A around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6420.0
Applied rewrites20.0%
Applied rewrites20.6%
Final simplification45.9%
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 (/ (* B_m B_m) A) -0.5 C) C))
(t_1 (fma (* C A) -4.0 (* B_m B_m)))
(t_2 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_3
(/
(sqrt
(*
(* 2.0 (* t_2 F))
(+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))))
(- t_2)))
(t_4 (fma -4.0 (* C A) (* B_m B_m)))
(t_5 (- t_4))
(t_6 (* t_1 2.0))
(t_7 (* (* 2.0 F) t_4)))
(if (<= t_3 (- INFINITY))
(* (sqrt t_0) (/ (* (sqrt t_6) (sqrt F)) t_5))
(if (<= t_3 -5e-196)
(/ (sqrt (* (+ (+ (hypot B_m (- A C)) A) C) t_7)) t_5)
(if (<= t_3 1e-57)
(/ (sqrt (* (* t_6 F) t_0)) (- t_1))
(if (<= t_3 INFINITY)
(* (/ (sqrt (* 2.0 C)) -1.0) (/ (sqrt t_7) t_4))
(*
(- (sqrt (+ (+ C A) (hypot (- A C) B_m))))
(/ (sqrt (* F 2.0)) B_m))))))))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(((B_m * B_m) / A), -0.5, C) + C;
double t_1 = fma((C * A), -4.0, (B_m * B_m));
double t_2 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_3 = sqrt(((2.0 * (t_2 * F)) * ((A + C) + sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / -t_2;
double t_4 = fma(-4.0, (C * A), (B_m * B_m));
double t_5 = -t_4;
double t_6 = t_1 * 2.0;
double t_7 = (2.0 * F) * t_4;
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = sqrt(t_0) * ((sqrt(t_6) * sqrt(F)) / t_5);
} else if (t_3 <= -5e-196) {
tmp = sqrt((((hypot(B_m, (A - C)) + A) + C) * t_7)) / t_5;
} else if (t_3 <= 1e-57) {
tmp = sqrt(((t_6 * F) * t_0)) / -t_1;
} else if (t_3 <= ((double) INFINITY)) {
tmp = (sqrt((2.0 * C)) / -1.0) * (sqrt(t_7) / t_4);
} else {
tmp = -sqrt(((C + A) + hypot((A - C), B_m))) * (sqrt((F * 2.0)) / B_m);
}
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(fma(Float64(Float64(B_m * B_m) / A), -0.5, C) + C) t_1 = fma(Float64(C * A), -4.0, Float64(B_m * B_m)) t_2 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_3 = Float64(sqrt(Float64(Float64(2.0 * Float64(t_2 * F)) * Float64(Float64(A + C) + sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0)))))) / Float64(-t_2)) t_4 = fma(-4.0, Float64(C * A), Float64(B_m * B_m)) t_5 = Float64(-t_4) t_6 = Float64(t_1 * 2.0) t_7 = Float64(Float64(2.0 * F) * t_4) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(sqrt(t_0) * Float64(Float64(sqrt(t_6) * sqrt(F)) / t_5)); elseif (t_3 <= -5e-196) tmp = Float64(sqrt(Float64(Float64(Float64(hypot(B_m, Float64(A - C)) + A) + C) * t_7)) / t_5); elseif (t_3 <= 1e-57) tmp = Float64(sqrt(Float64(Float64(t_6 * F) * t_0)) / Float64(-t_1)); elseif (t_3 <= Inf) tmp = Float64(Float64(sqrt(Float64(2.0 * C)) / -1.0) * Float64(sqrt(t_7) / t_4)); else tmp = Float64(Float64(-sqrt(Float64(Float64(C + A) + hypot(Float64(A - C), B_m)))) * Float64(sqrt(Float64(F * 2.0)) / B_m)); 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[(N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision] * -0.5 + C), $MachinePrecision] + C), $MachinePrecision]}, Block[{t$95$1 = N[(N[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(N[(2.0 * N[(t$95$2 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$2)), $MachinePrecision]}, Block[{t$95$4 = N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = (-t$95$4)}, Block[{t$95$6 = N[(t$95$1 * 2.0), $MachinePrecision]}, Block[{t$95$7 = N[(N[(2.0 * F), $MachinePrecision] * t$95$4), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(N[Sqrt[t$95$0], $MachinePrecision] * N[(N[(N[Sqrt[t$95$6], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision] / t$95$5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -5e-196], N[(N[Sqrt[N[(N[(N[(N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision] + A), $MachinePrecision] + C), $MachinePrecision] * t$95$7), $MachinePrecision]], $MachinePrecision] / t$95$5), $MachinePrecision], If[LessEqual[t$95$3, 1e-57], N[(N[Sqrt[N[(N[(t$95$6 * F), $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision] / (-t$95$1)), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(N[(N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision] / -1.0), $MachinePrecision] * N[(N[Sqrt[t$95$7], $MachinePrecision] / t$95$4), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(N[(C + A), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * N[(N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision] / B$95$m), $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(\frac{B\_m \cdot B\_m}{A}, -0.5, C\right) + C\\
t_1 := \mathsf{fma}\left(C \cdot A, -4, B\_m \cdot B\_m\right)\\
t_2 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := \frac{\sqrt{\left(2 \cdot \left(t\_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right)}}{-t\_2}\\
t_4 := \mathsf{fma}\left(-4, C \cdot A, B\_m \cdot B\_m\right)\\
t_5 := -t\_4\\
t_6 := t\_1 \cdot 2\\
t_7 := \left(2 \cdot F\right) \cdot t\_4\\
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;\sqrt{t\_0} \cdot \frac{\sqrt{t\_6} \cdot \sqrt{F}}{t\_5}\\
\mathbf{elif}\;t\_3 \leq -5 \cdot 10^{-196}:\\
\;\;\;\;\frac{\sqrt{\left(\left(\mathsf{hypot}\left(B\_m, A - C\right) + A\right) + C\right) \cdot t\_7}}{t\_5}\\
\mathbf{elif}\;t\_3 \leq 10^{-57}:\\
\;\;\;\;\frac{\sqrt{\left(t\_6 \cdot F\right) \cdot t\_0}}{-t\_1}\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;\frac{\sqrt{2 \cdot C}}{-1} \cdot \frac{\sqrt{t\_7}}{t\_4}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{\left(C + A\right) + \mathsf{hypot}\left(A - C, B\_m\right)}\right) \cdot \frac{\sqrt{F \cdot 2}}{B\_m}\\
\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.0%
Applied rewrites40.9%
Taylor expanded in A around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6423.7
Applied rewrites23.7%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
sqrt-prodN/A
Applied rewrites35.0%
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
/-rgt-identityN/A
lower-neg.f6435.0
Applied rewrites35.0%
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))) < -5.0000000000000005e-196Initial program 99.5%
Applied rewrites99.5%
if -5.0000000000000005e-196 < (/.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))) < 9.99999999999999955e-58Initial program 15.5%
Applied rewrites17.1%
Taylor expanded in A around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6424.6
Applied rewrites24.6%
Applied rewrites32.9%
if 9.99999999999999955e-58 < (/.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 27.7%
Applied rewrites75.8%
Taylor expanded in A around -inf
lower-*.f6413.2
Applied rewrites13.2%
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%
Applied rewrites0.1%
Taylor expanded in A around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6420.0
Applied rewrites20.0%
Applied rewrites20.6%
Final simplification34.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
(let* ((t_0 (fma (* C A) -4.0 (* B_m B_m)))
(t_1 (* t_0 2.0))
(t_2 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_3
(/
(sqrt
(*
(* 2.0 (* t_2 F))
(+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))))
(- t_2)))
(t_4 (fma -4.0 (* C A) (* B_m B_m)))
(t_5 (+ (fma (/ (* B_m B_m) A) -0.5 C) C)))
(if (<= t_3 -2e+216)
(* (sqrt t_5) (/ (* (sqrt t_1) (sqrt F)) (- t_4)))
(if (<= t_3 -5e-196)
(* (/ (sqrt 2.0) (- B_m)) (sqrt (* (+ (hypot B_m C) C) F)))
(if (<= t_3 1e-57)
(/ (sqrt (* (* t_1 F) t_5)) (- t_0))
(if (<= t_3 INFINITY)
(* (/ (sqrt (* 2.0 C)) -1.0) (/ (sqrt (* (* 2.0 F) t_4)) t_4))
(/ (sqrt (* F 2.0)) (- (sqrt B_m)))))))))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((C * A), -4.0, (B_m * B_m));
double t_1 = t_0 * 2.0;
double t_2 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_3 = sqrt(((2.0 * (t_2 * F)) * ((A + C) + sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / -t_2;
double t_4 = fma(-4.0, (C * A), (B_m * B_m));
double t_5 = fma(((B_m * B_m) / A), -0.5, C) + C;
double tmp;
if (t_3 <= -2e+216) {
tmp = sqrt(t_5) * ((sqrt(t_1) * sqrt(F)) / -t_4);
} else if (t_3 <= -5e-196) {
tmp = (sqrt(2.0) / -B_m) * sqrt(((hypot(B_m, C) + C) * F));
} else if (t_3 <= 1e-57) {
tmp = sqrt(((t_1 * F) * t_5)) / -t_0;
} else if (t_3 <= ((double) INFINITY)) {
tmp = (sqrt((2.0 * C)) / -1.0) * (sqrt(((2.0 * F) * t_4)) / t_4);
} else {
tmp = sqrt((F * 2.0)) / -sqrt(B_m);
}
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(C * A), -4.0, Float64(B_m * B_m)) t_1 = Float64(t_0 * 2.0) t_2 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_3 = Float64(sqrt(Float64(Float64(2.0 * Float64(t_2 * F)) * Float64(Float64(A + C) + sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0)))))) / Float64(-t_2)) t_4 = fma(-4.0, Float64(C * A), Float64(B_m * B_m)) t_5 = Float64(fma(Float64(Float64(B_m * B_m) / A), -0.5, C) + C) tmp = 0.0 if (t_3 <= -2e+216) tmp = Float64(sqrt(t_5) * Float64(Float64(sqrt(t_1) * sqrt(F)) / Float64(-t_4))); elseif (t_3 <= -5e-196) tmp = Float64(Float64(sqrt(2.0) / Float64(-B_m)) * sqrt(Float64(Float64(hypot(B_m, C) + C) * F))); elseif (t_3 <= 1e-57) tmp = Float64(sqrt(Float64(Float64(t_1 * F) * t_5)) / Float64(-t_0)); elseif (t_3 <= Inf) tmp = Float64(Float64(sqrt(Float64(2.0 * C)) / -1.0) * Float64(sqrt(Float64(Float64(2.0 * F) * t_4)) / t_4)); else tmp = Float64(sqrt(Float64(F * 2.0)) / Float64(-sqrt(B_m))); 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[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(N[(2.0 * N[(t$95$2 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$2)), $MachinePrecision]}, Block[{t$95$4 = N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision] * -0.5 + C), $MachinePrecision] + C), $MachinePrecision]}, If[LessEqual[t$95$3, -2e+216], N[(N[Sqrt[t$95$5], $MachinePrecision] * N[(N[(N[Sqrt[t$95$1], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision] / (-t$95$4)), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -5e-196], N[(N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $MachinePrecision] * N[Sqrt[N[(N[(N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision] + C), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 1e-57], N[(N[Sqrt[N[(N[(t$95$1 * F), $MachinePrecision] * t$95$5), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(N[(N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision] / -1.0), $MachinePrecision] * N[(N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * t$95$4), $MachinePrecision]], $MachinePrecision] / t$95$4), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision] / (-N[Sqrt[B$95$m], $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(C \cdot A, -4, B\_m \cdot B\_m\right)\\
t_1 := t\_0 \cdot 2\\
t_2 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := \frac{\sqrt{\left(2 \cdot \left(t\_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right)}}{-t\_2}\\
t_4 := \mathsf{fma}\left(-4, C \cdot A, B\_m \cdot B\_m\right)\\
t_5 := \mathsf{fma}\left(\frac{B\_m \cdot B\_m}{A}, -0.5, C\right) + C\\
\mathbf{if}\;t\_3 \leq -2 \cdot 10^{+216}:\\
\;\;\;\;\sqrt{t\_5} \cdot \frac{\sqrt{t\_1} \cdot \sqrt{F}}{-t\_4}\\
\mathbf{elif}\;t\_3 \leq -5 \cdot 10^{-196}:\\
\;\;\;\;\frac{\sqrt{2}}{-B\_m} \cdot \sqrt{\left(\mathsf{hypot}\left(B\_m, C\right) + C\right) \cdot F}\\
\mathbf{elif}\;t\_3 \leq 10^{-57}:\\
\;\;\;\;\frac{\sqrt{\left(t\_1 \cdot F\right) \cdot t\_5}}{-t\_0}\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;\frac{\sqrt{2 \cdot C}}{-1} \cdot \frac{\sqrt{\left(2 \cdot F\right) \cdot t\_4}}{t\_4}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{F \cdot 2}}{-\sqrt{B\_m}}\\
\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))) < -2e216Initial program 6.1%
Applied rewrites42.8%
Taylor expanded in A around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6426.1
Applied rewrites26.1%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
sqrt-prodN/A
Applied rewrites37.1%
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
/-rgt-identityN/A
lower-neg.f6437.1
Applied rewrites37.1%
if -2e216 < (/.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))) < -5.0000000000000005e-196Initial program 99.5%
Taylor expanded in A around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6435.2
Applied rewrites35.2%
if -5.0000000000000005e-196 < (/.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))) < 9.99999999999999955e-58Initial program 15.5%
Applied rewrites17.1%
Taylor expanded in A around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6424.6
Applied rewrites24.6%
Applied rewrites32.9%
if 9.99999999999999955e-58 < (/.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 27.7%
Applied rewrites75.8%
Taylor expanded in A around -inf
lower-*.f6413.2
Applied rewrites13.2%
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
lower-neg.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6412.8
Applied rewrites12.8%
Applied rewrites14.9%
Final simplification25.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
(let* ((t_0 (fma (* C A) -4.0 (* B_m B_m)))
(t_1 (* t_0 2.0))
(t_2 (sqrt (* F 2.0)))
(t_3 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_4
(/
(sqrt
(*
(* 2.0 (* t_3 F))
(+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))))
(- t_3)))
(t_5 (fma -4.0 (* C A) (* B_m B_m)))
(t_6 (+ (fma (/ (* B_m B_m) A) -0.5 C) C)))
(if (<= t_4 -2e+216)
(* (sqrt t_6) (/ (* (sqrt t_1) (sqrt F)) (- t_5)))
(if (<= t_4 -5e-196)
(* (sqrt (* B_m (+ (+ (/ A B_m) 1.0) (/ C B_m)))) (- (/ t_2 B_m)))
(if (<= t_4 1e-57)
(/ (sqrt (* (* t_1 F) t_6)) (- t_0))
(if (<= t_4 INFINITY)
(* (/ (sqrt (* 2.0 C)) -1.0) (/ (sqrt (* (* 2.0 F) t_5)) t_5))
(/ t_2 (- (sqrt B_m)))))))))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((C * A), -4.0, (B_m * B_m));
double t_1 = t_0 * 2.0;
double t_2 = sqrt((F * 2.0));
double t_3 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_4 = sqrt(((2.0 * (t_3 * F)) * ((A + C) + sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / -t_3;
double t_5 = fma(-4.0, (C * A), (B_m * B_m));
double t_6 = fma(((B_m * B_m) / A), -0.5, C) + C;
double tmp;
if (t_4 <= -2e+216) {
tmp = sqrt(t_6) * ((sqrt(t_1) * sqrt(F)) / -t_5);
} else if (t_4 <= -5e-196) {
tmp = sqrt((B_m * (((A / B_m) + 1.0) + (C / B_m)))) * -(t_2 / B_m);
} else if (t_4 <= 1e-57) {
tmp = sqrt(((t_1 * F) * t_6)) / -t_0;
} else if (t_4 <= ((double) INFINITY)) {
tmp = (sqrt((2.0 * C)) / -1.0) * (sqrt(((2.0 * F) * t_5)) / t_5);
} else {
tmp = t_2 / -sqrt(B_m);
}
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(C * A), -4.0, Float64(B_m * B_m)) t_1 = Float64(t_0 * 2.0) t_2 = sqrt(Float64(F * 2.0)) t_3 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_4 = Float64(sqrt(Float64(Float64(2.0 * Float64(t_3 * F)) * Float64(Float64(A + C) + sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0)))))) / Float64(-t_3)) t_5 = fma(-4.0, Float64(C * A), Float64(B_m * B_m)) t_6 = Float64(fma(Float64(Float64(B_m * B_m) / A), -0.5, C) + C) tmp = 0.0 if (t_4 <= -2e+216) tmp = Float64(sqrt(t_6) * Float64(Float64(sqrt(t_1) * sqrt(F)) / Float64(-t_5))); elseif (t_4 <= -5e-196) tmp = Float64(sqrt(Float64(B_m * Float64(Float64(Float64(A / B_m) + 1.0) + Float64(C / B_m)))) * Float64(-Float64(t_2 / B_m))); elseif (t_4 <= 1e-57) tmp = Float64(sqrt(Float64(Float64(t_1 * F) * t_6)) / Float64(-t_0)); elseif (t_4 <= Inf) tmp = Float64(Float64(sqrt(Float64(2.0 * C)) / -1.0) * Float64(sqrt(Float64(Float64(2.0 * F) * t_5)) / t_5)); else tmp = Float64(t_2 / Float64(-sqrt(B_m))); 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[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * 2.0), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sqrt[N[(N[(2.0 * N[(t$95$3 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$3)), $MachinePrecision]}, Block[{t$95$5 = N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision] * -0.5 + C), $MachinePrecision] + C), $MachinePrecision]}, If[LessEqual[t$95$4, -2e+216], N[(N[Sqrt[t$95$6], $MachinePrecision] * N[(N[(N[Sqrt[t$95$1], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision] / (-t$95$5)), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, -5e-196], N[(N[Sqrt[N[(B$95$m * N[(N[(N[(A / B$95$m), $MachinePrecision] + 1.0), $MachinePrecision] + N[(C / B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[(t$95$2 / B$95$m), $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$4, 1e-57], N[(N[Sqrt[N[(N[(t$95$1 * F), $MachinePrecision] * t$95$6), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(N[(N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision] / -1.0), $MachinePrecision] * N[(N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * t$95$5), $MachinePrecision]], $MachinePrecision] / t$95$5), $MachinePrecision]), $MachinePrecision], N[(t$95$2 / (-N[Sqrt[B$95$m], $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(C \cdot A, -4, B\_m \cdot B\_m\right)\\
t_1 := t\_0 \cdot 2\\
t_2 := \sqrt{F \cdot 2}\\
t_3 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_4 := \frac{\sqrt{\left(2 \cdot \left(t\_3 \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right)}}{-t\_3}\\
t_5 := \mathsf{fma}\left(-4, C \cdot A, B\_m \cdot B\_m\right)\\
t_6 := \mathsf{fma}\left(\frac{B\_m \cdot B\_m}{A}, -0.5, C\right) + C\\
\mathbf{if}\;t\_4 \leq -2 \cdot 10^{+216}:\\
\;\;\;\;\sqrt{t\_6} \cdot \frac{\sqrt{t\_1} \cdot \sqrt{F}}{-t\_5}\\
\mathbf{elif}\;t\_4 \leq -5 \cdot 10^{-196}:\\
\;\;\;\;\sqrt{B\_m \cdot \left(\left(\frac{A}{B\_m} + 1\right) + \frac{C}{B\_m}\right)} \cdot \left(-\frac{t\_2}{B\_m}\right)\\
\mathbf{elif}\;t\_4 \leq 10^{-57}:\\
\;\;\;\;\frac{\sqrt{\left(t\_1 \cdot F\right) \cdot t\_6}}{-t\_0}\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;\frac{\sqrt{2 \cdot C}}{-1} \cdot \frac{\sqrt{\left(2 \cdot F\right) \cdot t\_5}}{t\_5}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_2}{-\sqrt{B\_m}}\\
\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))) < -2e216Initial program 6.1%
Applied rewrites42.8%
Taylor expanded in A around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6426.1
Applied rewrites26.1%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
sqrt-prodN/A
Applied rewrites37.1%
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
/-rgt-identityN/A
lower-neg.f6437.1
Applied rewrites37.1%
if -2e216 < (/.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))) < -5.0000000000000005e-196Initial program 99.5%
Applied rewrites99.7%
Taylor expanded in A around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6439.2
Applied rewrites39.2%
Applied rewrites39.3%
Taylor expanded in B around inf
lower-*.f64N/A
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f6434.6
Applied rewrites34.6%
if -5.0000000000000005e-196 < (/.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))) < 9.99999999999999955e-58Initial program 15.5%
Applied rewrites17.1%
Taylor expanded in A around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6424.6
Applied rewrites24.6%
Applied rewrites32.9%
if 9.99999999999999955e-58 < (/.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 27.7%
Applied rewrites75.8%
Taylor expanded in A around -inf
lower-*.f6413.2
Applied rewrites13.2%
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
lower-neg.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6412.8
Applied rewrites12.8%
Applied rewrites14.9%
Final simplification25.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
(let* ((t_0 (fma -4.0 (* C A) (* B_m B_m)))
(t_1 (sqrt (* F 2.0)))
(t_2 (fma (* C A) -4.0 (* B_m B_m)))
(t_3 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_4
(/
(sqrt
(*
(* 2.0 (* t_3 F))
(+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))))
(- t_3)))
(t_5 (sqrt (+ (+ (hypot B_m (- A C)) A) C))))
(if (<= t_4 -5e-196)
(* (/ t_5 -1.0) (* t_1 (/ (sqrt t_2) t_2)))
(if (<= t_4 1e+228)
(/
(sqrt (* (* (* t_2 2.0) F) (+ (fma (/ (* B_m B_m) A) -0.5 C) C)))
(- t_2))
(if (<= t_4 INFINITY)
(* (/ (sqrt (* (* 2.0 F) t_0)) -1.0) (/ t_5 t_0))
(* (- (sqrt (+ (+ C A) (hypot (- A C) B_m)))) (/ t_1 B_m)))))))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, (C * A), (B_m * B_m));
double t_1 = sqrt((F * 2.0));
double t_2 = fma((C * A), -4.0, (B_m * B_m));
double t_3 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_4 = sqrt(((2.0 * (t_3 * F)) * ((A + C) + sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / -t_3;
double t_5 = sqrt(((hypot(B_m, (A - C)) + A) + C));
double tmp;
if (t_4 <= -5e-196) {
tmp = (t_5 / -1.0) * (t_1 * (sqrt(t_2) / t_2));
} else if (t_4 <= 1e+228) {
tmp = sqrt((((t_2 * 2.0) * F) * (fma(((B_m * B_m) / A), -0.5, C) + C))) / -t_2;
} else if (t_4 <= ((double) INFINITY)) {
tmp = (sqrt(((2.0 * F) * t_0)) / -1.0) * (t_5 / t_0);
} else {
tmp = -sqrt(((C + A) + hypot((A - C), B_m))) * (t_1 / B_m);
}
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(-4.0, Float64(C * A), Float64(B_m * B_m)) t_1 = sqrt(Float64(F * 2.0)) t_2 = fma(Float64(C * A), -4.0, Float64(B_m * B_m)) t_3 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_4 = Float64(sqrt(Float64(Float64(2.0 * Float64(t_3 * F)) * Float64(Float64(A + C) + sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0)))))) / Float64(-t_3)) t_5 = sqrt(Float64(Float64(hypot(B_m, Float64(A - C)) + A) + C)) tmp = 0.0 if (t_4 <= -5e-196) tmp = Float64(Float64(t_5 / -1.0) * Float64(t_1 * Float64(sqrt(t_2) / t_2))); elseif (t_4 <= 1e+228) tmp = Float64(sqrt(Float64(Float64(Float64(t_2 * 2.0) * F) * Float64(fma(Float64(Float64(B_m * B_m) / A), -0.5, C) + C))) / Float64(-t_2)); elseif (t_4 <= Inf) tmp = Float64(Float64(sqrt(Float64(Float64(2.0 * F) * t_0)) / -1.0) * Float64(t_5 / t_0)); else tmp = Float64(Float64(-sqrt(Float64(Float64(C + A) + hypot(Float64(A - C), B_m)))) * Float64(t_1 / B_m)); 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[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sqrt[N[(N[(2.0 * N[(t$95$3 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$3)), $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(N[(N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision] + A), $MachinePrecision] + C), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$4, -5e-196], N[(N[(t$95$5 / -1.0), $MachinePrecision] * N[(t$95$1 * N[(N[Sqrt[t$95$2], $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 1e+228], N[(N[Sqrt[N[(N[(N[(t$95$2 * 2.0), $MachinePrecision] * F), $MachinePrecision] * N[(N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision] * -0.5 + C), $MachinePrecision] + C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$2)), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(N[(N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision] / -1.0), $MachinePrecision] * N[(t$95$5 / t$95$0), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(N[(C + A), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * N[(t$95$1 / B$95$m), $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, C \cdot A, B\_m \cdot B\_m\right)\\
t_1 := \sqrt{F \cdot 2}\\
t_2 := \mathsf{fma}\left(C \cdot A, -4, B\_m \cdot B\_m\right)\\
t_3 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_4 := \frac{\sqrt{\left(2 \cdot \left(t\_3 \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right)}}{-t\_3}\\
t_5 := \sqrt{\left(\mathsf{hypot}\left(B\_m, A - C\right) + A\right) + C}\\
\mathbf{if}\;t\_4 \leq -5 \cdot 10^{-196}:\\
\;\;\;\;\frac{t\_5}{-1} \cdot \left(t\_1 \cdot \frac{\sqrt{t\_2}}{t\_2}\right)\\
\mathbf{elif}\;t\_4 \leq 10^{+228}:\\
\;\;\;\;\frac{\sqrt{\left(\left(t\_2 \cdot 2\right) \cdot F\right) \cdot \left(\mathsf{fma}\left(\frac{B\_m \cdot B\_m}{A}, -0.5, C\right) + C\right)}}{-t\_2}\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot F\right) \cdot t\_0}}{-1} \cdot \frac{t\_5}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{\left(C + A\right) + \mathsf{hypot}\left(A - C, B\_m\right)}\right) \cdot \frac{t\_1}{B\_m}\\
\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))) < -5.0000000000000005e-196Initial program 34.8%
Applied rewrites60.2%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lift-*.f64N/A
pow2N/A
lift-pow.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
Applied rewrites77.0%
if -5.0000000000000005e-196 < (/.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))) < 9.9999999999999992e227Initial program 25.4%
Applied rewrites26.8%
Taylor expanded in A around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6426.1
Applied rewrites26.1%
Applied rewrites33.5%
if 9.9999999999999992e227 < (/.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.7%
Applied rewrites68.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%
Applied rewrites0.1%
Taylor expanded in A around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6420.0
Applied rewrites20.0%
Applied rewrites20.6%
Final simplification45.9%
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 (* C A) (* B_m B_m)))
(t_1 (fma (* C A) -4.0 (* B_m B_m))))
(if (<= (pow B_m 2.0) 1e-171)
(/
(sqrt (* (* (* t_1 2.0) F) (+ (fma (/ (* B_m B_m) A) -0.5 C) C)))
(- t_1))
(if (<= (pow B_m 2.0) 4e+119)
(*
(/ (sqrt (+ (+ (hypot B_m (- A C)) A) C)) -1.0)
(/ (sqrt (* (* 2.0 F) t_0)) t_0))
(*
(- (sqrt (+ (+ C A) (hypot (- A C) B_m))))
(/ (sqrt (* F 2.0)) B_m))))))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, (C * A), (B_m * B_m));
double t_1 = fma((C * A), -4.0, (B_m * B_m));
double tmp;
if (pow(B_m, 2.0) <= 1e-171) {
tmp = sqrt((((t_1 * 2.0) * F) * (fma(((B_m * B_m) / A), -0.5, C) + C))) / -t_1;
} else if (pow(B_m, 2.0) <= 4e+119) {
tmp = (sqrt(((hypot(B_m, (A - C)) + A) + C)) / -1.0) * (sqrt(((2.0 * F) * t_0)) / t_0);
} else {
tmp = -sqrt(((C + A) + hypot((A - C), B_m))) * (sqrt((F * 2.0)) / B_m);
}
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(-4.0, Float64(C * A), Float64(B_m * B_m)) t_1 = fma(Float64(C * A), -4.0, Float64(B_m * B_m)) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-171) tmp = Float64(sqrt(Float64(Float64(Float64(t_1 * 2.0) * F) * Float64(fma(Float64(Float64(B_m * B_m) / A), -0.5, C) + C))) / Float64(-t_1)); elseif ((B_m ^ 2.0) <= 4e+119) tmp = Float64(Float64(sqrt(Float64(Float64(hypot(B_m, Float64(A - C)) + A) + C)) / -1.0) * Float64(sqrt(Float64(Float64(2.0 * F) * t_0)) / t_0)); else tmp = Float64(Float64(-sqrt(Float64(Float64(C + A) + hypot(Float64(A - C), B_m)))) * Float64(sqrt(Float64(F * 2.0)) / B_m)); 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[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-171], N[(N[Sqrt[N[(N[(N[(t$95$1 * 2.0), $MachinePrecision] * F), $MachinePrecision] * N[(N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision] * -0.5 + C), $MachinePrecision] + C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$1)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e+119], N[(N[(N[Sqrt[N[(N[(N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision] + A), $MachinePrecision] + C), $MachinePrecision]], $MachinePrecision] / -1.0), $MachinePrecision] * N[(N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(N[(C + A), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * N[(N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision] / B$95$m), $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, C \cdot A, B\_m \cdot B\_m\right)\\
t_1 := \mathsf{fma}\left(C \cdot A, -4, B\_m \cdot B\_m\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-171}:\\
\;\;\;\;\frac{\sqrt{\left(\left(t\_1 \cdot 2\right) \cdot F\right) \cdot \left(\mathsf{fma}\left(\frac{B\_m \cdot B\_m}{A}, -0.5, C\right) + C\right)}}{-t\_1}\\
\mathbf{elif}\;{B\_m}^{2} \leq 4 \cdot 10^{+119}:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{hypot}\left(B\_m, A - C\right) + A\right) + C}}{-1} \cdot \frac{\sqrt{\left(2 \cdot F\right) \cdot t\_0}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{\left(C + A\right) + \mathsf{hypot}\left(A - C, B\_m\right)}\right) \cdot \frac{\sqrt{F \cdot 2}}{B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 9.9999999999999998e-172Initial program 16.6%
Applied rewrites24.7%
Taylor expanded in A around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6419.9
Applied rewrites19.9%
Applied rewrites22.8%
if 9.9999999999999998e-172 < (pow.f64 B #s(literal 2 binary64)) < 3.99999999999999978e119Initial program 36.5%
Applied rewrites61.9%
if 3.99999999999999978e119 < (pow.f64 B #s(literal 2 binary64)) Initial program 8.6%
Applied rewrites21.6%
Taylor expanded in A around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6428.6
Applied rewrites28.6%
Applied rewrites28.9%
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 (* C A) (* B_m B_m)))
(t_1 (fma (* C A) -4.0 (* B_m B_m))))
(if (<= (pow B_m 2.0) 1e-171)
(/
(sqrt (* (* (* t_1 2.0) F) (+ (fma (/ (* B_m B_m) A) -0.5 C) C)))
(- t_1))
(if (<= (pow B_m 2.0) 4e+119)
(*
(/ (sqrt (* (* 2.0 F) t_0)) -1.0)
(/ (sqrt (+ (+ (hypot B_m (- A C)) A) C)) t_0))
(*
(- (sqrt (+ (+ C A) (hypot (- A C) B_m))))
(/ (sqrt (* F 2.0)) B_m))))))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, (C * A), (B_m * B_m));
double t_1 = fma((C * A), -4.0, (B_m * B_m));
double tmp;
if (pow(B_m, 2.0) <= 1e-171) {
tmp = sqrt((((t_1 * 2.0) * F) * (fma(((B_m * B_m) / A), -0.5, C) + C))) / -t_1;
} else if (pow(B_m, 2.0) <= 4e+119) {
tmp = (sqrt(((2.0 * F) * t_0)) / -1.0) * (sqrt(((hypot(B_m, (A - C)) + A) + C)) / t_0);
} else {
tmp = -sqrt(((C + A) + hypot((A - C), B_m))) * (sqrt((F * 2.0)) / B_m);
}
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(-4.0, Float64(C * A), Float64(B_m * B_m)) t_1 = fma(Float64(C * A), -4.0, Float64(B_m * B_m)) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-171) tmp = Float64(sqrt(Float64(Float64(Float64(t_1 * 2.0) * F) * Float64(fma(Float64(Float64(B_m * B_m) / A), -0.5, C) + C))) / Float64(-t_1)); elseif ((B_m ^ 2.0) <= 4e+119) tmp = Float64(Float64(sqrt(Float64(Float64(2.0 * F) * t_0)) / -1.0) * Float64(sqrt(Float64(Float64(hypot(B_m, Float64(A - C)) + A) + C)) / t_0)); else tmp = Float64(Float64(-sqrt(Float64(Float64(C + A) + hypot(Float64(A - C), B_m)))) * Float64(sqrt(Float64(F * 2.0)) / B_m)); 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[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-171], N[(N[Sqrt[N[(N[(N[(t$95$1 * 2.0), $MachinePrecision] * F), $MachinePrecision] * N[(N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision] * -0.5 + C), $MachinePrecision] + C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$1)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e+119], N[(N[(N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision] / -1.0), $MachinePrecision] * N[(N[Sqrt[N[(N[(N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision] + A), $MachinePrecision] + C), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(N[(C + A), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * N[(N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision] / B$95$m), $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, C \cdot A, B\_m \cdot B\_m\right)\\
t_1 := \mathsf{fma}\left(C \cdot A, -4, B\_m \cdot B\_m\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-171}:\\
\;\;\;\;\frac{\sqrt{\left(\left(t\_1 \cdot 2\right) \cdot F\right) \cdot \left(\mathsf{fma}\left(\frac{B\_m \cdot B\_m}{A}, -0.5, C\right) + C\right)}}{-t\_1}\\
\mathbf{elif}\;{B\_m}^{2} \leq 4 \cdot 10^{+119}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot F\right) \cdot t\_0}}{-1} \cdot \frac{\sqrt{\left(\mathsf{hypot}\left(B\_m, A - C\right) + A\right) + C}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{\left(C + A\right) + \mathsf{hypot}\left(A - C, B\_m\right)}\right) \cdot \frac{\sqrt{F \cdot 2}}{B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 9.9999999999999998e-172Initial program 16.6%
Applied rewrites24.7%
Taylor expanded in A around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6419.9
Applied rewrites19.9%
Applied rewrites22.8%
if 9.9999999999999998e-172 < (pow.f64 B #s(literal 2 binary64)) < 3.99999999999999978e119Initial program 36.5%
Applied rewrites61.9%
if 3.99999999999999978e119 < (pow.f64 B #s(literal 2 binary64)) Initial program 8.6%
Applied rewrites21.6%
Taylor expanded in A around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6428.6
Applied rewrites28.6%
Applied rewrites28.9%
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 (hypot (- A C) B_m))
(t_1 (fma (* C A) -4.0 (* B_m B_m)))
(t_2 (- t_1))
(t_3 (* (* t_1 2.0) F)))
(if (<= (pow B_m 2.0) 1e-171)
(/ (sqrt (* t_3 (+ (fma (/ (* B_m B_m) A) -0.5 C) C))) t_2)
(if (<= (pow B_m 2.0) 1e+64)
(/ (* (sqrt (+ (+ t_0 C) A)) (sqrt t_3)) t_2)
(* (- (sqrt (+ (+ C A) t_0))) (/ (sqrt (* F 2.0)) B_m))))))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 = hypot((A - C), B_m);
double t_1 = fma((C * A), -4.0, (B_m * B_m));
double t_2 = -t_1;
double t_3 = (t_1 * 2.0) * F;
double tmp;
if (pow(B_m, 2.0) <= 1e-171) {
tmp = sqrt((t_3 * (fma(((B_m * B_m) / A), -0.5, C) + C))) / t_2;
} else if (pow(B_m, 2.0) <= 1e+64) {
tmp = (sqrt(((t_0 + C) + A)) * sqrt(t_3)) / t_2;
} else {
tmp = -sqrt(((C + A) + t_0)) * (sqrt((F * 2.0)) / B_m);
}
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 = hypot(Float64(A - C), B_m) t_1 = fma(Float64(C * A), -4.0, Float64(B_m * B_m)) t_2 = Float64(-t_1) t_3 = Float64(Float64(t_1 * 2.0) * F) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-171) tmp = Float64(sqrt(Float64(t_3 * Float64(fma(Float64(Float64(B_m * B_m) / A), -0.5, C) + C))) / t_2); elseif ((B_m ^ 2.0) <= 1e+64) tmp = Float64(Float64(sqrt(Float64(Float64(t_0 + C) + A)) * sqrt(t_3)) / t_2); else tmp = Float64(Float64(-sqrt(Float64(Float64(C + A) + t_0))) * Float64(sqrt(Float64(F * 2.0)) / B_m)); 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[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]}, Block[{t$95$1 = N[(N[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = (-t$95$1)}, Block[{t$95$3 = N[(N[(t$95$1 * 2.0), $MachinePrecision] * F), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-171], N[(N[Sqrt[N[(t$95$3 * N[(N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision] * -0.5 + C), $MachinePrecision] + C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+64], N[(N[(N[Sqrt[N[(N[(t$95$0 + C), $MachinePrecision] + A), $MachinePrecision]], $MachinePrecision] * N[Sqrt[t$95$3], $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], N[((-N[Sqrt[N[(N[(C + A), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]) * N[(N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision] / B$95$m), $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{hypot}\left(A - C, B\_m\right)\\
t_1 := \mathsf{fma}\left(C \cdot A, -4, B\_m \cdot B\_m\right)\\
t_2 := -t\_1\\
t_3 := \left(t\_1 \cdot 2\right) \cdot F\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-171}:\\
\;\;\;\;\frac{\sqrt{t\_3 \cdot \left(\mathsf{fma}\left(\frac{B\_m \cdot B\_m}{A}, -0.5, C\right) + C\right)}}{t\_2}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{+64}:\\
\;\;\;\;\frac{\sqrt{\left(t\_0 + C\right) + A} \cdot \sqrt{t\_3}}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{\left(C + A\right) + t\_0}\right) \cdot \frac{\sqrt{F \cdot 2}}{B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 9.9999999999999998e-172Initial program 16.6%
Applied rewrites24.7%
Taylor expanded in A around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6419.9
Applied rewrites19.9%
Applied rewrites22.8%
if 9.9999999999999998e-172 < (pow.f64 B #s(literal 2 binary64)) < 1.00000000000000002e64Initial program 36.9%
Applied rewrites67.9%
Applied rewrites67.5%
if 1.00000000000000002e64 < (pow.f64 B #s(literal 2 binary64)) Initial program 10.6%
Applied rewrites22.6%
Taylor expanded in A around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6427.4
Applied rewrites27.4%
Applied rewrites27.7%
Final simplification32.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
(let* ((t_0 (+ (+ C A) (hypot (- A C) B_m)))
(t_1 (fma (* C A) -4.0 (* B_m B_m))))
(if (<= (pow B_m 2.0) 1e-171)
(/
(sqrt (* (* (* t_1 2.0) F) (+ (fma (/ (* B_m B_m) A) -0.5 C) C)))
(- t_1))
(if (<= (pow B_m 2.0) 2e+78)
(/
(* (- (sqrt (* t_1 F))) (sqrt (* 2.0 t_0)))
(fma -4.0 (* C A) (* B_m B_m)))
(* (- (sqrt t_0)) (/ (sqrt (* F 2.0)) B_m))))))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) + hypot((A - C), B_m);
double t_1 = fma((C * A), -4.0, (B_m * B_m));
double tmp;
if (pow(B_m, 2.0) <= 1e-171) {
tmp = sqrt((((t_1 * 2.0) * F) * (fma(((B_m * B_m) / A), -0.5, C) + C))) / -t_1;
} else if (pow(B_m, 2.0) <= 2e+78) {
tmp = (-sqrt((t_1 * F)) * sqrt((2.0 * t_0))) / fma(-4.0, (C * A), (B_m * B_m));
} else {
tmp = -sqrt(t_0) * (sqrt((F * 2.0)) / B_m);
}
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(Float64(C + A) + hypot(Float64(A - C), B_m)) t_1 = fma(Float64(C * A), -4.0, Float64(B_m * B_m)) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-171) tmp = Float64(sqrt(Float64(Float64(Float64(t_1 * 2.0) * F) * Float64(fma(Float64(Float64(B_m * B_m) / A), -0.5, C) + C))) / Float64(-t_1)); elseif ((B_m ^ 2.0) <= 2e+78) tmp = Float64(Float64(Float64(-sqrt(Float64(t_1 * F))) * sqrt(Float64(2.0 * t_0))) / fma(-4.0, Float64(C * A), Float64(B_m * B_m))); else tmp = Float64(Float64(-sqrt(t_0)) * Float64(sqrt(Float64(F * 2.0)) / B_m)); 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[(C + A), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-171], N[(N[Sqrt[N[(N[(N[(t$95$1 * 2.0), $MachinePrecision] * F), $MachinePrecision] * N[(N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision] * -0.5 + C), $MachinePrecision] + C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$1)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+78], N[(N[((-N[Sqrt[N[(t$95$1 * F), $MachinePrecision]], $MachinePrecision]) * N[Sqrt[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[t$95$0], $MachinePrecision]) * N[(N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision] / B$95$m), $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 := \left(C + A\right) + \mathsf{hypot}\left(A - C, B\_m\right)\\
t_1 := \mathsf{fma}\left(C \cdot A, -4, B\_m \cdot B\_m\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-171}:\\
\;\;\;\;\frac{\sqrt{\left(\left(t\_1 \cdot 2\right) \cdot F\right) \cdot \left(\mathsf{fma}\left(\frac{B\_m \cdot B\_m}{A}, -0.5, C\right) + C\right)}}{-t\_1}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+78}:\\
\;\;\;\;\frac{\left(-\sqrt{t\_1 \cdot F}\right) \cdot \sqrt{2 \cdot t\_0}}{\mathsf{fma}\left(-4, C \cdot A, B\_m \cdot B\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{t\_0}\right) \cdot \frac{\sqrt{F \cdot 2}}{B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 9.9999999999999998e-172Initial program 16.6%
Applied rewrites24.7%
Taylor expanded in A around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6419.9
Applied rewrites19.9%
Applied rewrites22.8%
if 9.9999999999999998e-172 < (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000002e78Initial program 38.9%
Applied rewrites50.1%
Applied rewrites67.0%
if 2.00000000000000002e78 < (pow.f64 B #s(literal 2 binary64)) Initial program 9.1%
Applied rewrites21.4%
Taylor expanded in A around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6427.3
Applied rewrites27.3%
Applied rewrites27.5%
Final simplification32.6%
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 (* C A) (* B_m B_m)))
(t_1 (fma (* C A) -4.0 (* B_m B_m))))
(if (<= (pow B_m 2.0) 1e-169)
(/
(sqrt (* (* (* t_1 2.0) F) (+ (fma (/ (* B_m B_m) A) -0.5 C) C)))
(- t_1))
(if (<= (pow B_m 2.0) 2e-22)
(* (/ (sqrt (* 2.0 C)) -1.0) (/ (sqrt (* (* 2.0 F) t_0)) t_0))
(*
(- (sqrt (+ (+ C A) (hypot (- A C) B_m))))
(/ (sqrt (* F 2.0)) B_m))))))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, (C * A), (B_m * B_m));
double t_1 = fma((C * A), -4.0, (B_m * B_m));
double tmp;
if (pow(B_m, 2.0) <= 1e-169) {
tmp = sqrt((((t_1 * 2.0) * F) * (fma(((B_m * B_m) / A), -0.5, C) + C))) / -t_1;
} else if (pow(B_m, 2.0) <= 2e-22) {
tmp = (sqrt((2.0 * C)) / -1.0) * (sqrt(((2.0 * F) * t_0)) / t_0);
} else {
tmp = -sqrt(((C + A) + hypot((A - C), B_m))) * (sqrt((F * 2.0)) / B_m);
}
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(-4.0, Float64(C * A), Float64(B_m * B_m)) t_1 = fma(Float64(C * A), -4.0, Float64(B_m * B_m)) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-169) tmp = Float64(sqrt(Float64(Float64(Float64(t_1 * 2.0) * F) * Float64(fma(Float64(Float64(B_m * B_m) / A), -0.5, C) + C))) / Float64(-t_1)); elseif ((B_m ^ 2.0) <= 2e-22) tmp = Float64(Float64(sqrt(Float64(2.0 * C)) / -1.0) * Float64(sqrt(Float64(Float64(2.0 * F) * t_0)) / t_0)); else tmp = Float64(Float64(-sqrt(Float64(Float64(C + A) + hypot(Float64(A - C), B_m)))) * Float64(sqrt(Float64(F * 2.0)) / B_m)); 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[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-169], N[(N[Sqrt[N[(N[(N[(t$95$1 * 2.0), $MachinePrecision] * F), $MachinePrecision] * N[(N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision] * -0.5 + C), $MachinePrecision] + C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$1)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-22], N[(N[(N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision] / -1.0), $MachinePrecision] * N[(N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(N[(C + A), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * N[(N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision] / B$95$m), $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, C \cdot A, B\_m \cdot B\_m\right)\\
t_1 := \mathsf{fma}\left(C \cdot A, -4, B\_m \cdot B\_m\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-169}:\\
\;\;\;\;\frac{\sqrt{\left(\left(t\_1 \cdot 2\right) \cdot F\right) \cdot \left(\mathsf{fma}\left(\frac{B\_m \cdot B\_m}{A}, -0.5, C\right) + C\right)}}{-t\_1}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{-22}:\\
\;\;\;\;\frac{\sqrt{2 \cdot C}}{-1} \cdot \frac{\sqrt{\left(2 \cdot F\right) \cdot t\_0}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{\left(C + A\right) + \mathsf{hypot}\left(A - C, B\_m\right)}\right) \cdot \frac{\sqrt{F \cdot 2}}{B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 1.00000000000000002e-169Initial program 17.4%
Applied rewrites25.5%
Taylor expanded in A around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6419.7
Applied rewrites19.7%
Applied rewrites22.5%
if 1.00000000000000002e-169 < (pow.f64 B #s(literal 2 binary64)) < 2.0000000000000001e-22Initial program 25.7%
Applied rewrites61.4%
Taylor expanded in A around -inf
lower-*.f6422.1
Applied rewrites22.1%
if 2.0000000000000001e-22 < (pow.f64 B #s(literal 2 binary64)) Initial program 15.5%
Applied rewrites29.1%
Taylor expanded in A around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6428.0
Applied rewrites28.0%
Applied rewrites28.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
(let* ((t_0 (fma -4.0 (* C A) (* B_m B_m)))
(t_1 (fma (* C A) -4.0 (* B_m B_m))))
(if (<= (pow B_m 2.0) 1e-169)
(/
(sqrt (* (* (* t_1 2.0) F) (+ (fma (/ (* B_m B_m) A) -0.5 C) C)))
(- t_1))
(if (<= (pow B_m 2.0) 2e-7)
(* (/ (sqrt (* 2.0 C)) -1.0) (/ (sqrt (* (* 2.0 F) t_0)) t_0))
(/ (- (sqrt F)) (sqrt (* B_m 0.5)))))))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, (C * A), (B_m * B_m));
double t_1 = fma((C * A), -4.0, (B_m * B_m));
double tmp;
if (pow(B_m, 2.0) <= 1e-169) {
tmp = sqrt((((t_1 * 2.0) * F) * (fma(((B_m * B_m) / A), -0.5, C) + C))) / -t_1;
} else if (pow(B_m, 2.0) <= 2e-7) {
tmp = (sqrt((2.0 * C)) / -1.0) * (sqrt(((2.0 * F) * t_0)) / t_0);
} else {
tmp = -sqrt(F) / sqrt((B_m * 0.5));
}
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(-4.0, Float64(C * A), Float64(B_m * B_m)) t_1 = fma(Float64(C * A), -4.0, Float64(B_m * B_m)) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-169) tmp = Float64(sqrt(Float64(Float64(Float64(t_1 * 2.0) * F) * Float64(fma(Float64(Float64(B_m * B_m) / A), -0.5, C) + C))) / Float64(-t_1)); elseif ((B_m ^ 2.0) <= 2e-7) tmp = Float64(Float64(sqrt(Float64(2.0 * C)) / -1.0) * Float64(sqrt(Float64(Float64(2.0 * F) * t_0)) / t_0)); else tmp = Float64(Float64(-sqrt(F)) / sqrt(Float64(B_m * 0.5))); 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[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-169], N[(N[Sqrt[N[(N[(N[(t$95$1 * 2.0), $MachinePrecision] * F), $MachinePrecision] * N[(N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision] * -0.5 + C), $MachinePrecision] + C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$1)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-7], N[(N[(N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision] / -1.0), $MachinePrecision] * N[(N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[F], $MachinePrecision]) / N[Sqrt[N[(B$95$m * 0.5), $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, C \cdot A, B\_m \cdot B\_m\right)\\
t_1 := \mathsf{fma}\left(C \cdot A, -4, B\_m \cdot B\_m\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-169}:\\
\;\;\;\;\frac{\sqrt{\left(\left(t\_1 \cdot 2\right) \cdot F\right) \cdot \left(\mathsf{fma}\left(\frac{B\_m \cdot B\_m}{A}, -0.5, C\right) + C\right)}}{-t\_1}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{\sqrt{2 \cdot C}}{-1} \cdot \frac{\sqrt{\left(2 \cdot F\right) \cdot t\_0}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{F}}{\sqrt{B\_m \cdot 0.5}}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 1.00000000000000002e-169Initial program 17.4%
Applied rewrites25.5%
Taylor expanded in A around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6419.7
Applied rewrites19.7%
Applied rewrites22.5%
if 1.00000000000000002e-169 < (pow.f64 B #s(literal 2 binary64)) < 1.9999999999999999e-7Initial program 27.2%
Applied rewrites59.8%
Taylor expanded in A around -inf
lower-*.f6421.5
Applied rewrites21.5%
if 1.9999999999999999e-7 < (pow.f64 B #s(literal 2 binary64)) Initial program 14.7%
Taylor expanded in B around inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6416.7
Applied rewrites16.7%
Applied rewrites16.7%
Applied rewrites16.7%
Applied rewrites18.7%
Final simplification20.5%
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 (* C A) (* B_m B_m))) (t_1 (* (* 2.0 F) t_0)))
(if (<= (pow B_m 2.0) 1e-171)
(/ (sqrt (* (* 2.0 C) t_1)) (- t_0))
(if (<= (pow B_m 2.0) 2e-7)
(* (/ (sqrt (* 2.0 C)) -1.0) (/ (sqrt t_1) t_0))
(/ (- (sqrt F)) (sqrt (* B_m 0.5)))))))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, (C * A), (B_m * B_m));
double t_1 = (2.0 * F) * t_0;
double tmp;
if (pow(B_m, 2.0) <= 1e-171) {
tmp = sqrt(((2.0 * C) * t_1)) / -t_0;
} else if (pow(B_m, 2.0) <= 2e-7) {
tmp = (sqrt((2.0 * C)) / -1.0) * (sqrt(t_1) / t_0);
} else {
tmp = -sqrt(F) / sqrt((B_m * 0.5));
}
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(-4.0, Float64(C * A), Float64(B_m * B_m)) t_1 = Float64(Float64(2.0 * F) * t_0) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-171) tmp = Float64(sqrt(Float64(Float64(2.0 * C) * t_1)) / Float64(-t_0)); elseif ((B_m ^ 2.0) <= 2e-7) tmp = Float64(Float64(sqrt(Float64(2.0 * C)) / -1.0) * Float64(sqrt(t_1) / t_0)); else tmp = Float64(Float64(-sqrt(F)) / sqrt(Float64(B_m * 0.5))); 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[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-171], N[(N[Sqrt[N[(N[(2.0 * C), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-7], N[(N[(N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision] / -1.0), $MachinePrecision] * N[(N[Sqrt[t$95$1], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[F], $MachinePrecision]) / N[Sqrt[N[(B$95$m * 0.5), $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, C \cdot A, B\_m \cdot B\_m\right)\\
t_1 := \left(2 \cdot F\right) \cdot t\_0\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-171}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot C\right) \cdot t\_1}}{-t\_0}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{\sqrt{2 \cdot C}}{-1} \cdot \frac{\sqrt{t\_1}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{F}}{\sqrt{B\_m \cdot 0.5}}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 9.9999999999999998e-172Initial program 16.6%
Applied rewrites22.5%
Taylor expanded in A around -inf
lower-*.f6422.8
Applied rewrites22.8%
if 9.9999999999999998e-172 < (pow.f64 B #s(literal 2 binary64)) < 1.9999999999999999e-7Initial program 29.5%
Applied rewrites61.0%
Taylor expanded in A around -inf
lower-*.f6420.9
Applied rewrites20.9%
if 1.9999999999999999e-7 < (pow.f64 B #s(literal 2 binary64)) Initial program 14.7%
Taylor expanded in B around inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6416.7
Applied rewrites16.7%
Applied rewrites16.7%
Applied rewrites16.7%
Applied rewrites18.7%
Final simplification20.6%
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 (* C A) (* B_m B_m))))
(if (<= (pow B_m 2.0) 2e-7)
(/ (sqrt (* (* 2.0 C) (* (* 2.0 F) t_0))) (- t_0))
(/ (- (sqrt F)) (sqrt (* B_m 0.5))))))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, (C * A), (B_m * B_m));
double tmp;
if (pow(B_m, 2.0) <= 2e-7) {
tmp = sqrt(((2.0 * C) * ((2.0 * F) * t_0))) / -t_0;
} else {
tmp = -sqrt(F) / sqrt((B_m * 0.5));
}
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(-4.0, Float64(C * A), Float64(B_m * B_m)) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-7) tmp = Float64(sqrt(Float64(Float64(2.0 * C) * Float64(Float64(2.0 * F) * t_0))) / Float64(-t_0)); else tmp = Float64(Float64(-sqrt(F)) / sqrt(Float64(B_m * 0.5))); 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[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-7], N[(N[Sqrt[N[(N[(2.0 * C), $MachinePrecision] * N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], N[((-N[Sqrt[F], $MachinePrecision]) / N[Sqrt[N[(B$95$m * 0.5), $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, C \cdot A, B\_m \cdot B\_m\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot C\right) \cdot \left(\left(2 \cdot F\right) \cdot t\_0\right)}}{-t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{F}}{\sqrt{B\_m \cdot 0.5}}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 1.9999999999999999e-7Initial program 19.7%
Applied rewrites26.6%
Taylor expanded in A around -inf
lower-*.f6419.7
Applied rewrites19.7%
if 1.9999999999999999e-7 < (pow.f64 B #s(literal 2 binary64)) Initial program 14.7%
Taylor expanded in B around inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6416.7
Applied rewrites16.7%
Applied rewrites16.7%
Applied rewrites16.7%
Applied rewrites18.7%
Final simplification19.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 (if (<= B_m 1.1e-11) (/ (sqrt (* -16.0 (* A (* (* C C) F)))) (- (fma -4.0 (* C A) (* B_m B_m)))) (/ (sqrt (* F 2.0)) (- (sqrt B_m)))))
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 tmp;
if (B_m <= 1.1e-11) {
tmp = sqrt((-16.0 * (A * ((C * C) * F)))) / -fma(-4.0, (C * A), (B_m * B_m));
} else {
tmp = sqrt((F * 2.0)) / -sqrt(B_m);
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (B_m <= 1.1e-11) tmp = Float64(sqrt(Float64(-16.0 * Float64(A * Float64(Float64(C * C) * F)))) / Float64(-fma(-4.0, Float64(C * A), Float64(B_m * B_m)))); else tmp = Float64(sqrt(Float64(F * 2.0)) / Float64(-sqrt(B_m))); 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_] := If[LessEqual[B$95$m, 1.1e-11], N[(N[Sqrt[N[(-16.0 * N[(A * N[(N[(C * C), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision] / (-N[Sqrt[B$95$m], $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}
\mathbf{if}\;B\_m \leq 1.1 \cdot 10^{-11}:\\
\;\;\;\;\frac{\sqrt{-16 \cdot \left(A \cdot \left(\left(C \cdot C\right) \cdot F\right)\right)}}{-\mathsf{fma}\left(-4, C \cdot A, B\_m \cdot B\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{F \cdot 2}}{-\sqrt{B\_m}}\\
\end{array}
\end{array}
if B < 1.1000000000000001e-11Initial program 17.9%
Applied rewrites23.7%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f649.7
Applied rewrites9.7%
if 1.1000000000000001e-11 < B Initial program 14.7%
Taylor expanded in B around inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6441.8
Applied rewrites41.8%
Applied rewrites48.5%
Final simplification17.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 (if (<= C 3.4e+135) (/ (- (sqrt F)) (sqrt (* B_m 0.5))) (* (- (sqrt (* 2.0 C))) (/ (sqrt (* F 2.0)) B_m))))
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 tmp;
if (C <= 3.4e+135) {
tmp = -sqrt(F) / sqrt((B_m * 0.5));
} else {
tmp = -sqrt((2.0 * C)) * (sqrt((F * 2.0)) / B_m);
}
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) :: tmp
if (c <= 3.4d+135) then
tmp = -sqrt(f) / sqrt((b_m * 0.5d0))
else
tmp = -sqrt((2.0d0 * c)) * (sqrt((f * 2.0d0)) / b_m)
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 tmp;
if (C <= 3.4e+135) {
tmp = -Math.sqrt(F) / Math.sqrt((B_m * 0.5));
} else {
tmp = -Math.sqrt((2.0 * C)) * (Math.sqrt((F * 2.0)) / B_m);
}
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): tmp = 0 if C <= 3.4e+135: tmp = -math.sqrt(F) / math.sqrt((B_m * 0.5)) else: tmp = -math.sqrt((2.0 * C)) * (math.sqrt((F * 2.0)) / B_m) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (C <= 3.4e+135) tmp = Float64(Float64(-sqrt(F)) / sqrt(Float64(B_m * 0.5))); else tmp = Float64(Float64(-sqrt(Float64(2.0 * C))) * Float64(sqrt(Float64(F * 2.0)) / B_m)); 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)
tmp = 0.0;
if (C <= 3.4e+135)
tmp = -sqrt(F) / sqrt((B_m * 0.5));
else
tmp = -sqrt((2.0 * C)) * (sqrt((F * 2.0)) / B_m);
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_] := If[LessEqual[C, 3.4e+135], N[((-N[Sqrt[F], $MachinePrecision]) / N[Sqrt[N[(B$95$m * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision]) * N[(N[Sqrt[N[(F * 2.0), $MachinePrecision]], $MachinePrecision] / B$95$m), $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}
\mathbf{if}\;C \leq 3.4 \cdot 10^{+135}:\\
\;\;\;\;\frac{-\sqrt{F}}{\sqrt{B\_m \cdot 0.5}}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{2 \cdot C}\right) \cdot \frac{\sqrt{F \cdot 2}}{B\_m}\\
\end{array}
\end{array}
if C < 3.4000000000000001e135Initial program 19.0%
Taylor expanded in B around inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6412.1
Applied rewrites12.1%
Applied rewrites12.2%
Applied rewrites12.2%
Applied rewrites13.3%
if 3.4000000000000001e135 < C Initial program 7.2%
Applied rewrites35.6%
Taylor expanded in A around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6422.8
Applied rewrites22.8%
Applied rewrites22.8%
Taylor expanded in A around -inf
lower-*.f6420.5
Applied rewrites20.5%
Final simplification14.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 F)) (sqrt (* B_m 0.5))))
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(F) / sqrt((B_m * 0.5));
}
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(f) / sqrt((b_m * 0.5d0))
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(F) / Math.sqrt((B_m * 0.5));
}
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(F) / math.sqrt((B_m * 0.5))
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(F)) / sqrt(Float64(B_m * 0.5))) 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(F) / sqrt((B_m * 0.5));
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[F], $MachinePrecision]) / N[Sqrt[N[(B$95$m * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{-\sqrt{F}}{\sqrt{B\_m \cdot 0.5}}
\end{array}
Initial program 17.3%
Taylor expanded in B around inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6411.1
Applied rewrites11.1%
Applied rewrites11.1%
Applied rewrites11.1%
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 F)) (sqrt (/ 2.0 B_m))))
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(F) * sqrt((2.0 / B_m));
}
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(f) * sqrt((2.0d0 / b_m))
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(F) * Math.sqrt((2.0 / B_m));
}
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(F) * math.sqrt((2.0 / B_m))
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(F)) * sqrt(Float64(2.0 / B_m))) 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(F) * sqrt((2.0 / B_m));
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[F], $MachinePrecision]) * N[Sqrt[N[(2.0 / B$95$m), $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{F}\right) \cdot \sqrt{\frac{2}{B\_m}}
\end{array}
Initial program 17.3%
Taylor expanded in B around inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6411.1
Applied rewrites11.1%
Applied rewrites11.1%
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 (* F (/ 2.0 B_m)))))
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((F * (2.0 / B_m)));
}
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((f * (2.0d0 / b_m)))
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((F * (2.0 / B_m)));
}
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((F * (2.0 / B_m)))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(-sqrt(Float64(F * Float64(2.0 / B_m)))) 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((F * (2.0 / B_m)));
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[(F * N[(2.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
-\sqrt{F \cdot \frac{2}{B\_m}}
\end{array}
Initial program 17.3%
Taylor expanded in B around inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6411.1
Applied rewrites11.1%
Applied rewrites11.1%
Applied rewrites11.1%
herbie shell --seed 2024322
(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))))