
(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 -1e+144)
(/ (* b_2 -2.0) a)
(if (<= b_2 1.2e-34)
(/ (- (sqrt (fma (- c) a (* b_2 b_2))) b_2) a)
(/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e+144) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.2e-34) {
tmp = (sqrt(fma(-c, a, (b_2 * b_2))) - b_2) / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1e+144) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 1.2e-34) tmp = Float64(Float64(sqrt(fma(Float64(-c), a, Float64(b_2 * b_2))) - b_2) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1e+144], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 1.2e-34], N[(N[(N[Sqrt[N[((-c) * a + N[(b$95$2 * b$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1 \cdot 10^{+144}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq 1.2 \cdot 10^{-34}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -1.00000000000000002e144Initial program 32.4%
+-commutative32.4%
unsub-neg32.4%
Simplified32.4%
Taylor expanded in b_2 around -inf 97.8%
*-commutative97.8%
Simplified97.8%
if -1.00000000000000002e144 < b_2 < 1.19999999999999996e-34Initial program 84.2%
+-commutative84.2%
unsub-neg84.2%
Simplified84.2%
sub-neg84.2%
+-commutative84.2%
*-commutative84.2%
distribute-lft-neg-in84.2%
fma-def84.3%
Applied egg-rr84.3%
if 1.19999999999999996e-34 < b_2 Initial program 14.3%
+-commutative14.3%
unsub-neg14.3%
Simplified14.3%
Taylor expanded in b_2 around inf 89.9%
associate-*r/89.9%
Applied egg-rr89.9%
Final simplification88.6%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -3.2e+133)
(/ (* b_2 -2.0) a)
(if (<= b_2 1.45e-34)
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
(/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.2e+133) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.45e-34) {
tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a;
} else {
tmp = (c * -0.5) / 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+133)) then
tmp = (b_2 * (-2.0d0)) / a
else if (b_2 <= 1.45d-34) then
tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a
else
tmp = (c * (-0.5d0)) / 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+133) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.45e-34) {
tmp = (Math.sqrt(((b_2 * b_2) - (a * c))) - b_2) / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.2e+133: tmp = (b_2 * -2.0) / a elif b_2 <= 1.45e-34: tmp = (math.sqrt(((b_2 * b_2) - (a * c))) - b_2) / a else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.2e+133) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 1.45e-34) tmp = Float64(Float64(sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c))) - b_2) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.2e+133) tmp = (b_2 * -2.0) / a; elseif (b_2 <= 1.45e-34) tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.2e+133], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 1.45e-34], N[(N[(N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3.2 \cdot 10^{+133}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq 1.45 \cdot 10^{-34}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -3.19999999999999997e133Initial program 32.4%
+-commutative32.4%
unsub-neg32.4%
Simplified32.4%
Taylor expanded in b_2 around -inf 97.8%
*-commutative97.8%
Simplified97.8%
if -3.19999999999999997e133 < b_2 < 1.4500000000000001e-34Initial program 84.2%
+-commutative84.2%
unsub-neg84.2%
Simplified84.2%
if 1.4500000000000001e-34 < b_2 Initial program 14.3%
+-commutative14.3%
unsub-neg14.3%
Simplified14.3%
Taylor expanded in b_2 around inf 89.9%
associate-*r/89.9%
Applied egg-rr89.9%
Final simplification88.6%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.2e-84) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))) (if (<= b_2 2.7e-33) (/ (- (sqrt (* a (- c))) b_2) a) (/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.2e-84) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 2.7e-33) {
tmp = (sqrt((a * -c)) - b_2) / a;
} else {
tmp = (c * -0.5) / 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 <= (-1.2d-84)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else if (b_2 <= 2.7d-33) then
tmp = (sqrt((a * -c)) - b_2) / a
else
tmp = (c * (-0.5d0)) / b_2
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.2e-84) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 2.7e-33) {
tmp = (Math.sqrt((a * -c)) - b_2) / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.2e-84: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) elif b_2 <= 2.7e-33: tmp = (math.sqrt((a * -c)) - b_2) / a else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.2e-84) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 2.7e-33) tmp = Float64(Float64(sqrt(Float64(a * Float64(-c))) - b_2) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.2e-84) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); elseif (b_2 <= 2.7e-33) tmp = (sqrt((a * -c)) - b_2) / a; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.2e-84], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 2.7e-33], N[(N[(N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.2 \cdot 10^{-84}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 2.7 \cdot 10^{-33}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -1.20000000000000009e-84Initial program 64.6%
+-commutative64.6%
unsub-neg64.6%
Simplified64.6%
Taylor expanded in b_2 around -inf 87.3%
if -1.20000000000000009e-84 < b_2 < 2.7000000000000001e-33Initial program 78.3%
+-commutative78.3%
unsub-neg78.3%
Simplified78.3%
Taylor expanded in b_2 around 0 73.9%
mul-1-neg73.9%
distribute-rgt-neg-out73.9%
Simplified73.9%
if 2.7000000000000001e-33 < b_2 Initial program 14.3%
+-commutative14.3%
unsub-neg14.3%
Simplified14.3%
Taylor expanded in b_2 around inf 89.9%
associate-*r/89.9%
Applied egg-rr89.9%
Final simplification84.6%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-312) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))) (/ (* c -0.5) b_2)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-312) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else {
tmp = (c * -0.5) / 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-312)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else
tmp = (c * (-0.5d0)) / 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-312) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-312: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-312) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e-312) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-312], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-312}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -5.0000000000022e-312Initial program 70.6%
+-commutative70.6%
unsub-neg70.6%
Simplified70.6%
Taylor expanded in b_2 around -inf 69.9%
if -5.0000000000022e-312 < b_2 Initial program 29.5%
+-commutative29.5%
unsub-neg29.5%
Simplified29.5%
Taylor expanded in b_2 around inf 69.4%
associate-*r/69.4%
Applied egg-rr69.4%
Final simplification69.7%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-312) (/ (- b_2) a) (* -0.5 (/ c b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-312) {
tmp = -b_2 / a;
} else {
tmp = -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-312)) then
tmp = -b_2 / a
else
tmp = (-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-312) {
tmp = -b_2 / a;
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-312: tmp = -b_2 / a else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-312) tmp = Float64(Float64(-b_2) / a); else tmp = 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-312) tmp = -b_2 / a; else tmp = -0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-312], N[((-b$95$2) / a), $MachinePrecision], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-312}:\\
\;\;\;\;\frac{-b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -5.0000000000022e-312Initial program 70.6%
+-commutative70.6%
unsub-neg70.6%
Simplified70.6%
Taylor expanded in b_2 around 0 39.4%
mul-1-neg39.4%
distribute-rgt-neg-out39.4%
Simplified39.4%
Taylor expanded in c around 0 23.3%
neg-mul-123.3%
distribute-neg-frac23.3%
Simplified23.3%
if -5.0000000000022e-312 < b_2 Initial program 29.5%
+-commutative29.5%
unsub-neg29.5%
Simplified29.5%
Taylor expanded in b_2 around inf 69.4%
Final simplification46.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-312) (* b_2 (/ -2.0 a)) (* -0.5 (/ c b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-312) {
tmp = b_2 * (-2.0 / a);
} else {
tmp = -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-312)) then
tmp = b_2 * ((-2.0d0) / a)
else
tmp = (-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-312) {
tmp = b_2 * (-2.0 / a);
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-312: tmp = b_2 * (-2.0 / a) else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-312) tmp = Float64(b_2 * Float64(-2.0 / a)); else tmp = 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-312) tmp = b_2 * (-2.0 / a); else tmp = -0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-312], N[(b$95$2 * N[(-2.0 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-312}:\\
\;\;\;\;b_2 \cdot \frac{-2}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -5.0000000000022e-312Initial program 70.6%
+-commutative70.6%
unsub-neg70.6%
Simplified70.6%
sub-neg70.6%
+-commutative70.6%
add-sqr-sqrt54.7%
hypot-def67.6%
*-commutative67.6%
distribute-rgt-neg-in67.6%
Applied egg-rr67.6%
Taylor expanded in b_2 around -inf 68.4%
associate-*r/68.4%
associate-/l*68.2%
Simplified68.2%
associate-/r/68.2%
Applied egg-rr68.2%
if -5.0000000000022e-312 < b_2 Initial program 29.5%
+-commutative29.5%
unsub-neg29.5%
Simplified29.5%
Taylor expanded in b_2 around inf 69.4%
Final simplification68.8%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-312) (* b_2 (/ -2.0 a)) (/ (* c -0.5) b_2)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-312) {
tmp = b_2 * (-2.0 / a);
} else {
tmp = (c * -0.5) / 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-312)) then
tmp = b_2 * ((-2.0d0) / a)
else
tmp = (c * (-0.5d0)) / 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-312) {
tmp = b_2 * (-2.0 / a);
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-312: tmp = b_2 * (-2.0 / a) else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-312) tmp = Float64(b_2 * Float64(-2.0 / a)); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e-312) tmp = b_2 * (-2.0 / a); else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-312], N[(b$95$2 * N[(-2.0 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-312}:\\
\;\;\;\;b_2 \cdot \frac{-2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -5.0000000000022e-312Initial program 70.6%
+-commutative70.6%
unsub-neg70.6%
Simplified70.6%
sub-neg70.6%
+-commutative70.6%
add-sqr-sqrt54.7%
hypot-def67.6%
*-commutative67.6%
distribute-rgt-neg-in67.6%
Applied egg-rr67.6%
Taylor expanded in b_2 around -inf 68.4%
associate-*r/68.4%
associate-/l*68.2%
Simplified68.2%
associate-/r/68.2%
Applied egg-rr68.2%
if -5.0000000000022e-312 < b_2 Initial program 29.5%
+-commutative29.5%
unsub-neg29.5%
Simplified29.5%
Taylor expanded in b_2 around inf 69.4%
associate-*r/69.4%
Applied egg-rr69.4%
Final simplification68.8%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-312) (/ (* b_2 -2.0) a) (/ (* c -0.5) b_2)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-312) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = (c * -0.5) / 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-312)) then
tmp = (b_2 * (-2.0d0)) / a
else
tmp = (c * (-0.5d0)) / 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-312) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-312: tmp = (b_2 * -2.0) / a else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-312) tmp = Float64(Float64(b_2 * -2.0) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e-312) tmp = (b_2 * -2.0) / a; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-312], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-312}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -5.0000000000022e-312Initial program 70.6%
+-commutative70.6%
unsub-neg70.6%
Simplified70.6%
Taylor expanded in b_2 around -inf 68.4%
*-commutative68.4%
Simplified68.4%
if -5.0000000000022e-312 < b_2 Initial program 29.5%
+-commutative29.5%
unsub-neg29.5%
Simplified29.5%
Taylor expanded in b_2 around inf 69.4%
associate-*r/69.4%
Applied egg-rr69.4%
Final simplification68.9%
(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 50.2%
+-commutative50.2%
unsub-neg50.2%
Simplified50.2%
Taylor expanded in b_2 around 0 31.5%
mul-1-neg31.5%
distribute-rgt-neg-out31.5%
Simplified31.5%
Taylor expanded in c around 0 13.1%
neg-mul-113.1%
distribute-neg-frac13.1%
Simplified13.1%
Final simplification13.1%
herbie shell --seed 2023238
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))