
(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
(let* ((t_0 (sqrt (- (* b_2 b_2) (* c a)))))
(if (<= b_2 -2.3e+48)
(* -0.5 (/ c b_2))
(if (<= b_2 -2e-110)
(/ (/ (* c (- a)) (- b_2 t_0)) a)
(if (<= b_2 8.5e+72)
(/ (- (- b_2) t_0) a)
(+ (* -2.0 (/ b_2 a)) (* (/ c b_2) 0.5)))))))
double code(double a, double b_2, double c) {
double t_0 = sqrt(((b_2 * b_2) - (c * a)));
double tmp;
if (b_2 <= -2.3e+48) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= -2e-110) {
tmp = ((c * -a) / (b_2 - t_0)) / a;
} else if (b_2 <= 8.5e+72) {
tmp = (-b_2 - t_0) / 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) :: t_0
real(8) :: tmp
t_0 = sqrt(((b_2 * b_2) - (c * a)))
if (b_2 <= (-2.3d+48)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= (-2d-110)) then
tmp = ((c * -a) / (b_2 - t_0)) / a
else if (b_2 <= 8.5d+72) then
tmp = (-b_2 - t_0) / 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 t_0 = Math.sqrt(((b_2 * b_2) - (c * a)));
double tmp;
if (b_2 <= -2.3e+48) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= -2e-110) {
tmp = ((c * -a) / (b_2 - t_0)) / a;
} else if (b_2 <= 8.5e+72) {
tmp = (-b_2 - t_0) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5);
}
return tmp;
}
def code(a, b_2, c): t_0 = math.sqrt(((b_2 * b_2) - (c * a))) tmp = 0 if b_2 <= -2.3e+48: tmp = -0.5 * (c / b_2) elif b_2 <= -2e-110: tmp = ((c * -a) / (b_2 - t_0)) / a elif b_2 <= 8.5e+72: tmp = (-b_2 - t_0) / a else: tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5) 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 <= -2.3e+48) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= -2e-110) tmp = Float64(Float64(Float64(c * Float64(-a)) / Float64(b_2 - t_0)) / a); elseif (b_2 <= 8.5e+72) tmp = Float64(Float64(Float64(-b_2) - t_0) / 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) t_0 = sqrt(((b_2 * b_2) - (c * a))); tmp = 0.0; if (b_2 <= -2.3e+48) tmp = -0.5 * (c / b_2); elseif (b_2 <= -2e-110) tmp = ((c * -a) / (b_2 - t_0)) / a; elseif (b_2 <= 8.5e+72) tmp = (-b_2 - t_0) / a; else tmp = (-2.0 * (b_2 / a)) + ((c / b_2) * 0.5); end tmp_2 = 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, -2.3e+48], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, -2e-110], N[(N[(N[(c * (-a)), $MachinePrecision] / N[(b$95$2 - t$95$0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 8.5e+72], N[(N[((-b$95$2) - t$95$0), $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}
t_0 := \sqrt{b_2 \cdot b_2 - c \cdot a}\\
\mathbf{if}\;b_2 \leq -2.3 \cdot 10^{+48}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq -2 \cdot 10^{-110}:\\
\;\;\;\;\frac{\frac{c \cdot \left(-a\right)}{b_2 - t_0}}{a}\\
\mathbf{elif}\;b_2 \leq 8.5 \cdot 10^{+72}:\\
\;\;\;\;\frac{\left(-b_2\right) - t_0}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{c}{b_2} \cdot 0.5\\
\end{array}
\end{array}
if b_2 < -2.3e48Initial program 12.2%
Taylor expanded in b_2 around -inf 96.4%
if -2.3e48 < b_2 < -2.0000000000000001e-110Initial program 36.6%
add-sqr-sqrt36.4%
pow236.4%
pow1/236.4%
sqrt-pow136.5%
metadata-eval36.5%
Applied egg-rr36.5%
flip--36.4%
frac-2neg36.4%
Applied egg-rr36.6%
unpow236.6%
unpow236.6%
associate--r-87.4%
+-inverses87.4%
distribute-neg-in87.4%
metadata-eval87.4%
distribute-rgt-neg-in87.4%
Simplified87.4%
if -2.0000000000000001e-110 < b_2 < 8.5000000000000004e72Initial program 85.4%
if 8.5000000000000004e72 < b_2 Initial program 64.4%
Taylor expanded in b_2 around inf 100.0%
Final simplification92.0%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -5.1e-70)
(* -0.5 (/ c b_2))
(if (<= b_2 8.5e+72)
(/ (- (- 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 <= -5.1e-70) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 8.5e+72) {
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 <= (-5.1d-70)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 8.5d+72) 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 <= -5.1e-70) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 8.5e+72) {
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 <= -5.1e-70: tmp = -0.5 * (c / b_2) elif b_2 <= 8.5e+72: 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 <= -5.1e-70) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 8.5e+72) 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 <= -5.1e-70) tmp = -0.5 * (c / b_2); elseif (b_2 <= 8.5e+72) 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, -5.1e-70], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 8.5e+72], 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 -5.1 \cdot 10^{-70}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 8.5 \cdot 10^{+72}:\\
\;\;\;\;\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 < -5.10000000000000025e-70Initial program 16.5%
Taylor expanded in b_2 around -inf 90.1%
if -5.10000000000000025e-70 < b_2 < 8.5000000000000004e72Initial program 85.1%
if 8.5000000000000004e72 < b_2 Initial program 64.4%
Taylor expanded in b_2 around inf 100.0%
Final simplification90.3%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -8.8e-67)
(* -0.5 (/ c b_2))
(if (<= b_2 8.5e-30)
(/ (- (- 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 <= -8.8e-67) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 8.5e-30) {
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 <= (-8.8d-67)) then
tmp = (-0.5d0) * (c / b_2)
else if (b_2 <= 8.5d-30) 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 <= -8.8e-67) {
tmp = -0.5 * (c / b_2);
} else if (b_2 <= 8.5e-30) {
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 <= -8.8e-67: tmp = -0.5 * (c / b_2) elif b_2 <= 8.5e-30: 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 <= -8.8e-67) tmp = Float64(-0.5 * Float64(c / b_2)); elseif (b_2 <= 8.5e-30) 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 <= -8.8e-67) tmp = -0.5 * (c / b_2); elseif (b_2 <= 8.5e-30) 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, -8.8e-67], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 8.5e-30], 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 -8.8 \cdot 10^{-67}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 8.5 \cdot 10^{-30}:\\
\;\;\;\;\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 < -8.8000000000000004e-67Initial program 16.5%
Taylor expanded in b_2 around -inf 90.1%
if -8.8000000000000004e-67 < b_2 < 8.49999999999999931e-30Initial program 84.5%
Taylor expanded in b_2 around 0 72.4%
associate-*r*72.4%
neg-mul-172.4%
*-commutative72.4%
Simplified72.4%
if 8.49999999999999931e-30 < b_2 Initial program 70.2%
Taylor expanded in b_2 around inf 90.7%
Final simplification84.6%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1e-309) (* -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 <= -1e-309) {
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 <= (-1d-309)) 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 <= -1e-309) {
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 <= -1e-309: 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 <= -1e-309) 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 <= -1e-309) 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, -1e-309], 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 -1 \cdot 10^{-309}:\\
\;\;\;\;-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 < -1.000000000000002e-309Initial program 30.5%
Taylor expanded in b_2 around -inf 73.6%
if -1.000000000000002e-309 < b_2 Initial program 78.5%
Taylor expanded in b_2 around inf 64.7%
Final simplification69.4%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1e-309) (/ 0.0 a) (* -2.0 (/ b_2 a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-309) {
tmp = 0.0 / a;
} 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 <= (-1d-309)) then
tmp = 0.0d0 / a
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 <= -1e-309) {
tmp = 0.0 / a;
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1e-309: tmp = 0.0 / a else: tmp = -2.0 * (b_2 / a) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1e-309) tmp = Float64(0.0 / a); 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 <= -1e-309) tmp = 0.0 / a; else tmp = -2.0 * (b_2 / a); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1e-309], N[(0.0 / a), $MachinePrecision], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{0}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\
\end{array}
\end{array}
if b_2 < -1.000000000000002e-309Initial program 30.5%
add-sqr-sqrt27.9%
pow227.9%
pow1/227.9%
sqrt-pow127.9%
metadata-eval27.9%
Applied egg-rr27.9%
Taylor expanded in b_2 around -inf 19.7%
distribute-rgt1-in19.7%
metadata-eval19.7%
mul0-lft19.7%
Simplified19.7%
if -1.000000000000002e-309 < b_2 Initial program 78.5%
Taylor expanded in b_2 around inf 64.6%
Final simplification40.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1e-309) (* -0.5 (/ c b_2)) (* -2.0 (/ b_2 a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-309) {
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 <= (-1d-309)) 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 <= -1e-309) {
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 <= -1e-309: 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 <= -1e-309) 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 <= -1e-309) 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, -1e-309], 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 \cdot 10^{-309}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\
\end{array}
\end{array}
if b_2 < -1.000000000000002e-309Initial program 30.5%
Taylor expanded in b_2 around -inf 73.6%
if -1.000000000000002e-309 < b_2 Initial program 78.5%
Taylor expanded in b_2 around inf 64.6%
Final simplification69.3%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1e-309) (/ 0.0 a) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-309) {
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 <= (-1d-309)) 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 <= -1e-309) {
tmp = 0.0 / a;
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1e-309: tmp = 0.0 / a else: tmp = -b_2 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1e-309) 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 <= -1e-309) 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, -1e-309], N[(0.0 / a), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{0}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\
\end{array}
\end{array}
if b_2 < -1.000000000000002e-309Initial program 30.5%
add-sqr-sqrt27.9%
pow227.9%
pow1/227.9%
sqrt-pow127.9%
metadata-eval27.9%
Applied egg-rr27.9%
Taylor expanded in b_2 around -inf 19.7%
distribute-rgt1-in19.7%
metadata-eval19.7%
mul0-lft19.7%
Simplified19.7%
if -1.000000000000002e-309 < b_2 Initial program 78.5%
Taylor expanded in b_2 around 0 50.5%
associate-*r*50.5%
neg-mul-150.5%
*-commutative50.5%
Simplified50.5%
Taylor expanded in b_2 around inf 26.4%
associate-*r/26.4%
mul-1-neg26.4%
Simplified26.4%
Final simplification22.9%
(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.2%
add-sqr-sqrt51.6%
pow251.6%
pow1/251.6%
sqrt-pow151.6%
metadata-eval51.6%
Applied egg-rr51.6%
Taylor expanded in b_2 around -inf 11.6%
distribute-rgt1-in11.6%
metadata-eval11.6%
mul0-lft11.6%
Simplified11.6%
Final simplification11.6%
herbie shell --seed 2023280
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))