
(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 -4.8e+72)
(- (/ c b) (/ b a))
(if (<= b 2.8e-74)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.8e+72) {
tmp = (c / b) - (b / a);
} else if (b <= 2.8e-74) {
tmp = (sqrt(((b * b) - (c * (a * 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.8d+72)) then
tmp = (c / b) - (b / a)
else if (b <= 2.8d-74) then
tmp = (sqrt(((b * b) - (c * (a * 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.8e+72) {
tmp = (c / b) - (b / a);
} else if (b <= 2.8e-74) {
tmp = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.8e+72: tmp = (c / b) - (b / a) elif b <= 2.8e-74: tmp = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.8e+72) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 2.8e-74) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 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.8e+72) tmp = (c / b) - (b / a); elseif (b <= 2.8e-74) tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.8e+72], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.8e-74], 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[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8 \cdot 10^{+72}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 2.8 \cdot 10^{-74}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.8000000000000002e72Initial program 55.6%
neg-sub055.6%
associate-+l-55.6%
sub0-neg55.6%
neg-mul-155.6%
associate-*l/55.5%
*-commutative55.5%
associate-/r*55.5%
/-rgt-identity55.5%
metadata-eval55.5%
Simplified55.6%
Taylor expanded in b around -inf 96.9%
mul-1-neg96.9%
unsub-neg96.9%
Simplified96.9%
if -4.8000000000000002e72 < b < 2.79999999999999988e-74Initial program 78.3%
if 2.79999999999999988e-74 < b Initial program 10.0%
neg-sub010.0%
associate-+l-10.0%
sub0-neg10.0%
neg-mul-110.0%
associate-*l/9.9%
*-commutative9.9%
associate-/r*9.9%
/-rgt-identity9.9%
metadata-eval9.9%
Simplified9.9%
Taylor expanded in b around inf 87.1%
mul-1-neg87.1%
distribute-neg-frac87.1%
Simplified87.1%
Final simplification86.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.75e+72)
(- (/ c b) (/ b a))
(if (<= b 1.35e-72)
(* (- b (sqrt (- (* b b) (* a (* c 4.0))))) (/ -0.5 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.75e+72) {
tmp = (c / b) - (b / a);
} else if (b <= 1.35e-72) {
tmp = (b - sqrt(((b * b) - (a * (c * 4.0))))) * (-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 <= (-1.75d+72)) then
tmp = (c / b) - (b / a)
else if (b <= 1.35d-72) then
tmp = (b - sqrt(((b * b) - (a * (c * 4.0d0))))) * ((-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 <= -1.75e+72) {
tmp = (c / b) - (b / a);
} else if (b <= 1.35e-72) {
tmp = (b - Math.sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.75e+72: tmp = (c / b) - (b / a) elif b <= 1.35e-72: tmp = (b - math.sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.75e+72) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.35e-72) tmp = Float64(Float64(b - sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 4.0))))) * 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 <= -1.75e+72) tmp = (c / b) - (b / a); elseif (b <= 1.35e-72) tmp = (b - sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.75e+72], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-72], N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.75 \cdot 10^{+72}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-72}:\\
\;\;\;\;\left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot \frac{-0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.75000000000000005e72Initial program 55.6%
neg-sub055.6%
associate-+l-55.6%
sub0-neg55.6%
neg-mul-155.6%
associate-*l/55.5%
*-commutative55.5%
associate-/r*55.5%
/-rgt-identity55.5%
metadata-eval55.5%
Simplified55.6%
Taylor expanded in b around -inf 96.9%
mul-1-neg96.9%
unsub-neg96.9%
Simplified96.9%
if -1.75000000000000005e72 < b < 1.35e-72Initial program 78.3%
neg-sub078.3%
associate-+l-78.3%
sub0-neg78.3%
neg-mul-178.3%
associate-*l/78.0%
*-commutative78.0%
associate-/r*78.0%
/-rgt-identity78.0%
metadata-eval78.0%
Simplified78.0%
fma-udef78.0%
*-commutative78.0%
associate-*r*78.0%
metadata-eval78.0%
distribute-rgt-neg-in78.0%
*-commutative78.0%
distribute-lft-neg-in78.0%
+-commutative78.0%
sub-neg78.0%
*-commutative78.0%
associate-*l*78.0%
Applied egg-rr78.0%
*-commutative78.0%
Simplified78.0%
if 1.35e-72 < b Initial program 10.0%
neg-sub010.0%
associate-+l-10.0%
sub0-neg10.0%
neg-mul-110.0%
associate-*l/9.9%
*-commutative9.9%
associate-/r*9.9%
/-rgt-identity9.9%
metadata-eval9.9%
Simplified9.9%
Taylor expanded in b around inf 87.1%
mul-1-neg87.1%
distribute-neg-frac87.1%
Simplified87.1%
Final simplification86.1%
(FPCore (a b c)
:precision binary64
(if (<= b -5.4e-52)
(/ (- b) a)
(if (<= b 5.8e-73)
(* (/ -0.5 a) (- b (sqrt (* a (* c -4.0)))))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.4e-52) {
tmp = -b / a;
} else if (b <= 5.8e-73) {
tmp = (-0.5 / a) * (b - sqrt((a * (c * -4.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.4d-52)) then
tmp = -b / a
else if (b <= 5.8d-73) then
tmp = ((-0.5d0) / a) * (b - sqrt((a * (c * (-4.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.4e-52) {
tmp = -b / a;
} else if (b <= 5.8e-73) {
tmp = (-0.5 / a) * (b - Math.sqrt((a * (c * -4.0))));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.4e-52: tmp = -b / a elif b <= 5.8e-73: tmp = (-0.5 / a) * (b - math.sqrt((a * (c * -4.0)))) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.4e-52) tmp = Float64(Float64(-b) / a); elseif (b <= 5.8e-73) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(Float64(a * Float64(c * -4.0))))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.4e-52) tmp = -b / a; elseif (b <= 5.8e-73) tmp = (-0.5 / a) * (b - sqrt((a * (c * -4.0)))); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.4e-52], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 5.8e-73], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.4 \cdot 10^{-52}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-73}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{a \cdot \left(c \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.40000000000000019e-52Initial program 65.2%
neg-sub065.2%
associate-+l-65.2%
sub0-neg65.2%
neg-mul-165.2%
associate-*l/65.0%
*-commutative65.0%
associate-/r*65.0%
/-rgt-identity65.0%
metadata-eval65.0%
Simplified65.1%
Taylor expanded in b around -inf 92.0%
associate-*r/92.0%
mul-1-neg92.0%
Simplified92.0%
if -5.40000000000000019e-52 < b < 5.8e-73Initial program 73.8%
neg-sub073.8%
associate-+l-73.8%
sub0-neg73.8%
neg-mul-173.8%
associate-*l/73.6%
*-commutative73.6%
associate-/r*73.6%
/-rgt-identity73.6%
metadata-eval73.6%
Simplified73.6%
Taylor expanded in a around inf 66.6%
*-commutative66.6%
*-commutative66.6%
associate-*r*66.6%
Simplified66.6%
if 5.8e-73 < b Initial program 10.0%
neg-sub010.0%
associate-+l-10.0%
sub0-neg10.0%
neg-mul-110.0%
associate-*l/9.9%
*-commutative9.9%
associate-/r*9.9%
/-rgt-identity9.9%
metadata-eval9.9%
Simplified9.9%
Taylor expanded in b around inf 87.1%
mul-1-neg87.1%
distribute-neg-frac87.1%
Simplified87.1%
Final simplification82.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.65e-52)
(/ (- b) a)
(if (<= b 3.1e-79)
(/ (* -0.5 (- b (sqrt (* a (* c -4.0))))) a)
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.65e-52) {
tmp = -b / a;
} else if (b <= 3.1e-79) {
tmp = (-0.5 * (b - sqrt((a * (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.65d-52)) then
tmp = -b / a
else if (b <= 3.1d-79) then
tmp = ((-0.5d0) * (b - sqrt((a * (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.65e-52) {
tmp = -b / a;
} else if (b <= 3.1e-79) {
tmp = (-0.5 * (b - Math.sqrt((a * (c * -4.0))))) / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.65e-52: tmp = -b / a elif b <= 3.1e-79: tmp = (-0.5 * (b - math.sqrt((a * (c * -4.0))))) / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.65e-52) tmp = Float64(Float64(-b) / a); elseif (b <= 3.1e-79) tmp = Float64(Float64(-0.5 * Float64(b - sqrt(Float64(a * Float64(c * -4.0))))) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.65e-52) tmp = -b / a; elseif (b <= 3.1e-79) tmp = (-0.5 * (b - sqrt((a * (c * -4.0))))) / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.65e-52], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 3.1e-79], N[(N[(-0.5 * N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.65 \cdot 10^{-52}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 3.1 \cdot 10^{-79}:\\
\;\;\;\;\frac{-0.5 \cdot \left(b - \sqrt{a \cdot \left(c \cdot -4\right)}\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.64999999999999998e-52Initial program 65.2%
neg-sub065.2%
associate-+l-65.2%
sub0-neg65.2%
neg-mul-165.2%
associate-*l/65.0%
*-commutative65.0%
associate-/r*65.0%
/-rgt-identity65.0%
metadata-eval65.0%
Simplified65.1%
Taylor expanded in b around -inf 92.0%
associate-*r/92.0%
mul-1-neg92.0%
Simplified92.0%
if -1.64999999999999998e-52 < b < 3.0999999999999999e-79Initial program 73.8%
neg-sub073.8%
associate-+l-73.8%
sub0-neg73.8%
neg-mul-173.8%
associate-*l/73.6%
*-commutative73.6%
associate-/r*73.6%
/-rgt-identity73.6%
metadata-eval73.6%
Simplified73.6%
Taylor expanded in a around inf 66.6%
*-commutative66.6%
*-commutative66.6%
associate-*r*66.6%
Simplified66.6%
associate-*r/66.8%
Applied egg-rr66.8%
if 3.0999999999999999e-79 < b Initial program 10.0%
neg-sub010.0%
associate-+l-10.0%
sub0-neg10.0%
neg-mul-110.0%
associate-*l/9.9%
*-commutative9.9%
associate-/r*9.9%
/-rgt-identity9.9%
metadata-eval9.9%
Simplified9.9%
Taylor expanded in b around inf 87.1%
mul-1-neg87.1%
distribute-neg-frac87.1%
Simplified87.1%
Final simplification82.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) 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 <= -5e-310) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 69.8%
neg-sub069.8%
associate-+l-69.8%
sub0-neg69.8%
neg-mul-169.8%
associate-*l/69.6%
*-commutative69.6%
associate-/r*69.6%
/-rgt-identity69.6%
metadata-eval69.6%
Simplified69.7%
Taylor expanded in b around -inf 69.6%
mul-1-neg69.6%
unsub-neg69.6%
Simplified69.6%
if -4.999999999999985e-310 < b Initial program 23.3%
neg-sub023.3%
associate-+l-23.3%
sub0-neg23.3%
neg-mul-123.3%
associate-*l/23.2%
*-commutative23.2%
associate-/r*23.2%
/-rgt-identity23.2%
metadata-eval23.2%
Simplified23.2%
Taylor expanded in b around inf 71.6%
mul-1-neg71.6%
distribute-neg-frac71.6%
Simplified71.6%
Final simplification70.6%
(FPCore (a b c) :precision binary64 (if (<= b -2.6e-295) (/ (- b) a) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.6e-295) {
tmp = -b / a;
} else {
tmp = 0.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.6d-295)) then
tmp = -b / a
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.6e-295) {
tmp = -b / a;
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.6e-295: tmp = -b / a else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.6e-295) tmp = Float64(Float64(-b) / a); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.6e-295) tmp = -b / a; else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.6e-295], N[((-b) / a), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.6 \cdot 10^{-295}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < -2.59999999999999985e-295Initial program 69.6%
neg-sub069.6%
associate-+l-69.6%
sub0-neg69.6%
neg-mul-169.6%
associate-*l/69.4%
*-commutative69.4%
associate-/r*69.4%
/-rgt-identity69.4%
metadata-eval69.4%
Simplified69.4%
Taylor expanded in b around -inf 69.8%
associate-*r/69.8%
mul-1-neg69.8%
Simplified69.8%
if -2.59999999999999985e-295 < b Initial program 23.9%
neg-sub023.9%
associate-+l-23.9%
sub0-neg23.9%
neg-mul-123.9%
associate-*l/23.8%
*-commutative23.8%
associate-/r*23.8%
/-rgt-identity23.8%
metadata-eval23.8%
Simplified23.8%
*-commutative23.8%
sub-neg23.8%
distribute-lft-in23.5%
Applied egg-rr23.5%
Taylor expanded in a around 0 19.3%
distribute-rgt-out19.3%
metadata-eval19.3%
metadata-eval19.3%
associate-*l/16.5%
metadata-eval16.5%
mul0-rgt19.3%
Simplified19.3%
Final simplification44.1%
(FPCore (a b c) :precision binary64 (if (<= b 2.3e-254) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.3e-254) {
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 <= 2.3d-254) 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 <= 2.3e-254) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.3e-254: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.3e-254) 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 <= 2.3e-254) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.3e-254], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.3 \cdot 10^{-254}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 2.2999999999999999e-254Initial program 70.7%
neg-sub070.7%
associate-+l-70.7%
sub0-neg70.7%
neg-mul-170.7%
associate-*l/70.4%
*-commutative70.4%
associate-/r*70.4%
/-rgt-identity70.4%
metadata-eval70.4%
Simplified70.5%
Taylor expanded in b around -inf 65.8%
associate-*r/65.8%
mul-1-neg65.8%
Simplified65.8%
if 2.2999999999999999e-254 < b Initial program 19.7%
neg-sub019.7%
associate-+l-19.7%
sub0-neg19.7%
neg-mul-119.7%
associate-*l/19.6%
*-commutative19.6%
associate-/r*19.6%
/-rgt-identity19.6%
metadata-eval19.6%
Simplified19.6%
Taylor expanded in b around inf 75.5%
mul-1-neg75.5%
distribute-neg-frac75.5%
Simplified75.5%
Final simplification70.4%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.0d0
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 46.4%
neg-sub046.4%
associate-+l-46.4%
sub0-neg46.4%
neg-mul-146.4%
associate-*l/46.2%
*-commutative46.2%
associate-/r*46.2%
/-rgt-identity46.2%
metadata-eval46.2%
Simplified46.2%
*-commutative46.2%
sub-neg46.2%
distribute-lft-in46.1%
Applied egg-rr46.1%
Taylor expanded in a around 0 11.2%
distribute-rgt-out11.2%
metadata-eval11.2%
metadata-eval11.2%
associate-*l/9.6%
metadata-eval9.6%
mul0-rgt11.2%
Simplified11.2%
Final simplification11.2%
herbie shell --seed 2023215
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))