
(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 -1e+132)
(/ b (- a))
(if (<= b 6e-118)
(/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e+132) {
tmp = b / -a;
} else if (b <= 6e-118) {
tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - 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 <= (-1d+132)) then
tmp = b / -a
else if (b <= 6d-118) then
tmp = (sqrt(((b * b) - ((a * 4.0d0) * c))) - 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 <= -1e+132) {
tmp = b / -a;
} else if (b <= 6e-118) {
tmp = (Math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e+132: tmp = b / -a elif b <= 6e-118: tmp = (math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e+132) tmp = Float64(b / Float64(-a)); elseif (b <= 6e-118) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - 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 <= -1e+132) tmp = b / -a; elseif (b <= 6e-118) tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e+132], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 6e-118], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $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 \cdot 10^{+132}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-118}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -9.99999999999999991e131Initial program 45.8%
*-commutative45.8%
Simplified45.9%
Taylor expanded in b around -inf 98.1%
associate-*r/98.1%
mul-1-neg98.1%
Simplified98.1%
if -9.99999999999999991e131 < b < 6.00000000000000035e-118Initial program 84.5%
if 6.00000000000000035e-118 < b Initial program 16.9%
*-commutative16.9%
Simplified16.9%
Taylor expanded in a around 0 85.1%
associate-*r/85.1%
mul-1-neg85.1%
Simplified85.1%
Final simplification87.4%
(FPCore (a b c) :precision binary64 (if (<= b -2.3e-130) (- (/ c b) (/ b a)) (if (<= b 1e-117) (/ (- (sqrt (* -4.0 (* a c))) b) (* a 2.0)) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.3e-130) {
tmp = (c / b) - (b / a);
} else if (b <= 1e-117) {
tmp = (sqrt((-4.0 * (a * c))) - 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.3d-130)) then
tmp = (c / b) - (b / a)
else if (b <= 1d-117) then
tmp = (sqrt(((-4.0d0) * (a * c))) - 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.3e-130) {
tmp = (c / b) - (b / a);
} else if (b <= 1e-117) {
tmp = (Math.sqrt((-4.0 * (a * c))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.3e-130: tmp = (c / b) - (b / a) elif b <= 1e-117: tmp = (math.sqrt((-4.0 * (a * c))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.3e-130) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1e-117) tmp = Float64(Float64(sqrt(Float64(-4.0 * Float64(a * c))) - 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 <= -2.3e-130) tmp = (c / b) - (b / a); elseif (b <= 1e-117) tmp = (sqrt((-4.0 * (a * c))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.3e-130], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e-117], N[(N[(N[Sqrt[N[(-4.0 * N[(a * c), $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.3 \cdot 10^{-130}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 10^{-117}:\\
\;\;\;\;\frac{\sqrt{-4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.3000000000000001e-130Initial program 67.6%
*-commutative67.6%
Simplified67.6%
Taylor expanded in b around -inf 83.7%
mul-1-neg83.7%
*-commutative83.7%
distribute-rgt-neg-in83.7%
+-commutative83.7%
mul-1-neg83.7%
unsub-neg83.7%
Simplified83.7%
Taylor expanded in a around inf 84.0%
+-commutative84.0%
mul-1-neg84.0%
unsub-neg84.0%
Applied egg-rr84.0%
if -2.3000000000000001e-130 < b < 1.00000000000000003e-117Initial program 80.4%
*-commutative80.4%
Simplified78.5%
Taylor expanded in a around inf 75.5%
if 1.00000000000000003e-117 < b Initial program 16.9%
*-commutative16.9%
Simplified16.9%
Taylor expanded in a around 0 85.1%
associate-*r/85.1%
mul-1-neg85.1%
Simplified85.1%
Final simplification82.8%
(FPCore (a b c) :precision binary64 (if (<= b -1.95e-131) (- (/ c b) (/ b a)) (if (<= b 5.6e-123) (/ (sqrt (* a (* c -4.0))) (* a 2.0)) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.95e-131) {
tmp = (c / b) - (b / a);
} else if (b <= 5.6e-123) {
tmp = sqrt((a * (c * -4.0))) / (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 <= (-1.95d-131)) then
tmp = (c / b) - (b / a)
else if (b <= 5.6d-123) then
tmp = sqrt((a * (c * (-4.0d0)))) / (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 <= -1.95e-131) {
tmp = (c / b) - (b / a);
} else if (b <= 5.6e-123) {
tmp = Math.sqrt((a * (c * -4.0))) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.95e-131: tmp = (c / b) - (b / a) elif b <= 5.6e-123: tmp = math.sqrt((a * (c * -4.0))) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.95e-131) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 5.6e-123) tmp = Float64(sqrt(Float64(a * Float64(c * -4.0))) / 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 <= -1.95e-131) tmp = (c / b) - (b / a); elseif (b <= 5.6e-123) tmp = sqrt((a * (c * -4.0))) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.95e-131], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-123], N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.95 \cdot 10^{-131}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-123}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.9500000000000001e-131Initial program 68.2%
*-commutative68.2%
Simplified68.3%
Taylor expanded in b around -inf 83.1%
mul-1-neg83.1%
*-commutative83.1%
distribute-rgt-neg-in83.1%
+-commutative83.1%
mul-1-neg83.1%
unsub-neg83.1%
Simplified83.1%
Taylor expanded in a around inf 83.4%
+-commutative83.4%
mul-1-neg83.4%
unsub-neg83.4%
Applied egg-rr83.4%
if -1.9500000000000001e-131 < b < 5.5999999999999998e-123Initial program 79.5%
*-commutative79.5%
Simplified77.6%
fma-undefine77.6%
*-commutative77.6%
associate-*r*79.5%
metadata-eval79.5%
distribute-rgt-neg-in79.5%
*-commutative79.5%
distribute-lft-neg-in79.5%
+-commutative79.5%
sub-neg79.5%
prod-diff79.3%
*-commutative79.3%
fma-define79.3%
associate-+l+79.3%
pow279.3%
distribute-lft-neg-in79.3%
*-commutative79.3%
distribute-rgt-neg-in79.3%
metadata-eval79.3%
associate-*r*77.4%
*-commutative77.4%
Applied egg-rr77.4%
fma-define77.4%
fma-define77.4%
associate-*r*77.4%
Simplified77.4%
Taylor expanded in b around 0 74.1%
distribute-rgt-out74.3%
metadata-eval74.3%
associate-*r*72.3%
Simplified72.3%
if 5.5999999999999998e-123 < b Initial program 16.9%
*-commutative16.9%
Simplified16.9%
Taylor expanded in a around 0 85.1%
associate-*r/85.1%
mul-1-neg85.1%
Simplified85.1%
Final simplification82.1%
(FPCore (a b c) :precision binary64 (if (<= b -1.95e-131) (- (/ c b) (/ b a)) (if (<= b 1e-117) (* (sqrt (* a (* c -4.0))) (/ 0.5 a)) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.95e-131) {
tmp = (c / b) - (b / a);
} else if (b <= 1e-117) {
tmp = sqrt((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 <= (-1.95d-131)) then
tmp = (c / b) - (b / a)
else if (b <= 1d-117) then
tmp = sqrt((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 <= -1.95e-131) {
tmp = (c / b) - (b / a);
} else if (b <= 1e-117) {
tmp = Math.sqrt((a * (c * -4.0))) * (0.5 / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.95e-131: tmp = (c / b) - (b / a) elif b <= 1e-117: tmp = math.sqrt((a * (c * -4.0))) * (0.5 / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.95e-131) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1e-117) tmp = Float64(sqrt(Float64(a * Float64(c * -4.0))) * Float64(0.5 / a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.95e-131) tmp = (c / b) - (b / a); elseif (b <= 1e-117) tmp = sqrt((a * (c * -4.0))) * (0.5 / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.95e-131], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e-117], N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.95 \cdot 10^{-131}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 10^{-117}:\\
\;\;\;\;\sqrt{a \cdot \left(c \cdot -4\right)} \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.9500000000000001e-131Initial program 68.2%
*-commutative68.2%
Simplified68.3%
Taylor expanded in b around -inf 83.1%
mul-1-neg83.1%
*-commutative83.1%
distribute-rgt-neg-in83.1%
+-commutative83.1%
mul-1-neg83.1%
unsub-neg83.1%
Simplified83.1%
Taylor expanded in a around inf 83.4%
+-commutative83.4%
mul-1-neg83.4%
unsub-neg83.4%
Applied egg-rr83.4%
if -1.9500000000000001e-131 < b < 1.00000000000000003e-117Initial program 79.5%
*-commutative79.5%
Simplified77.6%
fma-undefine77.6%
*-commutative77.6%
associate-*r*79.5%
metadata-eval79.5%
distribute-rgt-neg-in79.5%
*-commutative79.5%
distribute-lft-neg-in79.5%
+-commutative79.5%
sub-neg79.5%
prod-diff79.3%
*-commutative79.3%
fma-define79.3%
associate-+l+79.3%
pow279.3%
distribute-lft-neg-in79.3%
*-commutative79.3%
distribute-rgt-neg-in79.3%
metadata-eval79.3%
associate-*r*77.4%
*-commutative77.4%
Applied egg-rr77.4%
fma-define77.4%
fma-define77.4%
associate-*r*77.4%
Simplified77.4%
Taylor expanded in b around 0 73.8%
associate-*r*73.8%
associate-*r/73.8%
metadata-eval73.8%
distribute-rgt-out74.1%
metadata-eval74.1%
associate-*r*72.1%
Simplified72.1%
if 1.00000000000000003e-117 < b Initial program 16.9%
*-commutative16.9%
Simplified16.9%
Taylor expanded in a around 0 85.1%
associate-*r/85.1%
mul-1-neg85.1%
Simplified85.1%
Final simplification82.0%
(FPCore (a b c) :precision binary64 (if (<= b -5.5e-175) (- (/ c b) (/ b a)) (if (<= b 2.9e-234) (* 0.5 (/ 1.0 (sqrt (/ (/ a c) -4.0)))) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-175) {
tmp = (c / b) - (b / a);
} else if (b <= 2.9e-234) {
tmp = 0.5 * (1.0 / 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 <= (-5.5d-175)) then
tmp = (c / b) - (b / a)
else if (b <= 2.9d-234) then
tmp = 0.5d0 * (1.0d0 / 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 <= -5.5e-175) {
tmp = (c / b) - (b / a);
} else if (b <= 2.9e-234) {
tmp = 0.5 * (1.0 / Math.sqrt(((a / c) / -4.0)));
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.5e-175: tmp = (c / b) - (b / a) elif b <= 2.9e-234: tmp = 0.5 * (1.0 / math.sqrt(((a / c) / -4.0))) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.5e-175) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 2.9e-234) tmp = Float64(0.5 * Float64(1.0 / sqrt(Float64(Float64(a / c) / -4.0)))); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.5e-175) tmp = (c / b) - (b / a); elseif (b <= 2.9e-234) tmp = 0.5 * (1.0 / sqrt(((a / c) / -4.0))); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.5e-175], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.9e-234], N[(0.5 * N[(1.0 / N[Sqrt[N[(N[(a / c), $MachinePrecision] / -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{-175}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-234}:\\
\;\;\;\;0.5 \cdot \frac{1}{\sqrt{\frac{\frac{a}{c}}{-4}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -5.50000000000000054e-175Initial program 70.2%
*-commutative70.2%
Simplified70.3%
Taylor expanded in b around -inf 79.9%
mul-1-neg79.9%
*-commutative79.9%
distribute-rgt-neg-in79.9%
+-commutative79.9%
mul-1-neg79.9%
unsub-neg79.9%
Simplified79.9%
Taylor expanded in a around inf 80.1%
+-commutative80.1%
mul-1-neg80.1%
unsub-neg80.1%
Applied egg-rr80.1%
if -5.50000000000000054e-175 < b < 2.90000000000000016e-234Initial program 81.4%
*-commutative81.4%
Simplified77.1%
fma-undefine77.1%
*-commutative77.1%
associate-*r*81.4%
metadata-eval81.4%
distribute-rgt-neg-in81.4%
*-commutative81.4%
distribute-lft-neg-in81.4%
+-commutative81.4%
sub-neg81.4%
prod-diff81.1%
*-commutative81.1%
fma-define81.1%
associate-+l+81.1%
pow281.1%
distribute-lft-neg-in81.1%
*-commutative81.1%
distribute-rgt-neg-in81.1%
metadata-eval81.1%
associate-*r*76.7%
*-commutative76.7%
Applied egg-rr76.7%
fma-define76.7%
fma-define76.7%
associate-*r*76.7%
Simplified76.7%
Taylor expanded in a around inf 31.0%
distribute-rgt-out31.0%
metadata-eval31.0%
associate-/l*31.0%
Simplified31.0%
associate-*r/31.0%
Applied egg-rr31.0%
clear-num31.1%
sqrt-div33.1%
metadata-eval33.1%
Applied egg-rr33.1%
associate-/r*33.1%
Simplified33.1%
if 2.90000000000000016e-234 < b Initial program 24.9%
*-commutative24.9%
Simplified24.9%
Taylor expanded in a around 0 76.4%
associate-*r/76.4%
mul-1-neg76.4%
Simplified76.4%
Final simplification74.4%
(FPCore (a b c) :precision binary64 (if (<= b -6.5e-207) (- (/ c b) (/ b a)) (if (<= b 3.7e-234) (* 0.5 (sqrt (/ 1.0 (/ a (* c -4.0))))) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-207) {
tmp = (c / b) - (b / a);
} else if (b <= 3.7e-234) {
tmp = 0.5 * sqrt((1.0 / (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 <= (-6.5d-207)) then
tmp = (c / b) - (b / a)
else if (b <= 3.7d-234) then
tmp = 0.5d0 * sqrt((1.0d0 / (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 <= -6.5e-207) {
tmp = (c / b) - (b / a);
} else if (b <= 3.7e-234) {
tmp = 0.5 * Math.sqrt((1.0 / (a / (c * -4.0))));
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e-207: tmp = (c / b) - (b / a) elif b <= 3.7e-234: tmp = 0.5 * math.sqrt((1.0 / (a / (c * -4.0)))) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-207) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.7e-234) tmp = Float64(0.5 * sqrt(Float64(1.0 / Float64(a / Float64(c * -4.0))))); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.5e-207) tmp = (c / b) - (b / a); elseif (b <= 3.7e-234) tmp = 0.5 * sqrt((1.0 / (a / (c * -4.0)))); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-207], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.7e-234], N[(0.5 * N[Sqrt[N[(1.0 / 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 -6.5 \cdot 10^{-207}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.7 \cdot 10^{-234}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{\frac{a}{c \cdot -4}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -6.5000000000000001e-207Initial program 70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in b around -inf 77.8%
mul-1-neg77.8%
*-commutative77.8%
distribute-rgt-neg-in77.8%
+-commutative77.8%
mul-1-neg77.8%
unsub-neg77.8%
Simplified77.8%
Taylor expanded in a around inf 78.1%
+-commutative78.1%
mul-1-neg78.1%
unsub-neg78.1%
Applied egg-rr78.1%
if -6.5000000000000001e-207 < b < 3.70000000000000012e-234Initial program 83.8%
*-commutative83.8%
Simplified78.7%
fma-undefine78.7%
*-commutative78.7%
associate-*r*83.8%
metadata-eval83.8%
distribute-rgt-neg-in83.8%
*-commutative83.8%
distribute-lft-neg-in83.8%
+-commutative83.8%
sub-neg83.8%
prod-diff83.6%
*-commutative83.6%
fma-define83.6%
associate-+l+83.6%
pow283.6%
distribute-lft-neg-in83.6%
*-commutative83.6%
distribute-rgt-neg-in83.6%
metadata-eval83.6%
associate-*r*78.5%
*-commutative78.5%
Applied egg-rr78.5%
fma-define78.5%
fma-define78.3%
associate-*r*78.3%
Simplified78.3%
Taylor expanded in a around inf 35.5%
distribute-rgt-out35.5%
metadata-eval35.5%
associate-/l*35.5%
Simplified35.5%
associate-*r/35.5%
clear-num35.6%
Applied egg-rr35.6%
if 3.70000000000000012e-234 < b Initial program 24.9%
*-commutative24.9%
Simplified24.9%
Taylor expanded in a around 0 76.4%
associate-*r/76.4%
mul-1-neg76.4%
Simplified76.4%
Final simplification74.3%
(FPCore (a b c) :precision binary64 (if (<= b -6.5e-207) (- (/ c b) (/ b a)) (if (<= b 3.7e-234) (* 0.5 (sqrt (* c (/ -4.0 a)))) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-207) {
tmp = (c / b) - (b / a);
} else if (b <= 3.7e-234) {
tmp = 0.5 * sqrt((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 <= (-6.5d-207)) then
tmp = (c / b) - (b / a)
else if (b <= 3.7d-234) then
tmp = 0.5d0 * sqrt((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 <= -6.5e-207) {
tmp = (c / b) - (b / a);
} else if (b <= 3.7e-234) {
tmp = 0.5 * Math.sqrt((c * (-4.0 / a)));
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e-207: tmp = (c / b) - (b / a) elif b <= 3.7e-234: tmp = 0.5 * math.sqrt((c * (-4.0 / a))) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-207) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.7e-234) tmp = Float64(0.5 * sqrt(Float64(c * Float64(-4.0 / a)))); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.5e-207) tmp = (c / b) - (b / a); elseif (b <= 3.7e-234) tmp = 0.5 * sqrt((c * (-4.0 / a))); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-207], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.7e-234], N[(0.5 * N[Sqrt[N[(c * N[(-4.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-207}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.7 \cdot 10^{-234}:\\
\;\;\;\;0.5 \cdot \sqrt{c \cdot \frac{-4}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -6.5000000000000001e-207Initial program 70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in b around -inf 77.8%
mul-1-neg77.8%
*-commutative77.8%
distribute-rgt-neg-in77.8%
+-commutative77.8%
mul-1-neg77.8%
unsub-neg77.8%
Simplified77.8%
Taylor expanded in a around inf 78.1%
+-commutative78.1%
mul-1-neg78.1%
unsub-neg78.1%
Applied egg-rr78.1%
if -6.5000000000000001e-207 < b < 3.70000000000000012e-234Initial program 83.8%
*-commutative83.8%
Simplified78.7%
fma-undefine78.7%
*-commutative78.7%
associate-*r*83.8%
metadata-eval83.8%
distribute-rgt-neg-in83.8%
*-commutative83.8%
distribute-lft-neg-in83.8%
+-commutative83.8%
sub-neg83.8%
prod-diff83.6%
*-commutative83.6%
fma-define83.6%
associate-+l+83.6%
pow283.6%
distribute-lft-neg-in83.6%
*-commutative83.6%
distribute-rgt-neg-in83.6%
metadata-eval83.6%
associate-*r*78.5%
*-commutative78.5%
Applied egg-rr78.5%
fma-define78.5%
fma-define78.3%
associate-*r*78.3%
Simplified78.3%
Taylor expanded in a around inf 35.5%
distribute-rgt-out35.5%
metadata-eval35.5%
associate-/l*35.5%
Simplified35.5%
if 3.70000000000000012e-234 < b Initial program 24.9%
*-commutative24.9%
Simplified24.9%
Taylor expanded in a around 0 76.4%
associate-*r/76.4%
mul-1-neg76.4%
Simplified76.4%
Final simplification74.3%
(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 70.8%
*-commutative70.8%
Simplified70.8%
Taylor expanded in b around -inf 72.3%
mul-1-neg72.3%
*-commutative72.3%
distribute-rgt-neg-in72.3%
+-commutative72.3%
mul-1-neg72.3%
unsub-neg72.3%
Simplified72.3%
Taylor expanded in a around inf 72.7%
+-commutative72.7%
mul-1-neg72.7%
unsub-neg72.7%
Applied egg-rr72.7%
if -1.999999999999994e-310 < b Initial program 29.1%
*-commutative29.1%
Simplified28.5%
Taylor expanded in a around 0 71.6%
associate-*r/71.6%
mul-1-neg71.6%
Simplified71.6%
Final simplification72.1%
(FPCore (a b c) :precision binary64 (if (<= b 1.55e-307) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.55e-307) {
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.55d-307) 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.55e-307) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.55e-307: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.55e-307) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.55e-307) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.55e-307], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.55 \cdot 10^{-307}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < 1.5499999999999999e-307Initial program 70.8%
*-commutative70.8%
Simplified70.8%
Taylor expanded in b around -inf 72.6%
associate-*r/72.6%
mul-1-neg72.6%
Simplified72.6%
if 1.5499999999999999e-307 < b Initial program 29.1%
*-commutative29.1%
Simplified28.5%
Taylor expanded in a around 0 71.6%
associate-*r/71.6%
mul-1-neg71.6%
Simplified71.6%
Final simplification72.1%
(FPCore (a b c) :precision binary64 (if (<= b 1.4e-170) (/ b (- a)) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.4e-170) {
tmp = b / -a;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.4d-170) then
tmp = b / -a
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.4e-170) {
tmp = b / -a;
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.4e-170: tmp = b / -a else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.4e-170) tmp = Float64(b / Float64(-a)); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.4e-170) tmp = b / -a; else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.4e-170], N[(b / (-a)), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.4 \cdot 10^{-170}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < 1.39999999999999998e-170Initial program 71.9%
*-commutative71.9%
Simplified71.3%
Taylor expanded in b around -inf 63.7%
associate-*r/63.7%
mul-1-neg63.7%
Simplified63.7%
if 1.39999999999999998e-170 < b Initial program 21.4%
*-commutative21.4%
Simplified21.4%
add-cube-cbrt21.3%
pow321.3%
associate-*l*21.3%
Applied egg-rr21.3%
clear-num21.3%
inv-pow21.3%
neg-mul-121.3%
fma-define21.3%
pow221.3%
unpow321.3%
add-cube-cbrt21.5%
associate-*r*21.5%
*-commutative21.5%
Applied egg-rr21.5%
unpow-121.5%
associate-/l*21.4%
Simplified21.4%
Taylor expanded in a around 0 21.9%
associate-*r/21.9%
distribute-rgt1-in21.9%
metadata-eval21.9%
mul0-lft21.9%
metadata-eval21.9%
Simplified21.9%
Taylor expanded in a around 0 21.9%
Final simplification44.6%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.0d0
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 48.8%
*-commutative48.8%
Simplified48.8%
add-cube-cbrt48.6%
pow348.6%
associate-*l*48.6%
Applied egg-rr48.6%
clear-num48.5%
inv-pow48.5%
neg-mul-148.5%
fma-define48.5%
pow248.5%
unpow348.5%
add-cube-cbrt48.7%
associate-*r*48.7%
*-commutative48.7%
Applied egg-rr48.7%
unpow-148.7%
associate-/l*48.7%
Simplified48.7%
Taylor expanded in a around 0 11.4%
associate-*r/11.4%
distribute-rgt1-in11.4%
metadata-eval11.4%
mul0-lft11.4%
metadata-eval11.4%
Simplified11.4%
Taylor expanded in a around 0 11.4%
herbie shell --seed 2024148
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))