
(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 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0))))
(t_1 (fma A (* C -4.0) (pow B 2.0)))
(t_2 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_3
(/
(-
(sqrt
(*
(* 2.0 (* t_2 F))
(- (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_2)))
(if (<= t_3 -5e-197)
(/
(* (pow (* 2.0 t_0) 0.5) (- (sqrt (* F (+ A (- C (hypot B (- A C))))))))
t_0)
(if (<= t_3 4e+250)
(/
(-
(sqrt
(*
2.0
(*
(* F t_1)
(+
A
(+
A
(*
-0.5
(/ (+ (pow A 2.0) (- (pow B 2.0) (pow (- A) 2.0))) C))))))))
t_1)
(if (<= t_3 INFINITY)
(/
(-
(pow
(*
(exp
(* 0.25 (+ (log (* -8.0 (* C F))) (* -2.0 (log (/ -1.0 A))))))
(sqrt (sqrt 2.0)))
2.0))
t_0)
(*
(/ (sqrt 2.0) B)
(- (pow (sqrt (sqrt (* F (- A (hypot B A))))) 2.0))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double t_1 = fma(A, (C * -4.0), pow(B, 2.0));
double t_2 = pow(B, 2.0) - ((4.0 * A) * C);
double t_3 = -sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_2;
double tmp;
if (t_3 <= -5e-197) {
tmp = (pow((2.0 * t_0), 0.5) * -sqrt((F * (A + (C - hypot(B, (A - C))))))) / t_0;
} else if (t_3 <= 4e+250) {
tmp = -sqrt((2.0 * ((F * t_1) * (A + (A + (-0.5 * ((pow(A, 2.0) + (pow(B, 2.0) - pow(-A, 2.0))) / C))))))) / t_1;
} else if (t_3 <= ((double) INFINITY)) {
tmp = -pow((exp((0.25 * (log((-8.0 * (C * F))) + (-2.0 * log((-1.0 / A)))))) * sqrt(sqrt(2.0))), 2.0) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -pow(sqrt(sqrt((F * (A - hypot(B, A))))), 2.0);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) t_1 = fma(A, Float64(C * -4.0), (B ^ 2.0)) t_2 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_3 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_2 * F)) * Float64(Float64(A + C) - sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_2) tmp = 0.0 if (t_3 <= -5e-197) tmp = Float64(Float64((Float64(2.0 * t_0) ^ 0.5) * Float64(-sqrt(Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C)))))))) / t_0); elseif (t_3 <= 4e+250) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_1) * Float64(A + Float64(A + Float64(-0.5 * Float64(Float64((A ^ 2.0) + Float64((B ^ 2.0) - (Float64(-A) ^ 2.0))) / C)))))))) / t_1); elseif (t_3 <= Inf) tmp = Float64(Float64(-(Float64(exp(Float64(0.25 * Float64(log(Float64(-8.0 * Float64(C * F))) + Float64(-2.0 * log(Float64(-1.0 / A)))))) * sqrt(sqrt(2.0))) ^ 2.0)) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-(sqrt(sqrt(Float64(F * Float64(A - hypot(B, A))))) ^ 2.0))); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[B, 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[B, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, -5e-197], N[(N[(N[Power[N[(2.0 * t$95$0), $MachinePrecision], 0.5], $MachinePrecision] * (-N[Sqrt[N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[t$95$3, 4e+250], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$1), $MachinePrecision] * N[(A + N[(A + N[(-0.5 * N[(N[(N[Power[A, 2.0], $MachinePrecision] + N[(N[Power[B, 2.0], $MachinePrecision] - N[Power[(-A), 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[((-N[Power[N[(N[Exp[N[(0.25 * N[(N[Log[N[(-8.0 * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-2.0 * N[Log[N[(-1.0 / A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Sqrt[2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Power[N[Sqrt[N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision]]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)\\
t_2 := {B}^{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{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\
\mathbf{if}\;t_3 \leq -5 \cdot 10^{-197}:\\
\;\;\;\;\frac{{\left(2 \cdot t_0\right)}^{0.5} \cdot \left(-\sqrt{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}\right)}{t_0}\\
\mathbf{elif}\;t_3 \leq 4 \cdot 10^{+250}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_1\right) \cdot \left(A + \left(A + -0.5 \cdot \frac{{A}^{2} + \left({B}^{2} - {\left(-A\right)}^{2}\right)}{C}\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{-{\left(e^{0.25 \cdot \left(\log \left(-8 \cdot \left(C \cdot F\right)\right) + -2 \cdot \log \left(\frac{-1}{A}\right)\right)} \cdot \sqrt{\sqrt{2}}\right)}^{2}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-{\left(\sqrt{\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}}\right)}^{2}\right)\\
\end{array}
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -5.0000000000000002e-197Initial program 52.7%
Simplified60.5%
pow1/260.5%
associate-*r*60.5%
unpow-prod-down72.6%
pow1/272.6%
associate--l+74.2%
Applied egg-rr74.2%
if -5.0000000000000002e-197 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < 3.9999999999999997e250Initial program 31.4%
Simplified33.5%
Taylor expanded in C around inf 36.2%
associate--l+36.2%
associate--l+36.2%
mul-1-neg36.2%
mul-1-neg36.2%
Simplified36.2%
if 3.9999999999999997e250 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < +inf.0Initial program 3.7%
Simplified30.4%
add-sqr-sqrt30.3%
pow230.3%
associate-*r*30.3%
associate--l+30.3%
Applied egg-rr30.3%
Taylor expanded in A around -inf 28.2%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) Initial program 0.0%
Simplified0.7%
Taylor expanded in C around 0 1.9%
mul-1-neg1.9%
distribute-rgt-neg-in1.9%
+-commutative1.9%
unpow21.9%
unpow21.9%
hypot-def23.1%
Simplified23.1%
add-sqr-sqrt23.1%
pow223.1%
Applied egg-rr23.1%
Final simplification46.0%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0))))
(t_1 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_2
(/
(-
(sqrt
(*
(* 2.0 (* t_1 F))
(- (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_1)))
(if (<= t_2 -5e-197)
(/
(* (pow (* 2.0 t_0) 0.5) (- (sqrt (* F (+ A (- C (hypot B (- A C))))))))
t_0)
(if (<= t_2 4e+250)
(/ (- (sqrt (* 2.0 (* -4.0 (* (* A C) (* F (+ A A))))))) t_0)
(if (<= t_2 INFINITY)
(/
(-
(pow
(*
(exp
(* 0.25 (+ (log (* -8.0 (* C F))) (* -2.0 (log (/ -1.0 A))))))
(sqrt (sqrt 2.0)))
2.0))
t_0)
(*
(/ (sqrt 2.0) B)
(- (pow (sqrt (sqrt (* F (- A (hypot B A))))) 2.0))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double t_1 = pow(B, 2.0) - ((4.0 * A) * C);
double t_2 = -sqrt(((2.0 * (t_1 * F)) * ((A + C) - sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_1;
double tmp;
if (t_2 <= -5e-197) {
tmp = (pow((2.0 * t_0), 0.5) * -sqrt((F * (A + (C - hypot(B, (A - C))))))) / t_0;
} else if (t_2 <= 4e+250) {
tmp = -sqrt((2.0 * (-4.0 * ((A * C) * (F * (A + A)))))) / t_0;
} else if (t_2 <= ((double) INFINITY)) {
tmp = -pow((exp((0.25 * (log((-8.0 * (C * F))) + (-2.0 * log((-1.0 / A)))))) * sqrt(sqrt(2.0))), 2.0) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -pow(sqrt(sqrt((F * (A - hypot(B, A))))), 2.0);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) t_1 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_2 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_1 * F)) * Float64(Float64(A + C) - sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_1) tmp = 0.0 if (t_2 <= -5e-197) tmp = Float64(Float64((Float64(2.0 * t_0) ^ 0.5) * Float64(-sqrt(Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C)))))))) / t_0); elseif (t_2 <= 4e+250) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-4.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))))) / t_0); elseif (t_2 <= Inf) tmp = Float64(Float64(-(Float64(exp(Float64(0.25 * Float64(log(Float64(-8.0 * Float64(C * F))) + Float64(-2.0 * log(Float64(-1.0 / A)))))) * sqrt(sqrt(2.0))) ^ 2.0)) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-(sqrt(sqrt(Float64(F * Float64(A - hypot(B, A))))) ^ 2.0))); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$1 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -5e-197], N[(N[(N[Power[N[(2.0 * t$95$0), $MachinePrecision], 0.5], $MachinePrecision] * (-N[Sqrt[N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[t$95$2, 4e+250], N[((-N[Sqrt[N[(2.0 * N[(-4.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[((-N[Power[N[(N[Exp[N[(0.25 * N[(N[Log[N[(-8.0 * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-2.0 * N[Log[N[(-1.0 / A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Sqrt[2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Power[N[Sqrt[N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision]]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_2 := \frac{-\sqrt{\left(2 \cdot \left(t_1 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_1}\\
\mathbf{if}\;t_2 \leq -5 \cdot 10^{-197}:\\
\;\;\;\;\frac{{\left(2 \cdot t_0\right)}^{0.5} \cdot \left(-\sqrt{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}\right)}{t_0}\\
\mathbf{elif}\;t_2 \leq 4 \cdot 10^{+250}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\frac{-{\left(e^{0.25 \cdot \left(\log \left(-8 \cdot \left(C \cdot F\right)\right) + -2 \cdot \log \left(\frac{-1}{A}\right)\right)} \cdot \sqrt{\sqrt{2}}\right)}^{2}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-{\left(\sqrt{\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}}\right)}^{2}\right)\\
\end{array}
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -5.0000000000000002e-197Initial program 52.7%
Simplified60.5%
pow1/260.5%
associate-*r*60.5%
unpow-prod-down72.6%
pow1/272.6%
associate--l+74.2%
Applied egg-rr74.2%
if -5.0000000000000002e-197 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < 3.9999999999999997e250Initial program 31.4%
Simplified31.3%
Taylor expanded in C around inf 32.2%
associate-*r*32.2%
*-commutative32.2%
cancel-sign-sub-inv32.2%
metadata-eval32.2%
*-lft-identity32.2%
Simplified32.2%
if 3.9999999999999997e250 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < +inf.0Initial program 3.7%
Simplified30.4%
add-sqr-sqrt30.3%
pow230.3%
associate-*r*30.3%
associate--l+30.3%
Applied egg-rr30.3%
Taylor expanded in A around -inf 28.2%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) Initial program 0.0%
Simplified0.7%
Taylor expanded in C around 0 1.9%
mul-1-neg1.9%
distribute-rgt-neg-in1.9%
+-commutative1.9%
unpow21.9%
unpow21.9%
hypot-def23.1%
Simplified23.1%
add-sqr-sqrt23.1%
pow223.1%
Applied egg-rr23.1%
Final simplification45.4%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0))))
(t_1 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_2
(/
(-
(sqrt
(*
(* 2.0 (* t_1 F))
(- (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_1)))
(if (<= t_2 -5e-197)
(/
(* (pow (* 2.0 t_0) 0.5) (- (sqrt (* F (+ A (- C (hypot B (- A C))))))))
t_0)
(if (<= t_2 INFINITY)
(/ (- (sqrt (* 2.0 (* -4.0 (* (* A C) (* F (+ A A))))))) t_0)
(*
(/ (sqrt 2.0) B)
(- (pow (sqrt (sqrt (* F (- A (hypot B A))))) 2.0)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double t_1 = pow(B, 2.0) - ((4.0 * A) * C);
double t_2 = -sqrt(((2.0 * (t_1 * F)) * ((A + C) - sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_1;
double tmp;
if (t_2 <= -5e-197) {
tmp = (pow((2.0 * t_0), 0.5) * -sqrt((F * (A + (C - hypot(B, (A - C))))))) / t_0;
} else if (t_2 <= ((double) INFINITY)) {
tmp = -sqrt((2.0 * (-4.0 * ((A * C) * (F * (A + A)))))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -pow(sqrt(sqrt((F * (A - hypot(B, A))))), 2.0);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) t_1 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_2 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_1 * F)) * Float64(Float64(A + C) - sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_1) tmp = 0.0 if (t_2 <= -5e-197) tmp = Float64(Float64((Float64(2.0 * t_0) ^ 0.5) * Float64(-sqrt(Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C)))))))) / t_0); elseif (t_2 <= Inf) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-4.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-(sqrt(sqrt(Float64(F * Float64(A - hypot(B, A))))) ^ 2.0))); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$1 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -5e-197], N[(N[(N[Power[N[(2.0 * t$95$0), $MachinePrecision], 0.5], $MachinePrecision] * (-N[Sqrt[N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[((-N[Sqrt[N[(2.0 * N[(-4.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Power[N[Sqrt[N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision]]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_2 := \frac{-\sqrt{\left(2 \cdot \left(t_1 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_1}\\
\mathbf{if}\;t_2 \leq -5 \cdot 10^{-197}:\\
\;\;\;\;\frac{{\left(2 \cdot t_0\right)}^{0.5} \cdot \left(-\sqrt{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}\right)}{t_0}\\
\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-{\left(\sqrt{\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}}\right)}^{2}\right)\\
\end{array}
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -5.0000000000000002e-197Initial program 52.7%
Simplified60.5%
pow1/260.5%
associate-*r*60.5%
unpow-prod-down72.6%
pow1/272.6%
associate--l+74.2%
Applied egg-rr74.2%
if -5.0000000000000002e-197 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < +inf.0Initial program 22.5%
Simplified31.0%
Taylor expanded in C around inf 26.6%
associate-*r*26.6%
*-commutative26.6%
cancel-sign-sub-inv26.6%
metadata-eval26.6%
*-lft-identity26.6%
Simplified26.6%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) Initial program 0.0%
Simplified0.7%
Taylor expanded in C around 0 1.9%
mul-1-neg1.9%
distribute-rgt-neg-in1.9%
+-commutative1.9%
unpow21.9%
unpow21.9%
hypot-def23.1%
Simplified23.1%
add-sqr-sqrt23.1%
pow223.1%
Applied egg-rr23.1%
Final simplification44.4%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0)))))
(if (<= (pow B 2.0) 1e-130)
(/ (- (sqrt (* 2.0 (* -4.0 (* (* A C) (* F (+ A A))))))) t_0)
(if (<= (pow B 2.0) 5e-90)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- B)))))
(if (<= (pow B 2.0) 5e-35)
(/
(-
(sqrt
(*
2.0
(+
(* -8.0 (* (pow A 2.0) (* C F)))
(* 2.0 (* A (* (pow B 2.0) F)))))))
t_0)
(/ (* (sqrt 2.0) (- (sqrt (* F (- A (hypot B A)))))) B))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (pow(B, 2.0) <= 1e-130) {
tmp = -sqrt((2.0 * (-4.0 * ((A * C) * (F * (A + A)))))) / t_0;
} else if (pow(B, 2.0) <= 5e-90) {
tmp = (sqrt(2.0) / B) * -sqrt((F * -B));
} else if (pow(B, 2.0) <= 5e-35) {
tmp = -sqrt((2.0 * ((-8.0 * (pow(A, 2.0) * (C * F))) + (2.0 * (A * (pow(B, 2.0) * F)))))) / t_0;
} else {
tmp = (sqrt(2.0) * -sqrt((F * (A - hypot(B, A))))) / B;
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B ^ 2.0) <= 1e-130) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-4.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))))) / t_0); elseif ((B ^ 2.0) <= 5e-90) tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(-B))))); elseif ((B ^ 2.0) <= 5e-35) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(-8.0 * Float64((A ^ 2.0) * Float64(C * F))) + Float64(2.0 * Float64(A * Float64((B ^ 2.0) * F))))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(A - hypot(B, A)))))) / B); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 1e-130], N[((-N[Sqrt[N[(2.0 * N[(-4.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e-90], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * (-B)), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e-35], N[((-N[Sqrt[N[(2.0 * N[(N[(-8.0 * N[(N[Power[A, 2.0], $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(A * N[(N[Power[B, 2.0], $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / B), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B}^{2} \leq 10^{-130}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;{B}^{2} \leq 5 \cdot 10^{-90}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(-B\right)}\right)\\
\mathbf{elif}\;{B}^{2} \leq 5 \cdot 10^{-35}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-8 \cdot \left({A}^{2} \cdot \left(C \cdot F\right)\right) + 2 \cdot \left(A \cdot \left({B}^{2} \cdot F\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}\right)}{B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 1.0000000000000001e-130Initial program 30.6%
Simplified37.5%
Taylor expanded in C around inf 22.7%
associate-*r*23.6%
*-commutative23.6%
cancel-sign-sub-inv23.6%
metadata-eval23.6%
*-lft-identity23.6%
Simplified23.6%
if 1.0000000000000001e-130 < (pow.f64 B 2) < 5.00000000000000019e-90Initial program 46.9%
Simplified54.6%
Taylor expanded in C around 0 17.1%
mul-1-neg17.1%
distribute-rgt-neg-in17.1%
+-commutative17.1%
unpow217.1%
unpow217.1%
hypot-def17.3%
Simplified17.3%
Taylor expanded in A around 0 15.8%
associate-*r*15.8%
mul-1-neg15.8%
Simplified15.8%
if 5.00000000000000019e-90 < (pow.f64 B 2) < 4.99999999999999964e-35Initial program 55.7%
Simplified55.7%
Taylor expanded in A around -inf 29.2%
if 4.99999999999999964e-35 < (pow.f64 B 2) Initial program 17.6%
Simplified21.7%
Taylor expanded in C around 0 10.8%
mul-1-neg10.8%
distribute-rgt-neg-in10.8%
+-commutative10.8%
unpow210.8%
unpow210.8%
hypot-def29.2%
Simplified29.2%
associate-*l/29.2%
Applied egg-rr29.2%
Final simplification26.2%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma B B (* A (* C -4.0)))))
(if (<= (pow B 2.0) 5e-182)
(/ (- (sqrt (* 2.0 (* -4.0 (* (* A C) (* F (+ A A))))))) t_0)
(if (<= (pow B 2.0) 2e+178)
(/ (- (sqrt (* 2.0 (* t_0 (* F (+ A (- C (hypot B (- A C))))))))) t_0)
(/ (* (sqrt 2.0) (- (sqrt (* F (- A (hypot B A)))))) B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (pow(B, 2.0) <= 5e-182) {
tmp = -sqrt((2.0 * (-4.0 * ((A * C) * (F * (A + A)))))) / t_0;
} else if (pow(B, 2.0) <= 2e+178) {
tmp = -sqrt((2.0 * (t_0 * (F * (A + (C - hypot(B, (A - C)))))))) / t_0;
} else {
tmp = (sqrt(2.0) * -sqrt((F * (A - hypot(B, A))))) / B;
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B ^ 2.0) <= 5e-182) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-4.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))))) / t_0); elseif ((B ^ 2.0) <= 2e+178) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C))))))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(A - hypot(B, A)))))) / B); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e-182], N[((-N[Sqrt[N[(2.0 * N[(-4.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e+178], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / B), $MachinePrecision]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{-182}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;{B}^{2} \leq 2 \cdot 10^{+178}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}\right)}{B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 5.00000000000000024e-182Initial program 28.5%
Simplified34.4%
Taylor expanded in C around inf 22.2%
associate-*r*22.2%
*-commutative22.2%
cancel-sign-sub-inv22.2%
metadata-eval22.2%
*-lft-identity22.2%
Simplified22.2%
if 5.00000000000000024e-182 < (pow.f64 B 2) < 2.0000000000000001e178Initial program 40.2%
Simplified48.7%
associate--l+50.1%
Applied egg-rr50.1%
if 2.0000000000000001e178 < (pow.f64 B 2) Initial program 4.7%
Simplified4.8%
Taylor expanded in C around 0 7.6%
mul-1-neg7.6%
distribute-rgt-neg-in7.6%
+-commutative7.6%
unpow27.6%
unpow27.6%
hypot-def34.2%
Simplified34.2%
associate-*l/34.2%
Applied egg-rr34.2%
Final simplification35.9%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma A (* C -4.0) (pow B 2.0))) (t_1 (fma B B (* A (* C -4.0)))))
(if (<= (pow B 2.0) 5e-182)
(/ (- (sqrt (* 2.0 (* (* F t_0) (+ A A))))) t_0)
(if (<= (pow B 2.0) 2e+178)
(/ (- (sqrt (* 2.0 (* t_1 (* F (+ A (- C (hypot B (- A C))))))))) t_1)
(/ (* (sqrt 2.0) (- (sqrt (* F (- A (hypot B A)))))) B)))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(A, (C * -4.0), pow(B, 2.0));
double t_1 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (pow(B, 2.0) <= 5e-182) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + A)))) / t_0;
} else if (pow(B, 2.0) <= 2e+178) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + (C - hypot(B, (A - C)))))))) / t_1;
} else {
tmp = (sqrt(2.0) * -sqrt((F * (A - hypot(B, A))))) / B;
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(A, Float64(C * -4.0), (B ^ 2.0)) t_1 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B ^ 2.0) <= 5e-182) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + A))))) / t_0); elseif ((B ^ 2.0) <= 2e+178) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C))))))))) / t_1); else tmp = Float64(Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(A - hypot(B, A)))))) / B); end return tmp end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e-182], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e+178], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / B), $MachinePrecision]]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)\\
t_1 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{-182}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + A\right)\right)}}{t_0}\\
\mathbf{elif}\;{B}^{2} \leq 2 \cdot 10^{+178}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}\right)}{B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 5.00000000000000024e-182Initial program 28.5%
Simplified35.4%
Taylor expanded in C around inf 24.2%
cancel-sign-sub-inv24.2%
metadata-eval24.2%
*-lft-identity24.2%
Simplified24.2%
if 5.00000000000000024e-182 < (pow.f64 B 2) < 2.0000000000000001e178Initial program 40.2%
Simplified48.7%
associate--l+50.1%
Applied egg-rr50.1%
if 2.0000000000000001e178 < (pow.f64 B 2) Initial program 4.7%
Simplified4.8%
Taylor expanded in C around 0 7.6%
mul-1-neg7.6%
distribute-rgt-neg-in7.6%
+-commutative7.6%
unpow27.6%
unpow27.6%
hypot-def34.2%
Simplified34.2%
associate-*l/34.2%
Applied egg-rr34.2%
Final simplification36.6%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= (pow B 2.0) 2e-135)
(/
(- (sqrt (* 2.0 (* -4.0 (* (* A C) (* F (+ A A)))))))
(fma B B (* A (* C -4.0))))
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A (hypot B A))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (pow(B, 2.0) <= 2e-135) {
tmp = -sqrt((2.0 * (-4.0 * ((A * C) * (F * (A + A)))))) / fma(B, B, (A * (C * -4.0)));
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(B, A))));
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if ((B ^ 2.0) <= 2e-135) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-4.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))))) / fma(B, B, Float64(A * Float64(C * -4.0)))); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - hypot(B, A)))))); end return tmp end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e-135], N[((-N[Sqrt[N[(2.0 * N[(-4.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-135}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 2.0000000000000001e-135Initial program 31.1%
Simplified38.3%
Taylor expanded in C around inf 23.7%
associate-*r*23.7%
*-commutative23.7%
cancel-sign-sub-inv23.7%
metadata-eval23.7%
*-lft-identity23.7%
Simplified23.7%
if 2.0000000000000001e-135 < (pow.f64 B 2) Initial program 22.9%
Simplified26.9%
Taylor expanded in C around 0 11.1%
mul-1-neg11.1%
distribute-rgt-neg-in11.1%
+-commutative11.1%
unpow211.1%
unpow211.1%
hypot-def26.1%
Simplified26.1%
Final simplification25.1%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= (pow B 2.0) 2e-135)
(/
(- (sqrt (* 2.0 (* -4.0 (* (* A C) (* F (+ A A)))))))
(fma B B (* A (* C -4.0))))
(/ (* (sqrt 2.0) (- (sqrt (* F (- A (hypot B A)))))) B)))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (pow(B, 2.0) <= 2e-135) {
tmp = -sqrt((2.0 * (-4.0 * ((A * C) * (F * (A + A)))))) / fma(B, B, (A * (C * -4.0)));
} else {
tmp = (sqrt(2.0) * -sqrt((F * (A - hypot(B, A))))) / B;
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if ((B ^ 2.0) <= 2e-135) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-4.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))))) / fma(B, B, Float64(A * Float64(C * -4.0)))); else tmp = Float64(Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(A - hypot(B, A)))))) / B); end return tmp end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e-135], N[((-N[Sqrt[N[(2.0 * N[(-4.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / B), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-135}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}\right)}{B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 2.0000000000000001e-135Initial program 31.1%
Simplified38.3%
Taylor expanded in C around inf 23.7%
associate-*r*23.7%
*-commutative23.7%
cancel-sign-sub-inv23.7%
metadata-eval23.7%
*-lft-identity23.7%
Simplified23.7%
if 2.0000000000000001e-135 < (pow.f64 B 2) Initial program 22.9%
Simplified26.9%
Taylor expanded in C around 0 11.1%
mul-1-neg11.1%
distribute-rgt-neg-in11.1%
+-commutative11.1%
unpow211.1%
unpow211.1%
hypot-def26.1%
Simplified26.1%
associate-*l/26.1%
Applied egg-rr26.1%
Final simplification25.1%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 7.5e-64)
(/
(- (sqrt (* 2.0 (* -4.0 (* (* A C) (* F (+ A A)))))))
(fma B B (* A (* C -4.0))))
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 7.5e-64) {
tmp = -sqrt((2.0 * (-4.0 * ((A * C) * (F * (A + A)))))) / fma(B, B, (A * (C * -4.0)));
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 7.5e-64) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-4.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))))) / fma(B, B, Float64(A * Float64(C * -4.0)))); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - B))))); end return tmp end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 7.5e-64], N[((-N[Sqrt[N[(2.0 * N[(-4.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 7.5 \cdot 10^{-64}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < 7.49999999999999949e-64Initial program 28.8%
Simplified34.1%
Taylor expanded in C around inf 16.9%
associate-*r*17.4%
*-commutative17.4%
cancel-sign-sub-inv17.4%
metadata-eval17.4%
*-lft-identity17.4%
Simplified17.4%
if 7.49999999999999949e-64 < B Initial program 20.0%
Simplified25.3%
Taylor expanded in C around 0 19.0%
mul-1-neg19.0%
distribute-rgt-neg-in19.0%
+-commutative19.0%
unpow219.0%
unpow219.0%
hypot-def48.1%
Simplified48.1%
Taylor expanded in A around 0 42.3%
mul-1-neg42.3%
Simplified42.3%
Final simplification25.0%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 1.1e-67)
(*
(sqrt (* -8.0 (* C (* A (* F (* 2.0 A))))))
(/ -1.0 (fma B B (* A (* C -4.0)))))
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 1.1e-67) {
tmp = sqrt((-8.0 * (C * (A * (F * (2.0 * A)))))) * (-1.0 / fma(B, B, (A * (C * -4.0))));
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 1.1e-67) tmp = Float64(sqrt(Float64(-8.0 * Float64(C * Float64(A * Float64(F * Float64(2.0 * A)))))) * Float64(-1.0 / fma(B, B, Float64(A * Float64(C * -4.0))))); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - B))))); end return tmp end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 1.1e-67], N[(N[Sqrt[N[(-8.0 * N[(C * N[(A * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 1.1 \cdot 10^{-67}:\\
\;\;\;\;\sqrt{-8 \cdot \left(C \cdot \left(A \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)\right)} \cdot \frac{-1}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < 1.1000000000000001e-67Initial program 28.9%
Simplified34.3%
Taylor expanded in C around inf 17.2%
associate-*r*17.7%
*-commutative17.7%
cancel-sign-sub-inv17.7%
metadata-eval17.7%
*-lft-identity17.7%
Simplified17.7%
div-inv17.8%
associate-*r*17.8%
metadata-eval17.8%
associate-*l*16.0%
count-216.0%
*-commutative16.0%
Applied egg-rr16.0%
if 1.1000000000000001e-67 < B Initial program 20.2%
Simplified25.3%
Taylor expanded in C around 0 19.4%
mul-1-neg19.4%
distribute-rgt-neg-in19.4%
+-commutative19.4%
unpow219.4%
unpow219.4%
hypot-def47.0%
Simplified47.0%
Taylor expanded in A around 0 41.6%
mul-1-neg41.6%
Simplified41.6%
Final simplification24.2%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 1.2e-67)
(/
(- (sqrt (* -8.0 (* C (* (* 2.0 A) (* A F))))))
(fma B B (* A (* C -4.0))))
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A B)))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 1.2e-67) {
tmp = -sqrt((-8.0 * (C * ((2.0 * A) * (A * F))))) / fma(B, B, (A * (C * -4.0)));
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 1.2e-67) tmp = Float64(Float64(-sqrt(Float64(-8.0 * Float64(C * Float64(Float64(2.0 * A) * Float64(A * F)))))) / fma(B, B, Float64(A * Float64(C * -4.0)))); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - B))))); end return tmp end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 1.2e-67], N[((-N[Sqrt[N[(-8.0 * N[(C * N[(N[(2.0 * A), $MachinePrecision] * N[(A * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 1.2 \cdot 10^{-67}:\\
\;\;\;\;\frac{-\sqrt{-8 \cdot \left(C \cdot \left(\left(2 \cdot A\right) \cdot \left(A \cdot F\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < 1.2e-67Initial program 28.9%
Simplified34.3%
Taylor expanded in C around inf 17.2%
associate-*r*17.7%
*-commutative17.7%
cancel-sign-sub-inv17.7%
metadata-eval17.7%
*-lft-identity17.7%
Simplified17.7%
expm1-log1p-u17.2%
expm1-udef10.7%
associate-*r*10.7%
metadata-eval10.7%
associate-*l*9.7%
count-29.7%
Applied egg-rr9.7%
expm1-def15.5%
expm1-log1p16.0%
associate-*r*16.0%
Simplified16.0%
if 1.2e-67 < B Initial program 20.2%
Simplified25.3%
Taylor expanded in C around 0 19.4%
mul-1-neg19.4%
distribute-rgt-neg-in19.4%
+-commutative19.4%
unpow219.4%
unpow219.4%
hypot-def47.0%
Simplified47.0%
Taylor expanded in A around 0 41.6%
mul-1-neg41.6%
Simplified41.6%
Final simplification24.2%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (/ (sqrt 2.0) B)))
(if (<= A -2.9e+194)
(* t_0 (- (sqrt (* 2.0 (* A F)))))
(* t_0 (- (sqrt (* F (- B))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt(2.0) / B;
double tmp;
if (A <= -2.9e+194) {
tmp = t_0 * -sqrt((2.0 * (A * F)));
} else {
tmp = t_0 * -sqrt((F * -B));
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(2.0d0) / b
if (a <= (-2.9d+194)) then
tmp = t_0 * -sqrt((2.0d0 * (a * f)))
else
tmp = t_0 * -sqrt((f * -b))
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = Math.sqrt(2.0) / B;
double tmp;
if (A <= -2.9e+194) {
tmp = t_0 * -Math.sqrt((2.0 * (A * F)));
} else {
tmp = t_0 * -Math.sqrt((F * -B));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt(2.0) / B tmp = 0 if A <= -2.9e+194: tmp = t_0 * -math.sqrt((2.0 * (A * F))) else: tmp = t_0 * -math.sqrt((F * -B)) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(sqrt(2.0) / B) tmp = 0.0 if (A <= -2.9e+194) tmp = Float64(t_0 * Float64(-sqrt(Float64(2.0 * Float64(A * F))))); else tmp = Float64(t_0 * Float64(-sqrt(Float64(F * Float64(-B))))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt(2.0) / B;
tmp = 0.0;
if (A <= -2.9e+194)
tmp = t_0 * -sqrt((2.0 * (A * F)));
else
tmp = t_0 * -sqrt((F * -B));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision]}, If[LessEqual[A, -2.9e+194], N[(t$95$0 * (-N[Sqrt[N[(2.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(t$95$0 * (-N[Sqrt[N[(F * (-B)), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \frac{\sqrt{2}}{B}\\
\mathbf{if}\;A \leq -2.9 \cdot 10^{+194}:\\
\;\;\;\;t_0 \cdot \left(-\sqrt{2 \cdot \left(A \cdot F\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(-\sqrt{F \cdot \left(-B\right)}\right)\\
\end{array}
\end{array}
if A < -2.9000000000000001e194Initial program 2.0%
Simplified24.2%
Taylor expanded in C around 0 1.2%
mul-1-neg1.2%
distribute-rgt-neg-in1.2%
+-commutative1.2%
unpow21.2%
unpow21.2%
hypot-def12.3%
Simplified12.3%
Taylor expanded in A around -inf 16.0%
if -2.9000000000000001e194 < A Initial program 28.8%
Simplified32.2%
Taylor expanded in C around 0 9.5%
mul-1-neg9.5%
distribute-rgt-neg-in9.5%
+-commutative9.5%
unpow29.5%
unpow29.5%
hypot-def18.9%
Simplified18.9%
Taylor expanded in A around 0 17.1%
associate-*r*17.1%
mul-1-neg17.1%
Simplified17.1%
Final simplification17.0%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (/ (sqrt 2.0) B)))
(if (<= A -1.55e+195)
(* t_0 (- (sqrt (* 2.0 (* A F)))))
(* t_0 (- (sqrt (* F (- A B))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt(2.0) / B;
double tmp;
if (A <= -1.55e+195) {
tmp = t_0 * -sqrt((2.0 * (A * F)));
} else {
tmp = t_0 * -sqrt((F * (A - B)));
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(2.0d0) / b
if (a <= (-1.55d+195)) then
tmp = t_0 * -sqrt((2.0d0 * (a * f)))
else
tmp = t_0 * -sqrt((f * (a - b)))
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = Math.sqrt(2.0) / B;
double tmp;
if (A <= -1.55e+195) {
tmp = t_0 * -Math.sqrt((2.0 * (A * F)));
} else {
tmp = t_0 * -Math.sqrt((F * (A - B)));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt(2.0) / B tmp = 0 if A <= -1.55e+195: tmp = t_0 * -math.sqrt((2.0 * (A * F))) else: tmp = t_0 * -math.sqrt((F * (A - B))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(sqrt(2.0) / B) tmp = 0.0 if (A <= -1.55e+195) tmp = Float64(t_0 * Float64(-sqrt(Float64(2.0 * Float64(A * F))))); else tmp = Float64(t_0 * Float64(-sqrt(Float64(F * Float64(A - B))))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt(2.0) / B;
tmp = 0.0;
if (A <= -1.55e+195)
tmp = t_0 * -sqrt((2.0 * (A * F)));
else
tmp = t_0 * -sqrt((F * (A - B)));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision]}, If[LessEqual[A, -1.55e+195], N[(t$95$0 * (-N[Sqrt[N[(2.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(t$95$0 * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \frac{\sqrt{2}}{B}\\
\mathbf{if}\;A \leq -1.55 \cdot 10^{+195}:\\
\;\;\;\;t_0 \cdot \left(-\sqrt{2 \cdot \left(A \cdot F\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if A < -1.5500000000000001e195Initial program 2.0%
Simplified24.2%
Taylor expanded in C around 0 1.2%
mul-1-neg1.2%
distribute-rgt-neg-in1.2%
+-commutative1.2%
unpow21.2%
unpow21.2%
hypot-def12.3%
Simplified12.3%
Taylor expanded in A around -inf 16.0%
if -1.5500000000000001e195 < A Initial program 28.8%
Simplified32.2%
Taylor expanded in C around 0 9.5%
mul-1-neg9.5%
distribute-rgt-neg-in9.5%
+-commutative9.5%
unpow29.5%
unpow29.5%
hypot-def18.9%
Simplified18.9%
Taylor expanded in A around 0 16.3%
mul-1-neg16.3%
Simplified16.3%
Final simplification16.3%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* (/ (sqrt 2.0) B) (- (sqrt (* F (- B))))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return (sqrt(2.0) / B) * -sqrt((F * -B));
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (sqrt(2.0d0) / b) * -sqrt((f * -b))
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return (Math.sqrt(2.0) / B) * -Math.sqrt((F * -B));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return (math.sqrt(2.0) / B) * -math.sqrt((F * -B))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(-B))))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = (sqrt(2.0) / B) * -sqrt((F * -B));
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * (-B)), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(-B\right)}\right)
\end{array}
Initial program 26.1%
Simplified31.4%
Taylor expanded in C around 0 8.6%
mul-1-neg8.6%
distribute-rgt-neg-in8.6%
+-commutative8.6%
unpow28.6%
unpow28.6%
hypot-def18.3%
Simplified18.3%
Taylor expanded in A around 0 15.7%
associate-*r*15.7%
mul-1-neg15.7%
Simplified15.7%
Final simplification15.7%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* (sqrt (* C F)) (/ (- (sqrt 2.0)) B)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return sqrt((C * F)) * (-sqrt(2.0) / B);
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = sqrt((c * f)) * (-sqrt(2.0d0) / b)
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return Math.sqrt((C * F)) * (-Math.sqrt(2.0) / B);
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return math.sqrt((C * F)) * (-math.sqrt(2.0) / B)
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(sqrt(Float64(C * F)) * Float64(Float64(-sqrt(2.0)) / B)) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = sqrt((C * F)) * (-sqrt(2.0) / B);
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(N[Sqrt[N[(C * F), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\sqrt{C \cdot F} \cdot \frac{-\sqrt{2}}{B}
\end{array}
Initial program 26.1%
Simplified26.1%
Taylor expanded in A around inf 3.9%
Taylor expanded in B around inf 2.2%
mul-1-neg2.2%
Simplified2.2%
Final simplification2.2%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* (sqrt (/ F B)) (- (sqrt 2.0))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return sqrt((F / B)) * -sqrt(2.0);
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = sqrt((f / b)) * -sqrt(2.0d0)
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return Math.sqrt((F / B)) * -Math.sqrt(2.0);
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return math.sqrt((F / B)) * -math.sqrt(2.0)
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(sqrt(Float64(F / B)) * Float64(-sqrt(2.0))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = sqrt((F / B)) * -sqrt(2.0);
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(N[Sqrt[N[(F / B), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\sqrt{\frac{F}{B}} \cdot \left(-\sqrt{2}\right)
\end{array}
Initial program 26.1%
Simplified31.9%
Taylor expanded in B around -inf 7.9%
Taylor expanded in A around 0 14.2%
Final simplification14.2%
herbie shell --seed 2023333
(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))))