
(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
(if (<= b -3e+120)
(/ (- b) a)
(if (<= b 1.55e-53)
(/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3e+120) {
tmp = -b / a;
} else if (b <= 1.55e-53) {
tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else {
tmp = -c / 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 <= (-3d+120)) then
tmp = -b / a
else if (b <= 1.55d-53) then
tmp = (sqrt(((b * b) - ((a * 4.0d0) * c))) - b) / (a * 2.0d0)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3e+120) {
tmp = -b / a;
} else if (b <= 1.55e-53) {
tmp = (Math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3e+120: tmp = -b / a elif b <= 1.55e-53: tmp = (math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3e+120) tmp = Float64(Float64(-b) / a); elseif (b <= 1.55e-53) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3e+120) tmp = -b / a; elseif (b <= 1.55e-53) tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3e+120], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 1.55e-53], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{+120}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 1.55 \cdot 10^{-53}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -3e120Initial program 45.5%
Taylor expanded in b around -inf 98.1%
associate-*r/98.1%
mul-1-neg98.1%
Simplified98.1%
if -3e120 < b < 1.55000000000000008e-53Initial program 87.5%
if 1.55000000000000008e-53 < b Initial program 15.6%
Taylor expanded in b around inf 85.0%
associate-*r/85.0%
neg-mul-185.0%
Simplified85.0%
Final simplification88.6%
(FPCore (a b c)
:precision binary64
(if (<= b -4.2e-41)
(- (/ c b) (/ b a))
(if (<= b 4.4e-59)
(* (- (sqrt (* a (* c -4.0))) b) (/ 0.5 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.2e-41) {
tmp = (c / b) - (b / a);
} else if (b <= 4.4e-59) {
tmp = (sqrt((a * (c * -4.0))) - b) * (0.5 / a);
} else {
tmp = -c / 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 <= (-4.2d-41)) then
tmp = (c / b) - (b / a)
else if (b <= 4.4d-59) then
tmp = (sqrt((a * (c * (-4.0d0)))) - b) * (0.5d0 / a)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.2e-41) {
tmp = (c / b) - (b / a);
} else if (b <= 4.4e-59) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) * (0.5 / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.2e-41: tmp = (c / b) - (b / a) elif b <= 4.4e-59: tmp = (math.sqrt((a * (c * -4.0))) - b) * (0.5 / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.2e-41) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 4.4e-59) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) * Float64(0.5 / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.2e-41) tmp = (c / b) - (b / a); elseif (b <= 4.4e-59) tmp = (sqrt((a * (c * -4.0))) - b) * (0.5 / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.2e-41], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.4e-59], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.2 \cdot 10^{-41}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{-59}:\\
\;\;\;\;\left(\sqrt{a \cdot \left(c \cdot -4\right)} - b\right) \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.20000000000000025e-41Initial program 69.2%
Taylor expanded in b around -inf 88.5%
+-commutative88.5%
mul-1-neg88.5%
unsub-neg88.5%
Simplified88.5%
if -4.20000000000000025e-41 < b < 4.3999999999999998e-59Initial program 82.5%
add-sqr-sqrt82.2%
pow282.2%
pow1/282.2%
sqrt-pow182.2%
fma-neg82.2%
*-commutative82.2%
distribute-rgt-neg-in82.2%
*-commutative82.2%
distribute-rgt-neg-in82.2%
metadata-eval82.2%
metadata-eval82.2%
Applied egg-rr82.2%
Taylor expanded in b around 0 77.2%
Taylor expanded in a around 0 30.4%
*-commutative30.4%
Simplified77.3%
if 4.3999999999999998e-59 < b Initial program 15.6%
Taylor expanded in b around inf 85.0%
associate-*r/85.0%
neg-mul-185.0%
Simplified85.0%
Final simplification84.2%
(FPCore (a b c)
:precision binary64
(if (<= b -7e-41)
(- (/ c b) (/ b a))
(if (<= b 1.8e-55)
(/ (- (sqrt (* -4.0 (* a c))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7e-41) {
tmp = (c / b) - (b / a);
} else if (b <= 1.8e-55) {
tmp = (sqrt((-4.0 * (a * c))) - b) / (a * 2.0);
} else {
tmp = -c / 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 <= (-7d-41)) then
tmp = (c / b) - (b / a)
else if (b <= 1.8d-55) then
tmp = (sqrt(((-4.0d0) * (a * c))) - b) / (a * 2.0d0)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -7e-41) {
tmp = (c / b) - (b / a);
} else if (b <= 1.8e-55) {
tmp = (Math.sqrt((-4.0 * (a * c))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7e-41: tmp = (c / b) - (b / a) elif b <= 1.8e-55: tmp = (math.sqrt((-4.0 * (a * c))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7e-41) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.8e-55) tmp = Float64(Float64(sqrt(Float64(-4.0 * Float64(a * c))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -7e-41) tmp = (c / b) - (b / a); elseif (b <= 1.8e-55) tmp = (sqrt((-4.0 * (a * c))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7e-41], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e-55], N[(N[(N[Sqrt[N[(-4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7 \cdot 10^{-41}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-55}:\\
\;\;\;\;\frac{\sqrt{-4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -6.9999999999999999e-41Initial program 69.2%
Taylor expanded in b around -inf 88.5%
+-commutative88.5%
mul-1-neg88.5%
unsub-neg88.5%
Simplified88.5%
if -6.9999999999999999e-41 < b < 1.8e-55Initial program 82.5%
add-sqr-sqrt82.2%
pow282.2%
pow1/282.2%
sqrt-pow182.2%
fma-neg82.2%
*-commutative82.2%
distribute-rgt-neg-in82.2%
*-commutative82.2%
distribute-rgt-neg-in82.2%
metadata-eval82.2%
metadata-eval82.2%
Applied egg-rr82.2%
Taylor expanded in c around inf 50.8%
Simplified77.5%
if 1.8e-55 < b Initial program 15.6%
Taylor expanded in b around inf 85.0%
associate-*r/85.0%
neg-mul-185.0%
Simplified85.0%
Final simplification84.2%
(FPCore (a b c)
:precision binary64
(if (<= b -4.4e-41)
(- (/ c b) (/ b a))
(if (<= b 2.8e-49)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.4e-41) {
tmp = (c / b) - (b / a);
} else if (b <= 2.8e-49) {
tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = -c / 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 <= (-4.4d-41)) then
tmp = (c / b) - (b / a)
else if (b <= 2.8d-49) then
tmp = (sqrt((a * (c * (-4.0d0)))) - b) / (a * 2.0d0)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.4e-41) {
tmp = (c / b) - (b / a);
} else if (b <= 2.8e-49) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.4e-41: tmp = (c / b) - (b / a) elif b <= 2.8e-49: tmp = (math.sqrt((a * (c * -4.0))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.4e-41) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 2.8e-49) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.4e-41) tmp = (c / b) - (b / a); elseif (b <= 2.8e-49) tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.4e-41], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.8e-49], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.4 \cdot 10^{-41}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 2.8 \cdot 10^{-49}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.4e-41Initial program 69.2%
Taylor expanded in b around -inf 88.5%
+-commutative88.5%
mul-1-neg88.5%
unsub-neg88.5%
Simplified88.5%
if -4.4e-41 < b < 2.79999999999999997e-49Initial program 82.5%
add-sqr-sqrt82.2%
pow282.2%
pow1/282.2%
sqrt-pow182.2%
fma-neg82.2%
*-commutative82.2%
distribute-rgt-neg-in82.2%
*-commutative82.2%
distribute-rgt-neg-in82.2%
metadata-eval82.2%
metadata-eval82.2%
Applied egg-rr82.2%
Taylor expanded in b around 0 77.2%
Taylor expanded in a around 0 30.4%
*-commutative30.4%
log-prod72.5%
log-pow72.5%
rem-exp-log77.3%
unpow277.3%
pow-sqr77.6%
metadata-eval77.6%
unpow1/277.6%
Simplified77.6%
if 2.79999999999999997e-49 < b Initial program 15.6%
Taylor expanded in b around inf 85.0%
associate-*r/85.0%
neg-mul-185.0%
Simplified85.0%
Final simplification84.2%
(FPCore (a b c) :precision binary64 (if (<= b -1e-311) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-311) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / 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 <= (-1d-311)) then
tmp = (c / b) - (b / a)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1e-311) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-311: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-311) tmp = Float64(Float64(c / b) - Float64(b / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-311) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-311], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-311}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -9.99999999999948e-312Initial program 73.8%
Taylor expanded in b around -inf 69.7%
+-commutative69.7%
mul-1-neg69.7%
unsub-neg69.7%
Simplified69.7%
if -9.99999999999948e-312 < b Initial program 33.5%
Taylor expanded in b around inf 65.2%
associate-*r/65.2%
neg-mul-165.2%
Simplified65.2%
Final simplification67.4%
(FPCore (a b c) :precision binary64 (if (<= b -1e-311) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-311) {
tmp = -b / a;
} else {
tmp = -c / 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 <= (-1d-311)) then
tmp = -b / a
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1e-311) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-311: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-311) tmp = Float64(Float64(-b) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-311) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-311], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-311}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -9.99999999999948e-312Initial program 73.8%
Taylor expanded in b around -inf 69.5%
associate-*r/69.5%
mul-1-neg69.5%
Simplified69.5%
if -9.99999999999948e-312 < b Initial program 33.5%
Taylor expanded in b around inf 65.2%
associate-*r/65.2%
neg-mul-165.2%
Simplified65.2%
Final simplification67.3%
(FPCore (a b c) :precision binary64 (/ (- b) a))
double code(double a, double b, double c) {
return -b / 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 / a
end function
public static double code(double a, double b, double c) {
return -b / a;
}
def code(a, b, c): return -b / a
function code(a, b, c) return Float64(Float64(-b) / a) end
function tmp = code(a, b, c) tmp = -b / a; end
code[a_, b_, c_] := N[((-b) / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{-b}{a}
\end{array}
Initial program 53.4%
Taylor expanded in b around -inf 35.6%
associate-*r/35.6%
mul-1-neg35.6%
Simplified35.6%
Final simplification35.6%
(FPCore (a b c) :precision binary64 (/ b a))
double code(double a, double b, double c) {
return b / 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 / a
end function
public static double code(double a, double b, double c) {
return b / a;
}
def code(a, b, c): return b / a
function code(a, b, c) return Float64(b / a) end
function tmp = code(a, b, c) tmp = b / a; end
code[a_, b_, c_] := N[(b / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{a}
\end{array}
Initial program 53.4%
clear-num53.3%
associate-/r/53.2%
associate-/r*53.2%
metadata-eval53.2%
add-sqr-sqrt36.2%
sqrt-unprod51.3%
sqr-neg51.3%
sqrt-prod15.2%
add-sqr-sqrt33.9%
sub-neg33.9%
add-sqr-sqrt30.9%
hypot-def28.2%
*-commutative28.2%
distribute-rgt-neg-in28.2%
*-commutative28.2%
distribute-rgt-neg-in28.2%
metadata-eval28.2%
Applied egg-rr28.2%
Taylor expanded in a around 0 2.5%
Final simplification2.5%
herbie shell --seed 2023283
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))