
(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 -8e+158)
(- (/ c b) (/ b a))
(if (<= b 1.9e-86)
(/ (- (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 <= -8e+158) {
tmp = (c / b) - (b / a);
} else if (b <= 1.9e-86) {
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 <= (-8d+158)) then
tmp = (c / b) - (b / a)
else if (b <= 1.9d-86) 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 <= -8e+158) {
tmp = (c / b) - (b / a);
} else if (b <= 1.9e-86) {
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 <= -8e+158: tmp = (c / b) - (b / a) elif b <= 1.9e-86: 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 <= -8e+158) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.9e-86) 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 <= -8e+158) tmp = (c / b) - (b / a); elseif (b <= 1.9e-86) 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, -8e+158], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.9e-86], 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 -8 \cdot 10^{+158}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-86}:\\
\;\;\;\;\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 < -7.99999999999999962e158Initial program 39.4%
*-commutative39.4%
Simplified39.4%
Taylor expanded in b around -inf 94.8%
+-commutative94.8%
mul-1-neg94.8%
unsub-neg94.8%
Simplified94.8%
if -7.99999999999999962e158 < b < 1.9e-86Initial program 78.2%
if 1.9e-86 < b Initial program 17.6%
*-commutative17.6%
Simplified17.6%
Taylor expanded in b around inf 86.2%
mul-1-neg86.2%
distribute-neg-frac86.2%
Simplified86.2%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.18e+14)
(/ (- b) a)
(if (<= b 6.8e-82)
(* (/ 0.5 a) (+ b (sqrt (* -4.0 (* c a)))))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.18e+14) {
tmp = -b / a;
} else if (b <= 6.8e-82) {
tmp = (0.5 / a) * (b + sqrt((-4.0 * (c * 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.18d+14)) then
tmp = -b / a
else if (b <= 6.8d-82) then
tmp = (0.5d0 / a) * (b + sqrt(((-4.0d0) * (c * 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.18e+14) {
tmp = -b / a;
} else if (b <= 6.8e-82) {
tmp = (0.5 / a) * (b + Math.sqrt((-4.0 * (c * a))));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.18e+14: tmp = -b / a elif b <= 6.8e-82: tmp = (0.5 / a) * (b + math.sqrt((-4.0 * (c * a)))) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.18e+14) tmp = Float64(Float64(-b) / a); elseif (b <= 6.8e-82) tmp = Float64(Float64(0.5 / a) * Float64(b + sqrt(Float64(-4.0 * Float64(c * a))))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.18e+14) tmp = -b / a; elseif (b <= 6.8e-82) tmp = (0.5 / a) * (b + sqrt((-4.0 * (c * a)))); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.18e+14], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 6.8e-82], N[(N[(0.5 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.18 \cdot 10^{+14}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 6.8 \cdot 10^{-82}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(b + \sqrt{-4 \cdot \left(c \cdot a\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.18e14Initial program 66.9%
*-commutative66.9%
Simplified66.9%
Taylor expanded in b around -inf 90.4%
associate-*r/90.4%
mul-1-neg90.4%
Simplified90.4%
if -1.18e14 < b < 6.7999999999999995e-82Initial program 70.5%
*-commutative70.5%
Simplified70.5%
clear-num70.2%
associate-/r/70.3%
*-commutative70.3%
associate-/r*70.3%
metadata-eval70.3%
add-sqr-sqrt47.5%
sqrt-unprod69.6%
sqr-neg69.6%
sqrt-prod23.0%
add-sqr-sqrt62.1%
fma-neg62.1%
*-commutative62.1%
distribute-rgt-neg-in62.1%
*-commutative62.1%
distribute-rgt-neg-in62.1%
metadata-eval62.1%
Applied egg-rr62.1%
Taylor expanded in b around 0 62.0%
if 6.7999999999999995e-82 < b Initial program 16.9%
*-commutative16.9%
Simplified16.9%
Taylor expanded in b around inf 86.9%
mul-1-neg86.9%
distribute-neg-frac86.9%
Simplified86.9%
Final simplification79.5%
(FPCore (a b c)
:precision binary64
(if (<= b -1.18e+14)
(/ (- b) a)
(if (<= b 4.5e-86)
(/ (+ b (sqrt (* a (* c -4.0)))) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.18e+14) {
tmp = -b / a;
} else if (b <= 4.5e-86) {
tmp = (b + 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.18d+14)) then
tmp = -b / a
else if (b <= 4.5d-86) then
tmp = (b + 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.18e+14) {
tmp = -b / a;
} else if (b <= 4.5e-86) {
tmp = (b + 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.18e+14: tmp = -b / a elif b <= 4.5e-86: tmp = (b + 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.18e+14) tmp = Float64(Float64(-b) / a); elseif (b <= 4.5e-86) tmp = Float64(Float64(b + sqrt(Float64(a * Float64(c * -4.0)))) / 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 <= -1.18e+14) tmp = -b / a; elseif (b <= 4.5e-86) tmp = (b + 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.18e+14], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 4.5e-86], N[(N[(b + N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.18 \cdot 10^{+14}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-86}:\\
\;\;\;\;\frac{b + \sqrt{a \cdot \left(c \cdot -4\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.18e14Initial program 66.9%
*-commutative66.9%
Simplified66.9%
Taylor expanded in b around -inf 90.4%
associate-*r/90.4%
mul-1-neg90.4%
Simplified90.4%
if -1.18e14 < b < 4.4999999999999998e-86Initial program 71.0%
*-commutative71.0%
Simplified71.0%
add-cbrt-cube47.9%
pow347.9%
add-sqr-sqrt32.0%
sqrt-unprod47.9%
sqr-neg47.9%
sqrt-prod15.9%
add-sqr-sqrt43.2%
fma-neg43.2%
*-commutative43.2%
distribute-rgt-neg-in43.2%
*-commutative43.2%
distribute-rgt-neg-in43.2%
metadata-eval43.2%
Applied egg-rr43.2%
Taylor expanded in b around 0 43.1%
rem-cbrt-cube62.3%
+-commutative62.3%
*-commutative62.3%
associate-*l*62.3%
Applied egg-rr62.3%
if 4.4999999999999998e-86 < b Initial program 17.6%
*-commutative17.6%
Simplified17.6%
Taylor expanded in b around inf 86.2%
mul-1-neg86.2%
distribute-neg-frac86.2%
Simplified86.2%
Final simplification79.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.18e+14)
(/ (- b) a)
(if (<= b 4.6e-86)
(/ (- (sqrt (* c (* a -4.0))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.18e+14) {
tmp = -b / a;
} else if (b <= 4.6e-86) {
tmp = (sqrt((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 <= (-1.18d+14)) then
tmp = -b / a
else if (b <= 4.6d-86) then
tmp = (sqrt((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 <= -1.18e+14) {
tmp = -b / a;
} else if (b <= 4.6e-86) {
tmp = (Math.sqrt((c * (a * -4.0))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.18e+14: tmp = -b / a elif b <= 4.6e-86: tmp = (math.sqrt((c * (a * -4.0))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.18e+14) tmp = Float64(Float64(-b) / a); elseif (b <= 4.6e-86) tmp = Float64(Float64(sqrt(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 <= -1.18e+14) tmp = -b / a; elseif (b <= 4.6e-86) tmp = (sqrt((c * (a * -4.0))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.18e+14], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 4.6e-86], N[(N[(N[Sqrt[N[(c * N[(a * -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 -1.18 \cdot 10^{+14}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 4.6 \cdot 10^{-86}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.18e14Initial program 66.9%
*-commutative66.9%
Simplified66.9%
Taylor expanded in b around -inf 90.4%
associate-*r/90.4%
mul-1-neg90.4%
Simplified90.4%
if -1.18e14 < b < 4.59999999999999992e-86Initial program 71.0%
*-commutative71.0%
Simplified71.0%
Taylor expanded in b around 0 64.0%
*-commutative64.0%
*-commutative64.0%
associate-*r*64.0%
Simplified64.0%
if 4.59999999999999992e-86 < b Initial program 17.6%
*-commutative17.6%
Simplified17.6%
Taylor expanded in b around inf 86.2%
mul-1-neg86.2%
distribute-neg-frac86.2%
Simplified86.2%
Final simplification80.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-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 <= (-5d-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 <= -5e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-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 <= -5e-310) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 72.3%
*-commutative72.3%
Simplified72.3%
Taylor expanded in b around -inf 61.6%
+-commutative61.6%
mul-1-neg61.6%
unsub-neg61.6%
Simplified61.6%
if -4.999999999999985e-310 < b Initial program 26.8%
*-commutative26.8%
Simplified26.8%
Taylor expanded in b around inf 72.7%
mul-1-neg72.7%
distribute-neg-frac72.7%
Simplified72.7%
Final simplification67.6%
(FPCore (a b c) :precision binary64 (if (<= b -9e-309) (/ (- b) a) (/ 0.0 a)))
double code(double a, double b, double c) {
double tmp;
if (b <= -9e-309) {
tmp = -b / a;
} else {
tmp = 0.0 / a;
}
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 <= (-9d-309)) then
tmp = -b / a
else
tmp = 0.0d0 / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -9e-309) {
tmp = -b / a;
} else {
tmp = 0.0 / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9e-309: tmp = -b / a else: tmp = 0.0 / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9e-309) tmp = Float64(Float64(-b) / a); else tmp = Float64(0.0 / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -9e-309) tmp = -b / a; else tmp = 0.0 / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9e-309], N[((-b) / a), $MachinePrecision], N[(0.0 / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{-309}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{a}\\
\end{array}
\end{array}
if b < -9.0000000000000021e-309Initial program 71.8%
*-commutative71.8%
Simplified71.8%
Taylor expanded in b around -inf 62.5%
associate-*r/62.5%
mul-1-neg62.5%
Simplified62.5%
if -9.0000000000000021e-309 < b Initial program 27.9%
*-commutative27.9%
Simplified27.9%
add-sqr-sqrt25.4%
pow225.4%
pow1/225.4%
sqrt-pow125.4%
fma-neg25.4%
*-commutative25.4%
distribute-rgt-neg-in25.4%
*-commutative25.4%
distribute-rgt-neg-in25.4%
metadata-eval25.4%
metadata-eval25.4%
Applied egg-rr25.4%
div-inv25.4%
Applied egg-rr28.0%
Taylor expanded in c around 0 16.7%
distribute-rgt1-in16.7%
metadata-eval16.7%
mul0-lft16.7%
associate-*r/16.7%
metadata-eval16.7%
Simplified16.7%
Final simplification37.5%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) 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 <= -5e-310) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 72.3%
*-commutative72.3%
Simplified72.3%
Taylor expanded in b around -inf 61.5%
associate-*r/61.5%
mul-1-neg61.5%
Simplified61.5%
if -4.999999999999985e-310 < b Initial program 26.8%
*-commutative26.8%
Simplified26.8%
Taylor expanded in b around inf 72.7%
mul-1-neg72.7%
distribute-neg-frac72.7%
Simplified72.7%
Final simplification67.6%
(FPCore (a b c) :precision binary64 (/ 0.0 a))
double code(double a, double b, double c) {
return 0.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 = 0.0d0 / a
end function
public static double code(double a, double b, double c) {
return 0.0 / a;
}
def code(a, b, c): return 0.0 / a
function code(a, b, c) return Float64(0.0 / a) end
function tmp = code(a, b, c) tmp = 0.0 / a; end
code[a_, b_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{0}{a}
\end{array}
Initial program 47.8%
*-commutative47.8%
Simplified47.8%
add-sqr-sqrt46.3%
pow246.3%
pow1/246.3%
sqrt-pow146.3%
fma-neg46.4%
*-commutative46.4%
distribute-rgt-neg-in46.4%
*-commutative46.4%
distribute-rgt-neg-in46.4%
metadata-eval46.4%
metadata-eval46.4%
Applied egg-rr46.4%
div-inv46.3%
Applied egg-rr45.1%
Taylor expanded in c around 0 10.4%
distribute-rgt1-in10.4%
metadata-eval10.4%
mul0-lft10.4%
associate-*r/10.4%
metadata-eval10.4%
Simplified10.4%
Final simplification10.4%
herbie shell --seed 2023308
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))