
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
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 (+ (* B B) (* -4.0 (* A C))))
(t_2 (* (* 4.0 A) C))
(t_3
(-
(/
(sqrt
(*
(- (sqrt (+ (pow B 2.0) (pow (- A C) 2.0))) (+ A C))
(* 2.0 (* F (- t_2 (pow B 2.0))))))
(- (pow B 2.0) t_2)))))
(if (<= t_3 -2e-200)
(/ (* (sqrt t_0) (* (sqrt (* F (- A (hypot B A)))) (- (sqrt 2.0)))) t_0)
(if (<= t_3 5e+60)
(/ (- (sqrt (* 2.0 (* t_1 (* F (* 2.0 A)))))) t_1)
(if (<= t_3 INFINITY)
(/
(*
(sqrt
(*
(+ C (- A (hypot B (- A C))))
(fma C (* A -8.0) (* 2.0 (* B B)))))
(- (sqrt F)))
t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A (hypot A 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 = (B * B) + (-4.0 * (A * C));
double t_2 = (4.0 * A) * C;
double t_3 = -(sqrt(((sqrt((pow(B, 2.0) + pow((A - C), 2.0))) - (A + C)) * (2.0 * (F * (t_2 - pow(B, 2.0)))))) / (pow(B, 2.0) - t_2));
double tmp;
if (t_3 <= -2e-200) {
tmp = (sqrt(t_0) * (sqrt((F * (A - hypot(B, A)))) * -sqrt(2.0))) / t_0;
} else if (t_3 <= 5e+60) {
tmp = -sqrt((2.0 * (t_1 * (F * (2.0 * A))))) / t_1;
} else if (t_3 <= ((double) INFINITY)) {
tmp = (sqrt(((C + (A - hypot(B, (A - C)))) * fma(C, (A * -8.0), (2.0 * (B * B))))) * -sqrt(F)) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(A, 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(Float64(B * B) + Float64(-4.0 * Float64(A * C))) t_2 = Float64(Float64(4.0 * A) * C) t_3 = Float64(-Float64(sqrt(Float64(Float64(sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))) - Float64(A + C)) * Float64(2.0 * Float64(F * Float64(t_2 - (B ^ 2.0)))))) / Float64((B ^ 2.0) - t_2))) tmp = 0.0 if (t_3 <= -2e-200) tmp = Float64(Float64(sqrt(t_0) * Float64(sqrt(Float64(F * Float64(A - hypot(B, A)))) * Float64(-sqrt(2.0)))) / t_0); elseif (t_3 <= 5e+60) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(2.0 * A)))))) / t_1); elseif (t_3 <= Inf) tmp = Float64(Float64(sqrt(Float64(Float64(C + Float64(A - hypot(B, Float64(A - C)))) * fma(C, Float64(A * -8.0), Float64(2.0 * Float64(B * B))))) * Float64(-sqrt(F))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - hypot(A, 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[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$3 = (-N[(N[Sqrt[N[(N[(N[Sqrt[N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(A + C), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(F * N[(t$95$2 - N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[Power[B, 2.0], $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[t$95$3, -2e-200], N[(N[(N[Sqrt[t$95$0], $MachinePrecision] * N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[t$95$3, 5e+60], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(N[(N[Sqrt[N[(N[(C + N[(A - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(C * N[(A * -8.0), $MachinePrecision] + N[(2.0 * N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[F], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $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 \cdot B + -4 \cdot \left(A \cdot C\right)\\
t_2 := \left(4 \cdot A\right) \cdot C\\
t_3 := -\frac{\sqrt{\left(\sqrt{{B}^{2} + {\left(A - C\right)}^{2}} - \left(A + C\right)\right) \cdot \left(2 \cdot \left(F \cdot \left(t_2 - {B}^{2}\right)\right)\right)}}{{B}^{2} - t_2}\\
\mathbf{if}\;t_3 \leq -2 \cdot 10^{-200}:\\
\;\;\;\;\frac{\sqrt{t_0} \cdot \left(\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \left(-\sqrt{2}\right)\right)}{t_0}\\
\mathbf{elif}\;t_3 \leq 5 \cdot 10^{+60}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_1}\\
\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\left(C + \left(A - \mathsf{hypot}\left(B, A - C\right)\right)\right) \cdot \mathsf{fma}\left(C, A \cdot -8, 2 \cdot \left(B \cdot B\right)\right)} \cdot \left(-\sqrt{F}\right)}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\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))) < -2e-200Initial program 45.2%
Simplified53.6%
sqrt-prod66.9%
*-commutative66.9%
associate--r-67.0%
+-commutative67.0%
*-commutative67.0%
Applied egg-rr67.0%
hypot-def54.7%
unpow254.7%
unpow254.7%
+-commutative54.7%
unpow254.7%
unpow254.7%
hypot-def67.0%
Simplified67.0%
Taylor expanded in C around 0 48.2%
unpow248.2%
unpow248.2%
hypot-def50.6%
Simplified50.6%
if -2e-200 < (/.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.99999999999999975e60Initial program 15.3%
Simplified15.3%
Taylor expanded in A around -inf 32.3%
distribute-frac-neg32.3%
associate-*l*35.4%
cancel-sign-sub-inv35.4%
metadata-eval35.4%
cancel-sign-sub-inv35.4%
metadata-eval35.4%
Applied egg-rr35.4%
if 4.99999999999999975e60 < (/.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 14.8%
Simplified30.8%
sqrt-prod62.1%
associate--r-62.1%
*-commutative62.1%
Applied egg-rr62.1%
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 C around 0 2.1%
mul-1-neg2.1%
+-commutative2.1%
unpow22.1%
unpow22.1%
hypot-def19.8%
Simplified19.8%
Final simplification35.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 (* A (* C -4.0))))
(if (<= B -1.65e+38)
(/
(*
(- (sqrt (* (- A (- (hypot (- A C) B) C)) (* 2.0 F))))
(sqrt (+ t_0 (* B B))))
(fma B B t_0))
(if (<= B 3.8e+40)
(/
(- (sqrt (* (* F (* 2.0 A)) (* 2.0 (fma B B (* -4.0 (* A C)))))))
(- (* B B) (* 4.0 (* A C))))
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A (hypot A B))))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = A * (C * -4.0);
double tmp;
if (B <= -1.65e+38) {
tmp = (-sqrt(((A - (hypot((A - C), B) - C)) * (2.0 * F))) * sqrt((t_0 + (B * B)))) / fma(B, B, t_0);
} else if (B <= 3.8e+40) {
tmp = -sqrt(((F * (2.0 * A)) * (2.0 * fma(B, B, (-4.0 * (A * C)))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(A, B))));
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(A * Float64(C * -4.0)) tmp = 0.0 if (B <= -1.65e+38) tmp = Float64(Float64(Float64(-sqrt(Float64(Float64(A - Float64(hypot(Float64(A - C), B) - C)) * Float64(2.0 * F)))) * sqrt(Float64(t_0 + Float64(B * B)))) / fma(B, B, t_0)); elseif (B <= 3.8e+40) tmp = Float64(Float64(-sqrt(Float64(Float64(F * Float64(2.0 * A)) * Float64(2.0 * fma(B, B, Float64(-4.0 * Float64(A * C))))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - hypot(A, 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[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -1.65e+38], N[(N[((-N[Sqrt[N[(N[(A - N[(N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision] - C), $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * N[Sqrt[N[(t$95$0 + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(B * B + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 3.8e+40], N[((-N[Sqrt[N[(N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(B * B + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := A \cdot \left(C \cdot -4\right)\\
\mathbf{if}\;B \leq -1.65 \cdot 10^{+38}:\\
\;\;\;\;\frac{\left(-\sqrt{\left(A - \left(\mathsf{hypot}\left(A - C, B\right) - C\right)\right) \cdot \left(2 \cdot F\right)}\right) \cdot \sqrt{t_0 + B \cdot B}}{\mathsf{fma}\left(B, B, t_0\right)}\\
\mathbf{elif}\;B \leq 3.8 \cdot 10^{+40}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot \left(2 \cdot A\right)\right) \cdot \left(2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}\right)\\
\end{array}
\end{array}
if B < -1.65e38Initial program 13.2%
Simplified16.9%
sqrt-prod21.9%
*-commutative21.9%
associate--r-21.9%
+-commutative21.9%
*-commutative21.9%
Applied egg-rr21.9%
hypot-def14.8%
unpow214.8%
unpow214.8%
+-commutative14.8%
unpow214.8%
unpow214.8%
hypot-def21.9%
Simplified21.9%
fma-udef21.9%
Applied egg-rr21.9%
if -1.65e38 < B < 3.80000000000000004e40Initial program 23.3%
Simplified23.2%
Taylor expanded in A around -inf 24.3%
*-un-lft-identity24.3%
associate-*l*25.7%
cancel-sign-sub-inv25.7%
metadata-eval25.7%
Applied egg-rr25.7%
*-lft-identity25.7%
associate-*r*25.8%
fma-def25.8%
Simplified25.8%
if 3.80000000000000004e40 < B Initial program 11.4%
Simplified11.4%
Taylor expanded in C around 0 20.0%
mul-1-neg20.0%
+-commutative20.0%
unpow220.0%
unpow220.0%
hypot-def55.4%
Simplified55.4%
Final simplification30.4%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B -1.62e+38)
(/
(* B (sqrt (* (- A (- (hypot (- A C) B) C)) (* 2.0 F))))
(fma B B (* A (* C -4.0))))
(if (<= B 4.2e+39)
(/
(- (sqrt (* (* F (* 2.0 A)) (* 2.0 (fma B B (* -4.0 (* A C)))))))
(- (* B B) (* 4.0 (* A C))))
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A (hypot A B)))))))))assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= -1.62e+38) {
tmp = (B * sqrt(((A - (hypot((A - C), B) - C)) * (2.0 * F)))) / fma(B, B, (A * (C * -4.0)));
} else if (B <= 4.2e+39) {
tmp = -sqrt(((F * (2.0 * A)) * (2.0 * fma(B, B, (-4.0 * (A * C)))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(A, B))));
}
return tmp;
}
A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= -1.62e+38) tmp = Float64(Float64(B * sqrt(Float64(Float64(A - Float64(hypot(Float64(A - C), B) - C)) * Float64(2.0 * F)))) / fma(B, B, Float64(A * Float64(C * -4.0)))); elseif (B <= 4.2e+39) tmp = Float64(Float64(-sqrt(Float64(Float64(F * Float64(2.0 * A)) * Float64(2.0 * fma(B, B, Float64(-4.0 * Float64(A * C))))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - hypot(A, 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, -1.62e+38], N[(N[(B * N[Sqrt[N[(N[(A - N[(N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision] - C), $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 4.2e+39], N[((-N[Sqrt[N[(N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(B * B + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq -1.62 \cdot 10^{+38}:\\
\;\;\;\;\frac{B \cdot \sqrt{\left(A - \left(\mathsf{hypot}\left(A - C, B\right) - C\right)\right) \cdot \left(2 \cdot F\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{elif}\;B \leq 4.2 \cdot 10^{+39}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot \left(2 \cdot A\right)\right) \cdot \left(2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}\right)\\
\end{array}
\end{array}
if B < -1.62000000000000001e38Initial program 13.2%
Simplified16.9%
sqrt-prod21.9%
*-commutative21.9%
associate--r-21.9%
+-commutative21.9%
*-commutative21.9%
Applied egg-rr21.9%
hypot-def14.8%
unpow214.8%
unpow214.8%
+-commutative14.8%
unpow214.8%
unpow214.8%
hypot-def21.9%
Simplified21.9%
Taylor expanded in B around -inf 21.4%
mul-1-neg21.4%
Simplified21.4%
if -1.62000000000000001e38 < B < 4.1999999999999997e39Initial program 23.3%
Simplified23.2%
Taylor expanded in A around -inf 24.3%
*-un-lft-identity24.3%
associate-*l*25.7%
cancel-sign-sub-inv25.7%
metadata-eval25.7%
Applied egg-rr25.7%
*-lft-identity25.7%
associate-*r*25.8%
fma-def25.8%
Simplified25.8%
if 4.1999999999999997e39 < B Initial program 11.4%
Simplified11.4%
Taylor expanded in C around 0 20.0%
mul-1-neg20.0%
+-commutative20.0%
unpow220.0%
unpow220.0%
hypot-def55.4%
Simplified55.4%
Final simplification30.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 (- (* B B) (* 4.0 (* A C)))) (t_1 (- A (hypot A B))))
(if (<= B -4.6e-24)
(- (/ (sqrt (* 2.0 (* t_1 (* F t_0)))) t_0))
(if (<= B 2.9e+39)
(/
(- (sqrt (* (* F (* 2.0 A)) (* 2.0 (fma B B (* -4.0 (* A C)))))))
t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* F t_1))))))))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 = A - hypot(A, B);
double tmp;
if (B <= -4.6e-24) {
tmp = -(sqrt((2.0 * (t_1 * (F * t_0)))) / t_0);
} else if (B <= 2.9e+39) {
tmp = -sqrt(((F * (2.0 * A)) * (2.0 * fma(B, B, (-4.0 * (A * C)))))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * t_1));
}
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(A - hypot(A, B)) tmp = 0.0 if (B <= -4.6e-24) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(t_1 * Float64(F * t_0)))) / t_0)); elseif (B <= 2.9e+39) tmp = Float64(Float64(-sqrt(Float64(Float64(F * Float64(2.0 * A)) * Float64(2.0 * fma(B, B, Float64(-4.0 * Float64(A * C))))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * 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[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -4.6e-24], (-N[(N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), If[LessEqual[B, 2.9e+39], N[((-N[Sqrt[N[(N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(B * B + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * t$95$1), $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 := A - \mathsf{hypot}\left(A, B\right)\\
\mathbf{if}\;B \leq -4.6 \cdot 10^{-24}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot t_0\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 2.9 \cdot 10^{+39}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot \left(2 \cdot A\right)\right) \cdot \left(2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot t_1}\right)\\
\end{array}
\end{array}
if B < -4.6000000000000002e-24Initial program 21.1%
Simplified21.0%
Taylor expanded in C around 0 16.7%
+-commutative16.7%
unpow216.7%
unpow216.7%
hypot-def18.0%
Simplified18.0%
if -4.6000000000000002e-24 < B < 2.90000000000000029e39Initial program 20.3%
Simplified20.2%
Taylor expanded in A around -inf 23.5%
*-un-lft-identity23.5%
associate-*l*25.1%
cancel-sign-sub-inv25.1%
metadata-eval25.1%
Applied egg-rr25.1%
*-lft-identity25.1%
associate-*r*25.2%
fma-def25.2%
Simplified25.2%
if 2.90000000000000029e39 < B Initial program 11.4%
Simplified11.4%
Taylor expanded in C around 0 20.0%
mul-1-neg20.0%
+-commutative20.0%
unpow220.0%
unpow220.0%
hypot-def55.4%
Simplified55.4%
Final simplification28.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)))) (t_1 (+ (* B B) (* -4.0 (* A C)))))
(if (<= C 1.8e+23)
(/ (- (sqrt (* 2.0 (* t_1 (* F (+ A (- C (hypot B (- A C))))))))) t_1)
(/
(-
(sqrt
(*
2.0
(*
(* F t_0)
(+ A (- A (* -0.5 (/ (- (- (* A A) (* A A)) (* B B)) 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));
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (C <= 1.8e+23) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + (C - hypot(B, (A - C)))))))) / t_1;
} else {
tmp = -sqrt((2.0 * ((F * t_0) * (A + (A - (-0.5 * ((((A * A) - (A * A)) - (B * B)) / C))))))) / t_0;
}
return tmp;
}
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 t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (C <= 1.8e+23) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (A + (C - Math.hypot(B, (A - C)))))))) / t_1;
} else {
tmp = -Math.sqrt((2.0 * ((F * t_0) * (A + (A - (-0.5 * ((((A * A) - (A * A)) - (B * B)) / C))))))) / t_0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = (B * B) + (-4.0 * (A * C)) tmp = 0 if C <= 1.8e+23: tmp = -math.sqrt((2.0 * (t_1 * (F * (A + (C - math.hypot(B, (A - C)))))))) / t_1 else: tmp = -math.sqrt((2.0 * ((F * t_0) * (A + (A - (-0.5 * ((((A * A) - (A * A)) - (B * B)) / C))))))) / 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(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (C <= 1.8e+23) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C))))))))) / t_1); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + Float64(A - Float64(-0.5 * Float64(Float64(Float64(Float64(A * A) - Float64(A * A)) - Float64(B * B)) / C)))))))) / 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));
t_1 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (C <= 1.8e+23)
tmp = -sqrt((2.0 * (t_1 * (F * (A + (C - hypot(B, (A - C)))))))) / t_1;
else
tmp = -sqrt((2.0 * ((F * t_0) * (A + (A - (-0.5 * ((((A * A) - (A * A)) - (B * B)) / C))))))) / 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]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[C, 1.8e+23], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * N[(A + N[(C - N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + N[(A - N[(-0.5 * N[(N[(N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision] - N[(B * B), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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)\\
t_1 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;C \leq 1.8 \cdot 10^{+23}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + \left(A - -0.5 \cdot \frac{\left(A \cdot A - A \cdot A\right) - B \cdot B}{C}\right)\right)\right)}}{t_0}\\
\end{array}
\end{array}
if C < 1.7999999999999999e23Initial program 23.8%
Simplified23.7%
distribute-frac-neg23.7%
Applied egg-rr30.7%
if 1.7999999999999999e23 < C Initial program 2.0%
Simplified2.0%
Taylor expanded in C around inf 31.3%
associate--l+31.3%
unpow231.3%
unpow231.3%
unpow231.3%
mul-1-neg31.3%
mul-1-neg31.3%
sqr-neg31.3%
mul-1-neg31.3%
Simplified31.3%
Final simplification30.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 (- (* B B) (* 4.0 (* A C)))) (t_1 (* F t_0)))
(if (<= C 5e+23)
(- (/ (sqrt (* 2.0 (* (- A (hypot A B)) t_1))) t_0))
(/
(-
(sqrt
(*
2.0
(* t_1 (+ A (- A (* -0.5 (/ (- (- (* A A) (* A A)) (* B B)) 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));
double t_1 = F * t_0;
double tmp;
if (C <= 5e+23) {
tmp = -(sqrt((2.0 * ((A - hypot(A, B)) * t_1))) / t_0);
} else {
tmp = -sqrt((2.0 * (t_1 * (A + (A - (-0.5 * ((((A * A) - (A * A)) - (B * B)) / C))))))) / t_0;
}
return tmp;
}
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 t_1 = F * t_0;
double tmp;
if (C <= 5e+23) {
tmp = -(Math.sqrt((2.0 * ((A - Math.hypot(A, B)) * t_1))) / t_0);
} else {
tmp = -Math.sqrt((2.0 * (t_1 * (A + (A - (-0.5 * ((((A * A) - (A * A)) - (B * B)) / C))))))) / t_0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) t_1 = F * t_0 tmp = 0 if C <= 5e+23: tmp = -(math.sqrt((2.0 * ((A - math.hypot(A, B)) * t_1))) / t_0) else: tmp = -math.sqrt((2.0 * (t_1 * (A + (A - (-0.5 * ((((A * A) - (A * A)) - (B * B)) / C))))))) / 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(F * t_0) tmp = 0.0 if (C <= 5e+23) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(A - hypot(A, B)) * t_1))) / t_0)); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A + Float64(A - Float64(-0.5 * Float64(Float64(Float64(Float64(A * A) - Float64(A * A)) - Float64(B * B)) / C)))))))) / 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));
t_1 = F * t_0;
tmp = 0.0;
if (C <= 5e+23)
tmp = -(sqrt((2.0 * ((A - hypot(A, B)) * t_1))) / t_0);
else
tmp = -sqrt((2.0 * (t_1 * (A + (A - (-0.5 * ((((A * A) - (A * A)) - (B * B)) / C))))))) / 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]}, Block[{t$95$1 = N[(F * t$95$0), $MachinePrecision]}, If[LessEqual[C, 5e+23], (-N[(N[Sqrt[N[(2.0 * N[(N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A + N[(A - N[(-0.5 * N[(N[(N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision] - N[(B * B), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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)\\
t_1 := F \cdot t_0\\
\mathbf{if}\;C \leq 5 \cdot 10^{+23}:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(A - \mathsf{hypot}\left(A, B\right)\right) \cdot t_1\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A + \left(A - -0.5 \cdot \frac{\left(A \cdot A - A \cdot A\right) - B \cdot B}{C}\right)\right)\right)}}{t_0}\\
\end{array}
\end{array}
if C < 4.9999999999999999e23Initial program 23.8%
Simplified23.7%
Taylor expanded in C around 0 17.5%
+-commutative17.5%
unpow217.5%
unpow217.5%
hypot-def19.7%
Simplified19.7%
if 4.9999999999999999e23 < C Initial program 2.0%
Simplified2.0%
Taylor expanded in C around inf 31.3%
associate--l+31.3%
unpow231.3%
unpow231.3%
unpow231.3%
mul-1-neg31.3%
mul-1-neg31.3%
sqr-neg31.3%
mul-1-neg31.3%
Simplified31.3%
Final simplification22.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 (- (* B B) (* 4.0 (* A C)))))
(if (<= A -3.5e-121)
(/ (- (sqrt (* (* F (* 2.0 A)) (* 2.0 (fma B B (* -4.0 (* A C))))))) t_0)
(/
(-
(sqrt
(*
2.0
(*
(* F t_0)
(+ A (- A (* -0.5 (/ (- (- (* A A) (* A A)) (* B B)) 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));
double tmp;
if (A <= -3.5e-121) {
tmp = -sqrt(((F * (2.0 * A)) * (2.0 * fma(B, B, (-4.0 * (A * C)))))) / t_0;
} else {
tmp = -sqrt((2.0 * ((F * t_0) * (A + (A - (-0.5 * ((((A * A) - (A * A)) - (B * B)) / C))))))) / 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 (A <= -3.5e-121) tmp = Float64(Float64(-sqrt(Float64(Float64(F * Float64(2.0 * A)) * Float64(2.0 * fma(B, B, Float64(-4.0 * Float64(A * C))))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + Float64(A - Float64(-0.5 * Float64(Float64(Float64(Float64(A * A) - Float64(A * A)) - Float64(B * B)) / C)))))))) / 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]}, If[LessEqual[A, -3.5e-121], N[((-N[Sqrt[N[(N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(B * B + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + N[(A - N[(-0.5 * N[(N[(N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision] - N[(B * B), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}\;A \leq -3.5 \cdot 10^{-121}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot \left(2 \cdot A\right)\right) \cdot \left(2 \cdot \mathsf{fma}\left(B, B, -4 \cdot \left(A \cdot C\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + \left(A - -0.5 \cdot \frac{\left(A \cdot A - A \cdot A\right) - B \cdot B}{C}\right)\right)\right)}}{t_0}\\
\end{array}
\end{array}
if A < -3.49999999999999993e-121Initial program 22.3%
Simplified22.2%
Taylor expanded in A around -inf 24.3%
*-un-lft-identity24.3%
associate-*l*26.5%
cancel-sign-sub-inv26.5%
metadata-eval26.5%
Applied egg-rr26.5%
*-lft-identity26.5%
associate-*r*26.6%
fma-def26.6%
Simplified26.6%
if -3.49999999999999993e-121 < A Initial program 16.7%
Simplified16.7%
Taylor expanded in C around inf 9.7%
associate--l+9.8%
unpow29.8%
unpow29.8%
unpow29.8%
mul-1-neg9.8%
mul-1-neg9.8%
sqr-neg9.8%
mul-1-neg9.8%
Simplified9.8%
Final simplification16.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 (+ (* B B) (* -4.0 (* A C)))) (t_1 (- (* B B) (* 4.0 (* A C)))))
(if (<= A -2.6e-119)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(/
(-
(sqrt
(*
2.0
(*
(* F t_1)
(+ A (- A (* -0.5 (/ (- (- (* A A) (* A A)) (* B B)) C))))))))
t_1))))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 = (B * B) - (4.0 * (A * C));
double tmp;
if (A <= -2.6e-119) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -sqrt((2.0 * ((F * t_1) * (A + (A - (-0.5 * ((((A * A) - (A * A)) - (B * B)) / C))))))) / t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = (b * b) + ((-4.0d0) * (a * c))
t_1 = (b * b) - (4.0d0 * (a * c))
if (a <= (-2.6d-119)) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (2.0d0 * a))))) / t_0
else
tmp = -sqrt((2.0d0 * ((f * t_1) * (a + (a - ((-0.5d0) * ((((a * a) - (a * a)) - (b * b)) / c))))))) / t_1
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 t_1 = (B * B) - (4.0 * (A * C));
double tmp;
if (A <= -2.6e-119) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -Math.sqrt((2.0 * ((F * t_1) * (A + (A - (-0.5 * ((((A * A) - (A * A)) - (B * B)) / C))))))) / t_1;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + (-4.0 * (A * C)) t_1 = (B * B) - (4.0 * (A * C)) tmp = 0 if A <= -2.6e-119: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = -math.sqrt((2.0 * ((F * t_1) * (A + (A - (-0.5 * ((((A * A) - (A * A)) - (B * B)) / C))))))) / t_1 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(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (A <= -2.6e-119) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_1) * Float64(A + Float64(A - Float64(-0.5 * Float64(Float64(Float64(Float64(A * A) - Float64(A * A)) - Float64(B * B)) / C)))))))) / t_1); 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));
t_1 = (B * B) - (4.0 * (A * C));
tmp = 0.0;
if (A <= -2.6e-119)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = -sqrt((2.0 * ((F * t_1) * (A + (A - (-0.5 * ((((A * A) - (A * A)) - (B * B)) / C))))))) / t_1;
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]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[A, -2.6e-119], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$1), $MachinePrecision] * N[(A + N[(A - N[(-0.5 * N[(N[(N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision] - N[(B * B), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $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 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;A \leq -2.6 \cdot 10^{-119}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_1\right) \cdot \left(A + \left(A - -0.5 \cdot \frac{\left(A \cdot A - A \cdot A\right) - B \cdot B}{C}\right)\right)\right)}}{t_1}\\
\end{array}
\end{array}
if A < -2.60000000000000012e-119Initial program 22.3%
Simplified22.2%
Taylor expanded in A around -inf 24.3%
distribute-frac-neg24.3%
associate-*l*26.5%
cancel-sign-sub-inv26.5%
metadata-eval26.5%
cancel-sign-sub-inv26.5%
metadata-eval26.5%
Applied egg-rr26.5%
if -2.60000000000000012e-119 < A Initial program 16.7%
Simplified16.7%
Taylor expanded in C around inf 9.7%
associate--l+9.8%
unpow29.8%
unpow29.8%
unpow29.8%
mul-1-neg9.8%
mul-1-neg9.8%
sqr-neg9.8%
mul-1-neg9.8%
Simplified9.8%
Final simplification16.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 (+ (* B B) (* -4.0 (* A C))))) (/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) 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 * (t_0 * (F * (2.0 * A))))) / 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 * (t_0 * (f * (2.0d0 * a))))) / 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 * (t_0 * (F * (2.0 * A))))) / 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 * (t_0 * (F * (2.0 * A))))) / 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(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / 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 * (t_0 * (F * (2.0 * A))))) / 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[(2.0 * N[(t$95$0 * N[(F * N[(2.0 * A), $MachinePrecision]), $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)\\
\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}
\end{array}
\end{array}
Initial program 18.9%
Simplified18.9%
Taylor expanded in A around -inf 15.2%
distribute-frac-neg15.2%
associate-*l*16.2%
cancel-sign-sub-inv16.2%
metadata-eval16.2%
cancel-sign-sub-inv16.2%
metadata-eval16.2%
Applied egg-rr16.2%
Final simplification16.2%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B -8.4e+37)
(* 2.0 (* (sqrt (* A F)) (/ 1.0 B)))
(/
(- (sqrt (* 2.0 (* (* 2.0 A) (* (* A -4.0) (* C F))))))
(- (* B B) (* 4.0 (* A C))))))assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= -8.4e+37) {
tmp = 2.0 * (sqrt((A * F)) * (1.0 / B));
} else {
tmp = -sqrt((2.0 * ((2.0 * A) * ((A * -4.0) * (C * F))))) / ((B * B) - (4.0 * (A * C)));
}
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 <= (-8.4d+37)) then
tmp = 2.0d0 * (sqrt((a * f)) * (1.0d0 / b))
else
tmp = -sqrt((2.0d0 * ((2.0d0 * a) * ((a * (-4.0d0)) * (c * f))))) / ((b * b) - (4.0d0 * (a * c)))
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= -8.4e+37) {
tmp = 2.0 * (Math.sqrt((A * F)) * (1.0 / B));
} else {
tmp = -Math.sqrt((2.0 * ((2.0 * A) * ((A * -4.0) * (C * F))))) / ((B * B) - (4.0 * (A * C)));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= -8.4e+37: tmp = 2.0 * (math.sqrt((A * F)) * (1.0 / B)) else: tmp = -math.sqrt((2.0 * ((2.0 * A) * ((A * -4.0) * (C * F))))) / ((B * B) - (4.0 * (A * C))) return tmp
A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= -8.4e+37) tmp = Float64(2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(Float64(A * -4.0) * Float64(C * F)))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (B <= -8.4e+37)
tmp = 2.0 * (sqrt((A * F)) * (1.0 / B));
else
tmp = -sqrt((2.0 * ((2.0 * A) * ((A * -4.0) * (C * F))))) / ((B * B) - (4.0 * (A * C)));
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[B, -8.4e+37], N[(2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(N[(2.0 * A), $MachinePrecision] * N[(N[(A * -4.0), $MachinePrecision] * N[(C * F), $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])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq -8.4 \cdot 10^{+37}:\\
\;\;\;\;2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(\left(A \cdot -4\right) \cdot \left(C \cdot F\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\end{array}
\end{array}
if B < -8.4000000000000004e37Initial program 14.6%
Simplified14.6%
Taylor expanded in A around -inf 2.5%
Taylor expanded in B around -inf 8.0%
if -8.4000000000000004e37 < B Initial program 20.1%
Simplified20.1%
Taylor expanded in A around -inf 18.9%
Taylor expanded in B around 0 16.0%
associate-*r*16.0%
Simplified16.0%
Final simplification14.2%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B -7.5e+37)
(* 2.0 (* (sqrt (* A F)) (/ 1.0 B)))
(/
(- (sqrt (* 2.0 (* -8.0 (* (* A A) (* C F))))))
(- (* B B) (* 4.0 (* A C))))))assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= -7.5e+37) {
tmp = 2.0 * (sqrt((A * F)) * (1.0 / B));
} else {
tmp = -sqrt((2.0 * (-8.0 * ((A * A) * (C * F))))) / ((B * B) - (4.0 * (A * C)));
}
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 <= (-7.5d+37)) then
tmp = 2.0d0 * (sqrt((a * f)) * (1.0d0 / b))
else
tmp = -sqrt((2.0d0 * ((-8.0d0) * ((a * a) * (c * f))))) / ((b * b) - (4.0d0 * (a * c)))
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= -7.5e+37) {
tmp = 2.0 * (Math.sqrt((A * F)) * (1.0 / B));
} else {
tmp = -Math.sqrt((2.0 * (-8.0 * ((A * A) * (C * F))))) / ((B * B) - (4.0 * (A * C)));
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= -7.5e+37: tmp = 2.0 * (math.sqrt((A * F)) * (1.0 / B)) else: tmp = -math.sqrt((2.0 * (-8.0 * ((A * A) * (C * F))))) / ((B * B) - (4.0 * (A * C))) return tmp
A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= -7.5e+37) tmp = Float64(2.0 * Float64(sqrt(Float64(A * F)) * Float64(1.0 / B))); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-8.0 * Float64(Float64(A * A) * Float64(C * F)))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (B <= -7.5e+37)
tmp = 2.0 * (sqrt((A * F)) * (1.0 / B));
else
tmp = -sqrt((2.0 * (-8.0 * ((A * A) * (C * F))))) / ((B * B) - (4.0 * (A * C)));
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[B, -7.5e+37], N[(2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(-8.0 * N[(N[(A * A), $MachinePrecision] * N[(C * F), $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])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq -7.5 \cdot 10^{+37}:\\
\;\;\;\;2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-8 \cdot \left(\left(A \cdot A\right) \cdot \left(C \cdot F\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\end{array}
\end{array}
if B < -7.5000000000000003e37Initial program 14.6%
Simplified14.6%
Taylor expanded in A around -inf 2.5%
Taylor expanded in B around -inf 8.0%
if -7.5000000000000003e37 < B Initial program 20.1%
Simplified20.1%
Taylor expanded in A around -inf 18.9%
Taylor expanded in B around 0 13.1%
unpow213.1%
Simplified13.1%
Final simplification12.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 (* (sqrt (* A F)) (/ 1.0 B)))) (if (<= B 1.35e-294) (* 2.0 t_0) (* t_0 -2.0))))
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt((A * F)) * (1.0 / B);
double tmp;
if (B <= 1.35e-294) {
tmp = 2.0 * t_0;
} else {
tmp = t_0 * -2.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 = sqrt((a * f)) * (1.0d0 / b)
if (b <= 1.35d-294) then
tmp = 2.0d0 * t_0
else
tmp = t_0 * (-2.0d0)
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = Math.sqrt((A * F)) * (1.0 / B);
double tmp;
if (B <= 1.35e-294) {
tmp = 2.0 * t_0;
} else {
tmp = t_0 * -2.0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt((A * F)) * (1.0 / B) tmp = 0 if B <= 1.35e-294: tmp = 2.0 * t_0 else: tmp = t_0 * -2.0 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(sqrt(Float64(A * F)) * Float64(1.0 / B)) tmp = 0.0 if (B <= 1.35e-294) tmp = Float64(2.0 * t_0); else tmp = Float64(t_0 * -2.0); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt((A * F)) * (1.0 / B);
tmp = 0.0;
if (B <= 1.35e-294)
tmp = 2.0 * t_0;
else
tmp = t_0 * -2.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[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 1.35e-294], N[(2.0 * t$95$0), $MachinePrecision], N[(t$95$0 * -2.0), $MachinePrecision]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \sqrt{A \cdot F} \cdot \frac{1}{B}\\
\mathbf{if}\;B \leq 1.35 \cdot 10^{-294}:\\
\;\;\;\;2 \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot -2\\
\end{array}
\end{array}
if B < 1.35000000000000005e-294Initial program 21.3%
Simplified21.2%
Taylor expanded in A around -inf 18.0%
Taylor expanded in B around -inf 6.5%
if 1.35000000000000005e-294 < B Initial program 16.4%
Simplified16.4%
Taylor expanded in A around -inf 12.3%
Taylor expanded in B around inf 4.6%
Final simplification5.6%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* (* (sqrt (* A F)) (/ 1.0 B)) -2.0))
assert(A < C);
double code(double A, double B, double C, double F) {
return (sqrt((A * F)) * (1.0 / B)) * -2.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
code = (sqrt((a * f)) * (1.0d0 / b)) * (-2.0d0)
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
return (Math.sqrt((A * F)) * (1.0 / B)) * -2.0;
}
[A, C] = sort([A, C]) def code(A, B, C, F): return (math.sqrt((A * F)) * (1.0 / B)) * -2.0
A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(sqrt(Float64(A * F)) * Float64(1.0 / B)) * -2.0) end
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = (sqrt((A * F)) * (1.0 / B)) * -2.0;
end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] * N[(1.0 / B), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right) \cdot -2
\end{array}
Initial program 18.9%
Simplified18.9%
Taylor expanded in A around -inf 15.2%
Taylor expanded in B around inf 2.8%
Final simplification2.8%
herbie shell --seed 2023187
(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))))