
(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 11 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
(let* ((t_0 (sqrt (fma a (* -4.0 c) (* b b)))))
(if (<= b -2e+106)
(- (/ b a))
(if (<= b 1.35e-91)
(fma (/ t_0 a) 0.5 (/ b (* a -2.0)))
(if (<= b 42000000000.0)
(/ (* 4.0 (* a c)) (* (* a -2.0) (+ b t_0)))
(- (/ c b)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(fma(a, (-4.0 * c), (b * b)));
double tmp;
if (b <= -2e+106) {
tmp = -(b / a);
} else if (b <= 1.35e-91) {
tmp = fma((t_0 / a), 0.5, (b / (a * -2.0)));
} else if (b <= 42000000000.0) {
tmp = (4.0 * (a * c)) / ((a * -2.0) * (b + t_0));
} else {
tmp = -(c / b);
}
return tmp;
}
function code(a, b, c) t_0 = sqrt(fma(a, Float64(-4.0 * c), Float64(b * b))) tmp = 0.0 if (b <= -2e+106) tmp = Float64(-Float64(b / a)); elseif (b <= 1.35e-91) tmp = fma(Float64(t_0 / a), 0.5, Float64(b / Float64(a * -2.0))); elseif (b <= 42000000000.0) tmp = Float64(Float64(4.0 * Float64(a * c)) / Float64(Float64(a * -2.0) * Float64(b + t_0))); else tmp = Float64(-Float64(c / b)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(a * N[(-4.0 * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -2e+106], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.35e-91], N[(N[(t$95$0 / a), $MachinePrecision] * 0.5 + N[(b / N[(a * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 42000000000.0], N[(N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision] / N[(N[(a * -2.0), $MachinePrecision] * N[(b + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(a, -4 \cdot c, b \cdot b\right)}\\
\mathbf{if}\;b \leq -2 \cdot 10^{+106}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-91}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t\_0}{a}, 0.5, \frac{b}{a \cdot -2}\right)\\
\mathbf{elif}\;b \leq 42000000000:\\
\;\;\;\;\frac{4 \cdot \left(a \cdot c\right)}{\left(a \cdot -2\right) \cdot \left(b + t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -2.00000000000000018e106Initial program 50.2%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6492.5
Applied rewrites92.5%
if -2.00000000000000018e106 < b < 1.3499999999999999e-91Initial program 80.5%
Applied rewrites80.5%
Applied rewrites80.6%
if 1.3499999999999999e-91 < b < 4.2e10Initial program 49.2%
Applied rewrites48.8%
Taylor expanded in b around 0
lower-*.f64N/A
*-commutativeN/A
lower-*.f6488.3
Applied rewrites88.3%
if 4.2e10 < b Initial program 12.6%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6491.8
Applied rewrites91.8%
Final simplification87.0%
(FPCore (a b c)
:precision binary64
(if (<= b -2e+106)
(- (/ b a))
(if (<= b 1.65e-91)
(fma (/ (sqrt (fma a (* -4.0 c) (* b b))) a) 0.5 (/ b (* a -2.0)))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e+106) {
tmp = -(b / a);
} else if (b <= 1.65e-91) {
tmp = fma((sqrt(fma(a, (-4.0 * c), (b * b))) / a), 0.5, (b / (a * -2.0)));
} else {
tmp = -(c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2e+106) tmp = Float64(-Float64(b / a)); elseif (b <= 1.65e-91) tmp = fma(Float64(sqrt(fma(a, Float64(-4.0 * c), Float64(b * b))) / a), 0.5, Float64(b / Float64(a * -2.0))); else tmp = Float64(-Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2e+106], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.65e-91], N[(N[(N[Sqrt[N[(a * N[(-4.0 * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision] * 0.5 + N[(b / N[(a * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{+106}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{-91}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\sqrt{\mathsf{fma}\left(a, -4 \cdot c, b \cdot b\right)}}{a}, 0.5, \frac{b}{a \cdot -2}\right)\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -2.00000000000000018e106Initial program 50.2%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6492.5
Applied rewrites92.5%
if -2.00000000000000018e106 < b < 1.65000000000000006e-91Initial program 80.5%
Applied rewrites80.5%
Applied rewrites80.6%
if 1.65000000000000006e-91 < b Initial program 18.9%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6484.7
Applied rewrites84.7%
Final simplification84.5%
(FPCore (a b c)
:precision binary64
(if (<= b -2e+106)
(- (/ b a))
(if (<= b 1.65e-91)
(/ (- (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 <= -2e+106) {
tmp = -(b / a);
} else if (b <= 1.65e-91) {
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 <= (-2d+106)) then
tmp = -(b / a)
else if (b <= 1.65d-91) 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 <= -2e+106) {
tmp = -(b / a);
} else if (b <= 1.65e-91) {
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 <= -2e+106: tmp = -(b / a) elif b <= 1.65e-91: 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 <= -2e+106) tmp = Float64(-Float64(b / a)); elseif (b <= 1.65e-91) 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 <= -2e+106) tmp = -(b / a); elseif (b <= 1.65e-91) 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, -2e+106], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.65e-91], 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 -2 \cdot 10^{+106}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{-91}:\\
\;\;\;\;\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 < -2.00000000000000018e106Initial program 50.2%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6492.5
Applied rewrites92.5%
if -2.00000000000000018e106 < b < 1.65000000000000006e-91Initial program 80.5%
if 1.65000000000000006e-91 < b Initial program 18.9%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6484.7
Applied rewrites84.7%
Final simplification84.5%
(FPCore (a b c)
:precision binary64
(if (<= b -2.3e+106)
(- (/ b a))
(if (<= b 1.65e-91)
(* (/ -0.5 a) (- b (sqrt (fma a (* -4.0 c) (* b b)))))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.3e+106) {
tmp = -(b / a);
} else if (b <= 1.65e-91) {
tmp = (-0.5 / a) * (b - sqrt(fma(a, (-4.0 * c), (b * b))));
} else {
tmp = -(c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.3e+106) tmp = Float64(-Float64(b / a)); elseif (b <= 1.65e-91) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(fma(a, Float64(-4.0 * c), Float64(b * b))))); else tmp = Float64(-Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.3e+106], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.65e-91], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(a * N[(-4.0 * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.3 \cdot 10^{+106}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{-91}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{\mathsf{fma}\left(a, -4 \cdot c, b \cdot b\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -2.3000000000000002e106Initial program 50.2%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6492.5
Applied rewrites92.5%
if -2.3000000000000002e106 < b < 1.65000000000000006e-91Initial program 80.5%
Applied rewrites80.5%
if 1.65000000000000006e-91 < b Initial program 18.9%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6484.7
Applied rewrites84.7%
Final simplification84.4%
(FPCore (a b c)
:precision binary64
(if (<= b -2.2e-86)
(- (/ c b) (/ b a))
(if (<= b 1.65e-91)
(/ (- b (sqrt (* a (* -4.0 c)))) (* a -2.0))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.2e-86) {
tmp = (c / b) - (b / a);
} else if (b <= 1.65e-91) {
tmp = (b - sqrt((a * (-4.0 * c)))) / (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.2d-86)) then
tmp = (c / b) - (b / a)
else if (b <= 1.65d-91) then
tmp = (b - sqrt((a * ((-4.0d0) * c)))) / (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.2e-86) {
tmp = (c / b) - (b / a);
} else if (b <= 1.65e-91) {
tmp = (b - Math.sqrt((a * (-4.0 * c)))) / (a * -2.0);
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.2e-86: tmp = (c / b) - (b / a) elif b <= 1.65e-91: tmp = (b - math.sqrt((a * (-4.0 * c)))) / (a * -2.0) else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.2e-86) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.65e-91) tmp = Float64(Float64(b - sqrt(Float64(a * Float64(-4.0 * c)))) / 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.2e-86) tmp = (c / b) - (b / a); elseif (b <= 1.65e-91) tmp = (b - sqrt((a * (-4.0 * c)))) / (a * -2.0); else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.2e-86], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.65e-91], N[(N[(b - N[Sqrt[N[(a * N[(-4.0 * c), $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.2 \cdot 10^{-86}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{-91}:\\
\;\;\;\;\frac{b - \sqrt{a \cdot \left(-4 \cdot c\right)}}{a \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -2.2000000000000002e-86Initial program 68.4%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-*l/N/A
*-lft-identityN/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6480.4
Applied rewrites80.4%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6480.4
Applied rewrites80.4%
if -2.2000000000000002e-86 < b < 1.65000000000000006e-91Initial program 74.2%
Applied rewrites74.1%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6471.6
Applied rewrites71.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
*-commutativeN/A
lift-/.f64N/A
metadata-evalN/A
associate-/r*N/A
*-commutativeN/A
lift-*.f64N/A
un-div-invN/A
lower-/.f6471.6
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.8
Applied rewrites71.8%
if 1.65000000000000006e-91 < b Initial program 18.9%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6484.7
Applied rewrites84.7%
Final simplification79.7%
(FPCore (a b c)
:precision binary64
(if (<= b -2.2e-86)
(- (/ c b) (/ b a))
(if (<= b 1.65e-91)
(* (/ -0.5 a) (- b (sqrt (* c (* a -4.0)))))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.2e-86) {
tmp = (c / b) - (b / a);
} else if (b <= 1.65e-91) {
tmp = (-0.5 / a) * (b - sqrt((c * (a * -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 <= (-2.2d-86)) then
tmp = (c / b) - (b / a)
else if (b <= 1.65d-91) then
tmp = ((-0.5d0) / a) * (b - sqrt((c * (a * (-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 <= -2.2e-86) {
tmp = (c / b) - (b / a);
} else if (b <= 1.65e-91) {
tmp = (-0.5 / a) * (b - Math.sqrt((c * (a * -4.0))));
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.2e-86: tmp = (c / b) - (b / a) elif b <= 1.65e-91: tmp = (-0.5 / a) * (b - math.sqrt((c * (a * -4.0)))) else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.2e-86) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.65e-91) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(Float64(c * Float64(a * -4.0))))); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.2e-86) tmp = (c / b) - (b / a); elseif (b <= 1.65e-91) tmp = (-0.5 / a) * (b - sqrt((c * (a * -4.0)))); else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.2e-86], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.65e-91], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.2 \cdot 10^{-86}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{-91}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{c \cdot \left(a \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -2.2000000000000002e-86Initial program 68.4%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-*l/N/A
*-lft-identityN/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6480.4
Applied rewrites80.4%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6480.4
Applied rewrites80.4%
if -2.2000000000000002e-86 < b < 1.65000000000000006e-91Initial program 74.2%
Applied rewrites74.1%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6471.6
Applied rewrites71.6%
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6471.8
Applied rewrites71.8%
if 1.65000000000000006e-91 < b Initial program 18.9%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6484.7
Applied rewrites84.7%
Final simplification79.7%
(FPCore (a b c)
:precision binary64
(if (<= b -2.2e-86)
(- (/ c b) (/ b a))
(if (<= b 1.65e-91)
(* (/ -0.5 a) (- b (sqrt (* -4.0 (* a c)))))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.2e-86) {
tmp = (c / b) - (b / a);
} else if (b <= 1.65e-91) {
tmp = (-0.5 / a) * (b - sqrt((-4.0 * (a * c))));
} 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.2d-86)) then
tmp = (c / b) - (b / a)
else if (b <= 1.65d-91) then
tmp = ((-0.5d0) / a) * (b - sqrt(((-4.0d0) * (a * c))))
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.2e-86) {
tmp = (c / b) - (b / a);
} else if (b <= 1.65e-91) {
tmp = (-0.5 / a) * (b - Math.sqrt((-4.0 * (a * c))));
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.2e-86: tmp = (c / b) - (b / a) elif b <= 1.65e-91: tmp = (-0.5 / a) * (b - math.sqrt((-4.0 * (a * c)))) else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.2e-86) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.65e-91) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(Float64(-4.0 * Float64(a * c))))); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.2e-86) tmp = (c / b) - (b / a); elseif (b <= 1.65e-91) tmp = (-0.5 / a) * (b - sqrt((-4.0 * (a * c)))); else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.2e-86], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.65e-91], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(-4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.2 \cdot 10^{-86}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{-91}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{-4 \cdot \left(a \cdot c\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -2.2000000000000002e-86Initial program 68.4%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-*l/N/A
*-lft-identityN/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6480.4
Applied rewrites80.4%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6480.4
Applied rewrites80.4%
if -2.2000000000000002e-86 < b < 1.65000000000000006e-91Initial program 74.2%
Applied rewrites74.1%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6471.6
Applied rewrites71.6%
if 1.65000000000000006e-91 < b Initial program 18.9%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6484.7
Applied rewrites84.7%
Final simplification79.6%
(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.4%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-*l/N/A
*-lft-identityN/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6458.4
Applied rewrites58.4%
Taylor expanded in c around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6459.3
Applied rewrites59.3%
if -4.999999999999985e-310 < b Initial program 32.9%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6467.7
Applied rewrites67.7%
Final simplification63.5%
(FPCore (a b c) :precision binary64 (if (<= b 1.25e-286) (- (/ b a)) (- (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.25e-286) {
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 <= 1.25d-286) 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 <= 1.25e-286) {
tmp = -(b / a);
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.25e-286: tmp = -(b / a) else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.25e-286) 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 <= 1.25e-286) tmp = -(b / a); else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.25e-286], (-N[(b / a), $MachinePrecision]), (-N[(c / b), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.25 \cdot 10^{-286}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.25000000000000009e-286Initial program 69.4%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6457.6
Applied rewrites57.6%
if 1.25000000000000009e-286 < b Initial program 32.1%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6469.2
Applied rewrites69.2%
Final simplification63.3%
(FPCore (a b c) :precision binary64 (if (<= b -4.5e-308) (- (/ b a)) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e-308) {
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 <= (-4.5d-308)) 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 <= -4.5e-308) {
tmp = -(b / a);
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.5e-308: tmp = -(b / a) else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.5e-308) 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 <= -4.5e-308) tmp = -(b / a); else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.5e-308], (-N[(b / a), $MachinePrecision]), 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{-308}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < -4.50000000000000009e-308Initial program 69.2%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6459.3
Applied rewrites59.3%
if -4.50000000000000009e-308 < b Initial program 33.4%
Applied rewrites33.4%
Applied rewrites33.1%
Taylor expanded in c around 0
distribute-rgt-outN/A
metadata-evalN/A
mul0-rgt18.0
Applied rewrites18.0%
Final simplification38.3%
(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 51.0%
Applied rewrites51.0%
Applied rewrites50.9%
Taylor expanded in c around 0
distribute-rgt-outN/A
metadata-evalN/A
mul0-rgt10.5
Applied rewrites10.5%
herbie shell --seed 2024216
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))