
(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 10 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 (fma B_m B_m (* A (* C -4.0))))
(t_1 (+ A (- C (hypot B_m (- A C)))))
(t_2 (- t_0))
(t_3 (* (* 4.0 A) C))
(t_4
(/
(sqrt
(*
(* 2.0 (* (- (pow B_m 2.0) t_3) F))
(- (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0))))))
(- t_3 (pow B_m 2.0)))))
(if (<= t_4 (- INFINITY))
(* (sqrt 2.0) (- (sqrt (* F (/ t_1 (fma -4.0 (* A C) (pow B_m 2.0)))))))
(if (<= t_4 -5e-214)
(/ (sqrt (* (* F t_0) (* 2.0 t_1))) t_2)
(if (<= t_4 0.0)
(* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C)))))
(if (<= t_4 INFINITY)
(/
(exp (* (+ (log (* F (* C -16.0))) (* -2.0 (log (/ -1.0 A)))) 0.5))
t_2)
(/ (sqrt (* 2.0 (* F (- C (hypot B_m C))))) (- 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 t_0 = fma(B_m, B_m, (A * (C * -4.0)));
double t_1 = A + (C - hypot(B_m, (A - C)));
double t_2 = -t_0;
double t_3 = (4.0 * A) * C;
double t_4 = sqrt(((2.0 * ((pow(B_m, 2.0) - t_3) * F)) * ((A + C) - sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / (t_3 - pow(B_m, 2.0));
double tmp;
if (t_4 <= -((double) INFINITY)) {
tmp = sqrt(2.0) * -sqrt((F * (t_1 / fma(-4.0, (A * C), pow(B_m, 2.0)))));
} else if (t_4 <= -5e-214) {
tmp = sqrt(((F * t_0) * (2.0 * t_1))) / t_2;
} else if (t_4 <= 0.0) {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
} else if (t_4 <= ((double) INFINITY)) {
tmp = exp(((log((F * (C * -16.0))) + (-2.0 * log((-1.0 / A)))) * 0.5)) / t_2;
} else {
tmp = sqrt((2.0 * (F * (C - hypot(B_m, C))))) / -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) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_1 = Float64(A + Float64(C - hypot(B_m, Float64(A - C)))) t_2 = Float64(-t_0) t_3 = Float64(Float64(4.0 * A) * C) t_4 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_3) * F)) * Float64(Float64(A + C) - sqrt(Float64((B_m ^ 2.0) + (Float64(A - C) ^ 2.0)))))) / Float64(t_3 - (B_m ^ 2.0))) tmp = 0.0 if (t_4 <= Float64(-Inf)) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(t_1 / fma(-4.0, Float64(A * C), (B_m ^ 2.0))))))); elseif (t_4 <= -5e-214) tmp = Float64(sqrt(Float64(Float64(F * t_0) * Float64(2.0 * t_1))) / t_2); elseif (t_4 <= 0.0) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); elseif (t_4 <= Inf) tmp = Float64(exp(Float64(Float64(log(Float64(F * Float64(C * -16.0))) + Float64(-2.0 * log(Float64(-1.0 / A)))) * 0.5)) / t_2); else tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(C - hypot(B_m, C))))) / Float64(-B_m)); end return 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[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(A + N[(C - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = (-t$95$0)}, Block[{t$95$3 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$3), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * 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] / N[(t$95$3 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(t$95$1 / N[(-4.0 * N[(A * C), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$4, -5e-214], N[(N[Sqrt[N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[t$95$4, 0.0], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(N[Exp[N[(N[(N[Log[N[(F * N[(C * -16.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-2.0 * N[Log[N[(-1.0 / A), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision], N[(N[Sqrt[N[(2.0 * N[(F * N[(C - N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $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 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := A + \left(C - \mathsf{hypot}\left(B\_m, A - C\right)\right)\\
t_2 := -t\_0\\
t_3 := \left(4 \cdot A\right) \cdot C\\
t_4 := \frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_3\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B\_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t\_3 - {B\_m}^{2}}\\
\mathbf{if}\;t\_4 \leq -\infty:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{t\_1}{\mathsf{fma}\left(-4, A \cdot C, {B\_m}^{2}\right)}}\right)\\
\mathbf{elif}\;t\_4 \leq -5 \cdot 10^{-214}:\\
\;\;\;\;\frac{\sqrt{\left(F \cdot t\_0\right) \cdot \left(2 \cdot t\_1\right)}}{t\_2}\\
\mathbf{elif}\;t\_4 \leq 0:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;\frac{e^{\left(\log \left(F \cdot \left(C \cdot -16\right)\right) + -2 \cdot \log \left(\frac{-1}{A}\right)\right) \cdot 0.5}}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(C - \mathsf{hypot}\left(B\_m, C\right)\right)\right)}}{-B\_m}\\
\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.0%
Taylor expanded in F around 0 18.5%
mul-1-neg18.5%
*-commutative18.5%
associate-/l*24.4%
associate--l+24.4%
unpow224.4%
unpow224.4%
hypot-undefine58.1%
cancel-sign-sub-inv58.1%
Simplified58.1%
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))) < -4.9999999999999998e-214Initial program 97.2%
Simplified97.2%
if -4.9999999999999998e-214 < (/.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))) < 0.0Initial program 3.5%
Taylor expanded in F around 0 9.7%
mul-1-neg9.7%
*-commutative9.7%
associate-/l*15.9%
associate--l+18.0%
unpow218.0%
unpow218.0%
hypot-undefine18.0%
cancel-sign-sub-inv18.0%
Simplified18.0%
Taylor expanded in A around -inf 26.0%
if 0.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))) < +inf.0Initial program 54.0%
Simplified59.1%
Taylor expanded in C around 0 39.4%
mul-1-neg39.4%
+-commutative39.4%
unpow239.4%
unpow239.4%
hypot-define39.4%
Simplified39.4%
pow1/239.4%
metadata-eval39.4%
pow-to-exp36.7%
associate-*l*32.3%
unsub-neg32.3%
metadata-eval32.3%
Applied egg-rr32.3%
Taylor expanded in A around -inf 43.6%
associate-*r*43.6%
Simplified43.6%
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%
Taylor expanded in A around 0 1.8%
mul-1-neg1.8%
unpow21.8%
unpow21.8%
hypot-define25.1%
Simplified25.1%
associate-*l/25.2%
pow1/225.2%
metadata-eval25.2%
pow1/225.2%
metadata-eval25.2%
pow-prod-down25.2%
metadata-eval25.2%
Applied egg-rr25.2%
unpow1/225.2%
Simplified25.2%
Final simplification48.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) 5e-50)
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (* 2.0 A)))
(- t_0 (pow B_m 2.0)))
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A)))))))))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) <= 5e-50) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - pow(B_m, 2.0));
} else {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
}
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) <= 5e-50) {
tmp = Math.sqrt(((2.0 * ((Math.pow(B_m, 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - Math.pow(B_m, 2.0));
} else {
tmp = (Math.sqrt(2.0) / B_m) * -Math.sqrt((F * (A - Math.hypot(B_m, A))));
}
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) <= 5e-50: tmp = math.sqrt(((2.0 * ((math.pow(B_m, 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - math.pow(B_m, 2.0)) else: tmp = (math.sqrt(2.0) / B_m) * -math.sqrt((F * (A - math.hypot(B_m, A)))) 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) <= 5e-50) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(2.0 * A))) / Float64(t_0 - (B_m ^ 2.0))); else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); 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) <= 5e-50)
tmp = sqrt(((2.0 * (((B_m ^ 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - (B_m ^ 2.0));
else
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
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], 5e-50], 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[(2.0 * A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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 5 \cdot 10^{-50}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(2 \cdot A\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)}\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999968e-50Initial program 27.1%
Taylor expanded in A around -inf 25.4%
if 4.99999999999999968e-50 < (pow.f64 B #s(literal 2 binary64)) Initial program 24.1%
Taylor expanded in C around 0 12.3%
mul-1-neg12.3%
+-commutative12.3%
unpow212.3%
unpow212.3%
hypot-define28.6%
Simplified28.6%
Final simplification27.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
(let* ((t_0 (* (* 4.0 A) C)))
(if (<= B_m 6.5e-22)
(/
(sqrt (* (* 2.0 (* (- (pow B_m 2.0) t_0) F)) (* 2.0 A)))
(- t_0 (pow B_m 2.0)))
(if (<= B_m 5.5e+143)
(-
(sqrt
(*
2.0
(*
F
(/
(- (+ A C) (hypot B_m (- A C)))
(fma -4.0 (* A C) (pow B_m 2.0)))))))
(if (<= B_m 1.35e+223)
(* (sqrt (- (/ F B_m))) (- (sqrt 2.0)))
(/ (sqrt (* 2.0 (* F (- C (hypot B_m C))))) (- 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 t_0 = (4.0 * A) * C;
double tmp;
if (B_m <= 6.5e-22) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - t_0) * F)) * (2.0 * A))) / (t_0 - pow(B_m, 2.0));
} else if (B_m <= 5.5e+143) {
tmp = -sqrt((2.0 * (F * (((A + C) - hypot(B_m, (A - C))) / fma(-4.0, (A * C), pow(B_m, 2.0))))));
} else if (B_m <= 1.35e+223) {
tmp = sqrt(-(F / B_m)) * -sqrt(2.0);
} else {
tmp = sqrt((2.0 * (F * (C - hypot(B_m, C))))) / -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) t_0 = Float64(Float64(4.0 * A) * C) tmp = 0.0 if (B_m <= 6.5e-22) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_0) * F)) * Float64(2.0 * A))) / Float64(t_0 - (B_m ^ 2.0))); elseif (B_m <= 5.5e+143) tmp = Float64(-sqrt(Float64(2.0 * Float64(F * Float64(Float64(Float64(A + C) - hypot(B_m, Float64(A - C))) / fma(-4.0, Float64(A * C), (B_m ^ 2.0))))))); elseif (B_m <= 1.35e+223) tmp = Float64(sqrt(Float64(-Float64(F / B_m))) * Float64(-sqrt(2.0))); else tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(C - hypot(B_m, C))))) / Float64(-B_m)); end return 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, 6.5e-22], 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[(2.0 * A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 5.5e+143], (-N[Sqrt[N[(2.0 * N[(F * N[(N[(N[(A + C), $MachinePrecision] - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[(-4.0 * N[(A * C), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), If[LessEqual[B$95$m, 1.35e+223], N[(N[Sqrt[(-N[(F / B$95$m), $MachinePrecision])], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[N[(2.0 * N[(F * N[(C - N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $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 6.5 \cdot 10^{-22}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_0\right) \cdot F\right)\right) \cdot \left(2 \cdot A\right)}}{t\_0 - {B\_m}^{2}}\\
\mathbf{elif}\;B\_m \leq 5.5 \cdot 10^{+143}:\\
\;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B\_m, A - C\right)}{\mathsf{fma}\left(-4, A \cdot C, {B\_m}^{2}\right)}\right)}\\
\mathbf{elif}\;B\_m \leq 1.35 \cdot 10^{+223}:\\
\;\;\;\;\sqrt{-\frac{F}{B\_m}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(C - \mathsf{hypot}\left(B\_m, C\right)\right)\right)}}{-B\_m}\\
\end{array}
\end{array}
if B < 6.50000000000000043e-22Initial program 26.9%
Taylor expanded in A around -inf 18.0%
if 6.50000000000000043e-22 < B < 5.4999999999999997e143Initial program 51.5%
Taylor expanded in F around 0 51.3%
mul-1-neg51.3%
*-commutative51.3%
associate-/l*54.9%
associate--l+54.9%
unpow254.9%
unpow254.9%
hypot-undefine66.3%
cancel-sign-sub-inv66.3%
Simplified66.3%
*-commutative66.3%
pow1/266.3%
metadata-eval66.3%
pow1/266.3%
metadata-eval66.3%
pow-prod-down66.6%
*-commutative66.6%
associate-+r-66.7%
*-commutative66.7%
metadata-eval66.7%
Applied egg-rr66.7%
unpow1/266.7%
Simplified66.7%
if 5.4999999999999997e143 < B < 1.35e223Initial program 5.9%
Taylor expanded in F around 0 0.3%
mul-1-neg0.3%
*-commutative0.3%
associate-/l*0.3%
associate--l+0.3%
unpow20.3%
unpow20.3%
hypot-undefine3.9%
cancel-sign-sub-inv3.9%
Simplified3.9%
Taylor expanded in B around inf 71.2%
Taylor expanded in F around 0 71.6%
mul-1-neg71.6%
Simplified71.6%
if 1.35e223 < B Initial program 0.0%
Taylor expanded in A around 0 2.2%
mul-1-neg2.2%
unpow22.2%
unpow22.2%
hypot-define71.1%
Simplified71.1%
associate-*l/71.2%
pow1/271.2%
metadata-eval71.2%
pow1/271.2%
metadata-eval71.2%
pow-prod-down71.3%
metadata-eval71.3%
Applied egg-rr71.3%
unpow1/271.3%
Simplified71.3%
Final simplification31.5%
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 (<= (pow B_m 2.0) 2e-58)
(/
(sqrt (* -8.0 (* (* A C) (* F (+ A A)))))
(- (fma C (* A -4.0) (pow B_m 2.0))))
(* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A))))))))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 (pow(B_m, 2.0) <= 2e-58) {
tmp = sqrt((-8.0 * ((A * C) * (F * (A + A))))) / -fma(C, (A * -4.0), pow(B_m, 2.0));
} else {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
}
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 ((B_m ^ 2.0) <= 2e-58) tmp = Float64(sqrt(Float64(-8.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))) / Float64(-fma(C, Float64(A * -4.0), (B_m ^ 2.0)))); else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); end return 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[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-58], N[(N[Sqrt[N[(-8.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(C * N[(A * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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}\;{B\_m}^{2} \leq 2 \cdot 10^{-58}:\\
\;\;\;\;\frac{\sqrt{-8 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{-\mathsf{fma}\left(C, A \cdot -4, {B\_m}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)}\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2.0000000000000001e-58Initial program 26.2%
Simplified28.1%
Taylor expanded in C around inf 22.7%
associate-*r*22.6%
*-commutative22.6%
mul-1-neg22.6%
Simplified22.6%
if 2.0000000000000001e-58 < (pow.f64 B #s(literal 2 binary64)) Initial program 24.9%
Taylor expanded in C around 0 12.1%
mul-1-neg12.1%
+-commutative12.1%
unpow212.1%
unpow212.1%
hypot-define27.9%
Simplified27.9%
Final simplification25.5%
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 (<= (pow B_m 2.0) 2e-43) (* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C))))) (* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A))))))))
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 (pow(B_m, 2.0) <= 2e-43) {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
} else {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
}
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 (Math.pow(B_m, 2.0) <= 2e-43) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
} else {
tmp = (Math.sqrt(2.0) / B_m) * -Math.sqrt((F * (A - Math.hypot(B_m, A))));
}
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 math.pow(B_m, 2.0) <= 2e-43: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) else: tmp = (math.sqrt(2.0) / B_m) * -math.sqrt((F * (A - math.hypot(B_m, A)))) 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 ((B_m ^ 2.0) <= 2e-43) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A)))))); 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 ((B_m ^ 2.0) <= 2e-43)
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
else
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
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[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-43], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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}\;{B\_m}^{2} \leq 2 \cdot 10^{-43}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)}\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000015e-43Initial program 26.7%
Taylor expanded in F around 0 17.8%
mul-1-neg17.8%
*-commutative17.8%
associate-/l*20.2%
associate--l+20.7%
unpow220.7%
unpow220.7%
hypot-undefine27.0%
cancel-sign-sub-inv27.0%
Simplified27.0%
Taylor expanded in A around -inf 18.6%
if 2.00000000000000015e-43 < (pow.f64 B #s(literal 2 binary64)) Initial program 24.4%
Taylor expanded in C around 0 12.5%
mul-1-neg12.5%
+-commutative12.5%
unpow212.5%
unpow212.5%
hypot-define29.0%
Simplified29.0%
Final simplification24.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 (<= B_m 6.5e-5) (* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C))))) (/ (sqrt (* 2.0 (* F (- C (hypot B_m C))))) (- 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 (B_m <= 6.5e-5) {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
} else {
tmp = sqrt((2.0 * (F * (C - hypot(B_m, C))))) / -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 (B_m <= 6.5e-5) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
} else {
tmp = Math.sqrt((2.0 * (F * (C - Math.hypot(B_m, C))))) / -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 B_m <= 6.5e-5: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) else: tmp = math.sqrt((2.0 * (F * (C - math.hypot(B_m, C))))) / -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 (B_m <= 6.5e-5) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); else tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(C - hypot(B_m, C))))) / 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 (B_m <= 6.5e-5)
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
else
tmp = sqrt((2.0 * (F * (C - hypot(B_m, C))))) / -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[B$95$m, 6.5e-5], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[N[(2.0 * N[(F * N[(C - N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $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}\;B\_m \leq 6.5 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(C - \mathsf{hypot}\left(B\_m, C\right)\right)\right)}}{-B\_m}\\
\end{array}
\end{array}
if B < 6.49999999999999943e-5Initial program 27.2%
Taylor expanded in F around 0 22.4%
mul-1-neg22.4%
*-commutative22.4%
associate-/l*24.4%
associate--l+24.8%
unpow224.8%
unpow224.8%
hypot-undefine33.5%
cancel-sign-sub-inv33.5%
Simplified33.5%
Taylor expanded in A around -inf 15.6%
if 6.49999999999999943e-5 < B Initial program 20.5%
Taylor expanded in A around 0 23.5%
mul-1-neg23.5%
unpow223.5%
unpow223.5%
hypot-define59.6%
Simplified59.6%
associate-*l/59.7%
pow1/259.7%
metadata-eval59.7%
pow1/259.7%
metadata-eval59.7%
pow-prod-down59.8%
metadata-eval59.8%
Applied egg-rr59.8%
unpow1/259.8%
Simplified59.8%
Final simplification26.8%
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 (<= B_m 3.4e-18) (* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C))))) (* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A 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 (B_m <= 3.4e-18) {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
} else {
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - B_m)));
}
return tmp;
}
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
real(8) :: tmp
if (b_m <= 3.4d-18) then
tmp = sqrt(2.0d0) * -sqrt((f * ((-0.5d0) / c)))
else
tmp = (sqrt(2.0d0) / b_m) * -sqrt((f * (a - b_m)))
end if
code = tmp
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) {
double tmp;
if (B_m <= 3.4e-18) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
} else {
tmp = (Math.sqrt(2.0) / B_m) * -Math.sqrt((F * (A - 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 B_m <= 3.4e-18: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) else: tmp = (math.sqrt(2.0) / B_m) * -math.sqrt((F * (A - 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 (B_m <= 3.4e-18) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); else tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - 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 (B_m <= 3.4e-18)
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
else
tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - 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[B$95$m, 3.4e-18], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - B$95$m), $MachinePrecision]), $MachinePrecision]], $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}\;B\_m \leq 3.4 \cdot 10^{-18}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(A - B\_m\right)}\right)\\
\end{array}
\end{array}
if B < 3.40000000000000001e-18Initial program 26.9%
Taylor expanded in F around 0 22.1%
mul-1-neg22.1%
*-commutative22.1%
associate-/l*24.1%
associate--l+24.5%
unpow224.5%
unpow224.5%
hypot-undefine32.8%
cancel-sign-sub-inv32.8%
Simplified32.8%
Taylor expanded in A around -inf 15.8%
if 3.40000000000000001e-18 < B Initial program 21.5%
Taylor expanded in B around inf 19.1%
Taylor expanded in C around 0 54.8%
mul-1-neg54.8%
Simplified54.8%
Final simplification26.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 (if (<= B_m 0.00018) (* (sqrt 2.0) (- (sqrt (* F (/ -0.5 C))))) (/ (sqrt (* 2.0 (* F (- (* C (+ (* -0.5 (/ C B_m)) 1.0)) B_m)))) (- 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 (B_m <= 0.00018) {
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
} else {
tmp = sqrt((2.0 * (F * ((C * ((-0.5 * (C / B_m)) + 1.0)) - B_m)))) / -B_m;
}
return tmp;
}
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
real(8) :: tmp
if (b_m <= 0.00018d0) then
tmp = sqrt(2.0d0) * -sqrt((f * ((-0.5d0) / c)))
else
tmp = sqrt((2.0d0 * (f * ((c * (((-0.5d0) * (c / b_m)) + 1.0d0)) - b_m)))) / -b_m
end if
code = tmp
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) {
double tmp;
if (B_m <= 0.00018) {
tmp = Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 / C)));
} else {
tmp = Math.sqrt((2.0 * (F * ((C * ((-0.5 * (C / B_m)) + 1.0)) - B_m)))) / -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 B_m <= 0.00018: tmp = math.sqrt(2.0) * -math.sqrt((F * (-0.5 / C))) else: tmp = math.sqrt((2.0 * (F * ((C * ((-0.5 * (C / B_m)) + 1.0)) - B_m)))) / -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 (B_m <= 0.00018) tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 / C))))); else tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(Float64(C * Float64(Float64(-0.5 * Float64(C / B_m)) + 1.0)) - B_m)))) / 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 (B_m <= 0.00018)
tmp = sqrt(2.0) * -sqrt((F * (-0.5 / C)));
else
tmp = sqrt((2.0 * (F * ((C * ((-0.5 * (C / B_m)) + 1.0)) - B_m)))) / -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[B$95$m, 0.00018], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[N[(2.0 * N[(F * N[(N[(C * N[(N[(-0.5 * N[(C / B$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $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}\;B\_m \leq 0.00018:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{-0.5}{C}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(C \cdot \left(-0.5 \cdot \frac{C}{B\_m} + 1\right) - B\_m\right)\right)}}{-B\_m}\\
\end{array}
\end{array}
if B < 1.80000000000000011e-4Initial program 27.2%
Taylor expanded in F around 0 22.4%
mul-1-neg22.4%
*-commutative22.4%
associate-/l*24.4%
associate--l+24.8%
unpow224.8%
unpow224.8%
hypot-undefine33.5%
cancel-sign-sub-inv33.5%
Simplified33.5%
Taylor expanded in A around -inf 15.6%
if 1.80000000000000011e-4 < B Initial program 20.5%
Taylor expanded in A around 0 23.5%
mul-1-neg23.5%
unpow223.5%
unpow223.5%
hypot-define59.6%
Simplified59.6%
associate-*l/59.7%
pow1/259.7%
metadata-eval59.7%
pow1/259.7%
metadata-eval59.7%
pow-prod-down59.8%
metadata-eval59.8%
Applied egg-rr59.8%
unpow1/259.8%
Simplified59.8%
Taylor expanded in C around 0 55.5%
Final simplification25.7%
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 -1.8e+25) (- (sqrt (* 2.0 (* F (/ -1.0 B_m))))) (/ (sqrt (* 2.0 (* B_m (- F)))) (- 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 <= -1.8e+25) {
tmp = -sqrt((2.0 * (F * (-1.0 / B_m))));
} else {
tmp = sqrt((2.0 * (B_m * -F))) / -B_m;
}
return tmp;
}
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
real(8) :: tmp
if (f <= (-1.8d+25)) then
tmp = -sqrt((2.0d0 * (f * ((-1.0d0) / b_m))))
else
tmp = sqrt((2.0d0 * (b_m * -f))) / -b_m
end if
code = tmp
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) {
double tmp;
if (F <= -1.8e+25) {
tmp = -Math.sqrt((2.0 * (F * (-1.0 / B_m))));
} else {
tmp = Math.sqrt((2.0 * (B_m * -F))) / -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 <= -1.8e+25: tmp = -math.sqrt((2.0 * (F * (-1.0 / B_m)))) else: tmp = math.sqrt((2.0 * (B_m * -F))) / -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 <= -1.8e+25) tmp = Float64(-sqrt(Float64(2.0 * Float64(F * Float64(-1.0 / B_m))))); else tmp = Float64(sqrt(Float64(2.0 * Float64(B_m * Float64(-F)))) / 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 <= -1.8e+25)
tmp = -sqrt((2.0 * (F * (-1.0 / B_m))));
else
tmp = sqrt((2.0 * (B_m * -F))) / -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, -1.8e+25], (-N[Sqrt[N[(2.0 * N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), N[(N[Sqrt[N[(2.0 * N[(B$95$m * (-F)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $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 -1.8 \cdot 10^{+25}:\\
\;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{-1}{B\_m}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(B\_m \cdot \left(-F\right)\right)}}{-B\_m}\\
\end{array}
\end{array}
if F < -1.80000000000000008e25Initial program 18.8%
Taylor expanded in F around 0 21.5%
mul-1-neg21.5%
*-commutative21.5%
associate-/l*24.5%
associate--l+24.9%
unpow224.9%
unpow224.9%
hypot-undefine35.4%
cancel-sign-sub-inv35.4%
Simplified35.4%
Taylor expanded in B around inf 21.2%
sqrt-unprod21.3%
Applied egg-rr21.3%
if -1.80000000000000008e25 < F Initial program 29.4%
Taylor expanded in A around 0 9.5%
mul-1-neg9.5%
unpow29.5%
unpow29.5%
hypot-define24.2%
Simplified24.2%
associate-*l/24.2%
pow1/224.2%
metadata-eval24.2%
pow1/224.2%
metadata-eval24.2%
pow-prod-down24.3%
metadata-eval24.3%
Applied egg-rr24.3%
unpow1/224.2%
Simplified24.2%
Taylor expanded in C around 0 21.8%
mul-1-neg21.8%
Simplified21.8%
Final simplification21.6%
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 (* F (/ -1.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) {
return -sqrt((2.0 * (F * (-1.0 / B_m))));
}
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 * ((-1.0d0) / b_m))))
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 * (F * (-1.0 / B_m))));
}
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 * (F * (-1.0 / B_m))))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(-sqrt(Float64(2.0 * Float64(F * Float64(-1.0 / B_m))))) 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 * (-1.0 / B_m))));
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[Sqrt[N[(2.0 * N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
-\sqrt{2 \cdot \left(F \cdot \frac{-1}{B\_m}\right)}
\end{array}
Initial program 25.5%
Taylor expanded in F around 0 21.5%
mul-1-neg21.5%
*-commutative21.5%
associate-/l*23.4%
associate--l+23.7%
unpow223.7%
unpow223.7%
hypot-undefine31.7%
cancel-sign-sub-inv31.7%
Simplified31.7%
Taylor expanded in B around inf 15.0%
sqrt-unprod15.1%
Applied egg-rr15.1%
Final simplification15.1%
herbie shell --seed 2024076
(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))))