
(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 7 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 (fma A (* C -4.0) (pow B 2.0))))
(if (<= (pow B 2.0) 1e-49)
(/
(- (pow (* -8.0 (* (* F (* 2.0 A)) (* A C))) 0.5))
(fma B B (* A (* C -4.0))))
(if (<= (pow B 2.0) 2e+106)
(/
(-
(sqrt
(*
2.0
(*
(* F t_0)
(+
A
(+
A
(/
(* -0.5 (+ (pow A 2.0) (- (pow B 2.0) (pow (- A) 2.0))))
C)))))))
t_0)
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A (hypot B A))))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(A, (C * -4.0), pow(B, 2.0));
double tmp;
if (pow(B, 2.0) <= 1e-49) {
tmp = -pow((-8.0 * ((F * (2.0 * A)) * (A * C))), 0.5) / fma(B, B, (A * (C * -4.0)));
} else if (pow(B, 2.0) <= 2e+106) {
tmp = -sqrt((2.0 * ((F * t_0) * (A + (A + ((-0.5 * (pow(A, 2.0) + (pow(B, 2.0) - pow(-A, 2.0)))) / C)))))) / t_0;
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(B, A))));
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(A, Float64(C * -4.0), (B ^ 2.0)) tmp = 0.0 if ((B ^ 2.0) <= 1e-49) tmp = Float64(Float64(-(Float64(-8.0 * Float64(Float64(F * Float64(2.0 * A)) * Float64(A * C))) ^ 0.5)) / fma(B, B, Float64(A * Float64(C * -4.0)))); elseif ((B ^ 2.0) <= 2e+106) tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(F * t_0) * Float64(A + Float64(A + Float64(Float64(-0.5 * Float64((A ^ 2.0) + Float64((B ^ 2.0) - (Float64(-A) ^ 2.0)))) / C))))))) / t_0); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - hypot(B, A)))))); end return 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[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 1e-49], N[((-N[Power[N[(-8.0 * N[(N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision] * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e+106], N[((-N[Sqrt[N[(2.0 * N[(N[(F * t$95$0), $MachinePrecision] * N[(A + N[(A + N[(N[(-0.5 * N[(N[Power[A, 2.0], $MachinePrecision] + N[(N[Power[B, 2.0], $MachinePrecision] - N[Power[(-A), 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)\\
\mathbf{if}\;{B}^{2} \leq 10^{-49}:\\
\;\;\;\;\frac{-{\left(-8 \cdot \left(\left(F \cdot \left(2 \cdot A\right)\right) \cdot \left(A \cdot C\right)\right)\right)}^{0.5}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{elif}\;{B}^{2} \leq 2 \cdot 10^{+106}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(F \cdot t_0\right) \cdot \left(A + \left(A + \frac{-0.5 \cdot \left({A}^{2} + \left({B}^{2} - {\left(-A\right)}^{2}\right)\right)}{C}\right)\right)\right)}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 9.99999999999999936e-50Initial program 16.8%
Simplified26.7%
Taylor expanded in C around inf 24.7%
associate-*r*25.5%
*-commutative25.5%
cancel-sign-sub-inv25.5%
metadata-eval25.5%
*-lft-identity25.5%
Simplified25.5%
pow1/225.7%
associate-*r*25.7%
metadata-eval25.7%
*-commutative25.7%
*-commutative25.7%
count-225.7%
*-commutative25.7%
Applied egg-rr25.7%
if 9.99999999999999936e-50 < (pow.f64 B 2) < 2.00000000000000018e106Initial program 34.9%
Simplified40.8%
Taylor expanded in C around inf 18.9%
associate--l+18.9%
associate-*r/18.9%
associate--l+18.9%
mul-1-neg18.9%
mul-1-neg18.9%
Simplified18.9%
if 2.00000000000000018e106 < (pow.f64 B 2) Initial program 8.6%
Simplified12.7%
Taylor expanded in C around 0 5.9%
mul-1-neg5.9%
distribute-rgt-neg-in5.9%
+-commutative5.9%
unpow25.9%
unpow25.9%
hypot-def23.8%
Simplified23.8%
Final simplification24.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 (fma B B (* (* A C) -4.0))))
(if (<= (pow B 2.0) 1e-102)
(/
(- (pow (* -8.0 (* (* F (* 2.0 A)) (* A C))) 0.5))
(fma B B (* A (* C -4.0))))
(if (<= (pow B 2.0) 2e+124)
(*
(sqrt (* (- A (- (hypot B (- A C)) C)) (* 2.0 (* F t_0))))
(/ -1.0 t_0))
(* (/ (sqrt 2.0) B) (- (sqrt (* F (- A (hypot B A))))))))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double t_0 = fma(B, B, ((A * C) * -4.0));
double tmp;
if (pow(B, 2.0) <= 1e-102) {
tmp = -pow((-8.0 * ((F * (2.0 * A)) * (A * C))), 0.5) / fma(B, B, (A * (C * -4.0)));
} else if (pow(B, 2.0) <= 2e+124) {
tmp = sqrt(((A - (hypot(B, (A - C)) - C)) * (2.0 * (F * t_0)))) * (-1.0 / t_0);
} else {
tmp = (sqrt(2.0) / B) * -sqrt((F * (A - hypot(B, A))));
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) t_0 = fma(B, B, Float64(Float64(A * C) * -4.0)) tmp = 0.0 if ((B ^ 2.0) <= 1e-102) tmp = Float64(Float64(-(Float64(-8.0 * Float64(Float64(F * Float64(2.0 * A)) * Float64(A * C))) ^ 0.5)) / fma(B, B, Float64(A * Float64(C * -4.0)))); elseif ((B ^ 2.0) <= 2e+124) tmp = Float64(sqrt(Float64(Float64(A - Float64(hypot(B, Float64(A - C)) - C)) * Float64(2.0 * Float64(F * t_0)))) * Float64(-1.0 / t_0)); else tmp = Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * Float64(A - hypot(B, A)))))); end return 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[(B * B + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 1e-102], N[((-N[Power[N[(-8.0 * N[(N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision] * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e+124], N[(N[Sqrt[N[(N[(A - N[(N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision] - C), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B, B, \left(A \cdot C\right) \cdot -4\right)\\
\mathbf{if}\;{B}^{2} \leq 10^{-102}:\\
\;\;\;\;\frac{-{\left(-8 \cdot \left(\left(F \cdot \left(2 \cdot A\right)\right) \cdot \left(A \cdot C\right)\right)\right)}^{0.5}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{elif}\;{B}^{2} \leq 2 \cdot 10^{+124}:\\
\;\;\;\;\sqrt{\left(A - \left(\mathsf{hypot}\left(B, A - C\right) - C\right)\right) \cdot \left(2 \cdot \left(F \cdot t_0\right)\right)} \cdot \frac{-1}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}\right)\\
\end{array}
\end{array}
if (pow.f64 B 2) < 9.99999999999999933e-103Initial program 16.5%
Simplified26.7%
Taylor expanded in C around inf 25.4%
associate-*r*26.2%
*-commutative26.2%
cancel-sign-sub-inv26.2%
metadata-eval26.2%
*-lft-identity26.2%
Simplified26.2%
pow1/226.4%
associate-*r*26.4%
metadata-eval26.4%
*-commutative26.4%
*-commutative26.4%
count-226.4%
*-commutative26.4%
Applied egg-rr26.4%
if 9.99999999999999933e-103 < (pow.f64 B 2) < 1.9999999999999999e124Initial program 34.1%
Simplified34.1%
div-inv34.1%
Applied egg-rr40.8%
if 1.9999999999999999e124 < (pow.f64 B 2) Initial program 7.8%
Simplified11.0%
Taylor expanded in C around 0 6.0%
mul-1-neg6.0%
distribute-rgt-neg-in6.0%
+-commutative6.0%
unpow26.0%
unpow26.0%
hypot-def24.4%
Simplified24.4%
Final simplification27.6%
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 (<= (pow B 2.0) 2e-94)
(/
(- (pow (* -8.0 (* (* F (* 2.0 A)) (* A C))) 0.5))
(fma B B (* A (* C -4.0))))
(* (sqrt (* F (- A (hypot B A)))) (/ (- (sqrt 2.0)) B))))B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
double tmp;
if (pow(B, 2.0) <= 2e-94) {
tmp = -pow((-8.0 * ((F * (2.0 * A)) * (A * C))), 0.5) / fma(B, B, (A * (C * -4.0)));
} else {
tmp = sqrt((F * (A - hypot(B, A)))) * (-sqrt(2.0) / B);
}
return tmp;
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) tmp = 0.0 if ((B ^ 2.0) <= 2e-94) tmp = Float64(Float64(-(Float64(-8.0 * Float64(Float64(F * Float64(2.0 * A)) * Float64(A * C))) ^ 0.5)) / fma(B, B, Float64(A * Float64(C * -4.0)))); else tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B, A)))) * Float64(Float64(-sqrt(2.0)) / B)); end return 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[N[Power[B, 2.0], $MachinePrecision], 2e-94], N[((-N[Power[N[(-8.0 * N[(N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision] * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-94}:\\
\;\;\;\;\frac{-{\left(-8 \cdot \left(\left(F \cdot \left(2 \cdot A\right)\right) \cdot \left(A \cdot C\right)\right)\right)}^{0.5}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\
\end{array}
\end{array}
if (pow.f64 B 2) < 1.9999999999999999e-94Initial program 16.2%
Simplified26.3%
Taylor expanded in C around inf 25.0%
associate-*r*25.8%
*-commutative25.8%
cancel-sign-sub-inv25.8%
metadata-eval25.8%
*-lft-identity25.8%
Simplified25.8%
pow1/226.0%
associate-*r*26.0%
metadata-eval26.0%
*-commutative26.0%
*-commutative26.0%
count-226.0%
*-commutative26.0%
Applied egg-rr26.0%
if 1.9999999999999999e-94 < (pow.f64 B 2) Initial program 15.1%
Simplified19.0%
Taylor expanded in C around 0 8.7%
mul-1-neg8.7%
distribute-rgt-neg-in8.7%
+-commutative8.7%
unpow28.7%
unpow28.7%
hypot-def22.3%
Simplified22.3%
Final simplification24.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 (/ (- (pow (* -8.0 (* (* F (* 2.0 A)) (* A C))) 0.5)) (fma B B (* A (* C -4.0)))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -pow((-8.0 * ((F * (2.0 * A)) * (A * C))), 0.5) / fma(B, B, (A * (C * -4.0)));
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(-(Float64(-8.0 * Float64(Float64(F * Float64(2.0 * A)) * Float64(A * C))) ^ 0.5)) / fma(B, B, Float64(A * Float64(C * -4.0)))) 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[Power[N[(-8.0 * N[(N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision] * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{-{\left(-8 \cdot \left(\left(F \cdot \left(2 \cdot A\right)\right) \cdot \left(A \cdot C\right)\right)\right)}^{0.5}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}
\end{array}
Initial program 15.6%
Simplified22.6%
Taylor expanded in C around inf 14.4%
associate-*r*14.7%
*-commutative14.7%
cancel-sign-sub-inv14.7%
metadata-eval14.7%
*-lft-identity14.7%
Simplified14.7%
pow1/214.9%
associate-*r*14.9%
metadata-eval14.9%
*-commutative14.9%
*-commutative14.9%
count-214.9%
*-commutative14.9%
Applied egg-rr14.9%
Final simplification14.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 (* -8.0 (* (* F (* 2.0 A)) (* A C))))) (fma B B (* (* A C) -4.0))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return -sqrt((-8.0 * ((F * (2.0 * A)) * (A * C)))) / fma(B, B, ((A * C) * -4.0));
}
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(-sqrt(Float64(-8.0 * Float64(Float64(F * Float64(2.0 * A)) * Float64(A * C))))) / fma(B, B, Float64(Float64(A * C) * -4.0))) 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[(-8.0 * N[(N[(F * N[(2.0 * A), $MachinePrecision]), $MachinePrecision] * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(N[(A * C), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{-\sqrt{-8 \cdot \left(\left(F \cdot \left(2 \cdot A\right)\right) \cdot \left(A \cdot C\right)\right)}}{\mathsf{fma}\left(B, B, \left(A \cdot C\right) \cdot -4\right)}
\end{array}
Initial program 15.6%
Simplified22.6%
Taylor expanded in C around inf 14.4%
associate-*r*14.7%
*-commutative14.7%
cancel-sign-sub-inv14.7%
metadata-eval14.7%
*-lft-identity14.7%
Simplified14.7%
distribute-frac-neg14.7%
associate-*r*14.7%
metadata-eval14.7%
*-commutative14.7%
*-commutative14.7%
count-214.7%
*-commutative14.7%
associate-*r*14.7%
*-commutative14.7%
*-commutative14.7%
Applied egg-rr14.7%
Final simplification14.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 (* (/ (sqrt 2.0) B) (- (sqrt (* F C)))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return (sqrt(2.0) / B) * -sqrt((F * C));
}
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) / b) * -sqrt((f * c))
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) / B) * -Math.sqrt((F * C));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return (math.sqrt(2.0) / B) * -math.sqrt((F * C))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(sqrt(2.0) / B) * Float64(-sqrt(Float64(F * C)))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = (sqrt(2.0) / B) * -sqrt((F * C));
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[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * (-N[Sqrt[N[(F * C), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot C}\right)
\end{array}
Initial program 15.6%
Simplified15.6%
Taylor expanded in A around inf 3.3%
Taylor expanded in B around inf 2.0%
mul-1-neg2.0%
*-commutative2.0%
Simplified2.0%
Final simplification2.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 (* (/ (sqrt 2.0) B) (sqrt (* F C))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
return (sqrt(2.0) / B) * sqrt((F * C));
}
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) / b) * sqrt((f * c))
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) / B) * Math.sqrt((F * C));
}
B = abs(B) [A, C] = sort([A, C]) def code(A, B, C, F): return (math.sqrt(2.0) / B) * math.sqrt((F * C))
B = abs(B) A, C = sort([A, C]) function code(A, B, C, F) return Float64(Float64(sqrt(2.0) / B) * sqrt(Float64(F * C))) end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
tmp = (sqrt(2.0) / B) * sqrt((F * C));
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[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * N[Sqrt[N[(F * C), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot C}
\end{array}
Initial program 15.6%
Simplified15.6%
Taylor expanded in A around inf 3.3%
Taylor expanded in B around -inf 2.2%
Final simplification2.2%
herbie shell --seed 2023320
(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))))