
(FPCore (a b_2 c) :precision binary64 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 - Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 - math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b_2 c) :precision binary64 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 - Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 - math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\end{array}
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -7.5e-96)
(/ (* -0.5 c) b_2)
(if (<= b_2 3e+45)
(/ (- (- b_2) (sqrt (fma (- c) a (* b_2 b_2)))) a)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -7.5e-96) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 3e+45) {
tmp = (-b_2 - sqrt(fma(-c, a, (b_2 * b_2)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -7.5e-96) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 3e+45) tmp = Float64(Float64(Float64(-b_2) - sqrt(fma(Float64(-c), a, Float64(b_2 * b_2)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -7.5e-96], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 3e+45], N[(N[((-b$95$2) - N[Sqrt[N[((-c) * a + N[(b$95$2 * b$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -7.5 \cdot 10^{-96}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 3 \cdot 10^{+45}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -7.5e-96Initial program 14.1%
Taylor expanded in b_2 around -inf 85.4%
associate-*r/85.4%
Simplified85.4%
if -7.5e-96 < b_2 < 3.00000000000000011e45Initial program 77.2%
sub-neg77.2%
+-commutative77.2%
*-commutative77.2%
distribute-lft-neg-in77.2%
fma-def77.3%
Applied egg-rr77.3%
if 3.00000000000000011e45 < b_2 Initial program 68.9%
Taylor expanded in b_2 around inf 93.5%
Final simplification85.2%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -3.2e-95)
(/ (* -0.5 c) b_2)
(if (<= b_2 3e+45)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.2e-95) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 3e+45) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-3.2d-95)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 3d+45) then
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.2e-95) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 3e+45) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.2e-95: tmp = (-0.5 * c) / b_2 elif b_2 <= 3e+45: tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (c * a)))) / a else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.2e-95) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 3e+45) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.2e-95) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 3e+45) tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.2e-95], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 3e+45], N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3.2 \cdot 10^{-95}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 3 \cdot 10^{+45}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -3.1999999999999997e-95Initial program 14.1%
Taylor expanded in b_2 around -inf 85.4%
associate-*r/85.4%
Simplified85.4%
if -3.1999999999999997e-95 < b_2 < 3.00000000000000011e45Initial program 77.2%
if 3.00000000000000011e45 < b_2 Initial program 68.9%
Taylor expanded in b_2 around inf 93.5%
Final simplification85.2%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -3.1e-95)
(/ (* -0.5 c) b_2)
(if (<= b_2 9.5e-95)
(/ (- (- b_2) (sqrt (* c (- a)))) a)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.1e-95) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 9.5e-95) {
tmp = (-b_2 - sqrt((c * -a))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-3.1d-95)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 9.5d-95) then
tmp = (-b_2 - sqrt((c * -a))) / a
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.1e-95) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 9.5e-95) {
tmp = (-b_2 - Math.sqrt((c * -a))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.1e-95: tmp = (-0.5 * c) / b_2 elif b_2 <= 9.5e-95: tmp = (-b_2 - math.sqrt((c * -a))) / a else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.1e-95) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 9.5e-95) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(c * Float64(-a)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.1e-95) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 9.5e-95) tmp = (-b_2 - sqrt((c * -a))) / a; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.1e-95], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 9.5e-95], N[(N[((-b$95$2) - N[Sqrt[N[(c * (-a)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3.1 \cdot 10^{-95}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 9.5 \cdot 10^{-95}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{c \cdot \left(-a\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -3.09999999999999992e-95Initial program 14.1%
Taylor expanded in b_2 around -inf 85.4%
associate-*r/85.4%
Simplified85.4%
if -3.09999999999999992e-95 < b_2 < 9.49999999999999998e-95Initial program 71.1%
Taylor expanded in b_2 around 0 67.6%
mul-1-neg67.6%
distribute-rgt-neg-out67.6%
Simplified67.6%
if 9.49999999999999998e-95 < b_2 Initial program 74.3%
Taylor expanded in b_2 around inf 85.1%
Final simplification81.6%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -3.2e-95)
(/ (* -0.5 c) b_2)
(if (<= b_2 1.95e-94)
(/ (- (sqrt (* c (- a)))) a)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.2e-95) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1.95e-94) {
tmp = -sqrt((c * -a)) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-3.2d-95)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 1.95d-94) then
tmp = -sqrt((c * -a)) / a
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.2e-95) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1.95e-94) {
tmp = -Math.sqrt((c * -a)) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.2e-95: tmp = (-0.5 * c) / b_2 elif b_2 <= 1.95e-94: tmp = -math.sqrt((c * -a)) / a else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.2e-95) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 1.95e-94) tmp = Float64(Float64(-sqrt(Float64(c * Float64(-a)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.2e-95) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 1.95e-94) tmp = -sqrt((c * -a)) / a; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.2e-95], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 1.95e-94], N[((-N[Sqrt[N[(c * (-a)), $MachinePrecision]], $MachinePrecision]) / a), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3.2 \cdot 10^{-95}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 1.95 \cdot 10^{-94}:\\
\;\;\;\;\frac{-\sqrt{c \cdot \left(-a\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -3.1999999999999997e-95Initial program 14.1%
Taylor expanded in b_2 around -inf 85.4%
associate-*r/85.4%
Simplified85.4%
if -3.1999999999999997e-95 < b_2 < 1.9500000000000001e-94Initial program 71.1%
prod-diff70.5%
*-commutative70.5%
fma-neg70.5%
prod-diff70.5%
*-commutative70.5%
fma-neg70.5%
associate-+l+70.5%
*-commutative70.5%
fma-udef70.5%
distribute-lft-neg-in70.5%
*-commutative70.5%
distribute-rgt-neg-in70.5%
fma-def70.5%
*-commutative70.5%
fma-udef70.5%
distribute-lft-neg-in70.5%
*-commutative70.5%
distribute-rgt-neg-in70.5%
fma-def70.5%
Applied egg-rr70.5%
*-commutative70.5%
count-270.5%
*-commutative70.5%
Simplified70.5%
Taylor expanded in b_2 around 0 66.2%
mul-1-neg66.2%
distribute-lft1-in66.2%
metadata-eval66.2%
mul0-lft66.8%
metadata-eval66.8%
neg-sub066.8%
distribute-lft-neg-in66.8%
*-commutative66.8%
Simplified66.8%
if 1.9500000000000001e-94 < b_2 Initial program 74.3%
Taylor expanded in b_2 around inf 85.1%
Final simplification81.5%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-310) (/ (* -0.5 c) b_2) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-5d-310)) then
tmp = ((-0.5d0) * c) / b_2
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-310: tmp = (-0.5 * c) / b_2 else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-310) tmp = Float64(Float64(-0.5 * c) / b_2); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e-310) tmp = (-0.5 * c) / b_2; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-310], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -4.999999999999985e-310Initial program 23.3%
Taylor expanded in b_2 around -inf 74.2%
associate-*r/74.2%
Simplified74.2%
if -4.999999999999985e-310 < b_2 Initial program 74.4%
Taylor expanded in b_2 around inf 68.8%
Final simplification71.5%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -0.0037) (* 0.5 (/ c b_2)) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -0.0037) {
tmp = 0.5 * (c / b_2);
} else {
tmp = -b_2 / a;
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-0.0037d0)) then
tmp = 0.5d0 * (c / b_2)
else
tmp = -b_2 / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -0.0037) {
tmp = 0.5 * (c / b_2);
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -0.0037: tmp = 0.5 * (c / b_2) else: tmp = -b_2 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -0.0037) tmp = Float64(0.5 * Float64(c / b_2)); else tmp = Float64(Float64(-b_2) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -0.0037) tmp = 0.5 * (c / b_2); else tmp = -b_2 / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -0.0037], N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -0.0037:\\
\;\;\;\;0.5 \cdot \frac{c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\
\end{array}
\end{array}
if b_2 < -0.0037000000000000002Initial program 12.6%
*-un-lft-identity12.6%
add-sqr-sqrt4.9%
times-frac4.9%
add-sqr-sqrt4.6%
sqrt-unprod4.5%
sqr-neg4.5%
sqrt-prod0.0%
add-sqr-sqrt3.3%
sub-neg3.3%
add-sqr-sqrt3.1%
hypot-def3.1%
*-commutative3.1%
distribute-rgt-neg-in3.1%
Applied egg-rr3.1%
associate-*l/3.1%
*-lft-identity3.1%
Simplified3.1%
Taylor expanded in b_2 around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt23.0%
associate-*r*23.0%
metadata-eval23.0%
associate-*r/23.0%
Simplified23.0%
if -0.0037000000000000002 < b_2 Initial program 68.7%
Taylor expanded in b_2 around 0 42.3%
mul-1-neg42.3%
distribute-rgt-neg-out42.3%
Simplified42.3%
Taylor expanded in b_2 around inf 25.4%
mul-1-neg25.4%
distribute-frac-neg25.4%
Simplified25.4%
Final simplification24.6%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-310) (/ (* -0.5 c) b_2) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = -b_2 / a;
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-5d-310)) then
tmp = ((-0.5d0) * c) / b_2
else
tmp = -b_2 / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-310: tmp = (-0.5 * c) / b_2 else: tmp = -b_2 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-310) tmp = Float64(Float64(-0.5 * c) / b_2); else tmp = Float64(Float64(-b_2) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e-310) tmp = (-0.5 * c) / b_2; else tmp = -b_2 / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-310], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\
\end{array}
\end{array}
if b_2 < -4.999999999999985e-310Initial program 23.3%
Taylor expanded in b_2 around -inf 74.2%
associate-*r/74.2%
Simplified74.2%
if -4.999999999999985e-310 < b_2 Initial program 74.4%
Taylor expanded in b_2 around 0 40.7%
mul-1-neg40.7%
distribute-rgt-neg-out40.7%
Simplified40.7%
Taylor expanded in b_2 around inf 31.7%
mul-1-neg31.7%
distribute-frac-neg31.7%
Simplified31.7%
Final simplification52.5%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -3e-307) (/ (* -0.5 c) b_2) (/ (* b_2 -2.0) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3e-307) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = (b_2 * -2.0) / a;
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-3d-307)) then
tmp = ((-0.5d0) * c) / b_2
else
tmp = (b_2 * (-2.0d0)) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3e-307) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = (b_2 * -2.0) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3e-307: tmp = (-0.5 * c) / b_2 else: tmp = (b_2 * -2.0) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3e-307) tmp = Float64(Float64(-0.5 * c) / b_2); else tmp = Float64(Float64(b_2 * -2.0) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3e-307) tmp = (-0.5 * c) / b_2; else tmp = (b_2 * -2.0) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3e-307], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3 \cdot 10^{-307}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\end{array}
\end{array}
if b_2 < -2.9999999999999999e-307Initial program 23.3%
Taylor expanded in b_2 around -inf 74.2%
associate-*r/74.2%
Simplified74.2%
if -2.9999999999999999e-307 < b_2 Initial program 74.4%
Taylor expanded in b_2 around inf 68.6%
*-commutative68.6%
Simplified68.6%
Final simplification71.4%
(FPCore (a b_2 c) :precision binary64 (/ (- b_2) a))
double code(double a, double b_2, double c) {
return -b_2 / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = -b_2 / a
end function
public static double code(double a, double b_2, double c) {
return -b_2 / a;
}
def code(a, b_2, c): return -b_2 / a
function code(a, b_2, c) return Float64(Float64(-b_2) / a) end
function tmp = code(a, b_2, c) tmp = -b_2 / a; end
code[a_, b$95$2_, c_] := N[((-b$95$2) / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{-b_2}{a}
\end{array}
Initial program 49.4%
Taylor expanded in b_2 around 0 29.4%
mul-1-neg29.4%
distribute-rgt-neg-out29.4%
Simplified29.4%
Taylor expanded in b_2 around inf 17.6%
mul-1-neg17.6%
distribute-frac-neg17.6%
Simplified17.6%
Final simplification17.6%
herbie shell --seed 2023279
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))