
(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 10 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
(let* ((t_0 (sqrt (- (* b_2 b_2) (* c a)))))
(if (<= b_2 -3.8e+114)
(/ (* -0.5 c) b_2)
(if (<= b_2 -1.7e-130)
(/ (/ (* c a) (fma -1.0 b_2 t_0)) a)
(if (<= b_2 1.2e+77)
(- (/ (- b_2) a) (/ t_0 a))
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))))
double code(double a, double b_2, double c) {
double t_0 = sqrt(((b_2 * b_2) - (c * a)));
double tmp;
if (b_2 <= -3.8e+114) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= -1.7e-130) {
tmp = ((c * a) / fma(-1.0, b_2, t_0)) / a;
} else if (b_2 <= 1.2e+77) {
tmp = (-b_2 / a) - (t_0 / a);
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
function code(a, b_2, c) t_0 = sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a))) tmp = 0.0 if (b_2 <= -3.8e+114) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= -1.7e-130) tmp = Float64(Float64(Float64(c * a) / fma(-1.0, b_2, t_0)) / a); elseif (b_2 <= 1.2e+77) tmp = Float64(Float64(Float64(-b_2) / a) - Float64(t_0 / a)); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
code[a_, b$95$2_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b$95$2, -3.8e+114], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, -1.7e-130], N[(N[(N[(c * a), $MachinePrecision] / N[(-1.0 * b$95$2 + t$95$0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 1.2e+77], N[(N[((-b$95$2) / a), $MachinePrecision] - N[(t$95$0 / a), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b_2 \cdot b_2 - c \cdot a}\\
\mathbf{if}\;b_2 \leq -3.8 \cdot 10^{+114}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq -1.7 \cdot 10^{-130}:\\
\;\;\;\;\frac{\frac{c \cdot a}{\mathsf{fma}\left(-1, b_2, t_0\right)}}{a}\\
\mathbf{elif}\;b_2 \leq 1.2 \cdot 10^{+77}:\\
\;\;\;\;\frac{-b_2}{a} - \frac{t_0}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -3.8000000000000001e114Initial program 4.0%
Taylor expanded in b_2 around -inf 98.1%
associate-*r/98.1%
Simplified98.1%
if -3.8000000000000001e114 < b_2 < -1.70000000000000003e-130Initial program 40.3%
sub-neg40.3%
+-commutative40.3%
*-commutative40.3%
distribute-lft-neg-in40.3%
fma-def40.3%
Applied egg-rr40.3%
flip--39.9%
pow239.9%
add-sqr-sqrt40.3%
neg-mul-140.3%
fma-def40.3%
Applied egg-rr40.3%
unpow240.3%
fma-udef40.3%
distribute-lft-neg-out40.3%
distribute-rgt-neg-out40.3%
+-commutative40.3%
distribute-rgt-neg-out40.3%
sub-neg40.3%
associate--r-82.2%
unpow282.2%
sqr-neg82.2%
unpow282.2%
+-inverses82.2%
unpow282.2%
fma-udef82.2%
distribute-lft-neg-out82.2%
distribute-rgt-neg-out82.2%
+-commutative82.2%
distribute-rgt-neg-out82.2%
sub-neg82.2%
unpow282.2%
Simplified82.2%
if -1.70000000000000003e-130 < b_2 < 1.1999999999999999e77Initial program 83.9%
add-sqr-sqrt83.6%
pow283.6%
pow1/283.6%
sqrt-pow183.6%
metadata-eval83.6%
Applied egg-rr83.6%
div-sub83.6%
pow-pow83.9%
metadata-eval83.9%
pow1/283.9%
cancel-sign-sub-inv83.9%
*-commutative83.9%
add-sqr-sqrt73.8%
hypot-udef75.6%
Applied egg-rr75.6%
hypot-udef73.8%
add-sqr-sqrt83.9%
*-commutative83.9%
cancel-sign-sub-inv83.9%
pow1/283.9%
*-commutative83.9%
Applied egg-rr83.9%
sqr-pow83.6%
metadata-eval83.6%
metadata-eval83.6%
Applied egg-rr83.6%
pow-sqr83.9%
metadata-eval83.9%
unpow1/283.9%
Simplified83.9%
if 1.1999999999999999e77 < b_2 Initial program 58.0%
Taylor expanded in b_2 around inf 95.7%
Final simplification89.3%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -1e-51)
(/ 1.0 (+ (* 0.5 (/ a b_2)) (* -2.0 (/ b_2 c))))
(if (<= b_2 1.3e+77)
(- (/ (- b_2) a) (/ (sqrt (- (* b_2 b_2) (* c a))) a))
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-51) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} else if (b_2 <= 1.3e+77) {
tmp = (-b_2 / a) - (sqrt(((b_2 * b_2) - (c * a))) / a);
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
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 <= (-1d-51)) then
tmp = 1.0d0 / ((0.5d0 * (a / b_2)) + ((-2.0d0) * (b_2 / c)))
else if (b_2 <= 1.3d+77) then
tmp = (-b_2 / a) - (sqrt(((b_2 * b_2) - (c * a))) / a)
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-51) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} else if (b_2 <= 1.3e+77) {
tmp = (-b_2 / a) - (Math.sqrt(((b_2 * b_2) - (c * a))) / a);
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1e-51: tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))) elif b_2 <= 1.3e+77: tmp = (-b_2 / a) - (math.sqrt(((b_2 * b_2) - (c * a))) / a) else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1e-51) tmp = Float64(1.0 / Float64(Float64(0.5 * Float64(a / b_2)) + Float64(-2.0 * Float64(b_2 / c)))); elseif (b_2 <= 1.3e+77) 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(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1e-51) tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))); elseif (b_2 <= 1.3e+77) tmp = (-b_2 / a) - (sqrt(((b_2 * b_2) - (c * a))) / a); else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1e-51], N[(1.0 / N[(N[(0.5 * N[(a / b$95$2), $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1.3e+77], 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[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1 \cdot 10^{-51}:\\
\;\;\;\;\frac{1}{0.5 \cdot \frac{a}{b_2} + -2 \cdot \frac{b_2}{c}}\\
\mathbf{elif}\;b_2 \leq 1.3 \cdot 10^{+77}:\\
\;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -1e-51Initial program 19.9%
sub-neg19.9%
+-commutative19.9%
*-commutative19.9%
distribute-lft-neg-in19.9%
fma-def19.9%
Applied egg-rr19.9%
clear-num19.9%
inv-pow19.9%
Applied egg-rr19.9%
unpow-119.9%
unpow219.9%
fma-udef19.8%
distribute-lft-neg-out19.8%
distribute-rgt-neg-out19.8%
+-commutative19.8%
distribute-rgt-neg-out19.8%
sub-neg19.8%
unpow219.8%
Simplified19.8%
Taylor expanded in b_2 around -inf 88.0%
if -1e-51 < b_2 < 1.3000000000000001e77Initial program 80.9%
add-sqr-sqrt80.6%
pow280.6%
pow1/280.6%
sqrt-pow180.6%
metadata-eval80.6%
Applied egg-rr80.6%
div-sub80.6%
pow-pow81.0%
metadata-eval81.0%
pow1/281.0%
cancel-sign-sub-inv81.0%
*-commutative81.0%
add-sqr-sqrt71.3%
hypot-udef72.8%
Applied egg-rr72.8%
hypot-udef71.3%
add-sqr-sqrt81.0%
*-commutative81.0%
cancel-sign-sub-inv81.0%
pow1/281.0%
*-commutative81.0%
Applied egg-rr81.0%
sqr-pow80.6%
metadata-eval80.6%
metadata-eval80.6%
Applied egg-rr80.6%
pow-sqr81.0%
metadata-eval81.0%
unpow1/281.0%
Simplified81.0%
if 1.3000000000000001e77 < b_2 Initial program 58.0%
Taylor expanded in b_2 around inf 95.7%
Final simplification87.3%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -8e-53)
(/ 1.0 (+ (* 0.5 (/ a b_2)) (* -2.0 (/ b_2 c))))
(if (<= b_2 1.45e+77)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -8e-53) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} else if (b_2 <= 1.45e+77) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
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 <= (-8d-53)) then
tmp = 1.0d0 / ((0.5d0 * (a / b_2)) + ((-2.0d0) * (b_2 / c)))
else if (b_2 <= 1.45d+77) then
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -8e-53) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} else if (b_2 <= 1.45e+77) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -8e-53: tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))) elif b_2 <= 1.45e+77: tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (c * a)))) / a else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -8e-53) tmp = Float64(1.0 / Float64(Float64(0.5 * Float64(a / b_2)) + Float64(-2.0 * Float64(b_2 / c)))); elseif (b_2 <= 1.45e+77) 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(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -8e-53) tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))); elseif (b_2 <= 1.45e+77) tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -8e-53], N[(1.0 / N[(N[(0.5 * N[(a / b$95$2), $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1.45e+77], 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[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -8 \cdot 10^{-53}:\\
\;\;\;\;\frac{1}{0.5 \cdot \frac{a}{b_2} + -2 \cdot \frac{b_2}{c}}\\
\mathbf{elif}\;b_2 \leq 1.45 \cdot 10^{+77}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -8.00000000000000025e-53Initial program 19.9%
sub-neg19.9%
+-commutative19.9%
*-commutative19.9%
distribute-lft-neg-in19.9%
fma-def19.9%
Applied egg-rr19.9%
clear-num19.9%
inv-pow19.9%
Applied egg-rr19.9%
unpow-119.9%
unpow219.9%
fma-udef19.8%
distribute-lft-neg-out19.8%
distribute-rgt-neg-out19.8%
+-commutative19.8%
distribute-rgt-neg-out19.8%
sub-neg19.8%
unpow219.8%
Simplified19.8%
Taylor expanded in b_2 around -inf 88.0%
if -8.00000000000000025e-53 < b_2 < 1.4500000000000001e77Initial program 80.9%
if 1.4500000000000001e77 < b_2 Initial program 58.0%
Taylor expanded in b_2 around inf 95.7%
Final simplification87.3%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -8.8e-120)
(/ 1.0 (+ (* 0.5 (/ a b_2)) (* -2.0 (/ b_2 c))))
(if (<= b_2 1.35e-31)
(/ (- (- b_2) (sqrt (* c (- a)))) a)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -8.8e-120) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} else if (b_2 <= 1.35e-31) {
tmp = (-b_2 - sqrt((c * -a))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
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.8d-120)) then
tmp = 1.0d0 / ((0.5d0 * (a / b_2)) + ((-2.0d0) * (b_2 / c)))
else if (b_2 <= 1.35d-31) then
tmp = (-b_2 - sqrt((c * -a))) / a
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -8.8e-120) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} else if (b_2 <= 1.35e-31) {
tmp = (-b_2 - Math.sqrt((c * -a))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -8.8e-120: tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))) elif b_2 <= 1.35e-31: tmp = (-b_2 - math.sqrt((c * -a))) / a else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -8.8e-120) tmp = Float64(1.0 / Float64(Float64(0.5 * Float64(a / b_2)) + Float64(-2.0 * Float64(b_2 / c)))); elseif (b_2 <= 1.35e-31) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(c * Float64(-a)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -8.8e-120) tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))); elseif (b_2 <= 1.35e-31) tmp = (-b_2 - sqrt((c * -a))) / a; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -8.8e-120], N[(1.0 / N[(N[(0.5 * N[(a / b$95$2), $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1.35e-31], 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[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -8.8 \cdot 10^{-120}:\\
\;\;\;\;\frac{1}{0.5 \cdot \frac{a}{b_2} + -2 \cdot \frac{b_2}{c}}\\
\mathbf{elif}\;b_2 \leq 1.35 \cdot 10^{-31}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{c \cdot \left(-a\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -8.8000000000000005e-120Initial program 22.7%
sub-neg22.7%
+-commutative22.7%
*-commutative22.7%
distribute-lft-neg-in22.7%
fma-def22.7%
Applied egg-rr22.7%
clear-num22.7%
inv-pow22.7%
Applied egg-rr22.7%
unpow-122.7%
unpow222.7%
fma-udef22.6%
distribute-lft-neg-out22.6%
distribute-rgt-neg-out22.6%
+-commutative22.6%
distribute-rgt-neg-out22.6%
sub-neg22.6%
unpow222.6%
Simplified22.6%
Taylor expanded in b_2 around -inf 84.5%
if -8.8000000000000005e-120 < b_2 < 1.35000000000000007e-31Initial program 78.9%
Taylor expanded in b_2 around 0 75.3%
mul-1-neg75.3%
distribute-rgt-neg-out75.3%
Simplified75.3%
if 1.35000000000000007e-31 < b_2 Initial program 68.8%
Taylor expanded in b_2 around inf 90.0%
Final simplification84.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-312) (/ 1.0 (+ (* 0.5 (/ a b_2)) (* -2.0 (/ b_2 c)))) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-312) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
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-312)) then
tmp = 1.0d0 / ((0.5d0 * (a / b_2)) + ((-2.0d0) * (b_2 / c)))
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-312) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-312: tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))) else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-312) tmp = Float64(1.0 / Float64(Float64(0.5 * Float64(a / b_2)) + Float64(-2.0 * Float64(b_2 / c)))); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e-312) tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))); else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-312], N[(1.0 / N[(N[(0.5 * N[(a / b$95$2), $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-312}:\\
\;\;\;\;\frac{1}{0.5 \cdot \frac{a}{b_2} + -2 \cdot \frac{b_2}{c}}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -5.0000000000022e-312Initial program 35.7%
sub-neg35.7%
+-commutative35.7%
*-commutative35.7%
distribute-lft-neg-in35.7%
fma-def35.7%
Applied egg-rr35.7%
clear-num35.7%
inv-pow35.7%
Applied egg-rr35.7%
unpow-135.7%
unpow235.7%
fma-udef35.7%
distribute-lft-neg-out35.7%
distribute-rgt-neg-out35.7%
+-commutative35.7%
distribute-rgt-neg-out35.7%
sub-neg35.7%
unpow235.7%
Simplified35.7%
Taylor expanded in b_2 around -inf 69.3%
if -5.0000000000022e-312 < b_2 Initial program 70.8%
Taylor expanded in b_2 around inf 69.5%
Final simplification69.4%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-312) (/ (* -0.5 c) b_2) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-312) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
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-312)) then
tmp = ((-0.5d0) * c) / b_2
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-312) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-312: tmp = (-0.5 * c) / b_2 else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-312) tmp = Float64(Float64(-0.5 * c) / b_2); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e-312) tmp = (-0.5 * c) / b_2; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-312], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-312}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -5.0000000000022e-312Initial program 35.7%
Taylor expanded in b_2 around -inf 68.4%
associate-*r/68.4%
Simplified68.4%
if -5.0000000000022e-312 < b_2 Initial program 70.8%
Taylor expanded in b_2 around inf 69.5%
Final simplification68.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.8e-308) (/ (* -0.5 c) b_2) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.8e-308) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = -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.8d-308)) then
tmp = ((-0.5d0) * c) / b_2
else
tmp = -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.8e-308) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.8e-308: tmp = (-0.5 * c) / b_2 else: tmp = -b_2 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.8e-308) tmp = Float64(Float64(-0.5 * c) / b_2); else tmp = Float64(Float64(-b_2) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.8e-308) tmp = (-0.5 * c) / b_2; else tmp = -b_2 / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.8e-308], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.8 \cdot 10^{-308}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\
\end{array}
\end{array}
if b_2 < -1.7999999999999999e-308Initial program 35.7%
Taylor expanded in b_2 around -inf 68.4%
associate-*r/68.4%
Simplified68.4%
if -1.7999999999999999e-308 < b_2 Initial program 70.8%
add-sqr-sqrt70.6%
pow270.6%
pow1/270.6%
sqrt-pow170.6%
metadata-eval70.6%
Applied egg-rr70.6%
Taylor expanded in b_2 around inf 27.9%
mul-1-neg27.9%
distribute-frac-neg27.9%
Simplified27.9%
Final simplification48.3%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-312) (/ (* -0.5 c) b_2) (/ (* b_2 -2.0) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-312) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = (b_2 * -2.0) / 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-312)) then
tmp = ((-0.5d0) * c) / b_2
else
tmp = (b_2 * (-2.0d0)) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-312) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = (b_2 * -2.0) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-312: tmp = (-0.5 * c) / b_2 else: tmp = (b_2 * -2.0) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-312) tmp = Float64(Float64(-0.5 * c) / b_2); else tmp = Float64(Float64(b_2 * -2.0) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e-312) tmp = (-0.5 * c) / b_2; else tmp = (b_2 * -2.0) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-312], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-312}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\end{array}
\end{array}
if b_2 < -5.0000000000022e-312Initial program 35.7%
Taylor expanded in b_2 around -inf 68.4%
associate-*r/68.4%
Simplified68.4%
if -5.0000000000022e-312 < b_2 Initial program 70.8%
Taylor expanded in b_2 around inf 69.4%
*-commutative69.4%
Simplified69.4%
Final simplification68.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -7e-8) (/ 0.0 a) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -7e-8) {
tmp = 0.0 / a;
} else {
tmp = -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 <= (-7d-8)) then
tmp = 0.0d0 / a
else
tmp = -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 <= -7e-8) {
tmp = 0.0 / a;
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -7e-8: tmp = 0.0 / a else: tmp = -b_2 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -7e-8) tmp = Float64(0.0 / a); else tmp = Float64(Float64(-b_2) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -7e-8) tmp = 0.0 / a; else tmp = -b_2 / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -7e-8], N[(0.0 / a), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -7 \cdot 10^{-8}:\\
\;\;\;\;\frac{0}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\
\end{array}
\end{array}
if b_2 < -7.00000000000000048e-8Initial program 16.0%
add-sqr-sqrt12.6%
pow212.6%
pow1/212.6%
sqrt-pow112.7%
metadata-eval12.7%
Applied egg-rr12.7%
Taylor expanded in b_2 around -inf 45.0%
distribute-lft1-in45.0%
metadata-eval45.0%
mul0-lft45.0%
Simplified45.0%
if -7.00000000000000048e-8 < b_2 Initial program 68.7%
add-sqr-sqrt68.5%
pow268.5%
pow1/268.5%
sqrt-pow168.5%
metadata-eval68.5%
Applied egg-rr68.5%
Taylor expanded in b_2 around inf 20.8%
mul-1-neg20.8%
distribute-frac-neg20.8%
Simplified20.8%
Final simplification28.0%
(FPCore (a b_2 c) :precision binary64 (/ 0.0 a))
double code(double a, double b_2, double c) {
return 0.0 / 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 = 0.0d0 / a
end function
public static double code(double a, double b_2, double c) {
return 0.0 / a;
}
def code(a, b_2, c): return 0.0 / a
function code(a, b_2, c) return Float64(0.0 / a) end
function tmp = code(a, b_2, c) tmp = 0.0 / a; end
code[a_, b$95$2_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{0}{a}
\end{array}
Initial program 53.1%
add-sqr-sqrt51.9%
pow251.9%
pow1/251.9%
sqrt-pow151.9%
metadata-eval51.9%
Applied egg-rr51.9%
Taylor expanded in b_2 around -inf 15.4%
distribute-lft1-in15.4%
metadata-eval15.4%
mul0-lft15.4%
Simplified15.4%
Final simplification15.4%
herbie shell --seed 2023238
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))