
(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}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* 4.0 (* A C)))))
(if (<= B 5.5e-61)
(/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 A))))) t_0)
(if (<= B 5.5e+39)
(/ (* (sqrt 2.0) (- (sqrt (* F (* -0.5 (/ (* B B) C)))))) B)
(if (<= B 9.5e+260)
(/ (- (sqrt (* 2.0 (* F (- A (hypot A B)))))) B)
(- (sqrt (* (/ (* 2.0 F) B) (/ (- C (hypot B C)) B)))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 5.5e-61) {
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else if (B <= 5.5e+39) {
tmp = (sqrt(2.0) * -sqrt((F * (-0.5 * ((B * B) / C))))) / B;
} else if (B <= 9.5e+260) {
tmp = -sqrt((2.0 * (F * (A - hypot(A, B))))) / B;
} else {
tmp = -sqrt((((2.0 * F) / B) * ((C - hypot(B, C)) / B)));
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) - (4.0 * (A * C));
double tmp;
if (B <= 5.5e-61) {
tmp = -Math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
} else if (B <= 5.5e+39) {
tmp = (Math.sqrt(2.0) * -Math.sqrt((F * (-0.5 * ((B * B) / C))))) / B;
} else if (B <= 9.5e+260) {
tmp = -Math.sqrt((2.0 * (F * (A - Math.hypot(A, B))))) / B;
} else {
tmp = -Math.sqrt((((2.0 * F) / B) * ((C - Math.hypot(B, C)) / B)));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) - (4.0 * (A * C)) tmp = 0 if B <= 5.5e-61: tmp = -math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0 elif B <= 5.5e+39: tmp = (math.sqrt(2.0) * -math.sqrt((F * (-0.5 * ((B * B) / C))))) / B elif B <= 9.5e+260: tmp = -math.sqrt((2.0 * (F * (A - math.hypot(A, B))))) / B else: tmp = -math.sqrt((((2.0 * F) / B) * ((C - math.hypot(B, C)) / B))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C))) tmp = 0.0 if (B <= 5.5e-61) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / t_0); elseif (B <= 5.5e+39) tmp = Float64(Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(-0.5 * Float64(Float64(B * B) / C)))))) / B); elseif (B <= 9.5e+260) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(F * Float64(A - hypot(A, B)))))) / B); else tmp = Float64(-sqrt(Float64(Float64(Float64(2.0 * F) / B) * Float64(Float64(C - hypot(B, C)) / B)))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) - (4.0 * (A * C));
tmp = 0.0;
if (B <= 5.5e-61)
tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
elseif (B <= 5.5e+39)
tmp = (sqrt(2.0) * -sqrt((F * (-0.5 * ((B * B) / C))))) / B;
elseif (B <= 9.5e+260)
tmp = -sqrt((2.0 * (F * (A - hypot(A, B))))) / B;
else
tmp = -sqrt((((2.0 * F) / B) * ((C - hypot(B, C)) / B)));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 5.5e-61], N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 5.5e+39], N[(N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(-0.5 * N[(N[(B * B), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / B), $MachinePrecision], If[LessEqual[B, 9.5e+260], N[((-N[Sqrt[N[(2.0 * N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / B), $MachinePrecision], (-N[Sqrt[N[(N[(N[(2.0 * F), $MachinePrecision] / B), $MachinePrecision] * N[(N[(C - N[Sqrt[B ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 5.5 \cdot 10^{-61}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 5.5 \cdot 10^{+39}:\\
\;\;\;\;\frac{\sqrt{2} \cdot \left(-\sqrt{F \cdot \left(-0.5 \cdot \frac{B \cdot B}{C}\right)}\right)}{B}\\
\mathbf{elif}\;B \leq 9.5 \cdot 10^{+260}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{B}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\frac{2 \cdot F}{B} \cdot \frac{C - \mathsf{hypot}\left(B, C\right)}{B}}\\
\end{array}
\end{array}
if B < 5.4999999999999997e-61Initial program 19.6%
Simplified19.5%
Taylor expanded in A around -inf 19.6%
if 5.4999999999999997e-61 < B < 5.4999999999999997e39Initial program 21.0%
Simplified21.0%
unpow221.0%
hypot-udef21.0%
add-exp-log20.4%
Applied egg-rr20.4%
Taylor expanded in A around 0 16.1%
mul-1-neg16.1%
associate-*l/16.1%
*-commutative16.1%
unpow216.1%
unpow216.1%
hypot-def16.5%
Simplified16.5%
Taylor expanded in C around inf 13.7%
unpow213.7%
Simplified13.7%
if 5.4999999999999997e39 < B < 9.5000000000000004e260Initial program 30.1%
Simplified30.1%
Taylor expanded in C around 0 29.3%
mul-1-neg29.3%
+-commutative29.3%
unpow229.3%
unpow229.3%
hypot-def73.4%
Simplified73.4%
associate-*l/73.4%
Applied egg-rr73.4%
sqrt-unprod73.5%
Applied egg-rr73.5%
if 9.5000000000000004e260 < B Initial program 0.0%
Simplified0.0%
unpow20.0%
hypot-udef0.0%
add-exp-log0.0%
Applied egg-rr0.0%
Taylor expanded in A around 0 2.4%
mul-1-neg2.4%
associate-*l/2.4%
*-commutative2.4%
unpow22.4%
unpow22.4%
hypot-def39.6%
Simplified39.6%
add-sqr-sqrt39.5%
sqrt-unprod15.7%
frac-times2.5%
sqrt-unprod2.5%
sqrt-unprod2.5%
add-sqr-sqrt2.5%
Applied egg-rr2.5%
associate-*r*2.5%
times-frac75.7%
Simplified75.7%
Final simplification28.2%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* (* A C) -4.0))))
(if (<= B 1.45e+25)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(if (<= B 7.6e+260)
(/ (- (sqrt (* 2.0 (* F (- A (hypot A B)))))) B)
(- (sqrt (* (/ (* 2.0 F) B) (/ (- C (hypot B C)) B))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= 1.45e+25) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else if (B <= 7.6e+260) {
tmp = -sqrt((2.0 * (F * (A - hypot(A, B))))) / B;
} else {
tmp = -sqrt((((2.0 * F) / B) * ((C - hypot(B, C)) / B)));
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= 1.45e+25) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else if (B <= 7.6e+260) {
tmp = -Math.sqrt((2.0 * (F * (A - Math.hypot(A, B))))) / B;
} else {
tmp = -Math.sqrt((((2.0 * F) / B) * ((C - Math.hypot(B, C)) / B)));
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + ((A * C) * -4.0) tmp = 0 if B <= 1.45e+25: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 elif B <= 7.6e+260: tmp = -math.sqrt((2.0 * (F * (A - math.hypot(A, B))))) / B else: tmp = -math.sqrt((((2.0 * F) / B) * ((C - math.hypot(B, C)) / B))) return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(Float64(A * C) * -4.0)) tmp = 0.0 if (B <= 1.45e+25) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); elseif (B <= 7.6e+260) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(F * Float64(A - hypot(A, B)))))) / B); else tmp = Float64(-sqrt(Float64(Float64(Float64(2.0 * F) / B) * Float64(Float64(C - hypot(B, C)) / B)))); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + ((A * C) * -4.0);
tmp = 0.0;
if (B <= 1.45e+25)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
elseif (B <= 7.6e+260)
tmp = -sqrt((2.0 * (F * (A - hypot(A, B))))) / B;
else
tmp = -sqrt((((2.0 * F) / B) * ((C - hypot(B, C)) / B)));
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 1.45e+25], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B, 7.6e+260], N[((-N[Sqrt[N[(2.0 * N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / B), $MachinePrecision], (-N[Sqrt[N[(N[(N[(2.0 * F), $MachinePrecision] / B), $MachinePrecision] * N[(N[(C - N[Sqrt[B ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + \left(A \cdot C\right) \cdot -4\\
\mathbf{if}\;B \leq 1.45 \cdot 10^{+25}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{elif}\;B \leq 7.6 \cdot 10^{+260}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{B}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\frac{2 \cdot F}{B} \cdot \frac{C - \mathsf{hypot}\left(B, C\right)}{B}}\\
\end{array}
\end{array}
if B < 1.44999999999999995e25Initial program 19.5%
Simplified19.5%
Taylor expanded in A around -inf 19.0%
distribute-frac-neg19.0%
associate-*l*18.6%
cancel-sign-sub-inv18.6%
metadata-eval18.6%
*-commutative18.6%
cancel-sign-sub-inv18.6%
metadata-eval18.6%
Applied egg-rr18.6%
if 1.44999999999999995e25 < B < 7.5999999999999995e260Initial program 30.6%
Simplified30.6%
Taylor expanded in C around 0 28.1%
mul-1-neg28.1%
+-commutative28.1%
unpow228.1%
unpow228.1%
hypot-def68.2%
Simplified68.2%
associate-*l/68.2%
Applied egg-rr68.2%
sqrt-unprod68.3%
Applied egg-rr68.3%
if 7.5999999999999995e260 < B Initial program 0.0%
Simplified0.0%
unpow20.0%
hypot-udef0.0%
add-exp-log0.0%
Applied egg-rr0.0%
Taylor expanded in A around 0 2.4%
mul-1-neg2.4%
associate-*l/2.4%
*-commutative2.4%
unpow22.4%
unpow22.4%
hypot-def39.6%
Simplified39.6%
add-sqr-sqrt39.5%
sqrt-unprod15.7%
frac-times2.5%
sqrt-unprod2.5%
sqrt-unprod2.5%
add-sqr-sqrt2.5%
Applied egg-rr2.5%
associate-*r*2.5%
times-frac75.7%
Simplified75.7%
Final simplification27.9%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* (* A C) -4.0))))
(if (<= B 3.6e+23)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(/ (- (sqrt (* 2.0 (* F (- A (hypot A B)))))) B))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= 3.6e+23) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -sqrt((2.0 * (F * (A - hypot(A, B))))) / B;
}
return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= 3.6e+23) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -Math.sqrt((2.0 * (F * (A - Math.hypot(A, B))))) / B;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + ((A * C) * -4.0) tmp = 0 if B <= 3.6e+23: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = -math.sqrt((2.0 * (F * (A - math.hypot(A, B))))) / B return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(Float64(A * C) * -4.0)) tmp = 0.0 if (B <= 3.6e+23) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(F * Float64(A - hypot(A, B)))))) / B); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + ((A * C) * -4.0);
tmp = 0.0;
if (B <= 3.6e+23)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = -sqrt((2.0 * (F * (A - hypot(A, B))))) / B;
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 3.6e+23], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / B), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + \left(A \cdot C\right) \cdot -4\\
\mathbf{if}\;B \leq 3.6 \cdot 10^{+23}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{B}\\
\end{array}
\end{array}
if B < 3.5999999999999998e23Initial program 19.5%
Simplified19.5%
Taylor expanded in A around -inf 19.0%
distribute-frac-neg19.0%
associate-*l*18.6%
cancel-sign-sub-inv18.6%
metadata-eval18.6%
*-commutative18.6%
cancel-sign-sub-inv18.6%
metadata-eval18.6%
Applied egg-rr18.6%
if 3.5999999999999998e23 < B Initial program 21.9%
Simplified21.9%
Taylor expanded in C around 0 20.9%
mul-1-neg20.9%
+-commutative20.9%
unpow220.9%
unpow220.9%
hypot-def60.1%
Simplified60.1%
associate-*l/60.1%
Applied egg-rr60.1%
sqrt-unprod60.3%
Applied egg-rr60.3%
Final simplification26.1%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (+ (* B B) (* (* A C) -4.0))))
(if (<= B 8.2e+23)
(/ (- (sqrt (* 2.0 (* t_0 (* F (* 2.0 A)))))) t_0)
(/ (- (sqrt (* 2.0 (* F (- A B))))) B))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= 8.2e+23) {
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -sqrt((2.0 * (F * (A - B)))) / B;
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
real(8) :: tmp
t_0 = (b * b) + ((a * c) * (-4.0d0))
if (b <= 8.2d+23) then
tmp = -sqrt((2.0d0 * (t_0 * (f * (2.0d0 * a))))) / t_0
else
tmp = -sqrt((2.0d0 * (f * (a - b)))) / b
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double t_0 = (B * B) + ((A * C) * -4.0);
double tmp;
if (B <= 8.2e+23) {
tmp = -Math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
} else {
tmp = -Math.sqrt((2.0 * (F * (A - B)))) / B;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): t_0 = (B * B) + ((A * C) * -4.0) tmp = 0 if B <= 8.2e+23: tmp = -math.sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0 else: tmp = -math.sqrt((2.0 * (F * (A - B)))) / B return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = Float64(Float64(B * B) + Float64(Float64(A * C) * -4.0)) tmp = 0.0 if (B <= 8.2e+23) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(2.0 * A)))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(F * Float64(A - B))))) / B); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
t_0 = (B * B) + ((A * C) * -4.0);
tmp = 0.0;
if (B <= 8.2e+23)
tmp = -sqrt((2.0 * (t_0 * (F * (2.0 * A))))) / t_0;
else
tmp = -sqrt((2.0 * (F * (A - B)))) / B;
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 8.2e+23], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / B), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B + \left(A \cdot C\right) \cdot -4\\
\mathbf{if}\;B \leq 8.2 \cdot 10^{+23}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - B\right)\right)}}{B}\\
\end{array}
\end{array}
if B < 8.19999999999999992e23Initial program 19.5%
Simplified19.5%
Taylor expanded in A around -inf 19.0%
distribute-frac-neg19.0%
associate-*l*18.6%
cancel-sign-sub-inv18.6%
metadata-eval18.6%
*-commutative18.6%
cancel-sign-sub-inv18.6%
metadata-eval18.6%
Applied egg-rr18.6%
if 8.19999999999999992e23 < B Initial program 21.9%
Simplified21.9%
Taylor expanded in C around 0 20.9%
mul-1-neg20.9%
+-commutative20.9%
unpow220.9%
unpow220.9%
hypot-def60.1%
Simplified60.1%
associate-*l/60.1%
Applied egg-rr60.1%
sqrt-unprod60.3%
Applied egg-rr60.3%
Taylor expanded in A around 0 59.1%
mul-1-neg59.1%
unsub-neg59.1%
Simplified59.1%
Final simplification25.9%
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 1.38e-5)
(/
(- (sqrt (* 2.0 (* -8.0 (* A (* (* A C) F))))))
(- (* B B) (* 4.0 (* A C))))
(/ (- (sqrt (* 2.0 (* F (- A B))))) B)))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 1.38e-5) {
tmp = -sqrt((2.0 * (-8.0 * (A * ((A * C) * F))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = -sqrt((2.0 * (F * (A - B)))) / B;
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (b <= 1.38d-5) then
tmp = -sqrt((2.0d0 * ((-8.0d0) * (a * ((a * c) * f))))) / ((b * b) - (4.0d0 * (a * c)))
else
tmp = -sqrt((2.0d0 * (f * (a - b)))) / b
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= 1.38e-5) {
tmp = -Math.sqrt((2.0 * (-8.0 * (A * ((A * C) * F))))) / ((B * B) - (4.0 * (A * C)));
} else {
tmp = -Math.sqrt((2.0 * (F * (A - B)))) / B;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if B <= 1.38e-5: tmp = -math.sqrt((2.0 * (-8.0 * (A * ((A * C) * F))))) / ((B * B) - (4.0 * (A * C))) else: tmp = -math.sqrt((2.0 * (F * (A - B)))) / B return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (B <= 1.38e-5) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-8.0 * Float64(A * Float64(Float64(A * C) * F)))))) / Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(F * Float64(A - B))))) / B); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (B <= 1.38e-5)
tmp = -sqrt((2.0 * (-8.0 * (A * ((A * C) * F))))) / ((B * B) - (4.0 * (A * C)));
else
tmp = -sqrt((2.0 * (F * (A - B)))) / B;
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 1.38e-5], N[((-N[Sqrt[N[(2.0 * N[(-8.0 * N[(A * N[(N[(A * C), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / B), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 1.38 \cdot 10^{-5}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-8 \cdot \left(A \cdot \left(\left(A \cdot C\right) \cdot F\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - B\right)\right)}}{B}\\
\end{array}
\end{array}
if B < 1.38e-5Initial program 19.9%
Simplified19.9%
Taylor expanded in A around -inf 19.4%
Taylor expanded in B around 0 11.5%
*-commutative11.5%
unpow211.5%
associate-*l*15.2%
*-commutative15.2%
associate-*r*18.9%
Simplified18.9%
if 1.38e-5 < B Initial program 20.0%
Simplified20.0%
Taylor expanded in C around 0 19.2%
mul-1-neg19.2%
+-commutative19.2%
unpow219.2%
unpow219.2%
hypot-def51.6%
Simplified51.6%
associate-*l/51.6%
Applied egg-rr51.6%
sqrt-unprod51.8%
Applied egg-rr51.8%
Taylor expanded in A around 0 50.3%
mul-1-neg50.3%
unsub-neg50.3%
Simplified50.3%
Final simplification25.8%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= A -1.3e+185) (* -2.0 (sqrt (* (/ F B) (/ A B)))) (/ (- (sqrt (* 2.0 (* F (- A B))))) B)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (A <= -1.3e+185) {
tmp = -2.0 * sqrt(((F / B) * (A / B)));
} else {
tmp = -sqrt((2.0 * (F * (A - B)))) / B;
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (a <= (-1.3d+185)) then
tmp = (-2.0d0) * sqrt(((f / b) * (a / b)))
else
tmp = -sqrt((2.0d0 * (f * (a - b)))) / b
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (A <= -1.3e+185) {
tmp = -2.0 * Math.sqrt(((F / B) * (A / B)));
} else {
tmp = -Math.sqrt((2.0 * (F * (A - B)))) / B;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if A <= -1.3e+185: tmp = -2.0 * math.sqrt(((F / B) * (A / B))) else: tmp = -math.sqrt((2.0 * (F * (A - B)))) / B return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (A <= -1.3e+185) tmp = Float64(-2.0 * sqrt(Float64(Float64(F / B) * Float64(A / B)))); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(F * Float64(A - B))))) / B); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (A <= -1.3e+185)
tmp = -2.0 * sqrt(((F / B) * (A / B)));
else
tmp = -sqrt((2.0 * (F * (A - B)))) / B;
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[A, -1.3e+185], N[(-2.0 * N[Sqrt[N[(N[(F / B), $MachinePrecision] * N[(A / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(F * N[(A - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / B), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;A \leq -1.3 \cdot 10^{+185}:\\
\;\;\;\;-2 \cdot \sqrt{\frac{F}{B} \cdot \frac{A}{B}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(A - B\right)\right)}}{B}\\
\end{array}
\end{array}
if A < -1.3e185Initial program 2.1%
Simplified2.1%
Taylor expanded in A around -inf 20.4%
Taylor expanded in B around inf 5.0%
associate-*r/5.0%
*-rgt-identity5.0%
*-commutative5.0%
Simplified5.0%
add-sqr-sqrt4.5%
sqrt-unprod6.6%
frac-times2.9%
add-sqr-sqrt2.9%
*-commutative2.9%
Applied egg-rr2.9%
*-commutative2.9%
times-frac29.4%
Simplified29.4%
if -1.3e185 < A Initial program 21.5%
Simplified21.5%
Taylor expanded in C around 0 8.4%
mul-1-neg8.4%
+-commutative8.4%
unpow28.4%
unpow28.4%
hypot-def16.4%
Simplified16.4%
associate-*l/16.3%
Applied egg-rr16.3%
sqrt-unprod16.4%
Applied egg-rr16.4%
Taylor expanded in A around 0 14.0%
mul-1-neg14.0%
unsub-neg14.0%
Simplified14.0%
Final simplification15.2%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= A -3.2e+199) (* -2.0 (sqrt (* (/ F B) (/ A B)))) (/ (- (sqrt (* 2.0 (* F (- B))))) B)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (A <= -3.2e+199) {
tmp = -2.0 * sqrt(((F / B) * (A / B)));
} else {
tmp = -sqrt((2.0 * (F * -B))) / B;
}
return tmp;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (a <= (-3.2d+199)) then
tmp = (-2.0d0) * sqrt(((f / b) * (a / b)))
else
tmp = -sqrt((2.0d0 * (f * -b))) / b
end if
code = tmp
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
double tmp;
if (A <= -3.2e+199) {
tmp = -2.0 * Math.sqrt(((F / B) * (A / B)));
} else {
tmp = -Math.sqrt((2.0 * (F * -B))) / B;
}
return tmp;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): tmp = 0 if A <= -3.2e+199: tmp = -2.0 * math.sqrt(((F / B) * (A / B))) else: tmp = -math.sqrt((2.0 * (F * -B))) / B return tmp
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if (A <= -3.2e+199) tmp = Float64(-2.0 * sqrt(Float64(Float64(F / B) * Float64(A / B)))); else tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(F * Float64(-B))))) / B); end return tmp end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (A <= -3.2e+199)
tmp = -2.0 * sqrt(((F / B) * (A / B)));
else
tmp = -sqrt((2.0 * (F * -B))) / B;
end
tmp_2 = tmp;
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[A, -3.2e+199], N[(-2.0 * N[Sqrt[N[(N[(F / B), $MachinePrecision] * N[(A / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(F * (-B)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / B), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;A \leq -3.2 \cdot 10^{+199}:\\
\;\;\;\;-2 \cdot \sqrt{\frac{F}{B} \cdot \frac{A}{B}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(F \cdot \left(-B\right)\right)}}{B}\\
\end{array}
\end{array}
if A < -3.20000000000000006e199Initial program 1.9%
Simplified1.9%
Taylor expanded in A around -inf 17.3%
Taylor expanded in B around inf 5.0%
associate-*r/5.0%
*-rgt-identity5.0%
*-commutative5.0%
Simplified5.0%
add-sqr-sqrt4.4%
sqrt-unprod6.8%
frac-times2.7%
add-sqr-sqrt2.7%
*-commutative2.7%
Applied egg-rr2.7%
*-commutative2.7%
times-frac32.1%
Simplified32.1%
if -3.20000000000000006e199 < A Initial program 21.4%
Simplified21.4%
Taylor expanded in C around 0 8.3%
mul-1-neg8.3%
+-commutative8.3%
unpow28.3%
unpow28.3%
hypot-def16.3%
Simplified16.3%
associate-*l/16.2%
Applied egg-rr16.2%
sqrt-unprod16.3%
Applied egg-rr16.3%
Taylor expanded in A around 0 14.6%
associate-*r*14.6%
mul-1-neg14.6%
Simplified14.6%
Final simplification15.9%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (/ (- (sqrt (* 2.0 (* F (- B))))) B))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -sqrt((2.0 * (F * -B))) / B;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = -sqrt((2.0d0 * (f * -b))) / b
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return -Math.sqrt((2.0 * (F * -B))) / B;
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -math.sqrt((2.0 * (F * -B))) / B
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(-sqrt(Float64(2.0 * Float64(F * Float64(-B))))) / B) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt((2.0 * (F * -B))) / B;
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[((-N[Sqrt[N[(2.0 * N[(F * (-B)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / B), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{-\sqrt{2 \cdot \left(F \cdot \left(-B\right)\right)}}{B}
\end{array}
Initial program 19.9%
Simplified19.9%
Taylor expanded in C around 0 7.8%
mul-1-neg7.8%
+-commutative7.8%
unpow27.8%
unpow27.8%
hypot-def15.4%
Simplified15.4%
associate-*l/15.4%
Applied egg-rr15.4%
sqrt-unprod15.5%
Applied egg-rr15.5%
Taylor expanded in A around 0 13.7%
associate-*r*13.7%
mul-1-neg13.7%
Simplified13.7%
Final simplification13.7%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* -2.0 (/ (pow (* A F) 0.5) B)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (pow((A * F), 0.5) / B);
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (-2.0d0) * (((a * f) ** 0.5d0) / b)
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return -2.0 * (Math.pow((A * F), 0.5) / B);
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.pow((A * F), 0.5) / B)
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64((Float64(A * F) ^ 0.5) / B)) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (((A * F) ^ 0.5) / B);
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(-2.0 * N[(N[Power[N[(A * F), $MachinePrecision], 0.5], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \frac{{\left(A \cdot F\right)}^{0.5}}{B}
\end{array}
Initial program 19.9%
Simplified19.9%
Taylor expanded in A around -inf 15.7%
Taylor expanded in B around inf 2.9%
associate-*r/2.9%
*-rgt-identity2.9%
*-commutative2.9%
Simplified2.9%
pow1/23.0%
*-commutative3.0%
Applied egg-rr3.0%
Final simplification3.0%
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* -2.0 (/ (sqrt (* A F)) B)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -2.0 * (sqrt((A * F)) / B);
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (-2.0d0) * (sqrt((a * f)) / b)
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
return -2.0 * (Math.sqrt((A * F)) / B);
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return -2.0 * (math.sqrt((A * F)) / B)
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(-2.0 * Float64(sqrt(Float64(A * F)) / B)) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = -2.0 * (sqrt((A * F)) / B);
end
NOTE: B should be positive before calling this function NOTE: A and C should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(-2.0 * N[(N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-2 \cdot \frac{\sqrt{A \cdot F}}{B}
\end{array}
Initial program 19.9%
Simplified19.9%
Taylor expanded in A around -inf 15.7%
Taylor expanded in B around inf 2.9%
associate-*r/2.9%
*-rgt-identity2.9%
*-commutative2.9%
Simplified2.9%
Final simplification2.9%
herbie shell --seed 2023214
(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))))