
(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 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (hypot B (- A C)))
(t_1 (fma A (* C -4.0) (pow B 2.0)))
(t_2 (fma B B (* A (* C -4.0)))))
(if (<= C -2.4e-180)
(/ (* (sqrt (* A -8.0)) (- (sqrt (* C (* F (* A 2.0)))))) t_1)
(if (<= C 4e-40)
(/ (* (sqrt (* F (+ A (- C t_0)))) (- (sqrt (* 2.0 t_1)))) t_1)
(/
(-
(sqrt
(*
(* t_2 (* F 2.0))
(+
A
(/ (- (* 2.0 (* C A)) (+ (pow B 2.0) (pow A 2.0))) (+ C t_0))))))
t_2)))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = hypot(B, (A - C));
double t_1 = fma(A, (C * -4.0), pow(B, 2.0));
double t_2 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (C <= -2.4e-180) {
tmp = (sqrt((A * -8.0)) * -sqrt((C * (F * (A * 2.0))))) / t_1;
} else if (C <= 4e-40) {
tmp = (sqrt((F * (A + (C - t_0)))) * -sqrt((2.0 * t_1))) / t_1;
} else {
tmp = -sqrt(((t_2 * (F * 2.0)) * (A + (((2.0 * (C * A)) - (pow(B, 2.0) + pow(A, 2.0))) / (C + t_0))))) / t_2;
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = hypot(B, Float64(A - C)) t_1 = fma(A, Float64(C * -4.0), (B ^ 2.0)) t_2 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (C <= -2.4e-180) tmp = Float64(Float64(sqrt(Float64(A * -8.0)) * Float64(-sqrt(Float64(C * Float64(F * Float64(A * 2.0)))))) / t_1); elseif (C <= 4e-40) tmp = Float64(Float64(sqrt(Float64(F * Float64(A + Float64(C - t_0)))) * Float64(-sqrt(Float64(2.0 * t_1)))) / t_1); else tmp = Float64(Float64(-sqrt(Float64(Float64(t_2 * Float64(F * 2.0)) * Float64(A + Float64(Float64(Float64(2.0 * Float64(C * A)) - Float64((B ^ 2.0) + (A ^ 2.0))) / Float64(C + t_0)))))) / t_2); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$1 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[C, -2.4e-180], N[(N[(N[Sqrt[N[(A * -8.0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(C * N[(F * N[(A * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[C, 4e-40], N[(N[(N[Sqrt[N[(F * N[(A + N[(C - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(2.0 * t$95$1), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], N[((-N[Sqrt[N[(N[(t$95$2 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision] * N[(A + N[(N[(N[(2.0 * N[(C * A), $MachinePrecision]), $MachinePrecision] - N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(C + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(B, A - C\right)\\
t_1 := \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)\\
t_2 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;C \leq -2.4 \cdot 10^{-180}:\\
\;\;\;\;\frac{\sqrt{A \cdot -8} \cdot \left(-\sqrt{C \cdot \left(F \cdot \left(A \cdot 2\right)\right)}\right)}{t_1}\\
\mathbf{elif}\;C \leq 4 \cdot 10^{-40}:\\
\;\;\;\;\frac{\sqrt{F \cdot \left(A + \left(C - t_0\right)\right)} \cdot \left(-\sqrt{2 \cdot t_1}\right)}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{\left(t_2 \cdot \left(F \cdot 2\right)\right) \cdot \left(A + \frac{2 \cdot \left(C \cdot A\right) - \left({B}^{2} + {A}^{2}\right)}{C + t_0}\right)}}{t_2}\\
\end{array}
\end{array}
if C < -2.39999999999999979e-180Initial program 21.0%
Simplified19.0%
Taylor expanded in C around inf 6.5%
mul-1-neg6.5%
Simplified6.5%
associate-*r*6.5%
sqrt-prod9.5%
*-commutative9.5%
*-un-lft-identity9.5%
metadata-eval9.5%
neg-mul-19.5%
distribute-rgt-out--9.5%
metadata-eval9.5%
metadata-eval9.5%
*-commutative9.5%
Applied egg-rr9.5%
if -2.39999999999999979e-180 < C < 3.9999999999999997e-40Initial program 26.9%
Simplified28.4%
associate-*r*29.6%
sqrt-prod36.3%
Applied egg-rr36.3%
if 3.9999999999999997e-40 < C Initial program 8.5%
Simplified13.4%
flip--10.6%
pow110.6%
metadata-eval10.6%
pow110.6%
metadata-eval10.6%
pow-sqr10.6%
metadata-eval10.6%
metadata-eval10.6%
pow110.6%
metadata-eval10.6%
pow110.6%
metadata-eval10.6%
pow-sqr10.6%
metadata-eval10.6%
metadata-eval10.6%
Applied egg-rr10.6%
Taylor expanded in C around 0 37.0%
mul-1-neg37.0%
+-commutative37.0%
Simplified37.0%
Final simplification26.4%
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 (- (pow B 2.0) (* (* C A) 4.0)))
(t_2 (- (pow B 2.0) (* C (* A 4.0))))
(t_3
(/
(-
(sqrt
(*
(* 2.0 (* F t_2))
(- (+ C A) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_2))
(t_4 (* F (* A 2.0)))
(t_5 (fma B B (* A (* C -4.0)))))
(if (<= t_3 (- INFINITY))
(/ (* (sqrt (* 2.0 t_0)) (- (sqrt t_4))) t_1)
(if (<= t_3 -2e-101)
t_3
(if (<= t_3 0.0)
(/
(-
(sqrt
(*
(* t_5 (* F 2.0))
(+
A
(/ (- (* 2.0 (* C A)) (pow B 2.0)) (+ C (hypot B (- A C))))))))
t_5)
(if (<= t_3 INFINITY)
(/ (* (sqrt (* A -8.0)) (- (sqrt (* C t_4)))) t_0)
(/ (* (sqrt (* 2.0 (* t_0 (* F 2.0)))) (- (sqrt A))) t_1)))))))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 = pow(B, 2.0) - ((C * A) * 4.0);
double t_2 = pow(B, 2.0) - (C * (A * 4.0));
double t_3 = -sqrt(((2.0 * (F * t_2)) * ((C + A) - sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_2;
double t_4 = F * (A * 2.0);
double t_5 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = (sqrt((2.0 * t_0)) * -sqrt(t_4)) / t_1;
} else if (t_3 <= -2e-101) {
tmp = t_3;
} else if (t_3 <= 0.0) {
tmp = -sqrt(((t_5 * (F * 2.0)) * (A + (((2.0 * (C * A)) - pow(B, 2.0)) / (C + hypot(B, (A - C))))))) / t_5;
} else if (t_3 <= ((double) INFINITY)) {
tmp = (sqrt((A * -8.0)) * -sqrt((C * t_4))) / t_0;
} else {
tmp = (sqrt((2.0 * (t_0 * (F * 2.0)))) * -sqrt(A)) / t_1;
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(A, Float64(C * -4.0), (B ^ 2.0)) t_1 = Float64((B ^ 2.0) - Float64(Float64(C * A) * 4.0)) t_2 = Float64((B ^ 2.0) - Float64(C * Float64(A * 4.0))) t_3 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_2)) * Float64(Float64(C + A) - sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_2) t_4 = Float64(F * Float64(A * 2.0)) t_5 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(Float64(sqrt(Float64(2.0 * t_0)) * Float64(-sqrt(t_4))) / t_1); elseif (t_3 <= -2e-101) tmp = t_3; elseif (t_3 <= 0.0) tmp = Float64(Float64(-sqrt(Float64(Float64(t_5 * Float64(F * 2.0)) * Float64(A + Float64(Float64(Float64(2.0 * Float64(C * A)) - (B ^ 2.0)) / Float64(C + hypot(B, Float64(A - C)))))))) / t_5); elseif (t_3 <= Inf) tmp = Float64(Float64(sqrt(Float64(A * -8.0)) * Float64(-sqrt(Float64(C * t_4)))) / t_0); else tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(t_0 * Float64(F * 2.0)))) * Float64(-sqrt(A))) / t_1); end return tmp end
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[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(C * A), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[((-N[Sqrt[N[(N[(2.0 * N[(F * t$95$2), $MachinePrecision]), $MachinePrecision] * N[(N[(C + A), $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]}, Block[{t$95$4 = N[(F * N[(A * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(N[(N[Sqrt[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[t$95$4], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$3, -2e-101], t$95$3, If[LessEqual[t$95$3, 0.0], N[((-N[Sqrt[N[(N[(t$95$5 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision] * N[(A + N[(N[(N[(2.0 * N[(C * A), $MachinePrecision]), $MachinePrecision] - N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision] / N[(C + N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$5), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(N[(N[Sqrt[N[(A * -8.0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(C * t$95$4), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[A], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)\\
t_1 := {B}^{2} - \left(C \cdot A\right) \cdot 4\\
t_2 := {B}^{2} - C \cdot \left(A \cdot 4\right)\\
t_3 := \frac{-\sqrt{\left(2 \cdot \left(F \cdot t_2\right)\right) \cdot \left(\left(C + A\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\
t_4 := F \cdot \left(A \cdot 2\right)\\
t_5 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;\frac{\sqrt{2 \cdot t_0} \cdot \left(-\sqrt{t_4}\right)}{t_1}\\
\mathbf{elif}\;t_3 \leq -2 \cdot 10^{-101}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;\frac{-\sqrt{\left(t_5 \cdot \left(F \cdot 2\right)\right) \cdot \left(A + \frac{2 \cdot \left(C \cdot A\right) - {B}^{2}}{C + \mathsf{hypot}\left(B, A - C\right)}\right)}}{t_5}\\
\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{\sqrt{A \cdot -8} \cdot \left(-\sqrt{C \cdot t_4}\right)}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot 2\right)\right)} \cdot \left(-\sqrt{A}\right)}{t_1}\\
\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))) < -inf.0Initial program 3.0%
Simplified3.0%
Taylor expanded in A around -inf 8.7%
associate-*l*9.0%
sqrt-prod15.8%
Applied egg-rr15.8%
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))) < -2.0000000000000001e-101Initial program 99.4%
if -2.0000000000000001e-101 < (/.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))) < 0.0Initial program 13.4%
Simplified17.6%
flip--17.6%
pow117.6%
metadata-eval17.6%
pow117.6%
metadata-eval17.6%
pow-sqr17.6%
metadata-eval17.6%
metadata-eval17.6%
pow117.6%
metadata-eval17.6%
pow117.6%
metadata-eval17.6%
pow-sqr17.6%
metadata-eval17.6%
metadata-eval17.6%
Applied egg-rr17.6%
Taylor expanded in A around 0 37.9%
mul-1-neg37.9%
Simplified37.9%
if 0.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))) < +inf.0Initial program 52.0%
Simplified43.1%
Taylor expanded in C around inf 26.4%
mul-1-neg26.4%
Simplified26.4%
associate-*r*26.4%
sqrt-prod36.2%
*-commutative36.2%
*-un-lft-identity36.2%
metadata-eval36.2%
neg-mul-136.2%
distribute-rgt-out--36.2%
metadata-eval36.2%
metadata-eval36.2%
*-commutative36.2%
Applied egg-rr36.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.0%
Taylor expanded in A around -inf 5.6%
associate-*r*5.6%
sqrt-prod9.6%
*-commutative9.6%
*-commutative9.6%
associate-*l*9.6%
cancel-sign-sub-inv9.6%
metadata-eval9.6%
*-commutative9.6%
associate-*r*9.6%
+-commutative9.6%
fma-udef9.6%
Applied egg-rr9.6%
Final simplification28.9%
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 (- (pow B 2.0) (* (* C A) 4.0)))
(t_2 (- (pow B 2.0) (* C (* A 4.0))))
(t_3
(/
(-
(sqrt
(*
(* 2.0 (* F t_2))
(- (+ C A) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_2))
(t_4 (* F (* A 2.0)))
(t_5 (fma B B (* A (* C -4.0)))))
(if (<= t_3 (- INFINITY))
(/ (* (sqrt (* 2.0 t_0)) (- (sqrt t_4))) t_1)
(if (<= t_3 -2e-189)
t_3
(if (<= t_3 5e+87)
(/
(-
(sqrt
(*
(* t_5 (* F 2.0))
(+
A
(+
A
(/
(* -0.5 (- (+ (pow B 2.0) (pow A 2.0)) (pow (- A) 2.0)))
C))))))
t_5)
(if (<= t_3 INFINITY)
(/ (* (sqrt (* A -8.0)) (- (sqrt (* C t_4)))) t_0)
(/ (* (sqrt (* 2.0 (* t_0 (* F 2.0)))) (- (sqrt A))) t_1)))))))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 = pow(B, 2.0) - ((C * A) * 4.0);
double t_2 = pow(B, 2.0) - (C * (A * 4.0));
double t_3 = -sqrt(((2.0 * (F * t_2)) * ((C + A) - sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_2;
double t_4 = F * (A * 2.0);
double t_5 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = (sqrt((2.0 * t_0)) * -sqrt(t_4)) / t_1;
} else if (t_3 <= -2e-189) {
tmp = t_3;
} else if (t_3 <= 5e+87) {
tmp = -sqrt(((t_5 * (F * 2.0)) * (A + (A + ((-0.5 * ((pow(B, 2.0) + pow(A, 2.0)) - pow(-A, 2.0))) / C))))) / t_5;
} else if (t_3 <= ((double) INFINITY)) {
tmp = (sqrt((A * -8.0)) * -sqrt((C * t_4))) / t_0;
} else {
tmp = (sqrt((2.0 * (t_0 * (F * 2.0)))) * -sqrt(A)) / t_1;
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(A, Float64(C * -4.0), (B ^ 2.0)) t_1 = Float64((B ^ 2.0) - Float64(Float64(C * A) * 4.0)) t_2 = Float64((B ^ 2.0) - Float64(C * Float64(A * 4.0))) t_3 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_2)) * Float64(Float64(C + A) - sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_2) t_4 = Float64(F * Float64(A * 2.0)) t_5 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(Float64(sqrt(Float64(2.0 * t_0)) * Float64(-sqrt(t_4))) / t_1); elseif (t_3 <= -2e-189) tmp = t_3; elseif (t_3 <= 5e+87) tmp = Float64(Float64(-sqrt(Float64(Float64(t_5 * Float64(F * 2.0)) * Float64(A + Float64(A + Float64(Float64(-0.5 * Float64(Float64((B ^ 2.0) + (A ^ 2.0)) - (Float64(-A) ^ 2.0))) / C)))))) / t_5); elseif (t_3 <= Inf) tmp = Float64(Float64(sqrt(Float64(A * -8.0)) * Float64(-sqrt(Float64(C * t_4)))) / t_0); else tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(t_0 * Float64(F * 2.0)))) * Float64(-sqrt(A))) / t_1); end return tmp end
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[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(C * A), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[((-N[Sqrt[N[(N[(2.0 * N[(F * t$95$2), $MachinePrecision]), $MachinePrecision] * N[(N[(C + A), $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]}, Block[{t$95$4 = N[(F * N[(A * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(N[(N[Sqrt[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[t$95$4], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$3, -2e-189], t$95$3, If[LessEqual[t$95$3, 5e+87], N[((-N[Sqrt[N[(N[(t$95$5 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision] * N[(A + N[(A + N[(N[(-0.5 * N[(N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision] - N[Power[(-A), 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$5), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(N[(N[Sqrt[N[(A * -8.0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(C * t$95$4), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[A], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)\\
t_1 := {B}^{2} - \left(C \cdot A\right) \cdot 4\\
t_2 := {B}^{2} - C \cdot \left(A \cdot 4\right)\\
t_3 := \frac{-\sqrt{\left(2 \cdot \left(F \cdot t_2\right)\right) \cdot \left(\left(C + A\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\
t_4 := F \cdot \left(A \cdot 2\right)\\
t_5 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;\frac{\sqrt{2 \cdot t_0} \cdot \left(-\sqrt{t_4}\right)}{t_1}\\
\mathbf{elif}\;t_3 \leq -2 \cdot 10^{-189}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_3 \leq 5 \cdot 10^{+87}:\\
\;\;\;\;\frac{-\sqrt{\left(t_5 \cdot \left(F \cdot 2\right)\right) \cdot \left(A + \left(A + \frac{-0.5 \cdot \left(\left({B}^{2} + {A}^{2}\right) - {\left(-A\right)}^{2}\right)}{C}\right)\right)}}{t_5}\\
\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{\sqrt{A \cdot -8} \cdot \left(-\sqrt{C \cdot t_4}\right)}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot 2\right)\right)} \cdot \left(-\sqrt{A}\right)}{t_1}\\
\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))) < -inf.0Initial program 3.0%
Simplified3.0%
Taylor expanded in A around -inf 8.7%
associate-*l*9.0%
sqrt-prod15.8%
Applied egg-rr15.8%
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))) < -2.00000000000000014e-189Initial program 99.4%
if -2.00000000000000014e-189 < (/.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))) < 4.9999999999999998e87Initial program 24.7%
Simplified28.3%
Taylor expanded in C around inf 33.8%
associate-*r/33.8%
+-commutative33.8%
mul-1-neg33.8%
Simplified33.8%
if 4.9999999999999998e87 < (/.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 12.1%
Simplified12.1%
Taylor expanded in C around inf 12.6%
mul-1-neg12.6%
Simplified12.6%
associate-*r*12.6%
sqrt-prod29.5%
*-commutative29.5%
*-un-lft-identity29.5%
metadata-eval29.5%
neg-mul-129.5%
distribute-rgt-out--29.5%
metadata-eval29.5%
metadata-eval29.5%
*-commutative29.5%
Applied egg-rr29.5%
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.0%
Taylor expanded in A around -inf 5.6%
associate-*r*5.6%
sqrt-prod9.6%
*-commutative9.6%
*-commutative9.6%
associate-*l*9.6%
cancel-sign-sub-inv9.6%
metadata-eval9.6%
*-commutative9.6%
associate-*r*9.6%
+-commutative9.6%
fma-udef9.6%
Applied egg-rr9.6%
Final simplification28.9%
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))))
(t_2 (* F (* A 2.0)))
(t_3 (- (pow B 2.0) (* (* C A) 4.0)))
(t_4 (- (pow B 2.0) (* C (* A 4.0))))
(t_5
(/
(-
(sqrt
(*
(* 2.0 (* F t_4))
(- (+ C A) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_4)))
(if (<= t_5 (- INFINITY))
(/ (* (sqrt (* 2.0 t_0)) (- (sqrt t_2))) t_3)
(if (<= t_5 5e+87)
(/
(-
(sqrt
(*
(* t_1 (* F 2.0))
(+
A
(/
(- (* 2.0 (* C A)) (+ (pow B 2.0) (pow A 2.0)))
(+ C (hypot B (- A C))))))))
t_1)
(if (<= t_5 INFINITY)
(/ (* (sqrt (* A -8.0)) (- (sqrt (* C t_2)))) t_0)
(/ (* (sqrt (* 2.0 (* t_0 (* F 2.0)))) (- (sqrt A))) t_3))))))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 t_2 = F * (A * 2.0);
double t_3 = pow(B, 2.0) - ((C * A) * 4.0);
double t_4 = pow(B, 2.0) - (C * (A * 4.0));
double t_5 = -sqrt(((2.0 * (F * t_4)) * ((C + A) - sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_4;
double tmp;
if (t_5 <= -((double) INFINITY)) {
tmp = (sqrt((2.0 * t_0)) * -sqrt(t_2)) / t_3;
} else if (t_5 <= 5e+87) {
tmp = -sqrt(((t_1 * (F * 2.0)) * (A + (((2.0 * (C * A)) - (pow(B, 2.0) + pow(A, 2.0))) / (C + hypot(B, (A - C))))))) / t_1;
} else if (t_5 <= ((double) INFINITY)) {
tmp = (sqrt((A * -8.0)) * -sqrt((C * t_2))) / t_0;
} else {
tmp = (sqrt((2.0 * (t_0 * (F * 2.0)))) * -sqrt(A)) / t_3;
}
return tmp;
}
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))) t_2 = Float64(F * Float64(A * 2.0)) t_3 = Float64((B ^ 2.0) - Float64(Float64(C * A) * 4.0)) t_4 = Float64((B ^ 2.0) - Float64(C * Float64(A * 4.0))) t_5 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_4)) * Float64(Float64(C + A) - sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_4) tmp = 0.0 if (t_5 <= Float64(-Inf)) tmp = Float64(Float64(sqrt(Float64(2.0 * t_0)) * Float64(-sqrt(t_2))) / t_3); elseif (t_5 <= 5e+87) tmp = Float64(Float64(-sqrt(Float64(Float64(t_1 * Float64(F * 2.0)) * Float64(A + Float64(Float64(Float64(2.0 * Float64(C * A)) - Float64((B ^ 2.0) + (A ^ 2.0))) / Float64(C + hypot(B, Float64(A - C)))))))) / t_1); elseif (t_5 <= Inf) tmp = Float64(Float64(sqrt(Float64(A * -8.0)) * Float64(-sqrt(Float64(C * t_2)))) / t_0); else tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(t_0 * Float64(F * 2.0)))) * Float64(-sqrt(A))) / t_3); end return tmp end
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]}, Block[{t$95$2 = N[(F * N[(A * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(C * A), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[((-N[Sqrt[N[(N[(2.0 * N[(F * t$95$4), $MachinePrecision]), $MachinePrecision] * N[(N[(C + A), $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$4), $MachinePrecision]}, If[LessEqual[t$95$5, (-Infinity)], N[(N[(N[Sqrt[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[t$95$2], $MachinePrecision])), $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[t$95$5, 5e+87], N[((-N[Sqrt[N[(N[(t$95$1 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision] * N[(A + N[(N[(N[(2.0 * N[(C * A), $MachinePrecision]), $MachinePrecision] - N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(C + N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[t$95$5, Infinity], N[(N[(N[Sqrt[N[(A * -8.0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(C * t$95$2), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[A], $MachinePrecision])), $MachinePrecision] / t$95$3), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
[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)\\
t_2 := F \cdot \left(A \cdot 2\right)\\
t_3 := {B}^{2} - \left(C \cdot A\right) \cdot 4\\
t_4 := {B}^{2} - C \cdot \left(A \cdot 4\right)\\
t_5 := \frac{-\sqrt{\left(2 \cdot \left(F \cdot t_4\right)\right) \cdot \left(\left(C + A\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_4}\\
\mathbf{if}\;t_5 \leq -\infty:\\
\;\;\;\;\frac{\sqrt{2 \cdot t_0} \cdot \left(-\sqrt{t_2}\right)}{t_3}\\
\mathbf{elif}\;t_5 \leq 5 \cdot 10^{+87}:\\
\;\;\;\;\frac{-\sqrt{\left(t_1 \cdot \left(F \cdot 2\right)\right) \cdot \left(A + \frac{2 \cdot \left(C \cdot A\right) - \left({B}^{2} + {A}^{2}\right)}{C + \mathsf{hypot}\left(B, A - C\right)}\right)}}{t_1}\\
\mathbf{elif}\;t_5 \leq \infty:\\
\;\;\;\;\frac{\sqrt{A \cdot -8} \cdot \left(-\sqrt{C \cdot t_2}\right)}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot 2\right)\right)} \cdot \left(-\sqrt{A}\right)}{t_3}\\
\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))) < -inf.0Initial program 3.0%
Simplified3.0%
Taylor expanded in A around -inf 8.7%
associate-*l*9.0%
sqrt-prod15.8%
Applied egg-rr15.8%
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))) < 4.9999999999999998e87Initial program 58.0%
Simplified60.0%
flip--46.8%
pow146.8%
metadata-eval46.8%
pow146.8%
metadata-eval46.8%
pow-sqr46.8%
metadata-eval46.8%
metadata-eval46.8%
pow146.8%
metadata-eval46.8%
pow146.8%
metadata-eval46.8%
pow-sqr46.8%
metadata-eval46.8%
metadata-eval46.8%
Applied egg-rr46.8%
Taylor expanded in C around 0 57.2%
mul-1-neg57.2%
+-commutative57.2%
Simplified57.2%
if 4.9999999999999998e87 < (/.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 12.1%
Simplified12.1%
Taylor expanded in C around inf 12.6%
mul-1-neg12.6%
Simplified12.6%
associate-*r*12.6%
sqrt-prod29.5%
*-commutative29.5%
*-un-lft-identity29.5%
metadata-eval29.5%
neg-mul-129.5%
distribute-rgt-out--29.5%
metadata-eval29.5%
metadata-eval29.5%
*-commutative29.5%
Applied egg-rr29.5%
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.0%
Taylor expanded in A around -inf 5.6%
associate-*r*5.6%
sqrt-prod9.6%
*-commutative9.6%
*-commutative9.6%
associate-*l*9.6%
cancel-sign-sub-inv9.6%
metadata-eval9.6%
*-commutative9.6%
associate-*r*9.6%
+-commutative9.6%
fma-udef9.6%
Applied egg-rr9.6%
Final simplification27.0%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* C A) 4.0))) (t_1 (fma B B (* A (* C -4.0)))))
(if (<= A -1.1e-23)
(/ (- (sqrt (* (* A 2.0) (* F (* 2.0 t_0))))) t_0)
(if (or (<= A -2.6e-304) (not (<= A 5e-220)))
(/
(-
(sqrt
(*
(* t_1 (* F 2.0))
(+ A (/ (- (* 2.0 (* C A)) (pow B 2.0)) (+ C (hypot B (- A C))))))))
t_1)
(/
(*
(sqrt (* 2.0 (* (fma A (* C -4.0) (pow B 2.0)) (* F 2.0))))
(- (sqrt A)))
t_0)))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((C * A) * 4.0);
double t_1 = fma(B, B, (A * (C * -4.0)));
double tmp;
if (A <= -1.1e-23) {
tmp = -sqrt(((A * 2.0) * (F * (2.0 * t_0)))) / t_0;
} else if ((A <= -2.6e-304) || !(A <= 5e-220)) {
tmp = -sqrt(((t_1 * (F * 2.0)) * (A + (((2.0 * (C * A)) - pow(B, 2.0)) / (C + hypot(B, (A - C))))))) / t_1;
} else {
tmp = (sqrt((2.0 * (fma(A, (C * -4.0), pow(B, 2.0)) * (F * 2.0)))) * -sqrt(A)) / t_0;
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(C * A) * 4.0)) t_1 = fma(B, B, Float64(A * Float64(C * -4.0))) tmp = 0.0 if (A <= -1.1e-23) tmp = Float64(Float64(-sqrt(Float64(Float64(A * 2.0) * Float64(F * Float64(2.0 * t_0))))) / t_0); elseif ((A <= -2.6e-304) || !(A <= 5e-220)) tmp = Float64(Float64(-sqrt(Float64(Float64(t_1 * Float64(F * 2.0)) * Float64(A + Float64(Float64(Float64(2.0 * Float64(C * A)) - (B ^ 2.0)) / Float64(C + hypot(B, Float64(A - C)))))))) / t_1); else tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(fma(A, Float64(C * -4.0), (B ^ 2.0)) * Float64(F * 2.0)))) * Float64(-sqrt(A))) / t_0); end return tmp end
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[Power[B, 2.0], $MachinePrecision] - N[(N[(C * A), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[A, -1.1e-23], N[((-N[Sqrt[N[(N[(A * 2.0), $MachinePrecision] * N[(F * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[Or[LessEqual[A, -2.6e-304], N[Not[LessEqual[A, 5e-220]], $MachinePrecision]], N[((-N[Sqrt[N[(N[(t$95$1 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision] * N[(A + N[(N[(N[(2.0 * N[(C * A), $MachinePrecision]), $MachinePrecision] - N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision] / N[(C + N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[(N[(N[Sqrt[N[(2.0 * N[(N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision] * N[(F * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[A], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(C \cdot A\right) \cdot 4\\
t_1 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;A \leq -1.1 \cdot 10^{-23}:\\
\;\;\;\;\frac{-\sqrt{\left(A \cdot 2\right) \cdot \left(F \cdot \left(2 \cdot t_0\right)\right)}}{t_0}\\
\mathbf{elif}\;A \leq -2.6 \cdot 10^{-304} \lor \neg \left(A \leq 5 \cdot 10^{-220}\right):\\
\;\;\;\;\frac{-\sqrt{\left(t_1 \cdot \left(F \cdot 2\right)\right) \cdot \left(A + \frac{2 \cdot \left(C \cdot A\right) - {B}^{2}}{C + \mathsf{hypot}\left(B, A - C\right)}\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right) \cdot \left(F \cdot 2\right)\right)} \cdot \left(-\sqrt{A}\right)}{t_0}\\
\end{array}
\end{array}
if A < -1.1e-23Initial program 22.9%
Simplified22.9%
Taylor expanded in A around -inf 27.5%
if -1.1e-23 < A < -2.59999999999999997e-304 or 5.0000000000000002e-220 < A Initial program 19.4%
Simplified24.0%
flip--13.8%
pow113.8%
metadata-eval13.8%
pow113.8%
metadata-eval13.8%
pow-sqr13.8%
metadata-eval13.8%
metadata-eval13.8%
pow113.8%
metadata-eval13.8%
pow113.8%
metadata-eval13.8%
pow-sqr13.8%
metadata-eval13.8%
metadata-eval13.8%
Applied egg-rr13.8%
Taylor expanded in A around 0 23.3%
mul-1-neg23.3%
Simplified23.3%
if -2.59999999999999997e-304 < A < 5.0000000000000002e-220Initial program 13.4%
Simplified13.4%
Taylor expanded in A around -inf 2.6%
associate-*r*2.6%
sqrt-prod31.5%
*-commutative31.5%
*-commutative31.5%
associate-*l*31.5%
cancel-sign-sub-inv31.5%
metadata-eval31.5%
*-commutative31.5%
associate-*r*31.5%
+-commutative31.5%
fma-udef31.5%
Applied egg-rr31.5%
Final simplification24.9%
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 (* t_0 (* F 2.0))))
(if (<= (pow B 2.0) 1e+69)
(/ (- (sqrt (* t_1 (+ A A)))) t_0)
(if (<= (pow B 2.0) 4e+258)
(/ (- (sqrt (* t_1 (- A B)))) t_0)
(* -2.0 (* (sqrt (* A F)) (/ 1.0 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 = t_0 * (F * 2.0);
double tmp;
if (pow(B, 2.0) <= 1e+69) {
tmp = -sqrt((t_1 * (A + A))) / t_0;
} else if (pow(B, 2.0) <= 4e+258) {
tmp = -sqrt((t_1 * (A - B))) / t_0;
} else {
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
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(t_0 * Float64(F * 2.0)) tmp = 0.0 if ((B ^ 2.0) <= 1e+69) tmp = Float64(Float64(-sqrt(Float64(t_1 * Float64(A + A)))) / t_0); elseif ((B ^ 2.0) <= 4e+258) tmp = Float64(Float64(-sqrt(Float64(t_1 * Float64(A - B)))) / t_0); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); end return tmp end
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[(t$95$0 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 1e+69], N[((-N[Sqrt[N[(t$95$1 * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 4e+258], N[((-N[Sqrt[N[(t$95$1 * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[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 := t_0 \cdot \left(F \cdot 2\right)\\
\mathbf{if}\;{B}^{2} \leq 10^{+69}:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \left(A + A\right)}}{t_0}\\
\mathbf{elif}\;{B}^{2} \leq 4 \cdot 10^{+258}:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \left(A - B\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 1.0000000000000001e69Initial program 24.3%
Simplified30.8%
Taylor expanded in C around inf 22.3%
if 1.0000000000000001e69 < (pow.f64 B 2) < 4.00000000000000023e258Initial program 36.5%
Simplified43.7%
Taylor expanded in B around inf 22.9%
mul-1-neg22.9%
Simplified22.9%
if 4.00000000000000023e258 < (pow.f64 B 2) Initial program 0.3%
Simplified0.3%
Taylor expanded in A around -inf 0.2%
Taylor expanded in B around inf 2.3%
Final simplification17.0%
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) (* (* C A) 4.0))))
(if (<= (pow B 2.0) 1e+69)
(/ (- (sqrt (* (* A 2.0) (* F (* 2.0 t_1))))) t_1)
(if (<= (pow B 2.0) 4e+258)
(/ (- (sqrt (* (* t_0 (* F 2.0)) (- A B)))) t_0)
(* -2.0 (* (sqrt (* A F)) (/ 1.0 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) - ((C * A) * 4.0);
double tmp;
if (pow(B, 2.0) <= 1e+69) {
tmp = -sqrt(((A * 2.0) * (F * (2.0 * t_1)))) / t_1;
} else if (pow(B, 2.0) <= 4e+258) {
tmp = -sqrt(((t_0 * (F * 2.0)) * (A - B))) / t_0;
} else {
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
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(C * A) * 4.0)) tmp = 0.0 if ((B ^ 2.0) <= 1e+69) tmp = Float64(Float64(-sqrt(Float64(Float64(A * 2.0) * Float64(F * Float64(2.0 * t_1))))) / t_1); elseif ((B ^ 2.0) <= 4e+258) tmp = Float64(Float64(-sqrt(Float64(Float64(t_0 * Float64(F * 2.0)) * Float64(A - B)))) / t_0); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); end return tmp end
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[(C * A), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 1e+69], N[((-N[Sqrt[N[(N[(A * 2.0), $MachinePrecision] * N[(F * N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 4e+258], N[((-N[Sqrt[N[(N[(t$95$0 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision] * N[(A - B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[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(C \cdot A\right) \cdot 4\\
\mathbf{if}\;{B}^{2} \leq 10^{+69}:\\
\;\;\;\;\frac{-\sqrt{\left(A \cdot 2\right) \cdot \left(F \cdot \left(2 \cdot t_1\right)\right)}}{t_1}\\
\mathbf{elif}\;{B}^{2} \leq 4 \cdot 10^{+258}:\\
\;\;\;\;\frac{-\sqrt{\left(t_0 \cdot \left(F \cdot 2\right)\right) \cdot \left(A - B\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 1.0000000000000001e69Initial program 24.3%
Simplified24.3%
Taylor expanded in A around -inf 22.3%
if 1.0000000000000001e69 < (pow.f64 B 2) < 4.00000000000000023e258Initial program 36.5%
Simplified43.7%
Taylor expanded in B around inf 22.9%
mul-1-neg22.9%
Simplified22.9%
if 4.00000000000000023e258 < (pow.f64 B 2) Initial program 0.3%
Simplified0.3%
Taylor expanded in A around -inf 0.2%
Taylor expanded in B around inf 2.3%
Final simplification17.0%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* C A) 4.0))))
(if (<= (pow B 2.0) 5e+32)
(/ (- (sqrt (* (* A 2.0) (* F (* 2.0 t_0))))) t_0)
(/
(- (sqrt (* (+ A (- C (hypot B (- A C)))) (* 2.0 (* F (pow B 2.0))))))
(fma B B (* A (* C -4.0)))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((C * A) * 4.0);
double tmp;
if (pow(B, 2.0) <= 5e+32) {
tmp = -sqrt(((A * 2.0) * (F * (2.0 * t_0)))) / t_0;
} else {
tmp = -sqrt(((A + (C - hypot(B, (A - C)))) * (2.0 * (F * pow(B, 2.0))))) / fma(B, B, (A * (C * -4.0)));
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(C * A) * 4.0)) tmp = 0.0 if ((B ^ 2.0) <= 5e+32) tmp = Float64(Float64(-sqrt(Float64(Float64(A * 2.0) * Float64(F * Float64(2.0 * t_0))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(Float64(A + Float64(C - hypot(B, Float64(A - C)))) * Float64(2.0 * Float64(F * (B ^ 2.0)))))) / fma(B, B, Float64(A * Float64(C * -4.0)))); end return tmp end
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[Power[B, 2.0], $MachinePrecision] - N[(N[(C * A), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e+32], N[((-N[Sqrt[N[(N[(A * 2.0), $MachinePrecision] * N[(F * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(F * N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(C \cdot A\right) \cdot 4\\
\mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{+32}:\\
\;\;\;\;\frac{-\sqrt{\left(A \cdot 2\right) \cdot \left(F \cdot \left(2 \cdot t_0\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{\left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right) \cdot \left(2 \cdot \left(F \cdot {B}^{2}\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 4.9999999999999997e32Initial program 22.5%
Simplified22.5%
Taylor expanded in A around -inf 21.8%
if 4.9999999999999997e32 < (pow.f64 B 2) Initial program 16.8%
Simplified20.2%
Taylor expanded in B around inf 18.2%
Final simplification20.2%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (* F (* A 2.0)))
(t_1 (fma B B (* A (* C -4.0))))
(t_2 (fma A (* C -4.0) (pow B 2.0))))
(if (<= C -1.85e-181)
(/ (* (sqrt (* A -8.0)) (- (sqrt (* C t_0)))) t_2)
(if (<= C -2.9e-286)
(*
(sqrt (* F (- A (sqrt (+ (pow B 2.0) (pow A 2.0))))))
(/ (- (sqrt 2.0)) B))
(if (<= C 9e+21)
(/ (- (sqrt (* (+ A (- C (hypot B (- A C)))) (* t_1 (* F 2.0))))) t_1)
(/ (sqrt (* -8.0 (* t_0 (* C A)))) (- t_2)))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = F * (A * 2.0);
double t_1 = fma(B, B, (A * (C * -4.0)));
double t_2 = fma(A, (C * -4.0), pow(B, 2.0));
double tmp;
if (C <= -1.85e-181) {
tmp = (sqrt((A * -8.0)) * -sqrt((C * t_0))) / t_2;
} else if (C <= -2.9e-286) {
tmp = sqrt((F * (A - sqrt((pow(B, 2.0) + pow(A, 2.0)))))) * (-sqrt(2.0) / B);
} else if (C <= 9e+21) {
tmp = -sqrt(((A + (C - hypot(B, (A - C)))) * (t_1 * (F * 2.0)))) / t_1;
} else {
tmp = sqrt((-8.0 * (t_0 * (C * A)))) / -t_2;
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(F * Float64(A * 2.0)) t_1 = fma(B, B, Float64(A * Float64(C * -4.0))) t_2 = fma(A, Float64(C * -4.0), (B ^ 2.0)) tmp = 0.0 if (C <= -1.85e-181) tmp = Float64(Float64(sqrt(Float64(A * -8.0)) * Float64(-sqrt(Float64(C * t_0)))) / t_2); elseif (C <= -2.9e-286) tmp = Float64(sqrt(Float64(F * Float64(A - sqrt(Float64((B ^ 2.0) + (A ^ 2.0)))))) * Float64(Float64(-sqrt(2.0)) / B)); elseif (C <= 9e+21) tmp = Float64(Float64(-sqrt(Float64(Float64(A + Float64(C - hypot(B, Float64(A - C)))) * Float64(t_1 * Float64(F * 2.0))))) / t_1); else tmp = Float64(sqrt(Float64(-8.0 * Float64(t_0 * Float64(C * A)))) / Float64(-t_2)); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(F * N[(A * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[C, -1.85e-181], N[(N[(N[Sqrt[N[(A * -8.0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(C * t$95$0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[C, -2.9e-286], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[C, 9e+21], N[((-N[Sqrt[N[(N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[(N[Sqrt[N[(-8.0 * N[(t$95$0 * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$2)), $MachinePrecision]]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := F \cdot \left(A \cdot 2\right)\\
t_1 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)\\
\mathbf{if}\;C \leq -1.85 \cdot 10^{-181}:\\
\;\;\;\;\frac{\sqrt{A \cdot -8} \cdot \left(-\sqrt{C \cdot t_0}\right)}{t_2}\\
\mathbf{elif}\;C \leq -2.9 \cdot 10^{-286}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \sqrt{{B}^{2} + {A}^{2}}\right)} \cdot \frac{-\sqrt{2}}{B}\\
\mathbf{elif}\;C \leq 9 \cdot 10^{+21}:\\
\;\;\;\;\frac{-\sqrt{\left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right) \cdot \left(t_1 \cdot \left(F \cdot 2\right)\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{-8 \cdot \left(t_0 \cdot \left(C \cdot A\right)\right)}}{-t_2}\\
\end{array}
\end{array}
if C < -1.84999999999999992e-181Initial program 21.0%
Simplified19.0%
Taylor expanded in C around inf 6.5%
mul-1-neg6.5%
Simplified6.5%
associate-*r*6.5%
sqrt-prod9.5%
*-commutative9.5%
*-un-lft-identity9.5%
metadata-eval9.5%
neg-mul-19.5%
distribute-rgt-out--9.5%
metadata-eval9.5%
metadata-eval9.5%
*-commutative9.5%
Applied egg-rr9.5%
if -1.84999999999999992e-181 < C < -2.8999999999999998e-286Initial program 20.7%
Simplified21.0%
Taylor expanded in C around 0 11.5%
mul-1-neg11.5%
+-commutative11.5%
Simplified11.5%
if -2.8999999999999998e-286 < C < 9e21Initial program 30.2%
Simplified33.5%
if 9e21 < C Initial program 2.8%
Simplified8.0%
Taylor expanded in C around inf 25.2%
mul-1-neg25.2%
Simplified25.2%
frac-2neg25.2%
remove-double-neg25.2%
div-inv25.1%
Applied egg-rr25.1%
associate-*r/25.2%
*-rgt-identity25.2%
associate-*r*25.2%
associate-*r*25.2%
Simplified25.2%
Final simplification20.8%
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 (<= C 1.25e+22)
(/ (- (sqrt (* (+ A (- C (hypot B (- A C)))) (* t_0 (* F 2.0))))) t_0)
(/
(sqrt (* -8.0 (* (* F (* A 2.0)) (* C A))))
(- (fma A (* C -4.0) (pow B 2.0)))))))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 (C <= 1.25e+22) {
tmp = -sqrt(((A + (C - hypot(B, (A - C)))) * (t_0 * (F * 2.0)))) / t_0;
} else {
tmp = sqrt((-8.0 * ((F * (A * 2.0)) * (C * A)))) / -fma(A, (C * -4.0), pow(B, 2.0));
}
return tmp;
}
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 (C <= 1.25e+22) tmp = Float64(Float64(-sqrt(Float64(Float64(A + Float64(C - hypot(B, Float64(A - C)))) * Float64(t_0 * Float64(F * 2.0))))) / t_0); else tmp = Float64(sqrt(Float64(-8.0 * Float64(Float64(F * Float64(A * 2.0)) * Float64(C * A)))) / Float64(-fma(A, Float64(C * -4.0), (B ^ 2.0)))); end return tmp end
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[C, 1.25e+22], N[((-N[Sqrt[N[(N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(-8.0 * N[(N[(F * N[(A * 2.0), $MachinePrecision]), $MachinePrecision] * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
[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}\;C \leq 1.25 \cdot 10^{+22}:\\
\;\;\;\;\frac{-\sqrt{\left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right) \cdot \left(t_0 \cdot \left(F \cdot 2\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{-8 \cdot \left(\left(F \cdot \left(A \cdot 2\right)\right) \cdot \left(C \cdot A\right)\right)}}{-\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\\
\end{array}
\end{array}
if C < 1.2499999999999999e22Initial program 24.8%
Simplified30.0%
if 1.2499999999999999e22 < C Initial program 2.8%
Simplified8.0%
Taylor expanded in C around inf 25.2%
mul-1-neg25.2%
Simplified25.2%
frac-2neg25.2%
remove-double-neg25.2%
div-inv25.1%
Applied egg-rr25.1%
associate-*r/25.2%
*-rgt-identity25.2%
associate-*r*25.2%
associate-*r*25.2%
Simplified25.2%
Final simplification28.9%
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 (<= B 6.8e+92)
(/ (- (sqrt (* (* t_0 (* F 2.0)) (+ A A)))) t_0)
(* -2.0 (* (sqrt (* A F)) (/ 1.0 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 (B <= 6.8e+92) {
tmp = -sqrt(((t_0 * (F * 2.0)) * (A + A))) / t_0;
} else {
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
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 <= 6.8e+92) tmp = Float64(Float64(-sqrt(Float64(Float64(t_0 * Float64(F * 2.0)) * Float64(A + A)))) / t_0); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); end return tmp end
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[B, 6.8e+92], N[((-N[Sqrt[N[(N[(t$95$0 * N[(F * 2.0), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[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 \leq 6.8 \cdot 10^{+92}:\\
\;\;\;\;\frac{-\sqrt{\left(t_0 \cdot \left(F \cdot 2\right)\right) \cdot \left(A + A\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if B < 6.7999999999999996e92Initial program 22.4%
Simplified28.2%
Taylor expanded in C around inf 16.0%
if 6.7999999999999996e92 < B Initial program 5.7%
Simplified5.7%
Taylor expanded in A around -inf 0.6%
Taylor expanded in B around inf 2.9%
Final simplification14.0%
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) 4e+54)
(/
(- (sqrt (* (* A 2.0) (* -8.0 (* A (* C F))))))
(- (pow B 2.0) (* (* C A) 4.0)))
(* -2.0 (* (sqrt (* A F)) (/ 1.0 B)))))assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (pow(B, 2.0) <= 4e+54) {
tmp = -sqrt(((A * 2.0) * (-8.0 * (A * (C * F))))) / (pow(B, 2.0) - ((C * A) * 4.0));
} else {
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
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) :: tmp
if ((b ** 2.0d0) <= 4d+54) then
tmp = -sqrt(((a * 2.0d0) * ((-8.0d0) * (a * (c * f))))) / ((b ** 2.0d0) - ((c * a) * 4.0d0))
else
tmp = (-2.0d0) * (sqrt((a * f)) * (1.0d0 / b))
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (Math.pow(B, 2.0) <= 4e+54) {
tmp = -Math.sqrt(((A * 2.0) * (-8.0 * (A * (C * F))))) / (Math.pow(B, 2.0) - ((C * A) * 4.0));
} else {
tmp = -2.0 * (Math.sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if math.pow(B, 2.0) <= 4e+54: tmp = -math.sqrt(((A * 2.0) * (-8.0 * (A * (C * F))))) / (math.pow(B, 2.0) - ((C * A) * 4.0)) else: tmp = -2.0 * (math.sqrt((A * F)) * (1.0 / B)) return tmp
A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if ((B ^ 2.0) <= 4e+54) tmp = Float64(Float64(-sqrt(Float64(Float64(A * 2.0) * Float64(-8.0 * Float64(A * Float64(C * F)))))) / Float64((B ^ 2.0) - Float64(Float64(C * A) * 4.0))); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if ((B ^ 2.0) <= 4e+54)
tmp = -sqrt(((A * 2.0) * (-8.0 * (A * (C * F))))) / ((B ^ 2.0) - ((C * A) * 4.0));
else
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
end
tmp_2 = tmp;
end
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], 4e+54], N[((-N[Sqrt[N[(N[(A * 2.0), $MachinePrecision] * N[(-8.0 * N[(A * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(C * A), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 4 \cdot 10^{+54}:\\
\;\;\;\;\frac{-\sqrt{\left(A \cdot 2\right) \cdot \left(-8 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)}}{{B}^{2} - \left(C \cdot A\right) \cdot 4}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 4.0000000000000003e54Initial program 22.2%
Simplified22.2%
Taylor expanded in A around -inf 21.5%
Taylor expanded in B around 0 19.0%
if 4.0000000000000003e54 < (pow.f64 B 2) Initial program 17.0%
Simplified17.0%
Taylor expanded in A around -inf 4.2%
Taylor expanded in B around inf 3.7%
Final simplification12.1%
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) 4e+54)
(/
(- (sqrt (* (* A 2.0) (* -8.0 (* F (* C A))))))
(- (pow B 2.0) (* (* C A) 4.0)))
(* -2.0 (* (sqrt (* A F)) (/ 1.0 B)))))assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (pow(B, 2.0) <= 4e+54) {
tmp = -sqrt(((A * 2.0) * (-8.0 * (F * (C * A))))) / (pow(B, 2.0) - ((C * A) * 4.0));
} else {
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
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) :: tmp
if ((b ** 2.0d0) <= 4d+54) then
tmp = -sqrt(((a * 2.0d0) * ((-8.0d0) * (f * (c * a))))) / ((b ** 2.0d0) - ((c * a) * 4.0d0))
else
tmp = (-2.0d0) * (sqrt((a * f)) * (1.0d0 / b))
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (Math.pow(B, 2.0) <= 4e+54) {
tmp = -Math.sqrt(((A * 2.0) * (-8.0 * (F * (C * A))))) / (Math.pow(B, 2.0) - ((C * A) * 4.0));
} else {
tmp = -2.0 * (Math.sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if math.pow(B, 2.0) <= 4e+54: tmp = -math.sqrt(((A * 2.0) * (-8.0 * (F * (C * A))))) / (math.pow(B, 2.0) - ((C * A) * 4.0)) else: tmp = -2.0 * (math.sqrt((A * F)) * (1.0 / B)) return tmp
A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if ((B ^ 2.0) <= 4e+54) tmp = Float64(Float64(-sqrt(Float64(Float64(A * 2.0) * Float64(-8.0 * Float64(F * Float64(C * A)))))) / Float64((B ^ 2.0) - Float64(Float64(C * A) * 4.0))); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if ((B ^ 2.0) <= 4e+54)
tmp = -sqrt(((A * 2.0) * (-8.0 * (F * (C * A))))) / ((B ^ 2.0) - ((C * A) * 4.0));
else
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
end
tmp_2 = tmp;
end
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], 4e+54], N[((-N[Sqrt[N[(N[(A * 2.0), $MachinePrecision] * N[(-8.0 * N[(F * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(C * A), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 4 \cdot 10^{+54}:\\
\;\;\;\;\frac{-\sqrt{\left(A \cdot 2\right) \cdot \left(-8 \cdot \left(F \cdot \left(C \cdot A\right)\right)\right)}}{{B}^{2} - \left(C \cdot A\right) \cdot 4}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 4.0000000000000003e54Initial program 22.2%
Simplified22.2%
Taylor expanded in A around -inf 21.5%
Taylor expanded in B around 0 19.0%
associate-*r*20.8%
Simplified20.8%
if 4.0000000000000003e54 < (pow.f64 B 2) Initial program 17.0%
Simplified17.0%
Taylor expanded in A around -inf 4.2%
Taylor expanded in B around inf 3.7%
Final simplification13.0%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 3e+29)
(/
(sqrt (* -8.0 (* (* F (* A 2.0)) (* C A))))
(- (fma A (* C -4.0) (pow B 2.0))))
(* -2.0 (* (sqrt (* A F)) (/ 1.0 B)))))assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 3e+29) {
tmp = sqrt((-8.0 * ((F * (A * 2.0)) * (C * A)))) / -fma(A, (C * -4.0), pow(B, 2.0));
} else {
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 3e+29) tmp = Float64(sqrt(Float64(-8.0 * Float64(Float64(F * Float64(A * 2.0)) * Float64(C * A)))) / Float64(-fma(A, Float64(C * -4.0), (B ^ 2.0)))); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); end return tmp end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 3e+29], N[(N[Sqrt[N[(-8.0 * N[(N[(F * N[(A * 2.0), $MachinePrecision]), $MachinePrecision] * N[(C * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision])), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 3 \cdot 10^{+29}:\\
\;\;\;\;\frac{\sqrt{-8 \cdot \left(\left(F \cdot \left(A \cdot 2\right)\right) \cdot \left(C \cdot A\right)\right)}}{-\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\end{array}
\end{array}
if B < 2.9999999999999999e29Initial program 20.3%
Simplified22.1%
Taylor expanded in C around inf 14.7%
mul-1-neg14.7%
Simplified14.7%
frac-2neg14.7%
remove-double-neg14.7%
div-inv14.7%
Applied egg-rr14.7%
associate-*r/14.7%
*-rgt-identity14.7%
associate-*r*14.7%
associate-*r*14.6%
Simplified14.6%
if 2.9999999999999999e29 < B Initial program 18.5%
Simplified18.5%
Taylor expanded in A around -inf 6.1%
Taylor expanded in B around inf 6.3%
Final simplification12.8%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* -2.0 (* (sqrt (* A F)) (/ 1.0 B))))
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (sqrt((A * F)) * (1.0 / B));
}
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 = (-2.0d0) * (sqrt((a * f)) * (1.0d0 / b))
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
return -2.0 * (Math.sqrt((A * F)) * (1.0 / B));
}
[A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.sqrt((A * F)) * (1.0 / B))
A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))) end
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (sqrt((A * F)) * (1.0 / B));
end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)
\end{array}
Initial program 19.9%
Simplified19.9%
Taylor expanded in A around -inf 13.7%
Taylor expanded in B around inf 2.3%
Final simplification2.3%
herbie shell --seed 2023305
(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))))