
(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 9 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 -2e+138)
(/ b (- a))
(if (<= b 1.9e-92)
(/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (* a 2.0))
(/ (/ 1.0 b) (+ (* a (pow b -2.0)) (/ -1.0 c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e+138) {
tmp = b / -a;
} else if (b <= 1.9e-92) {
tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else {
tmp = (1.0 / b) / ((a * pow(b, -2.0)) + (-1.0 / c));
}
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+138)) then
tmp = b / -a
else if (b <= 1.9d-92) then
tmp = (sqrt(((b * b) - ((a * 4.0d0) * c))) - b) / (a * 2.0d0)
else
tmp = (1.0d0 / b) / ((a * (b ** (-2.0d0))) + ((-1.0d0) / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e+138) {
tmp = b / -a;
} else if (b <= 1.9e-92) {
tmp = (Math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else {
tmp = (1.0 / b) / ((a * Math.pow(b, -2.0)) + (-1.0 / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e+138: tmp = b / -a elif b <= 1.9e-92: tmp = (math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0) else: tmp = (1.0 / b) / ((a * math.pow(b, -2.0)) + (-1.0 / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e+138) tmp = Float64(b / Float64(-a)); elseif (b <= 1.9e-92) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(1.0 / b) / Float64(Float64(a * (b ^ -2.0)) + Float64(-1.0 / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e+138) tmp = b / -a; elseif (b <= 1.9e-92) tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0); else tmp = (1.0 / b) / ((a * (b ^ -2.0)) + (-1.0 / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e+138], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.9e-92], 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[(N[(1.0 / b), $MachinePrecision] / N[(N[(a * N[Power[b, -2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{+138}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-92}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{b}}{a \cdot {b}^{-2} + \frac{-1}{c}}\\
\end{array}
\end{array}
if b < -2.0000000000000001e138Initial program 31.4%
*-commutative31.4%
Simplified31.4%
Taylor expanded in b around -inf 90.8%
associate-*r/90.8%
mul-1-neg90.8%
Simplified90.8%
if -2.0000000000000001e138 < b < 1.9e-92Initial program 88.8%
if 1.9e-92 < b Initial program 18.8%
*-commutative18.8%
Simplified18.8%
Applied egg-rr10.2%
unpow-110.2%
associate-/l*10.2%
Simplified10.2%
Taylor expanded in b around -inf 19.9%
associate-*r*19.9%
neg-mul-119.9%
Simplified19.9%
*-un-lft-identity19.9%
add-sqr-sqrt0.0%
sqrt-unprod59.5%
sqr-neg59.5%
sqrt-prod83.9%
add-sqr-sqrt84.2%
div-inv84.2%
pow-flip84.2%
metadata-eval84.2%
inv-pow84.2%
Applied egg-rr84.2%
*-lft-identity84.2%
associate-/r*86.3%
unpow-186.3%
Simplified86.3%
Final simplification88.1%
(FPCore (a b c)
:precision binary64
(if (<= b -3.2e-52)
(/ b (- a))
(if (<= b 7.9e-94)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ (/ 1.0 b) (+ (* a (pow b -2.0)) (/ -1.0 c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.2e-52) {
tmp = b / -a;
} else if (b <= 7.9e-94) {
tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = (1.0 / b) / ((a * pow(b, -2.0)) + (-1.0 / c));
}
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 <= (-3.2d-52)) then
tmp = b / -a
else if (b <= 7.9d-94) then
tmp = (sqrt((a * (c * (-4.0d0)))) - b) / (a * 2.0d0)
else
tmp = (1.0d0 / b) / ((a * (b ** (-2.0d0))) + ((-1.0d0) / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.2e-52) {
tmp = b / -a;
} else if (b <= 7.9e-94) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = (1.0 / b) / ((a * Math.pow(b, -2.0)) + (-1.0 / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.2e-52: tmp = b / -a elif b <= 7.9e-94: tmp = (math.sqrt((a * (c * -4.0))) - b) / (a * 2.0) else: tmp = (1.0 / b) / ((a * math.pow(b, -2.0)) + (-1.0 / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.2e-52) tmp = Float64(b / Float64(-a)); elseif (b <= 7.9e-94) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(1.0 / b) / Float64(Float64(a * (b ^ -2.0)) + Float64(-1.0 / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.2e-52) tmp = b / -a; elseif (b <= 7.9e-94) tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0); else tmp = (1.0 / b) / ((a * (b ^ -2.0)) + (-1.0 / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.2e-52], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 7.9e-94], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / b), $MachinePrecision] / N[(N[(a * N[Power[b, -2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.2 \cdot 10^{-52}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 7.9 \cdot 10^{-94}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{b}}{a \cdot {b}^{-2} + \frac{-1}{c}}\\
\end{array}
\end{array}
if b < -3.2000000000000001e-52Initial program 62.3%
*-commutative62.3%
Simplified62.3%
Taylor expanded in b around -inf 85.4%
associate-*r/85.4%
mul-1-neg85.4%
Simplified85.4%
if -3.2000000000000001e-52 < b < 7.9e-94Initial program 85.8%
*-commutative85.8%
Simplified85.8%
Taylor expanded in a around inf 79.1%
*-commutative79.1%
associate-*r*79.1%
Simplified79.1%
if 7.9e-94 < b Initial program 18.8%
*-commutative18.8%
Simplified18.8%
Applied egg-rr10.2%
unpow-110.2%
associate-/l*10.2%
Simplified10.2%
Taylor expanded in b around -inf 19.9%
associate-*r*19.9%
neg-mul-119.9%
Simplified19.9%
*-un-lft-identity19.9%
add-sqr-sqrt0.0%
sqrt-unprod59.5%
sqr-neg59.5%
sqrt-prod83.9%
add-sqr-sqrt84.2%
div-inv84.2%
pow-flip84.2%
metadata-eval84.2%
inv-pow84.2%
Applied egg-rr84.2%
*-lft-identity84.2%
associate-/r*86.3%
unpow-186.3%
Simplified86.3%
Final simplification84.0%
(FPCore (a b c)
:precision binary64
(if (<= b -5.3e-62)
(/ b (- a))
(if (<= b 2.1e-92)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.3e-62) {
tmp = b / -a;
} else if (b <= 2.1e-92) {
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 <= (-5.3d-62)) then
tmp = b / -a
else if (b <= 2.1d-92) 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 <= -5.3e-62) {
tmp = b / -a;
} else if (b <= 2.1e-92) {
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 <= -5.3e-62: tmp = b / -a elif b <= 2.1e-92: 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 <= -5.3e-62) tmp = Float64(b / Float64(-a)); elseif (b <= 2.1e-92) 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 <= -5.3e-62) tmp = b / -a; elseif (b <= 2.1e-92) 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, -5.3e-62], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 2.1e-92], 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 -5.3 \cdot 10^{-62}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 2.1 \cdot 10^{-92}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.2999999999999997e-62Initial program 62.3%
*-commutative62.3%
Simplified62.3%
Taylor expanded in b around -inf 85.4%
associate-*r/85.4%
mul-1-neg85.4%
Simplified85.4%
if -5.2999999999999997e-62 < b < 2.1e-92Initial program 85.8%
*-commutative85.8%
Simplified85.8%
Taylor expanded in a around inf 79.1%
*-commutative79.1%
associate-*r*79.1%
Simplified79.1%
if 2.1e-92 < b Initial program 18.8%
*-commutative18.8%
Simplified18.8%
Taylor expanded in a around 0 86.0%
associate-*r/86.0%
mul-1-neg86.0%
Simplified86.0%
Final simplification83.9%
(FPCore (a b c)
:precision binary64
(if (<= b -2.4e-120)
(/ b (- a))
(if (<= b 6.2e-93)
(/ (+ b (sqrt (* a (* c -4.0)))) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.4e-120) {
tmp = b / -a;
} else if (b <= 6.2e-93) {
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 <= (-2.4d-120)) then
tmp = b / -a
else if (b <= 6.2d-93) 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 <= -2.4e-120) {
tmp = b / -a;
} else if (b <= 6.2e-93) {
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 <= -2.4e-120: tmp = b / -a elif b <= 6.2e-93: 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 <= -2.4e-120) tmp = Float64(b / Float64(-a)); elseif (b <= 6.2e-93) tmp = Float64(Float64(b + sqrt(Float64(a * Float64(c * -4.0)))) / 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 <= -2.4e-120) tmp = b / -a; elseif (b <= 6.2e-93) 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, -2.4e-120], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 6.2e-93], 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 -2.4 \cdot 10^{-120}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-93}:\\
\;\;\;\;\frac{b + \sqrt{a \cdot \left(c \cdot -4\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.3999999999999999e-120Initial program 65.1%
*-commutative65.1%
Simplified65.1%
Taylor expanded in b around -inf 81.4%
associate-*r/81.4%
mul-1-neg81.4%
Simplified81.4%
if -2.3999999999999999e-120 < b < 6.19999999999999999e-93Initial program 85.3%
*-commutative85.3%
Simplified85.3%
Taylor expanded in a around inf 82.7%
*-commutative82.7%
associate-*r*82.8%
Simplified82.8%
*-commutative82.8%
sqrt-prod48.3%
Applied egg-rr48.3%
*-un-lft-identity48.3%
*-commutative48.3%
times-frac48.3%
metadata-eval48.3%
sub-neg48.3%
*-commutative48.3%
sqrt-unprod82.8%
add-sqr-sqrt27.6%
sqrt-unprod82.0%
sqr-neg82.0%
sqrt-prod55.0%
add-sqr-sqrt81.6%
Applied egg-rr81.6%
*-commutative81.6%
metadata-eval81.6%
times-frac81.6%
*-rgt-identity81.6%
+-commutative81.6%
Simplified81.6%
if 6.19999999999999999e-93 < b Initial program 18.8%
*-commutative18.8%
Simplified18.8%
Taylor expanded in a around 0 86.0%
associate-*r/86.0%
mul-1-neg86.0%
Simplified86.0%
Final simplification83.4%
(FPCore (a b c) :precision binary64 (if (<= b -5e-311) (/ (fabs (- b (* a (/ c b)))) a) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-311) {
tmp = fabs((b - (a * (c / 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 <= (-5d-311)) then
tmp = abs((b - (a * (c / 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 <= -5e-311) {
tmp = Math.abs((b - (a * (c / b)))) / a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-311: tmp = math.fabs((b - (a * (c / b)))) / a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-311) tmp = Float64(abs(Float64(b - Float64(a * Float64(c / b)))) / a); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-311) tmp = abs((b - (a * (c / b)))) / a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-311], N[(N[Abs[N[(b - N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\frac{\left|b - a \cdot \frac{c}{b}\right|}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -5.00000000000023e-311Initial program 68.4%
*-commutative68.4%
Simplified68.4%
Applied egg-rr36.9%
unpow-136.9%
associate-/l*36.9%
Simplified36.9%
Taylor expanded in a around 0 0.9%
mul-1-neg0.9%
unsub-neg0.9%
*-commutative0.9%
Simplified0.9%
clear-num0.9%
inv-pow0.9%
*-commutative0.9%
Applied egg-rr0.9%
unpow-10.9%
*-commutative0.9%
Simplified0.9%
add-sqr-sqrt0.0%
sqrt-unprod44.5%
pow244.5%
associate-/r/44.5%
Applied egg-rr44.5%
unpow244.5%
rem-sqrt-square66.2%
associate-*r*67.8%
*-commutative67.8%
associate-*r/67.8%
*-rgt-identity67.8%
Simplified67.8%
if -5.00000000000023e-311 < b Initial program 38.0%
*-commutative38.0%
Simplified38.0%
Taylor expanded in a around 0 64.5%
associate-*r/64.5%
mul-1-neg64.5%
Simplified64.5%
Final simplification65.9%
(FPCore (a b c) :precision binary64 (if (<= b -5e-311) (/ b (- a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-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 <= (-5d-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 <= -5e-311) {
tmp = b / -a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-311: tmp = b / -a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-311) tmp = Float64(b / Float64(-a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-311) tmp = b / -a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-311], N[(b / (-a)), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.00000000000023e-311Initial program 68.4%
*-commutative68.4%
Simplified68.4%
Taylor expanded in b around -inf 67.4%
associate-*r/67.4%
mul-1-neg67.4%
Simplified67.4%
if -5.00000000000023e-311 < b Initial program 38.0%
*-commutative38.0%
Simplified38.0%
Taylor expanded in a around 0 64.5%
associate-*r/64.5%
mul-1-neg64.5%
Simplified64.5%
Final simplification65.7%
(FPCore (a b c) :precision binary64 (if (<= b 2e+32) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2e+32) {
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+32) 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+32) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2e+32: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2e+32) 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 <= 2e+32) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2e+32], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2 \cdot 10^{+32}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 2.00000000000000011e32Initial program 66.9%
*-commutative66.9%
Simplified66.9%
Taylor expanded in b around -inf 42.9%
associate-*r/42.9%
mul-1-neg42.9%
Simplified42.9%
if 2.00000000000000011e32 < b Initial program 16.1%
*-commutative16.1%
Simplified16.1%
Applied egg-rr5.2%
unpow-15.2%
associate-/l*5.2%
Simplified5.2%
Taylor expanded in b around -inf 25.3%
Final simplification37.3%
(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 50.8%
*-commutative50.8%
Simplified50.8%
Applied egg-rr33.5%
unpow-133.5%
associate-/l*33.5%
Simplified33.5%
Taylor expanded in b around -inf 10.2%
(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 50.8%
*-commutative50.8%
Simplified50.8%
Applied egg-rr33.5%
unpow-133.5%
associate-/l*33.5%
Simplified33.5%
Taylor expanded in a around 0 2.8%
herbie shell --seed 2024137
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))