
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e+162)
(- (/ c b) (/ b a))
(if (<= b 6.6e-135)
(/ (- (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 <= -4.8e+162) {
tmp = (c / b) - (b / a);
} else if (b <= 6.6e-135) {
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 <= (-4.8d+162)) then
tmp = (c / b) - (b / a)
else if (b <= 6.6d-135) 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 <= -4.8e+162) {
tmp = (c / b) - (b / a);
} else if (b <= 6.6e-135) {
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 <= -4.8e+162: tmp = (c / b) - (b / a) elif b <= 6.6e-135: 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 <= -4.8e+162) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 6.6e-135) 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 <= -4.8e+162) tmp = (c / b) - (b / a); elseif (b <= 6.6e-135) 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, -4.8e+162], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.6e-135], 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 -4.8 \cdot 10^{+162}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 6.6 \cdot 10^{-135}:\\
\;\;\;\;\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 < -4.80000000000000018e162Initial program 28.6%
neg-sub028.6%
associate-+l-28.6%
sub0-neg28.6%
neg-mul-128.6%
associate-*l/28.6%
*-commutative28.6%
associate-/r*28.6%
/-rgt-identity28.6%
metadata-eval28.6%
Simplified29.0%
Taylor expanded in b around -inf 98.0%
mul-1-neg98.0%
unsub-neg98.0%
Simplified98.0%
if -4.80000000000000018e162 < b < 6.5999999999999999e-135Initial program 93.2%
if 6.5999999999999999e-135 < b Initial program 16.5%
neg-sub016.5%
associate-+l-16.5%
sub0-neg16.5%
neg-mul-116.5%
associate-*l/16.5%
*-commutative16.5%
associate-/r*16.5%
/-rgt-identity16.5%
metadata-eval16.5%
Simplified16.5%
Taylor expanded in b around inf 81.5%
mul-1-neg81.5%
distribute-neg-frac81.5%
Simplified81.5%
Final simplification89.0%
(FPCore (a b c)
:precision binary64
(if (<= b -1e+133)
(- (/ c b) (/ b a))
(if (<= b 6.6e-135)
(* (- b (sqrt (- (* b b) (* a (* c 4.0))))) (/ -0.5 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e+133) {
tmp = (c / b) - (b / a);
} else if (b <= 6.6e-135) {
tmp = (b - sqrt(((b * b) - (a * (c * 4.0))))) * (-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 <= (-1d+133)) then
tmp = (c / b) - (b / a)
else if (b <= 6.6d-135) then
tmp = (b - sqrt(((b * b) - (a * (c * 4.0d0))))) * ((-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 <= -1e+133) {
tmp = (c / b) - (b / a);
} else if (b <= 6.6e-135) {
tmp = (b - Math.sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e+133: tmp = (c / b) - (b / a) elif b <= 6.6e-135: tmp = (b - math.sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e+133) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 6.6e-135) tmp = Float64(Float64(b - sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 4.0))))) * 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 <= -1e+133) tmp = (c / b) - (b / a); elseif (b <= 6.6e-135) tmp = (b - sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e+133], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.6e-135], N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{+133}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 6.6 \cdot 10^{-135}:\\
\;\;\;\;\left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot \frac{-0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1e133Initial program 41.9%
neg-sub041.9%
associate-+l-41.9%
sub0-neg41.9%
neg-mul-141.9%
associate-*l/41.8%
*-commutative41.8%
associate-/r*41.8%
/-rgt-identity41.8%
metadata-eval41.8%
Simplified42.1%
Taylor expanded in b around -inf 98.3%
mul-1-neg98.3%
unsub-neg98.3%
Simplified98.3%
if -1e133 < b < 6.5999999999999999e-135Initial program 92.7%
neg-sub092.7%
associate-+l-92.7%
sub0-neg92.7%
neg-mul-192.7%
associate-*l/92.5%
*-commutative92.5%
associate-/r*92.5%
/-rgt-identity92.5%
metadata-eval92.5%
Simplified92.5%
fma-udef92.5%
*-commutative92.5%
associate-*r*92.5%
metadata-eval92.5%
distribute-rgt-neg-in92.5%
*-commutative92.5%
distribute-lft-neg-in92.5%
+-commutative92.5%
sub-neg92.5%
*-commutative92.5%
associate-*l*92.5%
Applied egg-rr92.5%
*-commutative92.5%
Simplified92.5%
if 6.5999999999999999e-135 < b Initial program 16.5%
neg-sub016.5%
associate-+l-16.5%
sub0-neg16.5%
neg-mul-116.5%
associate-*l/16.5%
*-commutative16.5%
associate-/r*16.5%
/-rgt-identity16.5%
metadata-eval16.5%
Simplified16.5%
Taylor expanded in b around inf 81.5%
mul-1-neg81.5%
distribute-neg-frac81.5%
Simplified81.5%
Final simplification88.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.42e-108)
(- (/ c b) (/ b a))
(if (<= b 6.6e-135)
(* (/ -0.5 a) (- b (sqrt (* a (* c -4.0)))))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.42e-108) {
tmp = (c / b) - (b / a);
} else if (b <= 6.6e-135) {
tmp = (-0.5 / a) * (b - sqrt((a * (c * -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 <= (-1.42d-108)) then
tmp = (c / b) - (b / a)
else if (b <= 6.6d-135) then
tmp = ((-0.5d0) / a) * (b - sqrt((a * (c * (-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 <= -1.42e-108) {
tmp = (c / b) - (b / a);
} else if (b <= 6.6e-135) {
tmp = (-0.5 / a) * (b - Math.sqrt((a * (c * -4.0))));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.42e-108: tmp = (c / b) - (b / a) elif b <= 6.6e-135: tmp = (-0.5 / a) * (b - math.sqrt((a * (c * -4.0)))) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.42e-108) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 6.6e-135) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(Float64(a * Float64(c * -4.0))))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.42e-108) tmp = (c / b) - (b / a); elseif (b <= 6.6e-135) tmp = (-0.5 / a) * (b - sqrt((a * (c * -4.0)))); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.42e-108], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.6e-135], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.42 \cdot 10^{-108}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 6.6 \cdot 10^{-135}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{a \cdot \left(c \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.42e-108Initial program 73.3%
neg-sub073.3%
associate-+l-73.3%
sub0-neg73.3%
neg-mul-173.3%
associate-*l/73.1%
*-commutative73.1%
associate-/r*73.1%
/-rgt-identity73.1%
metadata-eval73.1%
Simplified73.2%
Taylor expanded in b around -inf 89.7%
mul-1-neg89.7%
unsub-neg89.7%
Simplified89.7%
if -1.42e-108 < b < 6.5999999999999999e-135Initial program 88.0%
neg-sub088.0%
associate-+l-88.0%
sub0-neg88.0%
neg-mul-188.0%
associate-*l/87.9%
*-commutative87.9%
associate-/r*87.9%
/-rgt-identity87.9%
metadata-eval87.9%
Simplified87.9%
Taylor expanded in a around inf 83.0%
*-commutative83.0%
*-commutative83.0%
associate-*r*83.0%
Simplified83.0%
if 6.5999999999999999e-135 < b Initial program 16.5%
neg-sub016.5%
associate-+l-16.5%
sub0-neg16.5%
neg-mul-116.5%
associate-*l/16.5%
*-commutative16.5%
associate-/r*16.5%
/-rgt-identity16.5%
metadata-eval16.5%
Simplified16.5%
Taylor expanded in b around inf 81.5%
mul-1-neg81.5%
distribute-neg-frac81.5%
Simplified81.5%
Final simplification85.0%
(FPCore (a b c)
:precision binary64
(if (<= b -6.8e-109)
(- (/ c b) (/ b a))
(if (<= b 6.6e-135)
(/ (- b (sqrt (* a (* c -4.0)))) (/ a -0.5))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.8e-109) {
tmp = (c / b) - (b / a);
} else if (b <= 6.6e-135) {
tmp = (b - sqrt((a * (c * -4.0)))) / (a / -0.5);
} 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 <= (-6.8d-109)) then
tmp = (c / b) - (b / a)
else if (b <= 6.6d-135) then
tmp = (b - sqrt((a * (c * (-4.0d0))))) / (a / (-0.5d0))
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.8e-109) {
tmp = (c / b) - (b / a);
} else if (b <= 6.6e-135) {
tmp = (b - Math.sqrt((a * (c * -4.0)))) / (a / -0.5);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.8e-109: tmp = (c / b) - (b / a) elif b <= 6.6e-135: tmp = (b - math.sqrt((a * (c * -4.0)))) / (a / -0.5) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.8e-109) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 6.6e-135) tmp = Float64(Float64(b - sqrt(Float64(a * Float64(c * -4.0)))) / Float64(a / -0.5)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.8e-109) tmp = (c / b) - (b / a); elseif (b <= 6.6e-135) tmp = (b - sqrt((a * (c * -4.0)))) / (a / -0.5); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.8e-109], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.6e-135], N[(N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a / -0.5), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.8 \cdot 10^{-109}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 6.6 \cdot 10^{-135}:\\
\;\;\;\;\frac{b - \sqrt{a \cdot \left(c \cdot -4\right)}}{\frac{a}{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -6.80000000000000023e-109Initial program 73.3%
neg-sub073.3%
associate-+l-73.3%
sub0-neg73.3%
neg-mul-173.3%
associate-*l/73.1%
*-commutative73.1%
associate-/r*73.1%
/-rgt-identity73.1%
metadata-eval73.1%
Simplified73.2%
Taylor expanded in b around -inf 89.7%
mul-1-neg89.7%
unsub-neg89.7%
Simplified89.7%
if -6.80000000000000023e-109 < b < 6.5999999999999999e-135Initial program 88.0%
neg-sub088.0%
associate-+l-88.0%
sub0-neg88.0%
neg-mul-188.0%
associate-*l/87.9%
*-commutative87.9%
associate-/r*87.9%
/-rgt-identity87.9%
metadata-eval87.9%
Simplified87.9%
Taylor expanded in a around inf 83.0%
*-commutative83.0%
*-commutative83.0%
associate-*r*83.0%
Simplified83.0%
clear-num83.0%
un-div-inv83.0%
Applied egg-rr83.0%
if 6.5999999999999999e-135 < b Initial program 16.5%
neg-sub016.5%
associate-+l-16.5%
sub0-neg16.5%
neg-mul-116.5%
associate-*l/16.5%
*-commutative16.5%
associate-/r*16.5%
/-rgt-identity16.5%
metadata-eval16.5%
Simplified16.5%
Taylor expanded in b around inf 81.5%
mul-1-neg81.5%
distribute-neg-frac81.5%
Simplified81.5%
Final simplification85.0%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-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 <= (-4d-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 <= -4e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-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 <= -4e-310) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-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 -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 75.9%
neg-sub075.9%
associate-+l-75.9%
sub0-neg75.9%
neg-mul-175.9%
associate-*l/75.7%
*-commutative75.7%
associate-/r*75.7%
/-rgt-identity75.7%
metadata-eval75.7%
Simplified75.8%
Taylor expanded in b around -inf 74.0%
mul-1-neg74.0%
unsub-neg74.0%
Simplified74.0%
if -3.999999999999988e-310 < b Initial program 29.3%
neg-sub029.3%
associate-+l-29.3%
sub0-neg29.3%
neg-mul-129.3%
associate-*l/29.3%
*-commutative29.3%
associate-/r*29.3%
/-rgt-identity29.3%
metadata-eval29.3%
Simplified29.3%
Taylor expanded in b around inf 68.3%
mul-1-neg68.3%
distribute-neg-frac68.3%
Simplified68.3%
Final simplification71.1%
(FPCore (a b c) :precision binary64 (if (<= b 2e+25) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2e+25) {
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 <= 2d+25) 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 <= 2e+25) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2e+25: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2e+25) 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 <= 2e+25) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2e+25], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2 \cdot 10^{+25}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 2.00000000000000018e25Initial program 71.3%
neg-sub071.3%
associate-+l-71.3%
sub0-neg71.3%
neg-mul-171.3%
associate-*l/71.1%
*-commutative71.1%
associate-/r*71.1%
/-rgt-identity71.1%
metadata-eval71.1%
Simplified71.2%
Taylor expanded in b around -inf 53.9%
associate-*r/53.9%
mul-1-neg53.9%
Simplified53.9%
if 2.00000000000000018e25 < b Initial program 10.0%
neg-sub010.0%
associate-+l-10.0%
sub0-neg10.0%
neg-mul-110.0%
associate-*l/10.0%
*-commutative10.0%
associate-/r*10.0%
/-rgt-identity10.0%
metadata-eval10.0%
Simplified10.0%
associate-*r/10.0%
clear-num10.0%
Applied egg-rr10.0%
Taylor expanded in b around -inf 2.6%
mul-1-neg2.6%
unsub-neg2.6%
*-commutative2.6%
associate-/l*2.8%
Simplified2.8%
Taylor expanded in a around inf 31.6%
Final simplification47.1%
(FPCore (a b c) :precision binary64 (if (<= b 1.7e-308) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.7e-308) {
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.7d-308) 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.7e-308) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.7e-308: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.7e-308) 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.7e-308) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.7e-308], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.7 \cdot 10^{-308}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 1.7000000000000002e-308Initial program 75.9%
neg-sub075.9%
associate-+l-75.9%
sub0-neg75.9%
neg-mul-175.9%
associate-*l/75.7%
*-commutative75.7%
associate-/r*75.7%
/-rgt-identity75.7%
metadata-eval75.7%
Simplified75.8%
Taylor expanded in b around -inf 73.7%
associate-*r/73.7%
mul-1-neg73.7%
Simplified73.7%
if 1.7000000000000002e-308 < b Initial program 29.3%
neg-sub029.3%
associate-+l-29.3%
sub0-neg29.3%
neg-mul-129.3%
associate-*l/29.3%
*-commutative29.3%
associate-/r*29.3%
/-rgt-identity29.3%
metadata-eval29.3%
Simplified29.3%
Taylor expanded in b around inf 68.3%
mul-1-neg68.3%
distribute-neg-frac68.3%
Simplified68.3%
Final simplification71.0%
(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 52.6%
neg-sub052.6%
associate-+l-52.6%
sub0-neg52.6%
neg-mul-152.6%
associate-*l/52.5%
*-commutative52.5%
associate-/r*52.5%
/-rgt-identity52.5%
metadata-eval52.5%
Simplified52.6%
associate-*r/52.7%
clear-num52.5%
Applied egg-rr52.5%
Taylor expanded in b around -inf 36.0%
mul-1-neg36.0%
unsub-neg36.0%
*-commutative36.0%
associate-/l*38.0%
Simplified38.0%
Taylor expanded in a around inf 11.8%
Final simplification11.8%
herbie shell --seed 2023261
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))