
(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 11 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 (- (/ (sqrt 2.0) B_m))))
(if (<= (pow B_m 2.0) 2e-96)
(* (sqrt (* t_0 (* F (* 2.0 (* 2.0 A))))) (/ -1.0 t_0))
(if (<= (pow B_m 2.0) 1e+147)
(/ (- (sqrt (* (* t_0 F) (* 2.0 (+ A (- C (hypot B_m (- A C)))))))) t_0)
(if (<= (pow B_m 2.0) 5e+234)
(* (sqrt (* F (* -0.5 (/ (pow B_m 2.0) C)))) t_1)
(* t_1 (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 = fma(B_m, B_m, (A * (C * -4.0)));
double t_1 = -(sqrt(2.0) / B_m);
double tmp;
if (pow(B_m, 2.0) <= 2e-96) {
tmp = sqrt((t_0 * (F * (2.0 * (2.0 * A))))) * (-1.0 / t_0);
} else if (pow(B_m, 2.0) <= 1e+147) {
tmp = -sqrt(((t_0 * F) * (2.0 * (A + (C - hypot(B_m, (A - C))))))) / t_0;
} else if (pow(B_m, 2.0) <= 5e+234) {
tmp = sqrt((F * (-0.5 * (pow(B_m, 2.0) / C)))) * t_1;
} else {
tmp = t_1 * 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) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_1 = Float64(-Float64(sqrt(2.0) / B_m)) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-96) tmp = Float64(sqrt(Float64(t_0 * Float64(F * Float64(2.0 * Float64(2.0 * A))))) * Float64(-1.0 / t_0)); elseif ((B_m ^ 2.0) <= 1e+147) tmp = Float64(Float64(-sqrt(Float64(Float64(t_0 * F) * Float64(2.0 * Float64(A + Float64(C - hypot(B_m, Float64(A - C)))))))) / t_0); elseif ((B_m ^ 2.0) <= 5e+234) tmp = Float64(sqrt(Float64(F * Float64(-0.5 * Float64((B_m ^ 2.0) / C)))) * t_1); else tmp = Float64(t_1 * 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_] := 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[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision])}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-96], N[(N[Sqrt[N[(t$95$0 * N[(F * N[(2.0 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+147], N[((-N[Sqrt[N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * N[(A + N[(C - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+234], N[(N[Sqrt[N[(F * N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], N[(t$95$1 * 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 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := -\frac{\sqrt{2}}{B_m}\\
\mathbf{if}\;{B_m}^{2} \leq 2 \cdot 10^{-96}:\\
\;\;\;\;\sqrt{t_0 \cdot \left(F \cdot \left(2 \cdot \left(2 \cdot A\right)\right)\right)} \cdot \frac{-1}{t_0}\\
\mathbf{elif}\;{B_m}^{2} \leq 10^{+147}:\\
\;\;\;\;\frac{-\sqrt{\left(t_0 \cdot F\right) \cdot \left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;{B_m}^{2} \leq 5 \cdot 10^{+234}:\\
\;\;\;\;\sqrt{F \cdot \left(-0.5 \cdot \frac{{B_m}^{2}}{C}\right)} \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 1.9999999999999998e-96Initial program 15.1%
Simplified23.2%
div-inv22.3%
associate-*l*25.8%
*-commutative25.8%
associate-+r-23.5%
+-commutative23.5%
Applied egg-rr23.5%
Taylor expanded in A around -inf 23.4%
if 1.9999999999999998e-96 < (pow.f64 B 2) < 9.9999999999999998e146Initial program 41.8%
Simplified52.1%
if 9.9999999999999998e146 < (pow.f64 B 2) < 5.0000000000000003e234Initial program 9.5%
Simplified4.4%
Taylor expanded in A around 0 11.0%
mul-1-neg11.0%
*-commutative11.0%
distribute-rgt-neg-in11.0%
unpow211.0%
unpow211.0%
hypot-def11.5%
Simplified11.5%
Taylor expanded in C around inf 22.1%
if 5.0000000000000003e234 < (pow.f64 B 2) Initial program 3.7%
Simplified0.4%
Taylor expanded in C around 0 5.4%
mul-1-neg5.4%
*-commutative5.4%
distribute-rgt-neg-in5.4%
+-commutative5.4%
unpow25.4%
unpow25.4%
hypot-def29.1%
Simplified29.1%
Final simplification31.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 (fma B_m B_m (* A (* C -4.0)))) (t_1 (- (/ (sqrt 2.0) B_m))))
(if (<= (pow B_m 2.0) 2e-96)
(* (sqrt (* t_0 (* F (* 2.0 (* 2.0 A))))) (/ -1.0 t_0))
(if (<= (pow B_m 2.0) 1e+147)
(- (/ (sqrt (* t_0 (* F (* 2.0 (- (+ A C) (hypot B_m (- A C))))))) t_0))
(if (<= (pow B_m 2.0) 5e+234)
(* (sqrt (* F (* -0.5 (/ (pow B_m 2.0) C)))) t_1)
(* t_1 (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 = fma(B_m, B_m, (A * (C * -4.0)));
double t_1 = -(sqrt(2.0) / B_m);
double tmp;
if (pow(B_m, 2.0) <= 2e-96) {
tmp = sqrt((t_0 * (F * (2.0 * (2.0 * A))))) * (-1.0 / t_0);
} else if (pow(B_m, 2.0) <= 1e+147) {
tmp = -(sqrt((t_0 * (F * (2.0 * ((A + C) - hypot(B_m, (A - C))))))) / t_0);
} else if (pow(B_m, 2.0) <= 5e+234) {
tmp = sqrt((F * (-0.5 * (pow(B_m, 2.0) / C)))) * t_1;
} else {
tmp = t_1 * 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) t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_1 = Float64(-Float64(sqrt(2.0) / B_m)) tmp = 0.0 if ((B_m ^ 2.0) <= 2e-96) tmp = Float64(sqrt(Float64(t_0 * Float64(F * Float64(2.0 * Float64(2.0 * A))))) * Float64(-1.0 / t_0)); elseif ((B_m ^ 2.0) <= 1e+147) tmp = Float64(-Float64(sqrt(Float64(t_0 * Float64(F * Float64(2.0 * Float64(Float64(A + C) - hypot(B_m, Float64(A - C))))))) / t_0)); elseif ((B_m ^ 2.0) <= 5e+234) tmp = Float64(sqrt(Float64(F * Float64(-0.5 * Float64((B_m ^ 2.0) / C)))) * t_1); else tmp = Float64(t_1 * 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_] := 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[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision])}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-96], N[(N[Sqrt[N[(t$95$0 * N[(F * N[(2.0 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+147], (-N[(N[Sqrt[N[(t$95$0 * N[(F * N[(2.0 * N[(N[(A + C), $MachinePrecision] - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+234], N[(N[Sqrt[N[(F * N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], N[(t$95$1 * 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 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := -\frac{\sqrt{2}}{B_m}\\
\mathbf{if}\;{B_m}^{2} \leq 2 \cdot 10^{-96}:\\
\;\;\;\;\sqrt{t_0 \cdot \left(F \cdot \left(2 \cdot \left(2 \cdot A\right)\right)\right)} \cdot \frac{-1}{t_0}\\
\mathbf{elif}\;{B_m}^{2} \leq 10^{+147}:\\
\;\;\;\;-\frac{\sqrt{t_0 \cdot \left(F \cdot \left(2 \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;{B_m}^{2} \leq 5 \cdot 10^{+234}:\\
\;\;\;\;\sqrt{F \cdot \left(-0.5 \cdot \frac{{B_m}^{2}}{C}\right)} \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 1.9999999999999998e-96Initial program 15.1%
Simplified23.2%
div-inv22.3%
associate-*l*25.8%
*-commutative25.8%
associate-+r-23.5%
+-commutative23.5%
Applied egg-rr23.5%
Taylor expanded in A around -inf 23.4%
if 1.9999999999999998e-96 < (pow.f64 B 2) < 9.9999999999999998e146Initial program 41.8%
Simplified52.1%
distribute-frac-neg52.1%
associate-*l*52.5%
*-commutative52.5%
associate-+r-51.3%
+-commutative51.3%
Applied egg-rr51.3%
if 9.9999999999999998e146 < (pow.f64 B 2) < 5.0000000000000003e234Initial program 9.5%
Simplified4.4%
Taylor expanded in A around 0 11.0%
mul-1-neg11.0%
*-commutative11.0%
distribute-rgt-neg-in11.0%
unpow211.0%
unpow211.0%
hypot-def11.5%
Simplified11.5%
Taylor expanded in C around inf 22.1%
if 5.0000000000000003e234 < (pow.f64 B 2) Initial program 3.7%
Simplified0.4%
Taylor expanded in C around 0 5.4%
mul-1-neg5.4%
*-commutative5.4%
distribute-rgt-neg-in5.4%
+-commutative5.4%
unpow25.4%
unpow25.4%
hypot-def29.1%
Simplified29.1%
Final simplification30.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 (- A (hypot B_m A)))
(t_1 (fma B_m B_m (* A (* C -4.0))))
(t_2 (- (/ (sqrt 2.0) B_m))))
(if (<= (pow B_m 2.0) 4e-55)
(* (sqrt (* t_1 (* F (* 2.0 (* 2.0 A))))) (/ -1.0 t_1))
(if (<= (pow B_m 2.0) 1e+147)
(/ (- (sqrt (* (* t_1 F) (* 2.0 t_0)))) t_1)
(if (<= (pow B_m 2.0) 5e+234)
(* (sqrt (* F (* -0.5 (/ (pow B_m 2.0) C)))) t_2)
(* t_2 (sqrt (* F t_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 = A - hypot(B_m, A);
double t_1 = fma(B_m, B_m, (A * (C * -4.0)));
double t_2 = -(sqrt(2.0) / B_m);
double tmp;
if (pow(B_m, 2.0) <= 4e-55) {
tmp = sqrt((t_1 * (F * (2.0 * (2.0 * A))))) * (-1.0 / t_1);
} else if (pow(B_m, 2.0) <= 1e+147) {
tmp = -sqrt(((t_1 * F) * (2.0 * t_0))) / t_1;
} else if (pow(B_m, 2.0) <= 5e+234) {
tmp = sqrt((F * (-0.5 * (pow(B_m, 2.0) / C)))) * t_2;
} else {
tmp = t_2 * sqrt((F * t_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(A - hypot(B_m, A)) t_1 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) t_2 = Float64(-Float64(sqrt(2.0) / B_m)) tmp = 0.0 if ((B_m ^ 2.0) <= 4e-55) tmp = Float64(sqrt(Float64(t_1 * Float64(F * Float64(2.0 * Float64(2.0 * A))))) * Float64(-1.0 / t_1)); elseif ((B_m ^ 2.0) <= 1e+147) tmp = Float64(Float64(-sqrt(Float64(Float64(t_1 * F) * Float64(2.0 * t_0)))) / t_1); elseif ((B_m ^ 2.0) <= 5e+234) tmp = Float64(sqrt(Float64(F * Float64(-0.5 * Float64((B_m ^ 2.0) / C)))) * t_2); else tmp = Float64(t_2 * sqrt(Float64(F * t_0))); 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[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = (-N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision])}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e-55], N[(N[Sqrt[N[(t$95$1 * N[(F * N[(2.0 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+147], N[((-N[Sqrt[N[(N[(t$95$1 * F), $MachinePrecision] * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+234], N[(N[Sqrt[N[(F * N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision], N[(t$95$2 * N[Sqrt[N[(F * t$95$0), $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 := A - \mathsf{hypot}\left(B_m, A\right)\\
t_1 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := -\frac{\sqrt{2}}{B_m}\\
\mathbf{if}\;{B_m}^{2} \leq 4 \cdot 10^{-55}:\\
\;\;\;\;\sqrt{t_1 \cdot \left(F \cdot \left(2 \cdot \left(2 \cdot A\right)\right)\right)} \cdot \frac{-1}{t_1}\\
\mathbf{elif}\;{B_m}^{2} \leq 10^{+147}:\\
\;\;\;\;\frac{-\sqrt{\left(t_1 \cdot F\right) \cdot \left(2 \cdot t_0\right)}}{t_1}\\
\mathbf{elif}\;{B_m}^{2} \leq 5 \cdot 10^{+234}:\\
\;\;\;\;\sqrt{F \cdot \left(-0.5 \cdot \frac{{B_m}^{2}}{C}\right)} \cdot t_2\\
\mathbf{else}:\\
\;\;\;\;t_2 \cdot \sqrt{F \cdot t_0}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 3.99999999999999998e-55Initial program 17.8%
Simplified25.9%
div-inv25.2%
associate-*l*28.4%
*-commutative28.4%
associate-+r-26.1%
+-commutative26.1%
Applied egg-rr26.1%
Taylor expanded in A around -inf 24.5%
if 3.99999999999999998e-55 < (pow.f64 B 2) < 9.9999999999999998e146Initial program 42.7%
Simplified53.5%
Taylor expanded in C around 0 31.1%
mul-1-neg31.1%
+-commutative31.1%
unpow231.1%
unpow231.1%
hypot-def33.6%
Simplified33.6%
if 9.9999999999999998e146 < (pow.f64 B 2) < 5.0000000000000003e234Initial program 9.5%
Simplified4.4%
Taylor expanded in A around 0 11.0%
mul-1-neg11.0%
*-commutative11.0%
distribute-rgt-neg-in11.0%
unpow211.0%
unpow211.0%
hypot-def11.5%
Simplified11.5%
Taylor expanded in C around inf 22.1%
if 5.0000000000000003e234 < (pow.f64 B 2) Initial program 3.7%
Simplified0.4%
Taylor expanded in C around 0 5.4%
mul-1-neg5.4%
*-commutative5.4%
distribute-rgt-neg-in5.4%
+-commutative5.4%
unpow25.4%
unpow25.4%
hypot-def29.1%
Simplified29.1%
Final simplification27.3%
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 (- (/ (sqrt 2.0) B_m))))
(if (<= (pow B_m 2.0) 5e-13)
(/
(- (sqrt (* (* -8.0 (* A C)) (* F (* 2.0 A)))))
(fma A (* C -4.0) (pow B_m 2.0)))
(if (or (<= (pow B_m 2.0) 4e+172) (not (<= (pow B_m 2.0) 5e+234)))
(* t_0 (sqrt (* F (- A (hypot B_m A)))))
(* (sqrt (* F (* -0.5 (/ (pow B_m 2.0) C)))) t_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 = -(sqrt(2.0) / B_m);
double tmp;
if (pow(B_m, 2.0) <= 5e-13) {
tmp = -sqrt(((-8.0 * (A * C)) * (F * (2.0 * A)))) / fma(A, (C * -4.0), pow(B_m, 2.0));
} else if ((pow(B_m, 2.0) <= 4e+172) || !(pow(B_m, 2.0) <= 5e+234)) {
tmp = t_0 * sqrt((F * (A - hypot(B_m, A))));
} else {
tmp = sqrt((F * (-0.5 * (pow(B_m, 2.0) / C)))) * t_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(sqrt(2.0) / B_m)) tmp = 0.0 if ((B_m ^ 2.0) <= 5e-13) tmp = Float64(Float64(-sqrt(Float64(Float64(-8.0 * Float64(A * C)) * Float64(F * Float64(2.0 * A))))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0))); elseif (((B_m ^ 2.0) <= 4e+172) || !((B_m ^ 2.0) <= 5e+234)) tmp = Float64(t_0 * sqrt(Float64(F * Float64(A - hypot(B_m, A))))); else tmp = Float64(sqrt(Float64(F * Float64(-0.5 * Float64((B_m ^ 2.0) / C)))) * t_0); 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[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision])}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-13], N[((-N[Sqrt[N[(N[(-8.0 * N[(A * C), $MachinePrecision]), $MachinePrecision] * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e+172], N[Not[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+234]], $MachinePrecision]], N[(t$95$0 * N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $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 := -\frac{\sqrt{2}}{B_m}\\
\mathbf{if}\;{B_m}^{2} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{-\sqrt{\left(-8 \cdot \left(A \cdot C\right)\right) \cdot \left(F \cdot \left(2 \cdot A\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}\\
\mathbf{elif}\;{B_m}^{2} \leq 4 \cdot 10^{+172} \lor \neg \left({B_m}^{2} \leq 5 \cdot 10^{+234}\right):\\
\;\;\;\;t_0 \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(-0.5 \cdot \frac{{B_m}^{2}}{C}\right)} \cdot t_0\\
\end{array}
\end{array}
if (pow.f64 B 2) < 4.9999999999999999e-13Initial program 18.9%
Simplified22.4%
Taylor expanded in C around inf 23.4%
associate-*r*25.3%
sub-neg25.3%
mul-1-neg25.3%
remove-double-neg25.3%
Simplified25.3%
distribute-frac-neg25.3%
associate-*r*25.4%
*-commutative25.4%
count-225.4%
Applied egg-rr25.4%
if 4.9999999999999999e-13 < (pow.f64 B 2) < 4.0000000000000003e172 or 5.0000000000000003e234 < (pow.f64 B 2) Initial program 14.4%
Simplified12.2%
Taylor expanded in C around 0 9.3%
mul-1-neg9.3%
*-commutative9.3%
distribute-rgt-neg-in9.3%
+-commutative9.3%
unpow29.3%
unpow29.3%
hypot-def26.0%
Simplified26.0%
if 4.0000000000000003e172 < (pow.f64 B 2) < 5.0000000000000003e234Initial program 10.5%
Simplified4.6%
Taylor expanded in A around 0 4.2%
mul-1-neg4.2%
*-commutative4.2%
distribute-rgt-neg-in4.2%
unpow24.2%
unpow24.2%
hypot-def4.8%
Simplified4.8%
Taylor expanded in C around inf 17.5%
Final simplification25.3%
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 (- (/ (sqrt 2.0) B_m))) (t_1 (fma B_m B_m (* A (* C -4.0)))))
(if (<= (pow B_m 2.0) 1e+70)
(* (sqrt (* t_1 (* F (* 2.0 (* 2.0 A))))) (/ -1.0 t_1))
(if (or (<= (pow B_m 2.0) 4e+172) (not (<= (pow B_m 2.0) 5e+234)))
(* t_0 (sqrt (* F (- A (hypot B_m A)))))
(* (sqrt (* F (* -0.5 (/ (pow B_m 2.0) C)))) t_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 = -(sqrt(2.0) / B_m);
double t_1 = fma(B_m, B_m, (A * (C * -4.0)));
double tmp;
if (pow(B_m, 2.0) <= 1e+70) {
tmp = sqrt((t_1 * (F * (2.0 * (2.0 * A))))) * (-1.0 / t_1);
} else if ((pow(B_m, 2.0) <= 4e+172) || !(pow(B_m, 2.0) <= 5e+234)) {
tmp = t_0 * sqrt((F * (A - hypot(B_m, A))));
} else {
tmp = sqrt((F * (-0.5 * (pow(B_m, 2.0) / C)))) * t_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(sqrt(2.0) / B_m)) t_1 = fma(B_m, B_m, Float64(A * Float64(C * -4.0))) tmp = 0.0 if ((B_m ^ 2.0) <= 1e+70) tmp = Float64(sqrt(Float64(t_1 * Float64(F * Float64(2.0 * Float64(2.0 * A))))) * Float64(-1.0 / t_1)); elseif (((B_m ^ 2.0) <= 4e+172) || !((B_m ^ 2.0) <= 5e+234)) tmp = Float64(t_0 * sqrt(Float64(F * Float64(A - hypot(B_m, A))))); else tmp = Float64(sqrt(Float64(F * Float64(-0.5 * Float64((B_m ^ 2.0) / C)))) * t_0); 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[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision])}, Block[{t$95$1 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+70], N[(N[Sqrt[N[(t$95$1 * N[(F * N[(2.0 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 4e+172], N[Not[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+234]], $MachinePrecision]], N[(t$95$0 * N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $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 := -\frac{\sqrt{2}}{B_m}\\
t_1 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B_m}^{2} \leq 10^{+70}:\\
\;\;\;\;\sqrt{t_1 \cdot \left(F \cdot \left(2 \cdot \left(2 \cdot A\right)\right)\right)} \cdot \frac{-1}{t_1}\\
\mathbf{elif}\;{B_m}^{2} \leq 4 \cdot 10^{+172} \lor \neg \left({B_m}^{2} \leq 5 \cdot 10^{+234}\right):\\
\;\;\;\;t_0 \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(-0.5 \cdot \frac{{B_m}^{2}}{C}\right)} \cdot t_0\\
\end{array}
\end{array}
if (pow.f64 B 2) < 1.00000000000000007e70Initial program 21.8%
Simplified30.4%
div-inv29.8%
associate-*l*32.6%
*-commutative32.6%
associate-+r-30.4%
+-commutative30.4%
Applied egg-rr30.4%
Taylor expanded in A around -inf 23.9%
if 1.00000000000000007e70 < (pow.f64 B 2) < 4.0000000000000003e172 or 5.0000000000000003e234 < (pow.f64 B 2) Initial program 9.9%
Simplified7.4%
Taylor expanded in C around 0 9.3%
mul-1-neg9.3%
*-commutative9.3%
distribute-rgt-neg-in9.3%
+-commutative9.3%
unpow29.3%
unpow29.3%
hypot-def28.7%
Simplified28.7%
if 4.0000000000000003e172 < (pow.f64 B 2) < 5.0000000000000003e234Initial program 10.5%
Simplified4.6%
Taylor expanded in A around 0 4.2%
mul-1-neg4.2%
*-commutative4.2%
distribute-rgt-neg-in4.2%
unpow24.2%
unpow24.2%
hypot-def4.8%
Simplified4.8%
Taylor expanded in C around inf 17.5%
Final simplification25.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
(let* ((t_0 (/ (sqrt 2.0) B_m)))
(if (<= C 2.4e+214)
(* (- t_0) (sqrt (* F (- A (hypot B_m A)))))
(* t_0 (- (sqrt (* -0.5 (/ (* (pow B_m 2.0) F) 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) {
double t_0 = sqrt(2.0) / B_m;
double tmp;
if (C <= 2.4e+214) {
tmp = -t_0 * sqrt((F * (A - hypot(B_m, A))));
} else {
tmp = t_0 * -sqrt((-0.5 * ((pow(B_m, 2.0) * F) / C)));
}
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 = Math.sqrt(2.0) / B_m;
double tmp;
if (C <= 2.4e+214) {
tmp = -t_0 * Math.sqrt((F * (A - Math.hypot(B_m, A))));
} else {
tmp = t_0 * -Math.sqrt((-0.5 * ((Math.pow(B_m, 2.0) * F) / C)));
}
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 = math.sqrt(2.0) / B_m tmp = 0 if C <= 2.4e+214: tmp = -t_0 * math.sqrt((F * (A - math.hypot(B_m, A)))) else: tmp = t_0 * -math.sqrt((-0.5 * ((math.pow(B_m, 2.0) * F) / C))) 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(sqrt(2.0) / B_m) tmp = 0.0 if (C <= 2.4e+214) tmp = Float64(Float64(-t_0) * sqrt(Float64(F * Float64(A - hypot(B_m, A))))); else tmp = Float64(t_0 * Float64(-sqrt(Float64(-0.5 * Float64(Float64((B_m ^ 2.0) * F) / C))))); 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 = sqrt(2.0) / B_m;
tmp = 0.0;
if (C <= 2.4e+214)
tmp = -t_0 * sqrt((F * (A - hypot(B_m, A))));
else
tmp = t_0 * -sqrt((-0.5 * (((B_m ^ 2.0) * F) / C)));
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[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision]}, If[LessEqual[C, 2.4e+214], N[((-t$95$0) * N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * (-N[Sqrt[N[(-0.5 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] * F), $MachinePrecision] / C), $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 := \frac{\sqrt{2}}{B_m}\\
\mathbf{if}\;C \leq 2.4 \cdot 10^{+214}:\\
\;\;\;\;\left(-t_0\right) \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(-\sqrt{-0.5 \cdot \frac{{B_m}^{2} \cdot F}{C}}\right)\\
\end{array}
\end{array}
if C < 2.4000000000000001e214Initial program 17.4%
Simplified17.7%
Taylor expanded in C around 0 8.0%
mul-1-neg8.0%
*-commutative8.0%
distribute-rgt-neg-in8.0%
+-commutative8.0%
unpow28.0%
unpow28.0%
hypot-def17.3%
Simplified17.3%
if 2.4000000000000001e214 < C Initial program 0.6%
Simplified1.7%
Taylor expanded in A around 0 1.6%
mul-1-neg1.6%
*-commutative1.6%
distribute-rgt-neg-in1.6%
unpow21.6%
unpow21.6%
hypot-def4.6%
Simplified4.6%
Taylor expanded in C around inf 25.7%
Final simplification17.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
(let* ((t_0 (/ (sqrt 2.0) B_m)))
(if (<= C 2.3e+148)
(* (- t_0) (sqrt (* F (- A (hypot B_m A)))))
(* t_0 (- (sqrt (* -0.5 (/ (pow B_m 2.0) (/ C F)))))))))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 = sqrt(2.0) / B_m;
double tmp;
if (C <= 2.3e+148) {
tmp = -t_0 * sqrt((F * (A - hypot(B_m, A))));
} else {
tmp = t_0 * -sqrt((-0.5 * (pow(B_m, 2.0) / (C / F))));
}
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 = Math.sqrt(2.0) / B_m;
double tmp;
if (C <= 2.3e+148) {
tmp = -t_0 * Math.sqrt((F * (A - Math.hypot(B_m, A))));
} else {
tmp = t_0 * -Math.sqrt((-0.5 * (Math.pow(B_m, 2.0) / (C / F))));
}
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 = math.sqrt(2.0) / B_m tmp = 0 if C <= 2.3e+148: tmp = -t_0 * math.sqrt((F * (A - math.hypot(B_m, A)))) else: tmp = t_0 * -math.sqrt((-0.5 * (math.pow(B_m, 2.0) / (C / F)))) 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(sqrt(2.0) / B_m) tmp = 0.0 if (C <= 2.3e+148) tmp = Float64(Float64(-t_0) * sqrt(Float64(F * Float64(A - hypot(B_m, A))))); else tmp = Float64(t_0 * Float64(-sqrt(Float64(-0.5 * Float64((B_m ^ 2.0) / Float64(C / F)))))); 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 = sqrt(2.0) / B_m;
tmp = 0.0;
if (C <= 2.3e+148)
tmp = -t_0 * sqrt((F * (A - hypot(B_m, A))));
else
tmp = t_0 * -sqrt((-0.5 * ((B_m ^ 2.0) / (C / F))));
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[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision]}, If[LessEqual[C, 2.3e+148], N[((-t$95$0) * N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * (-N[Sqrt[N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / N[(C / F), $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 := \frac{\sqrt{2}}{B_m}\\
\mathbf{if}\;C \leq 2.3 \cdot 10^{+148}:\\
\;\;\;\;\left(-t_0\right) \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(-\sqrt{-0.5 \cdot \frac{{B_m}^{2}}{\frac{C}{F}}}\right)\\
\end{array}
\end{array}
if C < 2.3000000000000001e148Initial program 18.5%
Simplified18.7%
Taylor expanded in C around 0 8.4%
mul-1-neg8.4%
*-commutative8.4%
distribute-rgt-neg-in8.4%
+-commutative8.4%
unpow28.4%
unpow28.4%
hypot-def17.3%
Simplified17.3%
if 2.3000000000000001e148 < C Initial program 0.7%
Simplified1.6%
Taylor expanded in A around 0 1.7%
mul-1-neg1.7%
*-commutative1.7%
distribute-rgt-neg-in1.7%
unpow21.7%
unpow21.7%
hypot-def10.2%
Simplified10.2%
Taylor expanded in C around inf 18.4%
associate-/l*18.4%
Simplified18.4%
Final simplification17.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 (* (- (/ (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) {
return -(sqrt(2.0) / B_m) * sqrt((F * (A - hypot(B_m, A))));
}
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) / B_m) * Math.sqrt((F * (A - Math.hypot(B_m, A))));
}
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) / B_m) * math.sqrt((F * (A - math.hypot(B_m, A))))
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(-Float64(sqrt(2.0) / B_m)) * sqrt(Float64(F * Float64(A - hypot(B_m, A))))) 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) / B_m) * sqrt((F * (A - hypot(B_m, A))));
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[(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])\\
\\
\left(-\frac{\sqrt{2}}{B_m}\right) \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}
\end{array}
Initial program 16.3%
Simplified16.6%
Taylor expanded in C around 0 7.7%
mul-1-neg7.7%
*-commutative7.7%
distribute-rgt-neg-in7.7%
+-commutative7.7%
unpow27.7%
unpow27.7%
hypot-def16.4%
Simplified16.4%
Final simplification16.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 (* (- (/ (sqrt 2.0) B_m)) (sqrt (* B_m (- F)))))
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) / B_m) * sqrt((B_m * -F));
}
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) / b_m) * sqrt((b_m * -f))
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) / B_m) * Math.sqrt((B_m * -F));
}
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) / B_m) * math.sqrt((B_m * -F))
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(-Float64(sqrt(2.0) / B_m)) * sqrt(Float64(B_m * Float64(-F)))) 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) / B_m) * sqrt((B_m * -F));
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[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision]) * N[Sqrt[N[(B$95$m * (-F)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\left(-\frac{\sqrt{2}}{B_m}\right) \cdot \sqrt{B_m \cdot \left(-F\right)}
\end{array}
Initial program 16.3%
Simplified16.6%
Taylor expanded in A around 0 8.3%
mul-1-neg8.3%
*-commutative8.3%
distribute-rgt-neg-in8.3%
unpow28.3%
unpow28.3%
hypot-def18.3%
Simplified18.3%
Taylor expanded in C around 0 15.4%
associate-*r*15.4%
mul-1-neg15.4%
Simplified15.4%
Final simplification15.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 (* (/ (sqrt 2.0) B_m) (- (sqrt (* B_m F)))))
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) / B_m) * -sqrt((B_m * F));
}
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) / b_m) * -sqrt((b_m * f))
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) / B_m) * -Math.sqrt((B_m * F));
}
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) / B_m) * -math.sqrt((B_m * F))
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) / B_m) * Float64(-sqrt(Float64(B_m * F)))) 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) / B_m) * -sqrt((B_m * F));
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[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(B$95$m * F), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{B_m \cdot F}\right)
\end{array}
Initial program 16.3%
Simplified16.6%
Taylor expanded in A around 0 8.3%
mul-1-neg8.3%
*-commutative8.3%
distribute-rgt-neg-in8.3%
unpow28.3%
unpow28.3%
hypot-def18.3%
Simplified18.3%
Taylor expanded in B around -inf 1.1%
Final simplification1.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 (* 0.25 (* (sqrt (/ F C)) (sqrt -16.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 0.25 * (sqrt((F / C)) * sqrt(-16.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 = 0.25d0 * (sqrt((f / c)) * sqrt((-16.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 0.25 * (Math.sqrt((F / C)) * Math.sqrt(-16.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 0.25 * (math.sqrt((F / C)) * math.sqrt(-16.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(0.25 * Float64(sqrt(Float64(F / C)) * sqrt(-16.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 = 0.25 * (sqrt((F / C)) * sqrt(-16.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[(0.25 * N[(N[Sqrt[N[(F / C), $MachinePrecision]], $MachinePrecision] * N[Sqrt[-16.0], $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}{C}} \cdot \sqrt{-16}\right)
\end{array}
Initial program 16.3%
Simplified16.6%
Taylor expanded in C around inf 12.9%
associate-*r*13.8%
sub-neg13.8%
mul-1-neg13.8%
remove-double-neg13.8%
Simplified13.8%
Taylor expanded in A around inf 0.0%
Final simplification0.0%
herbie shell --seed 2024010
(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))))