
(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 -2.3e+150)
(/ b (- a))
(if (<= b 9.8e-108)
(/ (- (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 <= -2.3e+150) {
tmp = b / -a;
} else if (b <= 9.8e-108) {
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 <= (-2.3d+150)) then
tmp = b / -a
else if (b <= 9.8d-108) 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 <= -2.3e+150) {
tmp = b / -a;
} else if (b <= 9.8e-108) {
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 <= -2.3e+150: tmp = b / -a elif b <= 9.8e-108: 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 <= -2.3e+150) tmp = Float64(b / Float64(-a)); elseif (b <= 9.8e-108) 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 <= -2.3e+150) tmp = b / -a; elseif (b <= 9.8e-108) 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, -2.3e+150], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 9.8e-108], 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 -2.3 \cdot 10^{+150}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 9.8 \cdot 10^{-108}:\\
\;\;\;\;\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 < -2.30000000000000001e150Initial program 44.4%
Taylor expanded in b around -inf 97.9%
mul-1-neg97.9%
distribute-neg-frac297.9%
Simplified97.9%
if -2.30000000000000001e150 < b < 9.7999999999999996e-108Initial program 84.9%
if 9.7999999999999996e-108 < b Initial program 22.9%
Taylor expanded in b around inf 84.2%
mul-1-neg84.2%
distribute-neg-frac284.2%
Simplified84.2%
Final simplification86.8%
(FPCore (a b c) :precision binary64 (if (<= b -1.75e-63) (* b (+ (/ c (pow b 2.0)) (/ -1.0 a))) (if (<= b 2e-114) (/ (- (sqrt (* -4.0 (* a c))) b) (* a 2.0)) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.75e-63) {
tmp = b * ((c / pow(b, 2.0)) + (-1.0 / a));
} else if (b <= 2e-114) {
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 <= (-1.75d-63)) then
tmp = b * ((c / (b ** 2.0d0)) + ((-1.0d0) / a))
else if (b <= 2d-114) 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 <= -1.75e-63) {
tmp = b * ((c / Math.pow(b, 2.0)) + (-1.0 / a));
} else if (b <= 2e-114) {
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 <= -1.75e-63: tmp = b * ((c / math.pow(b, 2.0)) + (-1.0 / a)) elif b <= 2e-114: 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 <= -1.75e-63) tmp = Float64(b * Float64(Float64(c / (b ^ 2.0)) + Float64(-1.0 / a))); elseif (b <= 2e-114) tmp = Float64(Float64(sqrt(Float64(-4.0 * Float64(a * 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 <= -1.75e-63) tmp = b * ((c / (b ^ 2.0)) + (-1.0 / a)); elseif (b <= 2e-114) 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, -1.75e-63], N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e-114], 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 -1.75 \cdot 10^{-63}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-114}:\\
\;\;\;\;\frac{\sqrt{-4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.75000000000000002e-63Initial program 70.4%
Taylor expanded in b around -inf 84.7%
mul-1-neg84.7%
distribute-rgt-neg-in84.7%
+-commutative84.7%
mul-1-neg84.7%
unsub-neg84.7%
Simplified84.7%
if -1.75000000000000002e-63 < b < 2.0000000000000001e-114Initial program 80.2%
Taylor expanded in b around 0 77.3%
if 2.0000000000000001e-114 < b Initial program 23.5%
Taylor expanded in b around inf 82.7%
mul-1-neg82.7%
distribute-neg-frac282.7%
Simplified82.7%
Final simplification82.0%
(FPCore (a b c)
:precision binary64
(if (<= b -7.4e-62)
(* b (+ (/ c (pow b 2.0)) (/ -1.0 a)))
(if (<= b 2.8e-114)
(/ (- (sqrt (* c (* a -4.0))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.4e-62) {
tmp = b * ((c / pow(b, 2.0)) + (-1.0 / a));
} else if (b <= 2.8e-114) {
tmp = (sqrt((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 <= (-7.4d-62)) then
tmp = b * ((c / (b ** 2.0d0)) + ((-1.0d0) / a))
else if (b <= 2.8d-114) then
tmp = (sqrt((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 <= -7.4e-62) {
tmp = b * ((c / Math.pow(b, 2.0)) + (-1.0 / a));
} else if (b <= 2.8e-114) {
tmp = (Math.sqrt((c * (a * -4.0))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.4e-62: tmp = b * ((c / math.pow(b, 2.0)) + (-1.0 / a)) elif b <= 2.8e-114: tmp = (math.sqrt((c * (a * -4.0))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.4e-62) tmp = Float64(b * Float64(Float64(c / (b ^ 2.0)) + Float64(-1.0 / a))); elseif (b <= 2.8e-114) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -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 <= -7.4e-62) tmp = b * ((c / (b ^ 2.0)) + (-1.0 / a)); elseif (b <= 2.8e-114) tmp = (sqrt((c * (a * -4.0))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.4e-62], N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.8e-114], N[(N[(N[Sqrt[N[(c * N[(a * -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 -7.4 \cdot 10^{-62}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\
\mathbf{elif}\;b \leq 2.8 \cdot 10^{-114}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -7.3999999999999996e-62Initial program 70.4%
Taylor expanded in b around -inf 84.7%
mul-1-neg84.7%
distribute-rgt-neg-in84.7%
+-commutative84.7%
mul-1-neg84.7%
unsub-neg84.7%
Simplified84.7%
if -7.3999999999999996e-62 < b < 2.8000000000000001e-114Initial program 80.2%
prod-diff79.8%
*-commutative79.8%
fma-define79.8%
associate-+l+79.8%
fma-define79.8%
*-commutative79.8%
distribute-rgt-neg-in79.8%
fma-define79.7%
*-commutative79.7%
distribute-rgt-neg-in79.7%
metadata-eval79.7%
*-commutative79.7%
fma-undefine79.8%
distribute-lft-neg-in79.8%
distribute-rgt-neg-in79.8%
fma-define79.7%
Applied egg-rr79.7%
Taylor expanded in b around 0 76.9%
mul-1-neg76.9%
unsub-neg76.9%
associate-*r*76.9%
associate-*r*76.9%
distribute-rgt-in77.3%
distribute-rgt-out77.3%
metadata-eval77.3%
*-commutative77.3%
Simplified77.3%
if 2.8000000000000001e-114 < b Initial program 23.5%
Taylor expanded in b around inf 82.7%
mul-1-neg82.7%
distribute-neg-frac282.7%
Simplified82.7%
Final simplification82.0%
(FPCore (a b c) :precision binary64 (if (<= b -2.8e-63) (* b (+ (/ c (pow b 2.0)) (/ -1.0 a))) (if (<= b 2.75e-114) (* (sqrt (* c (* a -4.0))) (/ 0.5 a)) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.8e-63) {
tmp = b * ((c / pow(b, 2.0)) + (-1.0 / a));
} else if (b <= 2.75e-114) {
tmp = sqrt((c * (a * -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 <= (-2.8d-63)) then
tmp = b * ((c / (b ** 2.0d0)) + ((-1.0d0) / a))
else if (b <= 2.75d-114) then
tmp = sqrt((c * (a * (-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 <= -2.8e-63) {
tmp = b * ((c / Math.pow(b, 2.0)) + (-1.0 / a));
} else if (b <= 2.75e-114) {
tmp = Math.sqrt((c * (a * -4.0))) * (0.5 / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.8e-63: tmp = b * ((c / math.pow(b, 2.0)) + (-1.0 / a)) elif b <= 2.75e-114: tmp = math.sqrt((c * (a * -4.0))) * (0.5 / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.8e-63) tmp = Float64(b * Float64(Float64(c / (b ^ 2.0)) + Float64(-1.0 / a))); elseif (b <= 2.75e-114) tmp = Float64(sqrt(Float64(c * Float64(a * -4.0))) * Float64(0.5 / a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.8e-63) tmp = b * ((c / (b ^ 2.0)) + (-1.0 / a)); elseif (b <= 2.75e-114) tmp = sqrt((c * (a * -4.0))) * (0.5 / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.8e-63], N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.75e-114], N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{-63}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\
\mathbf{elif}\;b \leq 2.75 \cdot 10^{-114}:\\
\;\;\;\;\sqrt{c \cdot \left(a \cdot -4\right)} \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.8000000000000002e-63Initial program 70.4%
Taylor expanded in b around -inf 84.7%
mul-1-neg84.7%
distribute-rgt-neg-in84.7%
+-commutative84.7%
mul-1-neg84.7%
unsub-neg84.7%
Simplified84.7%
if -2.8000000000000002e-63 < b < 2.75000000000000005e-114Initial program 80.2%
prod-diff79.8%
*-commutative79.8%
fma-define79.8%
associate-+l+79.8%
fma-define79.8%
*-commutative79.8%
distribute-rgt-neg-in79.8%
fma-define79.7%
*-commutative79.7%
distribute-rgt-neg-in79.7%
metadata-eval79.7%
*-commutative79.7%
fma-undefine79.8%
distribute-lft-neg-in79.8%
distribute-rgt-neg-in79.8%
fma-define79.7%
Applied egg-rr79.7%
Taylor expanded in b around 0 76.6%
associate-*r*76.6%
associate-*r/76.6%
metadata-eval76.6%
associate-*r*76.5%
associate-*r*76.5%
distribute-rgt-in77.0%
distribute-rgt-out77.0%
metadata-eval77.0%
*-commutative77.0%
Simplified77.0%
if 2.75000000000000005e-114 < b Initial program 23.5%
Taylor expanded in b around inf 82.7%
mul-1-neg82.7%
distribute-neg-frac282.7%
Simplified82.7%
Final simplification82.0%
(FPCore (a b c) :precision binary64 (if (<= b -2.7e-77) (/ b (- a)) (if (<= b 2.8e-114) (* (sqrt (* c (* a -4.0))) (/ 0.5 a)) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.7e-77) {
tmp = b / -a;
} else if (b <= 2.8e-114) {
tmp = sqrt((c * (a * -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 <= (-2.7d-77)) then
tmp = b / -a
else if (b <= 2.8d-114) then
tmp = sqrt((c * (a * (-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 <= -2.7e-77) {
tmp = b / -a;
} else if (b <= 2.8e-114) {
tmp = Math.sqrt((c * (a * -4.0))) * (0.5 / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.7e-77: tmp = b / -a elif b <= 2.8e-114: tmp = math.sqrt((c * (a * -4.0))) * (0.5 / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.7e-77) tmp = Float64(b / Float64(-a)); elseif (b <= 2.8e-114) tmp = Float64(sqrt(Float64(c * Float64(a * -4.0))) * Float64(0.5 / a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.7e-77) tmp = b / -a; elseif (b <= 2.8e-114) tmp = sqrt((c * (a * -4.0))) * (0.5 / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.7e-77], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 2.8e-114], N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.7 \cdot 10^{-77}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 2.8 \cdot 10^{-114}:\\
\;\;\;\;\sqrt{c \cdot \left(a \cdot -4\right)} \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.7e-77Initial program 69.7%
Taylor expanded in b around -inf 83.4%
mul-1-neg83.4%
distribute-neg-frac283.4%
Simplified83.4%
if -2.7e-77 < b < 2.8000000000000001e-114Initial program 81.4%
prod-diff81.1%
*-commutative81.1%
fma-define81.1%
associate-+l+81.1%
fma-define81.1%
*-commutative81.1%
distribute-rgt-neg-in81.1%
fma-define81.0%
*-commutative81.0%
distribute-rgt-neg-in81.0%
metadata-eval81.0%
*-commutative81.0%
fma-undefine81.0%
distribute-lft-neg-in81.0%
distribute-rgt-neg-in81.0%
fma-define81.0%
Applied egg-rr81.0%
Taylor expanded in b around 0 77.7%
associate-*r*77.7%
associate-*r/77.7%
metadata-eval77.7%
associate-*r*77.7%
associate-*r*77.7%
distribute-rgt-in78.1%
distribute-rgt-out78.1%
metadata-eval78.1%
*-commutative78.1%
Simplified78.1%
if 2.8000000000000001e-114 < b Initial program 23.5%
Taylor expanded in b around inf 82.7%
mul-1-neg82.7%
distribute-neg-frac282.7%
Simplified82.7%
Final simplification81.8%
(FPCore (a b c) :precision binary64 (if (<= b -3e-68) (/ b (- a)) (if (<= b 1.55e-108) (* 0.5 (sqrt (/ (* c -4.0) a))) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3e-68) {
tmp = b / -a;
} else if (b <= 1.55e-108) {
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 <= (-3d-68)) then
tmp = b / -a
else if (b <= 1.55d-108) 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 <= -3e-68) {
tmp = b / -a;
} else if (b <= 1.55e-108) {
tmp = 0.5 * Math.sqrt(((c * -4.0) / a));
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3e-68: tmp = b / -a elif b <= 1.55e-108: 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 <= -3e-68) tmp = Float64(b / Float64(-a)); elseif (b <= 1.55e-108) tmp = Float64(0.5 * 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 <= -3e-68) tmp = b / -a; elseif (b <= 1.55e-108) tmp = 0.5 * sqrt(((c * -4.0) / a)); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3e-68], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.55e-108], 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 -3 \cdot 10^{-68}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.55 \cdot 10^{-108}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{c \cdot -4}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -3e-68Initial program 70.4%
Taylor expanded in b around -inf 84.3%
mul-1-neg84.3%
distribute-neg-frac284.3%
Simplified84.3%
if -3e-68 < b < 1.55000000000000007e-108Initial program 79.4%
prod-diff78.9%
*-commutative78.9%
fma-define78.9%
associate-+l+78.9%
fma-define78.9%
*-commutative78.9%
distribute-rgt-neg-in78.9%
fma-define78.8%
*-commutative78.8%
distribute-rgt-neg-in78.8%
metadata-eval78.8%
*-commutative78.8%
fma-undefine78.9%
distribute-lft-neg-in78.9%
distribute-rgt-neg-in78.9%
fma-define78.8%
Applied egg-rr78.8%
Taylor expanded in a around inf 44.3%
distribute-rgt-out44.3%
metadata-eval44.3%
Simplified44.3%
if 1.55000000000000007e-108 < b Initial program 22.9%
Taylor expanded in b around inf 84.2%
mul-1-neg84.2%
distribute-neg-frac284.2%
Simplified84.2%
(FPCore (a b c) :precision binary64 (if (<= b 7.4e-305) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.4e-305) {
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 <= 7.4d-305) 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 <= 7.4e-305) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.4e-305: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7.4e-305) 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 <= 7.4e-305) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7.4e-305], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.4 \cdot 10^{-305}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < 7.39999999999999954e-305Initial program 73.9%
Taylor expanded in b around -inf 60.9%
mul-1-neg60.9%
distribute-neg-frac260.9%
Simplified60.9%
if 7.39999999999999954e-305 < b Initial program 35.0%
Taylor expanded in b around inf 66.7%
mul-1-neg66.7%
distribute-neg-frac266.7%
Simplified66.7%
(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 / Float64(-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.3%
Taylor expanded in b around -inf 33.2%
mul-1-neg33.2%
distribute-neg-frac233.2%
Simplified33.2%
herbie shell --seed 2024096
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))