
(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.15e+47)
(- (/ c b) (/ b a))
(if (<= b 3.5e-117)
(/ 0.5 (/ a (- (sqrt (fma a (* c -4.0) (pow b 2.0))) b)))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.15e+47) {
tmp = (c / b) - (b / a);
} else if (b <= 3.5e-117) {
tmp = 0.5 / (a / (sqrt(fma(a, (c * -4.0), pow(b, 2.0))) - b));
} else {
tmp = c / -b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.15e+47) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.5e-117) tmp = Float64(0.5 / Float64(a / Float64(sqrt(fma(a, Float64(c * -4.0), (b ^ 2.0))) - b))); else tmp = Float64(c / Float64(-b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.15e+47], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.5e-117], N[(0.5 / N[(a / N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.15 \cdot 10^{+47}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-117}:\\
\;\;\;\;\frac{0.5}{\frac{a}{\sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)} - b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.14999999999999997e47Initial program 55.4%
*-commutative55.4%
Simplified55.4%
Taylor expanded in b around -inf 98.4%
mul-1-neg98.4%
distribute-rgt-neg-in98.4%
+-commutative98.4%
mul-1-neg98.4%
unsub-neg98.4%
Simplified98.4%
Taylor expanded in a around inf 98.6%
if -2.14999999999999997e47 < b < 3.4999999999999998e-117Initial program 80.3%
*-commutative80.3%
Simplified80.3%
Applied egg-rr82.4%
sub-neg82.4%
distribute-rgt-out--82.4%
Simplified82.4%
associate-*l/82.7%
clear-num82.5%
*-commutative82.5%
Applied egg-rr82.5%
associate-/r/82.4%
Applied egg-rr82.4%
associate-*r*82.4%
associate-/r/82.5%
associate-*l/82.5%
metadata-eval82.5%
Simplified82.5%
if 3.4999999999999998e-117 < b Initial program 14.7%
*-commutative14.7%
Simplified14.7%
Taylor expanded in b around inf 87.7%
associate-*r/87.7%
mul-1-neg87.7%
Simplified87.7%
Final simplification88.9%
(FPCore (a b c)
:precision binary64
(if (<= b -4.7e+79)
(- (/ c b) (/ b a))
(if (<= b 3.5e-117)
(* (- (sqrt (fma a (* c -4.0) (pow b 2.0))) b) (/ 0.5 a))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.7e+79) {
tmp = (c / b) - (b / a);
} else if (b <= 3.5e-117) {
tmp = (sqrt(fma(a, (c * -4.0), pow(b, 2.0))) - b) * (0.5 / a);
} else {
tmp = c / -b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.7e+79) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.5e-117) tmp = Float64(Float64(sqrt(fma(a, Float64(c * -4.0), (b ^ 2.0))) - b) * Float64(0.5 / a)); else tmp = Float64(c / Float64(-b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.7e+79], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.5e-117], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[Power[b, 2.0], $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 -4.7 \cdot 10^{+79}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-117}:\\
\;\;\;\;\left(\sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)} - b\right) \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -4.70000000000000023e79Initial program 54.0%
*-commutative54.0%
Simplified54.0%
Taylor expanded in b around -inf 98.4%
mul-1-neg98.4%
distribute-rgt-neg-in98.4%
+-commutative98.4%
mul-1-neg98.4%
unsub-neg98.4%
Simplified98.4%
Taylor expanded in a around inf 98.6%
if -4.70000000000000023e79 < b < 3.4999999999999998e-117Initial program 80.7%
*-commutative80.7%
Simplified80.7%
Applied egg-rr82.8%
sub-neg82.8%
distribute-rgt-out--82.8%
Simplified82.8%
if 3.4999999999999998e-117 < b Initial program 14.7%
*-commutative14.7%
Simplified14.7%
Taylor expanded in b around inf 87.7%
associate-*r/87.7%
mul-1-neg87.7%
Simplified87.7%
Final simplification88.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.85e+153)
(- (/ c b) (/ b a))
(if (<= b 1.9e-117)
(/ (- (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 <= -1.85e+153) {
tmp = (c / b) - (b / a);
} else if (b <= 1.9e-117) {
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 <= -1.85e+153) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.9e-117) tmp = Float64(Float64(sqrt(fma(a, Float64(c * -4.0), Float64(b * b))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.85e+153], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.9e-117], 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 -1.85 \cdot 10^{+153}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-117}:\\
\;\;\;\;\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 < -1.8500000000000001e153Initial program 38.6%
*-commutative38.6%
Simplified38.6%
Taylor expanded in b around -inf 97.9%
mul-1-neg97.9%
distribute-rgt-neg-in97.9%
+-commutative97.9%
mul-1-neg97.9%
unsub-neg97.9%
Simplified97.9%
Taylor expanded in a around inf 98.1%
if -1.8500000000000001e153 < b < 1.89999999999999986e-117Initial program 83.8%
*-commutative83.8%
Simplified84.9%
if 1.89999999999999986e-117 < b Initial program 14.7%
*-commutative14.7%
Simplified14.7%
Taylor expanded in b around inf 87.7%
associate-*r/87.7%
mul-1-neg87.7%
Simplified87.7%
Final simplification88.5%
(FPCore (a b c)
:precision binary64
(if (<= b -3e+153)
(- (/ c b) (/ b a))
(if (<= b 3.5e-117)
(/ (- (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 <= -3e+153) {
tmp = (c / b) - (b / a);
} else if (b <= 3.5e-117) {
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 <= (-3d+153)) then
tmp = (c / b) - (b / a)
else if (b <= 3.5d-117) 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 <= -3e+153) {
tmp = (c / b) - (b / a);
} else if (b <= 3.5e-117) {
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 <= -3e+153: tmp = (c / b) - (b / a) elif b <= 3.5e-117: 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 <= -3e+153) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.5e-117) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3e+153) tmp = (c / b) - (b / a); elseif (b <= 3.5e-117) 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, -3e+153], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.5e-117], 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 -3 \cdot 10^{+153}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-117}:\\
\;\;\;\;\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 < -3.00000000000000019e153Initial program 38.6%
*-commutative38.6%
Simplified38.6%
Taylor expanded in b around -inf 97.9%
mul-1-neg97.9%
distribute-rgt-neg-in97.9%
+-commutative97.9%
mul-1-neg97.9%
unsub-neg97.9%
Simplified97.9%
Taylor expanded in a around inf 98.1%
if -3.00000000000000019e153 < b < 3.4999999999999998e-117Initial program 83.8%
if 3.4999999999999998e-117 < b Initial program 14.7%
*-commutative14.7%
Simplified14.7%
Taylor expanded in b around inf 87.7%
associate-*r/87.7%
mul-1-neg87.7%
Simplified87.7%
Final simplification88.1%
(FPCore (a b c)
:precision binary64
(if (<= b -9.5e-110)
(- (/ c b) (/ b a))
(if (<= b 3.5e-117)
(* (/ 0.5 a) (- (sqrt (* -4.0 (* a c))) b))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.5e-110) {
tmp = (c / b) - (b / a);
} else if (b <= 3.5e-117) {
tmp = (0.5 / a) * (sqrt((-4.0 * (a * c))) - b);
} 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 <= (-9.5d-110)) then
tmp = (c / b) - (b / a)
else if (b <= 3.5d-117) then
tmp = (0.5d0 / a) * (sqrt(((-4.0d0) * (a * c))) - b)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -9.5e-110) {
tmp = (c / b) - (b / a);
} else if (b <= 3.5e-117) {
tmp = (0.5 / a) * (Math.sqrt((-4.0 * (a * c))) - b);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9.5e-110: tmp = (c / b) - (b / a) elif b <= 3.5e-117: tmp = (0.5 / a) * (math.sqrt((-4.0 * (a * c))) - b) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9.5e-110) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.5e-117) tmp = Float64(Float64(0.5 / a) * Float64(sqrt(Float64(-4.0 * Float64(a * c))) - b)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -9.5e-110) tmp = (c / b) - (b / a); elseif (b <= 3.5e-117) tmp = (0.5 / a) * (sqrt((-4.0 * (a * c))) - b); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9.5e-110], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.5e-117], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(-4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.5 \cdot 10^{-110}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-117}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{-4 \cdot \left(a \cdot c\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -9.50000000000000004e-110Initial program 65.6%
*-commutative65.6%
Simplified65.6%
Taylor expanded in b around -inf 87.1%
mul-1-neg87.1%
distribute-rgt-neg-in87.1%
+-commutative87.1%
mul-1-neg87.1%
unsub-neg87.1%
Simplified87.1%
Taylor expanded in a around inf 87.2%
if -9.50000000000000004e-110 < b < 3.4999999999999998e-117Initial program 76.0%
*-commutative76.0%
Simplified76.0%
Applied egg-rr75.8%
sub-neg75.8%
distribute-rgt-out--75.8%
Simplified75.8%
Taylor expanded in a around inf 74.7%
if 3.4999999999999998e-117 < b Initial program 14.7%
*-commutative14.7%
Simplified14.7%
Taylor expanded in b around inf 87.7%
associate-*r/87.7%
mul-1-neg87.7%
Simplified87.7%
Final simplification84.9%
(FPCore (a b c)
:precision binary64
(if (<= b -9.5e-110)
(- (/ c b) (/ b a))
(if (<= b 3.5e-117)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.5e-110) {
tmp = (c / b) - (b / a);
} else if (b <= 3.5e-117) {
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 <= (-9.5d-110)) then
tmp = (c / b) - (b / a)
else if (b <= 3.5d-117) 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 <= -9.5e-110) {
tmp = (c / b) - (b / a);
} else if (b <= 3.5e-117) {
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 <= -9.5e-110: tmp = (c / b) - (b / a) elif b <= 3.5e-117: 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 <= -9.5e-110) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.5e-117) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -9.5e-110) tmp = (c / b) - (b / a); elseif (b <= 3.5e-117) 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, -9.5e-110], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.5e-117], 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 -9.5 \cdot 10^{-110}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-117}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -9.50000000000000004e-110Initial program 65.6%
*-commutative65.6%
Simplified65.6%
Taylor expanded in b around -inf 87.1%
mul-1-neg87.1%
distribute-rgt-neg-in87.1%
+-commutative87.1%
mul-1-neg87.1%
unsub-neg87.1%
Simplified87.1%
Taylor expanded in a around inf 87.2%
if -9.50000000000000004e-110 < b < 3.4999999999999998e-117Initial program 76.0%
*-commutative76.0%
Simplified76.0%
Taylor expanded in b around 0 74.9%
*-commutative74.9%
associate-*r*74.9%
Simplified74.9%
if 3.4999999999999998e-117 < b Initial program 14.7%
*-commutative14.7%
Simplified14.7%
Taylor expanded in b around inf 87.7%
associate-*r/87.7%
mul-1-neg87.7%
Simplified87.7%
Final simplification85.0%
(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(c / Float64(-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 69.3%
*-commutative69.3%
Simplified69.3%
Taylor expanded in b around -inf 71.2%
mul-1-neg71.2%
distribute-rgt-neg-in71.2%
+-commutative71.2%
mul-1-neg71.2%
unsub-neg71.2%
Simplified71.2%
Taylor expanded in a around inf 72.3%
if -1.999999999999994e-310 < b Initial program 25.8%
*-commutative25.8%
Simplified25.8%
Taylor expanded in b around inf 71.3%
associate-*r/71.3%
mul-1-neg71.3%
Simplified71.3%
Final simplification71.8%
(FPCore (a b c) :precision binary64 (if (<= b 2.8e+67) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.8e+67) {
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 <= 2.8d+67) 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 <= 2.8e+67) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.8e+67: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.8e+67) 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 <= 2.8e+67) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.8e+67], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.8 \cdot 10^{+67}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 2.7999999999999998e67Initial program 59.9%
*-commutative59.9%
Simplified59.9%
Taylor expanded in b around -inf 46.9%
associate-*r/46.9%
mul-1-neg46.9%
Simplified46.9%
if 2.7999999999999998e67 < b Initial program 8.3%
*-commutative8.3%
Simplified8.3%
Taylor expanded in b around -inf 2.5%
mul-1-neg2.5%
distribute-rgt-neg-in2.5%
+-commutative2.5%
mul-1-neg2.5%
unsub-neg2.5%
Simplified2.5%
Taylor expanded in b around 0 36.4%
Final simplification44.1%
(FPCore (a b c) :precision binary64 (if (<= b 5.6e-285) (/ (- b) a) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.6e-285) {
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 <= 5.6d-285) 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 <= 5.6e-285) {
tmp = -b / a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.6e-285: tmp = -b / a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.6e-285) tmp = Float64(Float64(-b) / a); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 5.6e-285) tmp = -b / a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.6e-285], N[((-b) / a), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.6 \cdot 10^{-285}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < 5.59999999999999982e-285Initial program 69.8%
*-commutative69.8%
Simplified69.8%
Taylor expanded in b around -inf 70.7%
associate-*r/70.7%
mul-1-neg70.7%
Simplified70.7%
if 5.59999999999999982e-285 < b Initial program 24.7%
*-commutative24.7%
Simplified24.7%
Taylor expanded in b around inf 72.3%
associate-*r/72.3%
mul-1-neg72.3%
Simplified72.3%
Final simplification71.5%
(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 46.2%
*-commutative46.2%
Simplified46.2%
Applied egg-rr30.0%
unpow-130.0%
Simplified30.0%
Taylor expanded in a around 0 2.4%
Final simplification2.4%
(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 46.2%
*-commutative46.2%
Simplified46.2%
Taylor expanded in b around -inf 34.5%
mul-1-neg34.5%
distribute-rgt-neg-in34.5%
+-commutative34.5%
mul-1-neg34.5%
unsub-neg34.5%
Simplified34.5%
Taylor expanded in b around 0 11.8%
Final simplification11.8%
herbie shell --seed 2024055
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))