
(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 13 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 -4.0 (* C A) (* B_m B_m)) 2.0))
(t_1 (- (+ C A) (hypot (- A C) B_m)))
(t_2 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_3 (* 2.0 (* t_2 F)))
(t_4 (- t_2))
(t_5
(/
(sqrt (* t_3 (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))))
t_4)))
(if (<= t_5 -1e-207)
(/ (* (- (sqrt t_0)) (sqrt (* F t_1))) t_2)
(if (<= t_5 4e-53)
(/ (sqrt (* t_3 (+ (fma (/ (* B_m B_m) C) -0.5 A) A))) t_4)
(if (<= t_5 INFINITY)
(/ (* (sqrt (* t_1 t_0)) (- (sqrt F))) t_2)
(/ (sqrt (* (* (- A (hypot A B_m)) 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)) * 2.0;
double t_1 = (C + A) - hypot((A - C), B_m);
double t_2 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_3 = 2.0 * (t_2 * F);
double t_4 = -t_2;
double t_5 = sqrt((t_3 * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / t_4;
double tmp;
if (t_5 <= -1e-207) {
tmp = (-sqrt(t_0) * sqrt((F * t_1))) / t_2;
} else if (t_5 <= 4e-53) {
tmp = sqrt((t_3 * (fma(((B_m * B_m) / C), -0.5, A) + A))) / t_4;
} else if (t_5 <= ((double) INFINITY)) {
tmp = (sqrt((t_1 * t_0)) * -sqrt(F)) / t_2;
} else {
tmp = sqrt((((A - hypot(A, B_m)) * 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(-4.0, Float64(C * A), Float64(B_m * B_m)) * 2.0) t_1 = Float64(Float64(C + A) - hypot(Float64(A - C), B_m)) t_2 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_3 = Float64(2.0 * Float64(t_2 * F)) t_4 = Float64(-t_2) t_5 = Float64(sqrt(Float64(t_3 * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0)))))) / t_4) tmp = 0.0 if (t_5 <= -1e-207) tmp = Float64(Float64(Float64(-sqrt(t_0)) * sqrt(Float64(F * t_1))) / t_2); elseif (t_5 <= 4e-53) tmp = Float64(sqrt(Float64(t_3 * Float64(fma(Float64(Float64(B_m * B_m) / C), -0.5, A) + A))) / t_4); elseif (t_5 <= Inf) tmp = Float64(Float64(sqrt(Float64(t_1 * t_0)) * Float64(-sqrt(F))) / t_2); else tmp = Float64(sqrt(Float64(Float64(Float64(A - hypot(A, B_m)) * F) * 2.0)) / Float64(-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[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(C + A), $MachinePrecision] - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $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[(2.0 * N[(t$95$2 * F), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = (-t$95$2)}, Block[{t$95$5 = N[(N[Sqrt[N[(t$95$3 * 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$4), $MachinePrecision]}, If[LessEqual[t$95$5, -1e-207], N[(N[((-N[Sqrt[t$95$0], $MachinePrecision]) * N[Sqrt[N[(F * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[t$95$5, 4e-53], N[(N[Sqrt[N[(t$95$3 * N[(N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] / C), $MachinePrecision] * -0.5 + A), $MachinePrecision] + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4), $MachinePrecision], If[LessEqual[t$95$5, Infinity], N[(N[(N[Sqrt[N[(t$95$1 * t$95$0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[F], $MachinePrecision])), $MachinePrecision] / t$95$2), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(A - N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $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) \cdot 2\\
t_1 := \left(C + A\right) - \mathsf{hypot}\left(A - C, B\_m\right)\\
t_2 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := 2 \cdot \left(t\_2 \cdot F\right)\\
t_4 := -t\_2\\
t_5 := \frac{\sqrt{t\_3 \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right)}}{t\_4}\\
\mathbf{if}\;t\_5 \leq -1 \cdot 10^{-207}:\\
\;\;\;\;\frac{\left(-\sqrt{t\_0}\right) \cdot \sqrt{F \cdot t\_1}}{t\_2}\\
\mathbf{elif}\;t\_5 \leq 4 \cdot 10^{-53}:\\
\;\;\;\;\frac{\sqrt{t\_3 \cdot \left(\mathsf{fma}\left(\frac{B\_m \cdot B\_m}{C}, -0.5, A\right) + A\right)}}{t\_4}\\
\mathbf{elif}\;t\_5 \leq \infty:\\
\;\;\;\;\frac{\sqrt{t\_1 \cdot t\_0} \cdot \left(-\sqrt{F}\right)}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - \mathsf{hypot}\left(A, B\_m\right)\right) \cdot F\right) \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))) < -9.99999999999999925e-208Initial program 45.2%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
sqrt-prodN/A
pow1/2N/A
lower-*.f64N/A
Applied rewrites66.3%
if -9.99999999999999925e-208 < (/.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))) < 4.00000000000000012e-53Initial program 14.0%
Taylor expanded in C around inf
sub-negN/A
mul-1-negN/A
remove-double-negN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6428.2
Applied rewrites28.2%
if 4.00000000000000012e-53 < (/.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 25.5%
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*r*N/A
sqrt-prodN/A
pow1/2N/A
Applied rewrites54.6%
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 C 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
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6414.7
Applied rewrites14.7%
Applied rewrites14.8%
Final simplification37.8%
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 -4.0 (* C A) (* B_m B_m)))
(t_2 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_3 (- t_2))
(t_4
(/
(sqrt
(*
(* 2.0 (* t_2 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))))
t_3))
(t_5 (fma (* C A) -4.0 (* B_m B_m))))
(if (<= t_4 (- INFINITY))
(* (sqrt (* F (/ t_0 t_1))) (- (sqrt 2.0)))
(if (<= t_4 -1e-207)
(/ (sqrt (* t_0 (* (* 2.0 F) t_1))) (- t_1))
(if (<= t_4 0.0)
(/ (* (sqrt (* (* t_5 F) 2.0)) (sqrt (+ A A))) t_3)
(if (<= t_4 INFINITY)
(/ -1.0 (/ t_1 (* (sqrt (* t_0 (* t_5 2.0))) (sqrt F))))
(/ (sqrt (* (* (- A (hypot A B_m)) 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(-4.0, (C * A), (B_m * B_m));
double t_2 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_3 = -t_2;
double t_4 = sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / t_3;
double t_5 = fma((C * A), -4.0, (B_m * B_m));
double tmp;
if (t_4 <= -((double) INFINITY)) {
tmp = sqrt((F * (t_0 / t_1))) * -sqrt(2.0);
} else if (t_4 <= -1e-207) {
tmp = sqrt((t_0 * ((2.0 * F) * t_1))) / -t_1;
} else if (t_4 <= 0.0) {
tmp = (sqrt(((t_5 * F) * 2.0)) * sqrt((A + A))) / t_3;
} else if (t_4 <= ((double) INFINITY)) {
tmp = -1.0 / (t_1 / (sqrt((t_0 * (t_5 * 2.0))) * sqrt(F)));
} else {
tmp = sqrt((((A - hypot(A, B_m)) * 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(-4.0, Float64(C * A), Float64(B_m * B_m)) t_2 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_3 = Float64(-t_2) t_4 = 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)))))) / t_3) t_5 = fma(Float64(C * A), -4.0, Float64(B_m * B_m)) tmp = 0.0 if (t_4 <= Float64(-Inf)) tmp = Float64(sqrt(Float64(F * Float64(t_0 / t_1))) * Float64(-sqrt(2.0))); elseif (t_4 <= -1e-207) tmp = Float64(sqrt(Float64(t_0 * Float64(Float64(2.0 * F) * t_1))) / Float64(-t_1)); elseif (t_4 <= 0.0) tmp = Float64(Float64(sqrt(Float64(Float64(t_5 * F) * 2.0)) * sqrt(Float64(A + A))) / t_3); elseif (t_4 <= Inf) tmp = Float64(-1.0 / Float64(t_1 / Float64(sqrt(Float64(t_0 * Float64(t_5 * 2.0))) * sqrt(F)))); else tmp = Float64(sqrt(Float64(Float64(Float64(A - hypot(A, B_m)) * F) * 2.0)) / Float64(-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[(-4.0 * N[(C * A), $MachinePrecision] + 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 = (-t$95$2)}, Block[{t$95$4 = 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$3), $MachinePrecision]}, Block[{t$95$5 = N[(N[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], N[(N[Sqrt[N[(F * N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$4, -1e-207], N[(N[Sqrt[N[(t$95$0 * N[(N[(2.0 * F), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$1)), $MachinePrecision], If[LessEqual[t$95$4, 0.0], N[(N[(N[Sqrt[N[(N[(t$95$5 * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(A + A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(-1.0 / N[(t$95$1 / N[(N[Sqrt[N[(t$95$0 * N[(t$95$5 * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(A - N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $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(-4, C \cdot A, B\_m \cdot B\_m\right)\\
t_2 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := -t\_2\\
t_4 := \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\_3}\\
t_5 := \mathsf{fma}\left(C \cdot A, -4, B\_m \cdot B\_m\right)\\
\mathbf{if}\;t\_4 \leq -\infty:\\
\;\;\;\;\sqrt{F \cdot \frac{t\_0}{t\_1}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;t\_4 \leq -1 \cdot 10^{-207}:\\
\;\;\;\;\frac{\sqrt{t\_0 \cdot \left(\left(2 \cdot F\right) \cdot t\_1\right)}}{-t\_1}\\
\mathbf{elif}\;t\_4 \leq 0:\\
\;\;\;\;\frac{\sqrt{\left(t\_5 \cdot F\right) \cdot 2} \cdot \sqrt{A + A}}{t\_3}\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;\frac{-1}{\frac{t\_1}{\sqrt{t\_0 \cdot \left(t\_5 \cdot 2\right)} \cdot \sqrt{F}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - \mathsf{hypot}\left(A, B\_m\right)\right) \cdot F\right) \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 2.9%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites46.8%
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))) < -9.99999999999999925e-208Initial program 99.2%
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
remove-double-negN/A
lower-/.f64N/A
Applied rewrites99.2%
if -9.99999999999999925e-208 < (/.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))) < -0.0Initial program 3.4%
Taylor expanded in A around inf
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f6424.9
Applied rewrites24.9%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites17.5%
Taylor expanded in C around inf
lower--.f64N/A
mul-1-negN/A
lower-neg.f6410.9
Applied rewrites10.9%
if -0.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))) < +inf.0Initial program 33.7%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
neg-mul-1N/A
clear-numN/A
un-div-invN/A
Applied rewrites47.8%
Applied rewrites54.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))) Initial program 0.0%
Taylor expanded in C 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
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6414.7
Applied rewrites14.7%
Applied rewrites14.8%
Final simplification37.1%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (+ C A) (hypot (- A C) B_m)))
(t_1 (fma -4.0 (* C A) (* B_m B_m)))
(t_2 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_3 (- t_2))
(t_4
(/
(sqrt
(*
(* 2.0 (* t_2 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))))
t_3)))
(if (<= t_4 (- INFINITY))
(* (sqrt (* F (/ t_0 t_1))) (- (sqrt 2.0)))
(if (<= t_4 -1e-207)
(/ (sqrt (* t_0 (* (* 2.0 F) t_1))) (- t_1))
(if (<= t_4 0.0)
(/
(*
(sqrt (* (* (fma (* C A) -4.0 (* B_m B_m)) F) 2.0))
(sqrt (+ A A)))
t_3)
(if (<= t_4 INFINITY)
(/
(*
(sqrt
(* (- (+ C A) (- A)) (* (fma (* -4.0 C) A (* B_m B_m)) 2.0)))
(- (sqrt F)))
t_2)
(/ (sqrt (* (* (- A (hypot A B_m)) 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(-4.0, (C * A), (B_m * B_m));
double t_2 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_3 = -t_2;
double t_4 = sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / t_3;
double tmp;
if (t_4 <= -((double) INFINITY)) {
tmp = sqrt((F * (t_0 / t_1))) * -sqrt(2.0);
} else if (t_4 <= -1e-207) {
tmp = sqrt((t_0 * ((2.0 * F) * t_1))) / -t_1;
} else if (t_4 <= 0.0) {
tmp = (sqrt(((fma((C * A), -4.0, (B_m * B_m)) * F) * 2.0)) * sqrt((A + A))) / t_3;
} else if (t_4 <= ((double) INFINITY)) {
tmp = (sqrt((((C + A) - -A) * (fma((-4.0 * C), A, (B_m * B_m)) * 2.0))) * -sqrt(F)) / t_2;
} else {
tmp = sqrt((((A - hypot(A, B_m)) * 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(-4.0, Float64(C * A), Float64(B_m * B_m)) t_2 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_3 = Float64(-t_2) t_4 = 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)))))) / t_3) tmp = 0.0 if (t_4 <= Float64(-Inf)) tmp = Float64(sqrt(Float64(F * Float64(t_0 / t_1))) * Float64(-sqrt(2.0))); elseif (t_4 <= -1e-207) tmp = Float64(sqrt(Float64(t_0 * Float64(Float64(2.0 * F) * t_1))) / Float64(-t_1)); elseif (t_4 <= 0.0) tmp = Float64(Float64(sqrt(Float64(Float64(fma(Float64(C * A), -4.0, Float64(B_m * B_m)) * F) * 2.0)) * sqrt(Float64(A + A))) / t_3); elseif (t_4 <= Inf) tmp = Float64(Float64(sqrt(Float64(Float64(Float64(C + A) - Float64(-A)) * Float64(fma(Float64(-4.0 * C), A, Float64(B_m * B_m)) * 2.0))) * Float64(-sqrt(F))) / t_2); else tmp = Float64(sqrt(Float64(Float64(Float64(A - hypot(A, B_m)) * F) * 2.0)) / Float64(-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[(-4.0 * N[(C * A), $MachinePrecision] + 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 = (-t$95$2)}, Block[{t$95$4 = 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$3), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], N[(N[Sqrt[N[(F * N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$4, -1e-207], N[(N[Sqrt[N[(t$95$0 * N[(N[(2.0 * F), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$1)), $MachinePrecision], If[LessEqual[t$95$4, 0.0], N[(N[(N[Sqrt[N[(N[(N[(N[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(A + A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(N[(N[Sqrt[N[(N[(N[(C + A), $MachinePrecision] - (-A)), $MachinePrecision] * N[(N[(N[(-4.0 * C), $MachinePrecision] * A + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[F], $MachinePrecision])), $MachinePrecision] / t$95$2), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(A - N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $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(-4, C \cdot A, B\_m \cdot B\_m\right)\\
t_2 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := -t\_2\\
t_4 := \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\_3}\\
\mathbf{if}\;t\_4 \leq -\infty:\\
\;\;\;\;\sqrt{F \cdot \frac{t\_0}{t\_1}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;t\_4 \leq -1 \cdot 10^{-207}:\\
\;\;\;\;\frac{\sqrt{t\_0 \cdot \left(\left(2 \cdot F\right) \cdot t\_1\right)}}{-t\_1}\\
\mathbf{elif}\;t\_4 \leq 0:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(C \cdot A, -4, B\_m \cdot B\_m\right) \cdot F\right) \cdot 2} \cdot \sqrt{A + A}}{t\_3}\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\left(\left(C + A\right) - \left(-A\right)\right) \cdot \left(\mathsf{fma}\left(-4 \cdot C, A, B\_m \cdot B\_m\right) \cdot 2\right)} \cdot \left(-\sqrt{F}\right)}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - \mathsf{hypot}\left(A, B\_m\right)\right) \cdot F\right) \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 2.9%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites46.8%
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))) < -9.99999999999999925e-208Initial program 99.2%
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
remove-double-negN/A
lower-/.f64N/A
Applied rewrites99.2%
if -9.99999999999999925e-208 < (/.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))) < -0.0Initial program 3.4%
Taylor expanded in A around inf
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f6424.9
Applied rewrites24.9%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites17.5%
Taylor expanded in C around inf
lower--.f64N/A
mul-1-negN/A
lower-neg.f6410.9
Applied rewrites10.9%
if -0.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))) < +inf.0Initial program 33.7%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f6422.5
Applied rewrites22.5%
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*r*N/A
sqrt-prodN/A
Applied rewrites26.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 C 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
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6414.7
Applied rewrites14.7%
Applied rewrites14.8%
Final simplification33.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 (- (+ C A) (hypot (- A C) B_m)))
(t_1 (fma -4.0 (* C A) (* B_m B_m)))
(t_2 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_3 (* 2.0 (* t_2 F)))
(t_4 (- t_2))
(t_5
(/
(sqrt (* t_3 (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))))
t_4)))
(if (<= t_5 (- INFINITY))
(* (sqrt (* F (/ t_0 t_1))) (- (sqrt 2.0)))
(if (<= t_5 -1e-207)
(/ (sqrt (* t_0 (* (* 2.0 F) t_1))) (- t_1))
(if (<= t_5 INFINITY)
(/ (sqrt (* t_3 (+ A A))) t_4)
(/ (sqrt (* (* (- A (hypot A B_m)) 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(-4.0, (C * A), (B_m * B_m));
double t_2 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_3 = 2.0 * (t_2 * F);
double t_4 = -t_2;
double t_5 = sqrt((t_3 * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / t_4;
double tmp;
if (t_5 <= -((double) INFINITY)) {
tmp = sqrt((F * (t_0 / t_1))) * -sqrt(2.0);
} else if (t_5 <= -1e-207) {
tmp = sqrt((t_0 * ((2.0 * F) * t_1))) / -t_1;
} else if (t_5 <= ((double) INFINITY)) {
tmp = sqrt((t_3 * (A + A))) / t_4;
} else {
tmp = sqrt((((A - hypot(A, B_m)) * 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(-4.0, Float64(C * A), Float64(B_m * B_m)) t_2 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_3 = Float64(2.0 * Float64(t_2 * F)) t_4 = Float64(-t_2) t_5 = Float64(sqrt(Float64(t_3 * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0)))))) / t_4) tmp = 0.0 if (t_5 <= Float64(-Inf)) tmp = Float64(sqrt(Float64(F * Float64(t_0 / t_1))) * Float64(-sqrt(2.0))); elseif (t_5 <= -1e-207) tmp = Float64(sqrt(Float64(t_0 * Float64(Float64(2.0 * F) * t_1))) / Float64(-t_1)); elseif (t_5 <= Inf) tmp = Float64(sqrt(Float64(t_3 * Float64(A + A))) / t_4); else tmp = Float64(sqrt(Float64(Float64(Float64(A - hypot(A, B_m)) * F) * 2.0)) / Float64(-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[(-4.0 * N[(C * A), $MachinePrecision] + 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[(2.0 * N[(t$95$2 * F), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = (-t$95$2)}, Block[{t$95$5 = N[(N[Sqrt[N[(t$95$3 * 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$4), $MachinePrecision]}, If[LessEqual[t$95$5, (-Infinity)], N[(N[Sqrt[N[(F * N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$5, -1e-207], N[(N[Sqrt[N[(t$95$0 * N[(N[(2.0 * F), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$1)), $MachinePrecision], If[LessEqual[t$95$5, Infinity], N[(N[Sqrt[N[(t$95$3 * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(A - N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $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(-4, C \cdot A, B\_m \cdot B\_m\right)\\
t_2 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := 2 \cdot \left(t\_2 \cdot F\right)\\
t_4 := -t\_2\\
t_5 := \frac{\sqrt{t\_3 \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right)}}{t\_4}\\
\mathbf{if}\;t\_5 \leq -\infty:\\
\;\;\;\;\sqrt{F \cdot \frac{t\_0}{t\_1}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;t\_5 \leq -1 \cdot 10^{-207}:\\
\;\;\;\;\frac{\sqrt{t\_0 \cdot \left(\left(2 \cdot F\right) \cdot t\_1\right)}}{-t\_1}\\
\mathbf{elif}\;t\_5 \leq \infty:\\
\;\;\;\;\frac{\sqrt{t\_3 \cdot \left(A + A\right)}}{t\_4}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - \mathsf{hypot}\left(A, B\_m\right)\right) \cdot F\right) \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 2.9%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites46.8%
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))) < -9.99999999999999925e-208Initial program 99.2%
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
remove-double-negN/A
lower-/.f64N/A
Applied rewrites99.2%
if -9.99999999999999925e-208 < (/.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 19.3%
Taylor expanded in C around inf
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f6416.8
Applied rewrites16.8%
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 C 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
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6414.7
Applied rewrites14.7%
Applied rewrites14.8%
Final simplification32.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 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_1
(/
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))))
(- t_0)))
(t_2 (fma (* -4.0 C) A (* B_m B_m))))
(if (<= t_1 -1e-207)
(*
(sqrt
(*
F
(/ (- (+ C A) (hypot (- A C) B_m)) (fma -4.0 (* C A) (* B_m B_m)))))
(- (sqrt 2.0)))
(if (<= t_1 0.0)
(/
(*
(sqrt (* (* (fma (* C A) -4.0 (* B_m B_m)) F) 2.0))
(sqrt
(+
A
(-
(/ (* -0.5 (* A (* B_m B_m))) (* C C))
(fma -1.0 A (* 0.5 (/ (* B_m B_m) C)))))))
(- (fma B_m B_m (* -4.0 (* A C)))))
(if (<= t_1 INFINITY)
(/ (sqrt (* (- (+ C A) (- A)) (* (* F 2.0) t_2))) (- t_2))
(/ (sqrt (* (* (- A (hypot A B_m)) 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 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_1 = sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / -t_0;
double t_2 = fma((-4.0 * C), A, (B_m * B_m));
double tmp;
if (t_1 <= -1e-207) {
tmp = sqrt((F * (((C + A) - hypot((A - C), B_m)) / fma(-4.0, (C * A), (B_m * B_m))))) * -sqrt(2.0);
} else if (t_1 <= 0.0) {
tmp = (sqrt(((fma((C * A), -4.0, (B_m * B_m)) * F) * 2.0)) * sqrt((A + (((-0.5 * (A * (B_m * B_m))) / (C * C)) - fma(-1.0, A, (0.5 * ((B_m * B_m) / C))))))) / -fma(B_m, B_m, (-4.0 * (A * C)));
} else if (t_1 <= ((double) INFINITY)) {
tmp = sqrt((((C + A) - -A) * ((F * 2.0) * t_2))) / -t_2;
} else {
tmp = sqrt((((A - hypot(A, B_m)) * 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((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_1 = Float64(sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0)))))) / Float64(-t_0)) t_2 = fma(Float64(-4.0 * C), A, Float64(B_m * B_m)) tmp = 0.0 if (t_1 <= -1e-207) tmp = Float64(sqrt(Float64(F * Float64(Float64(Float64(C + A) - hypot(Float64(A - C), B_m)) / fma(-4.0, Float64(C * A), Float64(B_m * B_m))))) * Float64(-sqrt(2.0))); elseif (t_1 <= 0.0) tmp = Float64(Float64(sqrt(Float64(Float64(fma(Float64(C * A), -4.0, Float64(B_m * B_m)) * F) * 2.0)) * sqrt(Float64(A + Float64(Float64(Float64(-0.5 * Float64(A * Float64(B_m * B_m))) / Float64(C * C)) - fma(-1.0, A, Float64(0.5 * Float64(Float64(B_m * B_m) / C))))))) / Float64(-fma(B_m, B_m, Float64(-4.0 * Float64(A * C))))); elseif (t_1 <= Inf) tmp = Float64(sqrt(Float64(Float64(Float64(C + A) - Float64(-A)) * Float64(Float64(F * 2.0) * t_2))) / Float64(-t_2)); else tmp = Float64(sqrt(Float64(Float64(Float64(A - hypot(A, B_m)) * F) * 2.0)) / Float64(-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[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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$95$m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision]}, Block[{t$95$2 = N[(N[(-4.0 * C), $MachinePrecision] * A + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-207], N[(N[Sqrt[N[(F * N[(N[(N[(C + A), $MachinePrecision] - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] / N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(N[Sqrt[N[(N[(N[(N[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(A + N[(N[(N[(-0.5 * N[(A * N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(C * C), $MachinePrecision]), $MachinePrecision] - N[(-1.0 * A + N[(0.5 * N[(N[(B$95$m * B$95$m), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / (-N[(B$95$m * B$95$m + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[Sqrt[N[(N[(N[(C + A), $MachinePrecision] - (-A)), $MachinePrecision] * N[(N[(F * 2.0), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$2)), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(A - N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $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 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_1 := \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\_m}^{2}}\right)}}{-t\_0}\\
t_2 := \mathsf{fma}\left(-4 \cdot C, A, B\_m \cdot B\_m\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-207}:\\
\;\;\;\;\sqrt{F \cdot \frac{\left(C + A\right) - \mathsf{hypot}\left(A - C, B\_m\right)}{\mathsf{fma}\left(-4, C \cdot A, B\_m \cdot B\_m\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(C \cdot A, -4, B\_m \cdot B\_m\right) \cdot F\right) \cdot 2} \cdot \sqrt{A + \left(\frac{-0.5 \cdot \left(A \cdot \left(B\_m \cdot B\_m\right)\right)}{C \cdot C} - \mathsf{fma}\left(-1, A, 0.5 \cdot \frac{B\_m \cdot B\_m}{C}\right)\right)}}{-\mathsf{fma}\left(B\_m, B\_m, -4 \cdot \left(A \cdot C\right)\right)}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\left(\left(C + A\right) - \left(-A\right)\right) \cdot \left(\left(F \cdot 2\right) \cdot t\_2\right)}}{-t\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - \mathsf{hypot}\left(A, B\_m\right)\right) \cdot F\right) \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))) < -9.99999999999999925e-208Initial program 45.2%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites63.0%
if -9.99999999999999925e-208 < (/.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))) < -0.0Initial program 3.4%
Taylor expanded in A around inf
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f6424.9
Applied rewrites24.9%
lift-neg.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites17.5%
Taylor expanded in C around inf
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6410.4
Applied rewrites10.4%
Taylor expanded in B around 0
cancel-sign-sub-invN/A
unpow2N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6410.4
Applied rewrites10.4%
if -0.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))) < +inf.0Initial program 33.7%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f6422.5
Applied rewrites22.5%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
lower-/.f64N/A
Applied rewrites22.5%
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 C 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
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6414.7
Applied rewrites14.7%
Applied rewrites14.8%
Final simplification30.7%
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 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_1 (* 2.0 (* t_0 F)))
(t_2 (- t_0))
(t_3
(/
(sqrt (* t_1 (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))))
t_2)))
(if (<= t_3 -1e-207)
(/
(*
(- (sqrt (* (fma -4.0 (* C A) (* B_m B_m)) 2.0)))
(sqrt (* F (- (+ C A) (hypot (- A C) B_m)))))
t_0)
(if (<= t_3 INFINITY)
(/ (sqrt (* t_1 (+ A A))) t_2)
(/ (sqrt (* (* (- A (hypot A B_m)) 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 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_1 = 2.0 * (t_0 * F);
double t_2 = -t_0;
double t_3 = sqrt((t_1 * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / t_2;
double tmp;
if (t_3 <= -1e-207) {
tmp = (-sqrt((fma(-4.0, (C * A), (B_m * B_m)) * 2.0)) * sqrt((F * ((C + A) - hypot((A - C), B_m))))) / t_0;
} else if (t_3 <= ((double) INFINITY)) {
tmp = sqrt((t_1 * (A + A))) / t_2;
} else {
tmp = sqrt((((A - hypot(A, B_m)) * 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((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_1 = Float64(2.0 * Float64(t_0 * F)) t_2 = Float64(-t_0) t_3 = Float64(sqrt(Float64(t_1 * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0)))))) / t_2) tmp = 0.0 if (t_3 <= -1e-207) tmp = Float64(Float64(Float64(-sqrt(Float64(fma(-4.0, Float64(C * A), Float64(B_m * B_m)) * 2.0))) * sqrt(Float64(F * Float64(Float64(C + A) - hypot(Float64(A - C), B_m))))) / t_0); elseif (t_3 <= Inf) tmp = Float64(sqrt(Float64(t_1 * Float64(A + A))) / t_2); else tmp = Float64(sqrt(Float64(Float64(Float64(A - hypot(A, B_m)) * F) * 2.0)) / Float64(-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[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = (-t$95$0)}, Block[{t$95$3 = N[(N[Sqrt[N[(t$95$1 * 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]}, If[LessEqual[t$95$3, -1e-207], N[(N[((-N[Sqrt[N[(N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision]) * N[Sqrt[N[(F * N[(N[(C + A), $MachinePrecision] - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(N[Sqrt[N[(t$95$1 * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(A - N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $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 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_1 := 2 \cdot \left(t\_0 \cdot F\right)\\
t_2 := -t\_0\\
t_3 := \frac{\sqrt{t\_1 \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right)}}{t\_2}\\
\mathbf{if}\;t\_3 \leq -1 \cdot 10^{-207}:\\
\;\;\;\;\frac{\left(-\sqrt{\mathsf{fma}\left(-4, C \cdot A, B\_m \cdot B\_m\right) \cdot 2}\right) \cdot \sqrt{F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(A - C, B\_m\right)\right)}}{t\_0}\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;\frac{\sqrt{t\_1 \cdot \left(A + A\right)}}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - \mathsf{hypot}\left(A, B\_m\right)\right) \cdot F\right) \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))) < -9.99999999999999925e-208Initial program 45.2%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
sqrt-prodN/A
pow1/2N/A
lower-*.f64N/A
Applied rewrites66.3%
if -9.99999999999999925e-208 < (/.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 19.3%
Taylor expanded in C around inf
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f6416.8
Applied rewrites16.8%
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 C 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
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6414.7
Applied rewrites14.7%
Applied rewrites14.8%
Final simplification31.8%
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 -4.0 (* C A) (* 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))))
(if (<= t_3 (- INFINITY))
(* (sqrt (* F (/ t_0 t_1))) (- (sqrt 2.0)))
(if (<= t_3 INFINITY)
(/ (sqrt (* t_0 (* (* 2.0 F) t_1))) (- t_1))
(/ (sqrt (* (* (- A (hypot A B_m)) 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(-4.0, (C * A), (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 tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = sqrt((F * (t_0 / t_1))) * -sqrt(2.0);
} else if (t_3 <= ((double) INFINITY)) {
tmp = sqrt((t_0 * ((2.0 * F) * t_1))) / -t_1;
} else {
tmp = sqrt((((A - hypot(A, B_m)) * 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(-4.0, Float64(C * A), 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)) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(sqrt(Float64(F * Float64(t_0 / t_1))) * Float64(-sqrt(2.0))); elseif (t_3 <= Inf) tmp = Float64(sqrt(Float64(t_0 * Float64(Float64(2.0 * F) * t_1))) / Float64(-t_1)); else tmp = Float64(sqrt(Float64(Float64(Float64(A - hypot(A, B_m)) * F) * 2.0)) / Float64(-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[(-4.0 * N[(C * A), $MachinePrecision] + 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]}, If[LessEqual[t$95$3, (-Infinity)], N[(N[Sqrt[N[(F * N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(N[Sqrt[N[(t$95$0 * N[(N[(2.0 * F), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$1)), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(A - N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $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(-4, C \cdot A, 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}\\
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;\sqrt{F \cdot \frac{t\_0}{t\_1}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;\frac{\sqrt{t\_0 \cdot \left(\left(2 \cdot F\right) \cdot t\_1\right)}}{-t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - \mathsf{hypot}\left(A, B\_m\right)\right) \cdot F\right) \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 2.9%
Taylor expanded in F around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites46.8%
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))) < +inf.0Initial program 47.8%
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
remove-double-negN/A
lower-/.f64N/A
Applied rewrites52.5%
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 C 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
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6414.7
Applied rewrites14.7%
Applied rewrites14.8%
Final simplification35.4%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma (* -4.0 C) A (* B_m B_m))))
(if (<= (pow B_m 2.0) 2e-130)
(/ (sqrt (* (- (+ C A) (- A)) (* (* F 2.0) t_0))) (- t_0))
(/ (sqrt (* (* (- A (hypot A B_m)) 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 tmp;
if (pow(B_m, 2.0) <= 2e-130) {
tmp = sqrt((((C + A) - -A) * ((F * 2.0) * t_0))) / -t_0;
} else {
tmp = sqrt((((A - hypot(A, B_m)) * 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(-4.0 * C), A, Float64(B_m * B_m)) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-130) tmp = Float64(sqrt(Float64(Float64(Float64(C + A) - Float64(-A)) * Float64(Float64(F * 2.0) * t_0))) / Float64(-t_0)); else tmp = Float64(sqrt(Float64(Float64(Float64(A - hypot(A, B_m)) * F) * 2.0)) / Float64(-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[(-4.0 * C), $MachinePrecision] * A + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-130], N[(N[Sqrt[N[(N[(N[(C + A), $MachinePrecision] - (-A)), $MachinePrecision] * N[(N[(F * 2.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(A - N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4 \cdot C, A, B\_m \cdot B\_m\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-130}:\\
\;\;\;\;\frac{\sqrt{\left(\left(C + A\right) - \left(-A\right)\right) \cdot \left(\left(F \cdot 2\right) \cdot t\_0\right)}}{-t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - \mathsf{hypot}\left(A, B\_m\right)\right) \cdot F\right) \cdot 2}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2.0000000000000002e-130Initial program 20.9%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f6412.6
Applied rewrites12.6%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
lower-/.f64N/A
Applied rewrites12.6%
if 2.0000000000000002e-130 < (pow.f64 B #s(literal 2 binary64)) Initial program 18.3%
Taylor expanded in C 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
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6418.7
Applied rewrites18.7%
Applied rewrites18.8%
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) 1e-77)
(/ (sqrt (* (- (+ C A) (- A)) (* (* F 2.0) t_0))) (- t_0))
(/ (sqrt (fma -2.0 (* B_m F) (* 2.0 (* A F)))) (- 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 tmp;
if (pow(B_m, 2.0) <= 1e-77) {
tmp = sqrt((((C + A) - -A) * ((F * 2.0) * t_0))) / -t_0;
} else {
tmp = sqrt(fma(-2.0, (B_m * F), (2.0 * (A * F)))) / -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(-4.0 * C), A, Float64(B_m * B_m)) tmp = 0.0 if ((B_m ^ 2.0) <= 1e-77) tmp = Float64(sqrt(Float64(Float64(Float64(C + A) - Float64(-A)) * Float64(Float64(F * 2.0) * t_0))) / Float64(-t_0)); else tmp = Float64(sqrt(fma(-2.0, Float64(B_m * F), Float64(2.0 * Float64(A * F)))) / Float64(-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[(-4.0 * C), $MachinePrecision] * A + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-77], N[(N[Sqrt[N[(N[(N[(C + A), $MachinePrecision] - (-A)), $MachinePrecision] * N[(N[(F * 2.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], N[(N[Sqrt[N[(-2.0 * N[(B$95$m * F), $MachinePrecision] + N[(2.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4 \cdot C, A, B\_m \cdot B\_m\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-77}:\\
\;\;\;\;\frac{\sqrt{\left(\left(C + A\right) - \left(-A\right)\right) \cdot \left(\left(F \cdot 2\right) \cdot t\_0\right)}}{-t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-2, B\_m \cdot F, 2 \cdot \left(A \cdot F\right)\right)}}{-B\_m}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 9.9999999999999993e-78Initial program 21.1%
Taylor expanded in A around -inf
mul-1-negN/A
lower-neg.f6412.7
Applied rewrites12.7%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
lower-/.f64N/A
Applied rewrites12.7%
if 9.9999999999999993e-78 < (pow.f64 B #s(literal 2 binary64)) Initial program 17.8%
Taylor expanded in C 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
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6419.4
Applied rewrites19.4%
Applied rewrites19.5%
Taylor expanded in A around 0
Applied rewrites17.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 (/ (sqrt (fma -2.0 (* B_m F) (* 2.0 (* A F)))) (- 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(fma(-2.0, (B_m * F), (2.0 * (A * F)))) / -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(fma(-2.0, Float64(B_m * F), Float64(2.0 * Float64(A * F)))) / Float64(-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[N[(-2.0 * N[(B$95$m * F), $MachinePrecision] + N[(2.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{\sqrt{\mathsf{fma}\left(-2, B\_m \cdot F, 2 \cdot \left(A \cdot F\right)\right)}}{-B\_m}
\end{array}
Initial program 19.4%
Taylor expanded in C 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
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6412.9
Applied rewrites12.9%
Applied rewrites13.0%
Taylor expanded in A around 0
Applied rewrites10.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 (/ (sqrt (* -2.0 (* B_m F))) (- 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((-2.0 * (B_m * F))) / -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(((-2.0d0) * (b_m * f))) / -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((-2.0 * (B_m * F))) / -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((-2.0 * (B_m * F))) / -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(-2.0 * Float64(B_m * F))) / Float64(-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((-2.0 * (B_m * F))) / -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[N[(-2.0 * N[(B$95$m * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{\sqrt{-2 \cdot \left(B\_m \cdot F\right)}}{-B\_m}
\end{array}
Initial program 19.4%
Taylor expanded in C 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
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6412.9
Applied rewrites12.9%
Applied rewrites13.0%
Taylor expanded in A around 0
Applied rewrites11.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 (/ (* -2.0 (sqrt (* F A))) 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 (-2.0 * sqrt((F * A))) / 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 = ((-2.0d0) * sqrt((f * a))) / 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 (-2.0 * Math.sqrt((F * A))) / 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 (-2.0 * math.sqrt((F * A))) / 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(-2.0 * sqrt(Float64(F * A))) / 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 = (-2.0 * sqrt((F * A))) / 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[(-2.0 * N[Sqrt[N[(F * A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / B$95$m), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{-2 \cdot \sqrt{F \cdot A}}{B\_m}
\end{array}
Initial program 19.4%
Taylor expanded in C 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
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6412.9
Applied rewrites12.9%
Taylor expanded in A around -inf
Applied rewrites2.4%
Applied rewrites2.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 (* A 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((A * 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((a * 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((A * 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((A * 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(A * 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((A * 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[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(-2.0 / 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])\\
\\
\sqrt{A \cdot F} \cdot \frac{-2}{B\_m}
\end{array}
Initial program 19.4%
Taylor expanded in C 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
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f6412.9
Applied rewrites12.9%
Taylor expanded in A around -inf
Applied rewrites2.4%
herbie shell --seed 2024309
(FPCore (A B C F)
:name "ABCF->ab-angle b"
:precision binary64
(/ (- (sqrt (* (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F)) (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))) (- (pow B 2.0) (* (* 4.0 A) C))))