
(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
(if (<= b -2.95e+156)
(/ (- b) a)
(if (<= b 2.4e-103)
(- (* (sqrt (fma a (* c -4.0) (pow b 2.0))) (/ 0.5 a)) (/ (/ b 2.0) a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.95e+156) {
tmp = -b / a;
} else if (b <= 2.4e-103) {
tmp = (sqrt(fma(a, (c * -4.0), pow(b, 2.0))) * (0.5 / a)) - ((b / 2.0) / a);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.95e+156) tmp = Float64(Float64(-b) / a); elseif (b <= 2.4e-103) tmp = Float64(Float64(sqrt(fma(a, Float64(c * -4.0), (b ^ 2.0))) * Float64(0.5 / a)) - Float64(Float64(b / 2.0) / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.95e+156], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 2.4e-103], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision] - N[(N[(b / 2.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.95 \cdot 10^{+156}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-103}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)} \cdot \frac{0.5}{a} - \frac{\frac{b}{2}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.9499999999999998e156Initial program 35.9%
*-commutative35.9%
Simplified35.9%
Taylor expanded in b around -inf 100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
if -2.9499999999999998e156 < b < 2.4000000000000002e-103Initial program 84.3%
*-commutative84.3%
Simplified84.3%
Applied egg-rr84.4%
if 2.4000000000000002e-103 < b Initial program 15.5%
*-commutative15.5%
Simplified15.5%
Taylor expanded in b around inf 89.7%
mul-1-neg89.7%
distribute-neg-frac89.7%
Simplified89.7%
Final simplification89.1%
(FPCore (a b c)
:precision binary64
(if (<= b -2.95e+156)
(/ (- b) a)
(if (<= b 7e-103)
(/ (- (sqrt (fma a (* c -4.0) (* b b))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.95e+156) {
tmp = -b / a;
} else if (b <= 7e-103) {
tmp = (sqrt(fma(a, (c * -4.0), (b * b))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.95e+156) tmp = Float64(Float64(-b) / a); elseif (b <= 7e-103) tmp = Float64(Float64(sqrt(fma(a, Float64(c * -4.0), Float64(b * b))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.95e+156], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 7e-103], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[(b * b), $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.95 \cdot 10^{+156}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 7 \cdot 10^{-103}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.9499999999999998e156Initial program 35.9%
*-commutative35.9%
Simplified35.9%
Taylor expanded in b around -inf 100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
if -2.9499999999999998e156 < b < 7.00000000000000032e-103Initial program 84.3%
Simplified84.4%
if 7.00000000000000032e-103 < b Initial program 15.5%
*-commutative15.5%
Simplified15.5%
Taylor expanded in b around inf 89.7%
mul-1-neg89.7%
distribute-neg-frac89.7%
Simplified89.7%
Final simplification89.1%
(FPCore (a b c)
:precision binary64
(if (<= b -2.95e+156)
(/ (- b) a)
(if (<= b 4.5e-103)
(/ (- (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 <= -2.95e+156) {
tmp = -b / a;
} else if (b <= 4.5e-103) {
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 <= (-2.95d+156)) then
tmp = -b / a
else if (b <= 4.5d-103) 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 <= -2.95e+156) {
tmp = -b / a;
} else if (b <= 4.5e-103) {
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 <= -2.95e+156: tmp = -b / a elif b <= 4.5e-103: 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 <= -2.95e+156) tmp = Float64(Float64(-b) / a); elseif (b <= 4.5e-103) 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 <= -2.95e+156) tmp = -b / a; elseif (b <= 4.5e-103) 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, -2.95e+156], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 4.5e-103], 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.95 \cdot 10^{+156}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-103}:\\
\;\;\;\;\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.9499999999999998e156Initial program 35.9%
*-commutative35.9%
Simplified35.9%
Taylor expanded in b around -inf 100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
if -2.9499999999999998e156 < b < 4.5e-103Initial program 84.3%
if 4.5e-103 < b Initial program 15.5%
*-commutative15.5%
Simplified15.5%
Taylor expanded in b around inf 89.7%
mul-1-neg89.7%
distribute-neg-frac89.7%
Simplified89.7%
Final simplification89.1%
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e-15)
(- (/ c b) (/ b a))
(if (<= b 8e-103)
(* (sqrt (* a (* c -4.0))) (* 0.5 (/ 1.0 a)))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-15) {
tmp = (c / b) - (b / a);
} else if (b <= 8e-103) {
tmp = sqrt((a * (c * -4.0))) * (0.5 * (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 <= (-4.6d-15)) then
tmp = (c / b) - (b / a)
else if (b <= 8d-103) then
tmp = sqrt((a * (c * (-4.0d0)))) * (0.5d0 * (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 <= -4.6e-15) {
tmp = (c / b) - (b / a);
} else if (b <= 8e-103) {
tmp = Math.sqrt((a * (c * -4.0))) * (0.5 * (1.0 / a));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.6e-15: tmp = (c / b) - (b / a) elif b <= 8e-103: tmp = math.sqrt((a * (c * -4.0))) * (0.5 * (1.0 / a)) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.6e-15) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 8e-103) tmp = Float64(sqrt(Float64(a * Float64(c * -4.0))) * Float64(0.5 * 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 <= -4.6e-15) tmp = (c / b) - (b / a); elseif (b <= 8e-103) tmp = sqrt((a * (c * -4.0))) * (0.5 * (1.0 / a)); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.6e-15], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e-103], N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.5 * N[(1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \cdot 10^{-15}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 8 \cdot 10^{-103}:\\
\;\;\;\;\sqrt{a \cdot \left(c \cdot -4\right)} \cdot \left(0.5 \cdot \frac{1}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.59999999999999981e-15Initial program 64.1%
*-commutative64.1%
Simplified64.1%
Taylor expanded in b around -inf 95.3%
+-commutative95.3%
mul-1-neg95.3%
unsub-neg95.3%
Simplified95.3%
if -4.59999999999999981e-15 < b < 7.99999999999999966e-103Initial program 79.0%
*-commutative79.0%
Simplified79.0%
prod-diff78.7%
*-commutative78.7%
fma-def78.7%
associate-+l+78.7%
pow278.7%
distribute-lft-neg-in78.7%
*-commutative78.7%
distribute-rgt-neg-in78.7%
metadata-eval78.7%
associate-*r*78.7%
*-commutative78.7%
*-commutative78.7%
fma-udef78.7%
Applied egg-rr78.7%
fma-def78.7%
fma-def78.6%
associate-*l*78.6%
Simplified78.6%
Taylor expanded in b around 0 66.9%
associate-*r*66.9%
distribute-rgt-out67.2%
metadata-eval67.2%
associate-*r*67.3%
*-commutative67.3%
Simplified67.3%
if 7.99999999999999966e-103 < b Initial program 15.5%
*-commutative15.5%
Simplified15.5%
Taylor expanded in b around inf 89.7%
mul-1-neg89.7%
distribute-neg-frac89.7%
Simplified89.7%
Final simplification85.6%
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e-15)
(- (/ c b) (/ b a))
(if (<= b 3.9e-103)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-15) {
tmp = (c / b) - (b / a);
} else if (b <= 3.9e-103) {
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 <= (-4.6d-15)) then
tmp = (c / b) - (b / a)
else if (b <= 3.9d-103) 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 <= -4.6e-15) {
tmp = (c / b) - (b / a);
} else if (b <= 3.9e-103) {
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 <= -4.6e-15: tmp = (c / b) - (b / a) elif b <= 3.9e-103: 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 <= -4.6e-15) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.9e-103) 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 <= -4.6e-15) tmp = (c / b) - (b / a); elseif (b <= 3.9e-103) 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, -4.6e-15], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.9e-103], 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 -4.6 \cdot 10^{-15}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.9 \cdot 10^{-103}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.59999999999999981e-15Initial program 64.1%
*-commutative64.1%
Simplified64.1%
Taylor expanded in b around -inf 95.3%
+-commutative95.3%
mul-1-neg95.3%
unsub-neg95.3%
Simplified95.3%
if -4.59999999999999981e-15 < b < 3.9000000000000002e-103Initial program 79.0%
*-commutative79.0%
Simplified79.0%
prod-diff78.7%
*-commutative78.7%
fma-def78.7%
associate-+l+78.7%
pow278.7%
distribute-lft-neg-in78.7%
*-commutative78.7%
distribute-rgt-neg-in78.7%
metadata-eval78.7%
associate-*r*78.7%
*-commutative78.7%
*-commutative78.7%
fma-udef78.7%
Applied egg-rr78.7%
fma-def78.7%
fma-def78.6%
associate-*l*78.6%
Simplified78.6%
Taylor expanded in b around 0 69.2%
mul-1-neg69.2%
unsub-neg69.2%
distribute-rgt-out69.5%
metadata-eval69.5%
associate-*r*69.6%
*-commutative69.6%
Simplified69.6%
if 3.9000000000000002e-103 < b Initial program 15.5%
*-commutative15.5%
Simplified15.5%
Taylor expanded in b around inf 89.7%
mul-1-neg89.7%
distribute-neg-frac89.7%
Simplified89.7%
Final simplification86.2%
(FPCore (a b c) :precision binary64 (if (<= b -4.6e-15) (- (/ c b) (/ b a)) (if (<= b 3.6e-103) (* 0.5 (/ (sqrt (* a (* c -4.0))) a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e-15) {
tmp = (c / b) - (b / a);
} else if (b <= 3.6e-103) {
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 <= (-4.6d-15)) then
tmp = (c / b) - (b / a)
else if (b <= 3.6d-103) 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 <= -4.6e-15) {
tmp = (c / b) - (b / a);
} else if (b <= 3.6e-103) {
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 <= -4.6e-15: tmp = (c / b) - (b / a) elif b <= 3.6e-103: 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 <= -4.6e-15) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.6e-103) 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 <= -4.6e-15) tmp = (c / b) - (b / a); elseif (b <= 3.6e-103) 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, -4.6e-15], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.6e-103], 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 -4.6 \cdot 10^{-15}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.6 \cdot 10^{-103}:\\
\;\;\;\;0.5 \cdot \frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.59999999999999981e-15Initial program 64.1%
*-commutative64.1%
Simplified64.1%
Taylor expanded in b around -inf 95.3%
+-commutative95.3%
mul-1-neg95.3%
unsub-neg95.3%
Simplified95.3%
if -4.59999999999999981e-15 < b < 3.5999999999999998e-103Initial program 79.0%
*-commutative79.0%
Simplified79.0%
prod-diff78.7%
*-commutative78.7%
fma-def78.7%
associate-+l+78.7%
pow278.7%
distribute-lft-neg-in78.7%
*-commutative78.7%
distribute-rgt-neg-in78.7%
metadata-eval78.7%
associate-*r*78.7%
*-commutative78.7%
*-commutative78.7%
fma-udef78.7%
Applied egg-rr78.7%
fma-def78.7%
fma-def78.6%
associate-*l*78.6%
Simplified78.6%
Taylor expanded in b around 0 66.9%
associate-*l/66.9%
*-lft-identity66.9%
distribute-rgt-out67.2%
metadata-eval67.2%
associate-*r*67.3%
*-commutative67.3%
Simplified67.3%
if 3.5999999999999998e-103 < b Initial program 15.5%
*-commutative15.5%
Simplified15.5%
Taylor expanded in b around inf 89.7%
mul-1-neg89.7%
distribute-neg-frac89.7%
Simplified89.7%
Final simplification85.6%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-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 <= (-2d-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 <= -2e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-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 <= -2e-310) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-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 -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in b around -inf 73.2%
+-commutative73.2%
mul-1-neg73.2%
unsub-neg73.2%
Simplified73.2%
if -1.999999999999994e-310 < b Initial program 27.5%
*-commutative27.5%
Simplified27.5%
Taylor expanded in b around inf 73.4%
mul-1-neg73.4%
distribute-neg-frac73.4%
Simplified73.4%
Final simplification73.3%
(FPCore (a b c) :precision binary64 (if (<= b 1e-13) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1e-13) {
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 <= 1d-13) 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 <= 1e-13) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1e-13: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1e-13) 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 <= 1e-13) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1e-13], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 10^{-13}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1e-13Initial program 67.3%
*-commutative67.3%
Simplified67.3%
Taylor expanded in b around -inf 55.4%
associate-*r/55.4%
mul-1-neg55.4%
Simplified55.4%
if 1e-13 < b Initial program 12.5%
*-commutative12.5%
Simplified12.5%
Applied egg-rr3.4%
Taylor expanded in b around -inf 29.2%
Final simplification46.4%
(FPCore (a b c) :precision binary64 (if (<= b 1.9e-279) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.9e-279) {
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.9d-279) 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.9e-279) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.9e-279: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.9e-279) 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.9e-279) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.9e-279], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.9 \cdot 10^{-279}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 1.90000000000000016e-279Initial program 70.0%
*-commutative70.0%
Simplified70.0%
Taylor expanded in b around -inf 71.3%
associate-*r/71.3%
mul-1-neg71.3%
Simplified71.3%
if 1.90000000000000016e-279 < b Initial program 26.6%
*-commutative26.6%
Simplified26.6%
Taylor expanded in b around inf 75.1%
mul-1-neg75.1%
distribute-neg-frac75.1%
Simplified75.1%
Final simplification73.2%
(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 48.5%
*-commutative48.5%
Simplified48.5%
Applied egg-rr28.4%
Taylor expanded in a around 0 2.3%
Final simplification2.3%
(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 48.5%
*-commutative48.5%
Simplified48.5%
Applied egg-rr28.4%
Taylor expanded in b around -inf 12.0%
Final simplification12.0%
herbie shell --seed 2023339
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))