
(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 12 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 (fma C (* A -4.0) (* B B)))
(t_1 (- (* B B) (* 4.0 (* A C))))
(t_2 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_3 (sqrt (+ C (+ A (hypot B (- A C))))))
(t_4
(/
(-
(sqrt
(*
(* 2.0 (* t_2 F))
(+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_2))
(t_5 (* (* A C) -4.0)))
(if (<= t_4 -5e-209)
(/ (* t_3 (* (sqrt (fma B B t_5)) (- (sqrt (* 2.0 F))))) t_1)
(if (<= t_4 1e+37)
(/
(- (sqrt (* 2.0 (* t_0 (* F (+ C (+ C (* -0.5 (/ B (/ A B))))))))))
t_0)
(if (<= t_4 INFINITY)
(/ (* t_3 (- (sqrt (* (* 2.0 F) t_5)))) t_1)
(* (/ (sqrt 2.0) B) (* (sqrt (+ A (hypot A B))) (- (sqrt F)))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(C, (A * -4.0), (B * B));
double t_1 = (B * B) - (4.0 * (A * C));
double t_2 = pow(B, 2.0) - ((4.0 * A) * C);
double t_3 = sqrt((C + (A + hypot(B, (A - C)))));
double t_4 = -sqrt(((2.0 * (t_2 * F)) * ((A + C) + sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_2;
double t_5 = (A * C) * -4.0;
double tmp;
if (t_4 <= -5e-209) {
tmp = (t_3 * (sqrt(fma(B, B, t_5)) * -sqrt((2.0 * F)))) / t_1;
} else if (t_4 <= 1e+37) {
tmp = -sqrt((2.0 * (t_0 * (F * (C + (C + (-0.5 * (B / (A / B))))))))) / t_0;
} else if (t_4 <= ((double) INFINITY)) {
tmp = (t_3 * -sqrt(((2.0 * F) * t_5))) / t_1;
} else {
tmp = (sqrt(2.0) / B) * (sqrt((A + hypot(A, B))) * -sqrt(F));
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(C, Float64(A * -4.0), Float64(B * B)) t_1 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_2 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_3 = sqrt(Float64(C + Float64(A + hypot(B, Float64(A - C))))) t_4 = 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) t_5 = Float64(Float64(A * C) * -4.0) tmp = 0.0 if (t_4 <= -5e-209) tmp = Float64(Float64(t_3 * Float64(sqrt(fma(B, B, t_5)) * Float64(-sqrt(Float64(2.0 * F))))) / t_1); elseif (t_4 <= 1e+37) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(C + Float64(C + Float64(-0.5 * Float64(B / Float64(A / B)))))))))) / t_0); elseif (t_4 <= Inf) tmp = Float64(Float64(t_3 * Float64(-sqrt(Float64(Float64(2.0 * F) * t_5)))) / t_1); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(sqrt(Float64(A + hypot(A, B))) * Float64(-sqrt(F)))); 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[(C * N[(A * -4.0), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $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[Sqrt[N[(C + N[(A + N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$2 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(N[Power[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$5 = N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]}, If[LessEqual[t$95$4, -5e-209], N[(N[(t$95$3 * N[(N[Sqrt[N[(B * B + t$95$5), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(2.0 * F), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$4, 1e+37], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(C + N[(C + N[(-0.5 * N[(B / N[(A / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(N[(t$95$3 * (-N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * t$95$5), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * N[(N[Sqrt[N[(A + N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[F], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(C, A \cdot -4, B \cdot B\right)\\
t_1 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_2 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := \sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}\\
t_4 := \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}\\
t_5 := \left(A \cdot C\right) \cdot -4\\
\mathbf{if}\;t_4 \leq -5 \cdot 10^{-209}:\\
\;\;\;\;\frac{t_3 \cdot \left(\sqrt{\mathsf{fma}\left(B, B, t_5\right)} \cdot \left(-\sqrt{2 \cdot F}\right)\right)}{t_1}\\
\mathbf{elif}\;t_4 \leq 10^{+37}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(C + \left(C + -0.5 \cdot \frac{B}{\frac{A}{B}}\right)\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;t_4 \leq \infty:\\
\;\;\;\;\frac{t_3 \cdot \left(-\sqrt{\left(2 \cdot F\right) \cdot t_5}\right)}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(\sqrt{A + \mathsf{hypot}\left(A, B\right)} \cdot \left(-\sqrt{F}\right)\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.0000000000000005e-209Initial program 40.1%
associate-*l*40.1%
unpow240.1%
+-commutative40.1%
unpow240.1%
associate-*l*40.1%
unpow240.1%
Simplified40.1%
unpow240.1%
hypot-udef47.4%
*-un-lft-identity47.4%
Applied egg-rr47.4%
*-lft-identity47.4%
Simplified47.4%
sqrt-prod60.7%
*-commutative60.7%
cancel-sign-sub-inv60.7%
metadata-eval60.7%
*-commutative60.7%
+-commutative60.7%
Applied egg-rr60.7%
associate-*r*60.8%
fma-def60.8%
associate-+l+61.1%
Simplified61.1%
sqrt-prod75.3%
Applied egg-rr75.3%
*-commutative75.3%
*-commutative75.3%
*-commutative75.3%
Simplified75.3%
if -5.0000000000000005e-209 < (/.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))) < 9.99999999999999954e36Initial program 9.4%
Simplified11.0%
Taylor expanded in A around -inf 17.8%
unpow217.8%
Simplified17.8%
distribute-frac-neg17.8%
associate-*l*19.1%
associate-/l*19.1%
Applied egg-rr19.1%
if 9.99999999999999954e36 < (/.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 21.6%
associate-*l*21.6%
unpow221.6%
+-commutative21.6%
unpow221.6%
associate-*l*21.6%
unpow221.6%
Simplified21.6%
unpow221.6%
hypot-udef45.8%
*-un-lft-identity45.8%
Applied egg-rr45.8%
*-lft-identity45.8%
Simplified45.8%
sqrt-prod87.9%
*-commutative87.9%
cancel-sign-sub-inv87.9%
metadata-eval87.9%
*-commutative87.9%
+-commutative87.9%
Applied egg-rr87.9%
associate-*r*87.9%
fma-def87.9%
associate-+l+87.9%
Simplified87.9%
Taylor expanded in B around 0 87.9%
*-commutative87.9%
*-commutative87.9%
Simplified87.9%
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.4%
Taylor expanded in C around 0 1.9%
mul-1-neg1.9%
distribute-rgt-neg-in1.9%
*-commutative1.9%
+-commutative1.9%
unpow21.9%
unpow21.9%
hypot-def13.3%
Simplified13.3%
sqrt-prod24.6%
Applied egg-rr24.6%
Final simplification43.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 (- (* B B) (* 4.0 (* A C))))
(t_1 (sqrt (+ C (+ A (hypot B (- A C)))))))
(if (<= B -1.7e+70)
(/ (* t_1 (* (sqrt F) (* B (sqrt 2.0)))) t_0)
(if (<= B 6.6e-159)
(/
(- (sqrt (* (* 2.0 (* F t_0)) (fma 2.0 C (* -0.5 (/ (* B B) A))))))
t_0)
(if (<= B 5e+32)
(/ (* t_1 (- (sqrt (* (* 2.0 F) t_0)))) t_0)
(* (/ (sqrt 2.0) B) (* (sqrt (+ A (hypot A B))) (- (sqrt F)))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = sqrt((C + (A + hypot(B, (A - C)))));
double tmp;
if (B <= -1.7e+70) {
tmp = (t_1 * (sqrt(F) * (B * sqrt(2.0)))) / t_0;
} else if (B <= 6.6e-159) {
tmp = -sqrt(((2.0 * (F * t_0)) * fma(2.0, C, (-0.5 * ((B * B) / A))))) / t_0;
} else if (B <= 5e+32) {
tmp = (t_1 * -sqrt(((2.0 * F) * t_0))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * (sqrt((A + hypot(A, B))) * -sqrt(F));
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = sqrt(Float64(C + Float64(A + hypot(B, Float64(A - C))))) tmp = 0.0 if (B <= -1.7e+70) tmp = Float64(Float64(t_1 * Float64(sqrt(F) * Float64(B * sqrt(2.0)))) / t_0); elseif (B <= 6.6e-159) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * fma(2.0, C, Float64(-0.5 * Float64(Float64(B * B) / A)))))) / t_0); elseif (B <= 5e+32) tmp = Float64(Float64(t_1 * Float64(-sqrt(Float64(Float64(2.0 * F) * t_0)))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(sqrt(Float64(A + hypot(A, B))) * Float64(-sqrt(F)))); 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[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(C + N[(A + N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[B, -1.7e+70], N[(N[(t$95$1 * N[(N[Sqrt[F], $MachinePrecision] * N[(B * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[B, 6.6e-159], N[((-N[Sqrt[N[(N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 5e+32], N[(N[(t$95$1 * (-N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * N[(N[Sqrt[N[(A + N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[F], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := \sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}\\
\mathbf{if}\;B \leq -1.7 \cdot 10^{+70}:\\
\;\;\;\;\frac{t_1 \cdot \left(\sqrt{F} \cdot \left(B \cdot \sqrt{2}\right)\right)}{t_0}\\
\mathbf{elif}\;B \leq 6.6 \cdot 10^{-159}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(F \cdot t_0\right)\right) \cdot \mathsf{fma}\left(2, C, -0.5 \cdot \frac{B \cdot B}{A}\right)}}{t_0}\\
\mathbf{elif}\;B \leq 5 \cdot 10^{+32}:\\
\;\;\;\;\frac{t_1 \cdot \left(-\sqrt{\left(2 \cdot F\right) \cdot t_0}\right)}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(\sqrt{A + \mathsf{hypot}\left(A, B\right)} \cdot \left(-\sqrt{F}\right)\right)\\
\end{array}
\end{array}
if B < -1.7e70Initial program 7.4%
associate-*l*7.4%
unpow27.4%
+-commutative7.4%
unpow27.4%
associate-*l*7.4%
unpow27.4%
Simplified7.4%
unpow27.4%
hypot-udef7.3%
*-un-lft-identity7.3%
Applied egg-rr7.3%
*-lft-identity7.3%
Simplified7.3%
sqrt-prod10.5%
*-commutative10.5%
cancel-sign-sub-inv10.5%
metadata-eval10.5%
*-commutative10.5%
+-commutative10.5%
Applied egg-rr10.5%
associate-*r*10.5%
fma-def10.5%
associate-+l+10.7%
Simplified10.7%
Taylor expanded in B around -inf 20.1%
mul-1-neg20.1%
Simplified20.1%
if -1.7e70 < B < 6.6000000000000003e-159Initial program 20.1%
associate-*l*20.1%
unpow220.1%
+-commutative20.1%
unpow220.1%
associate-*l*20.1%
unpow220.1%
Simplified20.1%
unpow220.1%
hypot-udef25.0%
*-un-lft-identity25.0%
Applied egg-rr25.0%
*-lft-identity25.0%
Simplified25.0%
Taylor expanded in A around -inf 19.5%
fma-def19.5%
unpow219.5%
Simplified19.5%
if 6.6000000000000003e-159 < B < 4.9999999999999997e32Initial program 26.8%
associate-*l*26.8%
unpow226.8%
+-commutative26.8%
unpow226.8%
associate-*l*26.8%
unpow226.8%
Simplified26.8%
unpow226.8%
hypot-udef39.0%
*-un-lft-identity39.0%
Applied egg-rr39.0%
*-lft-identity39.0%
Simplified39.0%
sqrt-prod53.7%
*-commutative53.7%
cancel-sign-sub-inv53.7%
metadata-eval53.7%
*-commutative53.7%
+-commutative53.7%
Applied egg-rr53.7%
associate-*r*53.8%
fma-def53.8%
associate-+l+53.9%
Simplified53.9%
fma-udef53.9%
metadata-eval53.9%
*-commutative53.9%
cancel-sign-sub-inv53.9%
*-commutative53.9%
Applied egg-rr53.9%
if 4.9999999999999997e32 < B Initial program 9.1%
Simplified9.1%
Taylor expanded in C around 0 19.3%
mul-1-neg19.3%
distribute-rgt-neg-in19.3%
*-commutative19.3%
+-commutative19.3%
unpow219.3%
unpow219.3%
hypot-def43.0%
Simplified43.0%
sqrt-prod72.3%
Applied egg-rr72.3%
Final simplification35.1%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))) (t_1 (* 2.0 (* F t_0))))
(if (<= A -2.7e-34)
(/ (- (sqrt (* t_1 (fma 2.0 C (* -0.5 (/ (* B B) A)))))) t_0)
(/ (* (sqrt (+ (+ A C) (hypot B (- A C)))) (- (sqrt t_1))) t_0))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double t_1 = 2.0 * (F * t_0);
double tmp;
if (A <= -2.7e-34) {
tmp = -sqrt((t_1 * fma(2.0, C, (-0.5 * ((B * B) / A))))) / t_0;
} else {
tmp = (sqrt(((A + C) + hypot(B, (A - C)))) * -sqrt(t_1)) / t_0;
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) t_1 = Float64(2.0 * Float64(F * t_0)) tmp = 0.0 if (A <= -2.7e-34) tmp = Float64(Float64(-sqrt(Float64(t_1 * fma(2.0, C, Float64(-0.5 * Float64(Float64(B * B) / A)))))) / t_0); else tmp = Float64(Float64(sqrt(Float64(Float64(A + C) + hypot(B, Float64(A - C)))) * Float64(-sqrt(t_1))) / 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[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[A, -2.7e-34], N[((-N[Sqrt[N[(t$95$1 * N[(2.0 * C + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(A + C), $MachinePrecision] + N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[t$95$1], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := 2 \cdot \left(F \cdot t_0\right)\\
\mathbf{if}\;A \leq -2.7 \cdot 10^{-34}:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \mathsf{fma}\left(2, C, -0.5 \cdot \frac{B \cdot B}{A}\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(A + C\right) + \mathsf{hypot}\left(B, A - C\right)} \cdot \left(-\sqrt{t_1}\right)}{t_0}\\
\end{array}
\end{array}
if A < -2.70000000000000017e-34Initial program 4.4%
associate-*l*4.4%
unpow24.4%
+-commutative4.4%
unpow24.4%
associate-*l*4.4%
unpow24.4%
Simplified4.4%
unpow24.4%
hypot-udef4.7%
*-un-lft-identity4.7%
Applied egg-rr4.7%
*-lft-identity4.7%
Simplified4.7%
Taylor expanded in A around -inf 26.7%
fma-def26.7%
unpow226.7%
Simplified26.7%
if -2.70000000000000017e-34 < A Initial program 20.2%
associate-*l*20.2%
unpow220.2%
+-commutative20.2%
unpow220.2%
associate-*l*20.2%
unpow220.2%
Simplified20.2%
sqrt-prod25.0%
*-commutative25.0%
unpow225.0%
hypot-udef34.2%
Applied egg-rr34.2%
Final simplification32.3%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))))
(if (<= B -6.5e+70)
(/
(* (sqrt (+ C (+ A (hypot B (- A C))))) (- (sqrt (* (* 2.0 F) (* B B)))))
t_0)
(if (<= B 2.25e+27)
(/
(- (sqrt (* (* 2.0 (* F t_0)) (fma 2.0 C (* -0.5 (/ (* B B) A))))))
t_0)
(* (sqrt 2.0) (- (sqrt (/ F B))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= -6.5e+70) {
tmp = (sqrt((C + (A + hypot(B, (A - C))))) * -sqrt(((2.0 * F) * (B * B)))) / t_0;
} else if (B <= 2.25e+27) {
tmp = -sqrt(((2.0 * (F * t_0)) * fma(2.0, C, (-0.5 * ((B * B) / A))))) / t_0;
} else {
tmp = sqrt(2.0) * -sqrt((F / B));
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= -6.5e+70) tmp = Float64(Float64(sqrt(Float64(C + Float64(A + hypot(B, Float64(A - C))))) * Float64(-sqrt(Float64(Float64(2.0 * F) * Float64(B * B))))) / t_0); elseif (B <= 2.25e+27) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * fma(2.0, C, Float64(-0.5 * Float64(Float64(B * B) / A)))))) / t_0); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F / 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[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -6.5e+70], N[(N[(N[Sqrt[N[(C + N[(A + N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[B, 2.25e+27], N[((-N[Sqrt[N[(N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F / B), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq -6.5 \cdot 10^{+70}:\\
\;\;\;\;\frac{\sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)} \cdot \left(-\sqrt{\left(2 \cdot F\right) \cdot \left(B \cdot B\right)}\right)}{t_0}\\
\mathbf{elif}\;B \leq 2.25 \cdot 10^{+27}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(F \cdot t_0\right)\right) \cdot \mathsf{fma}\left(2, C, -0.5 \cdot \frac{B \cdot B}{A}\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{F}{B}}\right)\\
\end{array}
\end{array}
if B < -6.49999999999999978e70Initial program 7.4%
associate-*l*7.4%
unpow27.4%
+-commutative7.4%
unpow27.4%
associate-*l*7.4%
unpow27.4%
Simplified7.4%
unpow27.4%
hypot-udef7.3%
*-un-lft-identity7.3%
Applied egg-rr7.3%
*-lft-identity7.3%
Simplified7.3%
sqrt-prod10.5%
*-commutative10.5%
cancel-sign-sub-inv10.5%
metadata-eval10.5%
*-commutative10.5%
+-commutative10.5%
Applied egg-rr10.5%
associate-*r*10.5%
fma-def10.5%
associate-+l+10.7%
Simplified10.7%
Taylor expanded in B around inf 10.8%
unpow210.8%
Simplified10.8%
if -6.49999999999999978e70 < B < 2.25e27Initial program 21.9%
associate-*l*21.9%
unpow221.9%
+-commutative21.9%
unpow221.9%
associate-*l*21.9%
unpow221.9%
Simplified21.9%
unpow221.9%
hypot-udef28.9%
*-un-lft-identity28.9%
Applied egg-rr28.9%
*-lft-identity28.9%
Simplified28.9%
Taylor expanded in A around -inf 19.2%
fma-def19.2%
unpow219.2%
Simplified19.2%
if 2.25e27 < B Initial program 9.1%
Simplified9.1%
Taylor expanded in C around 0 19.3%
mul-1-neg19.3%
distribute-rgt-neg-in19.3%
*-commutative19.3%
+-commutative19.3%
unpow219.3%
unpow219.3%
hypot-def43.0%
Simplified43.0%
Taylor expanded in A around 0 49.5%
mul-1-neg49.5%
*-commutative49.5%
distribute-rgt-neg-in49.5%
Simplified49.5%
Final simplification22.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 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 4.95e+30)
(/
(- (sqrt (* (* 2.0 (* F t_0)) (fma 2.0 C (* -0.5 (/ (* B B) A))))))
t_0)
(* (sqrt 2.0) (- (sqrt (/ F B)))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 4.95e+30) {
tmp = -sqrt(((2.0 * (F * t_0)) * fma(2.0, C, (-0.5 * ((B * B) / A))))) / t_0;
} else {
tmp = sqrt(2.0) * -sqrt((F / B));
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= 4.95e+30) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * fma(2.0, C, Float64(-0.5 * Float64(Float64(B * B) / A)))))) / t_0); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F / 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[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 4.95e+30], N[((-N[Sqrt[N[(N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C + N[(-0.5 * N[(N[(B * B), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F / B), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 4.95 \cdot 10^{+30}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(F \cdot t_0\right)\right) \cdot \mathsf{fma}\left(2, C, -0.5 \cdot \frac{B \cdot B}{A}\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{F}{B}}\right)\\
\end{array}
\end{array}
if B < 4.9500000000000001e30Initial program 17.8%
associate-*l*17.8%
unpow217.8%
+-commutative17.8%
unpow217.8%
associate-*l*17.8%
unpow217.8%
Simplified17.8%
unpow217.8%
hypot-udef22.7%
*-un-lft-identity22.7%
Applied egg-rr22.7%
*-lft-identity22.7%
Simplified22.7%
Taylor expanded in A around -inf 13.9%
fma-def13.9%
unpow213.9%
Simplified13.9%
if 4.9500000000000001e30 < B Initial program 9.1%
Simplified9.1%
Taylor expanded in C around 0 19.3%
mul-1-neg19.3%
distribute-rgt-neg-in19.3%
*-commutative19.3%
+-commutative19.3%
unpow219.3%
unpow219.3%
hypot-def43.0%
Simplified43.0%
Taylor expanded in A around 0 49.5%
mul-1-neg49.5%
*-commutative49.5%
distribute-rgt-neg-in49.5%
Simplified49.5%
Final simplification20.6%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 2600000000.0)
(/ (- (sqrt (* (* 2.0 (* F t_0)) (* 2.0 C)))) t_0)
(* (sqrt 2.0) (- (sqrt (/ F B)))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 2600000000.0) {
tmp = -sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
} else {
tmp = sqrt(2.0) * -sqrt((F / 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) :: t_0
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (a * c))
if (b <= 2600000000.0d0) then
tmp = -sqrt(((2.0d0 * (f * t_0)) * (2.0d0 * c))) / t_0
else
tmp = sqrt(2.0d0) * -sqrt((f / b))
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 2600000000.0) {
tmp = -Math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
} else {
tmp = Math.sqrt(2.0) * -Math.sqrt((F / B));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) tmp = 0 if B <= 2600000000.0: tmp = -math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0 else: tmp = math.sqrt(2.0) * -math.sqrt((F / B)) return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= 2600000000.0) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * Float64(2.0 * C)))) / t_0); else tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F / B)))); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
tmp = 0.0;
if (B <= 2600000000.0)
tmp = -sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
else
tmp = sqrt(2.0) * -sqrt((F / 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_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 2600000000.0], N[((-N[Sqrt[N[(N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F / B), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 2600000000:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(F \cdot t_0\right)\right) \cdot \left(2 \cdot C\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{F}{B}}\right)\\
\end{array}
\end{array}
if B < 2.6e9Initial program 17.5%
associate-*l*17.5%
unpow217.5%
+-commutative17.5%
unpow217.5%
associate-*l*17.5%
unpow217.5%
Simplified17.5%
unpow217.5%
hypot-udef22.5%
*-un-lft-identity22.5%
Applied egg-rr22.5%
*-lft-identity22.5%
Simplified22.5%
Taylor expanded in A around -inf 13.6%
if 2.6e9 < B Initial program 10.6%
Simplified10.7%
Taylor expanded in C around 0 19.4%
mul-1-neg19.4%
distribute-rgt-neg-in19.4%
*-commutative19.4%
+-commutative19.4%
unpow219.4%
unpow219.4%
hypot-def41.7%
Simplified41.7%
Taylor expanded in A around 0 47.8%
mul-1-neg47.8%
*-commutative47.8%
distribute-rgt-neg-in47.8%
Simplified47.8%
Final simplification20.5%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 6.2e-110)
(- (/ (sqrt (* -8.0 (* A (* F (* C C))))) t_0))
(/ (- (sqrt (* B (* 2.0 (* F t_0))))) t_0))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 6.2e-110) {
tmp = -(sqrt((-8.0 * (A * (F * (C * C))))) / t_0);
} else {
tmp = -sqrt((B * (2.0 * (F * t_0)))) / t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = (b * b) - (4.0d0 * (a * c))
if (b <= 6.2d-110) then
tmp = -(sqrt(((-8.0d0) * (a * (f * (c * c))))) / t_0)
else
tmp = -sqrt((b * (2.0d0 * (f * t_0)))) / t_0
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 6.2e-110) {
tmp = -(Math.sqrt((-8.0 * (A * (F * (C * C))))) / t_0);
} else {
tmp = -Math.sqrt((B * (2.0 * (F * t_0)))) / t_0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) tmp = 0 if B <= 6.2e-110: tmp = -(math.sqrt((-8.0 * (A * (F * (C * C))))) / t_0) else: tmp = -math.sqrt((B * (2.0 * (F * t_0)))) / t_0 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= 6.2e-110) tmp = Float64(-Float64(sqrt(Float64(-8.0 * Float64(A * Float64(F * Float64(C * C))))) / t_0)); else tmp = Float64(Float64(-sqrt(Float64(B * Float64(2.0 * Float64(F * t_0))))) / t_0); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
tmp = 0.0;
if (B <= 6.2e-110)
tmp = -(sqrt((-8.0 * (A * (F * (C * C))))) / t_0);
else
tmp = -sqrt((B * (2.0 * (F * t_0)))) / t_0;
end
tmp_2 = 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[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 6.2e-110], (-N[(N[Sqrt[N[(-8.0 * N[(A * N[(F * N[(C * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), N[((-N[Sqrt[N[(B * N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 6.2 \cdot 10^{-110}:\\
\;\;\;\;-\frac{\sqrt{-8 \cdot \left(A \cdot \left(F \cdot \left(C \cdot C\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{B \cdot \left(2 \cdot \left(F \cdot t_0\right)\right)}}{t_0}\\
\end{array}
\end{array}
if B < 6.20000000000000014e-110Initial program 16.0%
associate-*l*16.0%
unpow216.0%
+-commutative16.0%
unpow216.0%
associate-*l*16.0%
unpow216.0%
Simplified16.0%
Taylor expanded in A around inf 11.0%
Taylor expanded in C around inf 4.0%
unpow24.0%
Simplified4.0%
if 6.20000000000000014e-110 < B Initial program 16.6%
associate-*l*16.6%
unpow216.6%
+-commutative16.6%
unpow216.6%
associate-*l*16.6%
unpow216.6%
Simplified16.6%
unpow216.6%
hypot-udef21.6%
*-un-lft-identity21.6%
Applied egg-rr21.6%
*-lft-identity21.6%
Simplified21.6%
Taylor expanded in B around inf 9.5%
Final simplification5.7%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (let* ((t_0 (- (* B B) (* 4.0 (* A C))))) (/ (- (sqrt (* (* 2.0 (* F t_0)) (* 2.0 C)))) t_0)))
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
return -sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
}
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
t_0 = (b * b) - (4.0d0 * (a * c))
code = -sqrt(((2.0d0 * (f * t_0)) * (2.0d0 * c))) / t_0
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
return -Math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) return -math.sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(F * t_0)) * Float64(2.0 * C)))) / t_0) end
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
tmp = -sqrt(((2.0 * (F * t_0)) * (2.0 * C))) / t_0;
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[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\frac{-\sqrt{\left(2 \cdot \left(F \cdot t_0\right)\right) \cdot \left(2 \cdot C\right)}}{t_0}
\end{array}
\end{array}
Initial program 16.2%
associate-*l*16.2%
unpow216.2%
+-commutative16.2%
unpow216.2%
associate-*l*16.2%
unpow216.2%
Simplified16.2%
unpow216.2%
hypot-udef20.2%
*-un-lft-identity20.2%
Applied egg-rr20.2%
*-lft-identity20.2%
Simplified20.2%
Taylor expanded in A around -inf 11.2%
Final simplification11.2%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (/ (- (sqrt (* -16.0 (* F (* C (* A A)))))) (- (* B B) (* 4.0 (* A C)))))
assert(A < C);
double code(double A, double B, double C, double F) {
return -sqrt((-16.0 * (F * (C * (A * A))))) / ((B * B) - (4.0 * (A * C)));
}
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(((-16.0d0) * (f * (c * (a * a))))) / ((b * b) - (4.0d0 * (a * c)))
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
return -Math.sqrt((-16.0 * (F * (C * (A * A))))) / ((B * B) - (4.0 * (A * C)));
}
[A, C] = sort([A, C]) def code(A, B, C, F): return -math.sqrt((-16.0 * (F * (C * (A * A))))) / ((B * B) - (4.0 * (A * C)))
A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(-sqrt(Float64(-16.0 * Float64(F * Float64(C * Float64(A * A)))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))) end
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt((-16.0 * (F * (C * (A * A))))) / ((B * B) - (4.0 * (A * C)));
end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[((-N[Sqrt[N[(-16.0 * N[(F * N[(C * N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{-\sqrt{-16 \cdot \left(F \cdot \left(C \cdot \left(A \cdot A\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\end{array}
Initial program 16.2%
associate-*l*16.2%
unpow216.2%
+-commutative16.2%
unpow216.2%
associate-*l*16.2%
unpow216.2%
Simplified16.2%
Taylor expanded in A around inf 10.6%
Taylor expanded in A around inf 11.7%
associate-*r*12.1%
unpow212.1%
Simplified12.1%
Final simplification12.1%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (- (/ (sqrt (* -8.0 (* A (* F (* C C))))) (- (* B B) (* 4.0 (* A C))))))
assert(A < C);
double code(double A, double B, double C, double F) {
return -(sqrt((-8.0 * (A * (F * (C * C))))) / ((B * B) - (4.0 * (A * C))));
}
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(((-8.0d0) * (a * (f * (c * c))))) / ((b * b) - (4.0d0 * (a * c))))
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
return -(Math.sqrt((-8.0 * (A * (F * (C * C))))) / ((B * B) - (4.0 * (A * C))));
}
[A, C] = sort([A, C]) def code(A, B, C, F): return -(math.sqrt((-8.0 * (A * (F * (C * C))))) / ((B * B) - (4.0 * (A * C))))
A, C = sort([A, C]) function code(A, B, C, F) return Float64(-Float64(sqrt(Float64(-8.0 * Float64(A * Float64(F * Float64(C * C))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))))) end
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -(sqrt((-8.0 * (A * (F * (C * C))))) / ((B * B) - (4.0 * (A * C))));
end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := (-N[(N[Sqrt[N[(-8.0 * N[(A * N[(F * N[(C * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
-\frac{\sqrt{-8 \cdot \left(A \cdot \left(F \cdot \left(C \cdot C\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\end{array}
Initial program 16.2%
associate-*l*16.2%
unpow216.2%
+-commutative16.2%
unpow216.2%
associate-*l*16.2%
unpow216.2%
Simplified16.2%
Taylor expanded in A around inf 10.6%
Taylor expanded in C around inf 3.6%
unpow23.6%
Simplified3.6%
Final simplification3.6%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* 0.5 (* (sqrt (/ F A)) (/ B C))))
assert(A < C);
double code(double A, double B, double C, double F) {
return 0.5 * (sqrt((F / A)) * (B / C));
}
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 = 0.5d0 * (sqrt((f / a)) * (b / c))
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
return 0.5 * (Math.sqrt((F / A)) * (B / C));
}
[A, C] = sort([A, C]) def code(A, B, C, F): return 0.5 * (math.sqrt((F / A)) * (B / C))
A, C = sort([A, C]) function code(A, B, C, F) return Float64(0.5 * Float64(sqrt(Float64(F / A)) * Float64(B / C))) end
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = 0.5 * (sqrt((F / A)) * (B / C));
end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(0.5 * N[(N[Sqrt[N[(F / A), $MachinePrecision]], $MachinePrecision] * N[(B / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
0.5 \cdot \left(\sqrt{\frac{F}{A}} \cdot \frac{B}{C}\right)
\end{array}
Initial program 16.2%
associate-*l*16.2%
unpow216.2%
+-commutative16.2%
unpow216.2%
associate-*l*16.2%
unpow216.2%
Simplified16.2%
Taylor expanded in A around inf 10.6%
Taylor expanded in C around 0 2.5%
unpow22.5%
rem-square-sqrt2.5%
Simplified2.5%
Taylor expanded in B around 0 1.7%
Final simplification1.7%
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)) B)))
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (sqrt((A * F)) / 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)) / 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)) / B);
}
[A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.sqrt((A * F)) / B)
A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)) end
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (sqrt((A * F)) / 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] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \frac{\sqrt{A \cdot F}}{B}
\end{array}
Initial program 16.2%
associate-*l*16.2%
unpow216.2%
+-commutative16.2%
unpow216.2%
associate-*l*16.2%
unpow216.2%
Simplified16.2%
Taylor expanded in A around inf 10.6%
Taylor expanded in C around 0 2.5%
unpow22.5%
rem-square-sqrt2.5%
Simplified2.5%
Taylor expanded in B around inf 2.9%
associate-*r/2.9%
*-commutative2.9%
*-rgt-identity2.9%
Simplified2.9%
Final simplification2.9%
herbie shell --seed 2023174
(FPCore (A B C F)
:name "ABCF->ab-angle a"
:precision binary64
(/ (- (sqrt (* (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F)) (+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))) (- (pow B 2.0) (* (* 4.0 A) C))))