
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) + sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) + sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) + Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) + math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) + sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) + sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) + sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) + sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) + Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) + math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) + sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) + sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) + \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0}
\end{array}
\end{array}
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma -4.0 (* A C) (* B_m B_m))))
(if (<= (pow B_m 2.0) 200000000.0)
(*
(/ (sqrt (* 2.0 (* t_0 F))) -1.0)
(/ (sqrt (fma -0.5 (/ (* B_m B_m) A) (* 2.0 C))) t_0))
(- 0.0 (/ (sqrt F) (sqrt (* B_m 0.5)))))))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(-4.0, (A * C), (B_m * B_m));
double tmp;
if (pow(B_m, 2.0) <= 200000000.0) {
tmp = (sqrt((2.0 * (t_0 * F))) / -1.0) * (sqrt(fma(-0.5, ((B_m * B_m) / A), (2.0 * C))) / t_0);
} else {
tmp = 0.0 - (sqrt(F) / sqrt((B_m * 0.5)));
}
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(-4.0, Float64(A * C), Float64(B_m * B_m)) tmp = 0.0 if ((B_m ^ 2.0) <= 200000000.0) tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(t_0 * F))) / -1.0) * Float64(sqrt(fma(-0.5, Float64(Float64(B_m * B_m) / A), Float64(2.0 * C))) / t_0)); else tmp = Float64(0.0 - Float64(sqrt(F) / sqrt(Float64(B_m * 0.5)))); 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[(-4.0 * N[(A * C), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 200000000.0], N[(N[(N[Sqrt[N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / -1.0), $MachinePrecision] * N[(N[Sqrt[N[(-0.5 * N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision] + N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(0.0 - N[(N[Sqrt[F], $MachinePrecision] / N[Sqrt[N[(B$95$m * 0.5), $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(-4, A \cdot C, B\_m \cdot B\_m\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 200000000:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(t\_0 \cdot F\right)}}{-1} \cdot \frac{\sqrt{\mathsf{fma}\left(-0.5, \frac{B\_m \cdot B\_m}{A}, 2 \cdot C\right)}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;0 - \frac{\sqrt{F}}{\sqrt{B\_m \cdot 0.5}}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 2e8Initial program 15.8%
frac-2negN/A
remove-double-negN/A
pow1/2N/A
unpow-prod-downN/A
neg-mul-1N/A
times-fracN/A
*-lowering-*.f64N/A
Applied egg-rr17.4%
Taylor expanded in A around -inf
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f6424.9
Simplified24.9%
if 2e8 < (pow.f64 B #s(literal 2 binary64)) Initial program 14.6%
Taylor expanded in B around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6424.2
Simplified24.2%
sub0-negN/A
neg-lowering-neg.f64N/A
sqrt-unprodN/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
sqrt-unprodN/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f6424.3
Applied egg-rr24.3%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6424.3
Applied egg-rr24.3%
clear-numN/A
un-div-invN/A
sqrt-divN/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
div-invN/A
metadata-evalN/A
*-lowering-*.f6429.1
Applied egg-rr29.1%
Final simplification27.0%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma -4.0 (* A C) (* B_m B_m))))
(if (<= B_m 13000.0)
(* (/ (sqrt (* 2.0 (* t_0 F))) -1.0) (/ (sqrt (* 2.0 C)) t_0))
(- 0.0 (/ (sqrt F) (sqrt (* B_m 0.5)))))))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(-4.0, (A * C), (B_m * B_m));
double tmp;
if (B_m <= 13000.0) {
tmp = (sqrt((2.0 * (t_0 * F))) / -1.0) * (sqrt((2.0 * C)) / t_0);
} else {
tmp = 0.0 - (sqrt(F) / sqrt((B_m * 0.5)));
}
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(-4.0, Float64(A * C), Float64(B_m * B_m)) tmp = 0.0 if (B_m <= 13000.0) tmp = Float64(Float64(sqrt(Float64(2.0 * Float64(t_0 * F))) / -1.0) * Float64(sqrt(Float64(2.0 * C)) / t_0)); else tmp = Float64(0.0 - Float64(sqrt(F) / sqrt(Float64(B_m * 0.5)))); 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[(-4.0 * N[(A * C), $MachinePrecision] + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 13000.0], N[(N[(N[Sqrt[N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / -1.0), $MachinePrecision] * N[(N[Sqrt[N[(2.0 * C), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(0.0 - N[(N[Sqrt[F], $MachinePrecision] / N[Sqrt[N[(B$95$m * 0.5), $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(-4, A \cdot C, B\_m \cdot B\_m\right)\\
\mathbf{if}\;B\_m \leq 13000:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(t\_0 \cdot F\right)}}{-1} \cdot \frac{\sqrt{2 \cdot C}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;0 - \frac{\sqrt{F}}{\sqrt{B\_m \cdot 0.5}}\\
\end{array}
\end{array}
if B < 13000Initial program 15.7%
frac-2negN/A
remove-double-negN/A
pow1/2N/A
unpow-prod-downN/A
neg-mul-1N/A
times-fracN/A
*-lowering-*.f64N/A
Applied egg-rr18.3%
Taylor expanded in A around -inf
*-lowering-*.f6415.0
Simplified15.0%
if 13000 < B Initial program 13.9%
Taylor expanded in B around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6445.7
Simplified45.7%
sub0-negN/A
neg-lowering-neg.f64N/A
sqrt-unprodN/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
sqrt-unprodN/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f6446.0
Applied egg-rr46.0%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6446.0
Applied egg-rr46.0%
clear-numN/A
un-div-invN/A
sqrt-divN/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
div-invN/A
metadata-evalN/A
*-lowering-*.f6456.4
Applied egg-rr56.4%
Final simplification25.7%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(if (<= B_m 7.2e-136)
(*
(sqrt
(/
(* F (+ (+ A C) (sqrt (fma B_m B_m (* (- A C) (- A C))))))
(fma B_m B_m (* -4.0 (* A C)))))
(- 0.0 (sqrt 2.0)))
(if (<= B_m 18000.0)
(/ (sqrt (* 2.0 (* F (* -0.5 (/ (* B_m B_m) A))))) (- 0.0 B_m))
(- 0.0 (/ (sqrt F) (sqrt (* B_m 0.5)))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 7.2e-136) {
tmp = sqrt(((F * ((A + C) + sqrt(fma(B_m, B_m, ((A - C) * (A - C)))))) / fma(B_m, B_m, (-4.0 * (A * C))))) * (0.0 - sqrt(2.0));
} else if (B_m <= 18000.0) {
tmp = sqrt((2.0 * (F * (-0.5 * ((B_m * B_m) / A))))) / (0.0 - B_m);
} else {
tmp = 0.0 - (sqrt(F) / sqrt((B_m * 0.5)));
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (B_m <= 7.2e-136) tmp = Float64(sqrt(Float64(Float64(F * Float64(Float64(A + C) + sqrt(fma(B_m, B_m, Float64(Float64(A - C) * Float64(A - C)))))) / fma(B_m, B_m, Float64(-4.0 * Float64(A * C))))) * Float64(0.0 - sqrt(2.0))); elseif (B_m <= 18000.0) tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(-0.5 * Float64(Float64(B_m * B_m) / A))))) / Float64(0.0 - B_m)); else tmp = Float64(0.0 - Float64(sqrt(F) / sqrt(Float64(B_m * 0.5)))); end return tmp end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 7.2e-136], N[(N[Sqrt[N[(N[(F * N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(B$95$m * B$95$m + N[(N[(A - C), $MachinePrecision] * N[(A - C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(B$95$m * B$95$m + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.0 - N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 18000.0], N[(N[Sqrt[N[(2.0 * N[(F * N[(-0.5 * N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(0.0 - B$95$m), $MachinePrecision]), $MachinePrecision], N[(0.0 - N[(N[Sqrt[F], $MachinePrecision] / N[Sqrt[N[(B$95$m * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 7.2 \cdot 10^{-136}:\\
\;\;\;\;\sqrt{\frac{F \cdot \left(\left(A + C\right) + \sqrt{\mathsf{fma}\left(B\_m, B\_m, \left(A - C\right) \cdot \left(A - C\right)\right)}\right)}{\mathsf{fma}\left(B\_m, B\_m, -4 \cdot \left(A \cdot C\right)\right)}} \cdot \left(0 - \sqrt{2}\right)\\
\mathbf{elif}\;B\_m \leq 18000:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(-0.5 \cdot \frac{B\_m \cdot B\_m}{A}\right)\right)}}{0 - B\_m}\\
\mathbf{else}:\\
\;\;\;\;0 - \frac{\sqrt{F}}{\sqrt{B\_m \cdot 0.5}}\\
\end{array}
\end{array}
if B < 7.1999999999999996e-136Initial program 14.5%
Taylor expanded in F around 0
mul-1-negN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
Simplified14.3%
if 7.1999999999999996e-136 < B < 18000Initial program 22.2%
Taylor expanded in C around 0
mul-1-negN/A
associate-*l/N/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
Simplified14.4%
sub0-negN/A
distribute-frac-neg2N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
Applied egg-rr14.5%
Taylor expanded in A around -inf
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6416.6
Simplified16.6%
if 18000 < B Initial program 13.9%
Taylor expanded in B around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6445.7
Simplified45.7%
sub0-negN/A
neg-lowering-neg.f64N/A
sqrt-unprodN/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
sqrt-unprodN/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f6446.0
Applied egg-rr46.0%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6446.0
Applied egg-rr46.0%
clear-numN/A
un-div-invN/A
sqrt-divN/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
div-invN/A
metadata-evalN/A
*-lowering-*.f6456.4
Applied egg-rr56.4%
Final simplification25.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 (if (<= B_m 11000.0) (/ (sqrt (* 2.0 (* F (* -0.5 (/ (* B_m B_m) A))))) (- 0.0 B_m)) (- 0.0 (/ (sqrt F) (sqrt (* B_m 0.5))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 11000.0) {
tmp = sqrt((2.0 * (F * (-0.5 * ((B_m * B_m) / A))))) / (0.0 - B_m);
} else {
tmp = 0.0 - (sqrt(F) / sqrt((B_m * 0.5)));
}
return tmp;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (b_m <= 11000.0d0) then
tmp = sqrt((2.0d0 * (f * ((-0.5d0) * ((b_m * b_m) / a))))) / (0.0d0 - b_m)
else
tmp = 0.0d0 - (sqrt(f) / sqrt((b_m * 0.5d0)))
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (B_m <= 11000.0) {
tmp = Math.sqrt((2.0 * (F * (-0.5 * ((B_m * B_m) / A))))) / (0.0 - B_m);
} else {
tmp = 0.0 - (Math.sqrt(F) / Math.sqrt((B_m * 0.5)));
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if B_m <= 11000.0: tmp = math.sqrt((2.0 * (F * (-0.5 * ((B_m * B_m) / A))))) / (0.0 - B_m) else: tmp = 0.0 - (math.sqrt(F) / math.sqrt((B_m * 0.5))) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (B_m <= 11000.0) tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(-0.5 * Float64(Float64(B_m * B_m) / A))))) / Float64(0.0 - B_m)); else tmp = Float64(0.0 - Float64(sqrt(F) / sqrt(Float64(B_m * 0.5)))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (B_m <= 11000.0)
tmp = sqrt((2.0 * (F * (-0.5 * ((B_m * B_m) / A))))) / (0.0 - B_m);
else
tmp = 0.0 - (sqrt(F) / sqrt((B_m * 0.5)));
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 11000.0], N[(N[Sqrt[N[(2.0 * N[(F * N[(-0.5 * N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(0.0 - B$95$m), $MachinePrecision]), $MachinePrecision], N[(0.0 - N[(N[Sqrt[F], $MachinePrecision] / N[Sqrt[N[(B$95$m * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 11000:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(-0.5 \cdot \frac{B\_m \cdot B\_m}{A}\right)\right)}}{0 - B\_m}\\
\mathbf{else}:\\
\;\;\;\;0 - \frac{\sqrt{F}}{\sqrt{B\_m \cdot 0.5}}\\
\end{array}
\end{array}
if B < 11000Initial program 15.7%
Taylor expanded in C around 0
mul-1-negN/A
associate-*l/N/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
Simplified3.7%
sub0-negN/A
distribute-frac-neg2N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
Applied egg-rr3.7%
Taylor expanded in A around -inf
*-lowering-*.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f646.4
Simplified6.4%
if 11000 < B Initial program 13.9%
Taylor expanded in B around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6445.7
Simplified45.7%
sub0-negN/A
neg-lowering-neg.f64N/A
sqrt-unprodN/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
sqrt-unprodN/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f6446.0
Applied egg-rr46.0%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6446.0
Applied egg-rr46.0%
clear-numN/A
un-div-invN/A
sqrt-divN/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
div-invN/A
metadata-evalN/A
*-lowering-*.f6456.4
Applied egg-rr56.4%
Final simplification19.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 (if (<= F 400000.0) (/ (sqrt (* 2.0 (* B_m F))) (- 0.0 B_m)) (- 0.0 (sqrt (* F (/ 2.0 B_m))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= 400000.0) {
tmp = sqrt((2.0 * (B_m * F))) / (0.0 - B_m);
} else {
tmp = 0.0 - sqrt((F * (2.0 / B_m)));
}
return tmp;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (f <= 400000.0d0) then
tmp = sqrt((2.0d0 * (b_m * f))) / (0.0d0 - b_m)
else
tmp = 0.0d0 - sqrt((f * (2.0d0 / b_m)))
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= 400000.0) {
tmp = Math.sqrt((2.0 * (B_m * F))) / (0.0 - B_m);
} else {
tmp = 0.0 - Math.sqrt((F * (2.0 / B_m)));
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if F <= 400000.0: tmp = math.sqrt((2.0 * (B_m * F))) / (0.0 - B_m) else: tmp = 0.0 - math.sqrt((F * (2.0 / B_m))) return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (F <= 400000.0) tmp = Float64(sqrt(Float64(2.0 * Float64(B_m * F))) / Float64(0.0 - B_m)); else tmp = Float64(0.0 - sqrt(Float64(F * Float64(2.0 / B_m)))); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (F <= 400000.0)
tmp = sqrt((2.0 * (B_m * F))) / (0.0 - B_m);
else
tmp = 0.0 - sqrt((F * (2.0 / B_m)));
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[F, 400000.0], N[(N[Sqrt[N[(2.0 * N[(B$95$m * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(0.0 - B$95$m), $MachinePrecision]), $MachinePrecision], N[(0.0 - N[Sqrt[N[(F * N[(2.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;F \leq 400000:\\
\;\;\;\;\frac{\sqrt{2 \cdot \left(B\_m \cdot F\right)}}{0 - B\_m}\\
\mathbf{else}:\\
\;\;\;\;0 - \sqrt{F \cdot \frac{2}{B\_m}}\\
\end{array}
\end{array}
if F < 4e5Initial program 18.4%
Taylor expanded in C around 0
mul-1-negN/A
associate-*l/N/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
Simplified9.9%
sub0-negN/A
distribute-frac-neg2N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
Applied egg-rr10.0%
Taylor expanded in A around 0
Simplified15.7%
if 4e5 < F Initial program 11.3%
Taylor expanded in B around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6418.2
Simplified18.2%
sub0-negN/A
neg-lowering-neg.f64N/A
sqrt-unprodN/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
sqrt-unprodN/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f6418.3
Applied egg-rr18.3%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6418.3
Applied egg-rr18.3%
Final simplification16.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 (- 0.0 (/ (sqrt F) (sqrt (* B_m 0.5)))))
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.0 - (sqrt(F) / sqrt((B_m * 0.5)));
}
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.0d0 - (sqrt(f) / sqrt((b_m * 0.5d0)))
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.0 - (Math.sqrt(F) / Math.sqrt((B_m * 0.5)));
}
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.0 - (math.sqrt(F) / math.sqrt((B_m * 0.5)))
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.0 - Float64(sqrt(F) / sqrt(Float64(B_m * 0.5)))) 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.0 - (sqrt(F) / sqrt((B_m * 0.5)));
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.0 - N[(N[Sqrt[F], $MachinePrecision] / N[Sqrt[N[(B$95$m * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
0 - \frac{\sqrt{F}}{\sqrt{B\_m \cdot 0.5}}
\end{array}
Initial program 15.2%
Taylor expanded in B around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6413.8
Simplified13.8%
sub0-negN/A
neg-lowering-neg.f64N/A
sqrt-unprodN/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
sqrt-unprodN/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f6413.9
Applied egg-rr13.9%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6413.9
Applied egg-rr13.9%
clear-numN/A
un-div-invN/A
sqrt-divN/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
div-invN/A
metadata-evalN/A
*-lowering-*.f6416.3
Applied egg-rr16.3%
Final simplification16.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 (- 0.0 (* (sqrt F) (sqrt (/ 2.0 B_m)))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return 0.0 - (sqrt(F) * sqrt((2.0 / B_m)));
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = 0.0d0 - (sqrt(f) * sqrt((2.0d0 / b_m)))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return 0.0 - (Math.sqrt(F) * Math.sqrt((2.0 / B_m)));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return 0.0 - (math.sqrt(F) * math.sqrt((2.0 / B_m)))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(0.0 - Float64(sqrt(F) * sqrt(Float64(2.0 / B_m)))) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = 0.0 - (sqrt(F) * sqrt((2.0 / B_m)));
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[(0.0 - N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(2.0 / B$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
0 - \sqrt{F} \cdot \sqrt{\frac{2}{B\_m}}
\end{array}
Initial program 15.2%
Taylor expanded in B around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6413.8
Simplified13.8%
sub0-negN/A
neg-lowering-neg.f64N/A
sqrt-unprodN/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
sqrt-unprodN/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f6413.9
Applied egg-rr13.9%
associate-/l*N/A
clear-numN/A
un-div-invN/A
sqrt-undivN/A
sqrt-undivN/A
associate-/r/N/A
*-lowering-*.f64N/A
sqrt-undivN/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f6416.2
Applied egg-rr16.2%
Final simplification16.2%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (- 0.0 (sqrt (fabs (fma F (/ 2.0 B_m) 0.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.0 - sqrt(fabs(fma(F, (2.0 / B_m), 0.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.0 - sqrt(abs(fma(F, Float64(2.0 / B_m), 0.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.0 - N[Sqrt[N[Abs[N[(F * N[(2.0 / B$95$m), $MachinePrecision] + 0.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
0 - \sqrt{\left|\mathsf{fma}\left(F, \frac{2}{B\_m}, 0\right)\right|}
\end{array}
Initial program 15.2%
Taylor expanded in B around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6413.8
Simplified13.8%
sub0-negN/A
neg-lowering-neg.f64N/A
sqrt-unprodN/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
sqrt-unprodN/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f6413.9
Applied egg-rr13.9%
associate-/l*N/A
*-commutativeN/A
rem-square-sqrtN/A
sqrt-unprodN/A
rem-sqrt-squareN/A
fabs-lowering-fabs.f64N/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-unprodN/A
pow2N/A
sqrt-divN/A
clear-numN/A
*-commutativeN/A
pow2N/A
+-lft-identityN/A
*-commutativeN/A
clear-numN/A
sqrt-divN/A
+-commutativeN/A
Applied egg-rr27.8%
Final simplification27.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 (- 0.0 (sqrt (* F (/ 2.0 B_m)))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return 0.0 - sqrt((F * (2.0 / B_m)));
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = 0.0d0 - sqrt((f * (2.0d0 / b_m)))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return 0.0 - Math.sqrt((F * (2.0 / B_m)));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return 0.0 - math.sqrt((F * (2.0 / B_m)))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(0.0 - sqrt(Float64(F * Float64(2.0 / B_m)))) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = 0.0 - sqrt((F * (2.0 / B_m)));
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[(0.0 - N[Sqrt[N[(F * N[(2.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
0 - \sqrt{F \cdot \frac{2}{B\_m}}
\end{array}
Initial program 15.2%
Taylor expanded in B around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6413.8
Simplified13.8%
sub0-negN/A
neg-lowering-neg.f64N/A
sqrt-unprodN/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
sqrt-unprodN/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f6413.9
Applied egg-rr13.9%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6413.9
Applied egg-rr13.9%
Final simplification13.9%
herbie shell --seed 2024196
(FPCore (A B C F)
:name "ABCF->ab-angle a"
: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))))