
(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 -1e+151)
(/ (- b) a)
(if (<= b 4.2e-277)
(/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (* a 2.0))
(if (<= b 0.045)
(/ (* c -2.0) (+ b (hypot b (sqrt (* a (* c -4.0))))))
(/ (- c) b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e+151) {
tmp = -b / a;
} else if (b <= 4.2e-277) {
tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else if (b <= 0.045) {
tmp = (c * -2.0) / (b + hypot(b, sqrt((a * (c * -4.0)))));
} else {
tmp = -c / b;
}
return tmp;
}
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1e+151) {
tmp = -b / a;
} else if (b <= 4.2e-277) {
tmp = (Math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else if (b <= 0.045) {
tmp = (c * -2.0) / (b + Math.hypot(b, Math.sqrt((a * (c * -4.0)))));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e+151: tmp = -b / a elif b <= 4.2e-277: tmp = (math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0) elif b <= 0.045: tmp = (c * -2.0) / (b + math.hypot(b, math.sqrt((a * (c * -4.0))))) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e+151) tmp = Float64(Float64(-b) / a); elseif (b <= 4.2e-277) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - b) / Float64(a * 2.0)); elseif (b <= 0.045) tmp = Float64(Float64(c * -2.0) / Float64(b + hypot(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 <= -1e+151) tmp = -b / a; elseif (b <= 4.2e-277) tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0); elseif (b <= 0.045) tmp = (c * -2.0) / (b + hypot(b, sqrt((a * (c * -4.0))))); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e+151], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 4.2e-277], 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], If[LessEqual[b, 0.045], N[(N[(c * -2.0), $MachinePrecision] / N[(b + N[Sqrt[b ^ 2 + N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{+151}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 4.2 \cdot 10^{-277}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 0.045:\\
\;\;\;\;\frac{c \cdot -2}{b + \mathsf{hypot}\left(b, \sqrt{a \cdot \left(c \cdot -4\right)}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.00000000000000002e151Initial program 39.7%
Taylor expanded in b around -inf 100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
if -1.00000000000000002e151 < b < 4.1999999999999999e-277Initial program 91.0%
if 4.1999999999999999e-277 < b < 0.044999999999999998Initial program 70.5%
frac-2neg70.5%
div-inv70.5%
Applied egg-rr70.5%
associate-*r*70.4%
*-commutative70.4%
associate-*l*70.5%
*-commutative70.5%
associate-/r*70.5%
metadata-eval70.5%
Simplified70.5%
flip--70.3%
hypot-udef70.3%
hypot-udef70.3%
add-sqr-sqrt70.3%
add-sqr-sqrt70.2%
Applied egg-rr70.2%
associate--r+81.2%
+-inverses81.2%
Simplified81.2%
associate-*l/81.3%
sub0-neg81.3%
Applied egg-rr81.3%
Taylor expanded in a around 0 93.7%
if 0.044999999999999998 < b Initial program 15.3%
Taylor expanded in b around inf 89.3%
associate-*r/89.3%
neg-mul-189.3%
Simplified89.3%
Final simplification92.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1e+148)
(/ (- b) a)
(if (<= b 2.5e-47)
(/ (- (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 <= -1e+148) {
tmp = -b / a;
} else if (b <= 2.5e-47) {
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 <= (-1d+148)) then
tmp = -b / a
else if (b <= 2.5d-47) 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 <= -1e+148) {
tmp = -b / a;
} else if (b <= 2.5e-47) {
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 <= -1e+148: tmp = -b / a elif b <= 2.5e-47: 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 <= -1e+148) tmp = Float64(Float64(-b) / a); elseif (b <= 2.5e-47) 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 <= -1e+148) tmp = -b / a; elseif (b <= 2.5e-47) 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, -1e+148], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 2.5e-47], 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 -1 \cdot 10^{+148}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{-47}:\\
\;\;\;\;\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 < -1e148Initial program 39.7%
Taylor expanded in b around -inf 100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
if -1e148 < b < 2.50000000000000006e-47Initial program 88.9%
if 2.50000000000000006e-47 < b Initial program 18.6%
Taylor expanded in b around inf 85.0%
associate-*r/85.0%
neg-mul-185.0%
Simplified85.0%
Final simplification89.1%
(FPCore (a b c)
:precision binary64
(if (<= b -6e-145)
(- (/ c b) (/ b a))
(if (<= b 1.15e-46)
(* 0.5 (* (sqrt (* a (* c -4.0))) (/ 1.0 a)))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e-145) {
tmp = (c / b) - (b / a);
} else if (b <= 1.15e-46) {
tmp = 0.5 * (sqrt((a * (c * -4.0))) * (1.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 <= (-6d-145)) then
tmp = (c / b) - (b / a)
else if (b <= 1.15d-46) then
tmp = 0.5d0 * (sqrt((a * (c * (-4.0d0)))) * (1.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 <= -6e-145) {
tmp = (c / b) - (b / a);
} else if (b <= 1.15e-46) {
tmp = 0.5 * (Math.sqrt((a * (c * -4.0))) * (1.0 / a));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e-145: tmp = (c / b) - (b / a) elif b <= 1.15e-46: tmp = 0.5 * (math.sqrt((a * (c * -4.0))) * (1.0 / a)) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e-145) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.15e-46) tmp = Float64(0.5 * Float64(sqrt(Float64(a * Float64(c * -4.0))) * Float64(1.0 / a))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6e-145) tmp = (c / b) - (b / a); elseif (b <= 1.15e-46) tmp = 0.5 * (sqrt((a * (c * -4.0))) * (1.0 / a)); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e-145], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.15e-46], N[(0.5 * N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{-145}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{-46}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{a \cdot \left(c \cdot -4\right)} \cdot \frac{1}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.99999999999999985e-145Initial program 74.0%
Taylor expanded in b around -inf 83.1%
+-commutative83.1%
mul-1-neg83.1%
unsub-neg83.1%
Simplified83.1%
if -5.99999999999999985e-145 < b < 1.15e-46Initial program 82.5%
prod-diff82.2%
*-commutative82.2%
fma-def82.2%
associate-+l+82.2%
*-commutative82.2%
distribute-rgt-neg-in82.2%
fma-def82.1%
*-commutative82.1%
distribute-rgt-neg-in82.1%
metadata-eval82.1%
*-commutative82.1%
fma-udef82.2%
distribute-lft-neg-in82.2%
distribute-rgt-neg-in82.2%
fma-def82.1%
Applied egg-rr82.0%
Taylor expanded in b around 0 80.1%
distribute-rgt-out80.4%
metadata-eval80.4%
associate-*r*80.4%
*-commutative80.4%
Applied egg-rr80.4%
if 1.15e-46 < b Initial program 18.6%
Taylor expanded in b around inf 85.0%
associate-*r/85.0%
neg-mul-185.0%
Simplified85.0%
Final simplification83.2%
(FPCore (a b c)
:precision binary64
(if (<= b -0.15)
(- (/ c b) (/ b a))
(if (<= b 1.85e-47)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -0.15) {
tmp = (c / b) - (b / a);
} else if (b <= 1.85e-47) {
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 <= (-0.15d0)) then
tmp = (c / b) - (b / a)
else if (b <= 1.85d-47) 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 <= -0.15) {
tmp = (c / b) - (b / a);
} else if (b <= 1.85e-47) {
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 <= -0.15: tmp = (c / b) - (b / a) elif b <= 1.85e-47: 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 <= -0.15) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.85e-47) 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 <= -0.15) tmp = (c / b) - (b / a); elseif (b <= 1.85e-47) 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, -0.15], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.85e-47], 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 -0.15:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.85 \cdot 10^{-47}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -0.149999999999999994Initial program 66.8%
Taylor expanded in b around -inf 96.1%
+-commutative96.1%
mul-1-neg96.1%
unsub-neg96.1%
Simplified96.1%
if -0.149999999999999994 < b < 1.85e-47Initial program 85.7%
prod-diff85.5%
*-commutative85.5%
fma-def85.5%
associate-+l+85.5%
*-commutative85.5%
distribute-rgt-neg-in85.5%
fma-def85.4%
*-commutative85.4%
distribute-rgt-neg-in85.4%
metadata-eval85.4%
*-commutative85.4%
fma-udef85.5%
distribute-lft-neg-in85.5%
distribute-rgt-neg-in85.5%
fma-def85.4%
Applied egg-rr85.4%
Taylor expanded in b around 0 71.3%
neg-mul-171.3%
unsub-neg71.3%
distribute-rgt-out71.5%
metadata-eval71.5%
associate-*r*71.5%
Simplified71.5%
if 1.85e-47 < b Initial program 18.6%
Taylor expanded in b around inf 85.0%
associate-*r/85.0%
neg-mul-185.0%
Simplified85.0%
Final simplification83.5%
(FPCore (a b c) :precision binary64 (if (<= b -6e-145) (- (/ c b) (/ b a)) (if (<= b 1.7e-47) (* 0.5 (/ (sqrt (* a (* c -4.0))) a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e-145) {
tmp = (c / b) - (b / a);
} else if (b <= 1.7e-47) {
tmp = 0.5 * (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 <= (-6d-145)) then
tmp = (c / b) - (b / a)
else if (b <= 1.7d-47) then
tmp = 0.5d0 * (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 <= -6e-145) {
tmp = (c / b) - (b / a);
} else if (b <= 1.7e-47) {
tmp = 0.5 * (Math.sqrt((a * (c * -4.0))) / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e-145: tmp = (c / b) - (b / a) elif b <= 1.7e-47: tmp = 0.5 * (math.sqrt((a * (c * -4.0))) / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e-145) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.7e-47) tmp = Float64(0.5 * Float64(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 <= -6e-145) tmp = (c / b) - (b / a); elseif (b <= 1.7e-47) tmp = 0.5 * (sqrt((a * (c * -4.0))) / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e-145], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.7e-47], N[(0.5 * N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{-145}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.7 \cdot 10^{-47}:\\
\;\;\;\;0.5 \cdot \frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.99999999999999985e-145Initial program 74.0%
Taylor expanded in b around -inf 83.1%
+-commutative83.1%
mul-1-neg83.1%
unsub-neg83.1%
Simplified83.1%
if -5.99999999999999985e-145 < b < 1.7000000000000001e-47Initial program 82.5%
prod-diff82.2%
*-commutative82.2%
fma-def82.2%
associate-+l+82.2%
*-commutative82.2%
distribute-rgt-neg-in82.2%
fma-def82.1%
*-commutative82.1%
distribute-rgt-neg-in82.1%
metadata-eval82.1%
*-commutative82.1%
fma-udef82.2%
distribute-lft-neg-in82.2%
distribute-rgt-neg-in82.2%
fma-def82.1%
Applied egg-rr82.0%
Taylor expanded in b around 0 80.1%
associate-*l/80.1%
distribute-rgt-out80.3%
metadata-eval80.3%
associate-*r*80.3%
*-lft-identity80.3%
Simplified80.3%
if 1.7000000000000001e-47 < b Initial program 18.6%
Taylor expanded in b around inf 85.0%
associate-*r/85.0%
neg-mul-185.0%
Simplified85.0%
Final simplification83.2%
(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 75.0%
Taylor expanded in b around -inf 70.0%
+-commutative70.0%
mul-1-neg70.0%
unsub-neg70.0%
Simplified70.0%
if -4.999999999999985e-310 < b Initial program 36.9%
Taylor expanded in b around inf 66.1%
associate-*r/66.1%
neg-mul-166.1%
Simplified66.1%
Final simplification68.0%
(FPCore (a b c) :precision binary64 (if (<= b 4.2e-277) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.2e-277) {
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 <= 4.2d-277) 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 <= 4.2e-277) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.2e-277: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.2e-277) 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 <= 4.2e-277) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.2e-277], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.2 \cdot 10^{-277}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 4.1999999999999999e-277Initial program 75.4%
Taylor expanded in b around -inf 68.6%
associate-*r/68.6%
mul-1-neg68.6%
Simplified68.6%
if 4.1999999999999999e-277 < b Initial program 36.0%
Taylor expanded in b around inf 67.0%
associate-*r/67.0%
neg-mul-167.0%
Simplified67.0%
Final simplification67.8%
(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 55.2%
Taylor expanded in b around -inf 34.8%
associate-*r/34.8%
mul-1-neg34.8%
Simplified34.8%
Final simplification34.8%
herbie shell --seed 2023272
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))