
(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: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= C -1.4e-291)
(/ (* (* 2.0 (* (sqrt (* C -4.0)) (sqrt F))) -0.25) C)
(if (<= C 4.7e-45)
(*
(*
(sqrt (fma C (* A -4.0) (* B B)))
(sqrt (* (* F 2.0) (- (+ C A) (sqrt (fma (- A C) (- A C) (* B B)))))))
(/ -1.0 (fma B B (* C (* A -4.0)))))
(/ (* -0.25 (* (* 2.0 (sqrt C)) (sqrt (* -4.0 F)))) C))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (C <= -1.4e-291) {
tmp = ((2.0 * (sqrt((C * -4.0)) * sqrt(F))) * -0.25) / C;
} else if (C <= 4.7e-45) {
tmp = (sqrt(fma(C, (A * -4.0), (B * B))) * sqrt(((F * 2.0) * ((C + A) - sqrt(fma((A - C), (A - C), (B * B))))))) * (-1.0 / fma(B, B, (C * (A * -4.0))));
} else {
tmp = (-0.25 * ((2.0 * sqrt(C)) * sqrt((-4.0 * F)))) / C;
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (C <= -1.4e-291) tmp = Float64(Float64(Float64(2.0 * Float64(sqrt(Float64(C * -4.0)) * sqrt(F))) * -0.25) / C); elseif (C <= 4.7e-45) tmp = Float64(Float64(sqrt(fma(C, Float64(A * -4.0), Float64(B * B))) * sqrt(Float64(Float64(F * 2.0) * Float64(Float64(C + A) - sqrt(fma(Float64(A - C), Float64(A - C), Float64(B * B))))))) * Float64(-1.0 / fma(B, B, Float64(C * Float64(A * -4.0))))); else tmp = Float64(Float64(-0.25 * Float64(Float64(2.0 * sqrt(C)) * sqrt(Float64(-4.0 * F)))) / C); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[C, -1.4e-291], N[(N[(N[(2.0 * N[(N[Sqrt[N[(C * -4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision] / C), $MachinePrecision], If[LessEqual[C, 4.7e-45], N[(N[(N[Sqrt[N[(C * N[(A * -4.0), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(N[(F * 2.0), $MachinePrecision] * N[(N[(C + A), $MachinePrecision] - N[Sqrt[N[(N[(A - C), $MachinePrecision] * N[(A - C), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.25 * N[(N[(2.0 * N[Sqrt[C], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(-4.0 * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;C \leq -1.4 \cdot 10^{-291}:\\
\;\;\;\;\frac{\left(2 \cdot \left(\sqrt{C \cdot -4} \cdot \sqrt{F}\right)\right) \cdot -0.25}{C}\\
\mathbf{elif}\;C \leq 4.7 \cdot 10^{-45}:\\
\;\;\;\;\left(\sqrt{\mathsf{fma}\left(C, A \cdot -4, B \cdot B\right)} \cdot \sqrt{\left(F \cdot 2\right) \cdot \left(\left(C + A\right) - \sqrt{\mathsf{fma}\left(A - C, A - C, B \cdot B\right)}\right)}\right) \cdot \frac{-1}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.25 \cdot \left(\left(2 \cdot \sqrt{C}\right) \cdot \sqrt{-4 \cdot F}\right)}{C}\\
\end{array}
\end{array}
if C < -1.4e-291Initial program 18.4%
Applied rewrites5.5%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6414.8
Applied rewrites14.8%
Applied rewrites15.0%
Applied rewrites18.5%
if -1.4e-291 < C < 4.6999999999999998e-45Initial program 27.2%
Applied rewrites27.2%
Applied rewrites32.0%
if 4.6999999999999998e-45 < C Initial program 7.8%
Applied rewrites6.1%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6428.2
Applied rewrites28.2%
Applied rewrites28.6%
Applied rewrites36.6%
Final simplification26.8%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= C -1.4e-291)
(/ (* (* 2.0 (* (sqrt (* C -4.0)) (sqrt F))) -0.25) C)
(if (<= C 4.7e-45)
(*
(/ -1.0 (fma B B (* C (* A -4.0))))
(*
(sqrt (* 2.0 (fma C (* A -4.0) (* B B))))
(sqrt (* F (- (+ C A) (sqrt (fma (- A C) (- A C) (* B B))))))))
(/ (* -0.25 (* (* 2.0 (sqrt C)) (sqrt (* -4.0 F)))) C))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (C <= -1.4e-291) {
tmp = ((2.0 * (sqrt((C * -4.0)) * sqrt(F))) * -0.25) / C;
} else if (C <= 4.7e-45) {
tmp = (-1.0 / fma(B, B, (C * (A * -4.0)))) * (sqrt((2.0 * fma(C, (A * -4.0), (B * B)))) * sqrt((F * ((C + A) - sqrt(fma((A - C), (A - C), (B * B)))))));
} else {
tmp = (-0.25 * ((2.0 * sqrt(C)) * sqrt((-4.0 * F)))) / C;
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (C <= -1.4e-291) tmp = Float64(Float64(Float64(2.0 * Float64(sqrt(Float64(C * -4.0)) * sqrt(F))) * -0.25) / C); elseif (C <= 4.7e-45) tmp = Float64(Float64(-1.0 / fma(B, B, Float64(C * Float64(A * -4.0)))) * Float64(sqrt(Float64(2.0 * fma(C, Float64(A * -4.0), Float64(B * B)))) * sqrt(Float64(F * Float64(Float64(C + A) - sqrt(fma(Float64(A - C), Float64(A - C), Float64(B * B)))))))); else tmp = Float64(Float64(-0.25 * Float64(Float64(2.0 * sqrt(C)) * sqrt(Float64(-4.0 * F)))) / C); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[C, -1.4e-291], N[(N[(N[(2.0 * N[(N[Sqrt[N[(C * -4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision] / C), $MachinePrecision], If[LessEqual[C, 4.7e-45], N[(N[(-1.0 / N[(B * B + N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(2.0 * N[(C * N[(A * -4.0), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(F * N[(N[(C + A), $MachinePrecision] - N[Sqrt[N[(N[(A - C), $MachinePrecision] * N[(A - C), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.25 * N[(N[(2.0 * N[Sqrt[C], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(-4.0 * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;C \leq -1.4 \cdot 10^{-291}:\\
\;\;\;\;\frac{\left(2 \cdot \left(\sqrt{C \cdot -4} \cdot \sqrt{F}\right)\right) \cdot -0.25}{C}\\
\mathbf{elif}\;C \leq 4.7 \cdot 10^{-45}:\\
\;\;\;\;\frac{-1}{\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)} \cdot \left(\sqrt{2 \cdot \mathsf{fma}\left(C, A \cdot -4, B \cdot B\right)} \cdot \sqrt{F \cdot \left(\left(C + A\right) - \sqrt{\mathsf{fma}\left(A - C, A - C, B \cdot B\right)}\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.25 \cdot \left(\left(2 \cdot \sqrt{C}\right) \cdot \sqrt{-4 \cdot F}\right)}{C}\\
\end{array}
\end{array}
if C < -1.4e-291Initial program 18.4%
Applied rewrites5.5%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6414.8
Applied rewrites14.8%
Applied rewrites15.0%
Applied rewrites18.5%
if -1.4e-291 < C < 4.6999999999999998e-45Initial program 27.2%
Applied rewrites27.2%
Applied rewrites31.9%
if 4.6999999999999998e-45 < C Initial program 7.8%
Applied rewrites6.1%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6428.2
Applied rewrites28.2%
Applied rewrites28.6%
Applied rewrites36.6%
Final simplification26.8%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= C -1.4e-291)
(/ (* (* 2.0 (* (sqrt (* C -4.0)) (sqrt F))) -0.25) C)
(if (<= C 7.6e-171)
(* (sqrt (* F (- A (sqrt (fma B B (* A A)))))) (/ (sqrt 2.0) (- B)))
(/ (* -0.25 (* (* 2.0 (sqrt C)) (sqrt (* -4.0 F)))) C))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (C <= -1.4e-291) {
tmp = ((2.0 * (sqrt((C * -4.0)) * sqrt(F))) * -0.25) / C;
} else if (C <= 7.6e-171) {
tmp = sqrt((F * (A - sqrt(fma(B, B, (A * A)))))) * (sqrt(2.0) / -B);
} else {
tmp = (-0.25 * ((2.0 * sqrt(C)) * sqrt((-4.0 * F)))) / C;
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (C <= -1.4e-291) tmp = Float64(Float64(Float64(2.0 * Float64(sqrt(Float64(C * -4.0)) * sqrt(F))) * -0.25) / C); elseif (C <= 7.6e-171) tmp = Float64(sqrt(Float64(F * Float64(A - sqrt(fma(B, B, Float64(A * A)))))) * Float64(sqrt(2.0) / Float64(-B))); else tmp = Float64(Float64(-0.25 * Float64(Float64(2.0 * sqrt(C)) * sqrt(Float64(-4.0 * F)))) / C); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[C, -1.4e-291], N[(N[(N[(2.0 * N[(N[Sqrt[N[(C * -4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision] / C), $MachinePrecision], If[LessEqual[C, 7.6e-171], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[N[(B * B + N[(A * A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] / (-B)), $MachinePrecision]), $MachinePrecision], N[(N[(-0.25 * N[(N[(2.0 * N[Sqrt[C], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(-4.0 * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;C \leq -1.4 \cdot 10^{-291}:\\
\;\;\;\;\frac{\left(2 \cdot \left(\sqrt{C \cdot -4} \cdot \sqrt{F}\right)\right) \cdot -0.25}{C}\\
\mathbf{elif}\;C \leq 7.6 \cdot 10^{-171}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \sqrt{\mathsf{fma}\left(B, B, A \cdot A\right)}\right)} \cdot \frac{\sqrt{2}}{-B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.25 \cdot \left(\left(2 \cdot \sqrt{C}\right) \cdot \sqrt{-4 \cdot F}\right)}{C}\\
\end{array}
\end{array}
if C < -1.4e-291Initial program 18.4%
Applied rewrites5.5%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6414.8
Applied rewrites14.8%
Applied rewrites15.0%
Applied rewrites18.5%
if -1.4e-291 < C < 7.60000000000000043e-171Initial program 28.6%
Taylor expanded in C around 0
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
Applied rewrites15.7%
if 7.60000000000000043e-171 < C Initial program 10.2%
Applied rewrites7.5%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6427.7
Applied rewrites27.7%
Applied rewrites28.1%
Applied rewrites35.9%
Final simplification24.1%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= C -1e-291) (/ (* (* 2.0 (* (sqrt (* C -4.0)) (sqrt F))) -0.25) C) (/ (* -0.25 (* (* 2.0 (sqrt C)) (sqrt (* -4.0 F)))) C)))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (C <= -1e-291) {
tmp = ((2.0 * (sqrt((C * -4.0)) * sqrt(F))) * -0.25) / C;
} else {
tmp = (-0.25 * ((2.0 * sqrt(C)) * sqrt((-4.0 * F)))) / C;
}
return tmp;
}
NOTE: A, B, C, and F 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 (c <= (-1d-291)) then
tmp = ((2.0d0 * (sqrt((c * (-4.0d0))) * sqrt(f))) * (-0.25d0)) / c
else
tmp = ((-0.25d0) * ((2.0d0 * sqrt(c)) * sqrt(((-4.0d0) * f)))) / c
end if
code = tmp
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
double tmp;
if (C <= -1e-291) {
tmp = ((2.0 * (Math.sqrt((C * -4.0)) * Math.sqrt(F))) * -0.25) / C;
} else {
tmp = (-0.25 * ((2.0 * Math.sqrt(C)) * Math.sqrt((-4.0 * F)))) / C;
}
return tmp;
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): tmp = 0 if C <= -1e-291: tmp = ((2.0 * (math.sqrt((C * -4.0)) * math.sqrt(F))) * -0.25) / C else: tmp = (-0.25 * ((2.0 * math.sqrt(C)) * math.sqrt((-4.0 * F)))) / C return tmp
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (C <= -1e-291) tmp = Float64(Float64(Float64(2.0 * Float64(sqrt(Float64(C * -4.0)) * sqrt(F))) * -0.25) / C); else tmp = Float64(Float64(-0.25 * Float64(Float64(2.0 * sqrt(C)) * sqrt(Float64(-4.0 * F)))) / C); end return tmp end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (C <= -1e-291)
tmp = ((2.0 * (sqrt((C * -4.0)) * sqrt(F))) * -0.25) / C;
else
tmp = (-0.25 * ((2.0 * sqrt(C)) * sqrt((-4.0 * F)))) / C;
end
tmp_2 = tmp;
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[C, -1e-291], N[(N[(N[(2.0 * N[(N[Sqrt[N[(C * -4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision] / C), $MachinePrecision], N[(N[(-0.25 * N[(N[(2.0 * N[Sqrt[C], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(-4.0 * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;C \leq -1 \cdot 10^{-291}:\\
\;\;\;\;\frac{\left(2 \cdot \left(\sqrt{C \cdot -4} \cdot \sqrt{F}\right)\right) \cdot -0.25}{C}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.25 \cdot \left(\left(2 \cdot \sqrt{C}\right) \cdot \sqrt{-4 \cdot F}\right)}{C}\\
\end{array}
\end{array}
if C < -9.99999999999999962e-292Initial program 18.4%
Applied rewrites5.5%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6414.8
Applied rewrites14.8%
Applied rewrites15.0%
Applied rewrites18.5%
if -9.99999999999999962e-292 < C Initial program 16.2%
Applied rewrites9.0%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6421.8
Applied rewrites21.8%
Applied rewrites22.1%
Applied rewrites28.3%
Final simplification23.6%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= F -5e-310) (/ (* (sqrt (* C (* -4.0 F))) -0.5) C) (/ (* (* 2.0 (* (sqrt (* C -4.0)) (sqrt F))) -0.25) C)))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (F <= -5e-310) {
tmp = (sqrt((C * (-4.0 * F))) * -0.5) / C;
} else {
tmp = ((2.0 * (sqrt((C * -4.0)) * sqrt(F))) * -0.25) / C;
}
return tmp;
}
NOTE: A, B, C, and F 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 (f <= (-5d-310)) then
tmp = (sqrt((c * ((-4.0d0) * f))) * (-0.5d0)) / c
else
tmp = ((2.0d0 * (sqrt((c * (-4.0d0))) * sqrt(f))) * (-0.25d0)) / c
end if
code = tmp
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
double tmp;
if (F <= -5e-310) {
tmp = (Math.sqrt((C * (-4.0 * F))) * -0.5) / C;
} else {
tmp = ((2.0 * (Math.sqrt((C * -4.0)) * Math.sqrt(F))) * -0.25) / C;
}
return tmp;
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): tmp = 0 if F <= -5e-310: tmp = (math.sqrt((C * (-4.0 * F))) * -0.5) / C else: tmp = ((2.0 * (math.sqrt((C * -4.0)) * math.sqrt(F))) * -0.25) / C return tmp
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (F <= -5e-310) tmp = Float64(Float64(sqrt(Float64(C * Float64(-4.0 * F))) * -0.5) / C); else tmp = Float64(Float64(Float64(2.0 * Float64(sqrt(Float64(C * -4.0)) * sqrt(F))) * -0.25) / C); end return tmp end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (F <= -5e-310)
tmp = (sqrt((C * (-4.0 * F))) * -0.5) / C;
else
tmp = ((2.0 * (sqrt((C * -4.0)) * sqrt(F))) * -0.25) / C;
end
tmp_2 = tmp;
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[F, -5e-310], N[(N[(N[Sqrt[N[(C * N[(-4.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5), $MachinePrecision] / C), $MachinePrecision], N[(N[(N[(2.0 * N[(N[Sqrt[N[(C * -4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision] / C), $MachinePrecision]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;F \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\sqrt{C \cdot \left(-4 \cdot F\right)} \cdot -0.5}{C}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(2 \cdot \left(\sqrt{C \cdot -4} \cdot \sqrt{F}\right)\right) \cdot -0.25}{C}\\
\end{array}
\end{array}
if F < -4.999999999999985e-310Initial program 15.8%
Applied rewrites8.5%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6413.4
Applied rewrites13.4%
Applied rewrites13.5%
Applied rewrites13.5%
if -4.999999999999985e-310 < F Initial program 25.6%
Applied rewrites0.0%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6448.2
Applied rewrites48.2%
Applied rewrites48.8%
Applied rewrites62.0%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= F -5e-310) (/ (* (sqrt (* C (* -4.0 F))) -0.5) C) (* -0.25 (* (sqrt F) (* (sqrt (* C -4.0)) (/ 2.0 C))))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (F <= -5e-310) {
tmp = (sqrt((C * (-4.0 * F))) * -0.5) / C;
} else {
tmp = -0.25 * (sqrt(F) * (sqrt((C * -4.0)) * (2.0 / C)));
}
return tmp;
}
NOTE: A, B, C, and F 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 (f <= (-5d-310)) then
tmp = (sqrt((c * ((-4.0d0) * f))) * (-0.5d0)) / c
else
tmp = (-0.25d0) * (sqrt(f) * (sqrt((c * (-4.0d0))) * (2.0d0 / c)))
end if
code = tmp
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
double tmp;
if (F <= -5e-310) {
tmp = (Math.sqrt((C * (-4.0 * F))) * -0.5) / C;
} else {
tmp = -0.25 * (Math.sqrt(F) * (Math.sqrt((C * -4.0)) * (2.0 / C)));
}
return tmp;
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): tmp = 0 if F <= -5e-310: tmp = (math.sqrt((C * (-4.0 * F))) * -0.5) / C else: tmp = -0.25 * (math.sqrt(F) * (math.sqrt((C * -4.0)) * (2.0 / C))) return tmp
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (F <= -5e-310) tmp = Float64(Float64(sqrt(Float64(C * Float64(-4.0 * F))) * -0.5) / C); else tmp = Float64(-0.25 * Float64(sqrt(F) * Float64(sqrt(Float64(C * -4.0)) * Float64(2.0 / C)))); end return tmp end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (F <= -5e-310)
tmp = (sqrt((C * (-4.0 * F))) * -0.5) / C;
else
tmp = -0.25 * (sqrt(F) * (sqrt((C * -4.0)) * (2.0 / C)));
end
tmp_2 = tmp;
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[F, -5e-310], N[(N[(N[Sqrt[N[(C * N[(-4.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5), $MachinePrecision] / C), $MachinePrecision], N[(-0.25 * N[(N[Sqrt[F], $MachinePrecision] * N[(N[Sqrt[N[(C * -4.0), $MachinePrecision]], $MachinePrecision] * N[(2.0 / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;F \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\sqrt{C \cdot \left(-4 \cdot F\right)} \cdot -0.5}{C}\\
\mathbf{else}:\\
\;\;\;\;-0.25 \cdot \left(\sqrt{F} \cdot \left(\sqrt{C \cdot -4} \cdot \frac{2}{C}\right)\right)\\
\end{array}
\end{array}
if F < -4.999999999999985e-310Initial program 15.8%
Applied rewrites8.5%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6413.4
Applied rewrites13.4%
Applied rewrites13.5%
Applied rewrites13.5%
if -4.999999999999985e-310 < F Initial program 25.6%
Applied rewrites0.0%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6448.2
Applied rewrites48.2%
Applied rewrites61.8%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= C -9e-240) (* (sqrt (* C -4.0)) (* (sqrt F) (/ -0.5 C))) (/ (* (sqrt (* C (* -4.0 F))) -0.5) C)))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (C <= -9e-240) {
tmp = sqrt((C * -4.0)) * (sqrt(F) * (-0.5 / C));
} else {
tmp = (sqrt((C * (-4.0 * F))) * -0.5) / C;
}
return tmp;
}
NOTE: A, B, C, and F 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 (c <= (-9d-240)) then
tmp = sqrt((c * (-4.0d0))) * (sqrt(f) * ((-0.5d0) / c))
else
tmp = (sqrt((c * ((-4.0d0) * f))) * (-0.5d0)) / c
end if
code = tmp
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
double tmp;
if (C <= -9e-240) {
tmp = Math.sqrt((C * -4.0)) * (Math.sqrt(F) * (-0.5 / C));
} else {
tmp = (Math.sqrt((C * (-4.0 * F))) * -0.5) / C;
}
return tmp;
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): tmp = 0 if C <= -9e-240: tmp = math.sqrt((C * -4.0)) * (math.sqrt(F) * (-0.5 / C)) else: tmp = (math.sqrt((C * (-4.0 * F))) * -0.5) / C return tmp
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (C <= -9e-240) tmp = Float64(sqrt(Float64(C * -4.0)) * Float64(sqrt(F) * Float64(-0.5 / C))); else tmp = Float64(Float64(sqrt(Float64(C * Float64(-4.0 * F))) * -0.5) / C); end return tmp end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (C <= -9e-240)
tmp = sqrt((C * -4.0)) * (sqrt(F) * (-0.5 / C));
else
tmp = (sqrt((C * (-4.0 * F))) * -0.5) / C;
end
tmp_2 = tmp;
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[C, -9e-240], N[(N[Sqrt[N[(C * -4.0), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[F], $MachinePrecision] * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(C * N[(-4.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5), $MachinePrecision] / C), $MachinePrecision]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;C \leq -9 \cdot 10^{-240}:\\
\;\;\;\;\sqrt{C \cdot -4} \cdot \left(\sqrt{F} \cdot \frac{-0.5}{C}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{C \cdot \left(-4 \cdot F\right)} \cdot -0.5}{C}\\
\end{array}
\end{array}
if C < -9.0000000000000003e-240Initial program 17.4%
Applied rewrites5.9%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6414.4
Applied rewrites14.4%
Applied rewrites18.5%
if -9.0000000000000003e-240 < C Initial program 17.1%
Applied rewrites8.4%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6421.6
Applied rewrites21.6%
Applied rewrites21.8%
Applied rewrites21.8%
Final simplification20.4%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (/ (* (sqrt (* C (* -4.0 F))) -0.5) C))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return (sqrt((C * (-4.0 * F))) * -0.5) / C;
}
NOTE: A, B, C, and F 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((c * ((-4.0d0) * f))) * (-0.5d0)) / c
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
return (Math.sqrt((C * (-4.0 * F))) * -0.5) / C;
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): return (math.sqrt((C * (-4.0 * F))) * -0.5) / C
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return Float64(Float64(sqrt(Float64(C * Float64(-4.0 * F))) * -0.5) / C) end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp = code(A, B, C, F)
tmp = (sqrt((C * (-4.0 * F))) * -0.5) / C;
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(N[(N[Sqrt[N[(C * N[(-4.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5), $MachinePrecision] / C), $MachinePrecision]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\frac{\sqrt{C \cdot \left(-4 \cdot F\right)} \cdot -0.5}{C}
\end{array}
Initial program 17.2%
Applied rewrites7.3%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6418.4
Applied rewrites18.4%
Applied rewrites18.6%
Applied rewrites18.6%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* (sqrt (* C (* -4.0 F))) (/ -0.5 C)))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return sqrt((C * (-4.0 * F))) * (-0.5 / C);
}
NOTE: A, B, C, and F 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((c * ((-4.0d0) * f))) * ((-0.5d0) / c)
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
return Math.sqrt((C * (-4.0 * F))) * (-0.5 / C);
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): return math.sqrt((C * (-4.0 * F))) * (-0.5 / C)
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return Float64(sqrt(Float64(C * Float64(-4.0 * F))) * Float64(-0.5 / C)) end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp = code(A, B, C, F)
tmp = sqrt((C * (-4.0 * F))) * (-0.5 / C);
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(N[Sqrt[N[(C * N[(-4.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\sqrt{C \cdot \left(-4 \cdot F\right)} \cdot \frac{-0.5}{C}
\end{array}
Initial program 17.2%
Applied rewrites7.3%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f6418.4
Applied rewrites18.4%
Applied rewrites18.6%
Final simplification18.6%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (sqrt (/ (* F 2.0) B)))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return sqrt(((F * 2.0) / B));
}
NOTE: A, B, C, and F 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(((f * 2.0d0) / b))
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
return Math.sqrt(((F * 2.0) / B));
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): return math.sqrt(((F * 2.0) / B))
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return sqrt(Float64(Float64(F * 2.0) / B)) end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp = code(A, B, C, F)
tmp = sqrt(((F * 2.0) / B));
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[Sqrt[N[(N[(F * 2.0), $MachinePrecision] / B), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\sqrt{\frac{F \cdot 2}{B}}
\end{array}
Initial program 17.2%
Taylor expanded in B around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f642.0
Applied rewrites2.0%
Applied rewrites2.0%
Applied rewrites2.0%
Final simplification2.0%
herbie shell --seed 2024227
(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))))