
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(-
(*
a
(-
(*
a
(fma
-2.0
(/ (pow c 3.0) (pow b 5.0))
(* (* a (* (/ (pow c 4.0) (pow b 7.0)) 20.0)) -0.25)))
(/ (pow c 2.0) (pow b 3.0))))
(/ c b)))
double code(double a, double b, double c) {
return (a * ((a * fma(-2.0, (pow(c, 3.0) / pow(b, 5.0)), ((a * ((pow(c, 4.0) / pow(b, 7.0)) * 20.0)) * -0.25))) - (pow(c, 2.0) / pow(b, 3.0)))) - (c / b);
}
function code(a, b, c) return Float64(Float64(a * Float64(Float64(a * fma(-2.0, Float64((c ^ 3.0) / (b ^ 5.0)), Float64(Float64(a * Float64(Float64((c ^ 4.0) / (b ^ 7.0)) * 20.0)) * -0.25))) - Float64((c ^ 2.0) / (b ^ 3.0)))) - Float64(c / b)) end
code[a_, b_, c_] := N[(N[(a * N[(N[(a * N[(-2.0 * N[(N[Power[c, 3.0], $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision] + N[(N[(a * N[(N[(N[Power[c, 4.0], $MachinePrecision] / N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision] * 20.0), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Power[c, 2.0], $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot \left(a \cdot \mathsf{fma}\left(-2, \frac{{c}^{3}}{{b}^{5}}, \left(a \cdot \left(\frac{{c}^{4}}{{b}^{7}} \cdot 20\right)\right) \cdot -0.25\right) - \frac{{c}^{2}}{{b}^{3}}\right) - \frac{c}{b}
\end{array}
Initial program 56.1%
*-commutative56.1%
Simplified56.1%
Taylor expanded in a around 0 92.5%
+-commutative92.5%
mul-1-neg92.5%
unsub-neg92.5%
Simplified92.5%
Taylor expanded in c around 0 92.5%
Final simplification92.5%
(FPCore (a b c) :precision binary64 (- (* a (- (* -2.0 (* a (/ (pow c 3.0) (pow b 5.0)))) (/ (pow c 2.0) (pow b 3.0)))) (/ c b)))
double code(double a, double b, double c) {
return (a * ((-2.0 * (a * (pow(c, 3.0) / pow(b, 5.0)))) - (pow(c, 2.0) / pow(b, 3.0)))) - (c / b);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (a * (((-2.0d0) * (a * ((c ** 3.0d0) / (b ** 5.0d0)))) - ((c ** 2.0d0) / (b ** 3.0d0)))) - (c / b)
end function
public static double code(double a, double b, double c) {
return (a * ((-2.0 * (a * (Math.pow(c, 3.0) / Math.pow(b, 5.0)))) - (Math.pow(c, 2.0) / Math.pow(b, 3.0)))) - (c / b);
}
def code(a, b, c): return (a * ((-2.0 * (a * (math.pow(c, 3.0) / math.pow(b, 5.0)))) - (math.pow(c, 2.0) / math.pow(b, 3.0)))) - (c / b)
function code(a, b, c) return Float64(Float64(a * Float64(Float64(-2.0 * Float64(a * Float64((c ^ 3.0) / (b ^ 5.0)))) - Float64((c ^ 2.0) / (b ^ 3.0)))) - Float64(c / b)) end
function tmp = code(a, b, c) tmp = (a * ((-2.0 * (a * ((c ^ 3.0) / (b ^ 5.0)))) - ((c ^ 2.0) / (b ^ 3.0)))) - (c / b); end
code[a_, b_, c_] := N[(N[(a * N[(N[(-2.0 * N[(a * N[(N[Power[c, 3.0], $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Power[c, 2.0], $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot \left(-2 \cdot \left(a \cdot \frac{{c}^{3}}{{b}^{5}}\right) - \frac{{c}^{2}}{{b}^{3}}\right) - \frac{c}{b}
\end{array}
Initial program 56.1%
*-commutative56.1%
Simplified56.1%
Taylor expanded in a around 0 89.2%
+-commutative89.2%
mul-1-neg89.2%
unsub-neg89.2%
mul-1-neg89.2%
unsub-neg89.2%
associate-/l*89.2%
Simplified89.2%
Final simplification89.2%
(FPCore (a b c) :precision binary64 (* c (+ (* c (- (* -2.0 (/ (* c (pow a 2.0)) (pow b 5.0))) (/ a (pow b 3.0)))) (/ -1.0 b))))
double code(double a, double b, double c) {
return c * ((c * ((-2.0 * ((c * pow(a, 2.0)) / pow(b, 5.0))) - (a / pow(b, 3.0)))) + (-1.0 / b));
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c * ((c * (((-2.0d0) * ((c * (a ** 2.0d0)) / (b ** 5.0d0))) - (a / (b ** 3.0d0)))) + ((-1.0d0) / b))
end function
public static double code(double a, double b, double c) {
return c * ((c * ((-2.0 * ((c * Math.pow(a, 2.0)) / Math.pow(b, 5.0))) - (a / Math.pow(b, 3.0)))) + (-1.0 / b));
}
def code(a, b, c): return c * ((c * ((-2.0 * ((c * math.pow(a, 2.0)) / math.pow(b, 5.0))) - (a / math.pow(b, 3.0)))) + (-1.0 / b))
function code(a, b, c) return Float64(c * Float64(Float64(c * Float64(Float64(-2.0 * Float64(Float64(c * (a ^ 2.0)) / (b ^ 5.0))) - Float64(a / (b ^ 3.0)))) + Float64(-1.0 / b))) end
function tmp = code(a, b, c) tmp = c * ((c * ((-2.0 * ((c * (a ^ 2.0)) / (b ^ 5.0))) - (a / (b ^ 3.0)))) + (-1.0 / b)); end
code[a_, b_, c_] := N[(c * N[(N[(c * N[(N[(-2.0 * N[(N[(c * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \left(c \cdot \left(-2 \cdot \frac{c \cdot {a}^{2}}{{b}^{5}} - \frac{a}{{b}^{3}}\right) + \frac{-1}{b}\right)
\end{array}
Initial program 56.1%
*-commutative56.1%
Simplified56.1%
div-sub55.3%
*-un-lft-identity55.3%
*-commutative55.3%
times-frac55.3%
metadata-eval55.3%
pow255.3%
*-un-lft-identity55.3%
*-commutative55.3%
times-frac55.3%
metadata-eval55.3%
Applied egg-rr55.3%
Taylor expanded in c around inf 55.3%
Taylor expanded in c around 0 89.0%
fma-define89.0%
mul-1-neg89.0%
fmm-undef89.0%
*-commutative89.0%
Simplified89.0%
Final simplification89.0%
(FPCore (a b c)
:precision binary64
(if (<= b 2.2)
(-
(* 0.5 (/ (sqrt (* c (+ (* a -4.0) (/ (pow b 2.0) c)))) a))
(* 0.5 (/ b a)))
(- (/ c (- b)) (* a (/ (pow c 2.0) (pow b 3.0))))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.2) {
tmp = (0.5 * (sqrt((c * ((a * -4.0) + (pow(b, 2.0) / c)))) / a)) - (0.5 * (b / a));
} else {
tmp = (c / -b) - (a * (pow(c, 2.0) / pow(b, 3.0)));
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 2.2d0) then
tmp = (0.5d0 * (sqrt((c * ((a * (-4.0d0)) + ((b ** 2.0d0) / c)))) / a)) - (0.5d0 * (b / a))
else
tmp = (c / -b) - (a * ((c ** 2.0d0) / (b ** 3.0d0)))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.2) {
tmp = (0.5 * (Math.sqrt((c * ((a * -4.0) + (Math.pow(b, 2.0) / c)))) / a)) - (0.5 * (b / a));
} else {
tmp = (c / -b) - (a * (Math.pow(c, 2.0) / Math.pow(b, 3.0)));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.2: tmp = (0.5 * (math.sqrt((c * ((a * -4.0) + (math.pow(b, 2.0) / c)))) / a)) - (0.5 * (b / a)) else: tmp = (c / -b) - (a * (math.pow(c, 2.0) / math.pow(b, 3.0))) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.2) tmp = Float64(Float64(0.5 * Float64(sqrt(Float64(c * Float64(Float64(a * -4.0) + Float64((b ^ 2.0) / c)))) / a)) - Float64(0.5 * Float64(b / a))); else tmp = Float64(Float64(c / Float64(-b)) - Float64(a * Float64((c ^ 2.0) / (b ^ 3.0)))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.2) tmp = (0.5 * (sqrt((c * ((a * -4.0) + ((b ^ 2.0) / c)))) / a)) - (0.5 * (b / a)); else tmp = (c / -b) - (a * ((c ^ 2.0) / (b ^ 3.0))); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.2], N[(N[(0.5 * N[(N[Sqrt[N[(c * N[(N[(a * -4.0), $MachinePrecision] + N[(N[Power[b, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / (-b)), $MachinePrecision] - N[(a * N[(N[Power[c, 2.0], $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.2:\\
\;\;\;\;0.5 \cdot \frac{\sqrt{c \cdot \left(a \cdot -4 + \frac{{b}^{2}}{c}\right)}}{a} - 0.5 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b} - a \cdot \frac{{c}^{2}}{{b}^{3}}\\
\end{array}
\end{array}
if b < 2.2000000000000002Initial program 78.8%
*-commutative78.8%
Simplified78.8%
div-sub78.5%
*-un-lft-identity78.5%
*-commutative78.5%
times-frac78.5%
metadata-eval78.5%
pow278.5%
*-un-lft-identity78.5%
*-commutative78.5%
times-frac78.5%
metadata-eval78.5%
Applied egg-rr78.5%
Taylor expanded in c around inf 78.9%
if 2.2000000000000002 < b Initial program 51.3%
*-commutative51.3%
Simplified51.3%
Taylor expanded in a around 0 86.8%
mul-1-neg86.8%
unsub-neg86.8%
mul-1-neg86.8%
distribute-neg-frac286.8%
associate-/l*86.8%
Simplified86.8%
Final simplification85.4%
(FPCore (a b c) :precision binary64 (if (<= b 2.0) (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)) (- (/ c (- b)) (* a (/ (pow c 2.0) (pow b 3.0))))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.0) {
tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = (c / -b) - (a * (pow(c, 2.0) / pow(b, 3.0)));
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 2.0d0) then
tmp = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
else
tmp = (c / -b) - (a * ((c ** 2.0d0) / (b ** 3.0d0)))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.0) {
tmp = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = (c / -b) - (a * (Math.pow(c, 2.0) / Math.pow(b, 3.0)));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.0: tmp = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) else: tmp = (c / -b) - (a * (math.pow(c, 2.0) / math.pow(b, 3.0))) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.0) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(c / Float64(-b)) - Float64(a * Float64((c ^ 2.0) / (b ^ 3.0)))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.0) tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); else tmp = (c / -b) - (a * ((c ^ 2.0) / (b ^ 3.0))); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.0], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / (-b)), $MachinePrecision] - N[(a * N[(N[Power[c, 2.0], $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b} - a \cdot \frac{{c}^{2}}{{b}^{3}}\\
\end{array}
\end{array}
if b < 2Initial program 78.8%
if 2 < b Initial program 51.3%
*-commutative51.3%
Simplified51.3%
Taylor expanded in a around 0 86.8%
mul-1-neg86.8%
unsub-neg86.8%
mul-1-neg86.8%
distribute-neg-frac286.8%
associate-/l*86.8%
Simplified86.8%
Final simplification85.4%
(FPCore (a b c) :precision binary64 (if (<= b 2.2) (/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)) (/ (- (- c) (* a (pow (/ c (- b)) 2.0))) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.2) {
tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = (-c - (a * pow((c / -b), 2.0))) / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 2.2d0) then
tmp = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
else
tmp = (-c - (a * ((c / -b) ** 2.0d0))) / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.2) {
tmp = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = (-c - (a * Math.pow((c / -b), 2.0))) / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.2: tmp = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) else: tmp = (-c - (a * math.pow((c / -b), 2.0))) / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.2) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(Float64(-c) - Float64(a * (Float64(c / Float64(-b)) ^ 2.0))) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.2) tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); else tmp = (-c - (a * ((c / -b) ^ 2.0))) / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.2], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[((-c) - N[(a * N[Power[N[(c / (-b)), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.2:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-c\right) - a \cdot {\left(\frac{c}{-b}\right)}^{2}}{b}\\
\end{array}
\end{array}
if b < 2.2000000000000002Initial program 78.8%
if 2.2000000000000002 < b Initial program 51.3%
*-commutative51.3%
Simplified51.3%
div-sub50.4%
*-un-lft-identity50.4%
*-commutative50.4%
times-frac50.4%
metadata-eval50.4%
pow250.4%
*-un-lft-identity50.4%
*-commutative50.4%
times-frac50.4%
metadata-eval50.4%
Applied egg-rr50.4%
Taylor expanded in c around inf 50.2%
Taylor expanded in b around inf 86.7%
fma-define86.7%
mul-1-neg86.7%
fmm-undef86.7%
mul-1-neg86.7%
associate-/l*86.7%
unpow286.7%
unpow286.7%
times-frac86.7%
sqr-neg86.7%
unpow286.7%
distribute-neg-frac286.7%
Simplified86.7%
Final simplification85.3%
(FPCore (a b c) :precision binary64 (/ (- (- c) (* a (pow (/ c (- b)) 2.0))) b))
double code(double a, double b, double c) {
return (-c - (a * pow((c / -b), 2.0))) / b;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-c - (a * ((c / -b) ** 2.0d0))) / b
end function
public static double code(double a, double b, double c) {
return (-c - (a * Math.pow((c / -b), 2.0))) / b;
}
def code(a, b, c): return (-c - (a * math.pow((c / -b), 2.0))) / b
function code(a, b, c) return Float64(Float64(Float64(-c) - Float64(a * (Float64(c / Float64(-b)) ^ 2.0))) / b) end
function tmp = code(a, b, c) tmp = (-c - (a * ((c / -b) ^ 2.0))) / b; end
code[a_, b_, c_] := N[(N[((-c) - N[(a * N[Power[N[(c / (-b)), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-c\right) - a \cdot {\left(\frac{c}{-b}\right)}^{2}}{b}
\end{array}
Initial program 56.1%
*-commutative56.1%
Simplified56.1%
div-sub55.3%
*-un-lft-identity55.3%
*-commutative55.3%
times-frac55.3%
metadata-eval55.3%
pow255.3%
*-un-lft-identity55.3%
*-commutative55.3%
times-frac55.3%
metadata-eval55.3%
Applied egg-rr55.3%
Taylor expanded in c around inf 55.3%
Taylor expanded in b around inf 82.8%
fma-define82.8%
mul-1-neg82.8%
fmm-undef82.8%
mul-1-neg82.8%
associate-/l*82.8%
unpow282.8%
unpow282.8%
times-frac82.8%
sqr-neg82.8%
unpow282.8%
distribute-neg-frac282.8%
Simplified82.8%
Final simplification82.8%
(FPCore (a b c) :precision binary64 (/ c (- b)))
double code(double a, double b, double c) {
return c / -b;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c / -b
end function
public static double code(double a, double b, double c) {
return c / -b;
}
def code(a, b, c): return c / -b
function code(a, b, c) return Float64(c / Float64(-b)) end
function tmp = code(a, b, c) tmp = c / -b; end
code[a_, b_, c_] := N[(c / (-b)), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{-b}
\end{array}
Initial program 56.1%
*-commutative56.1%
Simplified56.1%
Taylor expanded in b around inf 64.4%
associate-*r/64.4%
mul-1-neg64.4%
Simplified64.4%
Final simplification64.4%
herbie shell --seed 2024112
(FPCore (a b c)
:name "Quadratic roots, narrow range"
:precision binary64
:pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))