
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -4e+90)
(- (/ c b) (/ b a))
(if (<= b 7.6e-124)
(/ (- (sqrt (/ 1.0 (/ 1.0 (fma (* c -4.0) a (* b b))))) b) (* 2.0 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e+90) {
tmp = (c / b) - (b / a);
} else if (b <= 7.6e-124) {
tmp = (sqrt((1.0 / (1.0 / fma((c * -4.0), a, (b * b))))) - b) / (2.0 * a);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4e+90) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 7.6e-124) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(1.0 / fma(Float64(c * -4.0), a, Float64(b * b))))) - b) / Float64(2.0 * a)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4e+90], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-124], N[(N[(N[Sqrt[N[(1.0 / N[(1.0 / N[(N[(c * -4.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{+90}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-124}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{\frac{1}{\mathsf{fma}\left(c \cdot -4, a, b \cdot b\right)}}} - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -3.99999999999999987e90Initial program 57.8%
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
mul-1-negN/A
distribute-lft-neg-outN/A
remove-double-negN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
distribute-frac-negN/A
lower-/.f64N/A
lower-neg.f6497.0
Applied rewrites97.0%
Applied rewrites97.0%
if -3.99999999999999987e90 < b < 7.60000000000000025e-124Initial program 73.4%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6473.5
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites73.5%
if 7.60000000000000025e-124 < b Initial program 17.4%
Taylor expanded in a around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6487.9
Applied rewrites87.9%
Final simplification85.8%
(FPCore (a b c)
:precision binary64
(if (<= b -4e+90)
(- (/ c b) (/ b a))
(if (<= b 7.6e-124)
(/ (- (sqrt (fma a (* c -4.0) (* b b))) b) (* 2.0 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e+90) {
tmp = (c / b) - (b / a);
} else if (b <= 7.6e-124) {
tmp = (sqrt(fma(a, (c * -4.0), (b * b))) - b) / (2.0 * a);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4e+90) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 7.6e-124) tmp = Float64(Float64(sqrt(fma(a, Float64(c * -4.0), Float64(b * b))) - b) / Float64(2.0 * a)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4e+90], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-124], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{+90}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-124}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -3.99999999999999987e90Initial program 57.8%
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
mul-1-negN/A
distribute-lft-neg-outN/A
remove-double-negN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
distribute-frac-negN/A
lower-/.f64N/A
lower-neg.f6497.0
Applied rewrites97.0%
Applied rewrites97.0%
if -3.99999999999999987e90 < b < 7.60000000000000025e-124Initial program 73.4%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6473.5
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites73.5%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
remove-double-divN/A
lift-neg.f64N/A
sub-negN/A
lift--.f6473.4
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6473.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.4
Applied rewrites73.4%
if 7.60000000000000025e-124 < b Initial program 17.4%
Taylor expanded in a around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6487.9
Applied rewrites87.9%
(FPCore (a b c)
:precision binary64
(if (<= b -3.6e+90)
(- (/ c b) (/ b a))
(if (<= b 7.6e-124)
(* (- (sqrt (fma (* c -4.0) a (* b b))) b) (/ 0.5 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e+90) {
tmp = (c / b) - (b / a);
} else if (b <= 7.6e-124) {
tmp = (sqrt(fma((c * -4.0), a, (b * b))) - b) * (0.5 / a);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -3.6e+90) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 7.6e-124) tmp = Float64(Float64(sqrt(fma(Float64(c * -4.0), a, Float64(b * b))) - b) * Float64(0.5 / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -3.6e+90], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-124], N[(N[(N[Sqrt[N[(N[(c * -4.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{+90}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-124}:\\
\;\;\;\;\left(\sqrt{\mathsf{fma}\left(c \cdot -4, a, b \cdot b\right)} - b\right) \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -3.6e90Initial program 57.8%
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
mul-1-negN/A
distribute-lft-neg-outN/A
remove-double-negN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
distribute-frac-negN/A
lower-/.f64N/A
lower-neg.f6497.0
Applied rewrites97.0%
Applied rewrites97.0%
if -3.6e90 < b < 7.60000000000000025e-124Initial program 73.4%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6473.3
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6473.3
Applied rewrites73.3%
if 7.60000000000000025e-124 < b Initial program 17.4%
Taylor expanded in a around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6487.9
Applied rewrites87.9%
Final simplification85.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.25e-57)
(- (/ c b) (/ b a))
(if (<= b 7.6e-124)
(/ (- (sqrt (* (* a c) -4.0)) b) (* 2.0 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e-57) {
tmp = (c / b) - (b / a);
} else if (b <= 7.6e-124) {
tmp = (sqrt(((a * c) * -4.0)) - b) / (2.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.25d-57)) then
tmp = (c / b) - (b / a)
else if (b <= 7.6d-124) then
tmp = (sqrt(((a * c) * (-4.0d0))) - b) / (2.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.25e-57) {
tmp = (c / b) - (b / a);
} else if (b <= 7.6e-124) {
tmp = (Math.sqrt(((a * c) * -4.0)) - b) / (2.0 * a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.25e-57: tmp = (c / b) - (b / a) elif b <= 7.6e-124: tmp = (math.sqrt(((a * c) * -4.0)) - b) / (2.0 * a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.25e-57) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 7.6e-124) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -4.0)) - b) / Float64(2.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.25e-57) tmp = (c / b) - (b / a); elseif (b <= 7.6e-124) tmp = (sqrt(((a * c) * -4.0)) - b) / (2.0 * a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.25e-57], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-124], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25 \cdot 10^{-57}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-124}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -4} - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.25e-57Initial program 64.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
mul-1-negN/A
distribute-lft-neg-outN/A
remove-double-negN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
distribute-frac-negN/A
lower-/.f64N/A
lower-neg.f6488.7
Applied rewrites88.7%
Applied rewrites88.7%
if -1.25e-57 < b < 7.60000000000000025e-124Initial program 69.3%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6465.1
Applied rewrites65.1%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6465.1
Applied rewrites65.1%
if 7.60000000000000025e-124 < b Initial program 17.4%
Taylor expanded in a around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6487.9
Applied rewrites87.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.25e-57)
(- (/ c b) (/ b a))
(if (<= b 7.6e-124)
(* (- (sqrt (* (* a c) -4.0)) b) (/ 0.5 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e-57) {
tmp = (c / b) - (b / a);
} else if (b <= 7.6e-124) {
tmp = (sqrt(((a * c) * -4.0)) - b) * (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.25d-57)) then
tmp = (c / b) - (b / a)
else if (b <= 7.6d-124) then
tmp = (sqrt(((a * c) * (-4.0d0))) - b) * (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.25e-57) {
tmp = (c / b) - (b / a);
} else if (b <= 7.6e-124) {
tmp = (Math.sqrt(((a * c) * -4.0)) - b) * (0.5 / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.25e-57: tmp = (c / b) - (b / a) elif b <= 7.6e-124: tmp = (math.sqrt(((a * c) * -4.0)) - b) * (0.5 / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.25e-57) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 7.6e-124) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -4.0)) - b) * 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.25e-57) tmp = (c / b) - (b / a); elseif (b <= 7.6e-124) tmp = (sqrt(((a * c) * -4.0)) - b) * (0.5 / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.25e-57], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e-124], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25 \cdot 10^{-57}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-124}:\\
\;\;\;\;\left(\sqrt{\left(a \cdot c\right) \cdot -4} - b\right) \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.25e-57Initial program 64.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
mul-1-negN/A
distribute-lft-neg-outN/A
remove-double-negN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
distribute-frac-negN/A
lower-/.f64N/A
lower-neg.f6488.7
Applied rewrites88.7%
Applied rewrites88.7%
if -1.25e-57 < b < 7.60000000000000025e-124Initial program 69.3%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6465.1
Applied rewrites65.1%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6465.1
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6465.1
Applied rewrites65.1%
if 7.60000000000000025e-124 < b Initial program 17.4%
Taylor expanded in a around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6487.9
Applied rewrites87.9%
Final simplification83.0%
(FPCore (a b c) :precision binary64 (if (<= b 1.04e-240) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.04e-240) {
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.04d-240) 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.04e-240) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.04e-240: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.04e-240) 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.04e-240) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.04e-240], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.04 \cdot 10^{-240}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 1.04e-240Initial program 67.7%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6468.0
Applied rewrites68.0%
if 1.04e-240 < b Initial program 23.3%
Taylor expanded in a around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6478.3
Applied rewrites78.3%
(FPCore (a b c) :precision binary64 (if (<= b 8.5e+26) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 8.5e+26) {
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 <= 8.5d+26) 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 <= 8.5e+26) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 8.5e+26: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 8.5e+26) tmp = Float64(Float64(-b) / a); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 8.5e+26) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 8.5e+26], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8.5 \cdot 10^{+26}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 8.5e26Initial program 60.6%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6450.0
Applied rewrites50.0%
if 8.5e26 < b Initial program 13.0%
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
mul-1-negN/A
distribute-lft-neg-outN/A
remove-double-negN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
distribute-frac-negN/A
lower-/.f64N/A
lower-neg.f642.3
Applied rewrites2.3%
Taylor expanded in a around inf
Applied rewrites28.2%
(FPCore (a b c) :precision binary64 (/ c b))
double code(double a, double b, double c) {
return c / b;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c / b
end function
public static double code(double a, double b, double c) {
return c / b;
}
def code(a, b, c): return c / b
function code(a, b, c) return Float64(c / b) end
function tmp = code(a, b, c) tmp = c / b; end
code[a_, b_, c_] := N[(c / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b}
\end{array}
Initial program 44.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
mul-1-negN/A
distribute-lft-neg-outN/A
remove-double-negN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
distribute-frac-negN/A
lower-/.f64N/A
lower-neg.f6433.6
Applied rewrites33.6%
Taylor expanded in a around inf
Applied rewrites11.6%
(FPCore (a b c) :precision binary64 (/ b a))
double code(double a, double b, double c) {
return b / a;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = b / a
end function
public static double code(double a, double b, double c) {
return b / a;
}
def code(a, b, c): return b / a
function code(a, b, c) return Float64(b / a) end
function tmp = code(a, b, c) tmp = b / a; end
code[a_, b_, c_] := N[(b / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{a}
\end{array}
Initial program 44.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
mul-1-negN/A
distribute-lft-neg-outN/A
remove-double-negN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
distribute-frac-negN/A
lower-/.f64N/A
lower-neg.f6433.6
Applied rewrites33.6%
Applied rewrites2.3%
Taylor expanded in a around 0
Applied rewrites2.6%
herbie shell --seed 2024332
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))