
(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 -6.5e+31)
(/ b (- a))
(if (<= b 2.2e-50)
(/ (- (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 <= -6.5e+31) {
tmp = b / -a;
} else if (b <= 2.2e-50) {
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 <= (-6.5d+31)) then
tmp = b / -a
else if (b <= 2.2d-50) 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 <= -6.5e+31) {
tmp = b / -a;
} else if (b <= 2.2e-50) {
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 <= -6.5e+31: tmp = b / -a elif b <= 2.2e-50: 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 <= -6.5e+31) tmp = Float64(b / Float64(-a)); elseif (b <= 2.2e-50) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.5e+31) tmp = b / -a; elseif (b <= 2.2e-50) 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, -6.5e+31], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 2.2e-50], 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 -6.5 \cdot 10^{+31}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{-50}:\\
\;\;\;\;\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 < -6.5000000000000004e31Initial program 78.7%
*-commutative78.7%
Simplified78.7%
Taylor expanded in b around -inf 98.7%
associate-*r/98.7%
mul-1-neg98.7%
Simplified98.7%
if -6.5000000000000004e31 < b < 2.1999999999999999e-50Initial program 74.2%
if 2.1999999999999999e-50 < b Initial program 15.8%
*-commutative15.8%
Simplified15.8%
Taylor expanded in b around inf 84.4%
associate-*r/84.4%
mul-1-neg84.4%
Simplified84.4%
Final simplification84.5%
(FPCore (a b c)
:precision binary64
(if (<= b -2.05e-64)
(/ b (- a))
(if (<= b 1.2e-49)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.05e-64) {
tmp = b / -a;
} else if (b <= 1.2e-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 <= (-2.05d-64)) then
tmp = b / -a
else if (b <= 1.2d-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 <= -2.05e-64) {
tmp = b / -a;
} else if (b <= 1.2e-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 <= -2.05e-64: tmp = b / -a elif b <= 1.2e-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 <= -2.05e-64) tmp = Float64(b / Float64(-a)); elseif (b <= 1.2e-49) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.05e-64) tmp = b / -a; elseif (b <= 1.2e-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, -2.05e-64], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.2e-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 -2.05 \cdot 10^{-64}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.2 \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 < -2.05e-64Initial program 78.8%
*-commutative78.8%
Simplified78.8%
Taylor expanded in b around -inf 87.0%
associate-*r/87.0%
mul-1-neg87.0%
Simplified87.0%
if -2.05e-64 < b < 1.19999999999999996e-49Initial program 72.8%
*-commutative72.8%
Simplified72.8%
Taylor expanded in b around 0 68.0%
*-commutative68.0%
associate-*r*68.0%
Simplified68.0%
if 1.19999999999999996e-49 < b Initial program 15.8%
*-commutative15.8%
Simplified15.8%
Taylor expanded in b around inf 84.4%
associate-*r/84.4%
mul-1-neg84.4%
Simplified84.4%
Final simplification80.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.05e-139)
(/ b (- a))
(if (<= b 2.15e-51)
(/ (+ b (sqrt (* a (* c -4.0)))) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-139) {
tmp = b / -a;
} else if (b <= 2.15e-51) {
tmp = (b + sqrt((a * (c * -4.0)))) / (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 <= (-1.05d-139)) then
tmp = b / -a
else if (b <= 2.15d-51) then
tmp = (b + sqrt((a * (c * (-4.0d0))))) / (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 <= -1.05e-139) {
tmp = b / -a;
} else if (b <= 2.15e-51) {
tmp = (b + Math.sqrt((a * (c * -4.0)))) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.05e-139: tmp = b / -a elif b <= 2.15e-51: tmp = (b + math.sqrt((a * (c * -4.0)))) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.05e-139) tmp = Float64(b / Float64(-a)); elseif (b <= 2.15e-51) tmp = Float64(Float64(b + sqrt(Float64(a * Float64(c * -4.0)))) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.05e-139) tmp = b / -a; elseif (b <= 2.15e-51) tmp = (b + sqrt((a * (c * -4.0)))) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.05e-139], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 2.15e-51], N[(N[(b + N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.05 \cdot 10^{-139}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 2.15 \cdot 10^{-51}:\\
\;\;\;\;\frac{b + \sqrt{a \cdot \left(c \cdot -4\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.05000000000000004e-139Initial program 80.4%
*-commutative80.4%
Simplified80.4%
Taylor expanded in b around -inf 84.3%
associate-*r/84.3%
mul-1-neg84.3%
Simplified84.3%
if -1.05000000000000004e-139 < b < 2.1499999999999999e-51Initial program 69.5%
*-commutative69.5%
Simplified69.5%
Taylor expanded in b around 0 69.4%
*-commutative69.4%
associate-*r*69.4%
Simplified69.4%
+-commutative69.4%
*-un-lft-identity69.4%
fma-define69.4%
add-sqr-sqrt35.6%
sqrt-unprod68.7%
sqr-neg68.7%
sqrt-prod33.9%
add-sqr-sqrt68.7%
Applied egg-rr68.7%
fma-undefine68.7%
*-lft-identity68.7%
Simplified68.7%
if 2.1499999999999999e-51 < b Initial program 15.8%
*-commutative15.8%
Simplified15.8%
Taylor expanded in b around inf 84.4%
associate-*r/84.4%
mul-1-neg84.4%
Simplified84.4%
Final simplification80.3%
(FPCore (a b c) :precision binary64 (if (<= b -1.05e-139) (/ b (- a)) (if (<= b 5.5e-175) (* -0.5 (- (sqrt (/ (* c -4.0) a)))) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-139) {
tmp = b / -a;
} else if (b <= 5.5e-175) {
tmp = -0.5 * -sqrt(((c * -4.0) / 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 <= (-1.05d-139)) then
tmp = b / -a
else if (b <= 5.5d-175) then
tmp = (-0.5d0) * -sqrt(((c * (-4.0d0)) / 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 <= -1.05e-139) {
tmp = b / -a;
} else if (b <= 5.5e-175) {
tmp = -0.5 * -Math.sqrt(((c * -4.0) / a));
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.05e-139: tmp = b / -a elif b <= 5.5e-175: tmp = -0.5 * -math.sqrt(((c * -4.0) / a)) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.05e-139) tmp = Float64(b / Float64(-a)); elseif (b <= 5.5e-175) tmp = Float64(-0.5 * Float64(-sqrt(Float64(Float64(c * -4.0) / a)))); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.05e-139) tmp = b / -a; elseif (b <= 5.5e-175) tmp = -0.5 * -sqrt(((c * -4.0) / a)); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.05e-139], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 5.5e-175], N[(-0.5 * (-N[Sqrt[N[(N[(c * -4.0), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.05 \cdot 10^{-139}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 5.5 \cdot 10^{-175}:\\
\;\;\;\;-0.5 \cdot \left(-\sqrt{\frac{c \cdot -4}{a}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.05000000000000004e-139Initial program 80.4%
*-commutative80.4%
Simplified80.4%
Taylor expanded in b around -inf 84.3%
associate-*r/84.3%
mul-1-neg84.3%
Simplified84.3%
if -1.05000000000000004e-139 < b < 5.50000000000000054e-175Initial program 77.3%
*-commutative77.3%
Simplified77.3%
add-cube-cbrt76.7%
pow376.7%
Applied egg-rr76.7%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt42.0%
rem-cube-cbrt42.4%
Simplified42.4%
if 5.50000000000000054e-175 < b Initial program 22.4%
*-commutative22.4%
Simplified22.4%
Taylor expanded in b around inf 75.9%
associate-*r/75.9%
mul-1-neg75.9%
Simplified75.9%
Final simplification73.2%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
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 <= (-2d-310)) 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 <= -2e-310) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 80.0%
*-commutative80.0%
Simplified80.0%
Taylor expanded in b around -inf 67.6%
associate-*r/67.6%
mul-1-neg67.6%
Simplified67.6%
if -1.999999999999994e-310 < b Initial program 29.2%
*-commutative29.2%
Simplified29.2%
Taylor expanded in b around inf 67.5%
associate-*r/67.5%
mul-1-neg67.5%
Simplified67.5%
Final simplification67.6%
(FPCore (a b c) :precision binary64 (if (<= b 6.2e+72) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.2e+72) {
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 <= 6.2d+72) 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 <= 6.2e+72) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.2e+72: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.2e+72) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 6.2e+72) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.2e+72], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.2 \cdot 10^{+72}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 6.19999999999999977e72Initial program 71.6%
*-commutative71.6%
Simplified71.6%
Taylor expanded in b around -inf 47.9%
associate-*r/47.9%
mul-1-neg47.9%
Simplified47.9%
if 6.19999999999999977e72 < b Initial program 8.6%
*-commutative8.6%
Simplified8.6%
Taylor expanded in b around inf 77.5%
associate-*r/77.6%
associate-*r*77.6%
*-commutative77.6%
associate-*l/69.7%
Simplified69.7%
associate-/l*71.1%
Applied egg-rr71.1%
clear-num71.0%
un-div-inv71.0%
associate-/l*71.1%
frac-2neg71.1%
metadata-eval71.1%
add-sqr-sqrt0.0%
sqrt-unprod25.1%
sqr-neg25.1%
sqrt-prod24.5%
add-sqr-sqrt24.5%
*-commutative24.5%
*-un-lft-identity24.5%
times-frac24.5%
metadata-eval24.5%
Applied egg-rr24.5%
associate-*r/24.5%
metadata-eval24.5%
distribute-rgt-neg-in24.5%
associate-/r*24.8%
distribute-rgt-neg-in24.8%
metadata-eval24.8%
Simplified24.8%
Taylor expanded in a around 0 24.6%
Final simplification41.9%
(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 / 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 55.4%
*-commutative55.4%
Simplified55.4%
Taylor expanded in b around inf 27.0%
associate-*r/27.0%
associate-*r*27.0%
*-commutative27.0%
associate-*l/26.8%
Simplified26.8%
associate-/l*26.4%
Applied egg-rr26.4%
clear-num26.3%
un-div-inv26.3%
associate-/l*26.3%
frac-2neg26.3%
metadata-eval26.3%
add-sqr-sqrt1.0%
sqrt-unprod7.8%
sqr-neg7.8%
sqrt-prod6.6%
add-sqr-sqrt8.2%
*-commutative8.2%
*-un-lft-identity8.2%
times-frac8.2%
metadata-eval8.2%
Applied egg-rr8.2%
associate-*r/8.2%
metadata-eval8.2%
distribute-rgt-neg-in8.2%
associate-/r*10.9%
distribute-rgt-neg-in10.9%
metadata-eval10.9%
Simplified10.9%
Taylor expanded in a around 0 8.5%
(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 55.4%
*-commutative55.4%
Simplified55.4%
Taylor expanded in b around -inf 36.2%
associate-*r/36.2%
mul-1-neg36.2%
Simplified36.2%
div-inv36.1%
add-sqr-sqrt34.7%
sqrt-unprod30.0%
sqr-neg30.0%
sqrt-prod1.8%
add-sqr-sqrt2.6%
Applied egg-rr2.6%
associate-*r/2.6%
*-rgt-identity2.6%
Simplified2.6%
herbie shell --seed 2024119
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))