
(FPCore (a b_2 c) :precision binary64 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 - Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 - math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b_2 c) :precision binary64 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 - Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 - math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\end{array}
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -8.5e-18)
(* -0.5 (/ c b_2))
(if (<= b_2 1.45e+66)
(- (/ (- b_2) a) (/ (sqrt (- (* b_2 b_2) (* c a))) a))
(+ (* -2.0 (/ b_2 a)) (* (/ c b_2) 0.5)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -8.5e-18) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 1.45e+66) {
tmp = (-b_2 / a) - (sqrt(((b_2 * b_2) - (c * a))) / a);
} else {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-8.5d-18)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 1.45d+66) then
tmp = (-b_2 / a) - (sqrt(((b_2 * b_2) - (c * a))) / a)
else
tmp = ((-2.0d0) * (b_2 / a)) + ((c / b_2) * 0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -8.5e-18) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 1.45e+66) {
tmp = (-b_2 / a) - (Math.sqrt(((b_2 * b_2) - (c * a))) / a);
} else {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -8.5e-18: tmp = -0.5 * (c / b_2) elif b_2 <= 1.45e+66: tmp = (-b_2 / a) - (math.sqrt(((b_2 * b_2) - (c * a))) / a) else: tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -8.5e-18) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 1.45e+66) tmp = Float64(Float64(Float64(-b_2) / a) - Float64(sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a))) / a)); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(Float64(c / b_2) * 0.5)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -8.5e-18) tmp = -0.5 * (c / b_2); elseif (b_2 <= 1.45e+66) tmp = (-b_2 / a) - (sqrt(((b_2 * b_2) - (c * a))) / a); else tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -8.5e-18], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1.45e+66], N[(N[((-b$95$2) / a), $MachinePrecision] - N[(N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b$95$2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -8.5 \cdot 10^{-18}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 1.45 \cdot 10^{+66}:\\
\;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c}{b_2} \cdot 0.5\\
\end{array}
\end{array}
if b_2 < -8.4999999999999995e-18Initial program 10.1%
Taylor expanded in b_2 around -inf 90.0%
if -8.4999999999999995e-18 < b_2 < 1.44999999999999993e66Initial program 79.9%
div-sub79.9%
neg-mul-179.9%
*-un-lft-identity79.9%
times-frac79.9%
metadata-eval79.9%
add-sqr-sqrt56.5%
sqrt-prod78.3%
sqr-neg78.3%
sqrt-unprod22.4%
add-sqr-sqrt61.8%
fma-neg61.8%
add-sqr-sqrt22.4%
sqrt-unprod78.3%
sqr-neg78.3%
sqrt-prod56.5%
add-sqr-sqrt79.9%
Applied egg-rr77.0%
fma-neg77.0%
associate-*r/77.0%
mul-1-neg77.0%
distribute-rgt-neg-out77.0%
distribute-lft-neg-in77.0%
*-commutative77.0%
Simplified77.0%
hypot-udef74.9%
add-sqr-sqrt79.9%
distribute-rgt-neg-out79.9%
sub-neg79.9%
pow1/279.9%
metadata-eval79.9%
pow-prod-up79.6%
Applied egg-rr79.6%
pow-sqr79.9%
metadata-eval79.9%
unpow1/279.9%
*-commutative79.9%
Simplified79.9%
if 1.44999999999999993e66 < b_2 Initial program 46.9%
Taylor expanded in b_2 around inf 89.3%
Final simplification85.1%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -4.15e-19)
(* -0.5 (/ c b_2))
(if (<= b_2 1.45e+66)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
(+ (* -2.0 (/ b_2 a)) (* (/ c b_2) 0.5)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4.15e-19) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 1.45e+66) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-4.15d-19)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 1.45d+66) then
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a
else
tmp = ((-2.0d0) * (b_2 / a)) + ((c / b_2) * 0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4.15e-19) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 1.45e+66) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4.15e-19: tmp = -0.5 * (c / b_2) elif b_2 <= 1.45e+66: tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (c * a)))) / a else: tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -4.15e-19) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 1.45e+66) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(Float64(c / b_2) * 0.5)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -4.15e-19) tmp = -0.5 * (c / b_2); elseif (b_2 <= 1.45e+66) tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a; else tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -4.15e-19], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1.45e+66], N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b$95$2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -4.15 \cdot 10^{-19}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 1.45 \cdot 10^{+66}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c}{b_2} \cdot 0.5\\
\end{array}
\end{array}
if b_2 < -4.1500000000000001e-19Initial program 10.1%
Taylor expanded in b_2 around -inf 90.0%
if -4.1500000000000001e-19 < b_2 < 1.44999999999999993e66Initial program 79.9%
if 1.44999999999999993e66 < b_2 Initial program 46.9%
Taylor expanded in b_2 around inf 89.3%
Final simplification85.1%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -7.2e-19)
(* -0.5 (/ c b_2))
(if (<= b_2 9.2e-14)
(/ (- (- b_2) (sqrt (* c (- a)))) a)
(+ (* -2.0 (/ b_2 a)) (* (/ c b_2) 0.5)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -7.2e-19) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 9.2e-14) {
tmp = (-b_2 - sqrt((c * -a))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-7.2d-19)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 9.2d-14) then
tmp = (-b_2 - sqrt((c * -a))) / a
else
tmp = ((-2.0d0) * (b_2 / a)) + ((c / b_2) * 0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -7.2e-19) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 9.2e-14) {
tmp = (-b_2 - Math.sqrt((c * -a))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -7.2e-19: tmp = -0.5 * (c / b_2) elif b_2 <= 9.2e-14: tmp = (-b_2 - math.sqrt((c * -a))) / a else: tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -7.2e-19) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 9.2e-14) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(c * Float64(-a)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(Float64(c / b_2) * 0.5)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -7.2e-19) tmp = -0.5 * (c / b_2); elseif (b_2 <= 9.2e-14) tmp = (-b_2 - sqrt((c * -a))) / a; else tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -7.2e-19], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 9.2e-14], N[(N[((-b$95$2) - N[Sqrt[N[(c * (-a)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b$95$2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -7.2 \cdot 10^{-19}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 9.2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{c \cdot \left(-a\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c}{b_2} \cdot 0.5\\
\end{array}
\end{array}
if b_2 < -7.2000000000000002e-19Initial program 10.1%
Taylor expanded in b_2 around -inf 90.0%
if -7.2000000000000002e-19 < b_2 < 9.19999999999999993e-14Initial program 77.1%
Taylor expanded in b_2 around 0 70.8%
associate-*r*70.8%
neg-mul-170.8%
*-commutative70.8%
Simplified70.8%
if 9.19999999999999993e-14 < b_2 Initial program 59.7%
Taylor expanded in b_2 around inf 84.8%
Final simplification81.0%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-310) (* -0.5 (/ c b_2)) (+ (* -2.0 (/ b_2 a)) (* (/ c b_2) 0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = -0.5 * (c / b_2);
} else {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-5d-310)) then
tmp = (-0.5d0) * (c / b_2)
else
tmp = ((-2.0d0) * (b_2 / a)) + ((c / b_2) * 0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = -0.5 * (c / b_2);
} else {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-310: tmp = -0.5 * (c / b_2) else: tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-310) tmp = Float64(-0.5 * Float64(c / b_2)); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(Float64(c / b_2) * 0.5)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e-310) tmp = -0.5 * (c / b_2); else tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-310], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(N[(c / b$95$2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c}{b_2} \cdot 0.5\\
\end{array}
\end{array}
if b_2 < -4.999999999999985e-310Initial program 29.0%
Taylor expanded in b_2 around -inf 67.4%
if -4.999999999999985e-310 < b_2 Initial program 70.9%
Taylor expanded in b_2 around inf 54.9%
Final simplification61.0%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-310) 0.0 (* -2.0 (/ b_2 a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = 0.0;
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-5d-310)) then
tmp = 0.0d0
else
tmp = (-2.0d0) * (b_2 / a)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = 0.0;
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-310: tmp = 0.0 else: tmp = -2.0 * (b_2 / a) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-310) tmp = 0.0; else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e-310) tmp = 0.0; else tmp = -2.0 * (b_2 / a); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-310], 0.0, N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\
\end{array}
\end{array}
if b_2 < -4.999999999999985e-310Initial program 29.0%
div-sub28.6%
neg-mul-128.6%
*-un-lft-identity28.6%
times-frac28.6%
metadata-eval28.6%
add-sqr-sqrt0.0%
sqrt-prod25.8%
sqr-neg25.8%
sqrt-unprod25.9%
add-sqr-sqrt25.9%
fma-neg25.9%
add-sqr-sqrt25.9%
sqrt-unprod25.8%
sqr-neg25.8%
sqrt-prod0.0%
add-sqr-sqrt28.6%
Applied egg-rr30.6%
fma-neg30.6%
associate-*r/30.6%
mul-1-neg30.6%
distribute-rgt-neg-out30.6%
distribute-lft-neg-in30.6%
*-commutative30.6%
Simplified30.6%
Taylor expanded in b_2 around -inf 0.0%
mul-1-neg0.0%
distribute-frac-neg0.0%
+-commutative0.0%
distribute-frac-neg0.0%
unsub-neg0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt11.6%
neg-mul-111.6%
Simplified11.6%
Taylor expanded in a around 0 16.7%
distribute-rgt1-in16.7%
metadata-eval16.7%
associate-*r/10.5%
mul0-lft16.7%
Simplified16.7%
if -4.999999999999985e-310 < b_2 Initial program 70.9%
Taylor expanded in b_2 around inf 54.6%
Final simplification35.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.4e-302) (* -0.5 (/ c b_2)) (* -2.0 (/ b_2 a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.4e-302) {
tmp = -0.5 * (c / b_2);
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-1.4d-302)) then
tmp = (-0.5d0) * (c / b_2)
else
tmp = (-2.0d0) * (b_2 / a)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.4e-302) {
tmp = -0.5 * (c / b_2);
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.4e-302: tmp = -0.5 * (c / b_2) else: tmp = -2.0 * (b_2 / a) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.4e-302) tmp = Float64(-0.5 * Float64(c / b_2)); else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.4e-302) tmp = -0.5 * (c / b_2); else tmp = -2.0 * (b_2 / a); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.4e-302], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.4 \cdot 10^{-302}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\
\end{array}
\end{array}
if b_2 < -1.4e-302Initial program 27.9%
Taylor expanded in b_2 around -inf 68.4%
if -1.4e-302 < b_2 Initial program 71.3%
Taylor expanded in b_2 around inf 53.8%
Final simplification60.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.15e-302) 0.0 (/ c 0.0)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.15e-302) {
tmp = 0.0;
} else {
tmp = c / 0.0;
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-1.15d-302)) then
tmp = 0.0d0
else
tmp = c / 0.0d0
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.15e-302) {
tmp = 0.0;
} else {
tmp = c / 0.0;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.15e-302: tmp = 0.0 else: tmp = c / 0.0 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.15e-302) tmp = 0.0; else tmp = Float64(c / 0.0); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.15e-302) tmp = 0.0; else tmp = c / 0.0; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.15e-302], 0.0, N[(c / 0.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.15 \cdot 10^{-302}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{0}\\
\end{array}
\end{array}
if b_2 < -1.15000000000000001e-302Initial program 28.5%
div-sub28.0%
neg-mul-128.0%
*-un-lft-identity28.0%
times-frac28.0%
metadata-eval28.0%
add-sqr-sqrt0.0%
sqrt-prod25.2%
sqr-neg25.2%
sqrt-unprod25.3%
add-sqr-sqrt25.3%
fma-neg25.3%
add-sqr-sqrt25.3%
sqrt-unprod25.2%
sqr-neg25.2%
sqrt-prod0.0%
add-sqr-sqrt28.0%
Applied egg-rr30.1%
fma-neg30.1%
associate-*r/30.1%
mul-1-neg30.1%
distribute-rgt-neg-out30.1%
distribute-lft-neg-in30.1%
*-commutative30.1%
Simplified30.1%
Taylor expanded in b_2 around -inf 0.0%
mul-1-neg0.0%
distribute-frac-neg0.0%
+-commutative0.0%
distribute-frac-neg0.0%
unsub-neg0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt11.6%
neg-mul-111.6%
Simplified11.6%
Taylor expanded in a around 0 16.8%
distribute-rgt1-in16.8%
metadata-eval16.8%
associate-*r/10.5%
mul0-lft16.8%
Simplified16.8%
if -1.15000000000000001e-302 < b_2 Initial program 71.1%
add-sqr-sqrt70.9%
pow270.9%
pow1/270.9%
sqrt-pow170.9%
metadata-eval70.9%
Applied egg-rr70.9%
flip--40.3%
pow240.3%
pow-pow39.9%
metadata-eval39.9%
pow-pow37.8%
metadata-eval37.8%
pow-prod-up38.0%
metadata-eval38.0%
pow138.0%
neg-mul-138.0%
fma-def38.0%
pow-pow37.9%
metadata-eval37.9%
pow1/237.9%
Applied egg-rr37.0%
unpow237.0%
associate--r-38.2%
unpow238.2%
unpow238.2%
difference-of-squares47.8%
+-commutative47.8%
neg-mul-147.8%
distribute-rgt1-in47.8%
metadata-eval47.8%
mul0-lft47.8%
*-commutative47.8%
distribute-rgt-neg-out47.8%
*-commutative47.8%
distribute-rgt-neg-in47.8%
Simplified47.8%
Taylor expanded in c around 0 15.1%
distribute-rgt1-in15.1%
metadata-eval15.1%
mul0-lft15.1%
Simplified15.1%
Final simplification15.9%
(FPCore (a b_2 c) :precision binary64 0.0)
double code(double a, double b_2, double c) {
return 0.0;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = 0.0d0
end function
public static double code(double a, double b_2, double c) {
return 0.0;
}
def code(a, b_2, c): return 0.0
function code(a, b_2, c) return 0.0 end
function tmp = code(a, b_2, c) tmp = 0.0; end
code[a_, b$95$2_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 50.3%
div-sub50.1%
neg-mul-150.1%
*-un-lft-identity50.1%
times-frac50.1%
metadata-eval50.1%
add-sqr-sqrt36.0%
sqrt-prod48.4%
sqr-neg48.4%
sqrt-unprod12.8%
add-sqr-sqrt31.8%
fma-neg31.8%
add-sqr-sqrt12.8%
sqrt-unprod48.4%
sqr-neg48.4%
sqrt-prod36.0%
add-sqr-sqrt50.1%
Applied egg-rr52.0%
fma-neg52.0%
associate-*r/52.0%
mul-1-neg52.0%
distribute-rgt-neg-out52.0%
distribute-lft-neg-in52.0%
*-commutative52.0%
Simplified52.0%
Taylor expanded in b_2 around -inf 0.0%
mul-1-neg0.0%
distribute-frac-neg0.0%
+-commutative0.0%
distribute-frac-neg0.0%
unsub-neg0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt6.5%
neg-mul-16.5%
Simplified6.5%
Taylor expanded in a around 0 9.6%
distribute-rgt1-in9.6%
metadata-eval9.6%
associate-*r/6.4%
mul0-lft9.6%
Simplified9.6%
Final simplification9.6%
herbie shell --seed 2023271
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))