
(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 9 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}
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (* (* 4.0 A) C))
(t_1 (* 2.0 (* (- (pow B_m 2.0) t_0) F)))
(t_2 (- t_0 (pow B_m 2.0)))
(t_3
(/
(sqrt (* t_1 (- (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0))))))
t_2)))
(if (<= t_3 (- INFINITY))
(*
(sqrt
(*
F
(/
(+ A (- C (hypot (- A C) B_m)))
(+ (pow B_m 2.0) (* -4.0 (* A C))))))
(- (sqrt 2.0)))
(if (<= t_3 -1e-168)
t_3
(if (<= t_3 INFINITY)
(/ (sqrt (* t_1 (+ A (+ A (/ (* (pow B_m 2.0) -0.5) C))))) t_2)
(*
(sqrt 2.0)
(-
(pow
(*
(pow B_m -0.16666666666666666)
(pow (/ -1.0 F) -0.16666666666666666))
3.0))))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = (4.0 * A) * C;
double t_1 = 2.0 * ((pow(B_m, 2.0) - t_0) * F);
double t_2 = t_0 - pow(B_m, 2.0);
double t_3 = sqrt((t_1 * ((A + C) - sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / t_2;
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = sqrt((F * ((A + (C - hypot((A - C), B_m))) / (pow(B_m, 2.0) + (-4.0 * (A * C)))))) * -sqrt(2.0);
} else if (t_3 <= -1e-168) {
tmp = t_3;
} else if (t_3 <= ((double) INFINITY)) {
tmp = sqrt((t_1 * (A + (A + ((pow(B_m, 2.0) * -0.5) / C))))) / t_2;
} else {
tmp = sqrt(2.0) * -pow((pow(B_m, -0.16666666666666666) * pow((-1.0 / F), -0.16666666666666666)), 3.0);
}
return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double t_0 = (4.0 * A) * C;
double t_1 = 2.0 * ((Math.pow(B_m, 2.0) - t_0) * F);
double t_2 = t_0 - Math.pow(B_m, 2.0);
double t_3 = Math.sqrt((t_1 * ((A + C) - Math.sqrt((Math.pow(B_m, 2.0) + Math.pow((A - C), 2.0)))))) / t_2;
double tmp;
if (t_3 <= -Double.POSITIVE_INFINITY) {
tmp = Math.sqrt((F * ((A + (C - Math.hypot((A - C), B_m))) / (Math.pow(B_m, 2.0) + (-4.0 * (A * C)))))) * -Math.sqrt(2.0);
} else if (t_3 <= -1e-168) {
tmp = t_3;
} else if (t_3 <= Double.POSITIVE_INFINITY) {
tmp = Math.sqrt((t_1 * (A + (A + ((Math.pow(B_m, 2.0) * -0.5) / C))))) / t_2;
} else {
tmp = Math.sqrt(2.0) * -Math.pow((Math.pow(B_m, -0.16666666666666666) * Math.pow((-1.0 / F), -0.16666666666666666)), 3.0);
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): t_0 = (4.0 * A) * C t_1 = 2.0 * ((math.pow(B_m, 2.0) - t_0) * F) t_2 = t_0 - math.pow(B_m, 2.0) t_3 = math.sqrt((t_1 * ((A + C) - math.sqrt((math.pow(B_m, 2.0) + math.pow((A - C), 2.0)))))) / t_2 tmp = 0 if t_3 <= -math.inf: tmp = math.sqrt((F * ((A + (C - math.hypot((A - C), B_m))) / (math.pow(B_m, 2.0) + (-4.0 * (A * C)))))) * -math.sqrt(2.0) elif t_3 <= -1e-168: tmp = t_3 elif t_3 <= math.inf: tmp = math.sqrt((t_1 * (A + (A + ((math.pow(B_m, 2.0) * -0.5) / C))))) / t_2 else: tmp = math.sqrt(2.0) * -math.pow((math.pow(B_m, -0.16666666666666666) * math.pow((-1.0 / F), -0.16666666666666666)), 3.0) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(Float64(4.0 * A) * C) t_1 = Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) t_2 = Float64(t_0 - (B_m ^ 2.0)) t_3 = Float64(sqrt(Float64(t_1 * Float64(Float64(A + C) - sqrt(Float64((B_m ^ 2.0) + (Float64(A - C) ^ 2.0)))))) / t_2) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(sqrt(Float64(F * Float64(Float64(A + Float64(C - hypot(Float64(A - C), B_m))) / Float64((B_m ^ 2.0) + Float64(-4.0 * Float64(A * C)))))) * Float64(-sqrt(2.0))); elseif (t_3 <= -1e-168) tmp = t_3; elseif (t_3 <= Inf) tmp = Float64(sqrt(Float64(t_1 * Float64(A + Float64(A + Float64(Float64((B_m ^ 2.0) * -0.5) / C))))) / t_2); else tmp = Float64(sqrt(2.0) * Float64(-(Float64((B_m ^ -0.16666666666666666) * (Float64(-1.0 / F) ^ -0.16666666666666666)) ^ 3.0))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
t_0 = (4.0 * A) * C;
t_1 = 2.0 * (((B_m ^ 2.0) - t_0) * F);
t_2 = t_0 - (B_m ^ 2.0);
t_3 = sqrt((t_1 * ((A + C) - sqrt(((B_m ^ 2.0) + ((A - C) ^ 2.0)))))) / t_2;
tmp = 0.0;
if (t_3 <= -Inf)
tmp = sqrt((F * ((A + (C - hypot((A - C), B_m))) / ((B_m ^ 2.0) + (-4.0 * (A * C)))))) * -sqrt(2.0);
elseif (t_3 <= -1e-168)
tmp = t_3;
elseif (t_3 <= Inf)
tmp = sqrt((t_1 * (A + (A + (((B_m ^ 2.0) * -0.5) / C))))) / t_2;
else
tmp = sqrt(2.0) * -(((B_m ^ -0.16666666666666666) * ((-1.0 / F) ^ -0.16666666666666666)) ^ 3.0);
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(t$95$1 * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B$95$m, 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, (-Infinity)], N[(N[Sqrt[N[(F * N[(N[(A + N[(C - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$3, -1e-168], t$95$3, If[LessEqual[t$95$3, Infinity], N[(N[Sqrt[N[(t$95$1 * N[(A + N[(A + N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] * -0.5), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Power[N[(N[Power[B$95$m, -0.16666666666666666], $MachinePrecision] * N[Power[N[(-1.0 / F), $MachinePrecision], -0.16666666666666666], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision])), $MachinePrecision]]]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \left(4 \cdot A\right) \cdot C\\
t_1 := 2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\\
t_2 := t\_0 - {B\_m}^{2}\\
t_3 := \frac{\sqrt{t\_1 \cdot \left(\left(A + C\right) - \sqrt{{B\_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t\_2}\\
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;\sqrt{F \cdot \frac{A + \left(C - \mathsf{hypot}\left(A - C, B\_m\right)\right)}{{B\_m}^{2} + -4 \cdot \left(A \cdot C\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{elif}\;t\_3 \leq -1 \cdot 10^{-168}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;\frac{\sqrt{t\_1 \cdot \left(A + \left(A + \frac{{B\_m}^{2} \cdot -0.5}{C}\right)\right)}}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-{\left({B\_m}^{-0.16666666666666666} \cdot {\left(\frac{-1}{F}\right)}^{-0.16666666666666666}\right)}^{3}\right)\\
\end{array}
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -inf.0Initial program 3.4%
add-cbrt-cube3.4%
pow33.4%
unpow23.4%
unpow23.4%
hypot-define3.4%
Applied egg-rr3.4%
Taylor expanded in F around 0 13.9%
mul-1-neg13.9%
Simplified54.7%
if -inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -1e-168Initial program 97.6%
if -1e-168 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < +inf.0Initial program 13.6%
Taylor expanded in C around inf 18.9%
associate--l+18.9%
associate-*r/18.9%
mul-1-neg18.9%
Simplified18.9%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) Initial program 0.0%
Simplified1.0%
add-cube-cbrt1.0%
pow31.0%
Applied egg-rr0.4%
Taylor expanded in B around inf 22.0%
Taylor expanded in F around -inf 22.0%
rem-cube-cbrt22.0%
mul-1-neg22.0%
distribute-rgt-neg-in22.0%
Simplified22.2%
Final simplification39.4%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (* (* 4.0 A) C)))
(if (<= (pow B_m 2.0) 4e-18)
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (+ A A)))
(- t_0 (pow B_m 2.0)))
(if (<= (pow B_m 2.0) 2e+287)
(*
(sqrt
(*
F
(/
(+ A (- C (hypot (- A C) B_m)))
(+ (pow B_m 2.0) (* -4.0 (* A C))))))
(- (sqrt 2.0)))
(*
(sqrt 2.0)
(-
(pow
(*
(pow B_m -0.16666666666666666)
(pow (/ -1.0 F) -0.16666666666666666))
3.0)))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = (4.0 * A) * C;
double tmp;
if (pow(B_m, 2.0) <= 4e-18) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (A + A))) / (t_0 - pow(B_m, 2.0));
} else if (pow(B_m, 2.0) <= 2e+287) {
tmp = sqrt((F * ((A + (C - hypot((A - C), B_m))) / (pow(B_m, 2.0) + (-4.0 * (A * C)))))) * -sqrt(2.0);
} else {
tmp = sqrt(2.0) * -pow((pow(B_m, -0.16666666666666666) * pow((-1.0 / F), -0.16666666666666666)), 3.0);
}
return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double t_0 = (4.0 * A) * C;
double tmp;
if (Math.pow(B_m, 2.0) <= 4e-18) {
tmp = Math.sqrt(((2.0 * ((Math.pow(B_m, 2.0) - t_0) * F)) * (A + A))) / (t_0 - Math.pow(B_m, 2.0));
} else if (Math.pow(B_m, 2.0) <= 2e+287) {
tmp = Math.sqrt((F * ((A + (C - Math.hypot((A - C), B_m))) / (Math.pow(B_m, 2.0) + (-4.0 * (A * C)))))) * -Math.sqrt(2.0);
} else {
tmp = Math.sqrt(2.0) * -Math.pow((Math.pow(B_m, -0.16666666666666666) * Math.pow((-1.0 / F), -0.16666666666666666)), 3.0);
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): t_0 = (4.0 * A) * C tmp = 0 if math.pow(B_m, 2.0) <= 4e-18: tmp = math.sqrt(((2.0 * ((math.pow(B_m, 2.0) - t_0) * F)) * (A + A))) / (t_0 - math.pow(B_m, 2.0)) elif math.pow(B_m, 2.0) <= 2e+287: tmp = math.sqrt((F * ((A + (C - math.hypot((A - C), B_m))) / (math.pow(B_m, 2.0) + (-4.0 * (A * C)))))) * -math.sqrt(2.0) else: tmp = math.sqrt(2.0) * -math.pow((math.pow(B_m, -0.16666666666666666) * math.pow((-1.0 / F), -0.16666666666666666)), 3.0) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(Float64(4.0 * A) * C) tmp = 0.0 if ((B_m ^ 2.0) <= 4e-18) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(A + A))) / Float64(t_0 - (B_m ^ 2.0))); elseif ((B_m ^ 2.0) <= 2e+287) tmp = Float64(sqrt(Float64(F * Float64(Float64(A + Float64(C - hypot(Float64(A - C), B_m))) / Float64((B_m ^ 2.0) + Float64(-4.0 * Float64(A * C)))))) * Float64(-sqrt(2.0))); else tmp = Float64(sqrt(2.0) * Float64(-(Float64((B_m ^ -0.16666666666666666) * (Float64(-1.0 / F) ^ -0.16666666666666666)) ^ 3.0))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
t_0 = (4.0 * A) * C;
tmp = 0.0;
if ((B_m ^ 2.0) <= 4e-18)
tmp = sqrt(((2.0 * (((B_m ^ 2.0) - t_0) * F)) * (A + A))) / (t_0 - (B_m ^ 2.0));
elseif ((B_m ^ 2.0) <= 2e+287)
tmp = sqrt((F * ((A + (C - hypot((A - C), B_m))) / ((B_m ^ 2.0) + (-4.0 * (A * C)))))) * -sqrt(2.0);
else
tmp = sqrt(2.0) * -(((B_m ^ -0.16666666666666666) * ((-1.0 / F) ^ -0.16666666666666666)) ^ 3.0);
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e-18], N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+287], N[(N[Sqrt[N[(F * N[(N[(A + N[(C - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Power[N[(N[Power[B$95$m, -0.16666666666666666], $MachinePrecision] * N[Power[N[(-1.0 / F), $MachinePrecision], -0.16666666666666666], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \left(4 \cdot A\right) \cdot C\\
\mathbf{if}\;{B\_m}^{2} \leq 4 \cdot 10^{-18}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(A + A\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+287}:\\
\;\;\;\;\sqrt{F \cdot \frac{A + \left(C - \mathsf{hypot}\left(A - C, B\_m\right)\right)}{{B\_m}^{2} + -4 \cdot \left(A \cdot C\right)}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-{\left({B\_m}^{-0.16666666666666666} \cdot {\left(\frac{-1}{F}\right)}^{-0.16666666666666666}\right)}^{3}\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 4.0000000000000003e-18Initial program 19.7%
Taylor expanded in C around inf 17.4%
sub-neg17.4%
mul-1-neg17.4%
remove-double-neg17.4%
Simplified17.4%
if 4.0000000000000003e-18 < (pow.f64 B #s(literal 2 binary64)) < 2.0000000000000002e287Initial program 30.1%
add-cbrt-cube25.9%
pow325.9%
unpow225.9%
unpow225.9%
hypot-define25.9%
Applied egg-rr25.9%
Taylor expanded in F around 0 36.8%
mul-1-neg36.8%
Simplified59.2%
if 2.0000000000000002e287 < (pow.f64 B #s(literal 2 binary64)) Initial program 1.6%
Simplified3.0%
add-cube-cbrt2.9%
pow32.9%
Applied egg-rr2.9%
Taylor expanded in B around inf 35.3%
Taylor expanded in F around -inf 35.3%
rem-cube-cbrt35.3%
mul-1-neg35.3%
distribute-rgt-neg-in35.3%
Simplified35.7%
Final simplification33.9%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (* (* 4.0 A) C)))
(if (<= (pow B_m 2.0) 2e+18)
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (+ A A)))
(- t_0 (pow B_m 2.0)))
(if (<= (pow B_m 2.0) 1e+256)
(*
(/ (* B_m (sqrt 2.0)) (+ (pow B_m 2.0) (* -4.0 (* A C))))
(- (sqrt (* F (- A (hypot B_m A))))))
(*
(sqrt 2.0)
(-
(pow
(*
(pow B_m -0.16666666666666666)
(pow (/ -1.0 F) -0.16666666666666666))
3.0)))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = (4.0 * A) * C;
double tmp;
if (pow(B_m, 2.0) <= 2e+18) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (A + A))) / (t_0 - pow(B_m, 2.0));
} else if (pow(B_m, 2.0) <= 1e+256) {
tmp = ((B_m * sqrt(2.0)) / (pow(B_m, 2.0) + (-4.0 * (A * C)))) * -sqrt((F * (A - hypot(B_m, A))));
} else {
tmp = sqrt(2.0) * -pow((pow(B_m, -0.16666666666666666) * pow((-1.0 / F), -0.16666666666666666)), 3.0);
}
return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double t_0 = (4.0 * A) * C;
double tmp;
if (Math.pow(B_m, 2.0) <= 2e+18) {
tmp = Math.sqrt(((2.0 * ((Math.pow(B_m, 2.0) - t_0) * F)) * (A + A))) / (t_0 - Math.pow(B_m, 2.0));
} else if (Math.pow(B_m, 2.0) <= 1e+256) {
tmp = ((B_m * Math.sqrt(2.0)) / (Math.pow(B_m, 2.0) + (-4.0 * (A * C)))) * -Math.sqrt((F * (A - Math.hypot(B_m, A))));
} else {
tmp = Math.sqrt(2.0) * -Math.pow((Math.pow(B_m, -0.16666666666666666) * Math.pow((-1.0 / F), -0.16666666666666666)), 3.0);
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): t_0 = (4.0 * A) * C tmp = 0 if math.pow(B_m, 2.0) <= 2e+18: tmp = math.sqrt(((2.0 * ((math.pow(B_m, 2.0) - t_0) * F)) * (A + A))) / (t_0 - math.pow(B_m, 2.0)) elif math.pow(B_m, 2.0) <= 1e+256: tmp = ((B_m * math.sqrt(2.0)) / (math.pow(B_m, 2.0) + (-4.0 * (A * C)))) * -math.sqrt((F * (A - math.hypot(B_m, A)))) else: tmp = math.sqrt(2.0) * -math.pow((math.pow(B_m, -0.16666666666666666) * math.pow((-1.0 / F), -0.16666666666666666)), 3.0) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(Float64(4.0 * A) * C) tmp = 0.0 if ((B_m ^ 2.0) <= 2e+18) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(A + A))) / Float64(t_0 - (B_m ^ 2.0))); elseif ((B_m ^ 2.0) <= 1e+256) tmp = Float64(Float64(Float64(B_m * sqrt(2.0)) / Float64((B_m ^ 2.0) + Float64(-4.0 * Float64(A * C)))) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); else tmp = Float64(sqrt(2.0) * Float64(-(Float64((B_m ^ -0.16666666666666666) * (Float64(-1.0 / F) ^ -0.16666666666666666)) ^ 3.0))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
t_0 = (4.0 * A) * C;
tmp = 0.0;
if ((B_m ^ 2.0) <= 2e+18)
tmp = sqrt(((2.0 * (((B_m ^ 2.0) - t_0) * F)) * (A + A))) / (t_0 - (B_m ^ 2.0));
elseif ((B_m ^ 2.0) <= 1e+256)
tmp = ((B_m * sqrt(2.0)) / ((B_m ^ 2.0) + (-4.0 * (A * C)))) * -sqrt((F * (A - hypot(B_m, A))));
else
tmp = sqrt(2.0) * -(((B_m ^ -0.16666666666666666) * ((-1.0 / F) ^ -0.16666666666666666)) ^ 3.0);
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+18], N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+256], N[(N[(N[(B$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] / N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Power[N[(N[Power[B$95$m, -0.16666666666666666], $MachinePrecision] * N[Power[N[(-1.0 / F), $MachinePrecision], -0.16666666666666666], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \left(4 \cdot A\right) \cdot C\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{+18}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(A + A\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{+256}:\\
\;\;\;\;\frac{B\_m \cdot \sqrt{2}}{{B\_m}^{2} + -4 \cdot \left(A \cdot C\right)} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-{\left({B\_m}^{-0.16666666666666666} \cdot {\left(\frac{-1}{F}\right)}^{-0.16666666666666666}\right)}^{3}\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2e18Initial program 23.2%
Taylor expanded in C around inf 18.9%
sub-neg18.9%
mul-1-neg18.9%
remove-double-neg18.9%
Simplified18.9%
if 2e18 < (pow.f64 B #s(literal 2 binary64)) < 1e256Initial program 26.4%
Taylor expanded in C around 0 10.3%
associate-*r*10.3%
neg-mul-110.3%
+-commutative10.3%
unpow210.3%
unpow210.3%
hypot-define14.9%
Simplified14.9%
Taylor expanded in F around 0 10.3%
mul-1-neg10.3%
cancel-sign-sub-inv10.3%
metadata-eval10.3%
+-commutative10.3%
unpow210.3%
unpow210.3%
hypot-undefine14.9%
Simplified14.9%
if 1e256 < (pow.f64 B #s(literal 2 binary64)) Initial program 3.0%
Simplified4.3%
add-cube-cbrt4.2%
pow34.2%
Applied egg-rr4.2%
Taylor expanded in B around inf 34.8%
Taylor expanded in F around -inf 34.8%
rem-cube-cbrt34.8%
mul-1-neg34.8%
distribute-rgt-neg-in34.8%
Simplified35.2%
Final simplification23.0%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (* (* 4.0 A) C)))
(if (<= (pow B_m 2.0) 2e+18)
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (+ A A)))
(- t_0 (pow B_m 2.0)))
(if (<= (pow B_m 2.0) 1e+256)
(* (sqrt (* F (- A (hypot B_m A)))) (/ (sqrt 2.0) (- B_m)))
(*
(sqrt 2.0)
(-
(pow
(*
(pow B_m -0.16666666666666666)
(pow (/ -1.0 F) -0.16666666666666666))
3.0)))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = (4.0 * A) * C;
double tmp;
if (pow(B_m, 2.0) <= 2e+18) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (A + A))) / (t_0 - pow(B_m, 2.0));
} else if (pow(B_m, 2.0) <= 1e+256) {
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
} else {
tmp = sqrt(2.0) * -pow((pow(B_m, -0.16666666666666666) * pow((-1.0 / F), -0.16666666666666666)), 3.0);
}
return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double t_0 = (4.0 * A) * C;
double tmp;
if (Math.pow(B_m, 2.0) <= 2e+18) {
tmp = Math.sqrt(((2.0 * ((Math.pow(B_m, 2.0) - t_0) * F)) * (A + A))) / (t_0 - Math.pow(B_m, 2.0));
} else if (Math.pow(B_m, 2.0) <= 1e+256) {
tmp = Math.sqrt((F * (A - Math.hypot(B_m, A)))) * (Math.sqrt(2.0) / -B_m);
} else {
tmp = Math.sqrt(2.0) * -Math.pow((Math.pow(B_m, -0.16666666666666666) * Math.pow((-1.0 / F), -0.16666666666666666)), 3.0);
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): t_0 = (4.0 * A) * C tmp = 0 if math.pow(B_m, 2.0) <= 2e+18: tmp = math.sqrt(((2.0 * ((math.pow(B_m, 2.0) - t_0) * F)) * (A + A))) / (t_0 - math.pow(B_m, 2.0)) elif math.pow(B_m, 2.0) <= 1e+256: tmp = math.sqrt((F * (A - math.hypot(B_m, A)))) * (math.sqrt(2.0) / -B_m) else: tmp = math.sqrt(2.0) * -math.pow((math.pow(B_m, -0.16666666666666666) * math.pow((-1.0 / F), -0.16666666666666666)), 3.0) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(Float64(4.0 * A) * C) tmp = 0.0 if ((B_m ^ 2.0) <= 2e+18) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(A + A))) / Float64(t_0 - (B_m ^ 2.0))); elseif ((B_m ^ 2.0) <= 1e+256) tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * Float64(sqrt(2.0) / Float64(-B_m))); else tmp = Float64(sqrt(2.0) * Float64(-(Float64((B_m ^ -0.16666666666666666) * (Float64(-1.0 / F) ^ -0.16666666666666666)) ^ 3.0))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
t_0 = (4.0 * A) * C;
tmp = 0.0;
if ((B_m ^ 2.0) <= 2e+18)
tmp = sqrt(((2.0 * (((B_m ^ 2.0) - t_0) * F)) * (A + A))) / (t_0 - (B_m ^ 2.0));
elseif ((B_m ^ 2.0) <= 1e+256)
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
else
tmp = sqrt(2.0) * -(((B_m ^ -0.16666666666666666) * ((-1.0 / F) ^ -0.16666666666666666)) ^ 3.0);
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+18], N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+256], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Power[N[(N[Power[B$95$m, -0.16666666666666666], $MachinePrecision] * N[Power[N[(-1.0 / F), $MachinePrecision], -0.16666666666666666], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \left(4 \cdot A\right) \cdot C\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{+18}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(A + A\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{elif}\;{B\_m}^{2} \leq 10^{+256}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(-{\left({B\_m}^{-0.16666666666666666} \cdot {\left(\frac{-1}{F}\right)}^{-0.16666666666666666}\right)}^{3}\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2e18Initial program 23.2%
Taylor expanded in C around inf 18.9%
sub-neg18.9%
mul-1-neg18.9%
remove-double-neg18.9%
Simplified18.9%
if 2e18 < (pow.f64 B #s(literal 2 binary64)) < 1e256Initial program 26.4%
Taylor expanded in C around 0 10.6%
associate-*r*10.6%
mul-1-neg10.6%
+-commutative10.6%
unpow210.6%
unpow210.6%
hypot-define15.0%
Simplified15.0%
if 1e256 < (pow.f64 B #s(literal 2 binary64)) Initial program 3.0%
Simplified4.3%
add-cube-cbrt4.2%
pow34.2%
Applied egg-rr4.2%
Taylor expanded in B around inf 34.8%
Taylor expanded in F around -inf 34.8%
rem-cube-cbrt34.8%
mul-1-neg34.8%
distribute-rgt-neg-in34.8%
Simplified35.2%
Final simplification23.0%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (* (* 4.0 A) C)))
(if (<= B_m 1050000000.0)
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (+ A A)))
(- t_0 (pow B_m 2.0)))
(if (<= B_m 2.3e+254)
(* (sqrt (* F (- A (hypot B_m A)))) (/ (sqrt 2.0) (- B_m)))
(* (- (sqrt 2.0)) (pow (pow (/ F (- B_m)) 0.16666666666666666) 3.0))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = (4.0 * A) * C;
double tmp;
if (B_m <= 1050000000.0) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (A + A))) / (t_0 - pow(B_m, 2.0));
} else if (B_m <= 2.3e+254) {
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
} else {
tmp = -sqrt(2.0) * pow(pow((F / -B_m), 0.16666666666666666), 3.0);
}
return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double t_0 = (4.0 * A) * C;
double tmp;
if (B_m <= 1050000000.0) {
tmp = Math.sqrt(((2.0 * ((Math.pow(B_m, 2.0) - t_0) * F)) * (A + A))) / (t_0 - Math.pow(B_m, 2.0));
} else if (B_m <= 2.3e+254) {
tmp = Math.sqrt((F * (A - Math.hypot(B_m, A)))) * (Math.sqrt(2.0) / -B_m);
} else {
tmp = -Math.sqrt(2.0) * Math.pow(Math.pow((F / -B_m), 0.16666666666666666), 3.0);
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): t_0 = (4.0 * A) * C tmp = 0 if B_m <= 1050000000.0: tmp = math.sqrt(((2.0 * ((math.pow(B_m, 2.0) - t_0) * F)) * (A + A))) / (t_0 - math.pow(B_m, 2.0)) elif B_m <= 2.3e+254: tmp = math.sqrt((F * (A - math.hypot(B_m, A)))) * (math.sqrt(2.0) / -B_m) else: tmp = -math.sqrt(2.0) * math.pow(math.pow((F / -B_m), 0.16666666666666666), 3.0) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(Float64(4.0 * A) * C) tmp = 0.0 if (B_m <= 1050000000.0) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(A + A))) / Float64(t_0 - (B_m ^ 2.0))); elseif (B_m <= 2.3e+254) tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * Float64(sqrt(2.0) / Float64(-B_m))); else tmp = Float64(Float64(-sqrt(2.0)) * ((Float64(F / Float64(-B_m)) ^ 0.16666666666666666) ^ 3.0)); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
t_0 = (4.0 * A) * C;
tmp = 0.0;
if (B_m <= 1050000000.0)
tmp = sqrt(((2.0 * (((B_m ^ 2.0) - t_0) * F)) * (A + A))) / (t_0 - (B_m ^ 2.0));
elseif (B_m <= 2.3e+254)
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
else
tmp = -sqrt(2.0) * (((F / -B_m) ^ 0.16666666666666666) ^ 3.0);
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, If[LessEqual[B$95$m, 1050000000.0], N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 2.3e+254], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[2.0], $MachinePrecision]) * N[Power[N[Power[N[(F / (-B$95$m)), $MachinePrecision], 0.16666666666666666], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \left(4 \cdot A\right) \cdot C\\
\mathbf{if}\;B\_m \leq 1050000000:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(A + A\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{elif}\;B\_m \leq 2.3 \cdot 10^{+254}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{2}\right) \cdot {\left({\left(\frac{F}{-B\_m}\right)}^{0.16666666666666666}\right)}^{3}\\
\end{array}
\end{array}
if B < 1.05e9Initial program 19.9%
Taylor expanded in C around inf 13.8%
sub-neg13.8%
mul-1-neg13.8%
remove-double-neg13.8%
Simplified13.8%
if 1.05e9 < B < 2.29999999999999998e254Initial program 15.1%
Taylor expanded in C around 0 13.2%
associate-*r*13.2%
mul-1-neg13.2%
+-commutative13.2%
unpow213.2%
unpow213.2%
hypot-define38.9%
Simplified38.9%
if 2.29999999999999998e254 < B Initial program 0.0%
Simplified0.0%
add-cube-cbrt0.0%
pow30.0%
Applied egg-rr0.0%
Taylor expanded in B around inf 74.2%
Taylor expanded in F around 0 0.0%
Simplified57.0%
Final simplification21.1%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (if (<= F -2.7e+57) (* (- (sqrt 2.0)) (pow (pow (* F (/ -1.0 B_m)) 0.16666666666666666) 3.0)) (* (sqrt (* F (- A (hypot B_m A)))) (/ (sqrt 2.0) (- B_m)))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -2.7e+57) {
tmp = -sqrt(2.0) * pow(pow((F * (-1.0 / B_m)), 0.16666666666666666), 3.0);
} else {
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
}
return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -2.7e+57) {
tmp = -Math.sqrt(2.0) * Math.pow(Math.pow((F * (-1.0 / B_m)), 0.16666666666666666), 3.0);
} else {
tmp = Math.sqrt((F * (A - Math.hypot(B_m, A)))) * (Math.sqrt(2.0) / -B_m);
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if F <= -2.7e+57: tmp = -math.sqrt(2.0) * math.pow(math.pow((F * (-1.0 / B_m)), 0.16666666666666666), 3.0) else: tmp = math.sqrt((F * (A - math.hypot(B_m, A)))) * (math.sqrt(2.0) / -B_m) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (F <= -2.7e+57) tmp = Float64(Float64(-sqrt(2.0)) * ((Float64(F * Float64(-1.0 / B_m)) ^ 0.16666666666666666) ^ 3.0)); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * Float64(sqrt(2.0) / Float64(-B_m))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (F <= -2.7e+57)
tmp = -sqrt(2.0) * (((F * (-1.0 / B_m)) ^ 0.16666666666666666) ^ 3.0);
else
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[F, -2.7e+57], N[((-N[Sqrt[2.0], $MachinePrecision]) * N[Power[N[Power[N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision], 0.16666666666666666], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;F \leq -2.7 \cdot 10^{+57}:\\
\;\;\;\;\left(-\sqrt{2}\right) \cdot {\left({\left(F \cdot \frac{-1}{B\_m}\right)}^{0.16666666666666666}\right)}^{3}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if F < -2.6999999999999998e57Initial program 11.7%
Simplified13.6%
add-cube-cbrt13.5%
pow313.5%
Applied egg-rr12.5%
Taylor expanded in B around inf 17.4%
Taylor expanded in B around -inf 0.0%
rem-cube-cbrt0.0%
mul-1-neg0.0%
distribute-rgt-neg-in0.0%
Simplified17.8%
if -2.6999999999999998e57 < F Initial program 21.7%
Taylor expanded in C around 0 9.1%
associate-*r*9.1%
mul-1-neg9.1%
+-commutative9.1%
unpow29.1%
unpow29.1%
hypot-define18.4%
Simplified18.4%
Final simplification18.2%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (if (<= F -2.55e+57) (* (- (sqrt 2.0)) (pow (pow (/ F (- B_m)) 0.16666666666666666) 3.0)) (* (sqrt (* F (- A (hypot B_m A)))) (/ (sqrt 2.0) (- B_m)))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -2.55e+57) {
tmp = -sqrt(2.0) * pow(pow((F / -B_m), 0.16666666666666666), 3.0);
} else {
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
}
return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -2.55e+57) {
tmp = -Math.sqrt(2.0) * Math.pow(Math.pow((F / -B_m), 0.16666666666666666), 3.0);
} else {
tmp = Math.sqrt((F * (A - Math.hypot(B_m, A)))) * (Math.sqrt(2.0) / -B_m);
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if F <= -2.55e+57: tmp = -math.sqrt(2.0) * math.pow(math.pow((F / -B_m), 0.16666666666666666), 3.0) else: tmp = math.sqrt((F * (A - math.hypot(B_m, A)))) * (math.sqrt(2.0) / -B_m) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (F <= -2.55e+57) tmp = Float64(Float64(-sqrt(2.0)) * ((Float64(F / Float64(-B_m)) ^ 0.16666666666666666) ^ 3.0)); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * Float64(sqrt(2.0) / Float64(-B_m))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (F <= -2.55e+57)
tmp = -sqrt(2.0) * (((F / -B_m) ^ 0.16666666666666666) ^ 3.0);
else
tmp = sqrt((F * (A - hypot(B_m, A)))) * (sqrt(2.0) / -B_m);
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[F, -2.55e+57], N[((-N[Sqrt[2.0], $MachinePrecision]) * N[Power[N[Power[N[(F / (-B$95$m)), $MachinePrecision], 0.16666666666666666], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B$95$m)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;F \leq -2.55 \cdot 10^{+57}:\\
\;\;\;\;\left(-\sqrt{2}\right) \cdot {\left({\left(\frac{F}{-B\_m}\right)}^{0.16666666666666666}\right)}^{3}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\
\end{array}
\end{array}
if F < -2.55000000000000011e57Initial program 11.7%
Simplified13.6%
add-cube-cbrt13.5%
pow313.5%
Applied egg-rr12.5%
Taylor expanded in B around inf 17.4%
Taylor expanded in F around 0 0.0%
Simplified17.7%
if -2.55000000000000011e57 < F Initial program 21.7%
Taylor expanded in C around 0 9.1%
associate-*r*9.1%
mul-1-neg9.1%
+-commutative9.1%
unpow29.1%
unpow29.1%
hypot-define18.4%
Simplified18.4%
Final simplification18.2%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (* (- (sqrt 2.0)) (pow (pow (/ F (- B_m)) 0.16666666666666666) 3.0)))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return -sqrt(2.0) * pow(pow((F / -B_m), 0.16666666666666666), 3.0);
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = -sqrt(2.0d0) * (((f / -b_m) ** 0.16666666666666666d0) ** 3.0d0)
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return -Math.sqrt(2.0) * Math.pow(Math.pow((F / -B_m), 0.16666666666666666), 3.0);
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return -math.sqrt(2.0) * math.pow(math.pow((F / -B_m), 0.16666666666666666), 3.0)
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(Float64(-sqrt(2.0)) * ((Float64(F / Float64(-B_m)) ^ 0.16666666666666666) ^ 3.0)) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = -sqrt(2.0) * (((F / -B_m) ^ 0.16666666666666666) ^ 3.0);
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[((-N[Sqrt[2.0], $MachinePrecision]) * N[Power[N[Power[N[(F / (-B$95$m)), $MachinePrecision], 0.16666666666666666], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\left(-\sqrt{2}\right) \cdot {\left({\left(\frac{F}{-B\_m}\right)}^{0.16666666666666666}\right)}^{3}
\end{array}
Initial program 17.9%
Simplified23.9%
add-cube-cbrt23.5%
pow323.6%
Applied egg-rr23.0%
Taylor expanded in B around inf 16.0%
Taylor expanded in F around 0 0.0%
Simplified14.2%
Final simplification14.2%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (* -0.25 (* (sqrt (/ F A)) (/ (* B_m -2.0) C))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return -0.25 * (sqrt((F / A)) * ((B_m * -2.0) / C));
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (-0.25d0) * (sqrt((f / a)) * ((b_m * (-2.0d0)) / c))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return -0.25 * (Math.sqrt((F / A)) * ((B_m * -2.0) / C));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return -0.25 * (math.sqrt((F / A)) * ((B_m * -2.0) / C))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(-0.25 * Float64(sqrt(Float64(F / A)) * Float64(Float64(B_m * -2.0) / C))) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = -0.25 * (sqrt((F / A)) * ((B_m * -2.0) / C));
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[(-0.25 * N[(N[Sqrt[N[(F / A), $MachinePrecision]], $MachinePrecision] * N[(N[(B$95$m * -2.0), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
-0.25 \cdot \left(\sqrt{\frac{F}{A}} \cdot \frac{B\_m \cdot -2}{C}\right)
\end{array}
Initial program 17.9%
Taylor expanded in C around 0 7.1%
associate-*r*7.1%
neg-mul-17.1%
+-commutative7.1%
unpow27.1%
unpow27.1%
hypot-define8.9%
Simplified8.9%
Taylor expanded in A around -inf 0.0%
unpow20.0%
rem-square-sqrt1.8%
unpow21.8%
rem-square-sqrt1.8%
metadata-eval1.8%
Simplified1.8%
herbie shell --seed 2024111
(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))))