
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t_0}
\end{array}
\end{array}
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (* 4.0 (* A C)))
(t_1 (fma B B (* A (* C -4.0))))
(t_2 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_3
(/
(-
(sqrt
(*
(* 2.0 (* t_2 F))
(- (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
t_2)))
(if (<= t_3 -1e-213)
(/
(*
(sqrt (* 2.0 (* F (+ A (- C (hypot (- A C) B))))))
(- (sqrt (fma B B (* C (* A -4.0))))))
t_1)
(if (<= t_3 4e-54)
(/
(-
(sqrt
(*
2.0
(*
(* F (- t_0 (* B B)))
(- (- (* -0.5 (/ (- (- (* A A) (* A A)) (* B B)) C)) A) A)))))
(- (* B B) t_0))
(if (<= t_3 INFINITY)
(/
(*
(sqrt
(*
(+ C (- A (hypot B (- A C))))
(fma C (* A -8.0) (* B (* 2.0 B)))))
(- (sqrt F)))
t_1)
(* (/ (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 = 4.0 * (A * C);
double t_1 = fma(B, B, (A * (C * -4.0)));
double t_2 = pow(B, 2.0) - ((4.0 * A) * C);
double t_3 = -sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((pow(B, 2.0) + pow((A - C), 2.0)))))) / t_2;
double tmp;
if (t_3 <= -1e-213) {
tmp = (sqrt((2.0 * (F * (A + (C - hypot((A - C), B)))))) * -sqrt(fma(B, B, (C * (A * -4.0))))) / t_1;
} else if (t_3 <= 4e-54) {
tmp = -sqrt((2.0 * ((F * (t_0 - (B * B))) * (((-0.5 * ((((A * A) - (A * A)) - (B * B)) / C)) - A) - A)))) / ((B * B) - t_0);
} else if (t_3 <= ((double) INFINITY)) {
tmp = (sqrt(((C + (A - hypot(B, (A - C)))) * fma(C, (A * -8.0), (B * (2.0 * B))))) * -sqrt(F)) / t_1;
} 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(4.0 * Float64(A * C)) t_1 = fma(B, B, Float64(A * Float64(C * -4.0))) t_2 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_3 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_2 * F)) * Float64(Float64(A + C) - sqrt(Float64((B ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_2) tmp = 0.0 if (t_3 <= -1e-213) tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(F * Float64(A + Float64(C - hypot(Float64(A - C), B)))))) * Float64(-sqrt(fma(B, B, Float64(C * Float64(A * -4.0)))))) / t_1); elseif (t_3 <= 4e-54) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * Float64(t_0 - Float64(B * B))) * Float64(Float64(Float64(-0.5 * Float64(Float64(Float64(Float64(A * A) - Float64(A * A)) - Float64(B * B)) / C)) - A) - A))))) / Float64(Float64(B * B) - t_0)); 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(B * Float64(2.0 * B))))) * Float64(-sqrt(F))) / t_1); 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[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(B * B + N[(A * N[(C * -4.0), $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[((-N[Sqrt[N[(N[(2.0 * N[(t$95$2 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, -1e-213], N[(N[(N[Sqrt[N[(2.0 * N[(F * N[(A + N[(C - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$3, 4e-54], N[((-N[Sqrt[N[(2.0 * N[(N[(F * N[(t$95$0 - N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(-0.5 * N[(N[(N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision] - N[(B * B), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision] - A), $MachinePrecision] - A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - t$95$0), $MachinePrecision]), $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[(B * N[(2.0 * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[F], $MachinePrecision])), $MachinePrecision] / t$95$1), $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 := 4 \cdot \left(A \cdot C\right)\\
t_1 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := \frac{-\sqrt{\left(2 \cdot \left(t_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\
\mathbf{if}\;t_3 \leq -1 \cdot 10^{-213}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(A + \left(C - \mathsf{hypot}\left(A - C, B\right)\right)\right)\right)} \cdot \left(-\sqrt{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}\right)}{t_1}\\
\mathbf{elif}\;t_3 \leq 4 \cdot 10^{-54}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot \left(t_0 - B \cdot B\right)\right) \cdot \left(\left(-0.5 \cdot \frac{\left(A \cdot A - A \cdot A\right) - B \cdot B}{C} - A\right) - A\right)\right)}}{B \cdot B - t_0}\\
\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, B \cdot \left(2 \cdot B\right)\right)} \cdot \left(-\sqrt{F}\right)}{t_1}\\
\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))) < -9.9999999999999995e-214Initial program 48.9%
Simplified56.4%
sqrt-prod72.2%
associate-*r*72.2%
*-commutative72.2%
associate-*l*72.2%
associate--r-72.9%
+-commutative72.9%
Applied egg-rr72.9%
hypot-def61.1%
unpow261.1%
unpow261.1%
+-commutative61.1%
unpow261.1%
unpow261.1%
hypot-def72.9%
Simplified72.9%
if -9.9999999999999995e-214 < (/.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.0000000000000001e-54Initial program 10.8%
Simplified10.8%
Taylor expanded in C around inf 28.6%
associate--l+28.6%
associate--l+28.8%
unpow228.8%
unpow228.8%
unpow228.8%
mul-1-neg28.8%
mul-1-neg28.8%
sqr-neg28.8%
mul-1-neg28.8%
Simplified28.8%
if 4.0000000000000001e-54 < (/.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 57.1%
Simplified57.1%
sqrt-prod88.9%
associate--r-88.9%
associate-*r*88.9%
Applied egg-rr88.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.0%
Taylor expanded in C around 0 2.1%
mul-1-neg2.1%
*-commutative2.1%
+-commutative2.1%
unpow22.1%
unpow22.1%
hypot-def17.4%
Simplified17.4%
Final simplification42.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 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B -4.1e-35)
(/ (- (sqrt (* 2.0 (* t_1 (* F (+ A (- C (hypot B (- A C))))))))) t_1)
(if (<= B 1e-60)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) 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 = (B * B) - (4.0 * (A * C));
double t_1 = (B * B) + (-4.0 * (A * C));
double tmp;
if (B <= -4.1e-35) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + (C - hypot(B, (A - C)))))))) / t_1;
} else if (B <= 1e-60) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(A, B))));
}
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 (B <= -4.1e-35) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (A + (C - Math.hypot(B, (A - C)))))))) / t_1;
} else if (B <= 1e-60) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * (A - Math.hypot(A, B))));
}
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 B <= -4.1e-35: tmp = -math.sqrt((2.0 * (t_1 * (F * (A + (C - math.hypot(B, (A - C)))))))) / t_1 elif B <= 1e-60: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * (A - math.hypot(A, 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))) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= -4.1e-35) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C))))))))) / t_1); elseif (B <= 1e-60) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - hypot(A, 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));
t_1 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= -4.1e-35)
tmp = -sqrt((2.0 * (t_1 * (F * (A + (C - hypot(B, (A - C)))))))) / t_1;
elseif (B <= 1e-60)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(A, 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]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -4.1e-35], 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], If[LessEqual[B, 1e-60], 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[(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 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
t_1 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq -4.1 \cdot 10^{-35}:\\
\;\;\;\;\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{elif}\;B \leq 10^{-60}:\\
\;\;\;\;\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}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)}\right)\\
\end{array}
\end{array}
if B < -4.10000000000000026e-35Initial program 16.3%
Simplified16.3%
distribute-frac-neg16.3%
Applied egg-rr19.3%
if -4.10000000000000026e-35 < B < 9.9999999999999997e-61Initial program 28.4%
Simplified28.4%
Taylor expanded in A around -inf 26.3%
*-commutative26.3%
Simplified26.3%
distribute-frac-neg26.3%
associate-*l*27.3%
*-commutative27.3%
Applied egg-rr27.3%
if 9.9999999999999997e-61 < B Initial program 18.4%
Simplified18.4%
Taylor expanded in C around 0 23.4%
mul-1-neg23.4%
*-commutative23.4%
+-commutative23.4%
unpow223.4%
unpow223.4%
hypot-def43.4%
Simplified43.4%
Final simplification29.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 (+ (* B B) (* -4.0 (* A C)))))
(if (<= B -3.5e-36)
(/ (- (sqrt (* 2.0 (* t_1 (* F (+ A (- C (hypot B (- A C))))))))) t_1)
(if (<= B 2.2e-42)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A B)))))))))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 (B <= -3.5e-36) {
tmp = -sqrt((2.0 * (t_1 * (F * (A + (C - hypot(B, (A - C)))))))) / t_1;
} else if (B <= 2.2e-42) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
}
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 (B <= -3.5e-36) {
tmp = -Math.sqrt((2.0 * (t_1 * (F * (A + (C - Math.hypot(B, (A - C)))))))) / t_1;
} else if (B <= 2.2e-42) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * (A - B)));
}
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 B <= -3.5e-36: tmp = -math.sqrt((2.0 * (t_1 * (F * (A + (C - math.hypot(B, (A - C)))))))) / t_1 elif B <= 2.2e-42: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * (A - 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))) t_1 = Float64(Float64(B * B) + Float64(-4.0 * Float64(A * C))) tmp = 0.0 if (B <= -3.5e-36) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * Float64(A + Float64(C - hypot(B, Float64(A - C))))))))) / t_1); elseif (B <= 2.2e-42) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - 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));
t_1 = (B * B) + (-4.0 * (A * C));
tmp = 0.0;
if (B <= -3.5e-36)
tmp = -sqrt((2.0 * (t_1 * (F * (A + (C - hypot(B, (A - C)))))))) / t_1;
elseif (B <= 2.2e-42)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - 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]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, -3.5e-36], 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], If[LessEqual[B, 2.2e-42], 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[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $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 := B \cdot B + -4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq -3.5 \cdot 10^{-36}:\\
\;\;\;\;\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{elif}\;B \leq 2.2 \cdot 10^{-42}:\\
\;\;\;\;\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}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < -3.5e-36Initial program 16.3%
Simplified16.3%
distribute-frac-neg16.3%
Applied egg-rr19.3%
if -3.5e-36 < B < 2.20000000000000005e-42Initial program 29.2%
Simplified29.2%
Taylor expanded in A around -inf 25.4%
*-commutative25.4%
Simplified25.4%
distribute-frac-neg25.4%
associate-*l*26.4%
*-commutative26.4%
Applied egg-rr26.4%
if 2.20000000000000005e-42 < B Initial program 16.2%
Simplified16.2%
Taylor expanded in A around 0 15.0%
+-commutative15.0%
unpow215.0%
unpow215.0%
hypot-def15.0%
mul-1-neg15.0%
unpow215.0%
unpow215.0%
Simplified15.0%
Taylor expanded in C around 0 40.8%
associate-*r*40.8%
mul-1-neg40.8%
*-commutative40.8%
Simplified40.8%
Final simplification28.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 (<= B -4.2e-21)
(/ (- (sqrt (* 2.0 (* t_0 (* F (- A (hypot A B))))))) t_0)
(if (<= B 6.5e-43)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A 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.2e-21) {
tmp = -sqrt((2.0 * (t_0 * (F * (A - hypot(A, B)))))) / t_0;
} else if (B <= 6.5e-43) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
}
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 tmp;
if (B <= -4.2e-21) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (A - Math.hypot(A, B)))))) / t_0;
} else if (B <= 6.5e-43) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * (A - 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 <= -4.2e-21: tmp = -math.sqrt((2.0 * (t_0 * (F * (A - math.hypot(A, B)))))) / t_0 elif B <= 6.5e-43: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * (A - 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.2e-21) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(A - hypot(A, B))))))) / t_0); elseif (B <= 6.5e-43) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - 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 <= -4.2e-21)
tmp = -sqrt((2.0 * (t_0 * (F * (A - hypot(A, B)))))) / t_0;
elseif (B <= 6.5e-43)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - 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, -4.2e-21], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 6.5e-43], 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[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $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.2 \cdot 10^{-21}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 6.5 \cdot 10^{-43}:\\
\;\;\;\;\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}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < -4.20000000000000025e-21Initial program 15.8%
Simplified15.8%
Taylor expanded in C around 0 14.8%
+-commutative14.8%
unpow214.8%
unpow214.8%
hypot-def14.8%
Simplified14.8%
distribute-frac-neg14.8%
associate-*l*14.9%
Applied egg-rr14.9%
if -4.20000000000000025e-21 < B < 6.50000000000000001e-43Initial program 29.1%
Simplified29.1%
Taylor expanded in A around -inf 26.3%
*-commutative26.3%
Simplified26.3%
distribute-frac-neg26.3%
associate-*l*27.2%
*-commutative27.2%
Applied egg-rr27.2%
if 6.50000000000000001e-43 < B Initial program 16.2%
Simplified16.2%
Taylor expanded in A around 0 15.0%
+-commutative15.0%
unpow215.0%
unpow215.0%
hypot-def15.0%
mul-1-neg15.0%
unpow215.0%
unpow215.0%
Simplified15.0%
Taylor expanded in C around 0 40.8%
associate-*r*40.8%
mul-1-neg40.8%
*-commutative40.8%
Simplified40.8%
Final simplification27.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)))))
(if (<= B -1.8e+41)
(/ (- (sqrt (* 2.0 (* (- A (hypot A B)) (* F (* B B)))))) t_0)
(if (<= B 2.1e-42)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A 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 <= -1.8e+41) {
tmp = -sqrt((2.0 * ((A - hypot(A, B)) * (F * (B * B))))) / t_0;
} else if (B <= 2.1e-42) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - B)));
}
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 tmp;
if (B <= -1.8e+41) {
tmp = -Math.sqrt((2.0 * ((A - Math.hypot(A, B)) * (F * (B * B))))) / t_0;
} else if (B <= 2.1e-42) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * (A - 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 <= -1.8e+41: tmp = -math.sqrt((2.0 * ((A - math.hypot(A, B)) * (F * (B * B))))) / t_0 elif B <= 2.1e-42: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * (A - 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 <= -1.8e+41) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(A - hypot(A, B)) * Float64(F * Float64(B * B)))))) / t_0); elseif (B <= 2.1e-42) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - 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 <= -1.8e+41)
tmp = -sqrt((2.0 * ((A - hypot(A, B)) * (F * (B * B))))) / t_0;
elseif (B <= 2.1e-42)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - 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, -1.8e+41], N[((-N[Sqrt[N[(2.0 * N[(N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision] * N[(F * N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 2.1e-42], 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[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $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 -1.8 \cdot 10^{+41}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(A - \mathsf{hypot}\left(A, B\right)\right) \cdot \left(F \cdot \left(B \cdot B\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 2.1 \cdot 10^{-42}:\\
\;\;\;\;\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}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < -1.80000000000000013e41Initial program 11.8%
Simplified11.8%
Taylor expanded in C around 0 10.4%
+-commutative10.4%
unpow210.4%
unpow210.4%
hypot-def10.4%
Simplified10.4%
Taylor expanded in B around inf 10.8%
unpow210.8%
Simplified10.8%
if -1.80000000000000013e41 < B < 2.10000000000000006e-42Initial program 29.0%
Simplified29.0%
Taylor expanded in A around -inf 26.0%
*-commutative26.0%
Simplified26.0%
distribute-frac-neg26.0%
associate-*l*26.8%
*-commutative26.8%
Applied egg-rr26.8%
if 2.10000000000000006e-42 < B Initial program 16.2%
Simplified16.2%
Taylor expanded in A around 0 15.0%
+-commutative15.0%
unpow215.0%
unpow215.0%
hypot-def15.0%
mul-1-neg15.0%
unpow215.0%
unpow215.0%
Simplified15.0%
Taylor expanded in C around 0 40.8%
associate-*r*40.8%
mul-1-neg40.8%
*-commutative40.8%
Simplified40.8%
Final simplification27.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 (<= B 7.2e-45)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A 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 <= 7.2e-45) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - 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 <= 7.2d-45) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (2.0d0 * a))))) / t_0
else
tmp = (sqrt(2.0d0) / b) * -sqrt((f * (a - 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 <= 7.2e-45) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = (Math.sqrt(2.0) / B) * -Math.sqrt((F * (A - 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 <= 7.2e-45: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = (math.sqrt(2.0) / B) * -math.sqrt((F * (A - 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 <= 7.2e-45) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - 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 <= 7.2e-45)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - 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, 7.2e-45], 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[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B), $MachinePrecision]), $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 7.2 \cdot 10^{-45}:\\
\;\;\;\;\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}}{B} \cdot \left(-\sqrt{F \cdot \left(A - B\right)}\right)\\
\end{array}
\end{array}
if B < 7.20000000000000001e-45Initial program 23.7%
Simplified23.7%
Taylor expanded in A around -inf 18.3%
*-commutative18.3%
Simplified18.3%
distribute-frac-neg18.3%
associate-*l*18.9%
*-commutative18.9%
Applied egg-rr18.9%
if 7.20000000000000001e-45 < B Initial program 16.2%
Simplified16.2%
Taylor expanded in A around 0 15.0%
+-commutative15.0%
unpow215.0%
unpow215.0%
hypot-def15.0%
mul-1-neg15.0%
unpow215.0%
unpow215.0%
Simplified15.0%
Taylor expanded in C around 0 40.8%
associate-*r*40.8%
mul-1-neg40.8%
*-commutative40.8%
Simplified40.8%
Final simplification25.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 (* 4.0 (* A C))) (t_1 (- (* B B) t_0)))
(if (<= C 1.25e+36)
(/ (- (sqrt (* 2.0 (* (* F t_1) (* 2.0 A))))) t_1)
(/
(-
(sqrt
(*
2.0
(*
(* F (- t_0 (* B B)))
(- (- (* -0.5 (/ (- (- (* A A) (* A A)) (* B B)) C)) A) A)))))
t_1))))assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = 4.0 * (A * C);
double t_1 = (B * B) - t_0;
double tmp;
if (C <= 1.25e+36) {
tmp = -sqrt((2.0 * ((F * t_1) * (2.0 * A)))) / t_1;
} else {
tmp = -sqrt((2.0 * ((F * (t_0 - (B * B))) * (((-0.5 * ((((A * A) - (A * A)) - (B * B)) / C)) - A) - A)))) / 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 = 4.0d0 * (a * c)
t_1 = (b * b) - t_0
if (c <= 1.25d+36) then
tmp = -sqrt((2.0d0 * ((f * t_1) * (2.0d0 * a)))) / t_1
else
tmp = -sqrt((2.0d0 * ((f * (t_0 - (b * b))) * ((((-0.5d0) * ((((a * a) - (a * a)) - (b * b)) / c)) - a) - a)))) / 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 = 4.0 * (A * C);
double t_1 = (B * B) - t_0;
double tmp;
if (C <= 1.25e+36) {
tmp = -Math.sqrt((2.0 * ((F * t_1) * (2.0 * A)))) / t_1;
} else {
tmp = -Math.sqrt((2.0 * ((F * (t_0 - (B * B))) * (((-0.5 * ((((A * A) - (A * A)) - (B * B)) / C)) - A) - A)))) / t_1;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = 4.0 * (A * C) t_1 = (B * B) - t_0 tmp = 0 if C <= 1.25e+36: tmp = -math.sqrt((2.0 * ((F * t_1) * (2.0 * A)))) / t_1 else: tmp = -math.sqrt((2.0 * ((F * (t_0 - (B * B))) * (((-0.5 * ((((A * A) - (A * A)) - (B * B)) / C)) - A) - A)))) / t_1 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(4.0 * Float64(A * C)) t_1 = Float64(Float64(B * B) - t_0) tmp = 0.0 if (C <= 1.25e+36) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_1) * Float64(2.0 * A))))) / t_1); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * Float64(t_0 - Float64(B * B))) * Float64(Float64(Float64(-0.5 * Float64(Float64(Float64(Float64(A * A) - Float64(A * A)) - Float64(B * B)) / C)) - A) - A))))) / t_1); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = 4.0 * (A * C);
t_1 = (B * B) - t_0;
tmp = 0.0;
if (C <= 1.25e+36)
tmp = -sqrt((2.0 * ((F * t_1) * (2.0 * A)))) / t_1;
else
tmp = -sqrt((2.0 * ((F * (t_0 - (B * B))) * (((-0.5 * ((((A * A) - (A * A)) - (B * B)) / C)) - A) - A)))) / 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[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(B * B), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[C, 1.25e+36], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$1), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(N[(F * N[(t$95$0 - N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(-0.5 * N[(N[(N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision] - N[(B * B), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision] - A), $MachinePrecision] - A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision]]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := 4 \cdot \left(A \cdot C\right)\\
t_1 := B \cdot B - t_0\\
\mathbf{if}\;C \leq 1.25 \cdot 10^{+36}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_1\right) \cdot \left(2 \cdot A\right)\right)}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot \left(t_0 - B \cdot B\right)\right) \cdot \left(\left(-0.5 \cdot \frac{\left(A \cdot A - A \cdot A\right) - B \cdot B}{C} - A\right) - A\right)\right)}}{t_1}\\
\end{array}
\end{array}
if C < 1.24999999999999994e36Initial program 28.5%
Simplified28.5%
Taylor expanded in A around -inf 11.7%
*-commutative11.7%
Simplified11.7%
if 1.24999999999999994e36 < C Initial program 5.0%
Simplified5.0%
Taylor expanded in C around inf 25.2%
associate--l+25.2%
associate--l+25.2%
unpow225.2%
unpow225.2%
unpow225.2%
mul-1-neg25.2%
mul-1-neg25.2%
sqr-neg25.2%
mul-1-neg25.2%
Simplified25.2%
Final simplification15.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)))))
(if (<= B 3.2e-25)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(/ (- (sqrt (* 2.0 (* (* F t_0) (- (+ A C) B))))) 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 <= 3.2e-25) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / 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 <= 3.2d-25) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (2.0d0 * a))))) / t_0
else
tmp = -sqrt((2.0d0 * ((f * t_0) * ((a + c) - b)))) / 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 <= 3.2e-25) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -Math.sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / 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 <= 3.2e-25: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = -math.sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / 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 <= 3.2e-25) 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_0) * Float64(Float64(A + C) - B))))) / 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 <= 3.2e-25)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = -sqrt((2.0 * ((F * t_0) * ((A + C) - B)))) / 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, 3.2e-25], 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$0), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - B), $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 3.2 \cdot 10^{-25}:\\
\;\;\;\;\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_0\right) \cdot \left(\left(A + C\right) - B\right)\right)}}{t_0}\\
\end{array}
\end{array}
if B < 3.2000000000000001e-25Initial program 23.2%
Simplified23.2%
Taylor expanded in A around -inf 18.0%
*-commutative18.0%
Simplified18.0%
distribute-frac-neg18.0%
associate-*l*18.5%
*-commutative18.5%
Applied egg-rr18.5%
if 3.2000000000000001e-25 < B Initial program 16.9%
Simplified16.9%
Taylor expanded in B around inf 13.2%
Final simplification17.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))))) (/ (- (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 21.6%
Simplified21.6%
Taylor expanded in A around -inf 14.1%
*-commutative14.1%
Simplified14.1%
distribute-frac-neg14.1%
associate-*l*14.6%
*-commutative14.6%
Applied egg-rr14.6%
Final simplification14.6%
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 430000000.0)
(-
(/
(sqrt (* 2.0 (* (* (* A A) -8.0) (* C F))))
(- (* B B) (* 4.0 (* A C)))))
(* -2.0 (/ (sqrt (* A F)) B))))assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 430000000.0) {
tmp = -(sqrt((2.0 * (((A * A) * -8.0) * (C * F)))) / ((B * B) - (4.0 * (A * C))));
} else {
tmp = -2.0 * (sqrt((A * 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) :: tmp
if (b <= 430000000.0d0) then
tmp = -(sqrt((2.0d0 * (((a * a) * (-8.0d0)) * (c * f)))) / ((b * b) - (4.0d0 * (a * c))))
else
tmp = (-2.0d0) * (sqrt((a * f)) / b)
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= 430000000.0) {
tmp = -(Math.sqrt((2.0 * (((A * A) * -8.0) * (C * F)))) / ((B * B) - (4.0 * (A * C))));
} else {
tmp = -2.0 * (Math.sqrt((A * F)) / B);
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= 430000000.0: tmp = -(math.sqrt((2.0 * (((A * A) * -8.0) * (C * F)))) / ((B * B) - (4.0 * (A * C)))) else: tmp = -2.0 * (math.sqrt((A * F)) / B) return tmp
A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 430000000.0) tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(Float64(Float64(A * A) * -8.0) * Float64(C * F)))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))))); else tmp = Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (B <= 430000000.0)
tmp = -(sqrt((2.0 * (((A * A) * -8.0) * (C * F)))) / ((B * B) - (4.0 * (A * C))));
else
tmp = -2.0 * (sqrt((A * 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_] := If[LessEqual[B, 430000000.0], (-N[(N[Sqrt[N[(2.0 * N[(N[(N[(A * A), $MachinePrecision] * -8.0), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 430000000:\\
\;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(\left(A \cdot A\right) \cdot -8\right) \cdot \left(C \cdot F\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\end{array}
\end{array}
if B < 4.3e8Initial program 24.6%
Simplified24.6%
Taylor expanded in A around -inf 17.6%
*-commutative17.6%
Simplified17.6%
Taylor expanded in B around 0 13.2%
associate-*r*13.1%
unpow213.1%
*-commutative13.1%
Simplified13.1%
if 4.3e8 < B Initial program 12.1%
Simplified12.1%
Taylor expanded in A around -inf 3.4%
*-commutative3.4%
Simplified3.4%
Taylor expanded in B around inf 6.2%
associate-*r/6.3%
*-rgt-identity6.3%
*-commutative6.3%
Simplified6.3%
Final simplification11.5%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (/ (- (sqrt (* 2.0 (* (- (* B B) (* 4.0 (* A C))) (* F (* 2.0 A)))))) (* A (* C -4.0))))
assert(A < C);
double code(double A, double B, double C, double F) {
return -sqrt((2.0 * (((B * B) - (4.0 * (A * C))) * (F * (2.0 * A))))) / (A * (C * -4.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((2.0d0 * (((b * b) - (4.0d0 * (a * c))) * (f * (2.0d0 * a))))) / (a * (c * (-4.0d0)))
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
return -Math.sqrt((2.0 * (((B * B) - (4.0 * (A * C))) * (F * (2.0 * A))))) / (A * (C * -4.0));
}
[A, C] = sort([A, C]) def code(A, B, C, F): return -math.sqrt((2.0 * (((B * B) - (4.0 * (A * C))) * (F * (2.0 * A))))) / (A * (C * -4.0))
A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) * Float64(F * Float64(2.0 * A)))))) / Float64(A * Float64(C * -4.0))) end
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt((2.0 * (((B * B) - (4.0 * (A * C))) * (F * (2.0 * A))))) / (A * (C * -4.0));
end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[((-N[Sqrt[N[(2.0 * N[(N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{-\sqrt{2 \cdot \left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{A \cdot \left(C \cdot -4\right)}
\end{array}
Initial program 21.6%
Simplified21.6%
Taylor expanded in A around -inf 14.1%
*-commutative14.1%
Simplified14.1%
distribute-frac-neg14.1%
associate-*l*14.6%
*-commutative14.6%
Applied egg-rr14.6%
Taylor expanded in B around 0 13.4%
*-commutative13.4%
associate-*r*13.4%
Simplified13.4%
Final simplification13.4%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (/ (- (sqrt (* 2.0 (* (* 2.0 A) (* F (* A (* C -4.0))))))) (- (* B B) (* 4.0 (* A C)))))
assert(A < C);
double code(double A, double B, double C, double F) {
return -sqrt((2.0 * ((2.0 * A) * (F * (A * (C * -4.0)))))) / ((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((2.0d0 * ((2.0d0 * a) * (f * (a * (c * (-4.0d0))))))) / ((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((2.0 * ((2.0 * A) * (F * (A * (C * -4.0)))))) / ((B * B) - (4.0 * (A * C)));
}
[A, C] = sort([A, C]) def code(A, B, C, F): return -math.sqrt((2.0 * ((2.0 * A) * (F * (A * (C * -4.0)))))) / ((B * B) - (4.0 * (A * C)))
A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(2.0 * A) * Float64(F * Float64(A * Float64(C * -4.0))))))) / 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((2.0 * ((2.0 * A) * (F * (A * (C * -4.0)))))) / ((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[(2.0 * N[(N[(2.0 * A), $MachinePrecision] * N[(F * N[(A * N[(C * -4.0), $MachinePrecision]), $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{2 \cdot \left(\left(2 \cdot A\right) \cdot \left(F \cdot \left(A \cdot \left(C \cdot -4\right)\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}
\end{array}
Initial program 21.6%
Simplified21.6%
Taylor expanded in A around -inf 14.1%
*-commutative14.1%
Simplified14.1%
Taylor expanded in B around 0 13.6%
*-commutative13.4%
associate-*r*13.4%
Simplified13.6%
Final simplification13.6%
NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= B -4.7e-307) (* 2.0 (/ (sqrt (* A F)) B)) (* -2.0 (/ (pow (* A F) 0.5) B))))
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= -4.7e-307) {
tmp = 2.0 * (sqrt((A * F)) / B);
} else {
tmp = -2.0 * (pow((A * F), 0.5) / B);
}
return tmp;
}
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (b <= (-4.7d-307)) then
tmp = 2.0d0 * (sqrt((a * f)) / b)
else
tmp = (-2.0d0) * (((a * f) ** 0.5d0) / b)
end if
code = tmp
end function
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= -4.7e-307) {
tmp = 2.0 * (Math.sqrt((A * F)) / B);
} else {
tmp = -2.0 * (Math.pow((A * F), 0.5) / B);
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= -4.7e-307: tmp = 2.0 * (math.sqrt((A * F)) / B) else: tmp = -2.0 * (math.pow((A * F), 0.5) / B) return tmp
A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= -4.7e-307) tmp = Float64(2.0 * Float64(sqrt(Float64(A * F)) / B)); else tmp = Float64(-2.0 * Float64((Float64(A * F) ^ 0.5) / B)); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (B <= -4.7e-307)
tmp = 2.0 * (sqrt((A * F)) / B);
else
tmp = -2.0 * (((A * F) ^ 0.5) / B);
end
tmp_2 = tmp;
end
NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, -4.7e-307], N[(2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Power[N[(A * F), $MachinePrecision], 0.5], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq -4.7 \cdot 10^{-307}:\\
\;\;\;\;2 \cdot \frac{\sqrt{A \cdot F}}{B}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{{\left(A \cdot F\right)}^{0.5}}{B}\\
\end{array}
\end{array}
if B < -4.69999999999999967e-307Initial program 21.7%
Simplified21.7%
Taylor expanded in A around -inf 16.3%
*-commutative16.3%
Simplified16.3%
Taylor expanded in B around -inf 3.4%
associate-*r/3.4%
*-rgt-identity3.4%
*-commutative3.4%
Simplified3.4%
if -4.69999999999999967e-307 < B Initial program 21.4%
Simplified21.4%
Taylor expanded in A around -inf 11.8%
*-commutative11.8%
Simplified11.8%
Taylor expanded in B around inf 5.0%
associate-*r/5.0%
*-rgt-identity5.0%
*-commutative5.0%
Simplified5.0%
pow1/25.2%
*-commutative5.2%
Applied egg-rr5.2%
Final simplification4.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 (/ (sqrt (* A F)) B))) (if (<= B -4.7e-307) (* 2.0 t_0) (* -2.0 t_0))))
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = sqrt((A * F)) / B;
double tmp;
if (B <= -4.7e-307) {
tmp = 2.0 * t_0;
} else {
tmp = -2.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 = sqrt((a * f)) / b
if (b <= (-4.7d-307)) then
tmp = 2.0d0 * t_0
else
tmp = (-2.0d0) * 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 = Math.sqrt((A * F)) / B;
double tmp;
if (B <= -4.7e-307) {
tmp = 2.0 * t_0;
} else {
tmp = -2.0 * t_0;
}
return tmp;
}
[A, C] = sort([A, C]) def code(A, B, C, F): t_0 = math.sqrt((A * F)) / B tmp = 0 if B <= -4.7e-307: tmp = 2.0 * t_0 else: tmp = -2.0 * t_0 return tmp
A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(sqrt(Float64(A * F)) / B) tmp = 0.0 if (B <= -4.7e-307) tmp = Float64(2.0 * t_0); else tmp = Float64(-2.0 * t_0); end return tmp end
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt((A * F)) / B;
tmp = 0.0;
if (B <= -4.7e-307)
tmp = 2.0 * t_0;
else
tmp = -2.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[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]}, If[LessEqual[B, -4.7e-307], N[(2.0 * t$95$0), $MachinePrecision], N[(-2.0 * t$95$0), $MachinePrecision]]]
\begin{array}{l}
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \frac{\sqrt{A \cdot F}}{B}\\
\mathbf{if}\;B \leq -4.7 \cdot 10^{-307}:\\
\;\;\;\;2 \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot t_0\\
\end{array}
\end{array}
if B < -4.69999999999999967e-307Initial program 21.7%
Simplified21.7%
Taylor expanded in A around -inf 16.3%
*-commutative16.3%
Simplified16.3%
Taylor expanded in B around -inf 3.4%
associate-*r/3.4%
*-rgt-identity3.4%
*-commutative3.4%
Simplified3.4%
if -4.69999999999999967e-307 < B Initial program 21.4%
Simplified21.4%
Taylor expanded in A around -inf 11.8%
*-commutative11.8%
Simplified11.8%
Taylor expanded in B around inf 5.0%
associate-*r/5.0%
*-rgt-identity5.0%
*-commutative5.0%
Simplified5.0%
Final simplification4.2%
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 21.6%
Simplified21.6%
Taylor expanded in A around -inf 14.1%
*-commutative14.1%
Simplified14.1%
Taylor expanded in B around inf 3.1%
associate-*r/3.1%
*-rgt-identity3.1%
*-commutative3.1%
Simplified3.1%
Final simplification3.1%
herbie shell --seed 2023178
(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))))