
(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 6 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 -6.8e-59)
(* -0.5 (/ c b_2))
(if (<= b_2 5e+82)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
(/ (+ b_2 (+ b_2 (* -0.5 (/ a (/ b_2 c))))) (- a)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6.8e-59) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 5e+82) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (b_2 + (b_2 + (-0.5 * (a / (b_2 / c))))) / -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 <= (-6.8d-59)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 5d+82) then
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a
else
tmp = (b_2 + (b_2 + ((-0.5d0) * (a / (b_2 / c))))) / -a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6.8e-59) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 5e+82) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (b_2 + (b_2 + (-0.5 * (a / (b_2 / c))))) / -a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -6.8e-59: tmp = -0.5 * (c / b_2) elif b_2 <= 5e+82: tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (c * a)))) / a else: tmp = (b_2 + (b_2 + (-0.5 * (a / (b_2 / c))))) / -a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -6.8e-59) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 5e+82) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a)))) / a); else tmp = Float64(Float64(b_2 + Float64(b_2 + Float64(-0.5 * Float64(a / Float64(b_2 / c))))) / Float64(-a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -6.8e-59) tmp = -0.5 * (c / b_2); elseif (b_2 <= 5e+82) tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a; else tmp = (b_2 + (b_2 + (-0.5 * (a / (b_2 / c))))) / -a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -6.8e-59], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 5e+82], 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[(b$95$2 + N[(b$95$2 + N[(-0.5 * N[(a / N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-a)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -6.8 \cdot 10^{-59}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 5 \cdot 10^{+82}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b_2 + \left(b_2 + -0.5 \cdot \frac{a}{\frac{b_2}{c}}\right)}{-a}\\
\end{array}
\end{array}
if b_2 < -6.80000000000000035e-59Initial program 16.6%
sub-neg16.6%
sqr-neg16.6%
distribute-neg-out16.6%
neg-mul-116.6%
*-commutative16.6%
associate-/l*16.6%
remove-double-neg16.6%
neg-mul-116.6%
*-commutative16.6%
associate-/l*16.6%
metadata-eval16.6%
/-rgt-identity16.6%
Simplified16.6%
Taylor expanded in b_2 around -inf 84.7%
if -6.80000000000000035e-59 < b_2 < 5.00000000000000015e82Initial program 77.8%
if 5.00000000000000015e82 < b_2 Initial program 62.2%
sub-neg62.2%
sqr-neg62.2%
distribute-neg-out62.2%
neg-mul-162.2%
*-commutative62.2%
associate-/l*62.2%
remove-double-neg62.2%
neg-mul-162.2%
*-commutative62.2%
associate-/l*62.2%
metadata-eval62.2%
/-rgt-identity62.2%
Simplified62.2%
Taylor expanded in a around 0 93.8%
associate-/l*99.1%
Simplified99.1%
Final simplification85.6%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -1.55e-55)
(* -0.5 (/ c b_2))
(if (<= b_2 9.4e-57)
(/ (+ b_2 (sqrt (* a (- c)))) (- 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 <= -1.55e-55) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 9.4e-57) {
tmp = (b_2 + sqrt((a * -c))) / -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 <= (-1.55d-55)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 9.4d-57) then
tmp = (b_2 + sqrt((a * -c))) / -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 <= -1.55e-55) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 9.4e-57) {
tmp = (b_2 + Math.sqrt((a * -c))) / -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 <= -1.55e-55: tmp = -0.5 * (c / b_2) elif b_2 <= 9.4e-57: tmp = (b_2 + math.sqrt((a * -c))) / -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 <= -1.55e-55) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 9.4e-57) tmp = Float64(Float64(b_2 + sqrt(Float64(a * Float64(-c)))) / Float64(-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 <= -1.55e-55) tmp = -0.5 * (c / b_2); elseif (b_2 <= 9.4e-57) tmp = (b_2 + sqrt((a * -c))) / -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, -1.55e-55], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 9.4e-57], N[(N[(b$95$2 + N[Sqrt[N[(a * (-c)), $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 -1.55 \cdot 10^{-55}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 9.4 \cdot 10^{-57}:\\
\;\;\;\;\frac{b_2 + \sqrt{a \cdot \left(-c\right)}}{-a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c}{b_2} \cdot 0.5\\
\end{array}
\end{array}
if b_2 < -1.54999999999999998e-55Initial program 16.6%
sub-neg16.6%
sqr-neg16.6%
distribute-neg-out16.6%
neg-mul-116.6%
*-commutative16.6%
associate-/l*16.6%
remove-double-neg16.6%
neg-mul-116.6%
*-commutative16.6%
associate-/l*16.6%
metadata-eval16.6%
/-rgt-identity16.6%
Simplified16.6%
Taylor expanded in b_2 around -inf 84.7%
if -1.54999999999999998e-55 < b_2 < 9.3999999999999996e-57Initial program 74.8%
sub-neg74.8%
sqr-neg74.8%
distribute-neg-out74.8%
neg-mul-174.8%
*-commutative74.8%
associate-/l*74.8%
remove-double-neg74.8%
neg-mul-174.8%
*-commutative74.8%
associate-/l*74.8%
metadata-eval74.8%
/-rgt-identity74.8%
Simplified74.8%
Taylor expanded in a around inf 70.3%
mul-1-neg70.3%
Simplified70.3%
if 9.3999999999999996e-57 < b_2 Initial program 69.2%
sub-neg69.2%
sqr-neg69.2%
distribute-neg-out69.2%
neg-mul-169.2%
*-commutative69.2%
associate-/l*69.2%
remove-double-neg69.2%
neg-mul-169.2%
*-commutative69.2%
associate-/l*69.2%
metadata-eval69.2%
/-rgt-identity69.2%
Simplified69.2%
Taylor expanded in b_2 around inf 90.7%
Final simplification82.8%
(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 30.7%
sub-neg30.7%
sqr-neg30.7%
distribute-neg-out30.7%
neg-mul-130.7%
*-commutative30.7%
associate-/l*30.7%
remove-double-neg30.7%
neg-mul-130.7%
*-commutative30.7%
associate-/l*30.7%
metadata-eval30.7%
/-rgt-identity30.7%
Simplified30.7%
Taylor expanded in b_2 around -inf 66.5%
if -4.999999999999985e-310 < b_2 Initial program 73.7%
sub-neg73.7%
sqr-neg73.7%
distribute-neg-out73.7%
neg-mul-173.7%
*-commutative73.7%
associate-/l*73.7%
remove-double-neg73.7%
neg-mul-173.7%
*-commutative73.7%
associate-/l*73.7%
metadata-eval73.7%
/-rgt-identity73.7%
Simplified73.8%
Taylor expanded in b_2 around inf 71.1%
Final simplification68.7%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1e-285) (* -0.5 (/ c b_2)) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-285) {
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 <= (-1d-285)) 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 <= -1e-285) {
tmp = -0.5 * (c / b_2);
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1e-285: 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 <= -1e-285) tmp = Float64(-0.5 * Float64(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 <= -1e-285) 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, -1e-285], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1 \cdot 10^{-285}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\
\end{array}
\end{array}
if b_2 < -1.00000000000000007e-285Initial program 28.4%
sub-neg28.4%
sqr-neg28.4%
distribute-neg-out28.4%
neg-mul-128.4%
*-commutative28.4%
associate-/l*28.4%
remove-double-neg28.4%
neg-mul-128.4%
*-commutative28.4%
associate-/l*28.4%
metadata-eval28.4%
/-rgt-identity28.4%
Simplified28.4%
Taylor expanded in b_2 around -inf 70.0%
if -1.00000000000000007e-285 < b_2 Initial program 73.6%
sub-neg73.6%
sqr-neg73.6%
distribute-neg-out73.6%
neg-mul-173.6%
*-commutative73.6%
associate-/l*73.6%
remove-double-neg73.6%
neg-mul-173.6%
*-commutative73.6%
associate-/l*73.6%
metadata-eval73.6%
/-rgt-identity73.6%
Simplified73.7%
Taylor expanded in a around inf 44.8%
mul-1-neg44.8%
Simplified44.8%
Taylor expanded in b_2 around inf 31.8%
Final simplification50.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1e-285) (* -0.5 (/ c b_2)) (/ (* b_2 -2.0) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-285) {
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 <= (-1d-285)) 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 <= -1e-285) {
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 <= -1e-285: 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 <= -1e-285) tmp = Float64(-0.5 * Float64(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 <= -1e-285) 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, -1e-285], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1 \cdot 10^{-285}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\end{array}
\end{array}
if b_2 < -1.00000000000000007e-285Initial program 28.4%
sub-neg28.4%
sqr-neg28.4%
distribute-neg-out28.4%
neg-mul-128.4%
*-commutative28.4%
associate-/l*28.4%
remove-double-neg28.4%
neg-mul-128.4%
*-commutative28.4%
associate-/l*28.4%
metadata-eval28.4%
/-rgt-identity28.4%
Simplified28.4%
Taylor expanded in b_2 around -inf 70.0%
if -1.00000000000000007e-285 < b_2 Initial program 73.6%
sub-neg73.6%
sqr-neg73.6%
distribute-neg-out73.6%
neg-mul-173.6%
*-commutative73.6%
associate-/l*73.6%
remove-double-neg73.6%
neg-mul-173.6%
*-commutative73.6%
associate-/l*73.6%
metadata-eval73.6%
/-rgt-identity73.6%
Simplified73.7%
Taylor expanded in b_2 around inf 66.4%
associate-*r/66.4%
*-commutative66.4%
Simplified66.4%
Final simplification68.2%
(FPCore (a b_2 c) :precision binary64 (/ (- b_2) a))
double code(double a, double b_2, double c) {
return -b_2 / 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 / a
end function
public static double code(double a, double b_2, double c) {
return -b_2 / a;
}
def code(a, b_2, c): return -b_2 / a
function code(a, b_2, c) return Float64(Float64(-b_2) / a) end
function tmp = code(a, b_2, c) tmp = -b_2 / a; end
code[a_, b$95$2_, c_] := N[((-b$95$2) / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{-b_2}{a}
\end{array}
Initial program 51.0%
sub-neg51.0%
sqr-neg51.0%
distribute-neg-out51.0%
neg-mul-151.0%
*-commutative51.0%
associate-/l*51.0%
remove-double-neg51.0%
neg-mul-151.0%
*-commutative51.0%
associate-/l*51.0%
metadata-eval51.0%
/-rgt-identity51.0%
Simplified51.0%
Taylor expanded in a around inf 34.4%
mul-1-neg34.4%
Simplified34.4%
Taylor expanded in b_2 around inf 17.3%
Final simplification17.3%
(FPCore (a b_2 c)
:precision binary64
(let* ((t_0 (* (sqrt (fabs a)) (sqrt (fabs c))))
(t_1
(if (== (copysign a c) a)
(* (sqrt (- (fabs b_2) t_0)) (sqrt (+ (fabs b_2) t_0)))
(hypot b_2 t_0))))
(if (< b_2 0.0) (/ c (- t_1 b_2)) (/ (+ b_2 t_1) (- a)))))
double code(double a, double b_2, double c) {
double t_0 = sqrt(fabs(a)) * sqrt(fabs(c));
double tmp;
if (copysign(a, c) == a) {
tmp = sqrt((fabs(b_2) - t_0)) * sqrt((fabs(b_2) + t_0));
} else {
tmp = hypot(b_2, t_0);
}
double t_1 = tmp;
double tmp_1;
if (b_2 < 0.0) {
tmp_1 = c / (t_1 - b_2);
} else {
tmp_1 = (b_2 + t_1) / -a;
}
return tmp_1;
}
public static double code(double a, double b_2, double c) {
double t_0 = Math.sqrt(Math.abs(a)) * Math.sqrt(Math.abs(c));
double tmp;
if (Math.copySign(a, c) == a) {
tmp = Math.sqrt((Math.abs(b_2) - t_0)) * Math.sqrt((Math.abs(b_2) + t_0));
} else {
tmp = Math.hypot(b_2, t_0);
}
double t_1 = tmp;
double tmp_1;
if (b_2 < 0.0) {
tmp_1 = c / (t_1 - b_2);
} else {
tmp_1 = (b_2 + t_1) / -a;
}
return tmp_1;
}
def code(a, b_2, c): t_0 = math.sqrt(math.fabs(a)) * math.sqrt(math.fabs(c)) tmp = 0 if math.copysign(a, c) == a: tmp = math.sqrt((math.fabs(b_2) - t_0)) * math.sqrt((math.fabs(b_2) + t_0)) else: tmp = math.hypot(b_2, t_0) t_1 = tmp tmp_1 = 0 if b_2 < 0.0: tmp_1 = c / (t_1 - b_2) else: tmp_1 = (b_2 + t_1) / -a return tmp_1
function code(a, b_2, c) t_0 = Float64(sqrt(abs(a)) * sqrt(abs(c))) tmp = 0.0 if (copysign(a, c) == a) tmp = Float64(sqrt(Float64(abs(b_2) - t_0)) * sqrt(Float64(abs(b_2) + t_0))); else tmp = hypot(b_2, t_0); end t_1 = tmp tmp_1 = 0.0 if (b_2 < 0.0) tmp_1 = Float64(c / Float64(t_1 - b_2)); else tmp_1 = Float64(Float64(b_2 + t_1) / Float64(-a)); end return tmp_1 end
function tmp_3 = code(a, b_2, c) t_0 = sqrt(abs(a)) * sqrt(abs(c)); tmp = 0.0; if ((sign(c) * abs(a)) == a) tmp = sqrt((abs(b_2) - t_0)) * sqrt((abs(b_2) + t_0)); else tmp = hypot(b_2, t_0); end t_1 = tmp; tmp_2 = 0.0; if (b_2 < 0.0) tmp_2 = c / (t_1 - b_2); else tmp_2 = (b_2 + t_1) / -a; end tmp_3 = tmp_2; end
code[a_, b$95$2_, c_] := Block[{t$95$0 = N[(N[Sqrt[N[Abs[a], $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Abs[c], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = If[Equal[N[With[{TMP1 = Abs[a], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], a], N[(N[Sqrt[N[(N[Abs[b$95$2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(N[Abs[b$95$2], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[b$95$2 ^ 2 + t$95$0 ^ 2], $MachinePrecision]]}, If[Less[b$95$2, 0.0], N[(c / N[(t$95$1 - b$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(b$95$2 + t$95$1), $MachinePrecision] / (-a)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\left|a\right|} \cdot \sqrt{\left|c\right|}\\
t_1 := \begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(a, c\right) = a:\\
\;\;\;\;\sqrt{\left|b_2\right| - t_0} \cdot \sqrt{\left|b_2\right| + t_0}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(b_2, t_0\right)\\
\end{array}\\
\mathbf{if}\;b_2 < 0:\\
\;\;\;\;\frac{c}{t_1 - b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b_2 + t_1}{-a}\\
\end{array}
\end{array}
herbie shell --seed 2023301
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
:herbie-expected 10
:herbie-target
(if (< b_2 0.0) (/ c (- (if (== (copysign a c) a) (* (sqrt (- (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot b_2 (* (sqrt (fabs a)) (sqrt (fabs c))))) b_2)) (/ (+ b_2 (if (== (copysign a c) a) (* (sqrt (- (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot b_2 (* (sqrt (fabs a)) (sqrt (fabs c)))))) (- a)))
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))